@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,81 +1,82 @@
1
- /**
2
- * OpenAPI → Smithy 2.0 JSON converter (dev-time only, provider-agnostic).
3
- *
4
- * Turns a Swagger 2.0 / OAS 3.0 / OAS 3.1 document into the same Smithy JSON
5
- * model shape the other spec converters produce (`{ smithy: "2.0", metadata,
6
- * shapes }`), so every OpenAPI-sourced provider flows through the one shared
7
- * `generateService` compiler. Conversion fidelity follows distilled v0's
8
- * `generate-openapi.ts` feature matrix:
9
- *
10
- * • one operation per (path × get/post/put/patch/delete — plus head/options
11
- * when a provider opts in via `extraHttpMethods`), deprecated skipped by
12
- * default; op shape name = PascalCase(operationId), or verbNoun
13
- * (`Apps_list` → `ListApps`) when {@link OpenApiConvertOptions.operationNaming}
14
- * is `"verbNoun"`
15
- * • input `<Op>Request`: path params → `smithy.api#httpLabel` (+required),
16
- * query params → `smithy.api#httpQuery`, header params →
17
- * `smithy.api#httpHeader` when `headerParams` is on (dropped otherwise,
18
- * as cookie params always are),
19
- * body properties flattened alongside
20
- * (labels win, then query, then headers, then body);
21
- * non-object bodies become a sole `body` member with `smithy.api#httpPayload`
22
- * • `$ref`s become NAMED shapes (`components/schemas/X` → `<ns>#X`), reused
23
- * across operations; anonymous nested objects synthesize names from the
24
- * parent + member path
25
- * • responses: 200 → 201 → 204 precedence (`successStatuses` overrides),
26
- * JSON or opt-in binary `application/octet-stream`; object
27
- * results become `<Op>Response` structures (a sole `$ref` reuses the named
28
- * shape); bare array/scalar results wrap in a structure whose single
29
- * member carries `com.distilled.openapi#rawResponse` (the SdkSpec maps it
30
- * to a root pipe); no schema → `smithy.api#Unit`; `head` is always
31
- * `smithy.api#Unit`, whatever content the spec declares
32
- * • nullability (3.0 `nullable`, 3.1 `type: [..., "null"]`, 2.0
33
- * `x-nullable`, `oneOf`/`anyOf` null branches) → member-level
34
- * `com.distilled.openapi#nullable` trait
35
- * • sensitive string members (x-sensitive or name-pattern match) →
36
- * `smithy.api#sensitive` on the member (direction-agnostic; the SdkSpec
37
- * decides the input/output treatment)
38
- * • per-op non-2xx statuses (outside `defaultErrorStatuses`) → typed error
39
- * shapes with `smithy.api#error`/`smithy.api#httpError` and
40
- * `com.distilled.openapi#errorMatchers` status matchers
41
- * • v0 pagination detection (`pagination.cursor` / `.next` / `.next_page`,
42
- * `next_token`/`NextToken`/`nextToken`, `next_page` + input alias lists +
43
- * first top-level array property) → `smithy.api#paginated` on the op
44
- * (with the non-standard `mode` member the core runtime dispatches on)
45
- */
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
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+ import { ADDITIONAL_PROPERTIES_TRAIT } from "./members.js";
46
47
  import { isMechanicalOperationId, isVerbatimRouteId, pathToVerbNoun, RENAME_METADATA_KEY, renameShapes, resolveOperationName, toVerbNoun, } from "./rewrite-operation-ids.js";
47
48
  // ============================================================================
48
49
  // Trait ids (the `com.distilled.openapi` vocabulary)
49
50
  // ============================================================================
50
- /** Member-level nullability (`S.NullOr` + `| null` via `SdkSpec.nullableTrait`). */
51
+
51
52
  export const NULLABLE_TRAIT = "com.distilled.openapi#nullable";
52
- /**
53
- * Marks the sole member of a synthesized response wrapper for bare
54
- * array/scalar response bodies. SdkSpecs bind it with a `rootPipe`
55
- * (`T.RawResponseRoot()` from `core/protocol-rest`), so the emitted response
56
- * type IS the payload type.
57
- */
53
+
54
+
55
+
56
+
57
+
58
+
58
59
  export const RAW_RESPONSE_TRAIT = "com.distilled.openapi#rawResponse";
