@marktmentor/api 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (523) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +29 -2
  3. package/dist/BaseClient.d.ts +54 -0
  4. package/dist/BaseClient.js +43 -0
  5. package/dist/Client.d.ts +41 -0
  6. package/dist/Client.js +60 -0
  7. package/dist/api/errors/BadRequestError.d.ts +5 -0
  8. package/dist/api/errors/BadRequestError.js +17 -0
  9. package/dist/api/errors/ConflictError.d.ts +5 -0
  10. package/dist/api/errors/ConflictError.js +17 -0
  11. package/dist/api/errors/ForbiddenError.d.ts +5 -0
  12. package/dist/api/errors/ForbiddenError.js +17 -0
  13. package/dist/api/errors/NotFoundError.d.ts +7 -0
  14. package/dist/api/errors/NotFoundError.js +17 -0
  15. package/dist/api/errors/PaymentRequiredError.d.ts +7 -0
  16. package/dist/api/errors/PaymentRequiredError.js +17 -0
  17. package/dist/api/errors/ServiceUnavailableError.d.ts +5 -0
  18. package/dist/api/errors/ServiceUnavailableError.js +17 -0
  19. package/dist/api/errors/TooManyRequestsError.d.ts +5 -0
  20. package/dist/api/errors/TooManyRequestsError.js +17 -0
  21. package/dist/api/errors/UnauthorizedError.d.ts +5 -0
  22. package/dist/api/errors/UnauthorizedError.js +17 -0
  23. package/dist/api/errors/index.d.ts +8 -0
  24. package/dist/api/errors/index.js +8 -0
  25. package/dist/api/index.d.ts +3 -0
  26. package/dist/api/index.js +3 -0
  27. package/dist/api/resources/index.d.ts +13 -0
  28. package/dist/api/resources/index.js +13 -0
  29. package/dist/api/resources/niches/client/Client.d.ts +188 -0
  30. package/dist/api/resources/niches/client/Client.js +655 -0
  31. package/dist/api/resources/niches/client/index.d.ts +1 -0
  32. package/dist/api/resources/niches/client/index.js +1 -0
  33. package/dist/api/resources/niches/client/requests/GetNichesRequest.d.ts +17 -0
  34. package/dist/api/resources/niches/client/requests/GetNichesRequest.js +2 -0
  35. package/dist/api/resources/niches/client/requests/ListNichesRequest.d.ts +34 -0
  36. package/dist/api/resources/niches/client/requests/ListNichesRequest.js +2 -0
  37. package/dist/api/resources/niches/client/requests/ProductDistributionsNichesRequest.d.ts +13 -0
  38. package/dist/api/resources/niches/client/requests/ProductDistributionsNichesRequest.js +2 -0
  39. package/dist/api/resources/niches/client/requests/ProductsNichesRequest.d.ts +48 -0
  40. package/dist/api/resources/niches/client/requests/ProductsNichesRequest.js +2 -0
  41. package/dist/api/resources/niches/client/requests/ReviewHistoryNichesRequest.d.ts +23 -0
  42. package/dist/api/resources/niches/client/requests/ReviewHistoryNichesRequest.js +2 -0
  43. package/dist/api/resources/niches/client/requests/ReviewSummaryNichesRequest.d.ts +5 -0
  44. package/dist/api/resources/niches/client/requests/ReviewSummaryNichesRequest.js +2 -0
  45. package/dist/api/resources/niches/client/requests/ReviewsNichesRequest.d.ts +33 -0
  46. package/dist/api/resources/niches/client/requests/ReviewsNichesRequest.js +2 -0
  47. package/dist/api/resources/niches/client/requests/index.d.ts +7 -0
  48. package/dist/api/resources/niches/client/requests/index.js +1 -0
  49. package/dist/api/resources/niches/exports.d.ts +2 -0
  50. package/dist/api/resources/niches/exports.js +3 -0
  51. package/dist/api/resources/niches/index.d.ts +2 -0
  52. package/dist/api/resources/niches/index.js +2 -0
  53. package/dist/api/resources/niches/types/GetNichesRequestMarket.d.ts +6 -0
  54. package/dist/api/resources/niches/types/GetNichesRequestMarket.js +6 -0
  55. package/dist/api/resources/niches/types/GetNichesRequestPeriod.d.ts +6 -0
  56. package/dist/api/resources/niches/types/GetNichesRequestPeriod.js +6 -0
  57. package/dist/api/resources/niches/types/ListNichesRequestMarket.d.ts +6 -0
  58. package/dist/api/resources/niches/types/ListNichesRequestMarket.js +6 -0
  59. package/dist/api/resources/niches/types/ListNichesRequestPeriod.d.ts +6 -0
  60. package/dist/api/resources/niches/types/ListNichesRequestPeriod.js +6 -0
  61. package/dist/api/resources/niches/types/ListNichesRequestSort.d.ts +9 -0
  62. package/dist/api/resources/niches/types/ListNichesRequestSort.js +9 -0
  63. package/dist/api/resources/niches/types/ProductDistributionsNichesRequestPeriod.d.ts +6 -0
  64. package/dist/api/resources/niches/types/ProductDistributionsNichesRequestPeriod.js +6 -0
  65. package/dist/api/resources/niches/types/ProductsNichesRequestMarket.d.ts +6 -0
  66. package/dist/api/resources/niches/types/ProductsNichesRequestMarket.js +6 -0
  67. package/dist/api/resources/niches/types/ProductsNichesRequestPeriod.d.ts +6 -0
  68. package/dist/api/resources/niches/types/ProductsNichesRequestPeriod.js +6 -0
  69. package/dist/api/resources/niches/types/ProductsNichesRequestSort.d.ts +9 -0
  70. package/dist/api/resources/niches/types/ProductsNichesRequestSort.js +9 -0
  71. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestInterval.d.ts +5 -0
  72. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestInterval.js +5 -0
  73. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestMarket.d.ts +4 -0
  74. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestMarket.js +4 -0
  75. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestPeriod.d.ts +7 -0
  76. package/dist/api/resources/niches/types/ReviewHistoryNichesRequestPeriod.js +7 -0
  77. package/dist/api/resources/niches/types/ReviewsNichesRequestMarket.d.ts +4 -0
  78. package/dist/api/resources/niches/types/ReviewsNichesRequestMarket.js +4 -0
  79. package/dist/api/resources/niches/types/ReviewsNichesRequestPeriod.d.ts +7 -0
  80. package/dist/api/resources/niches/types/ReviewsNichesRequestPeriod.js +7 -0
  81. package/dist/api/resources/niches/types/ReviewsNichesRequestSort.d.ts +7 -0
  82. package/dist/api/resources/niches/types/ReviewsNichesRequestSort.js +7 -0
  83. package/dist/api/resources/niches/types/index.d.ts +15 -0
  84. package/dist/api/resources/niches/types/index.js +15 -0
  85. package/dist/api/resources/organization/client/Client.d.ts +32 -0
  86. package/dist/api/resources/organization/client/Client.js +73 -0
  87. package/dist/api/resources/organization/client/index.d.ts +1 -0
  88. package/dist/api/resources/organization/client/index.js +1 -0
  89. package/dist/api/resources/organization/exports.d.ts +2 -0
  90. package/dist/api/resources/organization/exports.js +3 -0
  91. package/dist/api/resources/organization/index.d.ts +1 -0
  92. package/dist/api/resources/organization/index.js +1 -0
  93. package/dist/api/resources/products/client/Client.d.ts +269 -0
  94. package/dist/api/resources/products/client/Client.js +927 -0
  95. package/dist/api/resources/products/client/index.d.ts +1 -0
  96. package/dist/api/resources/products/client/index.js +1 -0
  97. package/dist/api/resources/products/client/requests/CategoryRankingsProductsRequest.d.ts +23 -0
  98. package/dist/api/resources/products/client/requests/CategoryRankingsProductsRequest.js +2 -0
  99. package/dist/api/resources/products/client/requests/GetProductsRequest.d.ts +15 -0
  100. package/dist/api/resources/products/client/requests/GetProductsRequest.js +2 -0
  101. package/dist/api/resources/products/client/requests/KeywordRankingsProductsRequest.d.ts +27 -0
  102. package/dist/api/resources/products/client/requests/KeywordRankingsProductsRequest.js +2 -0
  103. package/dist/api/resources/products/client/requests/KeywordsProductsRequest.d.ts +19 -0
  104. package/dist/api/resources/products/client/requests/KeywordsProductsRequest.js +2 -0
  105. package/dist/api/resources/products/client/requests/ListProductsRequest.d.ts +50 -0
  106. package/dist/api/resources/products/client/requests/ListProductsRequest.js +2 -0
  107. package/dist/api/resources/products/client/requests/ReviewSummaryProductsRequest.d.ts +8 -0
  108. package/dist/api/resources/products/client/requests/ReviewSummaryProductsRequest.js +2 -0
  109. package/dist/api/resources/products/client/requests/ReviewsProductsRequest.d.ts +35 -0
  110. package/dist/api/resources/products/client/requests/ReviewsProductsRequest.js +2 -0
  111. package/dist/api/resources/products/client/requests/SalesHistoryProductsRequest.d.ts +23 -0
  112. package/dist/api/resources/products/client/requests/SalesHistoryProductsRequest.js +2 -0
  113. package/dist/api/resources/products/client/requests/SellersProductsRequest.d.ts +16 -0
  114. package/dist/api/resources/products/client/requests/SellersProductsRequest.js +2 -0
  115. package/dist/api/resources/products/client/requests/VisibilityHistoryProductsRequest.d.ts +23 -0
  116. package/dist/api/resources/products/client/requests/VisibilityHistoryProductsRequest.js +2 -0
  117. package/dist/api/resources/products/client/requests/index.d.ts +10 -0
  118. package/dist/api/resources/products/client/requests/index.js +1 -0
  119. package/dist/api/resources/products/exports.d.ts +2 -0
  120. package/dist/api/resources/products/exports.js +3 -0
  121. package/dist/api/resources/products/index.d.ts +2 -0
  122. package/dist/api/resources/products/index.js +2 -0
  123. package/dist/api/resources/products/types/CategoryRankingsProductsRequestInterval.d.ts +5 -0
  124. package/dist/api/resources/products/types/CategoryRankingsProductsRequestInterval.js +5 -0
  125. package/dist/api/resources/products/types/CategoryRankingsProductsRequestMarket.d.ts +6 -0
  126. package/dist/api/resources/products/types/CategoryRankingsProductsRequestMarket.js +6 -0
  127. package/dist/api/resources/products/types/CategoryRankingsProductsRequestPeriod.d.ts +7 -0
  128. package/dist/api/resources/products/types/CategoryRankingsProductsRequestPeriod.js +7 -0
  129. package/dist/api/resources/products/types/GetProductsRequestMarket.d.ts +6 -0
  130. package/dist/api/resources/products/types/GetProductsRequestMarket.js +6 -0
  131. package/dist/api/resources/products/types/GetProductsRequestPeriod.d.ts +6 -0
  132. package/dist/api/resources/products/types/GetProductsRequestPeriod.js +6 -0
  133. package/dist/api/resources/products/types/KeywordRankingsProductsRequestInterval.d.ts +5 -0
  134. package/dist/api/resources/products/types/KeywordRankingsProductsRequestInterval.js +5 -0
  135. package/dist/api/resources/products/types/KeywordRankingsProductsRequestMarket.d.ts +6 -0
  136. package/dist/api/resources/products/types/KeywordRankingsProductsRequestMarket.js +6 -0
  137. package/dist/api/resources/products/types/KeywordRankingsProductsRequestPeriod.d.ts +7 -0
  138. package/dist/api/resources/products/types/KeywordRankingsProductsRequestPeriod.js +7 -0
  139. package/dist/api/resources/products/types/KeywordsProductsRequestMarket.d.ts +6 -0
  140. package/dist/api/resources/products/types/KeywordsProductsRequestMarket.js +6 -0
  141. package/dist/api/resources/products/types/KeywordsProductsRequestPeriod.d.ts +6 -0
  142. package/dist/api/resources/products/types/KeywordsProductsRequestPeriod.js +6 -0
  143. package/dist/api/resources/products/types/ListProductsRequestMarket.d.ts +6 -0
  144. package/dist/api/resources/products/types/ListProductsRequestMarket.js +6 -0
  145. package/dist/api/resources/products/types/ListProductsRequestPeriod.d.ts +6 -0
  146. package/dist/api/resources/products/types/ListProductsRequestPeriod.js +6 -0
  147. package/dist/api/resources/products/types/ListProductsRequestSort.d.ts +9 -0
  148. package/dist/api/resources/products/types/ListProductsRequestSort.js +9 -0
  149. package/dist/api/resources/products/types/ReviewsProductsRequestMarket.d.ts +4 -0
  150. package/dist/api/resources/products/types/ReviewsProductsRequestMarket.js +4 -0
  151. package/dist/api/resources/products/types/ReviewsProductsRequestPeriod.d.ts +7 -0
  152. package/dist/api/resources/products/types/ReviewsProductsRequestPeriod.js +7 -0
  153. package/dist/api/resources/products/types/ReviewsProductsRequestSort.d.ts +7 -0
  154. package/dist/api/resources/products/types/ReviewsProductsRequestSort.js +7 -0
  155. package/dist/api/resources/products/types/SalesHistoryProductsRequestInterval.d.ts +5 -0
  156. package/dist/api/resources/products/types/SalesHistoryProductsRequestInterval.js +5 -0
  157. package/dist/api/resources/products/types/SalesHistoryProductsRequestMarket.d.ts +6 -0
  158. package/dist/api/resources/products/types/SalesHistoryProductsRequestMarket.js +6 -0
  159. package/dist/api/resources/products/types/SalesHistoryProductsRequestPeriod.d.ts +7 -0
  160. package/dist/api/resources/products/types/SalesHistoryProductsRequestPeriod.js +7 -0
  161. package/dist/api/resources/products/types/SellersProductsRequestMarket.d.ts +6 -0
  162. package/dist/api/resources/products/types/SellersProductsRequestMarket.js +6 -0
  163. package/dist/api/resources/products/types/SellersProductsRequestPeriod.d.ts +7 -0
  164. package/dist/api/resources/products/types/SellersProductsRequestPeriod.js +7 -0
  165. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestInterval.d.ts +5 -0
  166. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestInterval.js +5 -0
  167. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestMarket.d.ts +6 -0
  168. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestMarket.js +6 -0
  169. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestPeriod.d.ts +7 -0
  170. package/dist/api/resources/products/types/VisibilityHistoryProductsRequestPeriod.js +7 -0
  171. package/dist/api/resources/products/types/index.d.ts +24 -0
  172. package/dist/api/resources/products/types/index.js +24 -0
  173. package/dist/api/resources/reference/client/Client.d.ts +84 -0
  174. package/dist/api/resources/reference/client/Client.js +254 -0
  175. package/dist/api/resources/reference/client/index.d.ts +1 -0
  176. package/dist/api/resources/reference/client/index.js +1 -0
  177. package/dist/api/resources/reference/client/requests/BrandsReferenceRequest.d.ts +12 -0
  178. package/dist/api/resources/reference/client/requests/BrandsReferenceRequest.js +2 -0
  179. package/dist/api/resources/reference/client/requests/CategoriesReferenceRequest.d.ts +18 -0
  180. package/dist/api/resources/reference/client/requests/CategoriesReferenceRequest.js +2 -0
  181. package/dist/api/resources/reference/client/requests/CategoryReferenceRequest.d.ts +5 -0
  182. package/dist/api/resources/reference/client/requests/CategoryReferenceRequest.js +2 -0
  183. package/dist/api/resources/reference/client/requests/index.d.ts +3 -0
  184. package/dist/api/resources/reference/client/requests/index.js +1 -0
  185. package/dist/api/resources/reference/exports.d.ts +2 -0
  186. package/dist/api/resources/reference/exports.js +3 -0
  187. package/dist/api/resources/reference/index.d.ts +1 -0
  188. package/dist/api/resources/reference/index.js +1 -0
  189. package/dist/api/resources/store/client/Client.d.ts +82 -0
  190. package/dist/api/resources/store/client/Client.js +291 -0
  191. package/dist/api/resources/store/client/index.d.ts +1 -0
  192. package/dist/api/resources/store/client/index.js +1 -0
  193. package/dist/api/resources/store/client/requests/InventoryStoreRequest.d.ts +23 -0
  194. package/dist/api/resources/store/client/requests/InventoryStoreRequest.js +2 -0
  195. package/dist/api/resources/store/client/requests/OverviewStoreRequest.d.ts +13 -0
  196. package/dist/api/resources/store/client/requests/OverviewStoreRequest.js +2 -0
  197. package/dist/api/resources/store/client/requests/ProductsStoreRequest.d.ts +49 -0
  198. package/dist/api/resources/store/client/requests/ProductsStoreRequest.js +2 -0
  199. package/dist/api/resources/store/client/requests/index.d.ts +3 -0
  200. package/dist/api/resources/store/client/requests/index.js +1 -0
  201. package/dist/api/resources/store/exports.d.ts +2 -0
  202. package/dist/api/resources/store/exports.js +3 -0
  203. package/dist/api/resources/store/index.d.ts +2 -0
  204. package/dist/api/resources/store/index.js +2 -0
  205. package/dist/api/resources/store/types/InventoryStoreRequestStockState.d.ts +6 -0
  206. package/dist/api/resources/store/types/InventoryStoreRequestStockState.js +6 -0
  207. package/dist/api/resources/store/types/OverviewStoreRequestCountry.d.ts +6 -0
  208. package/dist/api/resources/store/types/OverviewStoreRequestCountry.js +6 -0
  209. package/dist/api/resources/store/types/ProductsStoreRequestCountry.d.ts +5 -0
  210. package/dist/api/resources/store/types/ProductsStoreRequestCountry.js +5 -0
  211. package/dist/api/resources/store/types/ProductsStoreRequestSort.d.ts +11 -0
  212. package/dist/api/resources/store/types/ProductsStoreRequestSort.js +11 -0
  213. package/dist/api/resources/store/types/index.d.ts +4 -0
  214. package/dist/api/resources/store/types/index.js +4 -0
  215. package/dist/api/resources/usage/client/Client.d.ts +32 -0
  216. package/dist/api/resources/usage/client/Client.js +73 -0
  217. package/dist/api/resources/usage/client/index.d.ts +1 -0
  218. package/dist/api/resources/usage/client/index.js +1 -0
  219. package/dist/api/resources/usage/exports.d.ts +2 -0
  220. package/dist/api/resources/usage/exports.js +3 -0
  221. package/dist/api/resources/usage/index.d.ts +1 -0
  222. package/dist/api/resources/usage/index.js +1 -0
  223. package/dist/api/types/AllowanceError.d.ts +26 -0
  224. package/dist/api/types/AllowanceError.js +16 -0
  225. package/dist/api/types/Brand.d.ts +4 -0
  226. package/dist/api/types/Brand.js +2 -0
  227. package/dist/api/types/BrandListResponse.d.ts +6 -0
  228. package/dist/api/types/BrandListResponse.js +2 -0
  229. package/dist/api/types/BundleUsage.d.ts +15 -0
  230. package/dist/api/types/BundleUsage.js +2 -0
  231. package/dist/api/types/Category.d.ts +14 -0
  232. package/dist/api/types/Category.js +2 -0
  233. package/dist/api/types/CategoryItem.d.ts +4 -0
  234. package/dist/api/types/CategoryItem.js +2 -0
  235. package/dist/api/types/CategoryListResponse.d.ts +5 -0
  236. package/dist/api/types/CategoryListResponse.js +2 -0
  237. package/dist/api/types/CategoryPathItem.d.ts +4 -0
  238. package/dist/api/types/CategoryPathItem.js +2 -0
  239. package/dist/api/types/CategoryRanking.d.ts +5 -0
  240. package/dist/api/types/CategoryRanking.js +2 -0
  241. package/dist/api/types/CategoryRankingsResponse.d.ts +7 -0
  242. package/dist/api/types/CategoryRankingsResponse.js +2 -0
  243. package/dist/api/types/CategoryResponse.d.ts +4 -0
  244. package/dist/api/types/CategoryResponse.js +2 -0
  245. package/dist/api/types/CommissionBracket.d.ts +8 -0
  246. package/dist/api/types/CommissionBracket.js +2 -0
  247. package/dist/api/types/CurrentPeriod.d.ts +8 -0
  248. package/dist/api/types/CurrentPeriod.js +2 -0
  249. package/dist/api/types/Dimensions.d.ts +8 -0
  250. package/dist/api/types/Dimensions.js +2 -0
  251. package/dist/api/types/DistributionBucket.d.ts +5 -0
  252. package/dist/api/types/DistributionBucket.js +2 -0
  253. package/dist/api/types/DistributionData.d.ts +7 -0
  254. package/dist/api/types/DistributionData.js +2 -0
  255. package/dist/api/types/FreeTierUsage.d.ts +12 -0
  256. package/dist/api/types/FreeTierUsage.js +2 -0
  257. package/dist/api/types/KeywordItem.d.ts +6 -0
  258. package/dist/api/types/KeywordItem.js +2 -0
  259. package/dist/api/types/KeywordMarkets.d.ts +5 -0
  260. package/dist/api/types/KeywordMarkets.js +2 -0
  261. package/dist/api/types/KeywordMetrics.d.ts +4 -0
  262. package/dist/api/types/KeywordMetrics.js +2 -0
  263. package/dist/api/types/KeywordRanking.d.ts +7 -0
  264. package/dist/api/types/KeywordRanking.js +2 -0
  265. package/dist/api/types/KeywordRankingsResponse.d.ts +7 -0
  266. package/dist/api/types/KeywordRankingsResponse.js +2 -0
  267. package/dist/api/types/KeywordResponse.d.ts +7 -0
  268. package/dist/api/types/KeywordResponse.js +2 -0
  269. package/dist/api/types/ListingChanges.d.ts +5 -0
  270. package/dist/api/types/ListingChanges.js +2 -0
  271. package/dist/api/types/NicheDetail.d.ts +12 -0
  272. package/dist/api/types/NicheDetail.js +2 -0
  273. package/dist/api/types/NicheDetailResponse.d.ts +6 -0
  274. package/dist/api/types/NicheDetailResponse.js +2 -0
  275. package/dist/api/types/NicheDistributionsResponse.d.ts +5 -0
  276. package/dist/api/types/NicheDistributionsResponse.js +2 -0
  277. package/dist/api/types/NicheHistoryData.d.ts +4 -0
  278. package/dist/api/types/NicheHistoryData.js +2 -0
  279. package/dist/api/types/NicheHistoryResponse.d.ts +7 -0
  280. package/dist/api/types/NicheHistoryResponse.js +2 -0
  281. package/dist/api/types/NicheItem.d.ts +11 -0
  282. package/dist/api/types/NicheItem.js +2 -0
  283. package/dist/api/types/NicheListResponse.d.ts +7 -0
  284. package/dist/api/types/NicheListResponse.js +2 -0
  285. package/dist/api/types/NicheMarkets.d.ts +5 -0
  286. package/dist/api/types/NicheMarkets.js +2 -0
  287. package/dist/api/types/NicheMetrics.d.ts +5 -0
  288. package/dist/api/types/NicheMetrics.js +2 -0
  289. package/dist/api/types/NichePeriod.d.ts +5 -0
  290. package/dist/api/types/NichePeriod.js +2 -0
  291. package/dist/api/types/OauthScope.d.ts +9 -0
  292. package/dist/api/types/OauthScope.js +9 -0
  293. package/dist/api/types/Organization.d.ts +4 -0
  294. package/dist/api/types/Organization.js +2 -0
  295. package/dist/api/types/Pagination.d.ts +6 -0
  296. package/dist/api/types/Pagination.js +2 -0
  297. package/dist/api/types/Period.d.ts +5 -0
  298. package/dist/api/types/Period.js +2 -0
  299. package/dist/api/types/PeriodRatings.d.ts +7 -0
  300. package/dist/api/types/PeriodRatings.js +2 -0
  301. package/dist/api/types/PeriodReviews.d.ts +9 -0
  302. package/dist/api/types/PeriodReviews.js +2 -0
  303. package/dist/api/types/ProductDetail.d.ts +29 -0
  304. package/dist/api/types/ProductDetail.js +2 -0
  305. package/dist/api/types/ProductDetailResponse.d.ts +24 -0
  306. package/dist/api/types/ProductDetailResponse.js +14 -0
  307. package/dist/api/types/ProductDistributions.d.ts +6 -0
  308. package/dist/api/types/ProductDistributions.js +2 -0
  309. package/dist/api/types/ProductItem.d.ts +27 -0
  310. package/dist/api/types/ProductItem.js +2 -0
  311. package/dist/api/types/ProductListResponse.d.ts +25 -0
  312. package/dist/api/types/ProductListResponse.js +14 -0
  313. package/dist/api/types/ProductMarketMetrics.d.ts +11 -0
  314. package/dist/api/types/ProductMarketMetrics.js +2 -0
  315. package/dist/api/types/ProductMarkets.d.ts +5 -0
  316. package/dist/api/types/ProductMarkets.js +2 -0
  317. package/dist/api/types/PublicApiError.d.ts +4 -0
  318. package/dist/api/types/PublicApiError.js +2 -0
  319. package/dist/api/types/RankMarkets.d.ts +4 -0
  320. package/dist/api/types/RankMarkets.js +2 -0
  321. package/dist/api/types/RankPoint.d.ts +5 -0
  322. package/dist/api/types/RankPoint.js +2 -0
  323. package/dist/api/types/RatingCount.d.ts +5 -0
  324. package/dist/api/types/RatingCount.js +2 -0
  325. package/dist/api/types/ResearchError.d.ts +6 -0
  326. package/dist/api/types/ResearchError.js +2 -0
  327. package/dist/api/types/ReviewHistoryPoint.d.ts +6 -0
  328. package/dist/api/types/ReviewHistoryPoint.js +2 -0
  329. package/dist/api/types/ReviewItem.d.ts +12 -0
  330. package/dist/api/types/ReviewItem.js +2 -0
  331. package/dist/api/types/ReviewListResponse.d.ts +7 -0
  332. package/dist/api/types/ReviewListResponse.js +2 -0
  333. package/dist/api/types/ReviewSummary.d.ts +10 -0
  334. package/dist/api/types/ReviewSummary.js +2 -0
  335. package/dist/api/types/ReviewSummaryResponse.d.ts +5 -0
  336. package/dist/api/types/ReviewSummaryResponse.js +2 -0
  337. package/dist/api/types/ReviewTopic.d.ts +4 -0
  338. package/dist/api/types/ReviewTopic.js +2 -0
  339. package/dist/api/types/SalesHistoryMarkets.d.ts +5 -0
  340. package/dist/api/types/SalesHistoryMarkets.js +2 -0
  341. package/dist/api/types/SalesHistoryMetrics.d.ts +5 -0
  342. package/dist/api/types/SalesHistoryMetrics.js +2 -0
  343. package/dist/api/types/SalesHistoryPoint.d.ts +5 -0
  344. package/dist/api/types/SalesHistoryPoint.js +2 -0
  345. package/dist/api/types/SalesHistoryResponse.d.ts +7 -0
  346. package/dist/api/types/SalesHistoryResponse.js +2 -0
  347. package/dist/api/types/SellerItem.d.ts +8 -0
  348. package/dist/api/types/SellerItem.js +2 -0
  349. package/dist/api/types/SellerMarkets.d.ts +5 -0
  350. package/dist/api/types/SellerMarkets.js +2 -0
  351. package/dist/api/types/SellerMetrics.d.ts +7 -0
  352. package/dist/api/types/SellerMetrics.js +2 -0
  353. package/dist/api/types/SellerResponse.d.ts +9 -0
  354. package/dist/api/types/SellerResponse.js +2 -0
  355. package/dist/api/types/SellerSummaryMarkets.d.ts +5 -0
  356. package/dist/api/types/SellerSummaryMarkets.js +2 -0
  357. package/dist/api/types/SellerSummaryMetrics.d.ts +6 -0
  358. package/dist/api/types/SellerSummaryMetrics.js +2 -0
  359. package/dist/api/types/StoreChange.d.ts +9 -0
  360. package/dist/api/types/StoreChange.js +2 -0
  361. package/dist/api/types/StoreError.d.ts +5 -0
  362. package/dist/api/types/StoreError.js +2 -0
  363. package/dist/api/types/StoreFilters.d.ts +3 -0
  364. package/dist/api/types/StoreFilters.js +2 -0
  365. package/dist/api/types/StoreInventoryCounts.d.ts +7 -0
  366. package/dist/api/types/StoreInventoryCounts.js +2 -0
  367. package/dist/api/types/StoreInventoryFilters.d.ts +4 -0
  368. package/dist/api/types/StoreInventoryFilters.js +2 -0
  369. package/dist/api/types/StoreInventoryPagination.d.ts +7 -0
  370. package/dist/api/types/StoreInventoryPagination.js +2 -0
  371. package/dist/api/types/StoreInventoryResponse.d.ts +28 -0
  372. package/dist/api/types/StoreInventoryResponse.js +14 -0
  373. package/dist/api/types/StoreInventoryRow.d.ts +35 -0
  374. package/dist/api/types/StoreInventoryRow.js +18 -0
  375. package/dist/api/types/StoreKpi.d.ts +12 -0
  376. package/dist/api/types/StoreKpi.js +2 -0
  377. package/dist/api/types/StoreOverviewResponse.d.ts +13 -0
  378. package/dist/api/types/StoreOverviewResponse.js +2 -0
  379. package/dist/api/types/StorePerformanceProductPerformanceItem.d.ts +48 -0
  380. package/dist/api/types/StorePerformanceProductPerformanceItem.js +2 -0
  381. package/dist/api/types/StorePerformanceReturnCostsBreakdown.d.ts +10 -0
  382. package/dist/api/types/StorePerformanceReturnCostsBreakdown.js +2 -0
  383. package/dist/api/types/StorePerformanceSalesCostsBreakdown.d.ts +10 -0
  384. package/dist/api/types/StorePerformanceSalesCostsBreakdown.js +2 -0
  385. package/dist/api/types/StorePreviousKpi.d.ts +9 -0
  386. package/dist/api/types/StorePreviousKpi.js +2 -0
  387. package/dist/api/types/StoreProductsFilters.d.ts +5 -0
  388. package/dist/api/types/StoreProductsFilters.js +2 -0
  389. package/dist/api/types/StoreProductsPagination.d.ts +9 -0
  390. package/dist/api/types/StoreProductsPagination.js +2 -0
  391. package/dist/api/types/StoreProductsResponse.d.ts +11 -0
  392. package/dist/api/types/StoreProductsResponse.js +2 -0
  393. package/dist/api/types/UnauthorizedErrorBody.d.ts +3 -0
  394. package/dist/api/types/UnauthorizedErrorBody.js +2 -0
  395. package/dist/api/types/Usage.d.ts +51 -0
  396. package/dist/api/types/Usage.js +28 -0
  397. package/dist/api/types/UsageOrganization.d.ts +4 -0
  398. package/dist/api/types/UsageOrganization.js +2 -0
  399. package/dist/api/types/VisibilityHistoryResponse.d.ts +7 -0
  400. package/dist/api/types/VisibilityHistoryResponse.js +2 -0
  401. package/dist/api/types/VisibilityMarkets.d.ts +5 -0
  402. package/dist/api/types/VisibilityMarkets.js +2 -0
  403. package/dist/api/types/VisibilityMetrics.d.ts +4 -0
  404. package/dist/api/types/VisibilityMetrics.js +2 -0
  405. package/dist/api/types/VisibilityPoint.d.ts +5 -0
  406. package/dist/api/types/VisibilityPoint.js +2 -0
  407. package/dist/api/types/index.d.ts +92 -0
  408. package/dist/api/types/index.js +92 -0
  409. package/dist/auth/BearerAuthProvider.d.ts +20 -0
  410. package/dist/auth/BearerAuthProvider.js +32 -0
  411. package/dist/auth/index.d.ts +1 -0
  412. package/dist/auth/index.js +1 -0
  413. package/dist/core/auth/AuthProvider.d.ts +8 -0
  414. package/dist/core/auth/AuthProvider.js +6 -0
  415. package/dist/core/auth/AuthRequest.d.ts +9 -0
  416. package/dist/core/auth/AuthRequest.js +1 -0
  417. package/dist/core/auth/BasicAuth.d.ts +8 -0
  418. package/dist/core/auth/BasicAuth.js +29 -0
  419. package/dist/core/auth/BearerToken.d.ts +7 -0
  420. package/dist/core/auth/BearerToken.js +13 -0
  421. package/dist/core/auth/NoOpAuthProvider.d.ts +5 -0
  422. package/dist/core/auth/NoOpAuthProvider.js +5 -0
  423. package/dist/core/auth/index.d.ts +5 -0
  424. package/dist/core/auth/index.js +4 -0
  425. package/dist/core/base64.d.ts +2 -0
  426. package/dist/core/base64.js +22 -0
  427. package/dist/core/exports.d.ts +2 -0
  428. package/dist/core/exports.js +2 -0
  429. package/dist/core/fetcher/APIResponse.d.ts +20 -0
  430. package/dist/core/fetcher/APIResponse.js +1 -0
  431. package/dist/core/fetcher/BinaryResponse.d.ts +19 -0
  432. package/dist/core/fetcher/BinaryResponse.js +14 -0
  433. package/dist/core/fetcher/EndpointMetadata.d.ts +13 -0
  434. package/dist/core/fetcher/EndpointMetadata.js +1 -0
  435. package/dist/core/fetcher/EndpointSupplier.d.ts +12 -0
  436. package/dist/core/fetcher/EndpointSupplier.js +10 -0
  437. package/dist/core/fetcher/Fetcher.d.ts +56 -0
  438. package/dist/core/fetcher/Fetcher.js +254 -0
  439. package/dist/core/fetcher/Headers.d.ts +2 -0
  440. package/dist/core/fetcher/Headers.js +83 -0
  441. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  442. package/dist/core/fetcher/HttpResponsePromise.js +90 -0
  443. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  444. package/dist/core/fetcher/RawResponse.js +40 -0
  445. package/dist/core/fetcher/Supplier.d.ts +4 -0
  446. package/dist/core/fetcher/Supplier.js +10 -0
  447. package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
  448. package/dist/core/fetcher/createRequestUrl.js +5 -0
  449. package/dist/core/fetcher/getErrorResponseBody.d.ts +1 -0
  450. package/dist/core/fetcher/getErrorResponseBody.js +43 -0
  451. package/dist/core/fetcher/getFetchFn.d.ts +1 -0
  452. package/dist/core/fetcher/getFetchFn.js +3 -0
  453. package/dist/core/fetcher/getHeader.d.ts +1 -0
  454. package/dist/core/fetcher/getHeader.js +8 -0
  455. package/dist/core/fetcher/getRequestBody.d.ts +7 -0
  456. package/dist/core/fetcher/getRequestBody.js +13 -0
  457. package/dist/core/fetcher/getResponseBody.d.ts +17 -0
  458. package/dist/core/fetcher/getResponseBody.js +70 -0
  459. package/dist/core/fetcher/index.d.ts +13 -0
  460. package/dist/core/fetcher/index.js +7 -0
  461. package/dist/core/fetcher/makePassthroughRequest.d.ts +49 -0
  462. package/dist/core/fetcher/makePassthroughRequest.js +157 -0
  463. package/dist/core/fetcher/makeRequest.d.ts +11 -0
  464. package/dist/core/fetcher/makeRequest.js +85 -0
  465. package/dist/core/fetcher/redactUrl.d.ts +2 -0
  466. package/dist/core/fetcher/redactUrl.js +84 -0
  467. package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
  468. package/dist/core/fetcher/requestWithRetries.js +77 -0
  469. package/dist/core/fetcher/signals.d.ts +6 -0
  470. package/dist/core/fetcher/signals.js +28 -0
  471. package/dist/core/headers.d.ts +2 -0
  472. package/dist/core/headers.js +27 -0
  473. package/dist/core/index.d.ts +8 -0
  474. package/dist/core/index.js +8 -0
  475. package/dist/core/json.d.ts +15 -0
  476. package/dist/core/json.js +19 -0
  477. package/dist/core/logging/exports.d.ts +18 -0
  478. package/dist/core/logging/exports.js +9 -0
  479. package/dist/core/logging/index.d.ts +1 -0
  480. package/dist/core/logging/index.js +1 -0
  481. package/dist/core/logging/logger.d.ts +126 -0
  482. package/dist/core/logging/logger.js +140 -0
  483. package/dist/core/pagination/Page.d.ts +33 -0
  484. package/dist/core/pagination/Page.js +55 -0
  485. package/dist/core/pagination/exports.d.ts +1 -0
  486. package/dist/core/pagination/exports.js +1 -0
  487. package/dist/core/pagination/index.d.ts +1 -0
  488. package/dist/core/pagination/index.js +1 -0
  489. package/dist/core/requestBody.d.ts +12 -0
  490. package/dist/core/requestBody.js +23 -0
  491. package/dist/core/runtime/index.d.ts +1 -0
  492. package/dist/core/runtime/index.js +1 -0
  493. package/dist/core/runtime/runtime.d.ts +28 -0
  494. package/dist/core/runtime/runtime.js +171 -0
  495. package/dist/core/url/QueryStringBuilder.d.ts +47 -0
  496. package/dist/core/url/QueryStringBuilder.js +78 -0
  497. package/dist/core/url/encodePathParam.d.ts +3 -0
  498. package/dist/core/url/encodePathParam.js +24 -0
  499. package/dist/core/url/index.d.ts +4 -0
  500. package/dist/core/url/index.js +4 -0
  501. package/dist/core/url/join.d.ts +1 -0
  502. package/dist/core/url/join.js +65 -0
  503. package/dist/core/url/qs.d.ts +7 -0
  504. package/dist/core/url/qs.js +76 -0
  505. package/dist/core/utils/index.d.ts +1 -0
  506. package/dist/core/utils/index.js +1 -0
  507. package/dist/core/utils/setObjectProperty.d.ts +12 -0
  508. package/dist/core/utils/setObjectProperty.js +45 -0
  509. package/dist/environments.d.ts +4 -0
  510. package/dist/environments.js +4 -0
  511. package/dist/errors/MarktMentorError.d.ts +15 -0
  512. package/dist/errors/MarktMentorError.js +52 -0
  513. package/dist/errors/MarktMentorTimeoutError.d.ts +6 -0
  514. package/dist/errors/MarktMentorTimeoutError.js +15 -0
  515. package/dist/errors/handleNonStatusCodeError.d.ts +2 -0
  516. package/dist/errors/handleNonStatusCodeError.js +32 -0
  517. package/dist/errors/index.d.ts +2 -0
  518. package/dist/errors/index.js +2 -0
  519. package/dist/exports.d.ts +1 -0
  520. package/dist/exports.js +1 -0
  521. package/dist/index.d.ts +6 -0
  522. package/dist/index.js +5 -0
  523. package/package.json +33 -4
