@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
@@ -1,17 +1,17 @@
1
- /**
2
- * RFC-6902 patch application (dev-time only). Every package's convert ends
3
- * in {@link finalizeConvert}, which applies the Smithy ops (`/shapes`,
4
- * `/metadata`, `/smithy`) of `patches/<model>/` to the freshly converted
5
- * model, under the names the spec gives, then the deferred names; so
6
- * `.generated-specs` is the patched model and generate never patches.
7
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
8
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
9
9
  import * as fs from "node:fs/promises";
10
10
  import * as path from "node:path";
11
11
  import { applyOperation, isStaleTargetError, } from "../json-patch.js";
12
12
  import { diffModels } from "./model-diff.js";
13
13
  import { applyDeferredRename, RENAME_METADATA_KEY, verbNounSmithyModel, } from "./rewrite-operation-ids.js";
14
- /** Smithy-model JSON pointers — OpenAPI has no `/shapes` tree. */
14
+
15
15
  export const isSmithyPatchPath = (pointer) => pointer.startsWith("/shapes") || pointer.startsWith("/metadata") || pointer.startsWith("/smithy");
16
16
  const exists = async (p) => {
17
17
  try {
@@ -22,19 +22,19 @@ const exists = async (p) => {
22
22
  return false;
23
23
  }
24
24
  };
25
- /**
26
- * Leave patches out of one convert run (dev-time only; the seam
27
- * `scripts/patches.ts audit` uses to find patches the spec no longer
28
- * needs). Comma-separated entries:
29
- *
30
- * all skip every patch file
31
- * <file> skip a file — its basename, or a path suffix
32
- * (`svc/a.json`) when basenames repeat
33
- * <file>:<index> skip one op of a file, by its index in `patches`
34
- *
35
- * Like `DISTILLED_SPECS_LOCAL`, it lives in one command's environment: a
36
- * model written under it is announced on stderr and must not be committed.
37
- */
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
38
  export const SKIP_PATCHES_ENV = "DISTILLED_SKIP_PATCHES";
39
39
  const parseSkipList = () => {
40
40
  const raw = (process.env[SKIP_PATCHES_ENV] ?? "").trim();
@@ -81,11 +81,11 @@ const skipsOp = (list, file, index) => {
81
81
  }
82
82
  return false;
83
83
  };
84
- /**
85
- * RFC-6902 files in `dir`: every `*.json`, `*.manual.json` last (those
86
- * usually target post-rename shape names). Missing dir → `[]`. Files named
87
- * by {@link SKIP_PATCHES_ENV} are left out.
88
- */
84
+
85
+
86
+
87
+
88
+
89
89
  export const listRfc6902PatchFiles = async (dir) => {
90
90
  if (!(await exists(dir)))
91
91
  return [];
@@ -140,12 +140,12 @@ export const applyRfc6902Files = async (target, files, opts = {}) => {
140
140
  }
141
141
  return result;
142
142
  };
143
- /**
144
- * An RFC-6902 `move` that renames an operation shape leaves the service's
145
- * `operations` list pointing at the old id. Drop entries whose target no
146
- * longer exists and append operation shapes the list is missing, keeping
147
- * the existing order. Returns the number of services whose list changed.
148
- */
143
+
144
+
145
+
146
+
147
+
148
+
149
149
  export const syncServiceOperations = (model) => {
150
150
  const shapes = model.shapes ?? {};
151
151
  const opIds = Object.keys(shapes).filter((id) => shapes[id]?.type === "operation");
@@ -164,12 +164,12 @@ export const syncServiceOperations = (model) => {
164
164
  }
165
165
  return changed;
166
166
  };
167
- /**
168
- * Every `target` in a Smithy model must resolve to a shape or a prelude
169
- * (`smithy.api#…`) id. Returns the dangling ones as `"<owner> → <target>"`.
170
- * A convert that produces any is broken — generate would emit references
171
- * to types that do not exist.
172
- */
167
+
168
+
169
+
170
+
171
+
172
+
173
173
  export const danglingTargets = (model) => {
174
174
  const shapes = model.shapes ?? {};
175
175
  const ids = new Set(Object.keys(shapes));
@@ -214,12 +214,12 @@ const loadSmithyPatches = async (patchesDir, dir) => {
214
214
  }
215
215
  return out;
216
216
  };
217
- /**
218
- * One model through the finalize steps: Smithy patches, verbNoun names,
219
- * the package's transform, the service operation list, and the reference
220
- * check. `skip` leaves out a patch file (`key`) or one of its ops
221
- * (`key:index`); `quiet` silences the progress lines for audit re-runs.
222
- */
217
+
218
+
219
+
220
+
221
+
222
+
223
223
  const finalizeModel = (model, resource, patches, o, skip, quiet) => {
224
224
  const log = quiet ? () => { } : console.log;
225
225
  const deferred = model.metadata?.[RENAME_METADATA_KEY];
@@ -316,20 +316,20 @@ const finalizeModel = (model, resource, patches, o, skip, quiet) => {
316
316
  return { ok: true, model };
317
317
  };
318
318
  const modelText = (model) => `${JSON.stringify(model, null, 2)}\n`;
319
- /**
320
- * Last step of every convert: Smithy RFC-6902 patches, then verbNoun
321
- * operation names, then an optional model transform, then a reference
322
- * check. Writes models back so `.generated-specs` is what generate
323
- * compiles. `outDir` may be nested (GCP `stable/` / `unstable/`).
324
- *
325
- * Input must be FRESHLY converted models. Smithy patches are `move`/`add`
326
- * ops that are not idempotent, and a `transform` may not be either, so
327
- * running this over a model that already went through it is an error —
328
- * re-run the package's `convert` instead.
329
- *
330
- * Under {@link PATCH_AUDIT_ENV} it also judges the requested patch files
331
- * in memory (see `./patch-audit.ts`).
332
- */
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
333
  export const finalizeConvert = async (o) => {
334
334
  const specsRoot = path.resolve(o.root, ".generated-specs");
335
335
  const specsDir = path.resolve(o.root, o.outDir ?? ".generated-specs");
@@ -389,12 +389,12 @@ export const finalizeConvert = async (o) => {
389
389
  throw new Error(`finalizeConvert: ${broken.length} model(s) reference shapes that do not exist:\n ${broken.join("\n ")}`);
390
390
  }
391
391
  };
392
- /**
393
- * Path of a JSON file finalizeConvert adds each model's deferred rename to
394
- * (`{ <model>: { <upstream id>: <final id> } }`). Set by
395
- * `pnpm patches:names`, which tells a patch author the upstream name of a
396
- * shape they see in `.generated-specs`.
397
- */
392
+
393
+
394
+
395
+
396
+
397
+
398
398
  export const RENAME_MAP_ENV = "DISTILLED_RENAME_MAP";
399
399
  const recordRename = (resource, rename) => {
400
400
  const file = process.env[RENAME_MAP_ENV];
@@ -406,17 +406,17 @@ const recordRename = (resource, rename) => {
406
406
  };
407
407
  // ---------------------------------------------------------------------------
408
408
  // in-memory patch audit
409
- /**
410
- * Path of a JSON request (`{ keys: string[], ops: boolean }`) asking
411
- * finalizeConvert to judge those patch files in memory. Set only by
412
- * `pnpm patches:audit` on a scratch copy of the package; the models it
413
- * writes are the normal, fully patched ones.
414
- *
415
- * Each verdict is printed to stdout as one line, {@link PATCH_AUDIT_MARKER}
416
- * followed by JSON. A requested key no finalizeConvert call owns (its ops
417
- * are applied somewhere else, e.g. before conversion) gets no line, and the
418
- * audit judges it by re-running convert.
419
- */
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
420
  export const PATCH_AUDIT_ENV = "DISTILLED_PATCH_AUDIT";
421
421
  export const PATCH_AUDIT_MARKER = "@@distilled-patch-audit ";
422
422
  const readAuditRequest = async () => {
@@ -464,9 +464,9 @@ const auditModel = (audit, model, resource, text, patches, o, baseline) => {
464
464
  emitVerdict({ key: p.key, model, verdict, deadOps });
465
465
  }
466
466
  };
467
- /**
468
- * Metadata marker stamped by {@link finalizeConvert}. Guards against a
469
- * second pass over the same file (see the note on finalizeConvert).
470
- */
467
+
468
+
469
+
470
+
471
471
  export const FINALIZED_KEY = "distilled.finalized";
472
472
  //# sourceMappingURL=patches.js.map
@@ -1,15 +1,15 @@
1
1
  import { isForwardRef } from "./graph.js";
2
- /**
3
- * Smithy prelude scalar baselines + reference resolvers for the SDK
4
- * generators (dev-time only).
5
- *
6
- * The JSON flavor maps timestamps/blobs to plain strings — the baseline for
7
- * SDKs whose wire format is JSON-over-docs (cloudflare). Generators with
8
- * richer models (AWS) emit real timestamp/blob schemas themselves and only
9
- * fall back here for untyped scalars.
10
- */
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
11
  import { isPrelude, local } from "./naming.js";
12
- /** Prelude shape → schema expression (JSON-wire flavor). */
12
+
13
13
  export const JSON_PRELUDE = {
14
14
  String: "S.String",
15
15
  Boolean: "S.Boolean",
@@ -24,7 +24,7 @@ export const JSON_PRELUDE = {
24
24
  Document: "S.Unknown",
25
25
  Unit: "S.Struct({})",
26
26
  };
27
- /** TypeScript type for each prelude shape, mirroring {@link JSON_PRELUDE}. */
27
+
28
28
  export const TS_JSON_PRELUDE = {
29
29
  String: "string",
30
30
  Boolean: "boolean",
@@ -39,10 +39,10 @@ export const TS_JSON_PRELUDE = {
39
39
  Document: "unknown",
40
40
  Unit: "{}",
41
41
  };
42
- /**
43
- * Schema reference resolver: prelude shapes map through the prelude table,
44
- * forward references (including into cycles) wrap in `S.suspend`.
45
- */
42
+
43
+
44
+
45
+
46
46
  export const makeSchemaRef = (prelude, indexOf) => (target, selfIdx) => {
47
47
  if (isPrelude(target))
48
48
  return prelude[local(target)] ?? "S.Unknown";
@@ -52,9 +52,9 @@ export const makeSchemaRef = (prelude, indexOf) => (target, selfIdx) => {
52
52
  }
53
53
  return name;
54
54
  };
55
- /**
56
- * TypeScript type reference resolver. Named shapes all get an emitted
57
- * interface / type alias, so forward references are always fine.
58
- */
55
+
56
+
57
+
58
+
59
59
  export const makeTsRef = (tsPrelude) => (target) => isPrelude(target) ? (tsPrelude[local(target)] ?? "unknown") : local(target);
60
60
  //# sourceMappingURL=prelude.js.map
@@ -0,0 +1,21 @@
1
+ type Node = {
2
+ readonly type: string;
3
+ readonly start: number;
4
+ readonly end: number;
5
+ } & Record<string, unknown>;
6
+ /** Value-position identifier names under `node` (type annotations, keys and member names excluded). */
7
+ export declare const valueRefs: (node: unknown, out: Set<string>, parent?: Node, parentKey?: string) => Set<string>;
8
+ export declare const privatizeSchemas: (code: string, filename?: string) => {
9
+ code: string;
10
+ privatized: number;
11
+ removed: number;
12
+ };
13
+ /**
14
+ * `import * as X` whose namespace is used only in type positions becomes
15
+ * `import type * as X`. The generator's `oxlint --fix` otherwise deletes it
16
+ * as unused once the schema consts that used it as a value are gone, and the
17
+ * types that still name it stop compiling.
18
+ */
19
+ export declare const typeOnlyNamespaceImports: (code: string, filename?: string) => string;
20
+ export {};
21
+ //# sourceMappingURL=privatize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privatize.d.ts","sourceRoot":"","sources":["../../src/codegen/privatize.ts"],"names":[],"mappings":"AAiBA,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAC1F,MAAM,EACN,OAAO,CACR,CAAC;AAKF,uGAAuG;AACvG,eAAO,MAAM,SAAS,SACd,OAAO,OACR,GAAG,CAAC,MAAM,CAAC,WACP,IAAI,cACD,MAAM,KACjB,GAAG,CAAC,MAAM,CAsCZ,CAAC;AAKF,eAAO,MAAM,gBAAgB,SACrB,MAAM,wBAEX;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAkGrD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,SAAU,MAAM,wBAA8B,MAgBlF,CAAC"}
@@ -0,0 +1,176 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+ import { parseAst } from "rolldown/parseAst";
17
+ const isNode = (value) => value !== null && typeof value === "object" && typeof value.type === "string";
18
+
19
+ export const valueRefs = (node, out, parent, parentKey) => {
20
+ if (Array.isArray(node)) {
21
+ for (const child of node)
22
+ valueRefs(child, out, parent, parentKey);
23
+ return out;
24
+ }
25
+ if (!isNode(node))
26
+ return out;
27
+ if (node.type.startsWith("TS")) {
28
+ // Only the expression side of a cast or assertion is a value.
29
+ if (node.type === "TSAsExpression" ||
30
+ node.type === "TSSatisfiesExpression" ||
31
+ node.type === "TSNonNullExpression")
32
+ valueRefs(node.expression, out, node, "expression");
33
+ return out;
34
+ }
35
+ if (node.type === "Identifier") {
36
+ const isKey = parent?.type === "Property" && parentKey === "key" && !parent.computed && !parent.shorthand;
37
+ const isMember = parent?.type === "MemberExpression" && parentKey === "property" && !parent.computed;
38
+ if (!isKey && !isMember)
39
+ out.add(node.name);
40
+ return out;
41
+ }
42
+ for (const [key, value] of Object.entries(node)) {
43
+ if (key === "type" ||
44
+ key === "start" ||
45
+ key === "end" ||
46
+ key === "typeAnnotation" ||
47
+ key === "typeArguments" ||
48
+ key === "typeParameters" ||
49
+ key === "returnType")
50
+ continue;
51
+ if (value !== null && typeof value === "object")
52
+ valueRefs(value, out, node, key);
53
+ }
54
+ return out;
55
+ };
56
+ const isOperation = (init, code) => /\bAPI\.make(Paginated)?\(/.test(code.slice(init.start, init.end));
57
+ export const privatizeSchemas = (code, filename = "generated.ts") => {
58
+ const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
59
+ const schemaDecls = new Map();
60
+ const roots = new Set();
61
+ // Operation names, so an operation alias (`export const listObjects =
62
+ // listBucketObjects`) stays an exported operation and is not taken for a schema.
63
+ const operations = new Set();
64
+ for (const raw of program.body) {
65
+ if (raw.type !== "ExportNamedDeclaration" || !isNode(raw.declaration))
66
+ continue;
67
+ const stmt = raw.declaration;
68
+ if (stmt.type !== "VariableDeclaration")
69
+ continue;
70
+ for (const d of stmt.declarations) {
71
+ const id = d.id;
72
+ if (id.type === "Identifier" && isNode(d.init) && isOperation(d.init, code))
73
+ operations.add(id.name);
74
+ }
75
+ }
76
+ const isOperationAlias = (init) => init.type === "Identifier" && operations.has(init.name);
77
+ for (const raw of program.body) {
78
+ const exported = raw.type === "ExportNamedDeclaration" && isNode(raw.declaration);
79
+ const stmt = exported ? raw.declaration : raw;
80
+ if (exported &&
81
+ stmt.type === "VariableDeclaration" &&
82
+ stmt.declarations.length === 1) {
83
+ const d = stmt.declarations[0];
84
+ const id = d.id;
85
+ if (id.type === "Identifier" &&
86
+ isNode(d.init) &&
87
+ !isOperation(d.init, code) &&
88
+ !isOperationAlias(d.init)) {
89
+ schemaDecls.set(id.name, {
90
+ name: id.name,
91
+ stmt: raw,
92
+ exportStart: raw.start,
93
+ refs: valueRefs(d.init, new Set()),
94
+ });
95
+ continue;
96
+ }
97
+ }
98
+ // Everything else (operations, classes, imports, plain statements) keeps what it references alive.
99
+ if (stmt.type === "ImportDeclaration" ||
100
+ stmt.type === "TSInterfaceDeclaration" ||
101
+ stmt.type === "TSTypeAliasDeclaration")
102
+ continue;
103
+ if (raw.type === "ExportNamedDeclaration" && !isNode(raw.declaration)) {
104
+ // `export { A, B }` / `export type { ... }`
105
+ if (raw.exportKind !== "type")
106
+ for (const s of raw.specifiers)
107
+ roots.add(s.local.name ?? "");
108
+ continue;
109
+ }
110
+ for (const r of valueRefs(stmt, new Set()))
111
+ roots.add(r);
112
+ }
113
+ // Reachability from the roots through schema references.
114
+ const live = new Set();
115
+ const stack = [...roots].filter((n) => schemaDecls.has(n));
116
+ while (stack.length) {
117
+ const n = stack.pop();
118
+ if (live.has(n))
119
+ continue;
120
+ live.add(n);
121
+ for (const r of schemaDecls.get(n).refs)
122
+ if (schemaDecls.has(r) && !live.has(r))
123
+ stack.push(r);
124
+ }
125
+ // Rewrite back to front: drop dead consts (with their leading doc comment), un-export live ones.
126
+ const decls = [...schemaDecls.values()].sort((a, b) => b.stmt.start - a.stmt.start);
127
+ let out = code;
128
+ let removed = 0;
129
+ for (const d of decls) {
130
+ if (live.has(d.name)) {
131
+ out = out.slice(0, d.stmt.start) + out.slice(d.stmt.start).replace(/^export\s+/, "");
132
+ }
133
+ else {
134
+ let start = d.stmt.start;
135
+ const before = out.slice(0, start);
136
+ const doc = /\/\*\*(?:(?!\*\/)[\s\S])*\*\/\s*$/.exec(before);
137
+ if (doc)
138
+ start = doc.index;
139
+ let end = d.stmt.end;
140
+ while (out[end] === "\n")
141
+ end++;
142
+ out = out.slice(0, start) + out.slice(end);
143
+ removed++;
144
+ }
145
+ }
146
+ return { code: out, privatized: live.size, removed };
147
+ };
148
+
149
+
150
+
151
+
152
+
153
+
154
+ export const typeOnlyNamespaceImports = (code, filename = "generated.ts") => {
155
+ const program = parseAst(code, { sourceType: "module", lang: "ts" }, filename);
156
+ const body = program.body;
157
+ const used = new Set();
158
+ for (const st of body)
159
+ if (st.type !== "ImportDeclaration")
160
+ valueRefs(st, used);
161
+ let out = code;
162
+ for (const st of [...body].reverse()) {
163
+ if (st.type !== "ImportDeclaration" || st.importKind === "type")
164
+ continue;
165
+ const specs = st.specifiers;
166
+ if (specs.length !== 1 || specs[0].type !== "ImportNamespaceSpecifier")
167
+ continue;
168
+ const name = specs[0].local.name;
169
+ if (used.has(name))
170
+ continue;
171
+ const text = code.slice(st.start, st.end).replace(/^import \*/, "import type *");
172
+ out = out.slice(0, st.start) + text + out.slice(st.end);
173
+ }
174
+ return out;
175
+ };
176
+ //# sourceMappingURL=privatize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privatize.js","sourceRoot":"","sources":["../../src/codegen/privatize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAO7C,MAAM,MAAM,GAAG,CAAC,KAA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AI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,0BAA0B;YAAE,SAAS;QAClF,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,CAAE,CAAC,KAAc,CAAC,IAAc,CAAC;QACtD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;QACjF,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
@@ -1,26 +1,26 @@
1
- /**
2
- * Proto3 → Smithy 2.0 JSON converter (dev-time only, provider-agnostic).
3
- *
4
- * Turns one or more `.proto` files (a package of messages, enums, and gRPC
5
- * services) into the same Smithy JSON model shape the other spec converters
6
- * produce (`{ smithy: "2.0", metadata, shapes }`), so a proto-sourced
7
- * provider flows through the shared `generateService` compiler.
8
- *
9
- * Mapping (proto3 JSON encoding on the wire):
10
- *
11
- * • each selected unary `rpc` → a Smithy operation, `POST /<package>.<Service>/<Method>`
12
- * • request/response messages → structures; members are camelCase (proto3 JSON)
13
- * • `repeated` → list, `map<k,v>` → map (JSON object keys are strings)
14
- * • `oneof` fields flatten onto the parent (proto3 JSON is untagged)
15
- * • enums → string enums (proto3 JSON emits the name)
16
- * • 64-bit integers → `smithy.api#String` (proto3 JSON encodes them as strings)
17
- * • `bytes` → `smithy.api#Blob` (base64 on the JSON wire)
18
- * • `google.protobuf.Empty` I/O → `smithy.api#Unit`
19
- * • streaming RPCs are skipped by default (they are not request/response POSTs)
20
- *
21
- * The converter does not speak binary protobuf. Generated SDKs send proto3
22
- * JSON at the gRPC method path — Connect-JSON / grpc-JSON transcoding shape.
23
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
24
  import { SENSITIVE_FIELD_PATTERNS } from "./openapi.js";
25
25
  // ============================================================================
26
26
  // Prelude
@@ -551,7 +551,7 @@ class Parser {
551
551
  };
552
552
  }
553
553
  }
554
- /** Parse a proto3 source file into an AST. */
554
+
555
555
  export const parseProto = (text, filename = "input.proto") => {
556
556
  const file = new Parser(text, filename).parseFile();
557
557
  if (file.syntax !== "proto3") {
@@ -847,7 +847,7 @@ const copyIo = (ctx, rpcName, side, typeName) => {
847
847
  },
848
848
  });
849
849
  };
850
- /** Leading PascalCase token of an RPC name (`AppCreate` → `App`). */
850
+
851
851
  export const rpcGroupName = (rpcName) => {
852
852
  const m = rpcName.match(/^([A-Z][a-z]+|[A-Z]+(?![a-z]))/);
853
853
  return m?.[1] ?? rpcName;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Returns `code` with a PURE marker before every unmarked call in a
3
+ * top-level `const`/`let`/`var` initializer or class `extends` clause.
4
+ */
5
+ export declare const annotateNestedCalls: (code: string, filename?: string) => string;
6
+ //# sourceMappingURL=pure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pure.d.ts","sourceRoot":"","sources":["../../src/codegen/pure.ts"],"names":[],"mappings":"AAoEA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,SAAU,MAAM,wBAA8B,MAqB7E,CAAC"}