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

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 (314) hide show
  1. package/lib/_bundle/base.js +2 -2
  2. package/lib/_bundle/base.js.map +1 -1
  3. package/lib/_bundle/graphql.js +2 -2
  4. package/lib/_bundle/graphql.js.map +1 -1
  5. package/lib/_bundle/grpc.js +2 -0
  6. package/lib/_bundle/grpc.js.map +1 -0
  7. package/lib/_bundle/rest.js +1 -1
  8. package/lib/_bundle/rest.js.map +1 -1
  9. package/lib/_bundle/xml.js +1 -1
  10. package/lib/_bundle/xml.js.map +1 -1
  11. package/lib/annotations.d.ts +17 -0
  12. package/lib/annotations.d.ts.map +1 -0
  13. package/lib/annotations.js +2 -0
  14. package/lib/annotations.js.map +1 -0
  15. package/lib/api.d.ts +52 -1
  16. package/lib/api.d.ts.map +1 -1
  17. package/lib/api.js +1 -1
  18. package/lib/category.d.ts.map +1 -1
  19. package/lib/config.d.ts +54 -13
  20. package/lib/config.d.ts.map +1 -1
  21. package/lib/config.js +1 -1
  22. package/lib/error-category.d.ts.map +1 -1
  23. package/lib/errors.d.ts +3 -13
  24. package/lib/errors.d.ts.map +1 -1
  25. package/lib/errors.js +1 -1
  26. package/lib/graphql.d.ts +26 -5
  27. package/lib/graphql.d.ts.map +1 -1
  28. package/lib/graphql.types.d.ts.map +1 -1
  29. package/lib/grpc-transport-cloudflare-http2.d.ts +7 -0
  30. package/lib/grpc-transport-cloudflare-http2.d.ts.map +1 -0
  31. package/lib/grpc-transport-cloudflare-http2.js +6 -0
  32. package/lib/grpc-transport-cloudflare-http2.js.map +1 -0
  33. package/lib/grpc-transport-cloudflare-sockets.d.ts +7 -0
  34. package/lib/grpc-transport-cloudflare-sockets.d.ts.map +1 -0
  35. package/lib/grpc-transport-cloudflare-sockets.js +5 -0
  36. package/lib/grpc-transport-cloudflare-sockets.js.map +1 -0
  37. package/lib/grpc-transport-node-http2.d.ts +19 -0
  38. package/lib/grpc-transport-node-http2.d.ts.map +1 -0
  39. package/lib/grpc-transport-node-http2.js +2 -0
  40. package/lib/grpc-transport-node-http2.js.map +1 -0
  41. package/lib/grpc-transport.d.ts +76 -0
  42. package/lib/grpc-transport.d.ts.map +1 -0
  43. package/lib/grpc-transport.js +1 -0
  44. package/lib/hpack.d.ts +34 -0
  45. package/lib/hpack.d.ts.map +1 -0
  46. package/lib/hpack.js +2 -0
  47. package/lib/hpack.js.map +1 -0
  48. package/lib/index.d.ts +6 -2
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +4 -0
  51. package/lib/pagination.d.ts +55 -3
  52. package/lib/pagination.d.ts.map +1 -1
  53. package/lib/pagination.js +1 -1
  54. package/lib/protobuf.d.ts +92 -0
  55. package/lib/protobuf.d.ts.map +1 -0
  56. package/lib/protobuf.js +1 -0
  57. package/lib/protocol-grpc.d.ts +86 -0
  58. package/lib/protocol-grpc.d.ts.map +1 -0
  59. package/lib/protocol-grpc.js +1 -0
  60. package/lib/protocol-http.d.ts +38 -9
  61. package/lib/protocol-http.d.ts.map +1 -1
  62. package/lib/protocol-http.js +1 -1
  63. package/lib/protocol-rest.d.ts +60 -42
  64. package/lib/protocol-rest.d.ts.map +1 -1
  65. package/lib/protocol-rest.js +1 -1
  66. package/lib/response-validation.d.ts +5 -4
  67. package/lib/response-validation.d.ts.map +1 -1
  68. package/lib/schema-lite-typed.js +1 -2
  69. package/lib/sdk-error.d.ts +27 -0
  70. package/lib/sdk-error.d.ts.map +1 -0
  71. package/lib/sdk-error.js +1 -0
  72. package/lib/sensitive.d.ts +28 -0
  73. package/lib/sensitive.d.ts.map +1 -0
  74. package/lib/sensitive.js +2 -0
  75. package/lib/sensitive.js.map +1 -0
  76. package/lib/telemetry-debug.d.ts +6 -0
  77. package/lib/telemetry-debug.d.ts.map +1 -0
  78. package/lib/telemetry-debug.js +2 -0
  79. package/lib/telemetry-debug.js.map +1 -0
  80. package/lib/telemetry-hooks.d.ts +32 -0
  81. package/lib/telemetry-hooks.d.ts.map +1 -0
  82. package/lib/telemetry-hooks.js +2 -0
  83. package/lib/telemetry-hooks.js.map +1 -0
  84. package/lib/telemetry-host-rules.d.ts +23 -0
  85. package/lib/telemetry-host-rules.d.ts.map +1 -0
  86. package/lib/telemetry-host-rules.js +2 -0
  87. package/lib/telemetry-host-rules.js.map +1 -0
  88. package/lib/telemetry-lambda-context.d.ts +17 -0
  89. package/lib/telemetry-lambda-context.d.ts.map +1 -0
  90. package/lib/telemetry-lambda-context.js +2 -0
  91. package/lib/telemetry-lambda-context.js.map +1 -0
  92. package/lib/telemetry-message-context.d.ts +52 -0
  93. package/lib/telemetry-message-context.d.ts.map +1 -0
  94. package/lib/telemetry-message-context.js +2 -0
  95. package/lib/telemetry-message-context.js.map +1 -0
  96. package/lib/telemetry-metrics.d.ts +6 -0
  97. package/lib/telemetry-metrics.d.ts.map +1 -0
  98. package/lib/telemetry-metrics.js +2 -0
  99. package/lib/telemetry-metrics.js.map +1 -0
  100. package/lib/telemetry-name-template.d.ts +13 -0
  101. package/lib/telemetry-name-template.d.ts.map +1 -0
  102. package/lib/telemetry-name-template.js +2 -0
  103. package/lib/telemetry-name-template.js.map +1 -0
  104. package/lib/telemetry-stream.d.ts +11 -0
  105. package/lib/telemetry-stream.d.ts.map +1 -0
  106. package/lib/telemetry-stream.js +2 -0
  107. package/lib/telemetry-stream.js.map +1 -0
  108. package/lib/telemetry-xray.d.ts +28 -0
  109. package/lib/telemetry-xray.d.ts.map +1 -0
  110. package/lib/telemetry-xray.js +2 -0
  111. package/lib/telemetry-xray.js.map +1 -0
  112. package/lib/telemetry.d.ts +288 -0
  113. package/lib/telemetry.d.ts.map +1 -0
  114. package/lib/telemetry.js +3 -0
  115. package/lib/telemetry.js.map +1 -0
  116. package/lib/trait.d.ts +7 -0
  117. package/lib/trait.d.ts.map +1 -1
  118. package/lib/trait.js +1 -1
  119. package/lib/xml.d.ts.map +1 -1
  120. package/package.json +3 -5
  121. package/src/annotations.ts +53 -0
  122. package/src/api.ts +316 -43
  123. package/src/category.ts +21 -22
  124. package/src/config.ts +58 -29
  125. package/src/error-category.ts +12 -14
  126. package/src/errors.ts +11 -7
  127. package/src/graphql.ts +191 -63
  128. package/src/graphql.types.ts +5 -1
  129. package/src/grpc-transport-cloudflare-http2.ts +494 -0
  130. package/src/grpc-transport-cloudflare-sockets.ts +299 -0
  131. package/src/grpc-transport-node-http2.ts +234 -0
  132. package/src/grpc-transport.ts +118 -0
  133. package/src/hpack.ts +331 -0
  134. package/src/index.ts +6 -2
  135. package/src/pagination.ts +193 -8
  136. package/src/protobuf.ts +1332 -0
  137. package/src/protocol-grpc.ts +641 -0
  138. package/src/protocol-http.ts +87 -67
  139. package/src/protocol-rest.ts +183 -191
  140. package/src/response-validation.ts +8 -5
  141. package/src/sdk-error.ts +33 -0
  142. package/src/sensitive.ts +154 -0
  143. package/src/telemetry-debug.ts +179 -0
  144. package/src/telemetry-hooks.ts +33 -0
  145. package/src/telemetry-host-rules.ts +39 -0
  146. package/src/telemetry-lambda-context.ts +46 -0
  147. package/src/telemetry-message-context.ts +170 -0
  148. package/src/telemetry-metrics.ts +69 -0
  149. package/src/telemetry-name-template.ts +26 -0
  150. package/src/telemetry-stream.ts +100 -0
  151. package/src/telemetry-xray.ts +66 -0
  152. package/src/telemetry.ts +832 -0
  153. package/src/trait.ts +10 -0
  154. package/src/xml.ts +10 -1
  155. package/lib/codegen/boolean-string-enums.d.ts +0 -36
  156. package/lib/codegen/boolean-string-enums.d.ts.map +0 -1
  157. package/lib/codegen/boolean-string-enums.js +0 -147
  158. package/lib/codegen/boolean-string-enums.js.map +0 -1
  159. package/lib/codegen/chunk.d.ts +0 -7
  160. package/lib/codegen/chunk.d.ts.map +0 -1
  161. package/lib/codegen/chunk.js +0 -139
  162. package/lib/codegen/chunk.js.map +0 -1
  163. package/lib/codegen/cli.d.ts +0 -80
  164. package/lib/codegen/cli.d.ts.map +0 -1
  165. package/lib/codegen/cli.js +0 -166
  166. package/lib/codegen/cli.js.map +0 -1
  167. package/lib/codegen/datafy.d.ts +0 -14
  168. package/lib/codegen/datafy.d.ts.map +0 -1
  169. package/lib/codegen/datafy.js +0 -853
  170. package/lib/codegen/datafy.js.map +0 -1
  171. package/lib/codegen/dedupe.d.ts +0 -5
  172. package/lib/codegen/dedupe.d.ts.map +0 -1
  173. package/lib/codegen/dedupe.js +0 -153
  174. package/lib/codegen/dedupe.js.map +0 -1
  175. package/lib/codegen/emit.d.ts +0 -125
  176. package/lib/codegen/emit.d.ts.map +0 -1
  177. package/lib/codegen/emit.js +0 -99
  178. package/lib/codegen/emit.js.map +0 -1
  179. package/lib/codegen/format.d.ts +0 -11
  180. package/lib/codegen/format.d.ts.map +0 -1
  181. package/lib/codegen/format.js +0 -32
  182. package/lib/codegen/format.js.map +0 -1
  183. package/lib/codegen/generated-at.d.ts +0 -29
  184. package/lib/codegen/generated-at.d.ts.map +0 -1
  185. package/lib/codegen/generated-at.js +0 -78
  186. package/lib/codegen/generated-at.js.map +0 -1
  187. package/lib/codegen/generator.d.ts +0 -353
  188. package/lib/codegen/generator.d.ts.map +0 -1
  189. package/lib/codegen/generator.js +0 -810
  190. package/lib/codegen/generator.js.map +0 -1
  191. package/lib/codegen/graph.d.ts +0 -36
  192. package/lib/codegen/graph.d.ts.map +0 -1
  193. package/lib/codegen/graph.js +0 -136
  194. package/lib/codegen/graph.js.map +0 -1
  195. package/lib/codegen/graphql-client.d.ts +0 -70
  196. package/lib/codegen/graphql-client.d.ts.map +0 -1
  197. package/lib/codegen/graphql-client.js +0 -439
  198. package/lib/codegen/graphql-client.js.map +0 -1
  199. package/lib/codegen/graphql.d.ts +0 -207
  200. package/lib/codegen/graphql.d.ts.map +0 -1
  201. package/lib/codegen/graphql.js +0 -786
  202. package/lib/codegen/graphql.js.map +0 -1
  203. package/lib/codegen/latin1.d.ts +0 -3
  204. package/lib/codegen/latin1.d.ts.map +0 -1
  205. package/lib/codegen/latin1.js +0 -126
  206. package/lib/codegen/latin1.js.map +0 -1
  207. package/lib/codegen/members.d.ts +0 -32
  208. package/lib/codegen/members.d.ts.map +0 -1
  209. package/lib/codegen/members.js +0 -62
  210. package/lib/codegen/members.js.map +0 -1
  211. package/lib/codegen/model-diff.d.ts +0 -10
  212. package/lib/codegen/model-diff.d.ts.map +0 -1
  213. package/lib/codegen/model-diff.js +0 -67
  214. package/lib/codegen/model-diff.js.map +0 -1
  215. package/lib/codegen/naming.d.ts +0 -29
  216. package/lib/codegen/naming.d.ts.map +0 -1
  217. package/lib/codegen/naming.js +0 -74
  218. package/lib/codegen/naming.js.map +0 -1
  219. package/lib/codegen/openapi-cli.d.ts +0 -52
  220. package/lib/codegen/openapi-cli.d.ts.map +0 -1
  221. package/lib/codegen/openapi-cli.js +0 -84
  222. package/lib/codegen/openapi-cli.js.map +0 -1
  223. package/lib/codegen/openapi.d.ts +0 -209
  224. package/lib/codegen/openapi.d.ts.map +0 -1
  225. package/lib/codegen/openapi.js +0 -1548
  226. package/lib/codegen/openapi.js.map +0 -1
  227. package/lib/codegen/operations.d.ts +0 -24
  228. package/lib/codegen/operations.d.ts.map +0 -1
  229. package/lib/codegen/operations.js +0 -56
  230. package/lib/codegen/operations.js.map +0 -1
  231. package/lib/codegen/pagination.d.ts +0 -39
  232. package/lib/codegen/pagination.d.ts.map +0 -1
  233. package/lib/codegen/pagination.js +0 -31
  234. package/lib/codegen/pagination.js.map +0 -1
  235. package/lib/codegen/patch-audit.d.ts +0 -84
  236. package/lib/codegen/patch-audit.d.ts.map +0 -1
  237. package/lib/codegen/patch-audit.js +0 -366
  238. package/lib/codegen/patch-audit.js.map +0 -1
  239. package/lib/codegen/patches.d.ts +0 -129
  240. package/lib/codegen/patches.d.ts.map +0 -1
  241. package/lib/codegen/patches.js +0 -472
  242. package/lib/codegen/patches.js.map +0 -1
  243. package/lib/codegen/prelude.d.ts +0 -15
  244. package/lib/codegen/prelude.d.ts.map +0 -1
  245. package/lib/codegen/prelude.js +0 -60
  246. package/lib/codegen/prelude.js.map +0 -1
  247. package/lib/codegen/privatize.d.ts +0 -21
  248. package/lib/codegen/privatize.d.ts.map +0 -1
  249. package/lib/codegen/privatize.js +0 -176
  250. package/lib/codegen/privatize.js.map +0 -1
  251. package/lib/codegen/proto.d.ts +0 -121
  252. package/lib/codegen/proto.d.ts.map +0 -1
  253. package/lib/codegen/proto.js +0 -960
  254. package/lib/codegen/proto.js.map +0 -1
  255. package/lib/codegen/pure.d.ts +0 -6
  256. package/lib/codegen/pure.d.ts.map +0 -1
  257. package/lib/codegen/pure.js +0 -91
  258. package/lib/codegen/pure.js.map +0 -1
  259. package/lib/codegen/rewrite-operation-ids.d.ts +0 -154
  260. package/lib/codegen/rewrite-operation-ids.d.ts.map +0 -1
  261. package/lib/codegen/rewrite-operation-ids.js +0 -1117
  262. package/lib/codegen/rewrite-operation-ids.js.map +0 -1
  263. package/lib/codegen/spec-path.d.ts +0 -16
  264. package/lib/codegen/spec-path.d.ts.map +0 -1
  265. package/lib/codegen/spec-path.js +0 -101
  266. package/lib/codegen/spec-path.js.map +0 -1
  267. package/lib/codegen/table.d.ts +0 -5
  268. package/lib/codegen/table.d.ts.map +0 -1
  269. package/lib/codegen/table.js +0 -249
  270. package/lib/codegen/table.js.map +0 -1
  271. package/lib/debug.d.ts +0 -2
  272. package/lib/debug.d.ts.map +0 -1
  273. package/lib/debug.js +0 -1
  274. package/lib/json-patch.d.ts +0 -58
  275. package/lib/json-patch.d.ts.map +0 -1
  276. package/lib/json-patch.js +0 -2
  277. package/lib/json-patch.js.map +0 -1
  278. package/lib/schema-lite-typed.js.map +0 -1
  279. package/lib/testing.d.ts +0 -40
  280. package/lib/testing.d.ts.map +0 -1
  281. package/lib/testing.js +0 -2
  282. package/lib/testing.js.map +0 -1
  283. package/src/codegen/boolean-string-enums.ts +0 -155
  284. package/src/codegen/chunk.ts +0 -147
  285. package/src/codegen/cli.ts +0 -293
  286. package/src/codegen/datafy.ts +0 -874
  287. package/src/codegen/dedupe.ts +0 -173
  288. package/src/codegen/emit.ts +0 -200
  289. package/src/codegen/format.ts +0 -49
  290. package/src/codegen/generated-at.ts +0 -88
  291. package/src/codegen/generator.ts +0 -1229
  292. package/src/codegen/graph.ts +0 -151
  293. package/src/codegen/graphql-client.ts +0 -545
  294. package/src/codegen/graphql.ts +0 -1145
  295. package/src/codegen/latin1.ts +0 -131
  296. package/src/codegen/members.ts +0 -79
  297. package/src/codegen/model-diff.ts +0 -67
  298. package/src/codegen/naming.ts +0 -85
  299. package/src/codegen/openapi-cli.ts +0 -141
  300. package/src/codegen/openapi.ts +0 -1845
  301. package/src/codegen/operations.ts +0 -73
  302. package/src/codegen/pagination.ts +0 -64
  303. package/src/codegen/patch-audit.ts +0 -480
  304. package/src/codegen/patches.ts +0 -581
  305. package/src/codegen/prelude.ts +0 -70
  306. package/src/codegen/privatize.ts +0 -200
  307. package/src/codegen/proto.ts +0 -1092
  308. package/src/codegen/pure.ts +0 -94
  309. package/src/codegen/rewrite-operation-ids.ts +0 -1219
  310. package/src/codegen/spec-path.ts +0 -112
  311. package/src/codegen/table.ts +0 -254
  312. package/src/debug.ts +0 -8
  313. package/src/json-patch.ts +0 -273
  314. package/src/testing.ts +0 -74
