@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.
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/dist/BaseClient.d.ts +54 -0
- package/dist/BaseClient.js +43 -0
- package/dist/Client.d.ts +41 -0
- package/dist/Client.js +60 -0
- package/dist/api/errors/BadRequestError.d.ts +5 -0
- package/dist/api/errors/BadRequestError.js +17 -0
- package/dist/api/errors/ConflictError.d.ts +5 -0
- package/dist/api/errors/ConflictError.js +17 -0
- package/dist/api/errors/ForbiddenError.d.ts +5 -0
- package/dist/api/errors/ForbiddenError.js +17 -0
- package/dist/api/errors/NotFoundError.d.ts +7 -0
- package/dist/api/errors/NotFoundError.js +17 -0
- package/dist/api/errors/PaymentRequiredError.d.ts +7 -0
- package/dist/api/errors/PaymentRequiredError.js +17 -0
- package/dist/api/errors/ServiceUnavailableError.d.ts +5 -0
- package/dist/api/errors/ServiceUnavailableError.js +17 -0
- package/dist/api/errors/TooManyRequestsError.d.ts +5 -0
- package/dist/api/errors/TooManyRequestsError.js +17 -0
- package/dist/api/errors/UnauthorizedError.d.ts +5 -0
- package/dist/api/errors/UnauthorizedError.js +17 -0
- package/dist/api/errors/index.d.ts +8 -0
- package/dist/api/errors/index.js +8 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +3 -0
- package/dist/api/resources/index.d.ts +13 -0
- package/dist/api/resources/index.js +13 -0
- package/dist/api/resources/niches/client/Client.d.ts +188 -0
- package/dist/api/resources/niches/client/Client.js +655 -0
- package/dist/api/resources/niches/client/index.d.ts +1 -0
- package/dist/api/resources/niches/client/index.js +1 -0
- package/dist/api/resources/niches/client/requests/GetNichesRequest.d.ts +17 -0
- package/dist/api/resources/niches/client/requests/GetNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ListNichesRequest.d.ts +34 -0
- package/dist/api/resources/niches/client/requests/ListNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ProductDistributionsNichesRequest.d.ts +13 -0
- package/dist/api/resources/niches/client/requests/ProductDistributionsNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ProductsNichesRequest.d.ts +48 -0
- package/dist/api/resources/niches/client/requests/ProductsNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ReviewHistoryNichesRequest.d.ts +23 -0
- package/dist/api/resources/niches/client/requests/ReviewHistoryNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ReviewSummaryNichesRequest.d.ts +5 -0
- package/dist/api/resources/niches/client/requests/ReviewSummaryNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/ReviewsNichesRequest.d.ts +33 -0
- package/dist/api/resources/niches/client/requests/ReviewsNichesRequest.js +2 -0
- package/dist/api/resources/niches/client/requests/index.d.ts +7 -0
- package/dist/api/resources/niches/client/requests/index.js +1 -0
- package/dist/api/resources/niches/exports.d.ts +2 -0
- package/dist/api/resources/niches/exports.js +3 -0
- package/dist/api/resources/niches/index.d.ts +2 -0
- package/dist/api/resources/niches/index.js +2 -0
- package/dist/api/resources/niches/types/GetNichesRequestMarket.d.ts +6 -0
- package/dist/api/resources/niches/types/GetNichesRequestMarket.js +6 -0
- package/dist/api/resources/niches/types/GetNichesRequestPeriod.d.ts +6 -0
- package/dist/api/resources/niches/types/GetNichesRequestPeriod.js +6 -0
- package/dist/api/resources/niches/types/ListNichesRequestMarket.d.ts +6 -0
- package/dist/api/resources/niches/types/ListNichesRequestMarket.js +6 -0
- package/dist/api/resources/niches/types/ListNichesRequestPeriod.d.ts +6 -0
- package/dist/api/resources/niches/types/ListNichesRequestPeriod.js +6 -0
- package/dist/api/resources/niches/types/ListNichesRequestSort.d.ts +9 -0
- package/dist/api/resources/niches/types/ListNichesRequestSort.js +9 -0
- package/dist/api/resources/niches/types/ProductDistributionsNichesRequestPeriod.d.ts +6 -0
- package/dist/api/resources/niches/types/ProductDistributionsNichesRequestPeriod.js +6 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestMarket.d.ts +6 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestMarket.js +6 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestPeriod.d.ts +6 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestPeriod.js +6 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestSort.d.ts +9 -0
- package/dist/api/resources/niches/types/ProductsNichesRequestSort.js +9 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestInterval.d.ts +5 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestInterval.js +5 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestMarket.d.ts +4 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestMarket.js +4 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestPeriod.d.ts +7 -0
- package/dist/api/resources/niches/types/ReviewHistoryNichesRequestPeriod.js +7 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestMarket.d.ts +4 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestMarket.js +4 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestPeriod.d.ts +7 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestPeriod.js +7 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestSort.d.ts +7 -0
- package/dist/api/resources/niches/types/ReviewsNichesRequestSort.js +7 -0
- package/dist/api/resources/niches/types/index.d.ts +15 -0
- package/dist/api/resources/niches/types/index.js +15 -0
- package/dist/api/resources/organization/client/Client.d.ts +32 -0
- package/dist/api/resources/organization/client/Client.js +73 -0
- package/dist/api/resources/organization/client/index.d.ts +1 -0
- package/dist/api/resources/organization/client/index.js +1 -0
- package/dist/api/resources/organization/exports.d.ts +2 -0
- package/dist/api/resources/organization/exports.js +3 -0
- package/dist/api/resources/organization/index.d.ts +1 -0
- package/dist/api/resources/organization/index.js +1 -0
- package/dist/api/resources/products/client/Client.d.ts +269 -0
- package/dist/api/resources/products/client/Client.js +927 -0
- package/dist/api/resources/products/client/index.d.ts +1 -0
- package/dist/api/resources/products/client/index.js +1 -0
- package/dist/api/resources/products/client/requests/CategoryRankingsProductsRequest.d.ts +23 -0
- package/dist/api/resources/products/client/requests/CategoryRankingsProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/GetProductsRequest.d.ts +15 -0
- package/dist/api/resources/products/client/requests/GetProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/KeywordRankingsProductsRequest.d.ts +27 -0
- package/dist/api/resources/products/client/requests/KeywordRankingsProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/KeywordsProductsRequest.d.ts +19 -0
- package/dist/api/resources/products/client/requests/KeywordsProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/ListProductsRequest.d.ts +50 -0
- package/dist/api/resources/products/client/requests/ListProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/ReviewSummaryProductsRequest.d.ts +8 -0
- package/dist/api/resources/products/client/requests/ReviewSummaryProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/ReviewsProductsRequest.d.ts +35 -0
- package/dist/api/resources/products/client/requests/ReviewsProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/SalesHistoryProductsRequest.d.ts +23 -0
- package/dist/api/resources/products/client/requests/SalesHistoryProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/SellersProductsRequest.d.ts +16 -0
- package/dist/api/resources/products/client/requests/SellersProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/VisibilityHistoryProductsRequest.d.ts +23 -0
- package/dist/api/resources/products/client/requests/VisibilityHistoryProductsRequest.js +2 -0
- package/dist/api/resources/products/client/requests/index.d.ts +10 -0
- package/dist/api/resources/products/client/requests/index.js +1 -0
- package/dist/api/resources/products/exports.d.ts +2 -0
- package/dist/api/resources/products/exports.js +3 -0
- package/dist/api/resources/products/index.d.ts +2 -0
- package/dist/api/resources/products/index.js +2 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestInterval.d.ts +5 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestInterval.js +5 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/CategoryRankingsProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/GetProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/GetProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/GetProductsRequestPeriod.d.ts +6 -0
- package/dist/api/resources/products/types/GetProductsRequestPeriod.js +6 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestInterval.d.ts +5 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestInterval.js +5 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/KeywordRankingsProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/KeywordsProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/KeywordsProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/KeywordsProductsRequestPeriod.d.ts +6 -0
- package/dist/api/resources/products/types/KeywordsProductsRequestPeriod.js +6 -0
- package/dist/api/resources/products/types/ListProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/ListProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/ListProductsRequestPeriod.d.ts +6 -0
- package/dist/api/resources/products/types/ListProductsRequestPeriod.js +6 -0
- package/dist/api/resources/products/types/ListProductsRequestSort.d.ts +9 -0
- package/dist/api/resources/products/types/ListProductsRequestSort.js +9 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestMarket.d.ts +4 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestMarket.js +4 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestSort.d.ts +7 -0
- package/dist/api/resources/products/types/ReviewsProductsRequestSort.js +7 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestInterval.d.ts +5 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestInterval.js +5 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/SalesHistoryProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/SellersProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/SellersProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/SellersProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/SellersProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestInterval.d.ts +5 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestInterval.js +5 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestMarket.d.ts +6 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestMarket.js +6 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestPeriod.d.ts +7 -0
- package/dist/api/resources/products/types/VisibilityHistoryProductsRequestPeriod.js +7 -0
- package/dist/api/resources/products/types/index.d.ts +24 -0
- package/dist/api/resources/products/types/index.js +24 -0
- package/dist/api/resources/reference/client/Client.d.ts +84 -0
- package/dist/api/resources/reference/client/Client.js +254 -0
- package/dist/api/resources/reference/client/index.d.ts +1 -0
- package/dist/api/resources/reference/client/index.js +1 -0
- package/dist/api/resources/reference/client/requests/BrandsReferenceRequest.d.ts +12 -0
- package/dist/api/resources/reference/client/requests/BrandsReferenceRequest.js +2 -0
- package/dist/api/resources/reference/client/requests/CategoriesReferenceRequest.d.ts +18 -0
- package/dist/api/resources/reference/client/requests/CategoriesReferenceRequest.js +2 -0
- package/dist/api/resources/reference/client/requests/CategoryReferenceRequest.d.ts +5 -0
- package/dist/api/resources/reference/client/requests/CategoryReferenceRequest.js +2 -0
- package/dist/api/resources/reference/client/requests/index.d.ts +3 -0
- package/dist/api/resources/reference/client/requests/index.js +1 -0
- package/dist/api/resources/reference/exports.d.ts +2 -0
- package/dist/api/resources/reference/exports.js +3 -0
- package/dist/api/resources/reference/index.d.ts +1 -0
- package/dist/api/resources/reference/index.js +1 -0
- package/dist/api/resources/store/client/Client.d.ts +82 -0
- package/dist/api/resources/store/client/Client.js +291 -0
- package/dist/api/resources/store/client/index.d.ts +1 -0
- package/dist/api/resources/store/client/index.js +1 -0
- package/dist/api/resources/store/client/requests/InventoryStoreRequest.d.ts +23 -0
- package/dist/api/resources/store/client/requests/InventoryStoreRequest.js +2 -0
- package/dist/api/resources/store/client/requests/OverviewStoreRequest.d.ts +13 -0
- package/dist/api/resources/store/client/requests/OverviewStoreRequest.js +2 -0
- package/dist/api/resources/store/client/requests/ProductsStoreRequest.d.ts +49 -0
- package/dist/api/resources/store/client/requests/ProductsStoreRequest.js +2 -0
- package/dist/api/resources/store/client/requests/index.d.ts +3 -0
- package/dist/api/resources/store/client/requests/index.js +1 -0
- package/dist/api/resources/store/exports.d.ts +2 -0
- package/dist/api/resources/store/exports.js +3 -0
- package/dist/api/resources/store/index.d.ts +2 -0
- package/dist/api/resources/store/index.js +2 -0
- package/dist/api/resources/store/types/InventoryStoreRequestStockState.d.ts +6 -0
- package/dist/api/resources/store/types/InventoryStoreRequestStockState.js +6 -0
- package/dist/api/resources/store/types/OverviewStoreRequestCountry.d.ts +6 -0
- package/dist/api/resources/store/types/OverviewStoreRequestCountry.js +6 -0
- package/dist/api/resources/store/types/ProductsStoreRequestCountry.d.ts +5 -0
- package/dist/api/resources/store/types/ProductsStoreRequestCountry.js +5 -0
- package/dist/api/resources/store/types/ProductsStoreRequestSort.d.ts +11 -0
- package/dist/api/resources/store/types/ProductsStoreRequestSort.js +11 -0
- package/dist/api/resources/store/types/index.d.ts +4 -0
- package/dist/api/resources/store/types/index.js +4 -0
- package/dist/api/resources/usage/client/Client.d.ts +32 -0
- package/dist/api/resources/usage/client/Client.js +73 -0
- package/dist/api/resources/usage/client/index.d.ts +1 -0
- package/dist/api/resources/usage/client/index.js +1 -0
- package/dist/api/resources/usage/exports.d.ts +2 -0
- package/dist/api/resources/usage/exports.js +3 -0
- package/dist/api/resources/usage/index.d.ts +1 -0
- package/dist/api/resources/usage/index.js +1 -0
- package/dist/api/types/AllowanceError.d.ts +26 -0
- package/dist/api/types/AllowanceError.js +16 -0
- package/dist/api/types/Brand.d.ts +4 -0
- package/dist/api/types/Brand.js +2 -0
- package/dist/api/types/BrandListResponse.d.ts +6 -0
- package/dist/api/types/BrandListResponse.js +2 -0
- package/dist/api/types/BundleUsage.d.ts +15 -0
- package/dist/api/types/BundleUsage.js +2 -0
- package/dist/api/types/Category.d.ts +14 -0
- package/dist/api/types/Category.js +2 -0
- package/dist/api/types/CategoryItem.d.ts +4 -0
- package/dist/api/types/CategoryItem.js +2 -0
- package/dist/api/types/CategoryListResponse.d.ts +5 -0
- package/dist/api/types/CategoryListResponse.js +2 -0
- package/dist/api/types/CategoryPathItem.d.ts +4 -0
- package/dist/api/types/CategoryPathItem.js +2 -0
- package/dist/api/types/CategoryRanking.d.ts +5 -0
- package/dist/api/types/CategoryRanking.js +2 -0
- package/dist/api/types/CategoryRankingsResponse.d.ts +7 -0
- package/dist/api/types/CategoryRankingsResponse.js +2 -0
- package/dist/api/types/CategoryResponse.d.ts +4 -0
- package/dist/api/types/CategoryResponse.js +2 -0
- package/dist/api/types/CommissionBracket.d.ts +8 -0
- package/dist/api/types/CommissionBracket.js +2 -0
- package/dist/api/types/CurrentPeriod.d.ts +8 -0
- package/dist/api/types/CurrentPeriod.js +2 -0
- package/dist/api/types/Dimensions.d.ts +8 -0
- package/dist/api/types/Dimensions.js +2 -0
- package/dist/api/types/DistributionBucket.d.ts +5 -0
- package/dist/api/types/DistributionBucket.js +2 -0
- package/dist/api/types/DistributionData.d.ts +7 -0
- package/dist/api/types/DistributionData.js +2 -0
- package/dist/api/types/FreeTierUsage.d.ts +12 -0
- package/dist/api/types/FreeTierUsage.js +2 -0
- package/dist/api/types/KeywordItem.d.ts +6 -0
- package/dist/api/types/KeywordItem.js +2 -0
- package/dist/api/types/KeywordMarkets.d.ts +5 -0
- package/dist/api/types/KeywordMarkets.js +2 -0
- package/dist/api/types/KeywordMetrics.d.ts +4 -0
- package/dist/api/types/KeywordMetrics.js +2 -0
- package/dist/api/types/KeywordRanking.d.ts +7 -0
- package/dist/api/types/KeywordRanking.js +2 -0
- package/dist/api/types/KeywordRankingsResponse.d.ts +7 -0
- package/dist/api/types/KeywordRankingsResponse.js +2 -0
- package/dist/api/types/KeywordResponse.d.ts +7 -0
- package/dist/api/types/KeywordResponse.js +2 -0
- package/dist/api/types/ListingChanges.d.ts +5 -0
- package/dist/api/types/ListingChanges.js +2 -0
- package/dist/api/types/NicheDetail.d.ts +12 -0
- package/dist/api/types/NicheDetail.js +2 -0
- package/dist/api/types/NicheDetailResponse.d.ts +6 -0
- package/dist/api/types/NicheDetailResponse.js +2 -0
- package/dist/api/types/NicheDistributionsResponse.d.ts +5 -0
- package/dist/api/types/NicheDistributionsResponse.js +2 -0
- package/dist/api/types/NicheHistoryData.d.ts +4 -0
- package/dist/api/types/NicheHistoryData.js +2 -0
- package/dist/api/types/NicheHistoryResponse.d.ts +7 -0
- package/dist/api/types/NicheHistoryResponse.js +2 -0
- package/dist/api/types/NicheItem.d.ts +11 -0
- package/dist/api/types/NicheItem.js +2 -0
- package/dist/api/types/NicheListResponse.d.ts +7 -0
- package/dist/api/types/NicheListResponse.js +2 -0
- package/dist/api/types/NicheMarkets.d.ts +5 -0
- package/dist/api/types/NicheMarkets.js +2 -0
- package/dist/api/types/NicheMetrics.d.ts +5 -0
- package/dist/api/types/NicheMetrics.js +2 -0
- package/dist/api/types/NichePeriod.d.ts +5 -0
- package/dist/api/types/NichePeriod.js +2 -0
- package/dist/api/types/OauthScope.d.ts +9 -0
- package/dist/api/types/OauthScope.js +9 -0
- package/dist/api/types/Organization.d.ts +4 -0
- package/dist/api/types/Organization.js +2 -0
- package/dist/api/types/Pagination.d.ts +6 -0
- package/dist/api/types/Pagination.js +2 -0
- package/dist/api/types/Period.d.ts +5 -0
- package/dist/api/types/Period.js +2 -0
- package/dist/api/types/PeriodRatings.d.ts +7 -0
- package/dist/api/types/PeriodRatings.js +2 -0
- package/dist/api/types/PeriodReviews.d.ts +9 -0
- package/dist/api/types/PeriodReviews.js +2 -0
- package/dist/api/types/ProductDetail.d.ts +29 -0
- package/dist/api/types/ProductDetail.js +2 -0
- package/dist/api/types/ProductDetailResponse.d.ts +24 -0
- package/dist/api/types/ProductDetailResponse.js +14 -0
- package/dist/api/types/ProductDistributions.d.ts +6 -0
- package/dist/api/types/ProductDistributions.js +2 -0
- package/dist/api/types/ProductItem.d.ts +27 -0
- package/dist/api/types/ProductItem.js +2 -0
- package/dist/api/types/ProductListResponse.d.ts +25 -0
- package/dist/api/types/ProductListResponse.js +14 -0
- package/dist/api/types/ProductMarketMetrics.d.ts +11 -0
- package/dist/api/types/ProductMarketMetrics.js +2 -0
- package/dist/api/types/ProductMarkets.d.ts +5 -0
- package/dist/api/types/ProductMarkets.js +2 -0
- package/dist/api/types/PublicApiError.d.ts +4 -0
- package/dist/api/types/PublicApiError.js +2 -0
- package/dist/api/types/RankMarkets.d.ts +4 -0
- package/dist/api/types/RankMarkets.js +2 -0
- package/dist/api/types/RankPoint.d.ts +5 -0
- package/dist/api/types/RankPoint.js +2 -0
- package/dist/api/types/RatingCount.d.ts +5 -0
- package/dist/api/types/RatingCount.js +2 -0
- package/dist/api/types/ResearchError.d.ts +6 -0
- package/dist/api/types/ResearchError.js +2 -0
- package/dist/api/types/ReviewHistoryPoint.d.ts +6 -0
- package/dist/api/types/ReviewHistoryPoint.js +2 -0
- package/dist/api/types/ReviewItem.d.ts +12 -0
- package/dist/api/types/ReviewItem.js +2 -0
- package/dist/api/types/ReviewListResponse.d.ts +7 -0
- package/dist/api/types/ReviewListResponse.js +2 -0
- package/dist/api/types/ReviewSummary.d.ts +10 -0
- package/dist/api/types/ReviewSummary.js +2 -0
- package/dist/api/types/ReviewSummaryResponse.d.ts +5 -0
- package/dist/api/types/ReviewSummaryResponse.js +2 -0
- package/dist/api/types/ReviewTopic.d.ts +4 -0
- package/dist/api/types/ReviewTopic.js +2 -0
- package/dist/api/types/SalesHistoryMarkets.d.ts +5 -0
- package/dist/api/types/SalesHistoryMarkets.js +2 -0
- package/dist/api/types/SalesHistoryMetrics.d.ts +5 -0
- package/dist/api/types/SalesHistoryMetrics.js +2 -0
- package/dist/api/types/SalesHistoryPoint.d.ts +5 -0
- package/dist/api/types/SalesHistoryPoint.js +2 -0
- package/dist/api/types/SalesHistoryResponse.d.ts +7 -0
- package/dist/api/types/SalesHistoryResponse.js +2 -0
- package/dist/api/types/SellerItem.d.ts +8 -0
- package/dist/api/types/SellerItem.js +2 -0
- package/dist/api/types/SellerMarkets.d.ts +5 -0
- package/dist/api/types/SellerMarkets.js +2 -0
- package/dist/api/types/SellerMetrics.d.ts +7 -0
- package/dist/api/types/SellerMetrics.js +2 -0
- package/dist/api/types/SellerResponse.d.ts +9 -0
- package/dist/api/types/SellerResponse.js +2 -0
- package/dist/api/types/SellerSummaryMarkets.d.ts +5 -0
- package/dist/api/types/SellerSummaryMarkets.js +2 -0
- package/dist/api/types/SellerSummaryMetrics.d.ts +6 -0
- package/dist/api/types/SellerSummaryMetrics.js +2 -0
- package/dist/api/types/StoreChange.d.ts +9 -0
- package/dist/api/types/StoreChange.js +2 -0
- package/dist/api/types/StoreError.d.ts +5 -0
- package/dist/api/types/StoreError.js +2 -0
- package/dist/api/types/StoreFilters.d.ts +3 -0
- package/dist/api/types/StoreFilters.js +2 -0
- package/dist/api/types/StoreInventoryCounts.d.ts +7 -0
- package/dist/api/types/StoreInventoryCounts.js +2 -0
- package/dist/api/types/StoreInventoryFilters.d.ts +4 -0
- package/dist/api/types/StoreInventoryFilters.js +2 -0
- package/dist/api/types/StoreInventoryPagination.d.ts +7 -0
- package/dist/api/types/StoreInventoryPagination.js +2 -0
- package/dist/api/types/StoreInventoryResponse.d.ts +28 -0
- package/dist/api/types/StoreInventoryResponse.js +14 -0
- package/dist/api/types/StoreInventoryRow.d.ts +35 -0
- package/dist/api/types/StoreInventoryRow.js +18 -0
- package/dist/api/types/StoreKpi.d.ts +12 -0
- package/dist/api/types/StoreKpi.js +2 -0
- package/dist/api/types/StoreOverviewResponse.d.ts +13 -0
- package/dist/api/types/StoreOverviewResponse.js +2 -0
- package/dist/api/types/StorePerformanceProductPerformanceItem.d.ts +48 -0
- package/dist/api/types/StorePerformanceProductPerformanceItem.js +2 -0
- package/dist/api/types/StorePerformanceReturnCostsBreakdown.d.ts +10 -0
- package/dist/api/types/StorePerformanceReturnCostsBreakdown.js +2 -0
- package/dist/api/types/StorePerformanceSalesCostsBreakdown.d.ts +10 -0
- package/dist/api/types/StorePerformanceSalesCostsBreakdown.js +2 -0
- package/dist/api/types/StorePreviousKpi.d.ts +9 -0
- package/dist/api/types/StorePreviousKpi.js +2 -0
- package/dist/api/types/StoreProductsFilters.d.ts +5 -0
- package/dist/api/types/StoreProductsFilters.js +2 -0
- package/dist/api/types/StoreProductsPagination.d.ts +9 -0
- package/dist/api/types/StoreProductsPagination.js +2 -0
- package/dist/api/types/StoreProductsResponse.d.ts +11 -0
- package/dist/api/types/StoreProductsResponse.js +2 -0
- package/dist/api/types/UnauthorizedErrorBody.d.ts +3 -0
- package/dist/api/types/UnauthorizedErrorBody.js +2 -0
- package/dist/api/types/Usage.d.ts +51 -0
- package/dist/api/types/Usage.js +28 -0
- package/dist/api/types/UsageOrganization.d.ts +4 -0
- package/dist/api/types/UsageOrganization.js +2 -0
- package/dist/api/types/VisibilityHistoryResponse.d.ts +7 -0
- package/dist/api/types/VisibilityHistoryResponse.js +2 -0
- package/dist/api/types/VisibilityMarkets.d.ts +5 -0
- package/dist/api/types/VisibilityMarkets.js +2 -0
- package/dist/api/types/VisibilityMetrics.d.ts +4 -0
- package/dist/api/types/VisibilityMetrics.js +2 -0
- package/dist/api/types/VisibilityPoint.d.ts +5 -0
- package/dist/api/types/VisibilityPoint.js +2 -0
- package/dist/api/types/index.d.ts +92 -0
- package/dist/api/types/index.js +92 -0
- package/dist/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/auth/BearerAuthProvider.js +32 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +1 -0
- package/dist/core/auth/AuthProvider.d.ts +8 -0
- package/dist/core/auth/AuthProvider.js +6 -0
- package/dist/core/auth/AuthRequest.d.ts +9 -0
- package/dist/core/auth/AuthRequest.js +1 -0
- package/dist/core/auth/BasicAuth.d.ts +8 -0
- package/dist/core/auth/BasicAuth.js +29 -0
- package/dist/core/auth/BearerToken.d.ts +7 -0
- package/dist/core/auth/BearerToken.js +13 -0
- package/dist/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/core/auth/NoOpAuthProvider.js +5 -0
- package/dist/core/auth/index.d.ts +5 -0
- package/dist/core/auth/index.js +4 -0
- package/dist/core/base64.d.ts +2 -0
- package/dist/core/base64.js +22 -0
- package/dist/core/exports.d.ts +2 -0
- package/dist/core/exports.js +2 -0
- package/dist/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/core/fetcher/APIResponse.js +1 -0
- package/dist/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/core/fetcher/BinaryResponse.js +14 -0
- package/dist/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/core/fetcher/EndpointMetadata.js +1 -0
- package/dist/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/core/fetcher/EndpointSupplier.js +10 -0
- package/dist/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/core/fetcher/Fetcher.js +254 -0
- package/dist/core/fetcher/Headers.d.ts +2 -0
- package/dist/core/fetcher/Headers.js +83 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +90 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +40 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +10 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +5 -0
- package/dist/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getErrorResponseBody.js +43 -0
- package/dist/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/core/fetcher/getFetchFn.js +3 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +8 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +13 -0
- package/dist/core/fetcher/getResponseBody.d.ts +17 -0
- package/dist/core/fetcher/getResponseBody.js +70 -0
- package/dist/core/fetcher/index.d.ts +13 -0
- package/dist/core/fetcher/index.js +7 -0
- package/dist/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/core/fetcher/makePassthroughRequest.js +157 -0
- package/dist/core/fetcher/makeRequest.d.ts +11 -0
- package/dist/core/fetcher/makeRequest.js +85 -0
- package/dist/core/fetcher/redactUrl.d.ts +2 -0
- package/dist/core/fetcher/redactUrl.js +84 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +77 -0
- package/dist/core/fetcher/signals.d.ts +6 -0
- package/dist/core/fetcher/signals.js +28 -0
- package/dist/core/headers.d.ts +2 -0
- package/dist/core/headers.js +27 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +8 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +19 -0
- package/dist/core/logging/exports.d.ts +18 -0
- package/dist/core/logging/exports.js +9 -0
- package/dist/core/logging/index.d.ts +1 -0
- package/dist/core/logging/index.js +1 -0
- package/dist/core/logging/logger.d.ts +126 -0
- package/dist/core/logging/logger.js +140 -0
- package/dist/core/pagination/Page.d.ts +33 -0
- package/dist/core/pagination/Page.js +55 -0
- package/dist/core/pagination/exports.d.ts +1 -0
- package/dist/core/pagination/exports.js +1 -0
- package/dist/core/pagination/index.d.ts +1 -0
- package/dist/core/pagination/index.js +1 -0
- package/dist/core/requestBody.d.ts +12 -0
- package/dist/core/requestBody.js +23 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +1 -0
- package/dist/core/runtime/runtime.d.ts +28 -0
- package/dist/core/runtime/runtime.js +171 -0
- package/dist/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/core/url/QueryStringBuilder.js +78 -0
- package/dist/core/url/encodePathParam.d.ts +3 -0
- package/dist/core/url/encodePathParam.js +24 -0
- package/dist/core/url/index.d.ts +4 -0
- package/dist/core/url/index.js +4 -0
- package/dist/core/url/join.d.ts +1 -0
- package/dist/core/url/join.js +65 -0
- package/dist/core/url/qs.d.ts +7 -0
- package/dist/core/url/qs.js +76 -0
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/index.js +1 -0
- package/dist/core/utils/setObjectProperty.d.ts +12 -0
- package/dist/core/utils/setObjectProperty.js +45 -0
- package/dist/environments.d.ts +4 -0
- package/dist/environments.js +4 -0
- package/dist/errors/MarktMentorError.d.ts +15 -0
- package/dist/errors/MarktMentorError.js +52 -0
- package/dist/errors/MarktMentorTimeoutError.d.ts +6 -0
- package/dist/errors/MarktMentorTimeoutError.js +15 -0
- package/dist/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/errors/handleNonStatusCodeError.js +32 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +2 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/package.json +33 -4
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { base64Decode, base64Encode } from "../base64.js";
|
|
2
|
+
const BASIC_AUTH_HEADER_PREFIX = /^Basic /i;
|
|
3
|
+
export const BasicAuth = {
|
|
4
|
+
toAuthorizationHeader: (basicAuth) => {
|
|
5
|
+
if (basicAuth == null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
const username = basicAuth.username ?? "";
|
|
9
|
+
const password = basicAuth.password ?? "";
|
|
10
|
+
if (username === "" && password === "") {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const token = base64Encode(`${username}:${password}`);
|
|
14
|
+
return `Basic ${token}`;
|
|
15
|
+
},
|
|
16
|
+
fromAuthorizationHeader: (header) => {
|
|
17
|
+
const credentials = header.replace(BASIC_AUTH_HEADER_PREFIX, "");
|
|
18
|
+
const decoded = base64Decode(credentials);
|
|
19
|
+
const [username, ...passwordParts] = decoded.split(":");
|
|
20
|
+
const password = passwordParts.length > 0 ? passwordParts.join(":") : undefined;
|
|
21
|
+
if (username == null || password == null) {
|
|
22
|
+
throw new Error("Invalid basic auth");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
username,
|
|
26
|
+
password,
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type BearerToken = string;
|
|
2
|
+
declare function toAuthorizationHeader(token: string | undefined): string | undefined;
|
|
3
|
+
export declare const BearerToken: {
|
|
4
|
+
toAuthorizationHeader: typeof toAuthorizationHeader;
|
|
5
|
+
fromAuthorizationHeader: (header: string) => BearerToken;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const BEARER_AUTH_HEADER_PREFIX = /^Bearer /i;
|
|
2
|
+
function toAuthorizationHeader(token) {
|
|
3
|
+
if (token == null) {
|
|
4
|
+
return undefined;
|
|
5
|
+
}
|
|
6
|
+
return `Bearer ${token}`;
|
|
7
|
+
}
|
|
8
|
+
export const BearerToken = {
|
|
9
|
+
toAuthorizationHeader: toAuthorizationHeader,
|
|
10
|
+
fromAuthorizationHeader: (header) => {
|
|
11
|
+
return header.replace(BEARER_AUTH_HEADER_PREFIX, "").trim();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
|
|
2
|
+
export type { AuthRequest } from "./AuthRequest.js";
|
|
3
|
+
export { BasicAuth } from "./BasicAuth.js";
|
|
4
|
+
export { BearerToken } from "./BearerToken.js";
|
|
5
|
+
export { NoOpAuthProvider } from "./NoOpAuthProvider.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function base64ToBytes(base64) {
|
|
2
|
+
const binString = atob(base64);
|
|
3
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
4
|
+
}
|
|
5
|
+
function bytesToBase64(bytes) {
|
|
6
|
+
const binString = String.fromCodePoint(...bytes);
|
|
7
|
+
return btoa(binString);
|
|
8
|
+
}
|
|
9
|
+
export function base64Encode(input) {
|
|
10
|
+
if (typeof Buffer !== "undefined") {
|
|
11
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
12
|
+
}
|
|
13
|
+
const bytes = new TextEncoder().encode(input);
|
|
14
|
+
return bytesToBase64(bytes);
|
|
15
|
+
}
|
|
16
|
+
export function base64Decode(input) {
|
|
17
|
+
if (typeof Buffer !== "undefined") {
|
|
18
|
+
return Buffer.from(input, "base64").toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
const bytes = base64ToBytes(input);
|
|
21
|
+
return new TextDecoder().decode(bytes);
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RawResponse } from "./RawResponse.js";
|
|
2
|
+
/**
|
|
3
|
+
* The response of an API call.
|
|
4
|
+
* It is a successful response or a failed response.
|
|
5
|
+
*/
|
|
6
|
+
export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
|
|
7
|
+
export interface SuccessfulResponse<T> {
|
|
8
|
+
ok: true;
|
|
9
|
+
body: T;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `rawResponse` instead
|
|
12
|
+
*/
|
|
13
|
+
headers?: Record<string, any>;
|
|
14
|
+
rawResponse: RawResponse;
|
|
15
|
+
}
|
|
16
|
+
export interface FailedResponse<T> {
|
|
17
|
+
ok: false;
|
|
18
|
+
error: T;
|
|
19
|
+
rawResponse: RawResponse;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BinaryResponse = {
|
|
2
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
3
|
+
bodyUsed: Response["bodyUsed"];
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ReadableStream of the response body.
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
7
|
+
*/
|
|
8
|
+
stream: () => Response["body"];
|
|
9
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
10
|
+
arrayBuffer: () => ReturnType<Response["arrayBuffer"]>;
|
|
11
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
12
|
+
blob: () => ReturnType<Response["blob"]>;
|
|
13
|
+
/**
|
|
14
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
|
+
* Some versions of the Fetch API may not support this method.
|
|
16
|
+
*/
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
|
+
};
|
|
19
|
+
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function getBinaryResponse(response) {
|
|
2
|
+
const binaryResponse = {
|
|
3
|
+
get bodyUsed() {
|
|
4
|
+
return response.bodyUsed;
|
|
5
|
+
},
|
|
6
|
+
stream: () => response.body,
|
|
7
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
8
|
+
blob: response.blob.bind(response),
|
|
9
|
+
};
|
|
10
|
+
if ("bytes" in response && typeof response.bytes === "function") {
|
|
11
|
+
binaryResponse.bytes = response.bytes.bind(response);
|
|
12
|
+
}
|
|
13
|
+
return binaryResponse;
|
|
14
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SecuritySchemeKey = string;
|
|
2
|
+
/**
|
|
3
|
+
* A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
|
|
4
|
+
* All schemes in the collection must be satisfied for authentication to be successful.
|
|
5
|
+
*/
|
|
6
|
+
export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
|
|
7
|
+
export type AuthScope = string;
|
|
8
|
+
export type EndpointMetadata = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of security scheme collections. Each collection represents an alternative way to authenticate.
|
|
11
|
+
*/
|
|
12
|
+
security?: SecuritySchemeCollection[];
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
2
|
+
import type { Supplier } from "./Supplier.js";
|
|
3
|
+
type EndpointSupplierFn<T> = (arg: {
|
|
4
|
+
endpointMetadata?: EndpointMetadata;
|
|
5
|
+
}) => T | Promise<T>;
|
|
6
|
+
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
7
|
+
export declare const EndpointSupplier: {
|
|
8
|
+
get: <T>(supplier: EndpointSupplier<T>, arg: {
|
|
9
|
+
endpointMetadata?: EndpointMetadata;
|
|
10
|
+
}) => Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
2
|
+
import type { APIResponse } from "./APIResponse.js";
|
|
3
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
4
|
+
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
5
|
+
export declare namespace Fetcher {
|
|
6
|
+
interface Args {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `queryString` (produced by `core.url.queryBuilder()`).
|
|
13
|
+
* Retained for backwards compatibility with custom fetchers and callers that
|
|
14
|
+
* still construct request args with a query-parameter object.
|
|
15
|
+
*/
|
|
16
|
+
queryParameters?: Record<string, unknown>;
|
|
17
|
+
queryString?: string;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
requestType?: "json" | "file" | "bytes" | "form" | "other";
|
|
24
|
+
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
25
|
+
duplex?: "half";
|
|
26
|
+
endpointMetadata?: EndpointMetadata;
|
|
27
|
+
fetchFn?: typeof fetch;
|
|
28
|
+
logging?: LogConfig | Logger;
|
|
29
|
+
}
|
|
30
|
+
type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError;
|
|
31
|
+
interface FailedStatusCodeError {
|
|
32
|
+
reason: "status-code";
|
|
33
|
+
statusCode: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface NonJsonError {
|
|
37
|
+
reason: "non-json";
|
|
38
|
+
statusCode: number;
|
|
39
|
+
rawBody: string;
|
|
40
|
+
}
|
|
41
|
+
interface BodyIsNullError {
|
|
42
|
+
reason: "body-is-null";
|
|
43
|
+
statusCode: number;
|
|
44
|
+
}
|
|
45
|
+
interface TimeoutError {
|
|
46
|
+
reason: "timeout";
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface UnknownError {
|
|
50
|
+
reason: "unknown";
|
|
51
|
+
errorMessage: string;
|
|
52
|
+
cause?: unknown;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
56
|
+
export declare const fetcher: FetchFunction;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { toJson } from "../json.js";
|
|
2
|
+
import { createLogger } from "../logging/logger.js";
|
|
3
|
+
import { createRequestUrl } from "./createRequestUrl.js";
|
|
4
|
+
import { EndpointSupplier } from "./EndpointSupplier.js";
|
|
5
|
+
import { getErrorResponseBody } from "./getErrorResponseBody.js";
|
|
6
|
+
import { getFetchFn } from "./getFetchFn.js";
|
|
7
|
+
import { getRequestBody } from "./getRequestBody.js";
|
|
8
|
+
import { getResponseBody, isResponseBodyError } from "./getResponseBody.js";
|
|
9
|
+
import { Headers } from "./Headers.js";
|
|
10
|
+
import { clearResponseTimeout, makeRequest } from "./makeRequest.js";
|
|
11
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
12
|
+
import { redactUrl, SENSITIVE_QUERY_PARAMS } from "./redactUrl.js";
|
|
13
|
+
import { requestWithRetries } from "./requestWithRetries.js";
|
|
14
|
+
import { TIMEOUT } from "./signals.js";
|
|
15
|
+
const SENSITIVE_HEADERS = new Set([
|
|
16
|
+
"authorization",
|
|
17
|
+
"www-authenticate",
|
|
18
|
+
"x-api-key",
|
|
19
|
+
"api-key",
|
|
20
|
+
"apikey",
|
|
21
|
+
"x-api-token",
|
|
22
|
+
"x-auth-token",
|
|
23
|
+
"auth-token",
|
|
24
|
+
"cookie",
|
|
25
|
+
"set-cookie",
|
|
26
|
+
"proxy-authorization",
|
|
27
|
+
"proxy-authenticate",
|
|
28
|
+
"x-csrf-token",
|
|
29
|
+
"x-xsrf-token",
|
|
30
|
+
"x-session-token",
|
|
31
|
+
"x-access-token",
|
|
32
|
+
]);
|
|
33
|
+
function redactHeaders(headers) {
|
|
34
|
+
const filtered = {};
|
|
35
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
36
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
37
|
+
filtered[key] = "[REDACTED]";
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
filtered[key] = value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return filtered;
|
|
44
|
+
}
|
|
45
|
+
function redactQueryParameters(queryParameters) {
|
|
46
|
+
if (queryParameters == null) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
const redacted = {};
|
|
50
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
51
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
52
|
+
}
|
|
53
|
+
return redacted;
|
|
54
|
+
}
|
|
55
|
+
async function getHeaders(args) {
|
|
56
|
+
const newHeaders = new Headers();
|
|
57
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
58
|
+
? "application/json"
|
|
59
|
+
: args.responseType === "text"
|
|
60
|
+
? "text/plain"
|
|
61
|
+
: args.responseType === "sse"
|
|
62
|
+
? "text/event-stream"
|
|
63
|
+
: "*/*");
|
|
64
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
65
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
66
|
+
}
|
|
67
|
+
if (args.headers == null) {
|
|
68
|
+
return newHeaders;
|
|
69
|
+
}
|
|
70
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
71
|
+
const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} });
|
|
72
|
+
if (typeof result === "string") {
|
|
73
|
+
newHeaders.set(key, result);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (result == null) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
newHeaders.set(key, `${result}`);
|
|
80
|
+
}
|
|
81
|
+
return newHeaders;
|
|
82
|
+
}
|
|
83
|
+
function isJsonContentType(contentType) {
|
|
84
|
+
const mediaType = contentType?.split(";")[0]?.trim().toLowerCase() ?? "";
|
|
85
|
+
return mediaType === "application/json" || mediaType === "text/json" || mediaType.endsWith("+json");
|
|
86
|
+
}
|
|
87
|
+
export async function fetcherImpl(args) {
|
|
88
|
+
let url = args.url;
|
|
89
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
90
|
+
url = `${url}?${args.queryString}`;
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
94
|
+
}
|
|
95
|
+
const requestBody = await getRequestBody({
|
|
96
|
+
body: args.body,
|
|
97
|
+
type: args.requestType ?? "other",
|
|
98
|
+
});
|
|
99
|
+
const fetchFn = args.fetchFn ?? (await getFetchFn());
|
|
100
|
+
const headers = await getHeaders(args);
|
|
101
|
+
const logger = createLogger(args.logging);
|
|
102
|
+
if (logger.isDebug()) {
|
|
103
|
+
const metadata = {
|
|
104
|
+
method: args.method,
|
|
105
|
+
url: redactUrl(url),
|
|
106
|
+
headers: redactHeaders(headers),
|
|
107
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
108
|
+
hasBody: requestBody != null,
|
|
109
|
+
};
|
|
110
|
+
logger.debug("Making HTTP request", metadata);
|
|
111
|
+
}
|
|
112
|
+
// Bodies that are read in full here stay covered by the timeout; streamed bodies are read by the caller.
|
|
113
|
+
const keepTimeoutUntilBodyRead = args.responseType !== "streaming" && args.responseType !== "sse" && args.responseType !== "binary-response";
|
|
114
|
+
const attemptResponses = [];
|
|
115
|
+
try {
|
|
116
|
+
const response = await requestWithRetries(async () => {
|
|
117
|
+
// A retry means the previous attempt is over; stop its timer now rather than at the end.
|
|
118
|
+
for (const previousResponse of attemptResponses) {
|
|
119
|
+
clearResponseTimeout(previousResponse);
|
|
120
|
+
}
|
|
121
|
+
const attemptResponse = await makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse", keepTimeoutUntilBodyRead);
|
|
122
|
+
attemptResponses.push(attemptResponse);
|
|
123
|
+
return attemptResponse;
|
|
124
|
+
}, args.maxRetries, args.abortSignal);
|
|
125
|
+
if (response.status >= 200 && response.status < 400) {
|
|
126
|
+
if (logger.isDebug()) {
|
|
127
|
+
const metadata = {
|
|
128
|
+
method: args.method,
|
|
129
|
+
url: redactUrl(url),
|
|
130
|
+
statusCode: response.status,
|
|
131
|
+
responseHeaders: redactHeaders(response.headers),
|
|
132
|
+
};
|
|
133
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
134
|
+
}
|
|
135
|
+
const body = await getResponseBody(response, args.responseType);
|
|
136
|
+
// Only a body the server labelled as JSON is an error here; void endpoints may return plain text.
|
|
137
|
+
if (isResponseBodyError(body) &&
|
|
138
|
+
body.error.reason === "non-json" &&
|
|
139
|
+
isJsonContentType(response.headers.get("Content-Type"))) {
|
|
140
|
+
return {
|
|
141
|
+
ok: false,
|
|
142
|
+
error: body.error,
|
|
143
|
+
rawResponse: toRawResponse(response),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
ok: true,
|
|
148
|
+
body: body,
|
|
149
|
+
headers: response.headers,
|
|
150
|
+
rawResponse: toRawResponse(response),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (logger.isError()) {
|
|
155
|
+
const metadata = {
|
|
156
|
+
method: args.method,
|
|
157
|
+
url: redactUrl(url),
|
|
158
|
+
statusCode: response.status,
|
|
159
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
160
|
+
};
|
|
161
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
162
|
+
}
|
|
163
|
+
return {
|
|
164
|
+
ok: false,
|
|
165
|
+
error: {
|
|
166
|
+
reason: "status-code",
|
|
167
|
+
statusCode: response.status,
|
|
168
|
+
body: await getErrorResponseBody(response),
|
|
169
|
+
},
|
|
170
|
+
rawResponse: toRawResponse(response),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
if (args.abortSignal?.aborted) {
|
|
176
|
+
if (logger.isError()) {
|
|
177
|
+
const metadata = {
|
|
178
|
+
method: args.method,
|
|
179
|
+
url: redactUrl(url),
|
|
180
|
+
};
|
|
181
|
+
logger.error("HTTP request was aborted", metadata);
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
ok: false,
|
|
185
|
+
error: {
|
|
186
|
+
reason: "unknown",
|
|
187
|
+
errorMessage: "The user aborted a request",
|
|
188
|
+
cause: error,
|
|
189
|
+
},
|
|
190
|
+
rawResponse: abortRawResponse,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
else if (error === TIMEOUT || (error instanceof Error && error.name === "AbortError")) {
|
|
194
|
+
if (logger.isError()) {
|
|
195
|
+
const metadata = {
|
|
196
|
+
method: args.method,
|
|
197
|
+
url: redactUrl(url),
|
|
198
|
+
timeoutMs: args.timeoutMs,
|
|
199
|
+
};
|
|
200
|
+
logger.error("HTTP request timed out", metadata);
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
ok: false,
|
|
204
|
+
error: {
|
|
205
|
+
reason: "timeout",
|
|
206
|
+
cause: error,
|
|
207
|
+
},
|
|
208
|
+
rawResponse: abortRawResponse,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
else if (error instanceof Error) {
|
|
212
|
+
if (logger.isError()) {
|
|
213
|
+
const metadata = {
|
|
214
|
+
method: args.method,
|
|
215
|
+
url: redactUrl(url),
|
|
216
|
+
errorMessage: error.message,
|
|
217
|
+
};
|
|
218
|
+
logger.error("HTTP request failed with error", metadata);
|
|
219
|
+
}
|
|
220
|
+
return {
|
|
221
|
+
ok: false,
|
|
222
|
+
error: {
|
|
223
|
+
reason: "unknown",
|
|
224
|
+
errorMessage: error.message,
|
|
225
|
+
cause: error,
|
|
226
|
+
},
|
|
227
|
+
rawResponse: unknownRawResponse,
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
if (logger.isError()) {
|
|
231
|
+
const metadata = {
|
|
232
|
+
method: args.method,
|
|
233
|
+
url: redactUrl(url),
|
|
234
|
+
error: toJson(error),
|
|
235
|
+
};
|
|
236
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
237
|
+
}
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
error: {
|
|
241
|
+
reason: "unknown",
|
|
242
|
+
errorMessage: toJson(error),
|
|
243
|
+
cause: error,
|
|
244
|
+
},
|
|
245
|
+
rawResponse: unknownRawResponse,
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
for (const attemptResponse of attemptResponses) {
|
|
250
|
+
clearResponseTimeout(attemptResponse);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
export const fetcher = fetcherImpl;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
let Headers;
|
|
2
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
3
|
+
Headers = globalThis.Headers;
|
|
4
|
+
}
|
|
5
|
+
else {
|
|
6
|
+
Headers = class Headers {
|
|
7
|
+
headers;
|
|
8
|
+
constructor(init) {
|
|
9
|
+
this.headers = new Map();
|
|
10
|
+
if (init) {
|
|
11
|
+
if (init instanceof Headers) {
|
|
12
|
+
init.forEach((value, key) => this.append(key, value));
|
|
13
|
+
}
|
|
14
|
+
else if (Array.isArray(init)) {
|
|
15
|
+
for (const [key, value] of init) {
|
|
16
|
+
if (typeof key === "string" && typeof value === "string") {
|
|
17
|
+
this.append(key, value);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const [key, value] of Object.entries(init)) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
this.append(key, value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new TypeError("Header values must be strings");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
append(name, value) {
|
|
37
|
+
const key = name.toLowerCase();
|
|
38
|
+
const existing = this.headers.get(key) || [];
|
|
39
|
+
this.headers.set(key, [...existing, value]);
|
|
40
|
+
}
|
|
41
|
+
delete(name) {
|
|
42
|
+
const key = name.toLowerCase();
|
|
43
|
+
this.headers.delete(key);
|
|
44
|
+
}
|
|
45
|
+
get(name) {
|
|
46
|
+
const key = name.toLowerCase();
|
|
47
|
+
const values = this.headers.get(key);
|
|
48
|
+
return values ? values.join(", ") : null;
|
|
49
|
+
}
|
|
50
|
+
has(name) {
|
|
51
|
+
const key = name.toLowerCase();
|
|
52
|
+
return this.headers.has(key);
|
|
53
|
+
}
|
|
54
|
+
set(name, value) {
|
|
55
|
+
const key = name.toLowerCase();
|
|
56
|
+
this.headers.set(key, [value]);
|
|
57
|
+
}
|
|
58
|
+
forEach(callbackfn, thisArg) {
|
|
59
|
+
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
60
|
+
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
61
|
+
}
|
|
62
|
+
getSetCookie() {
|
|
63
|
+
return this.headers.get("set-cookie") || [];
|
|
64
|
+
}
|
|
65
|
+
*entries() {
|
|
66
|
+
for (const [key, values] of this.headers.entries()) {
|
|
67
|
+
yield [key, values.join(", ")];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
*keys() {
|
|
71
|
+
yield* this.headers.keys();
|
|
72
|
+
}
|
|
73
|
+
*values() {
|
|
74
|
+
for (const values of this.headers.values()) {
|
|
75
|
+
yield values.join(", ");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
[Symbol.iterator]() {
|
|
79
|
+
return this.entries();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export { Headers };
|