@bfra.me/api-core 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (624) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/LICENSE +18 -0
  3. package/README.md +18 -0
  4. package/dist/chunk-7NM3WYHE.js +32 -0
  5. package/dist/chunk-7NM3WYHE.js.map +1 -0
  6. package/dist/chunk-7QVYU63E.js +7 -0
  7. package/dist/chunk-7QVYU63E.js.map +1 -0
  8. package/dist/chunk-HKKQOEV3.js +786 -0
  9. package/dist/chunk-HKKQOEV3.js.map +1 -0
  10. package/dist/errors/fetchError.d.ts +13 -0
  11. package/dist/errors/fetchError.js +8 -0
  12. package/dist/errors/fetchError.js.map +1 -0
  13. package/dist/index.d.ts +47 -0
  14. package/dist/index.js +105 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/lib/index.d.ts +59 -0
  17. package/dist/lib/index.js +16 -0
  18. package/dist/lib/index.js.map +1 -0
  19. package/dist/types.d.ts +22 -0
  20. package/dist/types.js +1 -0
  21. package/dist/types.js.map +1 -0
  22. package/eslint.config.ts +25 -0
  23. package/package.json +67 -0
  24. package/src/errors/fetchError.ts +29 -0
  25. package/src/index.ts +134 -0
  26. package/src/lib/getJSONSchemaDefaults.ts +77 -0
  27. package/src/lib/index.ts +7 -0
  28. package/src/lib/parseResponse.ts +28 -0
  29. package/src/lib/prepareAuth.ts +107 -0
  30. package/src/lib/prepareParams.ts +439 -0
  31. package/src/lib/prepareServer.ts +52 -0
  32. package/src/types.ts +28 -0
  33. package/test-utils/CHANGELOG.md +11 -0
  34. package/test-utils/datasets/real-world-apis.json +8507 -0
  35. package/test-utils/datasets/refresh-dataset +336 -0
  36. package/test-utils/definitions/alby.json +5391 -0
  37. package/test-utils/definitions/auth-quirks.json +62 -0
  38. package/test-utils/definitions/basiq.json +104 -0
  39. package/test-utils/definitions/metrotransit.json +318 -0
  40. package/test-utils/definitions/nested-defaults.json +107 -0
  41. package/test-utils/definitions/operationid-quirks.json +36 -0
  42. package/test-utils/definitions/optional-payload.json +57 -0
  43. package/test-utils/definitions/payloads.json +58 -0
  44. package/test-utils/definitions/response-title-quirks.json +77 -0
  45. package/test-utils/definitions/simple.json +291 -0
  46. package/test-utils/fetch-mock.ts +81 -0
  47. package/test-utils/fixtures/hello.jp.txt +1 -0
  48. package/test-utils/fixtures/hello.txt +1 -0
  49. package/test-utils/fixtures/owlbert-shrub.png +0 -0
  50. package/test-utils/fixtures/owlbert.png +0 -0
  51. package/test-utils/index.ts +2 -0
  52. package/test-utils/load-spec.ts +8 -0
  53. package/test-utils/node_modules/.bin/tsc +17 -0
  54. package/test-utils/node_modules/.bin/tsserver +17 -0
  55. package/test-utils/package.json +20 -0
  56. package/test-utils/sdks/README.md +3 -0
  57. package/test-utils/sdks/alby/README.md +23 -0
  58. package/test-utils/sdks/alby/package.json +55 -0
  59. package/test-utils/sdks/alby/src/index.ts +18 -0
  60. package/test-utils/sdks/alby/src/schemas/AmqpExternalRulePatch.ts +92 -0
  61. package/test-utils/sdks/alby/src/schemas/AmqpExternalRulePost.ts +93 -0
  62. package/test-utils/sdks/alby/src/schemas/AmqpExternalRuleResponse.ts +143 -0
  63. package/test-utils/sdks/alby/src/schemas/AmqpRulePatch.ts +76 -0
  64. package/test-utils/sdks/alby/src/schemas/AmqpRulePost.ts +85 -0
  65. package/test-utils/sdks/alby/src/schemas/AmqpRuleResponse.ts +124 -0
  66. package/test-utils/sdks/alby/src/schemas/AppPatch.ts +68 -0
  67. package/test-utils/sdks/alby/src/schemas/AppPkcs12.ts +22 -0
  68. package/test-utils/sdks/alby/src/schemas/AppPost.ts +71 -0
  69. package/test-utils/sdks/alby/src/schemas/AppResponse.ts +69 -0
  70. package/test-utils/sdks/alby/src/schemas/AwsAccessKeys.ts +28 -0
  71. package/test-utils/sdks/alby/src/schemas/AwsAccessKeysResponse.ts +20 -0
  72. package/test-utils/sdks/alby/src/schemas/AwsAssumeRole.ts +23 -0
  73. package/test-utils/sdks/alby/src/schemas/AwsKinesisRulePatch.ts +90 -0
  74. package/test-utils/sdks/alby/src/schemas/AwsKinesisRulePost.ts +103 -0
  75. package/test-utils/sdks/alby/src/schemas/AwsKinesisRuleResponse.ts +142 -0
  76. package/test-utils/sdks/alby/src/schemas/AwsLambdaRulePatch.ts +90 -0
  77. package/test-utils/sdks/alby/src/schemas/AwsLambdaRulePost.ts +90 -0
  78. package/test-utils/sdks/alby/src/schemas/AwsLambdaRuleResponse.ts +132 -0
  79. package/test-utils/sdks/alby/src/schemas/AwsSqsRulePatch.ts +86 -0
  80. package/test-utils/sdks/alby/src/schemas/AwsSqsRulePost.ts +98 -0
  81. package/test-utils/sdks/alby/src/schemas/AwsSqsRuleResponse.ts +137 -0
  82. package/test-utils/sdks/alby/src/schemas/AzureFunctionRulePatch.ts +96 -0
  83. package/test-utils/sdks/alby/src/schemas/AzureFunctionRulePost.ts +106 -0
  84. package/test-utils/sdks/alby/src/schemas/AzureFunctionRuleResponse.ts +145 -0
  85. package/test-utils/sdks/alby/src/schemas/CloudflareWorkerRulePatch.ts +74 -0
  86. package/test-utils/sdks/alby/src/schemas/CloudflareWorkerRulePost.ts +83 -0
  87. package/test-utils/sdks/alby/src/schemas/CloudflareWorkerRuleResponse.ts +125 -0
  88. package/test-utils/sdks/alby/src/schemas/DeleteAppsAppIdNamespacesNamespaceId.ts +26 -0
  89. package/test-utils/sdks/alby/src/schemas/DeleteAppsAppIdQueuesQueueId.ts +26 -0
  90. package/test-utils/sdks/alby/src/schemas/DeleteAppsAppIdRulesRuleId.ts +26 -0
  91. package/test-utils/sdks/alby/src/schemas/DeleteAppsId.ts +20 -0
  92. package/test-utils/sdks/alby/src/schemas/Error.ts +39 -0
  93. package/test-utils/sdks/alby/src/schemas/GetAccountsAccountIdApps.ts +29 -0
  94. package/test-utils/sdks/alby/src/schemas/GetAppsAppIdKeys.ts +29 -0
  95. package/test-utils/sdks/alby/src/schemas/GetAppsAppIdNamespaces.ts +29 -0
  96. package/test-utils/sdks/alby/src/schemas/GetAppsAppIdQueues.ts +29 -0
  97. package/test-utils/sdks/alby/src/schemas/GetAppsAppIdRules.ts +29 -0
  98. package/test-utils/sdks/alby/src/schemas/GetAppsAppIdRulesRuleId.ts +26 -0
  99. package/test-utils/sdks/alby/src/schemas/GoogleCloudFunctionRulePatch.ts +100 -0
  100. package/test-utils/sdks/alby/src/schemas/GoogleCloudFunctionRulePost.ts +100 -0
  101. package/test-utils/sdks/alby/src/schemas/GoogleCloudFunctionRuleResponse.ts +150 -0
  102. package/test-utils/sdks/alby/src/schemas/HttpRulePatch.ts +89 -0
  103. package/test-utils/sdks/alby/src/schemas/HttpRulePost.ts +100 -0
  104. package/test-utils/sdks/alby/src/schemas/HttpRuleResponse.ts +138 -0
  105. package/test-utils/sdks/alby/src/schemas/IftttRulePatch.ts +59 -0
  106. package/test-utils/sdks/alby/src/schemas/IftttRulePost.ts +62 -0
  107. package/test-utils/sdks/alby/src/schemas/IftttRuleResponse.ts +101 -0
  108. package/test-utils/sdks/alby/src/schemas/KeyPatch.ts +34 -0
  109. package/test-utils/sdks/alby/src/schemas/KeyPost.ts +39 -0
  110. package/test-utils/sdks/alby/src/schemas/KeyResponse.ts +63 -0
  111. package/test-utils/sdks/alby/src/schemas/Me.ts +98 -0
  112. package/test-utils/sdks/alby/src/schemas/NamespacePatch.ts +49 -0
  113. package/test-utils/sdks/alby/src/schemas/NamespacePost.ts +59 -0
  114. package/test-utils/sdks/alby/src/schemas/NamespaceResponse.ts +70 -0
  115. package/test-utils/sdks/alby/src/schemas/PatchAppsAppIdKeysKeyId.ts +26 -0
  116. package/test-utils/sdks/alby/src/schemas/PatchAppsAppIdNamespacesNamespaceId.ts +26 -0
  117. package/test-utils/sdks/alby/src/schemas/PatchAppsAppIdRulesRuleId.ts +26 -0
  118. package/test-utils/sdks/alby/src/schemas/PatchAppsId.ts +20 -0
  119. package/test-utils/sdks/alby/src/schemas/PostAccountsAccountIdApps.ts +20 -0
  120. package/test-utils/sdks/alby/src/schemas/PostAppsAppIdKeys.ts +20 -0
  121. package/test-utils/sdks/alby/src/schemas/PostAppsAppIdKeysKeyIdRevoke.ts +26 -0
  122. package/test-utils/sdks/alby/src/schemas/PostAppsAppIdNamespaces.ts +20 -0
  123. package/test-utils/sdks/alby/src/schemas/PostAppsAppIdQueues.ts +20 -0
  124. package/test-utils/sdks/alby/src/schemas/PostAppsAppIdRules.ts +20 -0
  125. package/test-utils/sdks/alby/src/schemas/PostAppsIdPkcs12.ts +20 -0
  126. package/test-utils/sdks/alby/src/schemas/Queue.ts +43 -0
  127. package/test-utils/sdks/alby/src/schemas/QueueResponse.ts +185 -0
  128. package/test-utils/sdks/alby/src/schemas/RulePatch.ts +46 -0
  129. package/test-utils/sdks/alby/src/schemas/RulePost.ts +49 -0
  130. package/test-utils/sdks/alby/src/schemas/RuleResponse.ts +46 -0
  131. package/test-utils/sdks/alby/src/schemas/RuleSource.ts +30 -0
  132. package/test-utils/sdks/alby/src/schemas/UnsupportedRuleResponse.ts +98 -0
  133. package/test-utils/sdks/alby/src/schemas/ZapierRulePatch.ts +74 -0
  134. package/test-utils/sdks/alby/src/schemas/ZapierRulePost.ts +83 -0
  135. package/test-utils/sdks/alby/src/schemas/ZapierRuleResponse.ts +122 -0
  136. package/test-utils/sdks/alby/src/schemas.ts +77 -0
  137. package/test-utils/sdks/alby/src/sdk.ts +381 -0
  138. package/test-utils/sdks/alby/src/types.ts +84 -0
  139. package/test-utils/sdks/alby/tsconfig.json +12 -0
  140. package/test-utils/sdks/metrotransit/README.md +22 -0
  141. package/test-utils/sdks/metrotransit/package.json +55 -0
  142. package/test-utils/sdks/metrotransit/src/index.ts +12 -0
  143. package/test-utils/sdks/metrotransit/src/schemas/Agency.ts +19 -0
  144. package/test-utils/sdks/metrotransit/src/schemas/AlertMessage.ts +18 -0
  145. package/test-utils/sdks/metrotransit/src/schemas/Departure.ts +78 -0
  146. package/test-utils/sdks/metrotransit/src/schemas/Direction.ts +19 -0
  147. package/test-utils/sdks/metrotransit/src/schemas/GetNextripAgencies.ts +12 -0
  148. package/test-utils/sdks/metrotransit/src/schemas/GetNextripDirectionsRouteId.ts +28 -0
  149. package/test-utils/sdks/metrotransit/src/schemas/GetNextripRouteIdDirectionIdPlaceCode.ts +30 -0
  150. package/test-utils/sdks/metrotransit/src/schemas/GetNextripRoutes.ts +12 -0
  151. package/test-utils/sdks/metrotransit/src/schemas/GetNextripStopId.ts +20 -0
  152. package/test-utils/sdks/metrotransit/src/schemas/GetNextripStopsRouteIdDirectionId.ts +34 -0
  153. package/test-utils/sdks/metrotransit/src/schemas/GetNextripVehiclesRouteId.ts +28 -0
  154. package/test-utils/sdks/metrotransit/src/schemas/NexTripResult.ts +34 -0
  155. package/test-utils/sdks/metrotransit/src/schemas/Place.ts +21 -0
  156. package/test-utils/sdks/metrotransit/src/schemas/ProblemDetails.ts +40 -0
  157. package/test-utils/sdks/metrotransit/src/schemas/Route.ts +25 -0
  158. package/test-utils/sdks/metrotransit/src/schemas/Stop.ts +27 -0
  159. package/test-utils/sdks/metrotransit/src/schemas/Vehicle.ts +61 -0
  160. package/test-utils/sdks/metrotransit/src/schemas.ts +18 -0
  161. package/test-utils/sdks/metrotransit/src/sdk.ts +107 -0
  162. package/test-utils/sdks/metrotransit/src/types.ts +23 -0
  163. package/test-utils/sdks/metrotransit/tsconfig.json +12 -0
  164. package/test-utils/sdks/operationid-quirks/README.md +22 -0
  165. package/test-utils/sdks/operationid-quirks/package.json +50 -0
  166. package/test-utils/sdks/operationid-quirks/src/index.ts +9 -0
  167. package/test-utils/sdks/operationid-quirks/src/sdk.ts +107 -0
  168. package/test-utils/sdks/operationid-quirks/tsconfig.json +12 -0
  169. package/test-utils/sdks/optional-payload/README.md +14 -0
  170. package/test-utils/sdks/optional-payload/package.json +55 -0
  171. package/test-utils/sdks/optional-payload/src/index.ts +9 -0
  172. package/test-utils/sdks/optional-payload/src/schemas/UpdatePetWithForm.ts +35 -0
  173. package/test-utils/sdks/optional-payload/src/schemas.ts +2 -0
  174. package/test-utils/sdks/optional-payload/src/sdk.ts +82 -0
  175. package/test-utils/sdks/optional-payload/src/types.ts +5 -0
  176. package/test-utils/sdks/optional-payload/tsconfig.json +12 -0
  177. package/test-utils/sdks/petstore/LICENSE +97 -0
  178. package/test-utils/sdks/petstore/README.md +23 -0
  179. package/test-utils/sdks/petstore/package.json +56 -0
  180. package/test-utils/sdks/petstore/src/index.ts +17 -0
  181. package/test-utils/sdks/petstore/src/schemas/ApiResponse.ts +18 -0
  182. package/test-utils/sdks/petstore/src/schemas/Category.ts +15 -0
  183. package/test-utils/sdks/petstore/src/schemas/CreateUsersWithArrayInput.ts +10 -0
  184. package/test-utils/sdks/petstore/src/schemas/CreateUsersWithListInput.ts +10 -0
  185. package/test-utils/sdks/petstore/src/schemas/DeleteOrder.ts +22 -0
  186. package/test-utils/sdks/petstore/src/schemas/DeletePet.ts +31 -0
  187. package/test-utils/sdks/petstore/src/schemas/DeleteUser.ts +20 -0
  188. package/test-utils/sdks/petstore/src/schemas/FindPetsByStatus.ts +38 -0
  189. package/test-utils/sdks/petstore/src/schemas/FindPetsByTags.ts +32 -0
  190. package/test-utils/sdks/petstore/src/schemas/GetInventory.ts +13 -0
  191. package/test-utils/sdks/petstore/src/schemas/GetOrderById.ts +23 -0
  192. package/test-utils/sdks/petstore/src/schemas/GetPetById.ts +21 -0
  193. package/test-utils/sdks/petstore/src/schemas/GetUserByName.ts +20 -0
  194. package/test-utils/sdks/petstore/src/schemas/LoginUser.ts +32 -0
  195. package/test-utils/sdks/petstore/src/schemas/Order.ts +37 -0
  196. package/test-utils/sdks/petstore/src/schemas/Pet.ts +53 -0
  197. package/test-utils/sdks/petstore/src/schemas/Tag.ts +15 -0
  198. package/test-utils/sdks/petstore/src/schemas/UpdatePetWithForm.ts +35 -0
  199. package/test-utils/sdks/petstore/src/schemas/UpdateUser.ts +20 -0
  200. package/test-utils/sdks/petstore/src/schemas/UploadFile.ts +36 -0
  201. package/test-utils/sdks/petstore/src/schemas/User.ts +35 -0
  202. package/test-utils/sdks/petstore/src/schemas.ts +22 -0
  203. package/test-utils/sdks/petstore/src/sdk.ts +248 -0
  204. package/test-utils/sdks/petstore/src/types.ts +29 -0
  205. package/test-utils/sdks/petstore/tsconfig.json +12 -0
  206. package/test-utils/sdks/readme/README.md +23 -0
  207. package/test-utils/sdks/readme/package.json +55 -0
  208. package/test-utils/sdks/readme/src/index.ts +13 -0
  209. package/test-utils/sdks/readme/src/schemas/Apply.ts +61 -0
  210. package/test-utils/sdks/readme/src/schemas/Category.ts +24 -0
  211. package/test-utils/sdks/readme/src/schemas/Changelog.ts +36 -0
  212. package/test-utils/sdks/readme/src/schemas/CondensedProjectData.ts +25 -0
  213. package/test-utils/sdks/readme/src/schemas/CreateCategory.ts +21 -0
  214. package/test-utils/sdks/readme/src/schemas/CreateCustomPage.ts +22 -0
  215. package/test-utils/sdks/readme/src/schemas/CreateDoc.ts +40 -0
  216. package/test-utils/sdks/readme/src/schemas/CreateVersion.ts +33 -0
  217. package/test-utils/sdks/readme/src/schemas/CustomPage.ts +33 -0
  218. package/test-utils/sdks/readme/src/schemas/DeleteApiSpecification.ts +39 -0
  219. package/test-utils/sdks/readme/src/schemas/DeleteCategory.ts +37 -0
  220. package/test-utils/sdks/readme/src/schemas/DeleteChangelog.ts +20 -0
  221. package/test-utils/sdks/readme/src/schemas/DeleteCustomPage.ts +39 -0
  222. package/test-utils/sdks/readme/src/schemas/DeleteDoc.ts +53 -0
  223. package/test-utils/sdks/readme/src/schemas/DeleteVersion.ts +42 -0
  224. package/test-utils/sdks/readme/src/schemas/DocSchemaPost.ts +135 -0
  225. package/test-utils/sdks/readme/src/schemas/DocSchemaPut.ts +62 -0
  226. package/test-utils/sdks/readme/src/schemas/DocSchemaResponse.ts +54 -0
  227. package/test-utils/sdks/readme/src/schemas/ErrorApikeyEmpty.ts +49 -0
  228. package/test-utils/sdks/readme/src/schemas/ErrorApikeyMismatch.ts +49 -0
  229. package/test-utils/sdks/readme/src/schemas/ErrorApikeyNotfound.ts +49 -0
  230. package/test-utils/sdks/readme/src/schemas/ErrorCategoryInvalid.ts +49 -0
  231. package/test-utils/sdks/readme/src/schemas/ErrorCategoryNotfound.ts +49 -0
  232. package/test-utils/sdks/readme/src/schemas/ErrorCustompageInvalid.ts +49 -0
  233. package/test-utils/sdks/readme/src/schemas/ErrorCustompageNotfound.ts +49 -0
  234. package/test-utils/sdks/readme/src/schemas/ErrorDocInvalid.ts +49 -0
  235. package/test-utils/sdks/readme/src/schemas/ErrorDocNotfound.ts +49 -0
  236. package/test-utils/sdks/readme/src/schemas/ErrorRegistryNotfound.ts +49 -0
  237. package/test-utils/sdks/readme/src/schemas/ErrorSpecFileEmpty.ts +49 -0
  238. package/test-utils/sdks/readme/src/schemas/ErrorSpecIdDuplicate.ts +49 -0
  239. package/test-utils/sdks/readme/src/schemas/ErrorSpecIdInvalid.ts +49 -0
  240. package/test-utils/sdks/readme/src/schemas/ErrorSpecInvalid.ts +49 -0
  241. package/test-utils/sdks/readme/src/schemas/ErrorSpecInvalidSchema.ts +49 -0
  242. package/test-utils/sdks/readme/src/schemas/ErrorSpecNotfound.ts +49 -0
  243. package/test-utils/sdks/readme/src/schemas/ErrorSpecTimeout.ts +49 -0
  244. package/test-utils/sdks/readme/src/schemas/ErrorSpecVersionNotfound.ts +49 -0
  245. package/test-utils/sdks/readme/src/schemas/ErrorVersionCantDemoteStable.ts +49 -0
  246. package/test-utils/sdks/readme/src/schemas/ErrorVersionCantRemoveStable.ts +49 -0
  247. package/test-utils/sdks/readme/src/schemas/ErrorVersionDuplicate.ts +49 -0
  248. package/test-utils/sdks/readme/src/schemas/ErrorVersionEmpty.ts +49 -0
  249. package/test-utils/sdks/readme/src/schemas/ErrorVersionForkEmpty.ts +49 -0
  250. package/test-utils/sdks/readme/src/schemas/ErrorVersionForkNotfound.ts +49 -0
  251. package/test-utils/sdks/readme/src/schemas/ErrorVersionNotfound.ts +49 -0
  252. package/test-utils/sdks/readme/src/schemas/GetApiRegistry.ts +27 -0
  253. package/test-utils/sdks/readme/src/schemas/GetApiSchema.ts +10 -0
  254. package/test-utils/sdks/readme/src/schemas/GetApiSpecification.ts +74 -0
  255. package/test-utils/sdks/readme/src/schemas/GetCategories.ts +57 -0
  256. package/test-utils/sdks/readme/src/schemas/GetCategory.ts +37 -0
  257. package/test-utils/sdks/readme/src/schemas/GetCategoryDocs.ts +37 -0
  258. package/test-utils/sdks/readme/src/schemas/GetChangelog.ts +20 -0
  259. package/test-utils/sdks/readme/src/schemas/GetChangelogs.ts +43 -0
  260. package/test-utils/sdks/readme/src/schemas/GetCustomPage.ts +39 -0
  261. package/test-utils/sdks/readme/src/schemas/GetCustomPages.ts +60 -0
  262. package/test-utils/sdks/readme/src/schemas/GetDoc.ts +53 -0
  263. package/test-utils/sdks/readme/src/schemas/GetOpenRoles.ts +12 -0
  264. package/test-utils/sdks/readme/src/schemas/GetProductionDoc.ts +53 -0
  265. package/test-utils/sdks/readme/src/schemas/GetProject.ts +22 -0
  266. package/test-utils/sdks/readme/src/schemas/GetVersion.ts +42 -0
  267. package/test-utils/sdks/readme/src/schemas/GetVersions.ts +22 -0
  268. package/test-utils/sdks/readme/src/schemas/JobOpening.ts +52 -0
  269. package/test-utils/sdks/readme/src/schemas/SearchDocs.ts +53 -0
  270. package/test-utils/sdks/readme/src/schemas/UpdateApiSpecification.ts +67 -0
  271. package/test-utils/sdks/readme/src/schemas/UpdateCategory.ts +37 -0
  272. package/test-utils/sdks/readme/src/schemas/UpdateChangelog.ts +20 -0
  273. package/test-utils/sdks/readme/src/schemas/UpdateCustomPage.ts +39 -0
  274. package/test-utils/sdks/readme/src/schemas/UpdateDoc.ts +53 -0
  275. package/test-utils/sdks/readme/src/schemas/UpdateVersion.ts +42 -0
  276. package/test-utils/sdks/readme/src/schemas/UploadApiSpecification.ts +64 -0
  277. package/test-utils/sdks/readme/src/schemas/Version.ts +40 -0
  278. package/test-utils/sdks/readme/src/schemas.ts +70 -0
  279. package/test-utils/sdks/readme/src/sdk.ts +477 -0
  280. package/test-utils/sdks/readme/src/types.ts +120 -0
  281. package/test-utils/sdks/readme/tsconfig.json +12 -0
  282. package/test-utils/sdks/response-title-quirks/README.md +14 -0
  283. package/test-utils/sdks/response-title-quirks/package.json +55 -0
  284. package/test-utils/sdks/response-title-quirks/src/index.ts +9 -0
  285. package/test-utils/sdks/response-title-quirks/src/schemas/GetAnything.ts +60 -0
  286. package/test-utils/sdks/response-title-quirks/src/schemas.ts +2 -0
  287. package/test-utils/sdks/response-title-quirks/src/sdk.ts +76 -0
  288. package/test-utils/sdks/response-title-quirks/src/types.ts +5 -0
  289. package/test-utils/sdks/response-title-quirks/tsconfig.json +12 -0
  290. package/test-utils/sdks/simple/README.md +14 -0
  291. package/test-utils/sdks/simple/package.json +55 -0
  292. package/test-utils/sdks/simple/src/index.ts +10 -0
  293. package/test-utils/sdks/simple/src/schemas/Category.ts +15 -0
  294. package/test-utils/sdks/simple/src/schemas/FindPetsByStatus.ts +38 -0
  295. package/test-utils/sdks/simple/src/schemas/Pet.ts +53 -0
  296. package/test-utils/sdks/simple/src/schemas/Tag.ts +15 -0
  297. package/test-utils/sdks/simple/src/schemas.ts +5 -0
  298. package/test-utils/sdks/simple/src/sdk.ts +81 -0
  299. package/test-utils/sdks/simple/src/types.ts +8 -0
  300. package/test-utils/sdks/simple/tsconfig.json +12 -0
  301. package/test-utils/sdks/star-trek/README.md +22 -0
  302. package/test-utils/sdks/star-trek/package.json +55 -0
  303. package/test-utils/sdks/star-trek/src/index.ts +9 -0
  304. package/test-utils/sdks/star-trek/src/schemas/AnimalBase.ts +41 -0
  305. package/test-utils/sdks/star-trek/src/schemas/AnimalBaseResponse.ts +20 -0
  306. package/test-utils/sdks/star-trek/src/schemas/AnimalFull.ts +41 -0
  307. package/test-utils/sdks/star-trek/src/schemas/AnimalFullResponse.ts +12 -0
  308. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectBase.ts +27 -0
  309. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectBaseResponse.ts +20 -0
  310. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectFull.ts +32 -0
  311. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectFullResponse.ts +12 -0
  312. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectHeader.ts +21 -0
  313. package/test-utils/sdks/star-trek/src/schemas/AstronomicalObjectType.ts +36 -0
  314. package/test-utils/sdks/star-trek/src/schemas/BloodType.ts +12 -0
  315. package/test-utils/sdks/star-trek/src/schemas/BookBase.ts +120 -0
  316. package/test-utils/sdks/star-trek/src/schemas/BookBaseResponse.ts +20 -0
  317. package/test-utils/sdks/star-trek/src/schemas/BookCollectionBase.ts +51 -0
  318. package/test-utils/sdks/star-trek/src/schemas/BookCollectionBaseResponse.ts +20 -0
  319. package/test-utils/sdks/star-trek/src/schemas/BookCollectionFull.ts +98 -0
  320. package/test-utils/sdks/star-trek/src/schemas/BookCollectionFullResponse.ts +12 -0
  321. package/test-utils/sdks/star-trek/src/schemas/BookFull.ts +182 -0
  322. package/test-utils/sdks/star-trek/src/schemas/BookFullResponse.ts +12 -0
  323. package/test-utils/sdks/star-trek/src/schemas/BookSeriesBase.ts +57 -0
  324. package/test-utils/sdks/star-trek/src/schemas/BookSeriesBaseResponse.ts +20 -0
  325. package/test-utils/sdks/star-trek/src/schemas/BookSeriesFull.ts +81 -0
  326. package/test-utils/sdks/star-trek/src/schemas/BookSeriesFullResponse.ts +12 -0
  327. package/test-utils/sdks/star-trek/src/schemas/CharacterBase.ts +104 -0
  328. package/test-utils/sdks/star-trek/src/schemas/CharacterBaseResponse.ts +20 -0
  329. package/test-utils/sdks/star-trek/src/schemas/CharacterFull.ts +152 -0
  330. package/test-utils/sdks/star-trek/src/schemas/CharacterFullResponse.ts +12 -0
  331. package/test-utils/sdks/star-trek/src/schemas/CharacterHeader.ts +21 -0
  332. package/test-utils/sdks/star-trek/src/schemas/CharacterRelation.ts +17 -0
  333. package/test-utils/sdks/star-trek/src/schemas/CharacterSpecies.ts +25 -0
  334. package/test-utils/sdks/star-trek/src/schemas/ComicCollectionBase.ts +71 -0
  335. package/test-utils/sdks/star-trek/src/schemas/ComicCollectionBaseResponse.ts +20 -0
  336. package/test-utils/sdks/star-trek/src/schemas/ComicCollectionFull.ts +123 -0
  337. package/test-utils/sdks/star-trek/src/schemas/ComicCollectionFullResponse.ts +12 -0
  338. package/test-utils/sdks/star-trek/src/schemas/ComicSeriesBase.ts +75 -0
  339. package/test-utils/sdks/star-trek/src/schemas/ComicSeriesBaseResponse.ts +20 -0
  340. package/test-utils/sdks/star-trek/src/schemas/ComicSeriesFull.ts +99 -0
  341. package/test-utils/sdks/star-trek/src/schemas/ComicSeriesFullResponse.ts +12 -0
  342. package/test-utils/sdks/star-trek/src/schemas/ComicStripBase.ts +61 -0
  343. package/test-utils/sdks/star-trek/src/schemas/ComicStripBaseResponse.ts +20 -0
  344. package/test-utils/sdks/star-trek/src/schemas/ComicStripFull.ts +85 -0
  345. package/test-utils/sdks/star-trek/src/schemas/ComicStripFullResponse.ts +12 -0
  346. package/test-utils/sdks/star-trek/src/schemas/ComicsBase.ts +75 -0
  347. package/test-utils/sdks/star-trek/src/schemas/ComicsBaseResponse.ts +20 -0
  348. package/test-utils/sdks/star-trek/src/schemas/ComicsFull.ts +127 -0
  349. package/test-utils/sdks/star-trek/src/schemas/ComicsFullResponse.ts +12 -0
  350. package/test-utils/sdks/star-trek/src/schemas/CompanyBase.ts +89 -0
  351. package/test-utils/sdks/star-trek/src/schemas/CompanyBaseResponse.ts +20 -0
  352. package/test-utils/sdks/star-trek/src/schemas/CompanyFull.ts +89 -0
  353. package/test-utils/sdks/star-trek/src/schemas/CompanyFullResponse.ts +12 -0
  354. package/test-utils/sdks/star-trek/src/schemas/CompanyHeader.ts +21 -0
  355. package/test-utils/sdks/star-trek/src/schemas/ConflictBase.ts +49 -0
  356. package/test-utils/sdks/star-trek/src/schemas/ConflictBaseResponse.ts +20 -0
  357. package/test-utils/sdks/star-trek/src/schemas/ConflictFull.ts +78 -0
  358. package/test-utils/sdks/star-trek/src/schemas/ConflictFullResponse.ts +12 -0
  359. package/test-utils/sdks/star-trek/src/schemas/ContentLanguage.ts +21 -0
  360. package/test-utils/sdks/star-trek/src/schemas/ContentRating.ts +20 -0
  361. package/test-utils/sdks/star-trek/src/schemas/ContentRatingSystem.ts +35 -0
  362. package/test-utils/sdks/star-trek/src/schemas/Country.ts +21 -0
  363. package/test-utils/sdks/star-trek/src/schemas/ElementBase.ts +61 -0
  364. package/test-utils/sdks/star-trek/src/schemas/ElementBaseResponse.ts +20 -0
  365. package/test-utils/sdks/star-trek/src/schemas/ElementFull.ts +61 -0
  366. package/test-utils/sdks/star-trek/src/schemas/ElementFullResponse.ts +12 -0
  367. package/test-utils/sdks/star-trek/src/schemas/EpisodeBase.ts +82 -0
  368. package/test-utils/sdks/star-trek/src/schemas/EpisodeBaseResponse.ts +20 -0
  369. package/test-utils/sdks/star-trek/src/schemas/EpisodeFull.ts +125 -0
  370. package/test-utils/sdks/star-trek/src/schemas/EpisodeFullResponse.ts +12 -0
  371. package/test-utils/sdks/star-trek/src/schemas/Error.ts +17 -0
  372. package/test-utils/sdks/star-trek/src/schemas/FoodBase.ts +61 -0
  373. package/test-utils/sdks/star-trek/src/schemas/FoodBaseResponse.ts +20 -0
  374. package/test-utils/sdks/star-trek/src/schemas/FoodFull.ts +61 -0
  375. package/test-utils/sdks/star-trek/src/schemas/FoodFullResponse.ts +12 -0
  376. package/test-utils/sdks/star-trek/src/schemas/Gender.ts +11 -0
  377. package/test-utils/sdks/star-trek/src/schemas/Genre.ts +17 -0
  378. package/test-utils/sdks/star-trek/src/schemas/GetAnimal.ts +25 -0
  379. package/test-utils/sdks/star-trek/src/schemas/GetAnimalSearch.ts +30 -0
  380. package/test-utils/sdks/star-trek/src/schemas/GetAstronomicalobject.ts +25 -0
  381. package/test-utils/sdks/star-trek/src/schemas/GetAstronomicalobjectSearch.ts +30 -0
  382. package/test-utils/sdks/star-trek/src/schemas/GetBook.ts +25 -0
  383. package/test-utils/sdks/star-trek/src/schemas/GetBookSearch.ts +30 -0
  384. package/test-utils/sdks/star-trek/src/schemas/GetBookcollection.ts +25 -0
  385. package/test-utils/sdks/star-trek/src/schemas/GetBookcollectionSearch.ts +30 -0
  386. package/test-utils/sdks/star-trek/src/schemas/GetBookseries.ts +25 -0
  387. package/test-utils/sdks/star-trek/src/schemas/GetBookseriesSearch.ts +30 -0
  388. package/test-utils/sdks/star-trek/src/schemas/GetCharacter.ts +25 -0
  389. package/test-utils/sdks/star-trek/src/schemas/GetCharacterSearch.ts +30 -0
  390. package/test-utils/sdks/star-trek/src/schemas/GetComiccollection.ts +25 -0
  391. package/test-utils/sdks/star-trek/src/schemas/GetComiccollectionSearch.ts +30 -0
  392. package/test-utils/sdks/star-trek/src/schemas/GetComics.ts +25 -0
  393. package/test-utils/sdks/star-trek/src/schemas/GetComicsSearch.ts +30 -0
  394. package/test-utils/sdks/star-trek/src/schemas/GetComicseries.ts +25 -0
  395. package/test-utils/sdks/star-trek/src/schemas/GetComicseriesSearch.ts +30 -0
  396. package/test-utils/sdks/star-trek/src/schemas/GetComicstrip.ts +25 -0
  397. package/test-utils/sdks/star-trek/src/schemas/GetComicstripSearch.ts +30 -0
  398. package/test-utils/sdks/star-trek/src/schemas/GetCompany.ts +25 -0
  399. package/test-utils/sdks/star-trek/src/schemas/GetCompanySearch.ts +30 -0
  400. package/test-utils/sdks/star-trek/src/schemas/GetConflict.ts +25 -0
  401. package/test-utils/sdks/star-trek/src/schemas/GetConflictSearch.ts +30 -0
  402. package/test-utils/sdks/star-trek/src/schemas/GetElement.ts +25 -0
  403. package/test-utils/sdks/star-trek/src/schemas/GetElementSearch.ts +30 -0
  404. package/test-utils/sdks/star-trek/src/schemas/GetEpisode.ts +25 -0
  405. package/test-utils/sdks/star-trek/src/schemas/GetEpisodeSearch.ts +30 -0
  406. package/test-utils/sdks/star-trek/src/schemas/GetFood.ts +25 -0
  407. package/test-utils/sdks/star-trek/src/schemas/GetFoodSearch.ts +30 -0
  408. package/test-utils/sdks/star-trek/src/schemas/GetLiterature.ts +25 -0
  409. package/test-utils/sdks/star-trek/src/schemas/GetLiteratureSearch.ts +30 -0
  410. package/test-utils/sdks/star-trek/src/schemas/GetLocation.ts +25 -0
  411. package/test-utils/sdks/star-trek/src/schemas/GetLocationSearch.ts +30 -0
  412. package/test-utils/sdks/star-trek/src/schemas/GetMagazine.ts +25 -0
  413. package/test-utils/sdks/star-trek/src/schemas/GetMagazineSearch.ts +30 -0
  414. package/test-utils/sdks/star-trek/src/schemas/GetMagazineseries.ts +25 -0
  415. package/test-utils/sdks/star-trek/src/schemas/GetMagazineseriesSearch.ts +30 -0
  416. package/test-utils/sdks/star-trek/src/schemas/GetMaterial.ts +25 -0
  417. package/test-utils/sdks/star-trek/src/schemas/GetMaterialSearch.ts +30 -0
  418. package/test-utils/sdks/star-trek/src/schemas/GetMedicalcondition.ts +25 -0
  419. package/test-utils/sdks/star-trek/src/schemas/GetMedicalconditionSearch.ts +30 -0
  420. package/test-utils/sdks/star-trek/src/schemas/GetMovie.ts +25 -0
  421. package/test-utils/sdks/star-trek/src/schemas/GetMovieSearch.ts +30 -0
  422. package/test-utils/sdks/star-trek/src/schemas/GetOccupation.ts +25 -0
  423. package/test-utils/sdks/star-trek/src/schemas/GetOccupationSearch.ts +30 -0
  424. package/test-utils/sdks/star-trek/src/schemas/GetOrganization.ts +25 -0
  425. package/test-utils/sdks/star-trek/src/schemas/GetOrganizationSearch.ts +30 -0
  426. package/test-utils/sdks/star-trek/src/schemas/GetPerformer.ts +25 -0
  427. package/test-utils/sdks/star-trek/src/schemas/GetPerformerSearch.ts +30 -0
  428. package/test-utils/sdks/star-trek/src/schemas/GetSeason.ts +25 -0
  429. package/test-utils/sdks/star-trek/src/schemas/GetSeasonSearch.ts +30 -0
  430. package/test-utils/sdks/star-trek/src/schemas/GetSeries.ts +25 -0
  431. package/test-utils/sdks/star-trek/src/schemas/GetSeriesSearch.ts +30 -0
  432. package/test-utils/sdks/star-trek/src/schemas/GetSoundtrack.ts +25 -0
  433. package/test-utils/sdks/star-trek/src/schemas/GetSoundtrackSearch.ts +30 -0
  434. package/test-utils/sdks/star-trek/src/schemas/GetSpacecraft.ts +25 -0
  435. package/test-utils/sdks/star-trek/src/schemas/GetSpacecraftSearch.ts +30 -0
  436. package/test-utils/sdks/star-trek/src/schemas/GetSpacecraftclass.ts +25 -0
  437. package/test-utils/sdks/star-trek/src/schemas/GetSpacecraftclassSearch.ts +30 -0
  438. package/test-utils/sdks/star-trek/src/schemas/GetSpecies.ts +25 -0
  439. package/test-utils/sdks/star-trek/src/schemas/GetSpeciesSearch.ts +30 -0
  440. package/test-utils/sdks/star-trek/src/schemas/GetStaff.ts +25 -0
  441. package/test-utils/sdks/star-trek/src/schemas/GetStaffSearch.ts +30 -0
  442. package/test-utils/sdks/star-trek/src/schemas/GetTechnology.ts +25 -0
  443. package/test-utils/sdks/star-trek/src/schemas/GetTechnologySearch.ts +30 -0
  444. package/test-utils/sdks/star-trek/src/schemas/GetTitle.ts +25 -0
  445. package/test-utils/sdks/star-trek/src/schemas/GetTitleSearch.ts +30 -0
  446. package/test-utils/sdks/star-trek/src/schemas/GetTradingcard.ts +25 -0
  447. package/test-utils/sdks/star-trek/src/schemas/GetTradingcardSearch.ts +30 -0
  448. package/test-utils/sdks/star-trek/src/schemas/GetTradingcarddeck.ts +25 -0
  449. package/test-utils/sdks/star-trek/src/schemas/GetTradingcarddeckSearch.ts +30 -0
  450. package/test-utils/sdks/star-trek/src/schemas/GetTradingcardset.ts +25 -0
  451. package/test-utils/sdks/star-trek/src/schemas/GetTradingcardsetSearch.ts +30 -0
  452. package/test-utils/sdks/star-trek/src/schemas/GetVideogame.ts +25 -0
  453. package/test-utils/sdks/star-trek/src/schemas/GetVideogameSearch.ts +30 -0
  454. package/test-utils/sdks/star-trek/src/schemas/GetVideorelease.ts +25 -0
  455. package/test-utils/sdks/star-trek/src/schemas/GetVideoreleaseSearch.ts +30 -0
  456. package/test-utils/sdks/star-trek/src/schemas/GetWeapon.ts +25 -0
  457. package/test-utils/sdks/star-trek/src/schemas/GetWeaponSearch.ts +30 -0
  458. package/test-utils/sdks/star-trek/src/schemas/LiteratureBase.ts +45 -0
  459. package/test-utils/sdks/star-trek/src/schemas/LiteratureBaseResponse.ts +20 -0
  460. package/test-utils/sdks/star-trek/src/schemas/LiteratureFull.ts +45 -0
  461. package/test-utils/sdks/star-trek/src/schemas/LiteratureFullResponse.ts +12 -0
  462. package/test-utils/sdks/star-trek/src/schemas/LocationBase.ts +113 -0
  463. package/test-utils/sdks/star-trek/src/schemas/LocationBaseResponse.ts +20 -0
  464. package/test-utils/sdks/star-trek/src/schemas/LocationFull.ts +113 -0
  465. package/test-utils/sdks/star-trek/src/schemas/LocationFullResponse.ts +12 -0
  466. package/test-utils/sdks/star-trek/src/schemas/MagazineBase.ts +53 -0
  467. package/test-utils/sdks/star-trek/src/schemas/MagazineBaseResponse.ts +20 -0
  468. package/test-utils/sdks/star-trek/src/schemas/MagazineFull.ts +72 -0
  469. package/test-utils/sdks/star-trek/src/schemas/MagazineFullResponse.ts +12 -0
  470. package/test-utils/sdks/star-trek/src/schemas/MagazineSeriesBase.ts +41 -0
  471. package/test-utils/sdks/star-trek/src/schemas/MagazineSeriesBaseResponse.ts +20 -0
  472. package/test-utils/sdks/star-trek/src/schemas/MagazineSeriesFull.ts +60 -0
  473. package/test-utils/sdks/star-trek/src/schemas/MagazineSeriesFullResponse.ts +12 -0
  474. package/test-utils/sdks/star-trek/src/schemas/MaritalStatus.ts +17 -0
  475. package/test-utils/sdks/star-trek/src/schemas/MaterialBase.ts +61 -0
  476. package/test-utils/sdks/star-trek/src/schemas/MaterialBaseResponse.ts +20 -0
  477. package/test-utils/sdks/star-trek/src/schemas/MaterialFull.ts +61 -0
  478. package/test-utils/sdks/star-trek/src/schemas/MaterialFullResponse.ts +12 -0
  479. package/test-utils/sdks/star-trek/src/schemas/MedicalConditionBase.ts +25 -0
  480. package/test-utils/sdks/star-trek/src/schemas/MedicalConditionBaseResponse.ts +20 -0
  481. package/test-utils/sdks/star-trek/src/schemas/MedicalConditionFull.ts +25 -0
  482. package/test-utils/sdks/star-trek/src/schemas/MedicalConditionFullResponse.ts +12 -0
  483. package/test-utils/sdks/star-trek/src/schemas/MovieBase.ts +87 -0
  484. package/test-utils/sdks/star-trek/src/schemas/MovieBaseResponse.ts +20 -0
  485. package/test-utils/sdks/star-trek/src/schemas/MovieFull.ts +139 -0
  486. package/test-utils/sdks/star-trek/src/schemas/MovieFullResponse.ts +12 -0
  487. package/test-utils/sdks/star-trek/src/schemas/OccupationBase.ts +33 -0
  488. package/test-utils/sdks/star-trek/src/schemas/OccupationBaseResponse.ts +20 -0
  489. package/test-utils/sdks/star-trek/src/schemas/OccupationFull.ts +40 -0
  490. package/test-utils/sdks/star-trek/src/schemas/OccupationFullResponse.ts +12 -0
  491. package/test-utils/sdks/star-trek/src/schemas/OrganizationBase.ts +69 -0
  492. package/test-utils/sdks/star-trek/src/schemas/OrganizationBaseResponse.ts +20 -0
  493. package/test-utils/sdks/star-trek/src/schemas/OrganizationFull.ts +76 -0
  494. package/test-utils/sdks/star-trek/src/schemas/OrganizationFullResponse.ts +12 -0
  495. package/test-utils/sdks/star-trek/src/schemas/OrganizationHeader.ts +21 -0
  496. package/test-utils/sdks/star-trek/src/schemas/PerformerBase.ts +98 -0
  497. package/test-utils/sdks/star-trek/src/schemas/PerformerBaseResponse.ts +20 -0
  498. package/test-utils/sdks/star-trek/src/schemas/PerformerFull.ts +136 -0
  499. package/test-utils/sdks/star-trek/src/schemas/PerformerFullResponse.ts +12 -0
  500. package/test-utils/sdks/star-trek/src/schemas/Platform.ts +17 -0
  501. package/test-utils/sdks/star-trek/src/schemas/PostAnimalSearch.ts +65 -0
  502. package/test-utils/sdks/star-trek/src/schemas/PostAstronomicalobjectSearch.ts +53 -0
  503. package/test-utils/sdks/star-trek/src/schemas/PostBookSearch.ts +141 -0
  504. package/test-utils/sdks/star-trek/src/schemas/PostBookcollectionSearch.ts +85 -0
  505. package/test-utils/sdks/star-trek/src/schemas/PostBookseriesSearch.ts +83 -0
  506. package/test-utils/sdks/star-trek/src/schemas/PostCharacterSearch.ts +69 -0
  507. package/test-utils/sdks/star-trek/src/schemas/PostComiccollectionSearch.ts +89 -0
  508. package/test-utils/sdks/star-trek/src/schemas/PostComicsSearch.ts +93 -0
  509. package/test-utils/sdks/star-trek/src/schemas/PostComicseriesSearch.ts +93 -0
  510. package/test-utils/sdks/star-trek/src/schemas/PostComicstripSearch.ts +75 -0
  511. package/test-utils/sdks/star-trek/src/schemas/PostCompanySearch.ts +113 -0
  512. package/test-utils/sdks/star-trek/src/schemas/PostConflictSearch.ts +75 -0
  513. package/test-utils/sdks/star-trek/src/schemas/PostElementSearch.ts +77 -0
  514. package/test-utils/sdks/star-trek/src/schemas/PostEpisodeSearch.ts +113 -0
  515. package/test-utils/sdks/star-trek/src/schemas/PostFoodSearch.ts +85 -0
  516. package/test-utils/sdks/star-trek/src/schemas/PostLiteratureSearch.ts +69 -0
  517. package/test-utils/sdks/star-trek/src/schemas/PostLocationSearch.ts +137 -0
  518. package/test-utils/sdks/star-trek/src/schemas/PostMagazineSearch.ts +65 -0
  519. package/test-utils/sdks/star-trek/src/schemas/PostMagazineseriesSearch.ts +65 -0
  520. package/test-utils/sdks/star-trek/src/schemas/PostMaterialSearch.ts +85 -0
  521. package/test-utils/sdks/star-trek/src/schemas/PostMedicalconditionSearch.ts +49 -0
  522. package/test-utils/sdks/star-trek/src/schemas/PostMovieSearch.ts +75 -0
  523. package/test-utils/sdks/star-trek/src/schemas/PostOccupationSearch.ts +57 -0
  524. package/test-utils/sdks/star-trek/src/schemas/PostOrganizationSearch.ts +93 -0
  525. package/test-utils/sdks/star-trek/src/schemas/PostPerformerSearch.ts +133 -0
  526. package/test-utils/sdks/star-trek/src/schemas/PostSeasonSearch.ts +65 -0
  527. package/test-utils/sdks/star-trek/src/schemas/PostSeriesSearch.ts +89 -0
  528. package/test-utils/sdks/star-trek/src/schemas/PostSoundtrackSearch.ts +65 -0
  529. package/test-utils/sdks/star-trek/src/schemas/PostSpacecraftSearch.ts +45 -0
  530. package/test-utils/sdks/star-trek/src/schemas/PostSpacecraftclassSearch.ts +53 -0
  531. package/test-utils/sdks/star-trek/src/schemas/PostSpeciesSearch.ts +93 -0
  532. package/test-utils/sdks/star-trek/src/schemas/PostStaffSearch.ts +301 -0
  533. package/test-utils/sdks/star-trek/src/schemas/PostTechnologySearch.ts +125 -0
  534. package/test-utils/sdks/star-trek/src/schemas/PostTitleSearch.ts +65 -0
  535. package/test-utils/sdks/star-trek/src/schemas/PostTradingcardSearch.ts +53 -0
  536. package/test-utils/sdks/star-trek/src/schemas/PostTradingcarddeckSearch.ts +49 -0
  537. package/test-utils/sdks/star-trek/src/schemas/PostTradingcardsetSearch.ts +119 -0
  538. package/test-utils/sdks/star-trek/src/schemas/PostVideogameSearch.ts +55 -0
  539. package/test-utils/sdks/star-trek/src/schemas/PostVideoreleaseSearch.ts +65 -0
  540. package/test-utils/sdks/star-trek/src/schemas/PostWeaponSearch.ts +73 -0
  541. package/test-utils/sdks/star-trek/src/schemas/ProductionRunUnit.ts +11 -0
  542. package/test-utils/sdks/star-trek/src/schemas/Reference.ts +20 -0
  543. package/test-utils/sdks/star-trek/src/schemas/ReferenceType.ts +11 -0
  544. package/test-utils/sdks/star-trek/src/schemas/ResponsePage.ts +42 -0
  545. package/test-utils/sdks/star-trek/src/schemas/ResponseSort.ts +16 -0
  546. package/test-utils/sdks/star-trek/src/schemas/ResponseSortClause.ts +25 -0
  547. package/test-utils/sdks/star-trek/src/schemas/ResponseSortDirection.ts +11 -0
  548. package/test-utils/sdks/star-trek/src/schemas/SeasonBase.ts +32 -0
  549. package/test-utils/sdks/star-trek/src/schemas/SeasonBaseResponse.ts +20 -0
  550. package/test-utils/sdks/star-trek/src/schemas/SeasonFull.ts +38 -0
  551. package/test-utils/sdks/star-trek/src/schemas/SeasonFullResponse.ts +12 -0
  552. package/test-utils/sdks/star-trek/src/schemas/SeasonHeader.ts +21 -0
  553. package/test-utils/sdks/star-trek/src/schemas/SeriesBase.ts +60 -0
  554. package/test-utils/sdks/star-trek/src/schemas/SeriesBaseResponse.ts +20 -0
  555. package/test-utils/sdks/star-trek/src/schemas/SeriesFull.ts +72 -0
  556. package/test-utils/sdks/star-trek/src/schemas/SeriesFullResponse.ts +12 -0
  557. package/test-utils/sdks/star-trek/src/schemas/SeriesHeader.ts +21 -0
  558. package/test-utils/sdks/star-trek/src/schemas/SoundtrackBase.ts +30 -0
  559. package/test-utils/sdks/star-trek/src/schemas/SoundtrackBaseResponse.ts +20 -0
  560. package/test-utils/sdks/star-trek/src/schemas/SoundtrackFull.ts +59 -0
  561. package/test-utils/sdks/star-trek/src/schemas/SoundtrackFullResponse.ts +12 -0
  562. package/test-utils/sdks/star-trek/src/schemas/SpacecraftBase.ts +39 -0
  563. package/test-utils/sdks/star-trek/src/schemas/SpacecraftBaseResponse.ts +20 -0
  564. package/test-utils/sdks/star-trek/src/schemas/SpacecraftClassBase.ts +48 -0
  565. package/test-utils/sdks/star-trek/src/schemas/SpacecraftClassBaseResponse.ts +20 -0
  566. package/test-utils/sdks/star-trek/src/schemas/SpacecraftClassFull.ts +60 -0
  567. package/test-utils/sdks/star-trek/src/schemas/SpacecraftClassFullResponse.ts +12 -0
  568. package/test-utils/sdks/star-trek/src/schemas/SpacecraftClassHeader.ts +21 -0
  569. package/test-utils/sdks/star-trek/src/schemas/SpacecraftFull.ts +45 -0
  570. package/test-utils/sdks/star-trek/src/schemas/SpacecraftFullResponse.ts +12 -0
  571. package/test-utils/sdks/star-trek/src/schemas/SpacecraftType.ts +17 -0
  572. package/test-utils/sdks/star-trek/src/schemas/SpeciesBase.ts +73 -0
  573. package/test-utils/sdks/star-trek/src/schemas/SpeciesBaseResponse.ts +20 -0
  574. package/test-utils/sdks/star-trek/src/schemas/SpeciesFull.ts +79 -0
  575. package/test-utils/sdks/star-trek/src/schemas/SpeciesFullResponse.ts +12 -0
  576. package/test-utils/sdks/star-trek/src/schemas/SpeciesHeader.ts +21 -0
  577. package/test-utils/sdks/star-trek/src/schemas/StaffBase.ts +266 -0
  578. package/test-utils/sdks/star-trek/src/schemas/StaffBaseResponse.ts +20 -0
  579. package/test-utils/sdks/star-trek/src/schemas/StaffFull.ts +323 -0
  580. package/test-utils/sdks/star-trek/src/schemas/StaffFullResponse.ts +12 -0
  581. package/test-utils/sdks/star-trek/src/schemas/StaffHeader.ts +21 -0
  582. package/test-utils/sdks/star-trek/src/schemas/TechnologyBase.ts +101 -0
  583. package/test-utils/sdks/star-trek/src/schemas/TechnologyBaseResponse.ts +20 -0
  584. package/test-utils/sdks/star-trek/src/schemas/TechnologyFull.ts +101 -0
  585. package/test-utils/sdks/star-trek/src/schemas/TechnologyFullResponse.ts +12 -0
  586. package/test-utils/sdks/star-trek/src/schemas/TitleBase.ts +41 -0
  587. package/test-utils/sdks/star-trek/src/schemas/TitleBaseResponse.ts +20 -0
  588. package/test-utils/sdks/star-trek/src/schemas/TitleFull.ts +48 -0
  589. package/test-utils/sdks/star-trek/src/schemas/TitleFullResponse.ts +12 -0
  590. package/test-utils/sdks/star-trek/src/schemas/TradingCardBase.ts +38 -0
  591. package/test-utils/sdks/star-trek/src/schemas/TradingCardBaseResponse.ts +20 -0
  592. package/test-utils/sdks/star-trek/src/schemas/TradingCardDeckBase.ts +28 -0
  593. package/test-utils/sdks/star-trek/src/schemas/TradingCardDeckBaseResponse.ts +20 -0
  594. package/test-utils/sdks/star-trek/src/schemas/TradingCardDeckFull.ts +34 -0
  595. package/test-utils/sdks/star-trek/src/schemas/TradingCardDeckFullResponse.ts +12 -0
  596. package/test-utils/sdks/star-trek/src/schemas/TradingCardDeckHeader.ts +21 -0
  597. package/test-utils/sdks/star-trek/src/schemas/TradingCardFull.ts +38 -0
  598. package/test-utils/sdks/star-trek/src/schemas/TradingCardFullResponse.ts +12 -0
  599. package/test-utils/sdks/star-trek/src/schemas/TradingCardSetBase.ts +62 -0
  600. package/test-utils/sdks/star-trek/src/schemas/TradingCardSetBaseResponse.ts +20 -0
  601. package/test-utils/sdks/star-trek/src/schemas/TradingCardSetFull.ts +86 -0
  602. package/test-utils/sdks/star-trek/src/schemas/TradingCardSetFullResponse.ts +12 -0
  603. package/test-utils/sdks/star-trek/src/schemas/TradingCardSetHeader.ts +21 -0
  604. package/test-utils/sdks/star-trek/src/schemas/VideoGameBase.ts +48 -0
  605. package/test-utils/sdks/star-trek/src/schemas/VideoGameBaseResponse.ts +20 -0
  606. package/test-utils/sdks/star-trek/src/schemas/VideoGameFull.ts +84 -0
  607. package/test-utils/sdks/star-trek/src/schemas/VideoGameFullResponse.ts +12 -0
  608. package/test-utils/sdks/star-trek/src/schemas/VideoReleaseBase.ts +127 -0
  609. package/test-utils/sdks/star-trek/src/schemas/VideoReleaseBaseResponse.ts +20 -0
  610. package/test-utils/sdks/star-trek/src/schemas/VideoReleaseFormat.ts +23 -0
  611. package/test-utils/sdks/star-trek/src/schemas/VideoReleaseFull.ts +155 -0
  612. package/test-utils/sdks/star-trek/src/schemas/VideoReleaseFullResponse.ts +12 -0
  613. package/test-utils/sdks/star-trek/src/schemas/WeaponBase.ts +49 -0
  614. package/test-utils/sdks/star-trek/src/schemas/WeaponBaseResponse.ts +20 -0
  615. package/test-utils/sdks/star-trek/src/schemas/WeaponFull.ts +49 -0
  616. package/test-utils/sdks/star-trek/src/schemas/WeaponFullResponse.ts +12 -0
  617. package/test-utils/sdks/star-trek/src/schemas.ts +314 -0
  618. package/test-utils/sdks/star-trek/src/sdk.ts +1032 -0
  619. package/test-utils/sdks/star-trek/src/types.ts +490 -0
  620. package/test-utils/sdks/star-trek/tsconfig.json +12 -0
  621. package/test-utils/tsconfig.json +9 -0
  622. package/tsconfig.eslint.json +8 -0
  623. package/tsconfig.json +9 -0
  624. package/tsup.config.ts +31 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/getJSONSchemaDefaults.ts","../src/lib/parseResponse.ts","../src/lib/prepareAuth.ts","../src/lib/prepareParams.ts","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/index.js","../../../node_modules/.pnpm/is-stream@4.0.1/node_modules/is-stream/index.js","../../../node_modules/.pnpm/@sec-ant+readable-stream@0.4.1/node_modules/@sec-ant/readable-stream/dist/ponyfill/asyncIterator.js","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/stream.js","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/contents.js","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/utils.js","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/array-buffer.js","../../../node_modules/.pnpm/get-stream@9.0.1/node_modules/get-stream/source/buffer.js","../src/lib/prepareServer.ts"],"sourcesContent":["import type {SchemaWrapper} from 'oas/operation/get-parameters-as-json-schema'\nimport type {SchemaObject} from 'oas/types'\n\nimport traverse from 'json-schema-traverse'\n\n/**\n * Run through a JSON Schema object and compose up an object containing default data for any schema\n * property that is required and also has a defined default.\n *\n * Code partially adapted from the `json-schema-default` package but modified to only return\n * defaults of required properties.\n *\n * @todo This is a good candidate to be moved into a core `oas` library method.\n * @see {@link https://github.com/mdornseif/json-schema-default}\n */\nexport default function getJSONSchemaDefaults(jsonSchemas: SchemaWrapper[]) {\n return jsonSchemas\n .map(({type: payloadType, schema: jsonSchema}) => {\n const defaults: Record<string, unknown> = {}\n traverse(\n jsonSchema,\n (\n schema: SchemaObject,\n pointer: string,\n _rootSchema: SchemaObject,\n parentPointer?: string,\n _parentKeyword?: string,\n parentSchema?: SchemaObject,\n indexProperty?: number | string,\n ) => {\n if (!pointer.startsWith('/properties/')) {\n return\n }\n\n if (\n Array.isArray(parentSchema?.required) &&\n parentSchema?.required.includes(String(indexProperty))\n ) {\n if (schema.type === 'object' && indexProperty) {\n defaults[indexProperty] = {}\n }\n\n let destination = defaults\n if (parentPointer) {\n // To map nested objects correct we need to pick apart the parent pointer.\n parentPointer\n .replace(/\\/properties/g, '')\n .split('/')\n .forEach((subSchema: string) => {\n if (subSchema === '') {\n return\n }\n\n destination = (destination?.[subSchema] as Record<string, unknown>) || {}\n })\n }\n\n if (schema.default !== undefined) {\n if (indexProperty !== undefined) {\n destination[indexProperty] = schema.default\n }\n }\n }\n },\n )\n\n if (!Object.keys(defaults).length) {\n return {}\n }\n\n return {\n // @todo should we filter out empty and undefined objects from here with `remove-undefined-objects`?\n [payloadType]: defaults,\n }\n })\n .reduce((prev, next) => Object.assign(prev, next))\n}\n","import {matchesMimeType} from 'oas/utils'\n\nexport default async function parseResponse<HTTPStatus extends number = number>(\n response: Response,\n) {\n const contentType = response.headers.get('Content-Type')\n const isJSON =\n contentType && (matchesMimeType.json(contentType) || matchesMimeType.wildcard(contentType))\n\n const responseBody = await response.clone().text()\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let data: any = responseBody\n if (isJSON) {\n try {\n data = JSON.parse(responseBody)\n } catch (e) {\n // If our JSON parsing failed then we can just return plaintext instead.\n }\n }\n\n return {\n data,\n status: response.status as HTTPStatus,\n headers: response.headers,\n res: response,\n }\n}\n","/* eslint-disable no-underscore-dangle */\nimport type {AuthForHAR} from '@readme/oas-to-har/lib/types'\nimport type {Operation} from 'oas/operation'\nimport type {KeyedSecuritySchemeObject} from 'oas/types'\n\nexport default function prepareAuth(authKey: (number | string)[], operation: Operation) {\n if (authKey.length === 0) {\n return {}\n }\n\n const preparedAuth: AuthForHAR = {}\n\n const security = operation.getSecurity()\n if (security.length === 0) {\n // If there's no auth configured on this operation, don't prepare anything (even if it was\n // supplied by the user).\n return {}\n }\n\n // Does this operation require multiple forms of auth?\n if (security.every(s => Object.keys(s).length > 1)) {\n throw new Error(\n \"Sorry, this operation currently requires multiple forms of authentication which this library doesn't yet support.\",\n )\n }\n\n // Since we can only handle single auth security configurations, let's pull those out. This code\n // is a bit opaque but `security` here may look like `[{ basic: [] }, { oauth2: [], basic: []}]`\n // and are filtering it down to only single-auth requirements of `[{ basic: [] }]`.\n const usableSecurity = security\n .map(s => {\n return Object.keys(s).length === 1 ? s : false\n })\n .filter(Boolean)\n\n const usableSecuritySchemes = usableSecurity\n .map(s => Object.keys(s))\n .reduce((prev, next) => prev.concat(next), [])\n const preparedSecurity = operation.prepareSecurity()\n\n // If we have two auth tokens present let's look for Basic Auth in their configuration.\n if (authKey.length >= 2) {\n // If this operation doesn't support HTTP Basic auth but we have two tokens, that's a paddlin.\n if (!('Basic' in preparedSecurity)) {\n throw new Error(\n 'Multiple auth tokens were supplied for this endpoint but only a single token is needed.',\n )\n }\n\n // If we have two auth keys for Basic Auth but Basic isn't a usable security scheme (maybe it's\n // part of an AND or auth configuration -- which we don't support) then we need to error out.\n const schemes = preparedSecurity.Basic.filter(s => usableSecuritySchemes.includes(s._key))\n if (!schemes.length) {\n throw new Error(\n 'Credentials for Basic Authentication were supplied but this operation requires another form of auth in that case, which this library does not yet support. This operation does, however, allow supplying a single auth token.',\n )\n }\n\n const scheme = schemes.shift() as KeyedSecuritySchemeObject\n preparedAuth[scheme._key] = {\n user: String(authKey[0]),\n pass: authKey.length === 2 ? String(authKey[1]) : '',\n }\n\n return preparedAuth\n }\n\n // If we know we don't need to use HTTP Basic auth because we have a username+password then we\n // can pick the first usable security scheme available and try to use that. This might not always\n // be the auth scheme that the user wants, but we don't have any other way for the user to tell\n // us what they want with the current `sdk.auth()` API.\n const usableScheme = usableSecuritySchemes[0]\n const schemes = Object.entries(preparedSecurity)\n .map(([, ps]) => ps.filter(s => usableScheme === s._key))\n .reduce((prev, next) => prev.concat(next), [])\n\n const scheme = schemes.shift() as KeyedSecuritySchemeObject\n switch (scheme.type) {\n case 'http':\n if (scheme.scheme === 'basic') {\n preparedAuth[scheme._key] = {\n user: String(authKey[0]),\n pass: authKey.length === 2 ? String(authKey[1]) : '',\n }\n } else if (scheme.scheme === 'bearer') {\n preparedAuth[scheme._key] = String(authKey[0])\n }\n break\n\n case 'oauth2':\n preparedAuth[scheme._key] = String(authKey[0])\n break\n\n case 'apiKey':\n if (scheme.in === 'query' || scheme.in === 'header' || scheme.in === 'cookie') {\n preparedAuth[scheme._key] = String(authKey[0])\n }\n break\n\n default:\n throw new Error(\n `Sorry, this API currently uses a security scheme, ${scheme.type}, which this library doesn't yet support.`,\n )\n }\n\n return preparedAuth\n}\n","import type {ReadStream} from 'node:fs'\nimport type {Operation} from 'oas/operation'\nimport type {ParameterObject, SchemaObject} from 'oas/types'\n\nimport stream from 'node:stream'\n\nimport caseless from 'caseless'\n// `get-stream` is included in our bundle, see `tsup.config.ts`\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport {getStreamAsBuffer} from 'get-stream'\nimport lodashMerge from 'lodash.merge'\nimport removeUndefinedObjects from 'remove-undefined-objects'\n\nimport getJSONSchemaDefaults from './getJSONSchemaDefaults.js'\n\n// These headers are normally only defined by the OpenAPI definition but we allow the user to\n// manually supply them in their `metadata` parameter if they wish.\nconst specialHeaders = ['accept', 'authorization']\n\n/**\n * Extract all available parameters from an operations Parameter Object into a digestable array\n * that we can use to apply to the request.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameterObject}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameterObject}\n */\nfunction digestParameters(parameters: ParameterObject[]): Record<string, ParameterObject> {\n return parameters.reduce((prev, param) => {\n if ('$ref' in param || 'allOf' in param || 'anyOf' in param || 'oneOf' in param) {\n throw new Error(\n \"The OpenAPI document for this operation wasn't dereferenced before processing.\",\n )\n } else if (param.name in prev) {\n throw new Error(\n `The operation you are using has the same parameter, ${param.name}, spread across multiple entry points. We unfortunately can't handle this right now.`,\n )\n }\n\n return Object.assign(prev, {[param.name]: param})\n }, {})\n}\n\n// https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_isempty\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction isEmpty(obj: any) {\n return [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length\n}\n\nfunction isObject(thing: unknown) {\n if (thing instanceof stream.Readable) {\n return false\n }\n\n return typeof thing === 'object' && thing !== null && !Array.isArray(thing)\n}\n\nfunction isPrimitive(obj: unknown) {\n return obj === null || typeof obj === 'number' || typeof obj === 'string'\n}\n\nfunction merge(src: unknown, target: unknown) {\n if (Array.isArray(target)) {\n // @todo we need to add support for merging array defaults with array body/metadata arguments\n return target\n } else if (!isObject(target)) {\n return target\n }\n\n return lodashMerge(src, target)\n}\n\n/**\n * Ingest a file path or readable stream into a common object that we can later use to process it\n * into a parameters object for making an API request.\n *\n */\nasync function processFile(\n paramName: string | undefined,\n file: ReadStream | string,\n): Promise<{base64?: string; buffer?: Buffer; filename: string; paramName?: string} | undefined> {\n const fs = await import('node:fs')\n const path = await import('node:path')\n const {default: DatauriParser} = await import('datauri/parser.js')\n const {default: datauri} = await import('datauri/sync.js')\n if (typeof file === 'string') {\n // In order to support relative pathed files, we need to attempt to resolve them.\n const resolvedFile = path.resolve(file)\n\n return new Promise((resolve, reject) => {\n fs.stat(resolvedFile, async err => {\n if (err) {\n if (err.code === 'ENOENT') {\n // It's less than ideal for us to handle files that don't exist like this but because\n // `file` is a string it might actually be the full text contents of the file and not\n // actually a path.\n //\n // We also can't really regex to see if `file` *looks*` like a path because one should be\n // able to pass in a relative `owlbert.png` (instead of `./owlbert.png`) and though that\n // doesn't *look* like a path, it is one that should still work.\n return resolve(undefined)\n }\n\n return reject(err)\n }\n\n const fileMetadata = await datauri(resolvedFile)\n const payloadFilename = encodeURIComponent(path.basename(resolvedFile))\n\n return resolve({\n paramName,\n base64: fileMetadata?.content?.replace(';base64', `;name=${payloadFilename};base64`),\n filename: payloadFilename,\n buffer: fileMetadata.buffer,\n })\n })\n })\n } else if (file instanceof stream.Readable) {\n return getStreamAsBuffer(file).then(buffer => {\n const filePath = file.path as string\n const parser = new DatauriParser()\n const base64 = parser.format(filePath, buffer).content\n const payloadFilename = encodeURIComponent(path.basename(filePath))\n\n return {\n paramName,\n base64: base64?.replace(';base64', `;name=${payloadFilename};base64`),\n filename: payloadFilename,\n buffer,\n }\n })\n }\n\n return Promise.reject(\n new TypeError(\n paramName\n ? `The data supplied for the \\`${paramName}\\` request body parameter is not a file handler that we support.`\n : 'The data supplied for the request body payload is not a file handler that we support.',\n ),\n )\n}\n\n/**\n * With potentially supplied body and/or metadata we need to run through them against a given API\n * operation to see what's what and prepare any available parameters to be used in an API request\n * with `@readme/oas-to-har`.\n *\n */\nexport default async function prepareParams(\n operation: Operation,\n body?: unknown,\n metadata?: Record<string, unknown>,\n) {\n let metadataIntersected = false\n const digestedParameters = digestParameters(operation.getParameters())\n const jsonSchema = operation.getParametersAsJSONSchema()\n\n /**\n * It might be common for somebody to run `sdk.findPetsByStatus({ status: 'available' }, {})`, in\n * which case we want to filter out the second (metadata) parameter and treat the first parameter\n * as the metadata instead. If we don't do this, their supplied `status` metadata will be treated\n * as a body parameter, and because there's no `status` body parameter, and no supplied metadata\n * (because it's an empty object), the request won't send a payload.\n *\n * @see {@link https://github.com/readmeio/api/issues/449}\n */\n // eslint-disable-next-line no-param-reassign\n metadata = removeUndefinedObjects(metadata)\n\n if (!jsonSchema && (body !== undefined || metadata !== undefined)) {\n let throwNoParamsError = true\n\n // If this operation doesn't have any parameters for us to transform to JSON Schema but they've\n // sent us either an `Accept` or `Authorization` header (or both) we should let them do that.\n // We should, however, only do this check for the `body` parameter as if they've sent this\n // request both `body` and `metadata` we can reject it outright as the operation won't have any\n // body data.\n if (body !== undefined) {\n if (typeof body === 'object' && body !== null && !Array.isArray(body)) {\n if (Object.keys(body).length <= 2) {\n const bodyParams = caseless(body)\n\n if (specialHeaders.some(header => bodyParams.has(header))) {\n throwNoParamsError = false\n }\n }\n }\n }\n\n if (throwNoParamsError) {\n throw new Error(\n \"You supplied metadata and/or body data for this operation but it doesn't have any documented parameters or request payloads. If you think this is an error please contact support for the API you're using.\",\n )\n }\n }\n\n const jsonSchemaDefaults = jsonSchema ? getJSONSchemaDefaults(jsonSchema) : {}\n\n const params: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n body?: any\n cookie?: Record<string, boolean | number | string>\n files?: Record<string, Buffer>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n formData?: any\n header?: Record<string, boolean | number | string>\n path?: Record<string, boolean | number | string>\n query?: Record<string, boolean | number | string>\n server?: {\n selected: number\n variables: Record<string, number | string>\n }\n } = jsonSchemaDefaults\n\n // If a body argument was supplied we need to do a bit of work to see if it's actually a body\n // argument or metadata because the library lets you supply either a body, metadata, or body with\n // metadata.\n if (typeof body !== 'undefined') {\n if (Array.isArray(body) || isPrimitive(body)) {\n // If the body param is an array or a primitive then we know it's absolutely a body because\n // metadata can only ever be undefined or an object.\n params.body = merge(params.body, body)\n } else if (typeof metadata === 'undefined') {\n // No metadata was explicitly provided so we need to analyze the body to determine if it's a\n // body or should be actually be treated as metadata.\n const headerParams = caseless({})\n Object.entries(digestedParameters).forEach(([paramName, param]) => {\n // Headers are sent case-insensitive so we need to make sure that we're properly\n // matching them when detecting what our incoming payload looks like.\n if (param.in === 'header') {\n headerParams.set(paramName, '')\n }\n })\n\n // `Accept` and `Authorization` headers can't be defined as normal parameters but we should\n // always allow the user to supply them if they wish.\n specialHeaders.forEach(header => {\n if (!headerParams.has(header)) {\n headerParams.set(header, '')\n }\n })\n\n const intersection = Object.keys(body as NonNullable<unknown>).filter(value => {\n if (Object.keys(digestedParameters).includes(value)) {\n return true\n } else if (headerParams.has(value)) {\n return true\n }\n\n return false\n }).length\n\n // If more than 25% of the body intersects with the parameters that we've got on hand, then\n // we should treat it as a metadata object and organize into parameters.\n if (intersection && intersection / Object.keys(body as NonNullable<unknown>).length > 0.25) {\n /* eslint-disable no-param-reassign */\n metadataIntersected = true\n metadata = merge(params.body, body) as Record<string, unknown>\n body = undefined\n /* eslint-enable no-param-reassign */\n } else {\n // For all other cases, we should just treat the supplied body as a body.\n params.body = merge(params.body, body)\n }\n } else {\n // Body and metadata were both supplied.\n params.body = merge(params.body, body)\n }\n }\n\n if (!operation.hasRequestBody()) {\n // If this operation doesn't have any documented request body then we shouldn't be sending\n // anything.\n delete params.body\n } else {\n if (!('body' in params)) params.body = {}\n\n // We need to retrieve the request body for this operation to search for any `binary` format\n // data that the user wants to send so we know what we need to prepare for the final API\n // request.\n const payloadJsonSchema = jsonSchema.find(js => js.type === 'body')\n if (payloadJsonSchema) {\n if (!params.files) params.files = {}\n\n const conversions = []\n\n // @todo add support for `type: array`, `oneOf` and `anyOf`\n if (payloadJsonSchema.schema?.properties) {\n Object.entries(payloadJsonSchema.schema?.properties)\n .filter(([, schema]: [string, SchemaObject]) => schema?.format === 'binary')\n .filter(([prop]) => Object.keys(params.body).includes(prop))\n .forEach(([prop]) => {\n conversions.push(processFile(prop, params.body[prop]))\n })\n } else if (payloadJsonSchema.schema?.type === 'string') {\n if (payloadJsonSchema.schema?.format === 'binary') {\n conversions.push(processFile(undefined, params.body))\n }\n }\n\n await Promise.all(conversions)\n .then(fileMetadata => fileMetadata.filter(Boolean))\n .then(fm => {\n fm.forEach(fileMetadata => {\n if (!fileMetadata) {\n // If we don't have any metadata here it's because the file we have is likely\n // the full string content of the file so since we don't have any filenames to\n // work with we shouldn't do any additional handling to the `body` or `files`\n // parameters.\n return\n }\n\n if (fileMetadata.paramName) {\n params.body[fileMetadata.paramName] = fileMetadata.base64\n } else {\n params.body = fileMetadata.base64\n }\n\n if (fileMetadata.buffer && params?.files) {\n params.files[fileMetadata.filename] = fileMetadata.buffer\n }\n })\n })\n }\n }\n\n // Form data should be placed within `formData` instead of `body` for it to properly get picked\n // up by `fetch-har`.\n if (operation.isFormUrlEncoded()) {\n params.formData = merge(params.formData, params.body)\n delete params.body\n }\n\n // Only spend time trying to organize metadata into parameters if we were able to digest\n // parameters out of the operation schema. If we couldn't digest anything, but metadata was\n // supplied then we wouldn't know how to send it in the request!\n if (typeof metadata !== 'undefined') {\n if (!('cookie' in params)) params.cookie = {}\n if (!('header' in params)) params.header = {}\n if (!('path' in params)) params.path = {}\n if (!('query' in params)) params.query = {}\n\n Object.entries(digestedParameters).forEach(([paramName, param]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let value: any\n let metadataHeaderParam\n if (typeof metadata === 'object' && !isEmpty(metadata)) {\n if (paramName in metadata) {\n value = metadata[paramName]\n metadataHeaderParam = paramName\n } else if (param.in === 'header') {\n // Headers are sent case-insensitive so we need to make sure that we're properly\n // matching them when detecting what our incoming payload looks like.\n metadataHeaderParam =\n Object.keys(metadata).find(k => k.toLowerCase() === paramName.toLowerCase()) || ''\n value = metadata[metadataHeaderParam]\n }\n }\n\n if (value === undefined) {\n return\n }\n\n /* eslint-disable no-param-reassign */\n switch (param.in) {\n case 'path':\n ;(params.path as NonNullable<typeof params.path>)[paramName] = value\n if (metadata?.[paramName]) delete metadata[paramName]\n break\n case 'query':\n ;(params.query as NonNullable<typeof params.query>)[paramName] = value\n if (metadata?.[paramName]) delete metadata[paramName]\n break\n case 'header':\n ;(params.header as NonNullable<typeof params.header>)[paramName.toLowerCase()] = value\n if (metadataHeaderParam && metadata?.[metadataHeaderParam])\n delete metadata[metadataHeaderParam]\n break\n case 'cookie':\n ;(params.cookie as NonNullable<typeof params.cookie>)[paramName] = value\n if (metadata?.[paramName]) delete metadata[paramName]\n break\n default: // no-op\n }\n /* eslint-enable no-param-reassign */\n\n // Because a user might have sent just a metadata object, we want to make sure that we filter\n // out anything that they sent that is a parameter from also being sent as part of a form\n // data payload for `x-www-form-urlencoded` requests.\n if (metadataIntersected && operation.isFormUrlEncoded()) {\n if (paramName in params.formData) {\n delete params.formData[paramName]\n }\n }\n })\n\n // If there's any leftover metadata that hasn't been moved into form data for this request we\n // need to move it or else it'll get tossed.\n if (!isEmpty(metadata)) {\n if (typeof metadata === 'object') {\n // If the user supplied an `accept` or `authorization` header themselves we should allow it\n // through. Normally these headers are automatically handled by `@readme/oas-to-har` but in\n // the event that maybe the user wants to return XML for an API that normally returns JSON\n // or specify a custom auth header (maybe we can't handle their auth case right) this is the\n // only way with this library that they can do that.\n specialHeaders.forEach(headerName => {\n const headerParam = Object.keys(metadata || {}).find(m => m.toLowerCase() === headerName)\n if (headerParam) {\n // this if-statement below is a typeguard\n if (typeof metadata === 'object') {\n // this if-statement below is a typeguard\n if (typeof params.header === 'object') {\n params.header[headerName] = metadata[headerParam] as string\n }\n // eslint-disable-next-line no-param-reassign\n delete metadata[headerParam]\n }\n }\n })\n }\n\n if (operation.isFormUrlEncoded()) {\n params.formData = merge(params.formData, metadata)\n } else {\n // Any other remaining unused metadata will be unused because we don't know where to place\n // it in the request.\n }\n }\n }\n\n ;(['body', 'cookie', 'files', 'formData', 'header', 'path', 'query'] as const).forEach(\n (type: keyof typeof params) => {\n if (type in params && isEmpty(params[type])) {\n delete params[type]\n }\n },\n )\n\n return params\n}\n","import {on} from 'node:events';\nimport {finished} from 'node:stream/promises';\nimport {nodeImports} from './stream.js';\n\nObject.assign(nodeImports, {on, finished});\n\nexport {\n\tdefault,\n\tgetStreamAsArray,\n\tgetStreamAsArrayBuffer,\n\tgetStreamAsBuffer,\n\tMaxBufferError,\n} from './exports.js';\n","export function isStream(stream, {checkOpen = true} = {}) {\n\treturn stream !== null\n\t\t&& typeof stream === 'object'\n\t\t&& (stream.writable || stream.readable || !checkOpen || (stream.writable === undefined && stream.readable === undefined))\n\t\t&& typeof stream.pipe === 'function';\n}\n\nexport function isWritableStream(stream, {checkOpen = true} = {}) {\n\treturn isStream(stream, {checkOpen})\n\t\t&& (stream.writable || !checkOpen)\n\t\t&& typeof stream.write === 'function'\n\t\t&& typeof stream.end === 'function'\n\t\t&& typeof stream.writable === 'boolean'\n\t\t&& typeof stream.writableObjectMode === 'boolean'\n\t\t&& typeof stream.destroy === 'function'\n\t\t&& typeof stream.destroyed === 'boolean';\n}\n\nexport function isReadableStream(stream, {checkOpen = true} = {}) {\n\treturn isStream(stream, {checkOpen})\n\t\t&& (stream.readable || !checkOpen)\n\t\t&& typeof stream.read === 'function'\n\t\t&& typeof stream.readable === 'boolean'\n\t\t&& typeof stream.readableObjectMode === 'boolean'\n\t\t&& typeof stream.destroy === 'function'\n\t\t&& typeof stream.destroyed === 'boolean';\n}\n\nexport function isDuplexStream(stream, options) {\n\treturn isWritableStream(stream, options)\n\t\t&& isReadableStream(stream, options);\n}\n\nexport function isTransformStream(stream, options) {\n\treturn isDuplexStream(stream, options)\n\t\t&& typeof stream._transform === 'function';\n}\n","const a = Object.getPrototypeOf(\n Object.getPrototypeOf(\n /* istanbul ignore next */\n async function* () {\n }\n ).prototype\n);\nclass c {\n #t;\n #n;\n #r = !1;\n #e = void 0;\n constructor(e, t) {\n this.#t = e, this.#n = t;\n }\n next() {\n const e = () => this.#s();\n return this.#e = this.#e ? this.#e.then(e, e) : e(), this.#e;\n }\n return(e) {\n const t = () => this.#i(e);\n return this.#e ? this.#e.then(t, t) : t();\n }\n async #s() {\n if (this.#r)\n return {\n done: !0,\n value: void 0\n };\n let e;\n try {\n e = await this.#t.read();\n } catch (t) {\n throw this.#e = void 0, this.#r = !0, this.#t.releaseLock(), t;\n }\n return e.done && (this.#e = void 0, this.#r = !0, this.#t.releaseLock()), e;\n }\n async #i(e) {\n if (this.#r)\n return {\n done: !0,\n value: e\n };\n if (this.#r = !0, !this.#n) {\n const t = this.#t.cancel(e);\n return this.#t.releaseLock(), await t, {\n done: !0,\n value: e\n };\n }\n return this.#t.releaseLock(), {\n done: !0,\n value: e\n };\n }\n}\nconst n = Symbol();\nfunction i() {\n return this[n].next();\n}\nObject.defineProperty(i, \"name\", { value: \"next\" });\nfunction o(r) {\n return this[n].return(r);\n}\nObject.defineProperty(o, \"name\", { value: \"return\" });\nconst u = Object.create(a, {\n next: {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: i\n },\n return: {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: o\n }\n});\nfunction h({ preventCancel: r = !1 } = {}) {\n const e = this.getReader(), t = new c(\n e,\n r\n ), s = Object.create(u);\n return s[n] = t, s;\n}\nexport {\n h as asyncIterator\n};\n","import {isReadableStream} from 'is-stream';\nimport {asyncIterator} from '@sec-ant/readable-stream/ponyfill';\n\nexport const getAsyncIterable = stream => {\n\tif (isReadableStream(stream, {checkOpen: false}) && nodeImports.on !== undefined) {\n\t\treturn getStreamIterable(stream);\n\t}\n\n\tif (typeof stream?.[Symbol.asyncIterator] === 'function') {\n\t\treturn stream;\n\t}\n\n\t// `ReadableStream[Symbol.asyncIterator]` support is missing in multiple browsers, so we ponyfill it\n\tif (toString.call(stream) === '[object ReadableStream]') {\n\t\treturn asyncIterator.call(stream);\n\t}\n\n\tthrow new TypeError('The first argument must be a Readable, a ReadableStream, or an async iterable.');\n};\n\nconst {toString} = Object.prototype;\n\n// The default iterable for Node.js streams does not allow for multiple readers at once, so we re-implement it\nconst getStreamIterable = async function * (stream) {\n\tconst controller = new AbortController();\n\tconst state = {};\n\thandleStreamEnd(stream, controller, state);\n\n\ttry {\n\t\tfor await (const [chunk] of nodeImports.on(stream, 'data', {signal: controller.signal})) {\n\t\t\tyield chunk;\n\t\t}\n\t} catch (error) {\n\t\t// Stream failure, for example due to `stream.destroy(error)`\n\t\tif (state.error !== undefined) {\n\t\t\tthrow state.error;\n\t\t// `error` event directly emitted on stream\n\t\t} else if (!controller.signal.aborted) {\n\t\t\tthrow error;\n\t\t// Otherwise, stream completed successfully\n\t\t}\n\t\t// The `finally` block also runs when the caller throws, for example due to the `maxBuffer` option\n\t} finally {\n\t\tstream.destroy();\n\t}\n};\n\nconst handleStreamEnd = async (stream, controller, state) => {\n\ttry {\n\t\tawait nodeImports.finished(stream, {\n\t\t\tcleanup: true,\n\t\t\treadable: true,\n\t\t\twritable: false,\n\t\t\terror: false,\n\t\t});\n\t} catch (error) {\n\t\tstate.error = error;\n\t} finally {\n\t\tcontroller.abort();\n\t}\n};\n\n// Loaded by the Node entrypoint, but not by the browser one.\n// This prevents using dynamic imports.\nexport const nodeImports = {};\n","import {getAsyncIterable} from './stream.js';\n\nexport const getStreamContents = async (stream, {init, convertChunk, getSize, truncateChunk, addChunk, getFinalChunk, finalize}, {maxBuffer = Number.POSITIVE_INFINITY} = {}) => {\n\tconst asyncIterable = getAsyncIterable(stream);\n\n\tconst state = init();\n\tstate.length = 0;\n\n\ttry {\n\t\tfor await (const chunk of asyncIterable) {\n\t\t\tconst chunkType = getChunkType(chunk);\n\t\t\tconst convertedChunk = convertChunk[chunkType](chunk, state);\n\t\t\tappendChunk({\n\t\t\t\tconvertedChunk,\n\t\t\t\tstate,\n\t\t\t\tgetSize,\n\t\t\t\ttruncateChunk,\n\t\t\t\taddChunk,\n\t\t\t\tmaxBuffer,\n\t\t\t});\n\t\t}\n\n\t\tappendFinalChunk({\n\t\t\tstate,\n\t\t\tconvertChunk,\n\t\t\tgetSize,\n\t\t\ttruncateChunk,\n\t\t\taddChunk,\n\t\t\tgetFinalChunk,\n\t\t\tmaxBuffer,\n\t\t});\n\t\treturn finalize(state);\n\t} catch (error) {\n\t\tconst normalizedError = typeof error === 'object' && error !== null ? error : new Error(error);\n\t\tnormalizedError.bufferedData = finalize(state);\n\t\tthrow normalizedError;\n\t}\n};\n\nconst appendFinalChunk = ({state, getSize, truncateChunk, addChunk, getFinalChunk, maxBuffer}) => {\n\tconst convertedChunk = getFinalChunk(state);\n\tif (convertedChunk !== undefined) {\n\t\tappendChunk({\n\t\t\tconvertedChunk,\n\t\t\tstate,\n\t\t\tgetSize,\n\t\t\ttruncateChunk,\n\t\t\taddChunk,\n\t\t\tmaxBuffer,\n\t\t});\n\t}\n};\n\nconst appendChunk = ({convertedChunk, state, getSize, truncateChunk, addChunk, maxBuffer}) => {\n\tconst chunkSize = getSize(convertedChunk);\n\tconst newLength = state.length + chunkSize;\n\n\tif (newLength <= maxBuffer) {\n\t\taddNewChunk(convertedChunk, state, addChunk, newLength);\n\t\treturn;\n\t}\n\n\tconst truncatedChunk = truncateChunk(convertedChunk, maxBuffer - state.length);\n\n\tif (truncatedChunk !== undefined) {\n\t\taddNewChunk(truncatedChunk, state, addChunk, maxBuffer);\n\t}\n\n\tthrow new MaxBufferError();\n};\n\nconst addNewChunk = (convertedChunk, state, addChunk, newLength) => {\n\tstate.contents = addChunk(convertedChunk, state, newLength);\n\tstate.length = newLength;\n};\n\nconst getChunkType = chunk => {\n\tconst typeOfChunk = typeof chunk;\n\n\tif (typeOfChunk === 'string') {\n\t\treturn 'string';\n\t}\n\n\tif (typeOfChunk !== 'object' || chunk === null) {\n\t\treturn 'others';\n\t}\n\n\tif (globalThis.Buffer?.isBuffer(chunk)) {\n\t\treturn 'buffer';\n\t}\n\n\tconst prototypeName = objectToString.call(chunk);\n\n\tif (prototypeName === '[object ArrayBuffer]') {\n\t\treturn 'arrayBuffer';\n\t}\n\n\tif (prototypeName === '[object DataView]') {\n\t\treturn 'dataView';\n\t}\n\n\tif (\n\t\tNumber.isInteger(chunk.byteLength)\n\t\t&& Number.isInteger(chunk.byteOffset)\n\t\t&& objectToString.call(chunk.buffer) === '[object ArrayBuffer]'\n\t) {\n\t\treturn 'typedArray';\n\t}\n\n\treturn 'others';\n};\n\nconst {toString: objectToString} = Object.prototype;\n\nexport class MaxBufferError extends Error {\n\tname = 'MaxBufferError';\n\n\tconstructor() {\n\t\tsuper('maxBuffer exceeded');\n\t}\n}\n","export const identity = value => value;\n\nexport const noop = () => undefined;\n\nexport const getContentsProperty = ({contents}) => contents;\n\nexport const throwObjectStream = chunk => {\n\tthrow new Error(`Streams in object mode are not supported: ${String(chunk)}`);\n};\n\nexport const getLengthProperty = convertedChunk => convertedChunk.length;\n","import {getStreamContents} from './contents.js';\nimport {noop, throwObjectStream, getLengthProperty} from './utils.js';\n\nexport async function getStreamAsArrayBuffer(stream, options) {\n\treturn getStreamContents(stream, arrayBufferMethods, options);\n}\n\nconst initArrayBuffer = () => ({contents: new ArrayBuffer(0)});\n\nconst useTextEncoder = chunk => textEncoder.encode(chunk);\nconst textEncoder = new TextEncoder();\n\nconst useUint8Array = chunk => new Uint8Array(chunk);\n\nconst useUint8ArrayWithOffset = chunk => new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength);\n\nconst truncateArrayBufferChunk = (convertedChunk, chunkSize) => convertedChunk.slice(0, chunkSize);\n\n// `contents` is an increasingly growing `Uint8Array`.\nconst addArrayBufferChunk = (convertedChunk, {contents, length: previousLength}, length) => {\n\tconst newContents = hasArrayBufferResize() ? resizeArrayBuffer(contents, length) : resizeArrayBufferSlow(contents, length);\n\tnew Uint8Array(newContents).set(convertedChunk, previousLength);\n\treturn newContents;\n};\n\n// Without `ArrayBuffer.resize()`, `contents` size is always a power of 2.\n// This means its last bytes are zeroes (not stream data), which need to be\n// trimmed at the end with `ArrayBuffer.slice()`.\nconst resizeArrayBufferSlow = (contents, length) => {\n\tif (length <= contents.byteLength) {\n\t\treturn contents;\n\t}\n\n\tconst arrayBuffer = new ArrayBuffer(getNewContentsLength(length));\n\tnew Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);\n\treturn arrayBuffer;\n};\n\n// With `ArrayBuffer.resize()`, `contents` size matches exactly the size of\n// the stream data. It does not include extraneous zeroes to trim at the end.\n// The underlying `ArrayBuffer` does allocate a number of bytes that is a power\n// of 2, but those bytes are only visible after calling `ArrayBuffer.resize()`.\nconst resizeArrayBuffer = (contents, length) => {\n\tif (length <= contents.maxByteLength) {\n\t\tcontents.resize(length);\n\t\treturn contents;\n\t}\n\n\tconst arrayBuffer = new ArrayBuffer(length, {maxByteLength: getNewContentsLength(length)});\n\tnew Uint8Array(arrayBuffer).set(new Uint8Array(contents), 0);\n\treturn arrayBuffer;\n};\n\n// Retrieve the closest `length` that is both >= and a power of 2\nconst getNewContentsLength = length => SCALE_FACTOR ** Math.ceil(Math.log(length) / Math.log(SCALE_FACTOR));\n\nconst SCALE_FACTOR = 2;\n\nconst finalizeArrayBuffer = ({contents, length}) => hasArrayBufferResize() ? contents : contents.slice(0, length);\n\n// `ArrayBuffer.slice()` is slow. When `ArrayBuffer.resize()` is available\n// (Node >=20.0.0, Safari >=16.4 and Chrome), we can use it instead.\n// eslint-disable-next-line no-warning-comments\n// TODO: remove after dropping support for Node 20.\n// eslint-disable-next-line no-warning-comments\n// TODO: use `ArrayBuffer.transferToFixedLength()` instead once it is available\nconst hasArrayBufferResize = () => 'resize' in ArrayBuffer.prototype;\n\nconst arrayBufferMethods = {\n\tinit: initArrayBuffer,\n\tconvertChunk: {\n\t\tstring: useTextEncoder,\n\t\tbuffer: useUint8Array,\n\t\tarrayBuffer: useUint8Array,\n\t\tdataView: useUint8ArrayWithOffset,\n\t\ttypedArray: useUint8ArrayWithOffset,\n\t\tothers: throwObjectStream,\n\t},\n\tgetSize: getLengthProperty,\n\ttruncateChunk: truncateArrayBufferChunk,\n\taddChunk: addArrayBufferChunk,\n\tgetFinalChunk: noop,\n\tfinalize: finalizeArrayBuffer,\n};\n","import {getStreamAsArrayBuffer} from './array-buffer.js';\n\nexport async function getStreamAsBuffer(stream, options) {\n\tif (!('Buffer' in globalThis)) {\n\t\tthrow new Error('getStreamAsBuffer() is only supported in Node.js');\n\t}\n\n\ttry {\n\t\treturn arrayBufferToNodeBuffer(await getStreamAsArrayBuffer(stream, options));\n\t} catch (error) {\n\t\tif (error.bufferedData !== undefined) {\n\t\t\terror.bufferedData = arrayBufferToNodeBuffer(error.bufferedData);\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nconst arrayBufferToNodeBuffer = arrayBuffer => globalThis.Buffer.from(arrayBuffer);\n","import type Oas from 'oas'\n\nfunction stripTrailingSlash(url: string) {\n if (url[url.length - 1] === '/') {\n return url.slice(0, -1)\n }\n\n return url\n}\n\n/**\n * With an SDK server config and an instance of OAS we should extract and prepare the server and\n * any server variables to be supplied to `@readme/oas-to-har`.\n *\n */\nexport default function prepareServer(\n spec: Oas,\n url: string,\n variables: Record<string, number | string> = {},\n) {\n let serverIdx: number | undefined\n const sanitizedUrl = stripTrailingSlash(url)\n ;(spec.api.servers || []).forEach((server, i) => {\n if (server.url === sanitizedUrl) {\n serverIdx = i\n }\n })\n\n // If we were able to find the passed in server in the OAS servers, we should use that! If we\n // couldn't and server variables were passed in we should try our best to handle that, otherwise\n // we should ignore the passed in server and use whever the default from the OAS is.\n if (serverIdx !== undefined) {\n return {\n selected: serverIdx,\n variables,\n }\n } else if (Object.keys(variables).length) {\n // @todo we should run `oas.replaceUrl(url)` and pass that unto `@readme/oas-to-har`\n } else {\n const server = spec.splitVariables(url)\n if (server) {\n return {\n selected: server.selected,\n variables: server.variables,\n }\n }\n\n // @todo we should pass `url` directly into `@readme/oas-to-har` as the base URL\n }\n\n return false\n}\n"],"mappings":";;;;;AAGA,OAAOA,cAAc;AAYN,SAAf,sBAA8CC,aAA4B;AACxE,SAAOA,YACJC,IAAI,CAAC,EAACC,MAAMC,aAAaC,QAAQC,WAAU,MAAC;AAC3C,UAAMC,WAAoC,CAAC;AAC3CC,aACEF,YACA,CACED,QACAI,SACAC,aACAC,eACAC,gBACAC,cACAC,kBAAAA;AAEA,UAAI,CAACL,QAAQM,WAAW,cAAA,GAAiB;AACvC;MACF;AAEA,UACEC,MAAMC,QAAQJ,cAAcK,QAAAA,KAC5BL,cAAcK,SAASC,SAASC,OAAON,aAAAA,CAAAA,GACvC;AACA,YAAIT,OAAOF,SAAS,YAAYW,eAAe;AAC7CP,mBAASO,aAAAA,IAAiB,CAAC;QAC7B;AAEA,YAAIO,cAAcd;AAClB,YAAII,eAAe;AAEjBA,wBACGW,QAAQ,iBAAiB,EAAA,EACzBC,MAAM,GAAA,EACNC,QAAQ,CAACC,cAAAA;AACR,gBAAIA,cAAc,IAAI;AACpB;YACF;AAEAJ,0BAAeA,cAAcI,SAAAA,KAA0C,CAAC;UAC1E,CAAA;QACJ;AAEA,YAAIpB,OAAOqB,YAAYC,QAAW;AAChC,cAAIb,kBAAkBa,QAAW;AAC/BN,wBAAYP,aAAAA,IAAiBT,OAAOqB;UACtC;QACF;MACF;IACF,CAAA;AAGF,QAAI,CAACE,OAAOC,KAAKtB,QAAAA,EAAUuB,QAAQ;AACjC,aAAO,CAAC;IACV;AAEA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AAIU,QAAQ;AACV,aAAO;QACLG,UAAUH,OAAOG;QACjBT,WAAWM,OAAON;MACpB;IACF;EAGF;AAEA,SAAO;AACT;AApCwBa;","names":["traverse","jsonSchemas","map","type","payloadType","schema","jsonSchema","defaults","traverse","pointer","_rootSchema","parentPointer","_parentKeyword","parentSchema","indexProperty","startsWith","Array","isArray","required","includes","String","destination","replace","split","forEach","subSchema","default","undefined","Object","keys","length","reduce","prev","next","assign","getJSONSchemaDefaults","matchesMimeType","response","contentType","headers","get","isJSON","matchesMimeType","json","wildcard","responseBody","clone","text","data","JSON","parse","e","status","res","parseResponse","authKey","operation","length","preparedAuth","security","getSecurity","every","s","Object","keys","Error","usableSecurity","map","filter","Boolean","usableSecuritySchemes","reduce","prev","next","concat","preparedSecurity","prepareSecurity","schemes","Basic","includes","_key","scheme","shift","user","String","pass","usableScheme","entries","ps","type","in","prepareAuth","stream","caseless","on","finished","isStream","stream","checkOpen","writable","readable","undefined","pipe","isReadableStream","stream","checkOpen","isStream","readable","read","readableObjectMode","destroy","destroyed","a","Object","getPrototypeOf","prototype","c","constructor","e","t","next","then","return","done","value","read","releaseLock","cancel","n","Symbol","i","defineProperty","o","r","u","create","enumerable","configurable","writable","h","preventCancel","getReader","s","getAsyncIterable","stream","isReadableStream","checkOpen","nodeImports","on","undefined","getStreamIterable","Symbol","asyncIterator","toString","call","TypeError","Object","prototype","controller","AbortController","state","handleStreamEnd","chunk","signal","error","aborted","destroy","finished","cleanup","readable","writable","abort","getStreamContents","stream","init","convertChunk","getSize","truncateChunk","addChunk","getFinalChunk","finalize","maxBuffer","Number","POSITIVE_INFINITY","asyncIterable","getAsyncIterable","state","length","chunk","chunkType","getChunkType","convertedChunk","appendChunk","appendFinalChunk","error","normalizedError","Error","bufferedData","undefined","chunkSize","newLength","addNewChunk","truncatedChunk","MaxBufferError","contents","typeOfChunk","globalThis","Buffer","isBuffer","prototypeName","objectToString","call","isInteger","byteLength","byteOffset","buffer","toString","Object","prototype","name","constructor","noop","undefined","throwObjectStream","chunk","Error","String","getLengthProperty","convertedChunk","length","getStreamAsArrayBuffer","stream","options","getStreamContents","arrayBufferMethods","initArrayBuffer","contents","ArrayBuffer","useTextEncoder","chunk","textEncoder","encode","TextEncoder","useUint8Array","Uint8Array","useUint8ArrayWithOffset","buffer","byteOffset","byteLength","truncateArrayBufferChunk","convertedChunk","chunkSize","slice","addArrayBufferChunk","length","previousLength","newContents","hasArrayBufferResize","resizeArrayBuffer","resizeArrayBufferSlow","set","arrayBuffer","getNewContentsLength","maxByteLength","resize","SCALE_FACTOR","Math","ceil","log","finalizeArrayBuffer","prototype","init","convertChunk","string","dataView","typedArray","others","throwObjectStream","getSize","getLengthProperty","truncateChunk","addChunk","getFinalChunk","noop","finalize","getStreamAsBuffer","stream","options","globalThis","Error","arrayBufferToNodeBuffer","getStreamAsArrayBuffer","error","bufferedData","undefined","arrayBuffer","Buffer","from","Object","assign","nodeImports","on","finished","lodashMerge","removeUndefinedObjects","specialHeaders","digestParameters","parameters","reduce","prev","param","Error","name","Object","assign","isEmpty","obj","Array","includes","constructor","entries","length","isObject","thing","stream","Readable","isArray","isPrimitive","merge","src","target","lodashMerge","processFile","paramName","file","fs","path","default","DatauriParser","datauri","resolvedFile","resolve","Promise","reject","stat","err","code","undefined","fileMetadata","payloadFilename","encodeURIComponent","basename","base64","content","replace","filename","buffer","getStreamAsBuffer","then","filePath","parser","format","TypeError","operation","body","metadata","metadataIntersected","digestedParameters","getParameters","jsonSchema","getParametersAsJSONSchema","removeUndefinedObjects","throwNoParamsError","keys","bodyParams","caseless","some","header","has","jsonSchemaDefaults","getJSONSchemaDefaults","params","headerParams","forEach","in","set","intersection","filter","value","hasRequestBody","payloadJsonSchema","find","js","type","files","conversions","schema","properties","prop","push","all","Boolean","fm","isFormUrlEncoded","formData","cookie","query","metadataHeaderParam","k","toLowerCase","headerName","headerParam","m","prepareParams","stripTrailingSlash","url","length","slice","spec","variables","serverIdx","sanitizedUrl","api","servers","forEach","server","i","undefined","selected","Object","keys","splitVariables","prepareServer"]}
@@ -0,0 +1,13 @@
1
+ declare class FetchError<Status = number, Data = unknown> extends Error {
2
+ /** HTTP Status */
3
+ status: Status;
4
+ /** The content of the response. */
5
+ data: Data;
6
+ /** The Headers of the response. */
7
+ headers: Headers;
8
+ /** The raw `Response` object. */
9
+ res: Response;
10
+ constructor(status: Status, data: Data, headers: Headers, res: Response);
11
+ }
12
+
13
+ export { FetchError as default };
@@ -0,0 +1,8 @@
1
+ import {
2
+ FetchError
3
+ } from "../chunk-7NM3WYHE.js";
4
+ import "../chunk-7QVYU63E.js";
5
+ export {
6
+ FetchError as default
7
+ };
8
+ //# sourceMappingURL=fetchError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,47 @@
1
+ import * as har_format from 'har-format';
2
+ import { ConfigOptions } from './types.js';
3
+ import { DataForHAR, AuthForHAR } from '@readme/oas-to-har/lib/types';
4
+ import { Operation } from 'oas/operation';
5
+ import { OASDocument, HttpMethods } from 'oas/types';
6
+ import Oas from 'oas';
7
+ import 'json-schema-to-ts';
8
+
9
+ declare class APICore {
10
+ spec: Oas;
11
+ private auth;
12
+ private server;
13
+ private config;
14
+ private userAgent;
15
+ constructor(definition?: OASDocument | Record<string, unknown>, userAgent?: string);
16
+ setSpec(spec: Oas): void;
17
+ setConfig(config: ConfigOptions): this;
18
+ setUserAgent(userAgent: string): this;
19
+ setAuth(...values: number[] | string[]): this;
20
+ setServer(url: string, variables?: Record<string, number | string>): this;
21
+ fetch<HTTPStatus extends number = number>(path: string, method: HttpMethods, body?: unknown, metadata?: Record<string, unknown>): Promise<{
22
+ data: any;
23
+ status: HTTPStatus;
24
+ headers: Headers;
25
+ res: Response;
26
+ }>;
27
+ /**
28
+ * Retrieve a HAR for a given HTTP request.
29
+ *
30
+ * @internal
31
+ */
32
+ getHARForRequest(operation: Operation, data: DataForHAR, auth: AuthForHAR): {
33
+ log: {
34
+ entries: {
35
+ request: har_format.Request;
36
+ }[];
37
+ };
38
+ };
39
+ fetchOperation<HTTPStatus extends number = number>(operation: Operation, body?: unknown, metadata?: Record<string, unknown>): Promise<{
40
+ data: any;
41
+ status: HTTPStatus;
42
+ headers: Headers;
43
+ res: Response;
44
+ }>;
45
+ }
46
+
47
+ export { APICore as default };
package/dist/index.js ADDED
@@ -0,0 +1,105 @@
1
+ import {
2
+ FetchError
3
+ } from "./chunk-7NM3WYHE.js";
4
+ import {
5
+ parseResponse,
6
+ prepareAuth,
7
+ prepareParams,
8
+ prepareServer
9
+ } from "./chunk-HKKQOEV3.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-7QVYU63E.js";
13
+
14
+ // src/index.ts
15
+ import oasToHar from "@readme/oas-to-har";
16
+ import fetchHar from "fetch-har";
17
+ import Oas from "oas";
18
+ var APICore = class {
19
+ static {
20
+ __name(this, "APICore");
21
+ }
22
+ spec;
23
+ auth = [];
24
+ server = false;
25
+ config = {};
26
+ userAgent;
27
+ constructor(definition, userAgent) {
28
+ if (definition) this.spec = Oas.init(definition);
29
+ if (userAgent) this.userAgent = userAgent;
30
+ }
31
+ setSpec(spec) {
32
+ this.spec = spec;
33
+ }
34
+ setConfig(config) {
35
+ this.config = config;
36
+ return this;
37
+ }
38
+ setUserAgent(userAgent) {
39
+ this.userAgent = userAgent;
40
+ return this;
41
+ }
42
+ setAuth(...values) {
43
+ this.auth = values;
44
+ return this;
45
+ }
46
+ setServer(url, variables = {}) {
47
+ this.server = {
48
+ url,
49
+ variables
50
+ };
51
+ return this;
52
+ }
53
+ async fetch(path, method, body, metadata) {
54
+ const operation = this.spec.operation(path, method);
55
+ return this.fetchOperation(operation, body, metadata);
56
+ }
57
+ /**
58
+ * Retrieve a HAR for a given HTTP request.
59
+ *
60
+ * @internal
61
+ */
62
+ getHARForRequest(operation, data, auth) {
63
+ return oasToHar(this.spec, operation, data, auth);
64
+ }
65
+ async fetchOperation(operation, body, metadata) {
66
+ return prepareParams(operation, body, metadata).then((params) => {
67
+ const data = {
68
+ ...params
69
+ };
70
+ if (this.server) {
71
+ const preparedServer = prepareServer(this.spec, this.server.url, this.server.variables);
72
+ if (preparedServer) {
73
+ data.server = preparedServer;
74
+ }
75
+ }
76
+ const har = this.getHARForRequest(operation, data, prepareAuth(this.auth, operation));
77
+ let timeoutSignal;
78
+ const init = {};
79
+ if (this.config.timeout) {
80
+ const controller = new AbortController();
81
+ timeoutSignal = setTimeout(() => controller.abort(), this.config.timeout);
82
+ init.signal = controller.signal;
83
+ }
84
+ return fetchHar(har, {
85
+ files: data.files || {},
86
+ init,
87
+ userAgent: this.userAgent
88
+ }).then(async (res) => {
89
+ const parsed = await parseResponse(res);
90
+ if (res.status >= 400 && res.status <= 599) {
91
+ throw new FetchError(parsed.status, parsed.data, parsed.headers, parsed.res);
92
+ }
93
+ return parsed;
94
+ }).finally(() => {
95
+ if (this.config.timeout) {
96
+ clearTimeout(timeoutSignal);
97
+ }
98
+ });
99
+ });
100
+ }
101
+ };
102
+ export {
103
+ APICore as default
104
+ };
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {ConfigOptions} from './types.js'\nimport type {AuthForHAR, DataForHAR} from '@readme/oas-to-har/lib/types'\nimport type {Har} from 'har-format'\nimport type {Operation} from 'oas/operation'\nimport type {HttpMethods, OASDocument} from 'oas/types'\n\nimport oasToHar from '@readme/oas-to-har'\nimport fetchHar from 'fetch-har'\nimport Oas from 'oas'\n\nimport FetchError from './errors/fetchError.js'\nimport {parseResponse, prepareAuth, prepareParams, prepareServer} from './lib/index.js'\n\nexport default class APICore {\n spec!: Oas\n\n private auth: (number | string)[] = []\n\n private server:\n | false\n | {\n url: string\n variables?: Record<string, number | string>\n } = false\n\n private config: ConfigOptions = {}\n\n private userAgent!: string\n\n constructor(definition?: OASDocument | Record<string, unknown>, userAgent?: string) {\n if (definition) this.spec = Oas.init(definition)\n if (userAgent) this.userAgent = userAgent\n }\n\n setSpec(spec: Oas) {\n this.spec = spec\n }\n\n setConfig(config: ConfigOptions) {\n this.config = config\n return this\n }\n\n setUserAgent(userAgent: string) {\n this.userAgent = userAgent\n return this\n }\n\n setAuth(...values: number[] | string[]) {\n this.auth = values\n return this\n }\n\n setServer(url: string, variables: Record<string, number | string> = {}) {\n this.server = {url, variables}\n return this\n }\n\n async fetch<HTTPStatus extends number = number>(\n path: string,\n method: HttpMethods,\n body?: unknown,\n metadata?: Record<string, unknown>,\n ) {\n const operation = this.spec.operation(path, method)\n\n return this.fetchOperation<HTTPStatus>(operation, body, metadata)\n }\n\n /**\n * Retrieve a HAR for a given HTTP request.\n *\n * @internal\n */\n getHARForRequest(operation: Operation, data: DataForHAR, auth: AuthForHAR) {\n return oasToHar(this.spec, operation, data, auth)\n }\n\n async fetchOperation<HTTPStatus extends number = number>(\n operation: Operation,\n body?: unknown,\n metadata?: Record<string, unknown>,\n ) {\n // eslint-disable-next-line @typescript-eslint/promise-function-async\n return prepareParams(operation, body, metadata).then(params => {\n const data = {...params}\n\n // If `sdk.server()` has been issued data then we need to do some extra work to figure out\n // how to use that supplied server, and also handle any server variables that were sent\n // alongside it.\n if (this.server) {\n const preparedServer = prepareServer(this.spec, this.server.url, this.server.variables)\n if (preparedServer) {\n data.server = preparedServer\n }\n }\n\n const har = this.getHARForRequest(operation, data, prepareAuth(this.auth, operation))\n\n let timeoutSignal: NodeJS.Timeout\n const init: RequestInit = {}\n if (this.config.timeout) {\n const controller = new AbortController()\n timeoutSignal = setTimeout(() => controller.abort(), this.config.timeout)\n init.signal = controller.signal\n }\n\n return fetchHar(har as Har, {\n files: data.files || {},\n init,\n userAgent: this.userAgent,\n })\n .then(async (res: Response) => {\n const parsed = await parseResponse<HTTPStatus>(res)\n\n if (res.status >= 400 && res.status <= 599) {\n throw new FetchError<typeof parsed.status, typeof parsed.data>(\n parsed.status,\n parsed.data,\n parsed.headers,\n parsed.res,\n )\n }\n\n return parsed\n })\n .finally(() => {\n if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AAS;AACtF,YAAIc,gBAAgB;AAClBL,eAAKvB,SAAS4B;QAChB;MACF;AAEA,YAAME,MAAM,KAAKR,iBAAiBF,WAAWG,MAAMQ,YAAY,KAAKhC,MAAMqB,SAAAA,CAAAA;AAE1E,UAAIY;AACJ,YAAM1B,OAAoB,CAAC;AAC3B,UAAI,KAAKL,OAAOgC,SAAS;AACvB,cAAMC,aAAa,IAAIC,gBAAAA;AACvBH,wBAAgBI,WAAW,MAAMF,WAAWG,MAAK,GAAI,KAAKpC,OAAOgC,OAAO;AACxE3B,aAAKgC,SAASJ,WAAWI;MAC3B;AAEA,aAAOC,SAAST,KAAY;QAC1BU,OAAOjB,KAAKiB,SAAS,CAAC;QACtBlC;QACAJ,WAAW,KAAKA;MAClB,CAAA,EACGwB,KAAK,OAAOe,QAAAA;AACX,cAAMC,SAAS,MAAMC,cAA0BF,GAAAA;AAE/C,YAAIA,IAAIG,UAAU,OAAOH,IAAIG,UAAU,KAAK;AAC1C,gBAAM,IAAIC,WACRH,OAAOE,QACPF,OAAOnB,MACPmB,OAAOI,SACPJ,OAAOD,GAAG;QAEd;AAEA,eAAOC;MACT,CAAA,EACCK,QAAQ,MAAA;AACP,YAAI,KAAK9C,OAAOgC,SAAS;AACvBe,uBAAahB,aAAAA;QACf;MACF,CAAA;IACJ,CAAA;EACF;AACF;","names":["oasToHar","fetchHar","Oas","APICore","spec","auth","server","config","userAgent","constructor","definition","Oas","init","setSpec","setConfig","setUserAgent","setAuth","values","setServer","url","variables","fetch","path","method","body","metadata","operation","fetchOperation","getHARForRequest","data","oasToHar","prepareParams","then","params","preparedServer","prepareServer","har","prepareAuth","timeoutSignal","timeout","controller","AbortController","setTimeout","abort","signal","fetchHar","files","res","parsed","parseResponse","status","FetchError","headers","finally","clearTimeout"]}
@@ -0,0 +1,59 @@
1
+ import { SchemaWrapper } from 'oas/operation/get-parameters-as-json-schema';
2
+ import { AuthForHAR } from '@readme/oas-to-har/lib/types';
3
+ import { Operation } from 'oas/operation';
4
+ import Oas from 'oas';
5
+
6
+ /**
7
+ * Run through a JSON Schema object and compose up an object containing default data for any schema
8
+ * property that is required and also has a defined default.
9
+ *
10
+ * Code partially adapted from the `json-schema-default` package but modified to only return
11
+ * defaults of required properties.
12
+ *
13
+ * @todo This is a good candidate to be moved into a core `oas` library method.
14
+ * @see {@link https://github.com/mdornseif/json-schema-default}
15
+ */
16
+ declare function getJSONSchemaDefaults(jsonSchemas: SchemaWrapper[]): {
17
+ [x: string]: Record<string, unknown>;
18
+ };
19
+
20
+ declare function parseResponse<HTTPStatus extends number = number>(response: Response): Promise<{
21
+ data: any;
22
+ status: HTTPStatus;
23
+ headers: Headers;
24
+ res: Response;
25
+ }>;
26
+
27
+ declare function prepareAuth(authKey: (number | string)[], operation: Operation): AuthForHAR;
28
+
29
+ /**
30
+ * With potentially supplied body and/or metadata we need to run through them against a given API
31
+ * operation to see what's what and prepare any available parameters to be used in an API request
32
+ * with `@readme/oas-to-har`.
33
+ *
34
+ */
35
+ declare function prepareParams(operation: Operation, body?: unknown, metadata?: Record<string, unknown>): Promise<{
36
+ body?: any;
37
+ cookie?: Record<string, boolean | number | string>;
38
+ files?: Record<string, Buffer>;
39
+ formData?: any;
40
+ header?: Record<string, boolean | number | string>;
41
+ path?: Record<string, boolean | number | string>;
42
+ query?: Record<string, boolean | number | string>;
43
+ server?: {
44
+ selected: number;
45
+ variables: Record<string, number | string>;
46
+ };
47
+ }>;
48
+
49
+ /**
50
+ * With an SDK server config and an instance of OAS we should extract and prepare the server and
51
+ * any server variables to be supplied to `@readme/oas-to-har`.
52
+ *
53
+ */
54
+ declare function prepareServer(spec: Oas, url: string, variables?: Record<string, number | string>): false | {
55
+ selected: number;
56
+ variables: Record<string, string | number>;
57
+ };
58
+
59
+ export { getJSONSchemaDefaults, parseResponse, prepareAuth, prepareParams, prepareServer };
@@ -0,0 +1,16 @@
1
+ import {
2
+ getJSONSchemaDefaults,
3
+ parseResponse,
4
+ prepareAuth,
5
+ prepareParams,
6
+ prepareServer
7
+ } from "../chunk-HKKQOEV3.js";
8
+ import "../chunk-7QVYU63E.js";
9
+ export {
10
+ getJSONSchemaDefaults,
11
+ parseResponse,
12
+ prepareAuth,
13
+ prepareParams,
14
+ prepareServer
15
+ };
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,22 @@
1
+ export { FromSchema } from 'json-schema-to-ts';
2
+
3
+ interface ConfigOptions {
4
+ /**
5
+ * Override the default `fetch` request timeout of 30 seconds. This number should be represented
6
+ * in milliseconds.
7
+ */
8
+ timeout?: number;
9
+ }
10
+ /**
11
+ * @see {@link https://stackoverflow.com/a/39495173}
12
+ */
13
+ type Enumerate<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : Enumerate<N, [...Acc, Acc['length']]>;
14
+ type HTTPMethodRange<F extends number, T extends number> = Exclude<Enumerate<T>, Enumerate<F>>;
15
+ interface FetchResponse<HTTPStatus, Data> {
16
+ data: Data;
17
+ headers: Headers;
18
+ res: Response;
19
+ status: HTTPStatus;
20
+ }
21
+
22
+ export type { ConfigOptions, FetchResponse, HTTPMethodRange };
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,25 @@
1
+ import {defineConfig} from '@bfra.me/eslint-config'
2
+
3
+ export default defineConfig({
4
+ name: '@bfra.me/api-core',
5
+ ignores: ['test-utils'],
6
+ rules: {
7
+ 'no-restricted-imports': [
8
+ 'error',
9
+ {
10
+ name: 'fs/promises',
11
+ message: "Please use `fs` instead as some client frameworks don't polyfill `fs/promises`.",
12
+ },
13
+ ],
14
+
15
+ '@typescript-eslint/explicit-function-return-type': 'off',
16
+ },
17
+ typescript: {
18
+ parserOptions: {
19
+ project: ['./tsconfig.json', './tsconfig.eslint.json'],
20
+ projectService: false,
21
+ },
22
+ tsconfigPath: './tsconfig.json',
23
+ },
24
+ vitest: true,
25
+ })
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@bfra.me/api-core",
3
+ "version": "0.1.0",
4
+ "description": "The magic behind `api` 🧙",
5
+ "homepage": "https://api.readme.dev",
6
+ "bugs": {
7
+ "url": "https://github.com/bfra-me/works/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/bfra-me/works.git",
12
+ "directory": "packages/api-core"
13
+ },
14
+ "license": "MIT",
15
+ "author": "Jon Ursenbach <jon@readme.io>",
16
+ "sideEffects": false,
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "import": "./dist/index.js"
21
+ },
22
+ "./errors/fetchError": {
23
+ "import": "./dist/errors/fetchError.js"
24
+ },
25
+ "./lib": {
26
+ "import": "./dist/lib/index.js"
27
+ },
28
+ "./types": {
29
+ "import": "./dist/types.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "main": "dist/index.js",
34
+ "module": "dist/index.js",
35
+ "types": "dist/index.d.ts",
36
+ "dependencies": {
37
+ "@readme/oas-to-har": "^23.2.0",
38
+ "caseless": "^0.12.0",
39
+ "datauri": "^4.1.0",
40
+ "fetch-har": "^11.0.1",
41
+ "json-schema-to-ts": "^3.0.0",
42
+ "json-schema-traverse": "^1.0.0",
43
+ "lodash.merge": "^4.6.2",
44
+ "oas": "^24.0.0",
45
+ "remove-undefined-objects": "^5.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@readme/oas-examples": "^5.12.0",
49
+ "@types/caseless": "0.12.5",
50
+ "@types/lodash.merge": "^4.6.9",
51
+ "@vitest/coverage-v8": "2.1.3",
52
+ "fetch-mock": "^11.1.3",
53
+ "get-stream": "^9.0.1",
54
+ "typescript": "5.6.2",
55
+ "vitest": "2.1.3",
56
+ "@api/test-utils": "0.1.0"
57
+ },
58
+ "engines": {
59
+ "node": ">=18"
60
+ },
61
+ "scripts": {
62
+ "attw": "attw --pack --format table-flipped",
63
+ "build": "tsup",
64
+ "lint:types": "tsc --noEmit",
65
+ "test": "vitest --coverage"
66
+ }
67
+ }
@@ -0,0 +1,29 @@
1
+ export default class FetchError<Status = number, Data = unknown> extends Error {
2
+ /** HTTP Status */
3
+ status: Status
4
+
5
+ /** The content of the response. */
6
+ data: Data
7
+
8
+ /** The Headers of the response. */
9
+ headers: Headers
10
+
11
+ /** The raw `Response` object. */
12
+ res: Response
13
+
14
+ constructor(status: Status, data: Data, headers: Headers, res: Response) {
15
+ super(res.statusText)
16
+
17
+ this.name = 'FetchError'
18
+ this.status = status
19
+ this.data = data
20
+ this.headers = headers
21
+ this.res = res
22
+
23
+ // We could fix this by updating our target to ES2015 but because we support exporting to CJS
24
+ // we can't.
25
+ //
26
+ // https://www.dannyguo.com/blog/how-to-fix-instanceof-not-working-for-custom-errors-in-typescript/
27
+ Object.setPrototypeOf(this, FetchError.prototype)
28
+ }
29
+ }