59
- /**
60
- * Wire-matching rules for a generated error class (see
61
- * `SdkSpec.errorMatchersTrait` + `applyErrorMatchers`). The converter stamps
62
- * `[{ status }]` from the response status the class was mapped from.
63
- */
60
+
61
+
62
+
63
+
64
+
64
65
  export const ERROR_MATCHERS_TRAIT = "com.distilled.openapi#errorMatchers";
65
- /**
66
- * Non-JSON request body encoding chosen by the v0 content-type precedence
67
- * (json > form-urlencoded > multipart). Value: `"form-urlencoded"` |
68
- * `"multipart"`. `"multipart"` is also merged into the `smithy.api#http`
69
- * trait's `contentType` (which core's `buildRequest` understands);
70
- * form-urlencoded is left to provider SdkSpecs/protocols.
71
- */
66
+
67
+
68
+
69
+
70
+
71
+
72
+
72
73
  export const CONTENT_TYPE_TRAIT = "com.distilled.openapi#contentType";
73
- /**
74
- * The `apiVersion` recorded on every operation when
75
- * {@link OpenApiConvertOptions.apiVersion} is set (Azure ARM style). The
76
- * matching `api-version` query parameter is dropped from inputs; the
77
- * provider's protocol injects it at request time.
78
- */
74
+
75
+
76
+
77
+
78
+
79
+
79
80
  export const API_VERSION_TRAIT = "com.distilled.openapi#apiVersion";
80
81
  // ============================================================================
81
82
  // Sensitive-field name patterns (distilled v0's SENSITIVE_FIELD_PATTERNS)
@@ -113,7 +114,7 @@ const PRELUDE = {
113
114
  Integer: "smithy.api#Integer",
114
115
  Document: "smithy.api#Document",
115
116
  };