@@ -0,0 +1,58 @@
1
+ import type { WithRawResponse } from "./RawResponse.js";
2
+ /**
3
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
4
+ */
5
+ export declare class HttpResponsePromise<T> extends Promise<T> {
6
+ private innerPromise;
7
+ private unwrappedPromise;
8
+ private constructor();
9
+ /**
10
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
11
+ *
12
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
13
+ * @param args - Arguments to pass to the function.
14
+ * @returns An `HttpResponsePromise` instance.
15
+ */
16
+ static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
17
+ /**
18
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
19
+ *
20
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
21
+ * @returns A function that returns an `HttpResponsePromise` instance.
22
+ */
23
+ static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
24
+ /**
25
+ * Creates an `HttpResponsePromise` from an existing promise.
26
+ *
27
+ * @param promise - A promise resolving to a `WithRawResponse` object.
28
+ * @returns An `HttpResponsePromise` instance.
29
+ */
30
+ static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
31
+ /**
32
+ * Creates an `HttpResponsePromise` from an executor function.
33
+ *
34
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
35
+ * @returns An `HttpResponsePromise` instance.
36
+ */
37
+ static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
38
+ /**
39
+ * Creates an `HttpResponsePromise` from a resolved result.
40
+ *
41
+ * @param result - A `WithRawResponse` object to resolve immediately.
42
+ * @returns An `HttpResponsePromise` instance.
43
+ */
44
+ static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
45
+ private unwrap;
46
+ /** @inheritdoc */
47
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
48
+ /** @inheritdoc */
49
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
50
+ /** @inheritdoc */
51
+ finally(onfinally?: (() => void) | null): Promise<T>;
52
+ /**
53
+ * Retrieves the data and raw response.
54
+ *
55
+ * @returns A promise resolving to a `WithRawResponse` object.
56
+ */
57
+ withRawResponse(): Promise<WithRawResponse<T>>;
58
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
3
+ */
4
+ export class HttpResponsePromise extends Promise {
5
+ innerPromise;
6
+ unwrappedPromise;
7
+ constructor(promise) {
8
+ // Initialize with a no-op to avoid premature parsing
9
+ super((resolve) => {
10
+ resolve(undefined);
11
+ });
12
+ this.innerPromise = promise;
13
+ }
14
+ /**
15
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
16
+ *
17
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
18
+ * @param args - Arguments to pass to the function.
19
+ * @returns An `HttpResponsePromise` instance.
20
+ */
21
+ static fromFunction(fn, ...args) {
22
+ return new HttpResponsePromise(fn(...args));
23
+ }
24
+ /**
25
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
26
+ *
27
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
28
+ * @returns A function that returns an `HttpResponsePromise` instance.
29
+ */
30
+ static interceptFunction(fn) {
31
+ return (...args) => {
32
+ return HttpResponsePromise.fromPromise(fn(...args));
33
+ };
34
+ }
35
+ /**
36
+ * Creates an `HttpResponsePromise` from an existing promise.
37
+ *
38
+ * @param promise - A promise resolving to a `WithRawResponse` object.
39
+ * @returns An `HttpResponsePromise` instance.
40
+ */
41
+ static fromPromise(promise) {
42
+ return new HttpResponsePromise(promise);
43
+ }
44
+ /**
45
+ * Creates an `HttpResponsePromise` from an executor function.
46
+ *
47
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
48
+ * @returns An `HttpResponsePromise` instance.
49
+ */
50
+ static fromExecutor(executor) {
51
+ const promise = new Promise(executor);
52
+ return new HttpResponsePromise(promise);
53
+ }
54
+ /**
55
+ * Creates an `HttpResponsePromise` from a resolved result.
56
+ *
57
+ * @param result - A `WithRawResponse` object to resolve immediately.
58
+ * @returns An `HttpResponsePromise` instance.
59
+ */
60
+ static fromResult(result) {
61
+ const promise = Promise.resolve(result);
62
+ return new HttpResponsePromise(promise);
63
+ }
64
+ unwrap() {
65
+ if (!this.unwrappedPromise) {
66
+ this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
67
+ }
68
+ return this.unwrappedPromise;
69
+ }
70
+ /** @inheritdoc */
71
+ then(onfulfilled, onrejected) {
72
+ return this.unwrap().then(onfulfilled, onrejected);
73
+ }
74
+ /** @inheritdoc */
75
+ catch(onrejected) {
76
+ return this.unwrap().catch(onrejected);
77
+ }
78
+ /** @inheritdoc */
79
+ finally(onfinally) {
80
+ return this.unwrap().finally(onfinally);
81
+ }
82
+ /**
83
+ * Retrieves the data and raw response.
84
+ *
85
+ * @returns A promise resolving to a `WithRawResponse` object.
86
+ */
87
+ async withRawResponse() {
88
+ return await this.innerPromise;
89
+ }
90
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The raw response from the fetch call excluding the body.
3
+ */
4
+ export type RawResponse = Omit<{
5
+ [K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
6
+ }, "ok" | "body" | "bodyUsed">;
7
+ /**
8
+ * A raw response indicating that the request was aborted.
9
+ */
10
+ export declare const abortRawResponse: RawResponse;
11
+ /**
12
+ * A raw response indicating an unknown error.
13
+ */
14
+ export declare const unknownRawResponse: RawResponse;
15
+ /**
16
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
17
+ * excluding the `body` and `bodyUsed` fields.
18
+ *
19
+ * @param response - The `RawResponse` object to convert.
20
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
21
+ */
22
+ export declare function toRawResponse(response: Response): RawResponse;
23
+ /**
24
+ * Creates a `RawResponse` from a standard `Response` object.
25
+ */
26
+ export interface WithRawResponse<T> {
27
+ readonly data: T;
28
+ readonly rawResponse: RawResponse;
29
+ }
@@ -0,0 +1,40 @@
1
+ import { Headers } from "./Headers.js";
2
+ /**
3
+ * A raw response indicating that the request was aborted.
4
+ */
5
+ export const abortRawResponse = {
6
+ headers: new Headers(),
7
+ redirected: false,
8
+ status: 499,
9
+ statusText: "Client Closed Request",
10
+ type: "error",
11
+ url: "",
12
+ };
13
+ /**
14
+ * A raw response indicating an unknown error.
15
+ */
16
+ export const unknownRawResponse = {
17
+ headers: new Headers(),
18
+ redirected: false,
19
+ status: 0,
20
+ statusText: "Unknown Error",
21
+ type: "error",
22
+ url: "",
23
+ };
24
+ /**
25
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
26
+ * excluding the `body` and `bodyUsed` fields.
27
+ *
28
+ * @param response - The `RawResponse` object to convert.
29
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
30
+ */
31
+ export function toRawResponse(response) {
32
+ return {
33
+ headers: response.headers,
34
+ redirected: response.redirected,
35
+ status: response.status,
36
+ statusText: response.statusText,
37
+ type: response.type,
38
+ url: response.url,
39
+ };
40
+ }
@@ -0,0 +1,4 @@
1
+ export type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
2
+ export declare const Supplier: {
3
+ get: <T>(supplier: Supplier<T>) => Promise<T>;
4
+ };
@@ -0,0 +1,10 @@
1
+ export const Supplier = {
2
+ get: async (supplier) => {
3
+ if (typeof supplier === "function") {
4
+ return supplier();
5
+ }
6
+ else {
7
+ return supplier;
8
+ }
9
+ },
10
+ };
@@ -0,0 +1 @@
1
+ export declare function createRequestUrl(baseUrl: string, queryParameters?: Record<string, unknown>): string;
@@ -0,0 +1,5 @@
1
+ import { toQueryString } from "../url/qs.js";
2
+ export function createRequestUrl(baseUrl, queryParameters) {
3
+ const queryString = toQueryString(queryParameters, { arrayFormat: "repeat" });
4
+ return queryString ? `${baseUrl}?${queryString}` : baseUrl;
5
+ }
@@ -0,0 +1 @@
1
+ export declare function getErrorResponseBody(response: Response): Promise<unknown>;
@@ -0,0 +1,43 @@
1
+ import { fromJson } from "../json.js";
2
+ import { getResponseBody, isResponseBodyError } from "./getResponseBody.js";
3
+ /** Parses a JSON error body, falling back to the raw text so the status and body are never lost. */
4
+ function parseJsonErrorBody(text) {
5
+ if (text.length === 0) {
6
+ return undefined;
7
+ }
8
+ try {
9
+ return fromJson(text);
10
+ }
11
+ catch {
12
+ return text;
13
+ }
14
+ }
15
+ export async function getErrorResponseBody(response) {
16
+ let contentType = response.headers.get("Content-Type")?.toLowerCase();
17
+ if (contentType == null || contentType.length === 0) {
18
+ const body = await getResponseBody(response);
19
+ if (isResponseBodyError(body)) {
20
+ return body.error.reason === "non-json" ? body.error.rawBody : undefined;
21
+ }
22
+ return body;
23
+ }
24
+ if (contentType.indexOf(";") !== -1) {
25
+ contentType = contentType.split(";")[0]?.trim() ?? "";
26
+ }
27
+ switch (contentType) {
28
+ case "application/hal+json":
29
+ case "application/json":
30
+ case "application/ld+json":
31
+ case "application/problem+json":
32
+ case "application/vnd.api+json":
33
+ case "text/json":
34
+ return parseJsonErrorBody(await response.text());
35
+ default:
36
+ if (contentType.startsWith("application/vnd.") && contentType.endsWith("+json")) {
37
+ return parseJsonErrorBody(await response.text());
38
+ }
39
+ // Fallback to plain text if content type is not recognized
40
+ // Even if no body is present, the response will be an empty string
41
+ return await response.text();
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ export declare function getFetchFn(): Promise<typeof fetch>;
@@ -0,0 +1,3 @@
1
+ export async function getFetchFn() {
2
+ return fetch;
3
+ }
@@ -0,0 +1 @@
1
+ export declare function getHeader(headers: Record<string, any>, header: string): string | undefined;
@@ -0,0 +1,8 @@
1
+ export function getHeader(headers, header) {
2
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
3
+ if (headerKey.toLowerCase() === header.toLowerCase()) {
4
+ return headerValue;
5
+ }
6
+ }
7
+ return undefined;
8
+ }
@@ -0,0 +1,7 @@
1
+ export declare namespace GetRequestBody {
2
+ interface Args {
3
+ body: unknown;
4
+ type: "json" | "file" | "bytes" | "form" | "other";
5
+ }
6
+ }
7
+ export declare function getRequestBody({ body, type }: GetRequestBody.Args): Promise<BodyInit | undefined>;
@@ -0,0 +1,13 @@
1
+ import { toJson } from "../json.js";
2
+ import { toQueryString } from "../url/qs.js";
3
+ export async function getRequestBody({ body, type }) {
4
+ if (type === "form") {
5
+ return toQueryString(body, { arrayFormat: "repeat", encode: true });
6
+ }
7
+ if (type.includes("json")) {
8
+ return toJson(body);
9
+ }
10
+ else {
11
+ return body;
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ export type ResponseBodyError = {
2
+ ok: false;
3
+ error: {
4
+ reason: "non-json";
5
+ statusCode: number;
6
+ rawBody: string;
7
+ } | {
8
+ reason: "body-is-null";
9
+ statusCode: number;
10
+ };
11
+ };
12
+ /**
13
+ * Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON),
14
+ * as opposed to a parsed JSON body that happens to have the same shape.
15
+ */
16
+ export declare function isResponseBodyError(value: unknown): value is ResponseBodyError;
17
+ export declare function getResponseBody(response: Response, responseType?: string): Promise<unknown>;
@@ -0,0 +1,70 @@
1
+ import { fromJson } from "../json.js";
2
+ import { getBinaryResponse } from "./BinaryResponse.js";
3
+ // Pins the upstream Response so undici's FinalizationRegistry can't GC it and cancel the body stream.
4
+ function retainResponse(target, response) {
5
+ Object.defineProperty(target, "__fern_response_ref", {
6
+ value: response,
7
+ enumerable: false,
8
+ configurable: true,
9
+ writable: false,
10
+ });
11
+ }
12
+ const responseBodyErrors = new WeakSet();
13
+ function responseBodyError(error) {
14
+ const record = { ok: false, error };
15
+ responseBodyErrors.add(record);
16
+ return record;
17
+ }
18
+ /**
19
+ * Returns true when `value` is a failure record created by `getResponseBody` (for example malformed JSON),
20
+ * as opposed to a parsed JSON body that happens to have the same shape.
21
+ */
22
+ export function isResponseBodyError(value) {
23
+ return typeof value === "object" && value != null && responseBodyErrors.has(value);
24
+ }
25
+ export async function getResponseBody(response, responseType) {
26
+ switch (responseType) {
27
+ case "binary-response":
28
+ return getBinaryResponse(response);
29
+ case "blob":
30
+ return await response.blob();
31
+ case "arrayBuffer":
32
+ return await response.arrayBuffer();
33
+ case "sse":
34
+ if (response.body == null) {
35
+ return responseBodyError({
36
+ reason: "body-is-null",
37
+ statusCode: response.status,
38
+ });
39
+ }
40
+ retainResponse(response.body, response);
41
+ return response.body;
42
+ case "streaming":
43
+ if (response.body == null) {
44
+ return responseBodyError({
45
+ reason: "body-is-null",
46
+ statusCode: response.status,
47
+ });
48
+ }
49
+ retainResponse(response.body, response);
50
+ return response.body;
51
+ case "text":
52
+ return await response.text();
53
+ }
54
+ // if responseType is "json" or not specified, try to parse as JSON
55
+ const text = await response.text();
56
+ if (text.length > 0) {
57
+ try {
58
+ const responseBody = fromJson(text);
59
+ return responseBody;
60
+ }
61
+ catch (_err) {
62
+ return responseBodyError({
63
+ reason: "non-json",
64
+ statusCode: response.status,
65
+ rawBody: text,
66
+ });
67
+ }
68
+ }
69
+ return undefined;
70
+ }
@@ -0,0 +1,13 @@
1
+ export type { APIResponse } from "./APIResponse.js";
2
+ export type { BinaryResponse } from "./BinaryResponse.js";
3
+ export type { EndpointMetadata } from "./EndpointMetadata.js";
4
+ export { EndpointSupplier } from "./EndpointSupplier.js";
5
+ export type { Fetcher, FetchFunction } from "./Fetcher.js";
6
+ export { fetcher } from "./Fetcher.js";
7
+ export { getHeader } from "./getHeader.js";
8
+ export { HttpResponsePromise } from "./HttpResponsePromise.js";
9
+ export type { PassthroughRequest } from "./makePassthroughRequest.js";
10
+ export { makePassthroughRequest } from "./makePassthroughRequest.js";
11
+ export type { RawResponse, WithRawResponse } from "./RawResponse.js";
12
+ export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
13
+ export { Supplier } from "./Supplier.js";
@@ -0,0 +1,7 @@
1
+ export { EndpointSupplier } from "./EndpointSupplier.js";
2
+ export { fetcher } from "./Fetcher.js";
3
+ export { getHeader } from "./getHeader.js";
4
+ export { HttpResponsePromise } from "./HttpResponsePromise.js";
5
+ export { makePassthroughRequest } from "./makePassthroughRequest.js";
6
+ export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
7
+ export { Supplier } from "./Supplier.js";
@@ -0,0 +1,49 @@
1
+ import { type LogConfig, type Logger } from "../logging/logger.js";
2
+ import { Supplier } from "./Supplier.js";
3
+ export declare namespace PassthroughRequest {
4
+ /**
5
+ * Per-request options that can override the SDK client defaults.
6
+ */
7
+ interface RequestOptions {
8
+ /** Override the default timeout for this request (in seconds). */
9
+ timeoutInSeconds?: number;
10
+ /** Override the default number of retries for this request. */
11
+ maxRetries?: number;
12
+ /** Additional headers to include in this request. */
13
+ headers?: Record<string, string>;
14
+ /** Abort signal for this request. */
15
+ abortSignal?: AbortSignal;
16
+ }
17
+ /**
18
+ * SDK client configuration used by the passthrough fetch method.
19
+ */
20
+ interface ClientOptions {
21
+ /** The base URL or environment for the client. */
22
+ environment?: Supplier<string>;
23
+ /** Override the base URL. */
24
+ baseUrl?: Supplier<string>;
25
+ /** Default headers to include in requests. */
26
+ headers?: Record<string, unknown>;
27
+ /** Default maximum time to wait for a response in seconds. */
28
+ timeoutInSeconds?: number;
29
+ /** Default number of times to retry the request. Defaults to 2. */
30
+ maxRetries?: number;
31
+ /** A custom fetch function. */
32
+ fetch?: typeof fetch;
33
+ /** Logging configuration. */
34
+ logging?: LogConfig | Logger;
35
+ /** A function that returns auth headers. */
36
+ getAuthHeaders?: () => Promise<Record<string, string>>;
37
+ }
38
+ }
39
+ /**
40
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
41
+ * while mimicking the standard `fetch` API.
42
+ *
43
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
44
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
45
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
46
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
47
+ * @returns A standard Response object.
48
+ */
49
+ export declare function makePassthroughRequest(input: Request | string | URL, init: RequestInit | undefined, clientOptions: PassthroughRequest.ClientOptions, requestOptions?: PassthroughRequest.RequestOptions): Promise<Response>;
@@ -0,0 +1,157 @@
1
+ import { createLogger } from "../logging/logger.js";
2
+ import { join } from "../url/join.js";
3
+ import { EndpointSupplier } from "./EndpointSupplier.js";
4
+ import { getFetchFn } from "./getFetchFn.js";
5
+ import { makeRequest } from "./makeRequest.js";
6
+ import { redactUrl } from "./redactUrl.js";
7
+ import { requestWithRetries } from "./requestWithRetries.js";
8
+ import { Supplier } from "./Supplier.js";
9
+ import { TIMEOUT } from "./signals.js";
10
+ /**
11
+ * Makes a passthrough HTTP request using the SDK's configuration (auth, retry, logging, etc.)
12
+ * while mimicking the standard `fetch` API.
13
+ *
14
+ * @param input - The URL, path, or Request object. If a relative path, it will be resolved against the configured base URL.
15
+ * @param init - Standard RequestInit options (method, headers, body, signal, etc.)
16
+ * @param clientOptions - SDK client options (auth, default headers, logging, etc.)
17
+ * @param requestOptions - Per-request overrides (timeout, retries, extra headers, abort signal).
18
+ * @returns A standard Response object.
19
+ */
20
+ export async function makePassthroughRequest(input, init, clientOptions, requestOptions) {
21
+ const logger = createLogger(clientOptions.logging);
22
+ // Extract URL and default init properties from Request object if provided
23
+ let url;
24
+ let effectiveInit = init;
25
+ if (input instanceof Request) {
26
+ url = input.url;
27
+ // If no explicit init provided, extract properties from the Request object
28
+ if (init == null) {
29
+ effectiveInit = {
30
+ method: input.method,
31
+ headers: Object.fromEntries(input.headers.entries()),
32
+ body: input.body,
33
+ signal: input.signal,
34
+ credentials: input.credentials,
35
+ cache: input.cache,
36
+ redirect: input.redirect,
37
+ referrer: input.referrer,
38
+ integrity: input.integrity,
39
+ mode: input.mode,
40
+ };
41
+ }
42
+ }
43
+ else {
44
+ url = input instanceof URL ? input.toString() : input;
45
+ }
46
+ // Resolve the base URL
47
+ const baseUrl = (clientOptions.baseUrl != null ? await Supplier.get(clientOptions.baseUrl) : undefined) ??
48
+ (clientOptions.environment != null ? await Supplier.get(clientOptions.environment) : undefined);
49
+ // Determine the full URL
50
+ let fullUrl;
51
+ if (url.startsWith("http://") || url.startsWith("https://")) {
52
+ fullUrl = url;
53
+ }
54
+ else if (baseUrl != null) {
55
+ fullUrl = join(baseUrl, url);
56
+ }
57
+ else {
58
+ fullUrl = url;
59
+ }
60
+ // Merge headers: SDK default headers -> auth headers -> user-provided headers
61
+ const mergedHeaders = {};
62
+ // Apply SDK default headers (resolve suppliers)
63
+ if (clientOptions.headers != null) {
64
+ for (const [key, value] of Object.entries(clientOptions.headers)) {
65
+ const resolved = await EndpointSupplier.get(value, { endpointMetadata: {} });
66
+ if (resolved != null) {
67
+ mergedHeaders[key.toLowerCase()] = `${resolved}`;
68
+ }
69
+ }
70
+ }
71
+ // Apply auth headers, but only when the resolved URL targets the configured base URL.
72
+ // This prevents the SDK's credentials from leaking to an unrelated host when a caller
73
+ // passes an absolute cross-origin URL into the passthrough fetch escape hatch.
74
+ if (clientOptions.getAuthHeaders != null && targetsBaseUrl(fullUrl, baseUrl)) {
75
+ const authHeaders = await clientOptions.getAuthHeaders();
76
+ for (const [key, value] of Object.entries(authHeaders)) {
77
+ mergedHeaders[key.toLowerCase()] = value;
78
+ }
79
+ }
80
+ // Apply user-provided headers from init
81
+ if (effectiveInit?.headers != null) {
82
+ const initHeaders = effectiveInit.headers instanceof Headers
83
+ ? Object.fromEntries(effectiveInit.headers.entries())
84
+ : Array.isArray(effectiveInit.headers)
85
+ ? Object.fromEntries(effectiveInit.headers)
86
+ : effectiveInit.headers;
87
+ for (const [key, value] of Object.entries(initHeaders)) {
88
+ if (value != null) {
89
+ mergedHeaders[key.toLowerCase()] = value;
90
+ }
91
+ }
92
+ }
93
+ // Apply per-request option headers (highest priority)
94
+ if (requestOptions?.headers != null) {
95
+ for (const [key, value] of Object.entries(requestOptions.headers)) {
96
+ mergedHeaders[key.toLowerCase()] = value;
97
+ }
98
+ }
99
+ const method = effectiveInit?.method ?? "GET";
100
+ const body = effectiveInit?.body;
101
+ const timeoutInSeconds = requestOptions?.timeoutInSeconds ?? clientOptions.timeoutInSeconds;
102
+ const timeoutMs = timeoutInSeconds != null ? timeoutInSeconds * 1000 : undefined;
103
+ const maxRetries = requestOptions?.maxRetries ?? clientOptions.maxRetries;
104
+ const abortSignal = requestOptions?.abortSignal ?? effectiveInit?.signal ?? undefined;
105
+ const fetchFn = clientOptions.fetch ?? (await getFetchFn());
106
+ if (logger.isDebug()) {
107
+ logger.debug("Making passthrough HTTP request", {
108
+ method,
109
+ url: redactUrl(fullUrl),
110
+ hasBody: body != null,
111
+ });
112
+ }
113
+ let response;
114
+ try {
115
+ response = await requestWithRetries(async () => makeRequest(fetchFn, fullUrl, method, mergedHeaders, body ?? undefined, timeoutMs, abortSignal, effectiveInit?.credentials === "include", undefined, // duplex
116
+ false), maxRetries, abortSignal);
117
+ }
118
+ catch (error) {
119
+ // Match `fetch`: a timeout rejects with an Error named "TimeoutError", not the bare abort reason.
120
+ if (error === TIMEOUT) {
121
+ throw createTimeoutError();
122
+ }
123
+ throw error;
124
+ }
125
+ if (logger.isDebug()) {
126
+ logger.debug("Passthrough HTTP request completed", {
127
+ method,
128
+ url: redactUrl(fullUrl),
129
+ statusCode: response.status,
130
+ });
131
+ }
132
+ return response;
133
+ }
134
+ function createTimeoutError() {
135
+ const error = new Error("The request timed out.");
136
+ error.name = "TimeoutError";
137
+ return error;
138
+ }
139
+ /**
140
+ * Returns true when the resolved request URL points at the same origin as the
141
+ * configured base URL. Relative paths are always joined onto the base URL, so
142
+ * they resolve to the base origin and return true. Absolute URLs only match when
143
+ * their origin equals the base origin. When there is no base URL to compare
144
+ * against, or either value is not a parseable absolute URL, this returns false so
145
+ * auth headers are not attached.
146
+ */
147
+ function targetsBaseUrl(fullUrl, baseUrl) {
148
+ if (baseUrl == null) {
149
+ return false;
150
+ }
151
+ try {
152
+ return new URL(fullUrl).origin === new URL(baseUrl).origin;
153
+ }
154
+ catch {
155
+ return false;
156
+ }
157
+ }