@@ -1,1845 +0,0 @@
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
- */
46
-
47
- import { ADDITIONAL_PROPERTIES_TRAIT } from "./members.ts";
48
- import {
49
- isMechanicalOperationId,
50
- isVerbatimRouteId,
51
- pathToVerbNoun,
52
- RENAME_METADATA_KEY,
53
- renameShapes,
54
- resolveOperationName,
55
- toVerbNoun,
56
- type OperationIdRewrite,
57
- } from "./rewrite-operation-ids.ts";
58
-
59
- // ============================================================================
60
- // Trait ids (the `com.distilled.openapi` vocabulary)
61
- // ============================================================================
62
-
63
- /** Member-level nullability (`S.NullOr` + `| null` via `SdkSpec.nullableTrait`). */
64
- export const NULLABLE_TRAIT = "com.distilled.openapi#nullable";
65
- /**
66
- * Marks the sole member of a synthesized response wrapper for bare
67
- * array/scalar response bodies. SdkSpecs bind it with a `rootPipe`
68
- * (`T.RawResponseRoot()` from `core/protocol-rest`), so the emitted response
69
- * type IS the payload type.
70
- */
71
- export const RAW_RESPONSE_TRAIT = "com.distilled.openapi#rawResponse";
72
- /**
73
- * Wire-matching rules for a generated error class (see
74
- * `SdkSpec.errorMatchersTrait` + `applyErrorMatchers`). The converter stamps
75
- * `[{ status }]` from the response status the class was mapped from.
76
- */
77
- export const ERROR_MATCHERS_TRAIT = "com.distilled.openapi#errorMatchers";
78
- /**
79
- * Non-JSON request body encoding chosen by the v0 content-type precedence
80
- * (json > form-urlencoded > multipart). Value: `"form-urlencoded"` |
81
- * `"multipart"`. `"multipart"` is also merged into the `smithy.api#http`
82
- * trait's `contentType` (which core's `buildRequest` understands);
83
- * form-urlencoded is left to provider SdkSpecs/protocols.
84
- */
85
- export const CONTENT_TYPE_TRAIT = "com.distilled.openapi#contentType";
86
- /**
87
- * The `apiVersion` recorded on every operation when
88
- * {@link OpenApiConvertOptions.apiVersion} is set (Azure ARM style). The
89
- * matching `api-version` query parameter is dropped from inputs; the
90
- * provider's protocol injects it at request time.
91
- */
92
- export const API_VERSION_TRAIT = "com.distilled.openapi#apiVersion";
93
-
94
- // ============================================================================
95
- // Sensitive-field name patterns (distilled v0's SENSITIVE_FIELD_PATTERNS)
96
- // ============================================================================
97
-
98
- export const SENSITIVE_FIELD_PATTERNS: readonly RegExp[] = [
99
- /password/i,
100
- /^secret$/i,
101
- /secret[-_]?key/i,
102
- /[-_]secret$/i,
103
- /^client[-_]?secret$/i,
104
- /^access[-_]?token$/i,
105
- /^refresh[-_]?token$/i,
106
- /^api[-_]?key$/i,
107
- /^api[-_]?key[-_]?secret$/i,
108
- /^api[-_]?token$/i,
109
- /^private[-_]?key$/i,
110
- /^secret[-_]?access[-_]?key$/i,
111
- /^session[-_]?token$/i,
112
- /^access[-_]?key[-_]?id$/i,
113
- /^one[-_]?time[-_]?password$/i,
114
- /^connection[-_]?string$/i,
115
- /^connection[-_]?uri$/i,
116
- /^plain[-_]?text$/i,
117
- /^plain[-_]?text[-_]?refresh[-_]?token$/i,
118
- ];
119
-
120
- // ============================================================================
121
- // Options
122
- // ============================================================================
123
-
124
- export interface OpenApiConvertOptions {
125
- /** Shape namespace, e.g. `"com.neon.api"`. */
126
- readonly namespace: string;
127
- /** Service shape name (PascalCased), e.g. `"Neon"`. */
128
- readonly serviceName: string;
129
- /** Service shape `version`. Default: the spec's `info.version`, else "1.0". */
130
- readonly serviceVersion?: string;
131
- /**
132
- * Non-2xx response status → error class name. Statuses in
133
- * {@link defaultErrorStatuses} never produce per-op errors. Default:
134
- * `{400: BadRequest, 403: Forbidden, 404: NotFound, 409: Conflict,
135
- * 422: UnprocessableEntity}` (the v0 default).
136
- */
137
- readonly statusToErrorClass?: Readonly<Record<string, string>>;
138
- /**
139
- * Statuses covered by the SDK's common errors, excluded from per-op error
140
- * lists. Default: `{"401","429","500","503"}` (the v0 default).
141
- */
142
- readonly defaultErrorStatuses?: Iterable<string>;
143
- /** Skip operations marked `deprecated: true`. Default true. */
144
- readonly skipDeprecated?: boolean;
145
- /**
146
- * HTTP methods to convert IN ADDITION to get/post/put/patch/delete —
147
- * currently `"head"` and `"options"`. Opt-in, so a provider that models
148
- * them (Vercel probes cache artifacts and sandbox files with HEAD) gets
149
- * them without every other provider silently gaining operations.
150
- *
151
- * `head` operations always output `smithy.api#Unit` — see the output-shape
152
- * comment in {@link convertOpenApiToSmithy} for why a declared response
153
- * body on a HEAD can never arrive.
154
- */
155
- readonly extraHttpMethods?: readonly ("head" | "options")[];
156
- /**
157
- * Emit `in: header` parameters as `smithy.api#httpHeader` members instead
158
- * of dropping them. Opt-in for the same reason as
159
- * {@link extraHttpMethods}: turning it on adds input members to every
160
- * operation whose spec declares a header parameter, and most providers
161
- * declare ones the protocol already sends itself (Accept, Authorization,
162
- * an API-version pin). Providers whose headers are real per-call inputs
163
- * — Vercel's `x-Artifact-*` remote-cache metadata, `x-Vercel-Digest` —
164
- * ask for them.
165
- */
166
- readonly headerParams?: boolean;
167
- /**
168
- * Convert `format: binary` strings to blobs and include binary
169
- * `application/octet-stream` responses. Opt in only when the provider's
170
- * generator and protocol support binary inputs and outputs. Default false.
171
- */
172
- readonly binaryTypes?: boolean;
173
- /**
174
- * Response statuses to read the operation's output shape from, most
175
- * preferred first. Default `["200", "201", "204"]`. Extend it for an API
176
- * that answers asynchronous work with a body under another status — Vercel
177
- * returns `202 Accepted` with a payload from nine endpoints (artifact
178
- * upload, account deletion, VCR blob/manifest writes), which would
179
- * otherwise generate as a `void` output.
180
- */
181
- readonly successStatuses?: readonly string[];
182
- /**
183
- * Response headers (matched case-insensitively) to add to an operation's
184
- * output as optional `smithy.api#httpHeader` members wherever one of its
185
- * 2xx responses declares them -- bodiless ones such as `202 Accepted`
186
- * included. An allowlist for the same reason as {@link headerParams}:
187
- * specs declare noise headers (request ids, ETags) on most responses.
188
- * Azure lists its long-running-operation status monitor
189
- * (`Azure-AsyncOperation`, `Location`, `Retry-After`), which callers need
190
- * to follow the operation themselves.
191
- *
192
- * An operation whose output reuses a named component gets its own output
193
- * structure (the component's members plus the headers), so the headers
194
- * never leak into other operations sharing that component. A header whose
195
- * member name a body member already uses is suffixed `Header`
196
- * (`Location` → `locationHeader` next to ARM's `location` region).
197
- */
198
- readonly responseHeaders?: readonly string[];
199
- /**
200
- * Azure-style fixed `api-version`: drops `api-version` query params and
201
- * stamps {@link API_VERSION_TRAIT} on every operation.
202
- */
203
- readonly apiVersion?: string;
204
- /**
205
- * Name patterns marking string members sensitive. Default
206
- * {@link SENSITIVE_FIELD_PATTERNS}. Pass `[]` to disable name-based
207
- * detection (explicit `x-sensitive: true` still applies).
208
- */
209
- readonly sensitivePatterns?: readonly RegExp[];
210
- /**
211
- * Optional full shape-definition overrides for emitted error classes
212
- * (keyed by class name) — e.g. custom members. The converter's default is
213
- * an empty structure with `smithy.api#error` + `smithy.api#httpError` +
214
- * {@link ERROR_MATCHERS_TRAIT} traits; overrides are merged over it.
215
- */
216
- readonly errorShapes?: Readonly<Record<string, any>>;
217
- /**
218
- * How to turn an OpenAPI `operationId` into the Smithy/SDK operation name.
219
- * This is a convert policy, not a spec patch — the OpenAPI document is
220
- * left alone.
221
- *
222
- * - `"verbNoun"` (default): `Apps_list` / `ConfigsList` / `showContact` →
223
- * `listApps` / `listConfigs` / `getApp`. Already verb-first ids stay.
224
- * An operation with no `operationId`, or a mechanical one that only
225
- * restates the method and path (`get-api-card`, `post_v1_users`), is
226
- * named from the route instead: `GET /users` → `listUsers`,
227
- * `GET /users/{id}` → `getUser`, `POST /users/{id}/reset` →
228
- * `resetUser`.
229
- * - `"as-is"`: `PascalCase(operationId)` (`Apps_list` → `AppsList`).
230
- *
231
- * {@link operationNames} overrides win (lookup by `"METHOD path"`, then
232
- * operationId).
233
- */
234
- readonly operationNaming?: "as-is" | "verbNoun";
235
- /**
236
- * Per-operation name overrides for {@link operationNaming}. Use
237
- * `"METHOD path"` keys when two methods share an `operationId`.
238
- */
239
- readonly operationNames?: OperationIdRewrite;
240
- /**
241
- * Name shapes from the spec (`PascalCase(operationId)`, no overrides) and
242
- * record the {@link operationNaming} names in
243
- * `metadata[RENAME_METADATA_KEY]`; `finalizeConvert` renames after the
244
- * Smithy patches, so patches target upstream names.
245
- */
246
- readonly deferNaming?: boolean;
247
- }
248
-
249
- export interface SmithyModel {
250
- smithy: "2.0";
251
- metadata: any;
252
- shapes: Record<string, any>;
253
- }
254
-
255
- // ============================================================================
256
- // String helpers (same conventions as cloudflare's spec-to-smithy)
257
- // ============================================================================
258
-
259
- const PRELUDE = {
260
- Unit: "smithy.api#Unit",
261
- String: "smithy.api#String",
262
- Blob: "smithy.api#Blob",
263
- Boolean: "smithy.api#Boolean",
264
- Double: "smithy.api#Double",
265
- Integer: "smithy.api#Integer",
266
- Document: "smithy.api#Document",
267
- } as const;
268
-
269
- /** snake/kebab/space/camel → PascalCase identifier (inner caps preserved). */
270
- const pascal = (s: string): string => {
271
- const parts = s.split(/[^A-Za-z0-9]+/).filter(Boolean);
272
- let out = parts.map((p) => p.charAt(0).toUpperCase() + p.slice(1)).join("");
273
- if (out === "") out = "Shape";
274
- if (/^[0-9]/.test(out)) out = `_${out}`;
275
- return out;
276
- };
277
-
278
- /** Keep a JSON field name if it's a valid Smithy member identifier, else sanitize. */
279
- const memberIdent = (name: string): string => {
280
- let out = name.replace(/[^A-Za-z0-9_]/g, "_");
281
- if (/^[0-9]/.test(out)) out = `_${out}`;
282
- return out || "_";
283
- };
284
-
285
- /**
286
- * Header name → member identifier (`x-Artifact-Tag` → `xArtifactTag`). The
287
- * wire name is carried by the `smithy.api#httpHeader` trait, so the member
288
- * can read like the rest of the input rather than like a header.
289
- */
290
- const headerMemberName = (name: string): string => {
291
- const parts = name.split(/[^A-Za-z0-9]+/).filter(Boolean);
292
- if (parts.length === 0) return "_";
293
- const out = parts
294
- .map((p, i) =>
295
- i === 0 ? p.charAt(0).toLowerCase() + p.slice(1) : p.charAt(0).toUpperCase() + p.slice(1),
296
- )
297
- .join("");
298
- return /^[0-9]/.test(out) ? `_${out}` : out;
299
- };
300
-
301
- const enumMemberName = (value: string): string => {
302
- let out = value
303
- .toUpperCase()
304
- .replace(/[^A-Z0-9]+/g, "_")
305
- .replace(/^_+|_+$/g, "");
306
- if (out === "") out = "VALUE";
307
- if (/^[0-9]/.test(out)) out = `_${out}`;
308
- return out;
309
- };
310
-
311
- // ============================================================================
312
- // Conversion context
313
- // ============================================================================
314
-
315
- const MAX_SCHEMA_DEPTH = 40;
316
-
317
- /**
318
- * Conversion direction: `"in"` for request-position schemas (drop
319
- * `readOnly: true` members), `"out"` for response-position schemas (drop
320
- * `writeOnly: true` members).
321
- */
322
- type Dir = "in" | "out";
323
-
324
- interface Ctx {
325
- readonly spec: any;
326
- readonly version: "2.0" | "3.0" | "3.1";
327
- readonly ns: string;
328
- readonly shapes: Record<string, any>;
329
- readonly names: Set<string>;
330
- /**
331
- * Variant-keyed `$ref` cache (`"*:<ref>"` for direction-agnostic schemas,
332
- * `"in:<ref>"`/`"out:<ref>"` for direction-sensitive ones) → converted
333
- * result (cycle-safe; mutated in place).
334
- */
335
- readonly refs: Map<string, { target: string; nullable: boolean }>;
336
- /**
337
- * Per-direction set of `$ref` pointers whose reachable schema graph
338
- * contains the direction's excluded flag (see {@link dirSensitive}).
339
- * Built lazily, once per direction, by {@link buildDirSensitiveRefs}.
340
- */
341
- readonly dirSensitiveRefs: Map<Dir, ReadonlySet<string>>;
342
- readonly sensitivePatterns: readonly RegExp[];
343
- readonly binaryTypes: boolean;
344
- }
345
-
346
- interface Converted {
347
- target: string;
348
- nullable: boolean;
349
- }
350
-
351
- const uniqueName = (ctx: Ctx, base: string): string => {
352
- const want = pascal(base);
353
- let name = want;
354
- let n = 2;
355
- while (ctx.names.has(name)) name = `${want}${n++}`;
356
- ctx.names.add(name);
357
- return name;
358
- };
359
-
360
- const addShape = (ctx: Ctx, base: string, def: any): string => {
361
- const id = `${ctx.ns}#${uniqueName(ctx, base)}`;
362
- ctx.shapes[id] = def;
363
- return id;
364
- };
365
-
366
- const detectVersion = (spec: any): "2.0" | "3.0" | "3.1" => {
367
- if (spec?.swagger === "2.0") return "2.0";
368
- const v = spec?.openapi;
369
- if (typeof v === "string" && v.startsWith("3.1")) return "3.1";
370
- if (typeof v === "string" && v.startsWith("3.0")) return "3.0";
371
- throw new Error(
372
- `Unsupported OpenAPI version (swagger=${spec?.swagger}, openapi=${spec?.openapi})`,
373
- );
374
- };
375
-
376
- /** Resolve a local `#/...` JSON pointer against the spec document. */
377
- const resolvePointer = (spec: any, ref: string): any => {
378
- if (typeof ref !== "string" || !ref.startsWith("#/")) return undefined;
379
- let cur = spec;
380
- for (const raw of ref.slice(2).split("/")) {
381
- const seg = raw.replace(/~1/g, "/").replace(/~0/g, "~");
382
- if (cur === null || typeof cur !== "object") return undefined;
383
- cur = cur[seg];
384
- }
385
- return cur;
386
- };
387
-
388
- /** Follow `$ref` chains (bounded) to the underlying schema object. */
389
- const deref = (ctx: Ctx, def: any): any => {
390
- let cur = def;
391
- for (let i = 0; i < 16 && cur && typeof cur === "object" && cur.$ref; i++) {
392
- cur = resolvePointer(ctx.spec, cur.$ref);
393
- }
394
- return cur;
395
- };
396
-
397
- // ============================================================================
398
- // allOf flattening + nullability
399
- // ============================================================================
400
-
401
- interface FlatObject {
402
- properties: Record<string, any>;
403
- required: Set<string>;
404
- isObject: boolean;
405
- /** First `additionalProperties` schema seen (allOf-merged map bodies). */
406
- additionalProperties?: any;
407
- }
408
-
409
- /**
410
- * Flatten a schema into a property bag: `$ref`s resolved, `allOf` merged
411
- * (properties + required unioned across resolved subschemas). A
412
- * `oneOf`/`anyOf` encountered INSIDE an `allOf` merges its branches'
413
- * properties as OPTIONAL members — the loosest satisfiable reading of the
414
- * intersection — rather than dropping them; a top-level union is left to
415
- * the union conversion path.
416
- */
417
- const flattenObject = (ctx: Ctx, def: any, depth = 0): FlatObject => {
418
- const out: FlatObject = {
419
- properties: {},
420
- required: new Set(),
421
- isObject: false,
422
- };
423
- // Revisiting a `$ref` under the same flags merges nothing new (property
424
- // merge is first-wins) — dedupe so shared/cyclic allOf bases are walked
425
- // once per flag combination instead of exponentially (MongoDB Atlas's
426
- // polymorphic allOf/oneOf graph never finished under the bare depth cap).
427
- const seen = new Set<string>();
428
- const visit = (d: any, dep: number, inAllOf: boolean, inUnion: boolean): void => {
429
- if (dep > MAX_SCHEMA_DEPTH) return;
430
- if (d && typeof d === "object" && typeof d.$ref === "string") {
431
- const key = `${d.$ref}|${inAllOf}|${inUnion}`;
432
- if (seen.has(key)) return;
433
- seen.add(key);
434
- }
435
- const r = deref(ctx, d);
436
- if (!r || typeof r !== "object") return;
437
- if (Array.isArray(r.allOf)) {
438
- for (const sub of r.allOf) visit(sub, dep + 1, true, inUnion);
439
- }
440
- if (inAllOf) {
441
- const branches = r.oneOf ?? r.anyOf;
442
- if (Array.isArray(branches)) {
443
- for (const b of branches) {
444
- if (!isNullBranch(ctx, b)) visit(b, dep + 1, inAllOf, true);
445
- }
446
- }
447
- }
448
- if (r.properties && typeof r.properties === "object") {
449
- out.isObject = true;
450
- for (const [k, v] of Object.entries(r.properties)) {
451
- if (!(k in out.properties)) out.properties[k] = v;
452
- }
453
- }
454
- if (r.type === "object") out.isObject = true;
455
- if (
456
- out.additionalProperties === undefined &&
457
- r.additionalProperties !== undefined &&
458
- r.additionalProperties !== false
459
- ) {
460
- out.additionalProperties = r.additionalProperties;
461
- }
462
- if (!inUnion && Array.isArray(r.required)) {
463
- for (const k of r.required) out.required.add(k);
464
- }
465
- };
466
- visit(def, depth, false, false);
467
- return out;
468
- };
469
-
470
- /** Whether a `oneOf`/`anyOf` branch represents JSON null. */
471
- const isNullBranch = (ctx: Ctx, branch: any): boolean => {
472
- const r = deref(ctx, branch);
473
- if (!r || typeof r !== "object") return false;
474
- if (r.type === "null") return true;
475
- if (Array.isArray(r.type) && r.type.every((t: unknown) => t === "null")) {
476
- return true;
477
- }
478
- if (Array.isArray(r.enum) && r.enum.length > 0 && r.enum.every((v: unknown) => v === null)) {
479
- return true;
480
- }
481
- return false;
482
- };
483
-
484
- /** Intrinsic nullability flags on a schema node (not union null branches). */
485
- const ownNullable = (ctx: Ctx, def: any): boolean => {
486
- if (!def || typeof def !== "object") return false;
487
- // `nullable: true` is 3.0 vocabulary but appears in real 3.1 (and even
488
- // 2.0) documents — honor it everywhere rather than silently dropping the
489
- // null arm.
490
- if (def.nullable === true) return true;
491
- if (def["x-nullable"] === true) return true;
492
- if (Array.isArray(def.type) && def.type.includes("null")) return true;
493
- return false;
494
- };
495
-
496
- /**
497
- * Whether a property schema is excluded from the given direction:
498
- * `readOnly: true` properties never appear in requests, `writeOnly: true`
499
- * properties never appear in responses. Checks the property node itself and
500
- * its `$ref` resolution.
501
- */
502
- const dirExcluded = (ctx: Ctx, prop: any, dir: Dir): boolean => {
503
- const flag = dir === "in" ? "readOnly" : "writeOnly";
504
- if (prop && typeof prop === "object" && prop[flag] === true) return true;
505
- const r = deref(ctx, prop);
506
- return !!r && typeof r === "object" && r[flag] === true;
507
- };
508
-
509
- /** Child schema slots the direction-sensitivity walk descends through. */
510
- const schemaChildren = (d: any): any[] => [
511
- ...(Array.isArray(d.allOf) ? d.allOf : []),
512
- ...(Array.isArray(d.oneOf) ? d.oneOf : []),
513
- ...(Array.isArray(d.anyOf) ? d.anyOf : []),
514
- ...(d.properties && typeof d.properties === "object" ? Object.values(d.properties) : []),
515
- ...(d.items ? [d.items] : []),
516
- ...(d.additionalProperties && typeof d.additionalProperties === "object"
517
- ? [d.additionalProperties]
518
- : []),
519
- ];
520
-
521
- /**
522
- * Walk an INLINE schema subtree (stopping at `$ref` nodes, which are
523
- * appended to `refs` instead of followed). Returns whether the flag
524
- * appears inline. Inline subtrees are JSON trees — no cycles.
525
- */
526
- const scanInlineForFlag = (d: any, flag: string, refs: string[]): boolean => {
527
- if (!d || typeof d !== "object") return false;
528
- if (typeof d.$ref === "string") {
529
- refs.push(d.$ref);
530
- return false;
531
- }
532
- if (d[flag] === true) return true;
533
- for (const sub of schemaChildren(d)) {
534
- if (scanInlineForFlag(sub, flag, refs)) return true;
535
- }
536
- return false;
537
- };
538
-
539
- /**
540
- * Compute, for the WHOLE document at once, the set of `$ref` pointers that
541
- * are direction-sensitive: the flag appears somewhere in the schema graph
542
- * reachable from the ref's target. One inline scan per distinct ref target
543
- * (local flag + outgoing ref edges), then reverse propagation from the
544
- * locally-flagged nodes — linear in spec size, and cycles / diamond-shared
545
- * refs cost nothing. (This replaces a per-call DFS whose memoization was
546
- * disabled by ANY re-encountered ref; on large specs where every schema
547
- * shares refs — e.g. MongoDB Atlas's ubiquitous `links` — that re-walked
548
- * the graph for each of thousands of `$ref` sites and never finished.)
549
- */
550
- const buildDirSensitiveRefs = (ctx: Ctx, dir: Dir): ReadonlySet<string> => {
551
- const flag = dir === "in" ? "readOnly" : "writeOnly";
552
-
553
- // Every distinct `$ref` pointer in the document.
554
- const allRefs = new Set<string>();
555
- const collect = (d: any): void => {
556
- if (Array.isArray(d)) {
557
- for (const v of d) collect(v);
558
- return;
559
- }
560
- if (!d || typeof d !== "object") return;
561
- if (typeof d.$ref === "string") allRefs.add(d.$ref);
562
- for (const v of Object.values(d)) collect(v);
563
- };
564
- collect(ctx.spec);
565
-
566
- // ref → refs reachable in one hop; refs whose target carries the flag inline.
567
- const reverse = new Map<string, string[]>();
568
- const flagged: string[] = [];
569
- for (const ref of allRefs) {
570
- const outgoing: string[] = [];
571
- if (scanInlineForFlag(resolvePointer(ctx.spec, ref), flag, outgoing)) {
572
- flagged.push(ref);
573
- continue; // already sensitive; its edges can't add anything
574
- }
575
- for (const to of outgoing) {
576
- let from = reverse.get(to);
577
- if (!from) reverse.set(to, (from = []));
578
- from.push(ref);
579
- }
580
- }
581
-
582
- // Sensitivity propagates from flagged targets to every ref that reaches them.
583
- const sensitive = new Set<string>(flagged);
584
- const queue = [...flagged];
585
- while (queue.length > 0) {
586
- const next = queue.pop()!;
587
- for (const from of reverse.get(next) ?? []) {
588
- if (!sensitive.has(from)) {
589
- sensitive.add(from);
590
- queue.push(from);
591
- }
592
- }
593
- }
594
- return sensitive;
595
- };
596
-
597
- /**
598
- * Whether a schema subtree is direction-sensitive — contains
599
- * `readOnly: true` (request direction) or `writeOnly: true` (response
600
- * direction) anywhere, following local `$ref`s. Direction-sensitive named
601
- * components convert to separate request/response shape variants
602
- * (`<Name>Input`/`<Name>Output`); everything else is shared.
603
- */
604
- const dirSensitive = (ctx: Ctx, def: any, dir: Dir): boolean => {
605
- let sensitiveRefs = ctx.dirSensitiveRefs.get(dir);
606
- if (sensitiveRefs === undefined) {
607
- sensitiveRefs = buildDirSensitiveRefs(ctx, dir);
608
- ctx.dirSensitiveRefs.set(dir, sensitiveRefs);
609
- }
610
- const refs: string[] = [];
611
- if (scanInlineForFlag(def, dir === "in" ? "readOnly" : "writeOnly", refs)) {
612
- return true;
613
- }
614
- return refs.some((ref) => sensitiveRefs.has(ref));
615
- };
616
-
617
- /** Single non-array type from a possibly 3.1-style `type` value. */
618
- const typeOf = (def: any): string | undefined => {
619
- const t = def?.type;
620
- if (typeof t === "string") return t;
621
- if (Array.isArray(t)) {
622
- const real = t.filter((x: unknown) => x !== "null");
623
- if (real.length === 1 && typeof real[0] === "string") return real[0];
624
- }
625
- return undefined;
626
- };
627
-
628
- // ============================================================================
629
- // Schema conversion
630
- // ============================================================================
631
-
632
- /**
633
- * Whether a schema definition warrants a NAMED shape (vs an inline prelude
634
- * target). Named shapes can participate in reference cycles, so `$ref`s to
635
- * nameable schemas reserve their name before converting.
636
- */
637
- const isNameable = (ctx: Ctx, def: any): boolean => {
638
- if (!def || typeof def !== "object") return false;
639
- if (def.$ref) return isNameable(ctx, deref(ctx, def));
640
- if (Array.isArray(def.enum)) {
641
- const values = def.enum.filter((v: unknown) => v !== null);
642
- return (
643
- values.length > 0 &&
644
- (values.every((v: unknown) => typeof v === "string") ||
645
- values.every((v: unknown) => typeof v === "number"))
646
- );
647
- }
648
- if (Array.isArray(def.allOf)) return true;
649
- const branches = def.oneOf ?? def.anyOf;
650
- if (Array.isArray(branches)) {
651
- return branches.filter((b: any) => !isNullBranch(ctx, b)).length >= 2;
652
- }
653
- const t = typeOf(def);
654
- if (t === "object" || def.properties || def.additionalProperties) return true;
655
- if (t === "array") return true;
656
- return false;
657
- };
658
-
659
- /**
660
- * Convert one schema to a shape target. `dir` is the conversion direction
661
- * (request vs response position — readOnly/writeOnly members are dropped
662
- * accordingly). `reservedId` names the top-level shape when the caller
663
- * pre-registered it (named `$ref` targets); otherwise anonymous shapes
664
- * synthesize names from `hint`.
665
- */
666
- const convertSchema = (
667
- ctx: Ctx,
668
- def: any,
669
- hint: string,
670
- depth: number,
671
- dir: Dir,
672
- reservedId?: string,
673
- ): Converted => {
674
- const emit = (shapeDef: any, base: string): string => {
675
- if (reservedId !== undefined) {
676
- ctx.shapes[reservedId] = shapeDef;
677
- return reservedId;
678
- }
679
- return addShape(ctx, base, shapeDef);
680
- };
681
- const inline = (target: string, nullable: boolean): Converted => {
682
- // A reserved placeholder that turned out to be inline (scalar/alias):
683
- // drop the placeholder; the burned name is harmless.
684
- if (reservedId !== undefined) delete ctx.shapes[reservedId];
685
- return { target, nullable };
686
- };
687
-
688
- if (depth > MAX_SCHEMA_DEPTH) return inline(PRELUDE.Document, false);
689
- if (def === true || def === undefined || def === null) {
690
- return inline(PRELUDE.Document, false);
691
- }
692
- if (typeof def !== "object") return inline(PRELUDE.Document, false);
693
-
694
- // --- $ref → named (or cached inline) shape --------------------------------
695
- if (def.$ref) {
696
- // Sibling nullability next to the $ref (common tool output even where
697
- // the spec says siblings are ignored) survives onto the member.
698
- const siteNullable = ownNullable(ctx, def);
699
- // Direction-sensitive components (readOnly members in request position,
700
- // writeOnly in response position) get per-direction variants; the rest
701
- // share one shape across both directions.
702
- const sensitive = dirSensitive(ctx, def, dir);
703
- const cacheKey = sensitive ? `${dir}:${def.$ref}` : `*:${def.$ref}`;
704
- const cached = ctx.refs.get(cacheKey);
705
- if (cached) return inline(cached.target, cached.nullable || siteNullable);
706
- const resolved = resolvePointer(ctx.spec, def.$ref);
707
- if (resolved === undefined) return inline(PRELUDE.Document, siteNullable);
708
- const refName =
709
- (String(def.$ref).split("/").pop() ?? "Shape") +
710
- (sensitive ? (dir === "in" ? "Input" : "Output") : "");
711
- if (!isNameable(ctx, resolved)) {
712
- // Scalars and aliases can't cycle — convert inline and cache.
713
- const entry: Converted = { target: PRELUDE.Document, nullable: false };
714
- ctx.refs.set(cacheKey, entry);
715
- const r = convertSchema(ctx, resolved, pascal(refName), depth + 1, dir);
716
- entry.target = r.target;
717
- entry.nullable = r.nullable;
718
- return inline(r.target, r.nullable || siteNullable);
719
- }
720
- // Reserve the component name before converting so cycles resolve.
721
- const id = `${ctx.ns}#${uniqueName(ctx, refName)}`;
722
- const entry: Converted = { target: id, nullable: false };
723
- ctx.refs.set(cacheKey, entry);
724
- ctx.shapes[id] = { type: "structure", members: {} }; // placeholder
725
- const r = convertSchema(ctx, resolved, pascal(refName), depth + 1, dir, id);
726
- entry.target = r.target;
727
- entry.nullable = r.nullable;
728
- return inline(r.target, r.nullable || siteNullable);
729
- }
730
-
731
- let nullable = ownNullable(ctx, def);
732
- const doc = typeof def.description === "string" ? def.description : undefined;
733
- const docTraits = doc ? { "smithy.api#documentation": doc } : {};
734
-
735
- // --- oneOf / anyOf --------------------------------------------------------
736
- const branches = def.oneOf ?? def.anyOf;
737
- if (Array.isArray(branches)) {
738
- const real: any[] = [];
739
- for (const b of branches) {
740
- if (isNullBranch(ctx, b)) nullable = true;
741
- else real.push(b);
742
- }
743
- if (real.length === 0) return inline(PRELUDE.Document, nullable);
744
- if (real.length === 1) {
745
- const r = convertSchema(ctx, real[0], hint, depth + 1, dir, reservedId);
746
- return { target: r.target, nullable: nullable || r.nullable };
747
- }
748
- // Distinct branches → a union shape. Members are synthesized case names;
749
- // duplicate targets are deduped.
750
- const members: Record<string, any> = {};
751
- const seenTargets = new Set<string>();
752
- real.forEach((b, i) => {
753
- const branchName =
754
- typeof b?.$ref === "string"
755
- ? pascal(String(b.$ref).split("/").pop() ?? `Case${i}`)
756
- : `Case${i}`;
757
- const r = convertSchema(ctx, b, `${hint}${branchName}`, depth + 1, dir);
758
- if (seenTargets.has(r.target)) return;
759
- seenTargets.add(r.target);
760
- let mn = memberIdent(branchName);
761
- let k = 2;
762
- while (mn in members) mn = `${memberIdent(branchName)}_${k++}`;
763
- members[mn] = { target: r.target };
764
- });
765
- const targets = Object.values(members);
766
- if (targets.length === 1) {
767
- return inline((targets[0] as any).target, nullable);
768
- }
769
- return {
770
- target: emit({ type: "union", members, traits: docTraits }, hint),
771
- nullable,
772
- };
773
- }
774
-
775
- // --- allOf ----------------------------------------------------------------
776
- if (Array.isArray(def.allOf)) {
777
- // Single-entry allOf over a $ref: passthrough (v0 semantics), carrying
778
- // the parent's nullability/description.
779
- if (def.allOf.length === 1 && !def.properties) {
780
- const r = convertSchema(ctx, def.allOf[0], hint, depth + 1, dir, reservedId);
781
- return { target: r.target, nullable: nullable || r.nullable };
782
- }
783
- const flat = flattenObject(ctx, def, depth);
784
- if (Object.keys(flat.properties).length === 0) {
785
- // A property-less intersection of map schemas is a map, not an empty
786
- // struct.
787
- if (flat.additionalProperties !== undefined) {
788
- const r = convertSchema(
789
- ctx,
790
- { type: "object", additionalProperties: flat.additionalProperties },
791
- hint,
792
- depth + 1,
793
- dir,
794
- reservedId,
795
- );
796
- return { target: r.target, nullable: nullable || r.nullable };
797
- }
798
- if (!flat.isObject) return inline(PRELUDE.Document, nullable);
799
- }
800
- const members = buildMembers(ctx, flat.properties, flat.required, hint, depth + 1, dir);
801
- return {
802
- target: emit(
803
- { type: "structure", members, traits: structTraits(docTraits, flat.additionalProperties) },
804
- hint,
805
- ),
806
- nullable,
807
- };
808
- }
809
-
810
- // --- enum -----------------------------------------------------------------
811
- if (Array.isArray(def.enum) && def.enum.length > 0) {
812
- const values = def.enum.filter((v: unknown) => v !== null);
813
- if (values.some((v: unknown) => v === null)) nullable = true;
814
- if (values.length === 0) return inline(PRELUDE.Document, true);
815
- if (values.every((v: unknown) => typeof v === "string")) {
816
- const members: Record<string, any> = {};
817
- const used = new Set<string>();
818
- for (const lit of values as string[]) {
819
- let mn = enumMemberName(lit);
820
- let k = 2;
821
- while (used.has(mn)) mn = `${enumMemberName(lit)}_${k++}`;
822
- used.add(mn);
823
- members[mn] = {
824
- target: PRELUDE.Unit,
825
- traits: { "smithy.api#enumValue": lit },
826
- };
827
- }
828
- return {
829
- target: emit({ type: "enum", members, traits: docTraits }, hint),
830
- nullable,
831
- };
832
- }
833
- // Numeric enums → intEnum shapes (closed numeric literal unions in the
834
- // generated TS; the schema stays a plain number).
835
- if (values.every((v: unknown) => typeof v === "number")) {
836
- const members: Record<string, any> = {};
837
- const used = new Set<string>();
838
- for (const lit of values as number[]) {
839
- let mn = enumMemberName(String(lit));
840
- let k = 2;
841
- while (used.has(mn)) mn = `${enumMemberName(String(lit))}_${k++}`;
842
- used.add(mn);
843
- members[mn] = {
844
- target: PRELUDE.Unit,
845
- traits: { "smithy.api#enumValue": lit },
846
- };
847
- }
848
- return {
849
- target: emit({ type: "intEnum", members, traits: docTraits }, hint),
850
- nullable,
851
- };
852
- }
853
- if (values.every((v: unknown) => typeof v === "boolean")) {
854
- return inline(PRELUDE.Boolean, nullable);
855
- }
856
- return inline(PRELUDE.Document, nullable);
857
- }
858
-
859
- const t = typeOf(def);
860
-
861
- // --- array ----------------------------------------------------------------
862
- if (t === "array") {
863
- const item = convertSchema(ctx, def.items, `${hint}Item`, depth + 1, dir);
864
- return {
865
- target: emit(
866
- {
867
- type: "list",
868
- member: {
869
- target: item.target,
870
- ...(item.nullable ? { traits: { [NULLABLE_TRAIT]: {} } } : {}),
871
- },
872
- traits: docTraits,
873
- },
874
- reservedId !== undefined ? hint : `${hint}List`,
875
- ),
876
- nullable,
877
- };
878
- }
879
-
880
- // --- object ---------------------------------------------------------------
881
- if (t === "object" || def.properties || def.additionalProperties) {
882
- if (def.properties && Object.keys(def.properties).length > 0) {
883
- const required = new Set<string>(Array.isArray(def.required) ? def.required : []);
884
- const members = buildMembers(ctx, def.properties, required, hint, depth + 1, dir);
885
- return {
886
- target: emit(
887
- {
888
- type: "structure",
889
- members,
890
- traits: structTraits(docTraits, def.additionalProperties),
891
- },
892
- hint,
893
- ),
894
- nullable,
895
- };
896
- }
897
- const ap = def.additionalProperties;
898
- if (ap !== undefined && ap !== false) {
899
- const value =
900
- ap === true || (typeof ap === "object" && Object.keys(ap).length === 0)
901
- ? { target: PRELUDE.Document, nullable: false }
902
- : convertSchema(ctx, ap, `${hint}Value`, depth + 1, dir);
903
- return {
904
- target: emit(
905
- {
906
- type: "map",
907
- key: { target: PRELUDE.String },
908
- value: {
909
- target: value.target,
910
- ...(value.nullable ? { traits: { [NULLABLE_TRAIT]: {} } } : {}),
911
- },
912
- traits: docTraits,
913
- },
914
- reservedId !== undefined ? hint : `${hint}Map`,
915
- ),
916
- nullable,
917
- };
918
- }
919
- return inline(PRELUDE.Document, nullable);
920
- }
921
-
922
- // --- scalars --------------------------------------------------------------
923
- switch (t) {
924
- case "string":
925
- return inline(
926
- ctx.binaryTypes && def.format === "binary" ? PRELUDE.Blob : PRELUDE.String,
927
- nullable,
928
- );
929
- case "boolean":
930
- return inline(PRELUDE.Boolean, nullable);
931
- case "integer":
932
- return inline(PRELUDE.Integer, nullable);
933
- case "number":
934
- return inline(PRELUDE.Double, nullable);
935
- case "null":
936
- return inline(PRELUDE.Document, true);
937
- default:
938
- return inline(PRELUDE.Document, nullable);
939
- }
940
- };
941
-
942
- /**
943
- * A structure's traits: its docs, plus the open-object marker when the spec
944
- * explicitly allows keys beyond `properties` (`additionalProperties: true`
945
- * or a schema). An absent `additionalProperties` stays closed: most specs
946
- * omit it without meaning "any key".
947
- */
948
- const structTraits = (docTraits: Record<string, unknown>, ap: unknown): Record<string, unknown> =>
949
- ap !== undefined && ap !== false
950
- ? { ...docTraits, [ADDITIONAL_PROPERTIES_TRAIT]: {} }
951
- : docTraits;
952
-
953
- /** Whether a property is a sensitive string (x-sensitive or name pattern). */
954
- const isSensitiveProperty = (ctx: Ctx, name: string, def: any): boolean => {
955
- const r = deref(ctx, def);
956
- if (!r || typeof r !== "object") return false;
957
- const isString = typeOf(r) === "string" && !Array.isArray(r.enum);
958
- if (!isString) return false;
959
- if (r["x-sensitive"] === true || def?.["x-sensitive"] === true) return true;
960
- return ctx.sensitivePatterns.some((p) => p.test(name));
961
- };
962
-
963
- /**
964
- * Build a structure's members from an OpenAPI property map. Direction-
965
- * excluded properties (`readOnly` in requests, `writeOnly` in responses)
966
- * are dropped — along with any response-side `required` they carried.
967
- */
968
- const buildMembers = (
969
- ctx: Ctx,
970
- properties: Record<string, any>,
971
- required: ReadonlySet<string>,
972
- hint: string,
973
- depth: number,
974
- dir: Dir,
975
- ): Record<string, any> => {
976
- const members: Record<string, any> = {};
977
- for (const [name, prop] of Object.entries(properties)) {
978
- if (dirExcluded(ctx, prop, dir)) continue;
979
- let mn = memberIdent(name);
980
- let k = 2;
981
- while (mn in members) mn = `${memberIdent(name)}_${k++}`;
982
- const conv = convertSchema(ctx, prop, `${hint}${pascal(name)}`, depth, dir);
983
- const traits: Record<string, any> = {};
984
- const doc =
985
- prop && typeof prop === "object" && typeof prop.description === "string"
986
- ? prop.description
987
- : undefined;
988
- if (doc) traits["smithy.api#documentation"] = doc;
989
- if (required.has(name)) traits["smithy.api#required"] = {};
990
- if (mn !== name) traits["smithy.api#jsonName"] = name;
991
- if (conv.nullable) traits[NULLABLE_TRAIT] = {};
992
- if (isSensitiveProperty(ctx, name, prop)) {
993
- traits["smithy.api#sensitive"] = {};
994
- }
995
- members[mn] = {
996
- target: conv.target,
997
- ...(Object.keys(traits).length ? { traits } : {}),
998
- };
999
- }
1000
- return members;
1001
- };
1002
-
1003
- // ============================================================================
1004
- // Parameters
1005
- // ============================================================================
1006
-
1007
- interface Param {
1008
- in: string;
1009
- name: string;
1010
- required: boolean;
1011
- description?: string;
1012
- schema: any;
1013
- }
1014
-
1015
- /** Normalize a (possibly `$ref`'d) parameter; Swagger 2.0 carries the schema inline. */
1016
- const normalizeParam = (ctx: Ctx, raw: any): Param | undefined => {
1017
- const p = raw?.$ref ? resolvePointer(ctx.spec, raw.$ref) : raw;
1018
- if (!p || typeof p !== "object" || typeof p.name !== "string") {
1019
- return undefined;
1020
- }
1021
- // Swagger 2.0: `in: body` parameters carry their (usually `$ref`'d)
1022
- // schema under `schema`; all other locations describe the type inline on
1023
- // the parameter itself.
1024
- const schema =
1025
- ctx.version === "2.0"
1026
- ? p.in === "body"
1027
- ? (p.schema ?? {})
1028
- : {
1029
- type: p.type,
1030
- enum: p.enum,
1031
- items: p.items,
1032
- format: p.format,
1033
- "x-nullable": p["x-nullable"],
1034
- }
1035
- : (p.schema ?? { type: "string" });
1036
- return {
1037
- in: p.in,
1038
- name: p.name,
1039
- required: p.required === true || p.in === "path",
1040
- description: typeof p.description === "string" ? p.description : undefined,
1041
- schema,
1042
- };
1043
- };
1044
-
1045
- /**
1046
- * Path-level parameters merged before operation-level ones; an op-level
1047
- * parameter overrides a path-level one with the same (in, name). Header and
1048
- * cookie parameters are dropped (v0 parity); `in: body` (2.0) is handled by
1049
- * the request-body path.
1050
- */
1051
- const collectParams = (ctx: Ctx, pathItem: any, op: any): Param[] => {
1052
- const byKey = new Map<string, Param>();
1053
- for (const raw of [
1054
- ...(Array.isArray(pathItem?.parameters) ? pathItem.parameters : []),
1055
- ...(Array.isArray(op?.parameters) ? op.parameters : []),
1056
- ]) {
1057
- const p = normalizeParam(ctx, raw);
1058
- if (!p) continue;
1059
- byKey.set(`${p.in}${p.name}`, p);
1060
- }
1061
- return [...byKey.values()].filter(
1062
- (p) => p.in === "path" || p.in === "query" || p.in === "body" || p.in === "header",
1063
- );
1064
- };
1065
-
1066
- /**
1067
- * Simple-type coercion for path labels (Smithy restricts label targets):
1068
- * enum → enum shape, integer → Integer, number → Double, boolean → Boolean,
1069
- * everything else → String.
1070
- */
1071
- const labelTarget = (ctx: Ctx, schema: any, hint: string): string => {
1072
- const r = deref(ctx, schema);
1073
- if (
1074
- Array.isArray(r?.enum) &&
1075
- r.enum.length > 0 &&
1076
- r.enum.every((v: unknown) => typeof v === "string")
1077
- ) {
1078
- return convertSchema(ctx, r, hint, 0, "in").target;
1079
- }
1080
- switch (typeOf(r)) {
1081
- case "integer":
1082
- return PRELUDE.Integer;
1083
- case "number":
1084
- return PRELUDE.Double;
1085
- case "boolean":
1086
- return PRELUDE.Boolean;
1087
- default:
1088
- return PRELUDE.String;
1089
- }
1090
- };
1091
-
1092
- // ============================================================================
1093
- // Docs
1094
- // ============================================================================
1095
-
1096
- /**
1097
- * v0 trimming rules: stop at a `### Authorization` heading, strip markdown
1098
- * table rows (lines starting with `|`).
1099
- */
1100
- const trimDescription = (desc: unknown): string | undefined => {
1101
- if (typeof desc !== "string" || !desc) return undefined;
1102
- const lines: string[] = [];
1103
- for (const line of desc.split(/\r?\n/)) {
1104
- if (line.trim().startsWith("### Authorization")) break;
1105
- if (line.trim().startsWith("|")) continue;
1106
- lines.push(line);
1107
- }
1108
- const out = lines.join("\n").trim();
1109
- return out || undefined;
1110
- };
1111
-
1112
- const opDoc = (op: any): string | undefined => {
1113
- const summary = typeof op.summary === "string" ? op.summary.trim() : undefined;
1114
- const desc = trimDescription(op.description);
1115
- const parts = [summary, desc].filter((s): s is string => s !== undefined && s !== "");
1116
- return parts.length ? parts.join("\n\n") : undefined;
1117
- };
1118
-
1119
- // ============================================================================
1120
- // Responses
1121
- // ============================================================================
1122
-
1123
- /**
1124
- * The allowed headers any 2xx response declares, in status order; the first
1125
- * declaration of a header (case-insensitively) wins. Swagger 2.0 headers are
1126
- * schemas themselves; OpenAPI 3 headers carry a `schema`.
1127
- */
1128
- const successHeaders = (
1129
- ctx: Ctx,
1130
- responses: any,
1131
- allowed: ReadonlySet<string>,
1132
- ): Array<{ name: string; schema: any; description?: string }> => {
1133
- const out: Array<{ name: string; schema: any; description?: string }> = [];
1134
- const seen = new Set<string>();
1135
- for (const code of Object.keys(responses ?? {}).sort()) {
1136
- if (!/^2\d\d$/.test(code)) continue;
1137
- const raw = responses[code];
1138
- const resp = raw?.$ref ? resolvePointer(ctx.spec, raw.$ref) : raw;
1139
- for (const [name, rawHeader] of Object.entries<any>(resp?.headers ?? {})) {
1140
- const lower = name.toLowerCase();
1141
- if (!allowed.has(lower) || seen.has(lower)) continue;
1142
- seen.add(lower);
1143
- const header = rawHeader?.$ref ? resolvePointer(ctx.spec, rawHeader.$ref) : rawHeader;
1144
- if (!header || typeof header !== "object") continue;
1145
- out.push({
1146
- name,
1147
- schema: ctx.version === "2.0" ? header : (header.schema ?? {}),
1148
- ...(typeof header.description === "string" ? { description: header.description } : {}),
1149
- });
1150
- }
1151
- }
1152
- return out;
1153
- };
1154
-
1155
- /** How many times each shape id is the `target` of a member or op input/output. */
1156
- const targetCounts = (shapes: Record<string, any>): Map<string, number> => {
1157
- const counts = new Map<string, number>();
1158
- const visit = (node: any): void => {
1159
- if (node === null || typeof node !== "object") return;
1160
- if (Array.isArray(node)) {
1161
- for (const item of node) visit(item);
1162
- return;
1163
- }
1164
- if (typeof node.target === "string") {
1165
- counts.set(node.target, (counts.get(node.target) ?? 0) + 1);
1166
- }
1167
- for (const [key, value] of Object.entries(node)) {
1168
- if (key !== "traits") visit(value);
1169
- }
1170
- };
1171
- for (const shape of Object.values(shapes)) visit(shape);
1172
- return counts;
1173
- };
1174
-
1175
- /** First declared status wins; resolve response refs and preserve JSON or binary bodies. */
1176
- const successSchema = (
1177
- ctx: Ctx,
1178
- responses: any,
1179
- order: readonly string[],
1180
- ): { schema: any | undefined } => {
1181
- for (const code of order) {
1182
- const raw = responses?.[code];
1183
- if (!raw) continue;
1184
- const resp = raw.$ref ? resolvePointer(ctx.spec, raw.$ref) : raw;
1185
- if (!resp || typeof resp !== "object") return { schema: undefined };
1186
- if (ctx.version === "2.0") {
1187
- return { schema: resp.schema };
1188
- }
1189
- const json = resp.content?.["application/json"]?.schema;
1190
- const binary = resp.content?.["application/octet-stream"]?.schema;
1191
- return {
1192
- schema:
1193
- json ?? (ctx.binaryTypes && deref(ctx, binary)?.format === "binary" ? binary : undefined),
1194
- };
1195
- }
1196
- return { schema: undefined };
1197
- };
1198
-
1199
- /**
1200
- * Whether the success body is a collection: an array, or an object whose
1201
- * array members outnumber its scalar ones (envelopes like `{ data: [] }`,
1202
- * `{ items: [], total }`). `undefined` when there is no body to judge.
1203
- */
1204
- const responseIsCollection = (
1205
- ctx: Ctx,
1206
- responses: any,
1207
- order: readonly string[],
1208
- ): boolean | undefined => {
1209
- const { schema } = successSchema(ctx, responses, order);
1210
- if (!schema) return undefined;
1211
- const s = deref(ctx, schema);
1212
- if (!s || typeof s !== "object") return undefined;
1213
- if (s.type === "array" || s.items) return true;
1214
- const props = s.properties;
1215
- if (!props || typeof props !== "object") {
1216
- return s.allOf || s.oneOf || s.anyOf ? undefined : false;
1217
- }
1218
- let arrays = 0;
1219
- let others = 0;
1220
- for (const prop of Object.values(props)) {
1221
- const p = deref(ctx, prop);
1222
- if (p?.type === "array" || p?.items) arrays++;
1223
- else others++;
1224
- }
1225
- if (arrays === 0) return false;
1226
- // `{ data: [...] }`, `{ items, next_cursor }`, `{ results, count, page }`
1227
- return arrays >= 1 && others <= 3;
1228
- };
1229
-
1230
- // ============================================================================
1231
- // Pagination detection (v0 detectPagination)
1232
- // ============================================================================
1233
-
1234
- interface DetectedPagination {
1235
- mode: "cursor" | "page" | "token";
1236
- inputToken: string;
1237
- outputToken: string;
1238
- items: string;
1239
- }
1240
-
1241
- const PAGINATION_INPUT_ALIASES: Record<string, readonly string[]> = {
1242
- cursor: ["cursor", "page_token", "pageToken"],
1243
- token: ["next_token", "NextToken", "nextToken"],
1244
- page: ["page"],
1245
- };
1246
-
1247
- const detectPagination = (
1248
- ctx: Ctx,
1249
- params: readonly Param[],
1250
- responseSchema: any,
1251
- ): DetectedPagination | undefined => {
1252
- if (!responseSchema) return undefined;
1253
- const bag = flattenObject(ctx, responseSchema).properties;
1254
- if (Object.keys(bag).length === 0) return undefined;
1255
-
1256
- let mode: DetectedPagination["mode"] | undefined;
1257
- let outputToken: string | undefined;
1258
- const pag = bag["pagination"] ? flattenObject(ctx, bag["pagination"]).properties : undefined;
1259
- if (pag?.["cursor"]) {
1260
- mode = "cursor";
1261
- outputToken = "pagination.cursor";
1262
- } else if (pag?.["next"]) {
1263
- mode = "cursor";
1264
- outputToken = "pagination.next";
1265
- } else if (pag?.["next_page"]) {
1266
- mode = "page";
1267
- outputToken = "pagination.next_page";
1268
- } else if (bag["next_token"]) {
1269
- mode = "token";
1270
- outputToken = "next_token";
1271
- } else if (bag["NextToken"]) {
1272
- mode = "token";
1273
- outputToken = "NextToken";
1274
- } else if (bag["nextToken"]) {
1275
- mode = "token";
1276
- outputToken = "nextToken";
1277
- } else if (bag["next_page"]) {
1278
- mode = "page";
1279
- outputToken = "next_page";
1280
- }
1281
- if (!mode || !outputToken) return undefined;
1282
-
1283
- const aliases = PAGINATION_INPUT_ALIASES[mode]!;
1284
- const inputToken = params.find((p) => p.in === "query" && aliases.includes(p.name))?.name;
1285
- if (!inputToken) return undefined;
1286
-
1287
- let items: string | undefined;
1288
- for (const [k, v] of Object.entries(bag)) {
1289
- if (k === "pagination" || k === "next_token" || k === "NextToken") continue;
1290
- if (typeOf(deref(ctx, v)) === "array") {
1291
- items = k;
1292
- break;
1293
- }
1294
- }
1295
- if (!items) return undefined;
1296
-
1297
- return { mode, inputToken, outputToken, items };
1298
- };
1299
-
1300
- // ============================================================================
1301
- // Main conversion
1302
- // ============================================================================
1303
-
1304
- const HTTP_METHODS = ["get", "post", "put", "patch", "delete"] as const;
1305
-
1306
- /**
1307
- * Methods a spec may declare beyond {@link HTTP_METHODS}, opt-in via
1308
- * {@link OpenApiConvertOptions.extraHttpMethods} — a provider that models
1309
- * `head` (Vercel's cache-artifact and file existence probes) asks for it
1310
- * rather than every provider silently gaining operations on regeneration.
1311
- */
1312
- const OPTIONAL_HTTP_METHODS = ["head", "options"] as const;
1313
-
1314
- const DEFAULT_STATUS_TO_ERROR_CLASS: Readonly<Record<string, string>> = {
1315
- "400": "BadRequest",
1316
- "403": "Forbidden",
1317
- "404": "NotFound",
1318
- "409": "Conflict",
1319
- "422": "UnprocessableEntity",
1320
- };
1321
-
1322
- const DEFAULT_ERROR_STATUSES = ["401", "429", "500", "503"];
1323
-
1324
- const DEFAULT_SUCCESS_STATUSES = ["200", "201", "204"];
1325
-
1326
- export { RENAME_METADATA_KEY };
1327
-
1328
- export const convertOpenApiToSmithy = (
1329
- spec: unknown,
1330
- options: OpenApiConvertOptions,
1331
- ): SmithyModel => {
1332
- const named = convertOnce(spec, options);
1333
- if (!options.deferNaming) return named;
1334
- const upstream = convertOnce(spec, {
1335
- ...options,
1336
- operationNaming: "as-is",
1337
- operationNames: undefined,
1338
- });
1339
- // Names never steer the conversion (only uniqueness suffixes and the
1340
- // `By<Param>` rule read them), so both runs create the same shapes in the
1341
- // same order: the i-th shape of one is the i-th of the other.
1342
- const from = Object.keys(upstream.shapes);
1343
- const to = Object.keys(named.shapes);
1344
- if (from.length !== to.length) {
1345
- throw new Error(
1346
- `deferNaming (${options.namespace}): ${from.length} shapes with upstream names, ${to.length} with final names`,
1347
- );
1348
- }
1349
- const rename: Record<string, string> = {};
1350
- for (let i = 0; i < from.length; i++) if (from[i] !== to[i]) rename[from[i]!] = to[i]!;
1351
- const check = structuredClone(upstream);
1352
- renameShapes(check, new Map(Object.entries(rename)));
1353
- if (JSON.stringify(check) !== JSON.stringify(named)) {
1354
- const differs = to.find(
1355
- (id) => JSON.stringify(check.shapes[id]) !== JSON.stringify(named.shapes[id]),
1356
- );
1357
- throw new Error(
1358
- `deferNaming (${options.namespace}): the upstream-named model does not rename to the final one (first difference: ${differs ?? "metadata"})`,
1359
- );
1360
- }
1361
- if (Object.keys(rename).length > 0) {
1362
- upstream.metadata = { ...upstream.metadata, [RENAME_METADATA_KEY]: rename };
1363
- }
1364
- return upstream;
1365
- };
1366
-
1367
- const convertOnce = (spec: unknown, options: OpenApiConvertOptions): SmithyModel => {
1368
- const doc = spec as any;
1369
- const version = detectVersion(doc);
1370
- const ctx: Ctx = {
1371
- spec: doc,
1372
- version,
1373
- ns: options.namespace,
1374
- shapes: {},
1375
- names: new Set(),
1376
- refs: new Map(),
1377
- dirSensitiveRefs: new Map(),
1378
- sensitivePatterns: options.sensitivePatterns ?? SENSITIVE_FIELD_PATTERNS,
1379
- binaryTypes: options.binaryTypes ?? false,
1380
- };
1381
- const statusToErrorClass = options.statusToErrorClass ?? DEFAULT_STATUS_TO_ERROR_CLASS;
1382
- const defaultErrorStatuses = new Set(options.defaultErrorStatuses ?? DEFAULT_ERROR_STATUSES);
1383
- const skipDeprecated = options.skipDeprecated ?? true;
1384
- const successStatuses = options.successStatuses ?? DEFAULT_SUCCESS_STATUSES;
1385
- const httpMethods = [
1386
- ...HTTP_METHODS,
1387
- ...OPTIONAL_HTTP_METHODS.filter((m) => options.extraHttpMethods?.includes(m)),
1388
- ];
1389
-
1390
- // Error class names and the service name are reserved up front so schema
1391
- // components can never steal them.
1392
- const errorIds = new Map<string, string>(); // class name → shape id
1393
- for (const cls of new Set(Object.values(statusToErrorClass))) {
1394
- errorIds.set(cls, `${ctx.ns}#${uniqueName(ctx, cls)}`);
1395
- }
1396
- const serviceName = uniqueName(ctx, options.serviceName);
1397
-
1398
- const usedErrors = new Map<string, number>(); // class name → first status
1399
- const serviceOps: Array<{ target: string }> = [];
1400
- const componentHeaders: Array<{
1401
- readonly opId: string;
1402
- readonly opName: string;
1403
- readonly members: Record<string, any>;
1404
- }> = [];
1405
- const allowedResponseHeaders = new Set(
1406
- (options.responseHeaders ?? []).map((name) => name.toLowerCase()),
1407
- );
1408
-
1409
- for (const [rawPath, pathItem] of Object.entries(doc.paths ?? {})) {
1410
- if (!pathItem || typeof pathItem !== "object") continue;
1411
- for (const method of httpMethods) {
1412
- const op = (pathItem as any)[method];
1413
- if (!op || typeof op !== "object") continue;
1414
- if (skipDeprecated && op.deprecated === true) continue;
1415
-
1416
- const rawOperationId =
1417
- typeof op.operationId === "string" && op.operationId
1418
- ? op.operationId
1419
- : `${method}_${rawPath}`;
1420
- const idCtx = { path: rawPath, method };
1421
- const naming = options.operationNaming ?? "verbNoun";
1422
- let named =
1423
- options.operationNames !== undefined
1424
- ? resolveOperationName(options.operationNames, rawOperationId, idCtx)
1425
- : undefined;
1426
- if (named === undefined && naming === "verbNoun") {
1427
- // A mechanical id (`get-api-card`, or none at all) is named from
1428
- // the route. A hand-chosen one that merely starts with the method
1429
- // and reads the route in order (`get-feeds` on /feeds) keeps its
1430
- // own nouns; only the HTTP-method verb is normalised.
1431
- if (typeof op.operationId !== "string" || !op.operationId) {
1432
- // No id: everything comes from the route, including whether a
1433
- // GET on a collection route is `list` or `get`.
1434
- named = pathToVerbNoun(idCtx, {
1435
- returnsCollection: responseIsCollection(ctx, op.responses, successStatuses),
1436
- });
1437
- } else if (isMechanicalOperationId(op.operationId, idCtx)) {
1438
- // Method-prefixed and reading the route (`get-feeds`,
1439
- // `postV1AppsByAppIdPromote`, `deleteProjectJWKS`): keep the
1440
- // author's tokens and casing; normalise `post`/`patch`, drop
1441
- // parameter clauses (`ByAppId`, `ById`) and api/version roots.
1442
- named = pathToVerbNoun(idCtx, {
1443
- nouns: op.operationId,
1444
- verbatim: isVerbatimRouteId(op.operationId, idCtx),
1445
- });
1446
- } else {
1447
- named = toVerbNoun(rawOperationId);
1448
- }
1449
- }
1450
- let resolved: string = named ?? rawOperationId;
1451
- // Two routes can derive the same name (`/collections/{slug}` and
1452
- // `/collections/{slug}-{id}`); suffix the trailing parameter rather
1453
- // than a counter.
1454
- if (
1455
- naming === "verbNoun" &&
1456
- ctx.names.has(pascal(resolved)) &&
1457
- isMechanicalOperationId(
1458
- typeof op.operationId === "string" ? op.operationId : undefined,
1459
- idCtx,
1460
- )
1461
- ) {
1462
- const lastParam = /\{([^}]+)\}[^/]*$/.exec(rawPath)?.[1];
1463
- if (lastParam) resolved = `${resolved}By${pascal(lastParam)}`;
1464
- }
1465
- const opName = pascal(resolved);
1466
-
1467
- const params = collectParams(ctx, pathItem, op);
1468
-
1469
- // ---- URI + labels (sanitize placeholder names to member idents) ----
1470
- let uri = rawPath.split(/[?#]/)[0]!;
1471
- const rawLabels = Array.from(uri.matchAll(/\{([^}]+)\}/g)).map((m) => m[1]!);
1472
- const members: Record<string, any> = {};
1473
- const addMember = (name: string, member: any): boolean => {
1474
- if (name in members) return false;
1475
- members[name] = member;
1476
- return true;
1477
- };
1478
-
1479
- for (const raw of rawLabels) {
1480
- const san = memberIdent(raw);
1481
- if (san !== raw) uri = uri.split(`{${raw}}`).join(`{${san}}`);
1482
- const p = params.find((x) => x.in === "path" && x.name === raw);
1483
- addMember(san, {
1484
- target: labelTarget(ctx, p?.schema, `${opName}Request${pascal(san)}`),
1485
- traits: {
1486
- "smithy.api#httpLabel": {},
1487
- "smithy.api#required": {},
1488
- ...(p?.description ? { "smithy.api#documentation": p.description } : {}),
1489
- },
1490
- });
1491
- }
1492
-
1493
- // ---- Query params ----
1494
- for (const p of params) {
1495
- if (p.in !== "query") continue;
1496
- if (options.apiVersion !== undefined && p.name === "api-version") {
1497
- continue;
1498
- }
1499
- const san = memberIdent(p.name);
1500
- const conv = convertSchema(ctx, p.schema, `${opName}Request${pascal(p.name)}`, 0, "in");
1501
- addMember(san, {
1502
- target: conv.target,
1503
- traits: {
1504
- "smithy.api#httpQuery": p.name,
1505
- ...(p.required ? { "smithy.api#required": {} } : {}),
1506
- ...(p.description ? { "smithy.api#documentation": p.description } : {}),
1507
- },
1508
- });
1509
- }
1510
-
1511
- // ---- Header params (opt-in) ----
1512
- if (options.headerParams) {
1513
- for (const p of params) {
1514
- if (p.in !== "header") continue;
1515
- const conv = convertSchema(ctx, p.schema, `${opName}Request${pascal(p.name)}`, 0, "in");
1516
- addMember(headerMemberName(p.name), {
1517
- target: conv.target,
1518
- traits: {
1519
- // The wire name rides on the trait, so the member is free to be
1520
- // a normal identifier.
1521
- "smithy.api#httpHeader": p.name,
1522
- ...(p.required ? { "smithy.api#required": {} } : {}),
1523
- ...(p.description ? { "smithy.api#documentation": p.description } : {}),
1524
- },
1525
- });
1526
- }
1527
- }
1528
-
1529
- // ---- Request body (json > form-urlencoded > multipart) ----
1530
- let contentType: "form-urlencoded" | "multipart" | undefined;
1531
- let bodySchema: any;
1532
- let bodyRequired = false;
1533
- if (version === "2.0") {
1534
- const bodyParam = params.find((p) => p.in === "body");
1535
- bodySchema = bodyParam?.schema;
1536
- bodyRequired = bodyParam?.required === true;
1537
- } else if (op.requestBody) {
1538
- // A components/requestBodies entry can itself be a $ref to another
1539
- // (1Password Events: AuditEventsRequest → CursorRequest).
1540
- const rb = deref(ctx, op.requestBody);
1541
- bodyRequired = rb?.required === true;
1542
- const content = rb?.content ?? {};
1543
- if (content["application/json"]) {
1544
- bodySchema = content["application/json"].schema;
1545
- } else if (content["application/x-www-form-urlencoded"]) {
1546
- bodySchema = content["application/x-www-form-urlencoded"].schema;
1547
- contentType = "form-urlencoded";
1548
- } else if (content["multipart/form-data"]) {
1549
- bodySchema = content["multipart/form-data"].schema;
1550
- contentType = "multipart";
1551
- }
1552
- }
1553
- if (bodySchema !== undefined) {
1554
- const flat = flattenObject(ctx, bodySchema);
1555
- if (Object.keys(flat.properties).length > 0) {
1556
- const bodyMembers = buildMembers(
1557
- ctx,
1558
- flat.properties,
1559
- flat.required,
1560
- `${opName}Request`,
1561
- 0,
1562
- "in",
1563
- );
1564
- for (const [mn, m] of Object.entries(bodyMembers)) {
1565
- addMember(mn, m); // labels win, then query, then body
1566
- }
1567
- } else {
1568
- // Non-flattenable body (bare array/scalar/map/union) → sole TYPED
1569
- // `body` member sent as the entire request body
1570
- // (`smithy.api#httpPayload`). A schema-less JSON body (empty or
1571
- // bare-object schema → Document) gets NO body member at all — the
1572
- // runtime's unknown-key passthrough is the escape hatch, and an
1573
- // opaque `body: unknown` payload member would swallow the typed
1574
- // surface.
1575
- const conv = convertSchema(ctx, bodySchema, `${opName}RequestBody`, 0, "in");
1576
- if (conv.target !== PRELUDE.Document) {
1577
- addMember("body", {
1578
- target: conv.target,
1579
- traits: {
1580
- "smithy.api#httpPayload": {},
1581
- ...(bodyRequired ? { "smithy.api#required": {} } : {}),
1582
- ...(conv.nullable ? { [NULLABLE_TRAIT]: {} } : {}),
1583
- },
1584
- });
1585
- }
1586
- }
1587
- }
1588
-
1589
- // ---- Input shape ----
1590
- const inputTarget =
1591
- Object.keys(members).length > 0
1592
- ? addShape(ctx, `${opName}Request`, {
1593
- type: "structure",
1594
- members,
1595
- traits: { "smithy.api#input": {} },
1596
- })
1597
- : PRELUDE.Unit;
1598
-
1599
- // ---- Output shape ----
1600
- // A HEAD response carries no content, and not merely by convention:
1601
- // HTTP/1.1 framing terminates it at the end of the header section
1602
- // "regardless of the header fields present in the message" (RFC 9112
1603
- // §6.3), so a declared `Content-Length` describes what a GET *would*
1604
- // return and no body can reach the client. Specs declare one anyway —
1605
- // Vercel mirrors the GET's schema onto two of its HEAD probes and
1606
- // gives the other two a bare `{"nullable": true}` — and honouring it
1607
- // generates an output struct with required members that then fails to
1608
- // decode against the empty body on every successful call.
1609
- const { schema: respSchema } =
1610
- method === "head"
1611
- ? { schema: undefined }
1612
- : successSchema(ctx, op.responses, successStatuses);
1613
- let outputTarget: string = PRELUDE.Unit;
1614
- if (respSchema !== undefined) {
1615
- const flat = flattenObject(ctx, respSchema);
1616
- if (Object.keys(flat.properties).length > 0) {
1617
- const resolved = deref(ctx, respSchema);
1618
- const isPlainRef =
1619
- typeof respSchema.$ref === "string" &&
1620
- !Array.isArray(resolved?.allOf) &&
1621
- isNameable(ctx, resolved);
1622
- if (isPlainRef) {
1623
- // Reuse the named component shape as the output directly.
1624
- outputTarget = convertSchema(ctx, respSchema, opName, 0, "out").target;
1625
- } else {
1626
- outputTarget = addShape(ctx, `${opName}Response`, {
1627
- type: "structure",
1628
- members: buildMembers(
1629
- ctx,
1630
- flat.properties,
1631
- flat.required,
1632
- `${opName}Response`,
1633
- 0,
1634
- "out",
1635
- ),
1636
- traits: { "smithy.api#output": {} },
1637
- });
1638
- }
1639
- } else {
1640
- // Non-flattenable response (bare array/scalar/map/union, or an
1641
- // opaque object) → wrapper whose sole TYPED member IS the payload;
1642
- // the SdkSpec's rootPipe collapses the wrapper.
1643
- const conv = convertSchema(ctx, respSchema, `${opName}ResponseBody`, 0, "out");
1644
- if (conv.target !== PRELUDE.Document || deref(ctx, respSchema)) {
1645
- outputTarget = addShape(ctx, `${opName}Response`, {
1646
- type: "structure",
1647
- members: {
1648
- body: {
1649
- target: conv.target,
1650
- traits: {
1651
- [RAW_RESPONSE_TRAIT]: {},
1652
- "smithy.api#required": {},
1653
- ...(conv.nullable ? { [NULLABLE_TRAIT]: {} } : {}),
1654
- },
1655
- },
1656
- },
1657
- traits: { "smithy.api#output": {} },
1658
- });
1659
- }
1660
- }
1661
- }
1662
-
1663
- // ---- Response headers (opt-in) ----
1664
- let pendingHeaders: Record<string, any> | undefined;
1665
- if (allowedResponseHeaders.size > 0 && method !== "head") {
1666
- const headers = successHeaders(ctx, op.responses, allowedResponseHeaders);
1667
- const current = outputTarget === PRELUDE.Unit ? undefined : ctx.shapes[outputTarget];
1668
- // A raw-root wrapper collapses to its payload, so it has nowhere to
1669
- // carry headers.
1670
- const rawRoot = Object.values<any>(current?.members ?? {}).some(
1671
- (m) => m?.traits?.[RAW_RESPONSE_TRAIT] !== undefined,
1672
- );
1673
- if (
1674
- headers.length > 0 &&
1675
- (current === undefined || current.type === "structure") &&
1676
- !rawRoot
1677
- ) {
1678
- const taken = new Set(Object.keys(current?.members ?? {}));
1679
- const members: Record<string, any> = {};
1680
- for (const header of headers) {
1681
- let name = headerMemberName(header.name);
1682
- if (taken.has(name)) name = `${name}Header`;
1683
- if (taken.has(name)) continue;
1684
- taken.add(name);
1685
- members[name] = {
1686
- target: convertSchema(
1687
- ctx,
1688
- header.schema,
1689
- `${opName}Response${pascal(header.name)}`,
1690
- 0,
1691
- "out",
1692
- ).target,
1693
- traits: {
1694
- "smithy.api#httpHeader": header.name,
1695
- ...(header.description ? { "smithy.api#documentation": header.description } : {}),
1696
- },
1697
- };
1698
- }
1699
- if (current === undefined) {
1700
- outputTarget = addShape(ctx, `${opName}Response`, {
1701
- type: "structure",
1702
- members,
1703
- traits: { "smithy.api#output": {} },
1704
- });
1705
- } else if (current.traits?.["smithy.api#output"] !== undefined) {
1706
- current.members = { ...current.members, ...members };
1707
- } else {
1708
- // A named component: whether it can take the headers itself
1709
- // depends on what else uses it, known once every op is converted.
1710
- pendingHeaders = members;
1711
- }
1712
- }
1713
- }
1714
-
1715
- // ---- Errors ----
1716
- const errors: Array<{ target: string }> = [];
1717
- for (const status of Object.keys(op.responses ?? {})) {
1718
- if (!/^[45]\d\d$/.test(status)) continue;
1719
- if (defaultErrorStatuses.has(status)) continue;
1720
- const cls = statusToErrorClass[status];
1721
- if (!cls) continue;
1722
- const id = errorIds.get(cls)!;
1723
- if (!usedErrors.has(cls)) usedErrors.set(cls, Number(status));
1724
- if (!errors.some((e) => e.target === id)) errors.push({ target: id });
1725
- }
1726
-
1727
- // ---- Pagination ----
1728
- const pagination = detectPagination(ctx, params, respSchema);
1729
-
1730
- // ---- Operation shape ----
1731
- const httpTrait: Record<string, any> = {
1732
- method: method.toUpperCase(),
1733
- uri,
1734
- code: 200,
1735
- };
1736
- if (contentType === "multipart") httpTrait.contentType = "multipart";
1737
- const traits: Record<string, any> = { "smithy.api#http": httpTrait };
1738
- const documentation = opDoc(op);
1739
- if (documentation) traits["smithy.api#documentation"] = documentation;
1740
- if (pagination) traits["smithy.api#paginated"] = pagination;
1741
- if (contentType) traits[CONTENT_TYPE_TRAIT] = contentType;
1742
- if (options.apiVersion !== undefined) {
1743
- traits[API_VERSION_TRAIT] = options.apiVersion;
1744
- }
1745
-
1746
- const opId = addShape(ctx, opName, {
1747
- type: "operation",
1748
- input: { target: inputTarget },
1749
- output: { target: outputTarget },
1750
- ...(errors.length ? { errors } : {}),
1751
- traits,
1752
- });
1753
- serviceOps.push({ target: opId });
1754
- if (pendingHeaders !== undefined) {
1755
- componentHeaders.push({ opId, opName, members: pendingHeaders });
1756
- }
1757
- }
1758
- }
1759
-
1760
- // ---- Response headers on named components ----
1761
- // A component returned only by ops that declare headers takes them itself
1762
- // (all optional) and keeps its name. A component that other shapes, or ops
1763
- // without those headers, also use is copied into an op-specific output, so
1764
- // the headers never leak into them.
1765
- if (componentHeaders.length > 0) {
1766
- const uses = targetCounts(ctx.shapes);
1767
- const outputs = new Map<string, number>();
1768
- for (const { opId } of componentHeaders) {
1769
- const id: string = ctx.shapes[opId].output.target;
1770
- outputs.set(id, (outputs.get(id) ?? 0) + 1);
1771
- }
1772
- for (const { opId, opName, members } of componentHeaders) {
1773
- const opShape = ctx.shapes[opId];
1774
- const componentId: string = opShape.output.target;
1775
- const component = ctx.shapes[componentId];
1776
- if (uses.get(componentId) === outputs.get(componentId)) {
1777
- component.members = { ...component.members, ...members };
1778
- } else {
1779
- opShape.output.target = addShape(ctx, `${opName}Response`, {
1780
- type: "structure",
1781
- members: { ...component.members, ...members },
1782
- traits: {
1783
- ...(component.traits?.["smithy.api#documentation"]
1784
- ? {
1785
- "smithy.api#documentation": component.traits["smithy.api#documentation"],
1786
- }
1787
- : {}),
1788
- "smithy.api#output": {},
1789
- },
1790
- });
1791
- }
1792
- }
1793
- }
1794
-
1795
- // ---- Error shapes (one per used class) ----
1796
- for (const [cls, status] of usedErrors) {
1797
- const id = errorIds.get(cls)!;
1798
- const base = {
1799
- type: "structure",
1800
- members: {},
1801
- traits: {
1802
- "smithy.api#error": status < 500 ? "client" : "server",
1803
- "smithy.api#httpError": status,
1804
- [ERROR_MATCHERS_TRAIT]: [{ status }],
1805
- },
1806
- };
1807
- const override = options.errorShapes?.[cls];
1808
- ctx.shapes[id] = override
1809
- ? {
1810
- ...base,
1811
- ...override,
1812
- traits: { ...base.traits, ...override.traits },
1813
- }
1814
- : base;
1815
- }
1816
-
1817
- // ---- Service shape ----
1818
- ctx.shapes[`${ctx.ns}#${serviceName}`] = {
1819
- type: "service",
1820
- version:
1821
- options.serviceVersion ?? (typeof doc.info?.version === "string" ? doc.info.version : "1.0"),
1822
- operations: serviceOps,
1823
- traits: {
1824
- "smithy.api#title":
1825
- typeof doc.info?.title === "string" ? doc.info.title : options.serviceName,
1826
- ...(typeof doc.info?.description === "string"
1827
- ? {
1828
- "smithy.api#documentation": trimDescription(doc.info.description),
1829
- }
1830
- : {}),
1831
- },
1832
- };
1833
-
1834
- return {
1835
- smithy: "2.0",
1836
- metadata: {
1837
- suppressions: [
1838
- { id: "HttpUriConflict", namespace: "*" },
1839
- { id: "HttpMethodSemantics", namespace: "*" },
1840
- { id: "UnreferencedShape", namespace: "*" },
1841
- ],
1842
- },
1843
- shapes: ctx.shapes,
1844
- };
1845
- };