116
- /** snake/kebab/space/camel → PascalCase identifier (inner caps preserved). */
117
+
117
118
  const pascal = (s) => {
118
119
  const parts = s.split(/[^A-Za-z0-9]+/).filter(Boolean);
119
120
  let out = parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
@@ -123,18 +124,18 @@ const pascal = (s) => {
123
124
  out = `_${out}`;
124
125
  return out;
125
126
  };
126
- /** Keep a JSON field name if it's a valid Smithy member identifier, else sanitize. */
127
+
127
128
  const memberIdent = (name) => {
128
129
  let out = name.replace(/[^A-Za-z0-9_]/g, "_");
129
130
  if (/^[0-9]/.test(out))
130
131
  out = `_${out}`;
131
132
  return out || "_";
132
133
  };
133
- /**
134
- * Header name → member identifier (`x-Artifact-Tag` → `xArtifactTag`). The
135
- * wire name is carried by the `smithy.api#httpHeader` trait, so the member
136
- * can read like the rest of the input rather than like a header.
137
- */
134
+
135
+
136
+
137
+
138
+
138
139
  const headerMemberName = (name) => {
139
140
  const parts = name.split(/[^A-Za-z0-9]+/).filter(Boolean);
140
141
  if (parts.length === 0)
@@ -183,7 +184,7 @@ const detectVersion = (spec) => {
183
184
  return "3.0";
184
185
  throw new Error(`Unsupported OpenAPI version (swagger=${spec?.swagger}, openapi=${spec?.openapi})`);
185
186
  };
186
- /** Resolve a local `#/...` JSON pointer against the spec document. */
187
+
187
188
  const resolvePointer = (spec, ref) => {
188
189
  if (typeof ref !== "string" || !ref.startsWith("#/"))
189
190
  return undefined;
@@ -196,7 +197,7 @@ const resolvePointer = (spec, ref) => {
196
197
  }
197
198
  return cur;
198
199
  };
199
- /** Follow `$ref` chains (bounded) to the underlying schema object. */
200
+
200
201
  const deref = (ctx, def) => {
201
202
  let cur = def;
202
203
  for (let i = 0; i < 16 && cur && typeof cur === "object" && cur.$ref; i++) {
@@ -204,14 +205,14 @@ const deref = (ctx, def) => {
204
205
  }
205
206
  return cur;
206
207
  };
207
- /**
208
- * Flatten a schema into a property bag: `$ref`s resolved, `allOf` merged
209
- * (properties + required unioned across resolved subschemas). A
210
- * `oneOf`/`anyOf` encountered INSIDE an `allOf` merges its branches'
211
- * properties as OPTIONAL members — the loosest satisfiable reading of the
212
- * intersection — rather than dropping them; a top-level union is left to
213
- * the union conversion path.
214
- */
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
215
216
  const flattenObject = (ctx, def, depth = 0) => {
216
217
  const out = {
217
218
  properties: {},
@@ -270,7 +271,7 @@ const flattenObject = (ctx, def, depth = 0) => {
270
271
  visit(def, depth, false, false);
271
272
  return out;
272
273
  };
273
- /** Whether a `oneOf`/`anyOf` branch represents JSON null. */
274
+
274
275
  const isNullBranch = (ctx, branch) => {
275
276
  const r = deref(ctx, branch);
276
277
  if (!r || typeof r !== "object")
@@ -285,7 +286,7 @@ const isNullBranch = (ctx, branch) => {
285
286
  }
286
287
  return false;
287
288
  };
288
- /** Intrinsic nullability flags on a schema node (not union null branches). */
289
+
289
290
  const ownNullable = (ctx, def) => {
290
291
  if (!def || typeof def !== "object")
291
292
  return false;
@@ -300,12 +301,12 @@ const ownNullable = (ctx, def) => {
300
301
  return true;
301
302
  return false;
302
303
  };
303
- /**
304
- * Whether a property schema is excluded from the given direction:
305
- * `readOnly: true` properties never appear in requests, `writeOnly: true`
306
- * properties never appear in responses. Checks the property node itself and
307
- * its `$ref` resolution.
308
- */
304
+
305
+
306
+
307
+
308
+
309
+
309
310
  const dirExcluded = (ctx, prop, dir) => {
310
311
  const flag = dir === "in" ? "readOnly" : "writeOnly";
311
312
  if (prop && typeof prop === "object" && prop[flag] === true)
@@ -313,7 +314,7 @@ const dirExcluded = (ctx, prop, dir) => {
313
314
  const r = deref(ctx, prop);
314
315
  return !!r && typeof r === "object" && r[flag] === true;
315
316
  };
316
- /** Child schema slots the direction-sensitivity walk descends through. */
317
+
317
318
  const schemaChildren = (d) => [
318
319
  ...(Array.isArray(d.allOf) ? d.allOf : []),
319
320
  ...(Array.isArray(d.oneOf) ? d.oneOf : []),
@@ -324,11 +325,11 @@ const schemaChildren = (d) => [
324
325
  ? [d.additionalProperties]
325
326
  : []),
326
327
  ];
327
- /**
328
- * Walk an INLINE schema subtree (stopping at `$ref` nodes, which are
329
- * appended to `refs` instead of followed). Returns whether the flag
330
- * appears inline. Inline subtrees are JSON trees — no cycles.
331
- */
328
+
329
+
330
+
331
+
332
+
332
333
  const scanInlineForFlag = (d, flag, refs) => {
333
334
  if (!d || typeof d !== "object")
334
335
  return false;
@@ -344,17 +345,17 @@ const scanInlineForFlag = (d, flag, refs) => {
344
345
  }
345
346
  return false;
346
347
  };
347
- /**
348
- * Compute, for the WHOLE document at once, the set of `$ref` pointers that
349
- * are direction-sensitive: the flag appears somewhere in the schema graph
350
- * reachable from the ref's target. One inline scan per distinct ref target
351
- * (local flag + outgoing ref edges), then reverse propagation from the
352
- * locally-flagged nodes — linear in spec size, and cycles / diamond-shared
353
- * refs cost nothing. (This replaces a per-call DFS whose memoization was
354
- * disabled by ANY re-encountered ref; on large specs where every schema
355
- * shares refs — e.g. MongoDB Atlas's ubiquitous `links` — that re-walked
356
- * the graph for each of thousands of `$ref` sites and never finished.)
357
- */
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
358
359
  const buildDirSensitiveRefs = (ctx, dir) => {
359
360
  const flag = dir === "in" ? "readOnly" : "writeOnly";
360
361
  // Every distinct `$ref` pointer in the document.
@@ -403,13 +404,13 @@ const buildDirSensitiveRefs = (ctx, dir) => {
403
404
  }
404
405
  return sensitive;
405
406
  };
406
- /**
407
- * Whether a schema subtree is direction-sensitive — contains
408
- * `readOnly: true` (request direction) or `writeOnly: true` (response
409
- * direction) anywhere, following local `$ref`s. Direction-sensitive named
410
- * components convert to separate request/response shape variants
411
- * (`<Name>Input`/`<Name>Output`); everything else is shared.
412
- */
407
+
408
+
409
+
410
+
411
+
412
+
413
+
413
414
  const dirSensitive = (ctx, def, dir) => {
414
415
  let sensitiveRefs = ctx.dirSensitiveRefs.get(dir);
415
416
  if (sensitiveRefs === undefined) {
@@ -422,7 +423,7 @@ const dirSensitive = (ctx, def, dir) => {
422
423
  }
423
424
  return refs.some((ref) => sensitiveRefs.has(ref));
424
425
  };
425
- /** Single non-array type from a possibly 3.1-style `type` value. */
426
+
426
427
  const typeOf = (def) => {
427
428
  const t = def?.type;
428
429
  if (typeof t === "string")
@@ -437,11 +438,11 @@ const typeOf = (def) => {
437
438
  // ============================================================================
438
439
  // Schema conversion
439
440
  // ============================================================================
440
- /**
441
- * Whether a schema definition warrants a NAMED shape (vs an inline prelude
442
- * target). Named shapes can participate in reference cycles, so `$ref`s to
443
- * nameable schemas reserve their name before converting.
444
- */
441
+
442
+
443
+
444
+
445
+
445
446
  const isNameable = (ctx, def) => {
446
447
  if (!def || typeof def !== "object")
447
448
  return false;
@@ -466,13 +467,13 @@ const isNameable = (ctx, def) => {
466
467
  return true;
467
468
  return false;
468
469
  };
469
- /**
470
- * Convert one schema to a shape target. `dir` is the conversion direction
471
- * (request vs response position — readOnly/writeOnly members are dropped
472
- * accordingly). `reservedId` names the top-level shape when the caller
473
- * pre-registered it (named `$ref` targets); otherwise anonymous shapes
474
- * synthesize names from `hint`.
475
- */
470
+
471
+
472
+
473
+
474
+
475
+
476
+
476
477
  const convertSchema = (ctx, def, hint, depth, dir, reservedId) => {
477
478
  const emit = (shapeDef, base) => {
478
479
  if (reservedId !== undefined) {
@@ -599,7 +600,7 @@ const convertSchema = (ctx, def, hint, depth, dir, reservedId) => {
599
600
  }
600
601
  const members = buildMembers(ctx, flat.properties, flat.required, hint, depth + 1, dir);
601
602
  return {
602
- target: emit({ type: "structure", members, traits: docTraits }, hint),
603
+ target: emit({ type: "structure", members, traits: structTraits(docTraits, flat.additionalProperties) }, hint),
603
604
  nullable,
604
605
  };
605
606
  }
@@ -677,7 +678,11 @@ const convertSchema = (ctx, def, hint, depth, dir, reservedId) => {
677
678
  const required = new Set(Array.isArray(def.required) ? def.required : []);
678
679
  const members = buildMembers(ctx, def.properties, required, hint, depth + 1, dir);
679
680
  return {
680
- target: emit({ type: "structure", members, traits: docTraits }, hint),
681
+ target: emit({
682
+ type: "structure",
683
+ members,
684
+ traits: structTraits(docTraits, def.additionalProperties),
685
+ }, hint),
681
686
  nullable,
682
687
  };
683
688
  }
@@ -717,7 +722,16 @@ const convertSchema = (ctx, def, hint, depth, dir, reservedId) => {
717
722
  return inline(PRELUDE.Document, nullable);
718
723
  }
719
724
  };
720
- /** Whether a property is a sensitive string (x-sensitive or name pattern). */
725
+
726
+
727
+
728
+
729
+
730
+
731
+ const structTraits = (docTraits, ap) => ap !== undefined && ap !== false
732
+ ? { ...docTraits, [ADDITIONAL_PROPERTIES_TRAIT]: {} }
733
+ : docTraits;
734
+
721
735
  const isSensitiveProperty = (ctx, name, def) => {
722
736
  const r = deref(ctx, def);
723
737
  if (!r || typeof r !== "object")
@@ -729,11 +743,11 @@ const isSensitiveProperty = (ctx, name, def) => {
729
743
  return true;
730
744
  return ctx.sensitivePatterns.some((p) => p.test(name));
731
745
  };
732
- /**
733
- * Build a structure's members from an OpenAPI property map. Direction-
734
- * excluded properties (`readOnly` in requests, `writeOnly` in responses)
735
- * are dropped — along with any response-side `required` they carried.
736
- */
746
+
747
+
748
+
749
+
750
+
737
751
  const buildMembers = (ctx, properties, required, hint, depth, dir) => {
738
752
  const members = {};
739
753
  for (const [name, prop] of Object.entries(properties)) {
@@ -766,7 +780,7 @@ const buildMembers = (ctx, properties, required, hint, depth, dir) => {
766
780
  }
767
781
  return members;
768
782
  };
769
- /** Normalize a (possibly `$ref`'d) parameter; Swagger 2.0 carries the schema inline. */
783
+
770
784
  const normalizeParam = (ctx, raw) => {
771
785
  const p = raw?.$ref ? resolvePointer(ctx.spec, raw.$ref) : raw;
772
786
  if (!p || typeof p !== "object" || typeof p.name !== "string") {
@@ -794,12 +808,12 @@ const normalizeParam = (ctx, raw) => {
794
808
  schema,
795
809
  };
796
810
  };
797
- /**
798
- * Path-level parameters merged before operation-level ones; an op-level
799
- * parameter overrides a path-level one with the same (in, name). Header and
800
- * cookie parameters are dropped (v0 parity); `in: body` (2.0) is handled by
801
- * the request-body path.
802
- */
811
+
812
+
813
+
814
+
815
+
816
+
803
817
  const collectParams = (ctx, pathItem, op) => {
804
818
  const byKey = new Map();
805
819
  for (const raw of [
@@ -813,11 +827,11 @@ const collectParams = (ctx, pathItem, op) => {
813
827
  }
814
828
  return [...byKey.values()].filter((p) => p.in === "path" || p.in === "query" || p.in === "body" || p.in === "header");
815
829
  };
816
- /**
817
- * Simple-type coercion for path labels (Smithy restricts label targets):
818
- * enum → enum shape, integer → Integer, number → Double, boolean → Boolean,
819
- * everything else → String.
820
- */
830
+
831
+
832
+
833
+
834
+
821
835
  const labelTarget = (ctx, schema, hint) => {
822
836
  const r = deref(ctx, schema);
823
837
  if (Array.isArray(r?.enum) &&
@@ -839,10 +853,10 @@ const labelTarget = (ctx, schema, hint) => {
839
853
  // ============================================================================
840
854
  // Docs
841
855
  // ============================================================================
842
- /**
843
- * v0 trimming rules: stop at a `### Authorization` heading, strip markdown
844
- * table rows (lines starting with `|`).
845
- */
856
+
857
+
858
+
859
+
846
860
  const trimDescription = (desc) => {
847
861
  if (typeof desc !== "string" || !desc)
848
862
  return undefined;
@@ -866,7 +880,60 @@ const opDoc = (op) => {
866
880
  // ============================================================================
867
881
  // Responses
868
882
  // ============================================================================
869
- /** First declared status wins; resolve response refs and preserve JSON or binary bodies. */
883
+
884
+
885
+
886
+
887
+
888
+ const successHeaders = (ctx, responses, allowed) => {
889
+ const out = [];
890
+ const seen = new Set();
891
+ for (const code of Object.keys(responses ?? {}).sort()) {
892
+ if (!/^2\d\d$/.test(code))
893
+ continue;
894
+ const raw = responses[code];
895
+ const resp = raw?.$ref ? resolvePointer(ctx.spec, raw.$ref) : raw;
896
+ for (const [name, rawHeader] of Object.entries(resp?.headers ?? {})) {
897
+ const lower = name.toLowerCase();
898
+ if (!allowed.has(lower) || seen.has(lower))
899
+ continue;
900
+ seen.add(lower);
901
+ const header = rawHeader?.$ref ? resolvePointer(ctx.spec, rawHeader.$ref) : rawHeader;
902
+ if (!header || typeof header !== "object")
903
+ continue;
904
+ out.push({
905
+ name,
906
+ schema: ctx.version === "2.0" ? header : (header.schema ?? {}),
907
+ ...(typeof header.description === "string" ? { description: header.description } : {}),
908
+ });
909
+ }
910
+ }
911
+ return out;
912
+ };
913
+
914
+ const targetCounts = (shapes) => {
915
+ const counts = new Map();
916
+ const visit = (node) => {
917
+ if (node === null || typeof node !== "object")
918
+ return;
919
+ if (Array.isArray(node)) {
920
+ for (const item of node)
921
+ visit(item);
922
+ return;
923
+ }
924
+ if (typeof node.target === "string") {
925
+ counts.set(node.target, (counts.get(node.target) ?? 0) + 1);
926
+ }
927
+ for (const [key, value] of Object.entries(node)) {
928
+ if (key !== "traits")
929
+ visit(value);
930
+ }
931
+ };
932
+ for (const shape of Object.values(shapes))
933
+ visit(shape);
934
+ return counts;
935
+ };
936
+
870
937
  const successSchema = (ctx, responses, order) => {
871
938
  for (const code of order) {
872
939
  const raw = responses?.[code];
@@ -886,11 +953,11 @@ const successSchema = (ctx, responses, order) => {
886
953
  }
887
954
  return { schema: undefined };
888
955
  };
889
- /**
890
- * Whether the success body is a collection: an array, or an object whose
891
- * array members outnumber its scalar ones (envelopes like `{ data: [] }`,
892
- * `{ items: [], total }`). `undefined` when there is no body to judge.
893
- */
956
+
957
+
958
+
959
+
960
+
894
961
  const responseIsCollection = (ctx, responses, order) => {
895
962
  const { schema } = successSchema(ctx, responses, order);
896
963
  if (!schema)
@@ -983,12 +1050,12 @@ const detectPagination = (ctx, params, responseSchema) => {
983
1050
  // Main conversion
984
1051
  // ============================================================================
985
1052
  const HTTP_METHODS = ["get", "post", "put", "patch", "delete"];
986
- /**
987
- * Methods a spec may declare beyond {@link HTTP_METHODS}, opt-in via
988
- * {@link OpenApiConvertOptions.extraHttpMethods} — a provider that models
989
- * `head` (Vercel's cache-artifact and file existence probes) asks for it
990
- * rather than every provider silently gaining operations on regeneration.
991
- */
1053
+
1054
+
1055
+
1056
+
1057
+
1058
+
992
1059
  const OPTIONAL_HTTP_METHODS = ["head", "options"];
993
1060
  const DEFAULT_STATUS_TO_ERROR_CLASS = {
994
1061
  "400": "BadRequest",
@@ -1063,6 +1130,8 @@ const convertOnce = (spec, options) => {
1063
1130
  const serviceName = uniqueName(ctx, options.serviceName);
1064
1131
  const usedErrors = new Map(); // class name → first status
1065
1132
  const serviceOps = [];
1133
+ const componentHeaders = [];
1134
+ const allowedResponseHeaders = new Set((options.responseHeaders ?? []).map((name) => name.toLowerCase()));
1066
1135
  for (const [rawPath, pathItem] of Object.entries(doc.paths ?? {})) {
1067
1136
  if (!pathItem || typeof pathItem !== "object")
1068
1137
  continue;
@@ -1189,7 +1258,9 @@ const convertOnce = (spec, options) => {
1189
1258
  bodyRequired = bodyParam?.required === true;
1190
1259
  }
1191
1260
  else if (op.requestBody) {
1192
- const rb = op.requestBody.$ref ? resolvePointer(doc, op.requestBody.$ref) : op.requestBody;
1261
+ // A components/requestBodies entry can itself be a $ref to another
1262
+ // (1Password Events: AuditEventsRequest → CursorRequest).
1263
+ const rb = deref(ctx, op.requestBody);
1193
1264
  bodyRequired = rb?.required === true;
1194
1265
  const content = rb?.content ?? {};
1195
1266
  if (content["application/json"]) {
@@ -1297,6 +1368,51 @@ const convertOnce = (spec, options) => {
1297
1368
  }
1298
1369
  }
1299
1370
  }
1371
+ // ---- Response headers (opt-in) ----
1372
+ let pendingHeaders;
1373
+ if (allowedResponseHeaders.size > 0 && method !== "head") {
1374
+ const headers = successHeaders(ctx, op.responses, allowedResponseHeaders);
1375
+ const current = outputTarget === PRELUDE.Unit ? undefined : ctx.shapes[outputTarget];
1376
+ // A raw-root wrapper collapses to its payload, so it has nowhere to
1377
+ // carry headers.
1378
+ const rawRoot = Object.values(current?.members ?? {}).some((m) => m?.traits?.[RAW_RESPONSE_TRAIT] !== undefined);
1379
+ if (headers.length > 0 &&
1380
+ (current === undefined || current.type === "structure") &&
1381
+ !rawRoot) {
1382
+ const taken = new Set(Object.keys(current?.members ?? {}));
1383
+ const members = {};
1384
+ for (const header of headers) {
1385
+ let name = headerMemberName(header.name);
1386
+ if (taken.has(name))
1387
+ name = `${name}Header`;
1388
+ if (taken.has(name))
1389
+ continue;
1390
+ taken.add(name);
1391
+ members[name] = {
1392
+ target: convertSchema(ctx, header.schema, `${opName}Response${pascal(header.name)}`, 0, "out").target,
1393
+ traits: {
1394
+ "smithy.api#httpHeader": header.name,
1395
+ ...(header.description ? { "smithy.api#documentation": header.description } : {}),
1396
+ },
1397
+ };
1398
+ }
1399
+ if (current === undefined) {
1400
+ outputTarget = addShape(ctx, `${opName}Response`, {
1401
+ type: "structure",
1402
+ members,
1403
+ traits: { "smithy.api#output": {} },
1404
+ });
1405
+ }
1406
+ else if (current.traits?.["smithy.api#output"] !== undefined) {
1407
+ current.members = { ...current.members, ...members };
1408
+ }
1409
+ else {
1410
+ // A named component: whether it can take the headers itself
1411
+ // depends on what else uses it, known once every op is converted.
1412
+ pendingHeaders = members;
1413
+ }
1414
+ }
1415
+ }
1300
1416
  // ---- Errors ----
1301
1417
  const errors = [];
1302
1418
  for (const status of Object.keys(op.responses ?? {})) {
@@ -1342,6 +1458,44 @@ const convertOnce = (spec, options) => {
1342
1458
  traits,
1343
1459
  });
1344
1460
  serviceOps.push({ target: opId });
1461
+ if (pendingHeaders !== undefined) {
1462
+ componentHeaders.push({ opId, opName, members: pendingHeaders });
1463
+ }
1464
+ }
1465
+ }
1466
+ // ---- Response headers on named components ----
1467
+ // A component returned only by ops that declare headers takes them itself
1468
+ // (all optional) and keeps its name. A component that other shapes, or ops
1469
+ // without those headers, also use is copied into an op-specific output, so
1470
+ // the headers never leak into them.
1471
+ if (componentHeaders.length > 0) {
1472
+ const uses = targetCounts(ctx.shapes);
1473
+ const outputs = new Map();
1474
+ for (const { opId } of componentHeaders) {
1475
+ const id = ctx.shapes[opId].output.target;
1476
+ outputs.set(id, (outputs.get(id) ?? 0) + 1);
1477
+ }
1478
+ for (const { opId, opName, members } of componentHeaders) {
1479
+ const opShape = ctx.shapes[opId];
1480
+ const componentId = opShape.output.target;
1481
+ const component = ctx.shapes[componentId];
1482
+ if (uses.get(componentId) === outputs.get(componentId)) {
1483
+ component.members = { ...component.members, ...members };
1484
+ }
1485
+ else {
1486
+ opShape.output.target = addShape(ctx, `${opName}Response`, {
1487
+ type: "structure",
1488
+ members: { ...component.members, ...members },
1489
+ traits: {
1490
+ ...(component.traits?.["smithy.api#documentation"]
1491
+ ? {
1492
+ "smithy.api#documentation": component.traits["smithy.api#documentation"],
1493
+ }
1494
+ : {}),
1495
+ "smithy.api#output": {},
1496
+ },
1497
+ });
1498
+ }
1345
1499
  }
1346
1500
  }
1347
1501
  // ---- Error shapes (one per used class) ----