ce-storefront 0.13.2 → 0.14.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/README.md +35 -28
- package/docs/sdks/catalog/README.md +7 -5
- package/esm/funcs/authGenerateOtp.d.ts +3 -2
- package/esm/funcs/authGenerateOtp.d.ts.map +1 -1
- package/esm/funcs/authGenerateOtp.js +1 -1
- package/esm/funcs/authGenerateOtp.js.map +1 -1
- package/esm/funcs/authGetAnonymousToken.d.ts +3 -2
- package/esm/funcs/authGetAnonymousToken.d.ts.map +1 -1
- package/esm/funcs/authGetAnonymousToken.js +1 -1
- package/esm/funcs/authGetAnonymousToken.js.map +1 -1
- package/esm/funcs/authGetUserDetail.d.ts +3 -2
- package/esm/funcs/authGetUserDetail.d.ts.map +1 -1
- package/esm/funcs/authGetUserDetail.js +1 -1
- package/esm/funcs/authGetUserDetail.js.map +1 -1
- package/esm/funcs/authLoginWithEmail.d.ts +3 -2
- package/esm/funcs/authLoginWithEmail.d.ts.map +1 -1
- package/esm/funcs/authLoginWithEmail.js +1 -1
- package/esm/funcs/authLoginWithEmail.js.map +1 -1
- package/esm/funcs/authLoginWithPhone.d.ts +3 -2
- package/esm/funcs/authLoginWithPhone.d.ts.map +1 -1
- package/esm/funcs/authLoginWithPhone.js +1 -1
- package/esm/funcs/authLoginWithPhone.js.map +1 -1
- package/esm/funcs/authLoginWithWhatsapp.d.ts +3 -2
- package/esm/funcs/authLoginWithWhatsapp.d.ts.map +1 -1
- package/esm/funcs/authLoginWithWhatsapp.js +1 -1
- package/esm/funcs/authLoginWithWhatsapp.js.map +1 -1
- package/esm/funcs/authLogout.d.ts +3 -2
- package/esm/funcs/authLogout.d.ts.map +1 -1
- package/esm/funcs/authLogout.js +1 -1
- package/esm/funcs/authLogout.js.map +1 -1
- package/esm/funcs/authRefreshToken.d.ts +3 -2
- package/esm/funcs/authRefreshToken.d.ts.map +1 -1
- package/esm/funcs/authRefreshToken.js +1 -1
- package/esm/funcs/authRefreshToken.js.map +1 -1
- package/esm/funcs/authUpdateUser.d.ts +3 -2
- package/esm/funcs/authUpdateUser.d.ts.map +1 -1
- package/esm/funcs/authUpdateUser.js +1 -1
- package/esm/funcs/authUpdateUser.js.map +1 -1
- package/esm/funcs/authVerifyOtp.d.ts +3 -2
- package/esm/funcs/authVerifyOtp.d.ts.map +1 -1
- package/esm/funcs/authVerifyOtp.js +1 -1
- package/esm/funcs/authVerifyOtp.js.map +1 -1
- package/esm/funcs/cartsAddShippingMethod.d.ts +3 -2
- package/esm/funcs/cartsAddShippingMethod.d.ts.map +1 -1
- package/esm/funcs/cartsAddShippingMethod.js +1 -1
- package/esm/funcs/cartsAddShippingMethod.js.map +1 -1
- package/esm/funcs/cartsApplyCoupon.d.ts +3 -2
- package/esm/funcs/cartsApplyCoupon.d.ts.map +1 -1
- package/esm/funcs/cartsApplyCoupon.js +1 -1
- package/esm/funcs/cartsApplyCoupon.js.map +1 -1
- package/esm/funcs/cartsCreateCart.d.ts +3 -2
- package/esm/funcs/cartsCreateCart.d.ts.map +1 -1
- package/esm/funcs/cartsCreateCart.js +1 -1
- package/esm/funcs/cartsCreateCart.js.map +1 -1
- package/esm/funcs/cartsCreateCartAddress.d.ts +3 -2
- package/esm/funcs/cartsCreateCartAddress.d.ts.map +1 -1
- package/esm/funcs/cartsCreateCartAddress.js +1 -1
- package/esm/funcs/cartsCreateCartAddress.js.map +1 -1
- package/esm/funcs/cartsDeleteCart.d.ts +3 -2
- package/esm/funcs/cartsDeleteCart.d.ts.map +1 -1
- package/esm/funcs/cartsDeleteCart.js +1 -1
- package/esm/funcs/cartsDeleteCart.js.map +1 -1
- package/esm/funcs/cartsGetCart.d.ts +3 -2
- package/esm/funcs/cartsGetCart.d.ts.map +1 -1
- package/esm/funcs/cartsGetCart.js +1 -1
- package/esm/funcs/cartsGetCart.js.map +1 -1
- package/esm/funcs/cartsGetUserCart.d.ts +3 -2
- package/esm/funcs/cartsGetUserCart.d.ts.map +1 -1
- package/esm/funcs/cartsGetUserCart.js +1 -1
- package/esm/funcs/cartsGetUserCart.js.map +1 -1
- package/esm/funcs/cartsRedeemLoyaltyPoints.d.ts +3 -2
- package/esm/funcs/cartsRedeemLoyaltyPoints.d.ts.map +1 -1
- package/esm/funcs/cartsRedeemLoyaltyPoints.js +1 -1
- package/esm/funcs/cartsRedeemLoyaltyPoints.js.map +1 -1
- package/esm/funcs/cartsRemoveCoupon.d.ts +3 -2
- package/esm/funcs/cartsRemoveCoupon.d.ts.map +1 -1
- package/esm/funcs/cartsRemoveCoupon.js +1 -1
- package/esm/funcs/cartsRemoveCoupon.js.map +1 -1
- package/esm/funcs/cartsRemoveLoyaltyPoints.d.ts +3 -2
- package/esm/funcs/cartsRemoveLoyaltyPoints.d.ts.map +1 -1
- package/esm/funcs/cartsRemoveLoyaltyPoints.js +1 -1
- package/esm/funcs/cartsRemoveLoyaltyPoints.js.map +1 -1
- package/esm/funcs/cartsRemoveUserCart.d.ts +3 -2
- package/esm/funcs/cartsRemoveUserCart.d.ts.map +1 -1
- package/esm/funcs/cartsRemoveUserCart.js +1 -1
- package/esm/funcs/cartsRemoveUserCart.js.map +1 -1
- package/esm/funcs/cartsUpdateCart.d.ts +3 -2
- package/esm/funcs/cartsUpdateCart.d.ts.map +1 -1
- package/esm/funcs/cartsUpdateCart.js +1 -1
- package/esm/funcs/cartsUpdateCart.js.map +1 -1
- package/esm/funcs/catalogGetProductDetail.d.ts +4 -3
- package/esm/funcs/catalogGetProductDetail.d.ts.map +1 -1
- package/esm/funcs/catalogGetProductDetail.js +4 -7
- package/esm/funcs/catalogGetProductDetail.js.map +1 -1
- package/esm/funcs/catalogGetVariantDetail.d.ts +3 -2
- package/esm/funcs/catalogGetVariantDetail.d.ts.map +1 -1
- package/esm/funcs/catalogGetVariantDetail.js +1 -1
- package/esm/funcs/catalogGetVariantDetail.js.map +1 -1
- package/esm/funcs/catalogListCategories.d.ts +3 -2
- package/esm/funcs/catalogListCategories.d.ts.map +1 -1
- package/esm/funcs/catalogListCategories.js +2 -1
- package/esm/funcs/catalogListCategories.js.map +1 -1
- package/esm/funcs/catalogListCrosssellProducts.d.ts +3 -2
- package/esm/funcs/catalogListCrosssellProducts.d.ts.map +1 -1
- package/esm/funcs/catalogListCrosssellProducts.js +1 -1
- package/esm/funcs/catalogListCrosssellProducts.js.map +1 -1
- package/esm/funcs/catalogListProductReviews.d.ts +3 -2
- package/esm/funcs/catalogListProductReviews.d.ts.map +1 -1
- package/esm/funcs/catalogListProductReviews.js +1 -1
- package/esm/funcs/catalogListProductReviews.js.map +1 -1
- package/esm/funcs/catalogListProductVariants.d.ts +3 -2
- package/esm/funcs/catalogListProductVariants.d.ts.map +1 -1
- package/esm/funcs/catalogListProductVariants.js +1 -1
- package/esm/funcs/catalogListProductVariants.js.map +1 -1
- package/esm/funcs/catalogListProducts.d.ts +3 -2
- package/esm/funcs/catalogListProducts.d.ts.map +1 -1
- package/esm/funcs/catalogListProducts.js +2 -1
- package/esm/funcs/catalogListProducts.js.map +1 -1
- package/esm/funcs/catalogListSimilarProducts.d.ts +3 -2
- package/esm/funcs/catalogListSimilarProducts.d.ts.map +1 -1
- package/esm/funcs/catalogListSimilarProducts.js +1 -1
- package/esm/funcs/catalogListSimilarProducts.js.map +1 -1
- package/esm/funcs/catalogListSkus.d.ts +3 -2
- package/esm/funcs/catalogListSkus.d.ts.map +1 -1
- package/esm/funcs/catalogListSkus.js +1 -1
- package/esm/funcs/catalogListSkus.js.map +1 -1
- package/esm/funcs/catalogListUpsellProducts.d.ts +3 -2
- package/esm/funcs/catalogListUpsellProducts.d.ts.map +1 -1
- package/esm/funcs/catalogListUpsellProducts.js +1 -1
- package/esm/funcs/catalogListUpsellProducts.js.map +1 -1
- package/esm/funcs/catalogSearchProducts.d.ts +3 -2
- package/esm/funcs/catalogSearchProducts.d.ts.map +1 -1
- package/esm/funcs/catalogSearchProducts.js +1 -1
- package/esm/funcs/catalogSearchProducts.js.map +1 -1
- package/esm/funcs/commonListCountryPincodes.d.ts +3 -2
- package/esm/funcs/commonListCountryPincodes.d.ts.map +1 -1
- package/esm/funcs/commonListCountryPincodes.js +1 -1
- package/esm/funcs/commonListCountryPincodes.js.map +1 -1
- package/esm/funcs/customersCreateAddress.d.ts +3 -2
- package/esm/funcs/customersCreateAddress.d.ts.map +1 -1
- package/esm/funcs/customersCreateAddress.js +1 -1
- package/esm/funcs/customersCreateAddress.js.map +1 -1
- package/esm/funcs/customersDeleteAddress.d.ts +3 -2
- package/esm/funcs/customersDeleteAddress.d.ts.map +1 -1
- package/esm/funcs/customersDeleteAddress.js +1 -1
- package/esm/funcs/customersDeleteAddress.js.map +1 -1
- package/esm/funcs/customersGetAddressDetail.d.ts +3 -2
- package/esm/funcs/customersGetAddressDetail.d.ts.map +1 -1
- package/esm/funcs/customersGetAddressDetail.js +1 -1
- package/esm/funcs/customersGetAddressDetail.js.map +1 -1
- package/esm/funcs/customersGetLoyaltyDetails.d.ts +3 -2
- package/esm/funcs/customersGetLoyaltyDetails.d.ts.map +1 -1
- package/esm/funcs/customersGetLoyaltyDetails.js +1 -1
- package/esm/funcs/customersGetLoyaltyDetails.js.map +1 -1
- package/esm/funcs/customersListAddresses.d.ts +3 -2
- package/esm/funcs/customersListAddresses.d.ts.map +1 -1
- package/esm/funcs/customersListAddresses.js +1 -1
- package/esm/funcs/customersListAddresses.js.map +1 -1
- package/esm/funcs/customersListUserReviews.d.ts +3 -2
- package/esm/funcs/customersListUserReviews.d.ts.map +1 -1
- package/esm/funcs/customersListUserReviews.js +1 -1
- package/esm/funcs/customersListUserReviews.js.map +1 -1
- package/esm/funcs/customersUpdateAddressDetail.d.ts +3 -2
- package/esm/funcs/customersUpdateAddressDetail.d.ts.map +1 -1
- package/esm/funcs/customersUpdateAddressDetail.js +1 -1
- package/esm/funcs/customersUpdateAddressDetail.js.map +1 -1
- package/esm/funcs/ordersCancelOrder.d.ts +3 -2
- package/esm/funcs/ordersCancelOrder.d.ts.map +1 -1
- package/esm/funcs/ordersCancelOrder.js +1 -1
- package/esm/funcs/ordersCancelOrder.js.map +1 -1
- package/esm/funcs/ordersCreateOrder.d.ts +3 -2
- package/esm/funcs/ordersCreateOrder.d.ts.map +1 -1
- package/esm/funcs/ordersCreateOrder.js +1 -1
- package/esm/funcs/ordersCreateOrder.js.map +1 -1
- package/esm/funcs/ordersGetOrderDetail.d.ts +3 -2
- package/esm/funcs/ordersGetOrderDetail.d.ts.map +1 -1
- package/esm/funcs/ordersGetOrderDetail.js +1 -1
- package/esm/funcs/ordersGetOrderDetail.js.map +1 -1
- package/esm/funcs/ordersGetPaymentStatus.d.ts +3 -2
- package/esm/funcs/ordersGetPaymentStatus.d.ts.map +1 -1
- package/esm/funcs/ordersGetPaymentStatus.js +1 -1
- package/esm/funcs/ordersGetPaymentStatus.js.map +1 -1
- package/esm/funcs/ordersListOrderShipments.d.ts +3 -2
- package/esm/funcs/ordersListOrderShipments.d.ts.map +1 -1
- package/esm/funcs/ordersListOrderShipments.js +1 -1
- package/esm/funcs/ordersListOrderShipments.js.map +1 -1
- package/esm/funcs/ordersListOrders.d.ts +3 -2
- package/esm/funcs/ordersListOrders.d.ts.map +1 -1
- package/esm/funcs/ordersListOrders.js +1 -1
- package/esm/funcs/ordersListOrders.js.map +1 -1
- package/esm/funcs/ordersRetryOrderPayment.d.ts +3 -2
- package/esm/funcs/ordersRetryOrderPayment.d.ts.map +1 -1
- package/esm/funcs/ordersRetryOrderPayment.js +1 -1
- package/esm/funcs/ordersRetryOrderPayment.js.map +1 -1
- package/esm/funcs/shippingShippingMethods.d.ts +3 -2
- package/esm/funcs/shippingShippingMethods.d.ts.map +1 -1
- package/esm/funcs/shippingShippingMethods.js +1 -1
- package/esm/funcs/shippingShippingMethods.js.map +1 -1
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/matchers.d.ts +3 -10
- package/esm/lib/matchers.d.ts.map +1 -1
- package/esm/lib/matchers.js +33 -30
- package/esm/lib/matchers.js.map +1 -1
- package/esm/models/components/product.d.ts +3 -0
- package/esm/models/components/product.d.ts.map +1 -1
- package/esm/models/components/product.js +3 -0
- package/esm/models/components/product.js.map +1 -1
- package/esm/models/components/productdetail.d.ts +3 -0
- package/esm/models/components/productdetail.d.ts.map +1 -1
- package/esm/models/components/productdetail.js +3 -0
- package/esm/models/components/productdetail.js.map +1 -1
- package/esm/models/components/productreview.d.ts +1 -10
- package/esm/models/components/productreview.d.ts.map +1 -1
- package/esm/models/components/productreview.js +2 -5
- package/esm/models/components/productreview.js.map +1 -1
- package/esm/models/errors/badrequest.d.ts +7 -2
- package/esm/models/errors/badrequest.d.ts.map +1 -1
- package/esm/models/errors/badrequest.js +12 -4
- package/esm/models/errors/badrequest.js.map +1 -1
- package/esm/models/errors/ceerror.d.ts +8 -18
- package/esm/models/errors/ceerror.d.ts.map +1 -1
- package/esm/models/errors/ceerror.js +17 -10
- package/esm/models/errors/ceerror.js.map +1 -1
- package/esm/models/errors/cestorefronterror.d.ts +19 -0
- package/esm/models/errors/cestorefronterror.d.ts.map +1 -0
- package/esm/models/errors/cestorefronterror.js +16 -0
- package/esm/models/errors/cestorefronterror.js.map +1 -0
- package/esm/models/errors/index.d.ts +1 -0
- package/esm/models/errors/index.d.ts.map +1 -1
- package/esm/models/errors/index.js +1 -0
- package/esm/models/errors/index.js.map +1 -1
- package/esm/models/errors/notfound.d.ts +7 -2
- package/esm/models/errors/notfound.d.ts.map +1 -1
- package/esm/models/errors/notfound.js +12 -4
- package/esm/models/errors/notfound.js.map +1 -1
- package/esm/models/errors/responsevalidationerror.d.ts +26 -0
- package/esm/models/errors/responsevalidationerror.d.ts.map +1 -0
- package/esm/models/errors/responsevalidationerror.js +29 -0
- package/esm/models/errors/responsevalidationerror.js.map +1 -0
- package/esm/models/errors/sdkvalidationerror.d.ts +1 -0
- package/esm/models/errors/sdkvalidationerror.d.ts.map +1 -1
- package/esm/models/errors/sdkvalidationerror.js +14 -0
- package/esm/models/errors/sdkvalidationerror.js.map +1 -1
- package/esm/models/errors/unauthorized.d.ts +7 -2
- package/esm/models/errors/unauthorized.d.ts.map +1 -1
- package/esm/models/errors/unauthorized.js +12 -4
- package/esm/models/errors/unauthorized.js.map +1 -1
- package/esm/models/operations/getproductdetail.d.ts +3 -3
- package/esm/models/operations/getproductdetail.d.ts.map +1 -1
- package/esm/models/operations/getproductdetail.js +4 -4
- package/esm/models/operations/getproductdetail.js.map +1 -1
- package/esm/models/operations/listcategories.d.ts +6 -1
- package/esm/models/operations/listcategories.d.ts.map +1 -1
- package/esm/models/operations/listcategories.js +4 -0
- package/esm/models/operations/listcategories.js.map +1 -1
- package/esm/models/operations/listproducts.d.ts +6 -1
- package/esm/models/operations/listproducts.d.ts.map +1 -1
- package/esm/models/operations/listproducts.js +4 -0
- package/esm/models/operations/listproducts.js.map +1 -1
- package/esm/sdk/catalog.d.ts +1 -1
- package/esm/sdk/catalog.js +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/authGenerateOtp.ts +21 -17
- package/src/funcs/authGetAnonymousToken.ts +21 -17
- package/src/funcs/authGetUserDetail.ts +21 -17
- package/src/funcs/authLoginWithEmail.ts +21 -17
- package/src/funcs/authLoginWithPhone.ts +21 -17
- package/src/funcs/authLoginWithWhatsapp.ts +21 -17
- package/src/funcs/authLogout.ts +21 -17
- package/src/funcs/authRefreshToken.ts +21 -17
- package/src/funcs/authUpdateUser.ts +21 -17
- package/src/funcs/authVerifyOtp.ts +21 -17
- package/src/funcs/cartsAddShippingMethod.ts +21 -17
- package/src/funcs/cartsApplyCoupon.ts +21 -17
- package/src/funcs/cartsCreateCart.ts +21 -17
- package/src/funcs/cartsCreateCartAddress.ts +21 -17
- package/src/funcs/cartsDeleteCart.ts +21 -17
- package/src/funcs/cartsGetCart.ts +21 -17
- package/src/funcs/cartsGetUserCart.ts +21 -17
- package/src/funcs/cartsRedeemLoyaltyPoints.ts +21 -17
- package/src/funcs/cartsRemoveCoupon.ts +21 -17
- package/src/funcs/cartsRemoveLoyaltyPoints.ts +21 -17
- package/src/funcs/cartsRemoveUserCart.ts +21 -17
- package/src/funcs/cartsUpdateCart.ts +21 -17
- package/src/funcs/catalogGetProductDetail.ts +28 -23
- package/src/funcs/catalogGetVariantDetail.ts +21 -17
- package/src/funcs/catalogListCategories.ts +22 -17
- package/src/funcs/catalogListCrosssellProducts.ts +21 -17
- package/src/funcs/catalogListProductReviews.ts +21 -17
- package/src/funcs/catalogListProductVariants.ts +21 -17
- package/src/funcs/catalogListProducts.ts +22 -17
- package/src/funcs/catalogListSimilarProducts.ts +21 -17
- package/src/funcs/catalogListSkus.ts +21 -17
- package/src/funcs/catalogListUpsellProducts.ts +21 -17
- package/src/funcs/catalogSearchProducts.ts +21 -17
- package/src/funcs/commonListCountryPincodes.ts +21 -17
- package/src/funcs/customersCreateAddress.ts +21 -17
- package/src/funcs/customersDeleteAddress.ts +21 -17
- package/src/funcs/customersGetAddressDetail.ts +21 -17
- package/src/funcs/customersGetLoyaltyDetails.ts +21 -17
- package/src/funcs/customersListAddresses.ts +21 -17
- package/src/funcs/customersListUserReviews.ts +21 -17
- package/src/funcs/customersUpdateAddressDetail.ts +21 -17
- package/src/funcs/ordersCancelOrder.ts +21 -17
- package/src/funcs/ordersCreateOrder.ts +21 -17
- package/src/funcs/ordersGetOrderDetail.ts +21 -17
- package/src/funcs/ordersGetPaymentStatus.ts +21 -17
- package/src/funcs/ordersListOrderShipments.ts +21 -17
- package/src/funcs/ordersListOrders.ts +21 -17
- package/src/funcs/ordersRetryOrderPayment.ts +21 -17
- package/src/funcs/shippingShippingMethods.ts +21 -17
- package/src/lib/config.ts +3 -3
- package/src/lib/matchers.ts +44 -41
- package/src/models/components/product.ts +10 -0
- package/src/models/components/productdetail.ts +10 -0
- package/src/models/components/productreview.ts +3 -6
- package/src/models/errors/badrequest.ts +15 -5
- package/src/models/errors/ceerror.ts +23 -31
- package/src/models/errors/cestorefronterror.ts +35 -0
- package/src/models/errors/index.ts +1 -0
- package/src/models/errors/notfound.ts +15 -5
- package/src/models/errors/responsevalidationerror.ts +50 -0
- package/src/models/errors/sdkvalidationerror.ts +12 -0
- package/src/models/errors/unauthorized.ts +15 -5
- package/src/models/operations/getproductdetail.ts +7 -7
- package/src/models/operations/listcategories.ts +10 -1
- package/src/models/operations/listproducts.ts +10 -1
- package/src/sdk/catalog.ts +1 -1
|
@@ -10,7 +10,7 @@ import { safeParse } from "../lib/schemas.js";
|
|
|
10
10
|
import { RequestOptions } from "../lib/sdks.js";
|
|
11
11
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
12
|
import { pathToFunc } from "../lib/url.js";
|
|
13
|
-
import {
|
|
13
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
14
14
|
import {
|
|
15
15
|
ConnectionError,
|
|
16
16
|
InvalidRequestError,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
UnexpectedClientError,
|
|
20
20
|
} from "../models/errors/httpclienterrors.js";
|
|
21
21
|
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
22
23
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
24
|
import * as operations from "../models/operations/index.js";
|
|
24
25
|
import { APICall, APIPromise } from "../types/async.js";
|
|
@@ -40,13 +41,14 @@ export function ordersRetryOrderPayment(
|
|
|
40
41
|
| errors.BadRequest
|
|
41
42
|
| errors.Unauthorized
|
|
42
43
|
| errors.NotFound
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
| InvalidRequestError
|
|
44
|
+
| CeStorefrontError
|
|
45
|
+
| ResponseValidationError
|
|
46
|
+
| ConnectionError
|
|
47
47
|
| RequestAbortedError
|
|
48
48
|
| RequestTimeoutError
|
|
49
|
-
|
|
|
49
|
+
| InvalidRequestError
|
|
50
|
+
| UnexpectedClientError
|
|
51
|
+
| SDKValidationError
|
|
50
52
|
>
|
|
51
53
|
> {
|
|
52
54
|
return new APIPromise($do(
|
|
@@ -67,13 +69,14 @@ async function $do(
|
|
|
67
69
|
| errors.BadRequest
|
|
68
70
|
| errors.Unauthorized
|
|
69
71
|
| errors.NotFound
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
| InvalidRequestError
|
|
72
|
+
| CeStorefrontError
|
|
73
|
+
| ResponseValidationError
|
|
74
|
+
| ConnectionError
|
|
74
75
|
| RequestAbortedError
|
|
75
76
|
| RequestTimeoutError
|
|
76
|
-
|
|
|
77
|
+
| InvalidRequestError
|
|
78
|
+
| UnexpectedClientError
|
|
79
|
+
| SDKValidationError
|
|
77
80
|
>,
|
|
78
81
|
APICall,
|
|
79
82
|
]
|
|
@@ -157,13 +160,14 @@ async function $do(
|
|
|
157
160
|
| errors.BadRequest
|
|
158
161
|
| errors.Unauthorized
|
|
159
162
|
| errors.NotFound
|
|
160
|
-
|
|
|
161
|
-
|
|
|
162
|
-
|
|
|
163
|
-
| InvalidRequestError
|
|
163
|
+
| CeStorefrontError
|
|
164
|
+
| ResponseValidationError
|
|
165
|
+
| ConnectionError
|
|
164
166
|
| RequestAbortedError
|
|
165
167
|
| RequestTimeoutError
|
|
166
|
-
|
|
|
168
|
+
| InvalidRequestError
|
|
169
|
+
| UnexpectedClientError
|
|
170
|
+
| SDKValidationError
|
|
167
171
|
>(
|
|
168
172
|
M.json(200, operations.RetryOrderPaymentResponseBody$inboundSchema),
|
|
169
173
|
M.jsonErr(400, errors.BadRequest$inboundSchema),
|
|
@@ -171,7 +175,7 @@ async function $do(
|
|
|
171
175
|
M.jsonErr(404, errors.NotFound$inboundSchema),
|
|
172
176
|
M.fail("4XX"),
|
|
173
177
|
M.fail("5XX"),
|
|
174
|
-
)(response, { extraFields: responseFields });
|
|
178
|
+
)(response, req, { extraFields: responseFields });
|
|
175
179
|
if (!result.ok) {
|
|
176
180
|
return [result, { status: "complete", request: req, response }];
|
|
177
181
|
}
|
|
@@ -11,7 +11,7 @@ import { RequestOptions } from "../lib/sdks.js";
|
|
|
11
11
|
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
12
|
import { pathToFunc } from "../lib/url.js";
|
|
13
13
|
import * as components from "../models/components/index.js";
|
|
14
|
-
import {
|
|
14
|
+
import { CeStorefrontError } from "../models/errors/cestorefronterror.js";
|
|
15
15
|
import {
|
|
16
16
|
ConnectionError,
|
|
17
17
|
InvalidRequestError,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
UnexpectedClientError,
|
|
21
21
|
} from "../models/errors/httpclienterrors.js";
|
|
22
22
|
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
24
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
25
|
import * as operations from "../models/operations/index.js";
|
|
25
26
|
import { APICall, APIPromise } from "../types/async.js";
|
|
@@ -41,13 +42,14 @@ export function shippingShippingMethods(
|
|
|
41
42
|
| errors.BadRequest
|
|
42
43
|
| errors.Unauthorized
|
|
43
44
|
| errors.NotFound
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
| InvalidRequestError
|
|
45
|
+
| CeStorefrontError
|
|
46
|
+
| ResponseValidationError
|
|
47
|
+
| ConnectionError
|
|
48
48
|
| RequestAbortedError
|
|
49
49
|
| RequestTimeoutError
|
|
50
|
-
|
|
|
50
|
+
| InvalidRequestError
|
|
51
|
+
| UnexpectedClientError
|
|
52
|
+
| SDKValidationError
|
|
51
53
|
>
|
|
52
54
|
> {
|
|
53
55
|
return new APIPromise($do(
|
|
@@ -68,13 +70,14 @@ async function $do(
|
|
|
68
70
|
| errors.BadRequest
|
|
69
71
|
| errors.Unauthorized
|
|
70
72
|
| errors.NotFound
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
| InvalidRequestError
|
|
73
|
+
| CeStorefrontError
|
|
74
|
+
| ResponseValidationError
|
|
75
|
+
| ConnectionError
|
|
75
76
|
| RequestAbortedError
|
|
76
77
|
| RequestTimeoutError
|
|
77
|
-
|
|
|
78
|
+
| InvalidRequestError
|
|
79
|
+
| UnexpectedClientError
|
|
80
|
+
| SDKValidationError
|
|
78
81
|
>,
|
|
79
82
|
APICall,
|
|
80
83
|
]
|
|
@@ -152,13 +155,14 @@ async function $do(
|
|
|
152
155
|
| errors.BadRequest
|
|
153
156
|
| errors.Unauthorized
|
|
154
157
|
| errors.NotFound
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
| InvalidRequestError
|
|
158
|
+
| CeStorefrontError
|
|
159
|
+
| ResponseValidationError
|
|
160
|
+
| ConnectionError
|
|
159
161
|
| RequestAbortedError
|
|
160
162
|
| RequestTimeoutError
|
|
161
|
-
|
|
|
163
|
+
| InvalidRequestError
|
|
164
|
+
| UnexpectedClientError
|
|
165
|
+
| SDKValidationError
|
|
162
166
|
>(
|
|
163
167
|
M.json(200, operations.GetShippingMethodsResponseBody$inboundSchema),
|
|
164
168
|
M.jsonErr(400, errors.BadRequest$inboundSchema),
|
|
@@ -166,7 +170,7 @@ async function $do(
|
|
|
166
170
|
M.jsonErr(404, errors.NotFound$inboundSchema),
|
|
167
171
|
M.fail("4XX"),
|
|
168
172
|
M.fail("5XX"),
|
|
169
|
-
)(response, { extraFields: responseFields });
|
|
173
|
+
)(response, req, { extraFields: responseFields });
|
|
170
174
|
if (!result.ok) {
|
|
171
175
|
return [result, { status: "complete", request: req, response }];
|
|
172
176
|
}
|
package/src/lib/config.ts
CHANGED
|
@@ -80,7 +80,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
80
80
|
export const SDK_METADATA = {
|
|
81
81
|
language: "typescript",
|
|
82
82
|
openapiDocVersion: "1.0",
|
|
83
|
-
sdkVersion: "0.
|
|
84
|
-
genVersion: "2.
|
|
85
|
-
userAgent: "speakeasy-sdk/typescript 0.
|
|
83
|
+
sdkVersion: "0.14.0",
|
|
84
|
+
genVersion: "2.623.0",
|
|
85
|
+
userAgent: "speakeasy-sdk/typescript 0.14.0 2.623.0 1.0 ce-storefront",
|
|
86
86
|
} as const;
|
package/src/lib/matchers.ts
CHANGED
|
@@ -3,11 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { CeError } from "../models/errors/ceerror.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Result } from "../types/fp.js";
|
|
6
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
7
|
+
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
9
|
import { isPlainObject } from "./is-plain-object.js";
|
|
10
|
-
import { safeParse } from "./schemas.js";
|
|
11
10
|
|
|
12
11
|
export type Encoding =
|
|
13
12
|
| "jsonl"
|
|
@@ -176,17 +175,19 @@ export type MatchedError<Matchers> = Matchers extends Matcher<any, infer E>[]
|
|
|
176
175
|
: never;
|
|
177
176
|
export type MatchFunc<T, E> = (
|
|
178
177
|
response: Response,
|
|
178
|
+
request: Request,
|
|
179
179
|
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
180
180
|
) => Promise<[result: Result<T, E>, raw: unknown]>;
|
|
181
181
|
|
|
182
182
|
export function match<T, E>(
|
|
183
183
|
...matchers: Array<Matcher<T, E>>
|
|
184
|
-
): MatchFunc<T, E | CeError |
|
|
184
|
+
): MatchFunc<T, E | CeError | ResponseValidationError> {
|
|
185
185
|
return async function matchFunc(
|
|
186
186
|
response: Response,
|
|
187
|
+
request: Request,
|
|
187
188
|
options?: { resultKey?: string; extraFields?: Record<string, unknown> },
|
|
188
189
|
): Promise<
|
|
189
|
-
[result: Result<T, E | CeError |
|
|
190
|
+
[result: Result<T, E | CeError | ResponseValidationError>, raw: unknown]
|
|
190
191
|
> {
|
|
191
192
|
let raw: unknown;
|
|
192
193
|
let matcher: Matcher<T, E> | undefined;
|
|
@@ -205,21 +206,22 @@ export function match<T, E>(
|
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
if (!matcher) {
|
|
208
|
-
const responseBody = await response.text();
|
|
209
209
|
return [{
|
|
210
210
|
ok: false,
|
|
211
|
-
error: new CeError(
|
|
212
|
-
"Unexpected API response status or content-type",
|
|
211
|
+
error: new CeError("Unexpected Status or Content-Type", {
|
|
213
212
|
response,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
213
|
+
request,
|
|
214
|
+
body: await response.text().catch(() => ""),
|
|
215
|
+
}),
|
|
216
|
+
}, raw];
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
const encoding = matcher.enc;
|
|
220
|
+
let body = "";
|
|
220
221
|
switch (encoding) {
|
|
221
222
|
case "json":
|
|
222
|
-
|
|
223
|
+
body = await response.text();
|
|
224
|
+
raw = JSON.parse(body);
|
|
223
225
|
break;
|
|
224
226
|
case "jsonl":
|
|
225
227
|
raw = response.body;
|
|
@@ -231,16 +233,19 @@ export function match<T, E>(
|
|
|
231
233
|
raw = response.body;
|
|
232
234
|
break;
|
|
233
235
|
case "text":
|
|
234
|
-
|
|
236
|
+
body = await response.text();
|
|
237
|
+
raw = body;
|
|
235
238
|
break;
|
|
236
239
|
case "sse":
|
|
237
240
|
raw = response.body;
|
|
238
241
|
break;
|
|
239
242
|
case "nil":
|
|
240
|
-
|
|
243
|
+
body = await response.text();
|
|
244
|
+
raw = undefined;
|
|
241
245
|
break;
|
|
242
246
|
case "fail":
|
|
243
|
-
|
|
247
|
+
body = await response.text();
|
|
248
|
+
raw = body;
|
|
244
249
|
break;
|
|
245
250
|
default:
|
|
246
251
|
encoding satisfies never;
|
|
@@ -250,11 +255,7 @@ export function match<T, E>(
|
|
|
250
255
|
if (matcher.enc === "fail") {
|
|
251
256
|
return [{
|
|
252
257
|
ok: false,
|
|
253
|
-
error: new CeError(
|
|
254
|
-
"API error occurred",
|
|
255
|
-
response,
|
|
256
|
-
typeof raw === "string" ? raw : "",
|
|
257
|
-
),
|
|
258
|
+
error: new CeError("API error occurred", { request, response, body }),
|
|
258
259
|
}, raw];
|
|
259
260
|
}
|
|
260
261
|
|
|
@@ -266,6 +267,9 @@ export function match<T, E>(
|
|
|
266
267
|
...options?.extraFields,
|
|
267
268
|
...(matcher.hdrs ? { Headers: unpackHeaders(response.headers) } : null),
|
|
268
269
|
...(isPlainObject(raw) ? raw : null),
|
|
270
|
+
request$: request,
|
|
271
|
+
response$: response,
|
|
272
|
+
body$: body,
|
|
269
273
|
};
|
|
270
274
|
} else if (resultKey) {
|
|
271
275
|
data = {
|
|
@@ -284,18 +288,20 @@ export function match<T, E>(
|
|
|
284
288
|
}
|
|
285
289
|
|
|
286
290
|
if ("err" in matcher) {
|
|
287
|
-
const result =
|
|
291
|
+
const result = safeParseResponse(
|
|
288
292
|
data,
|
|
289
293
|
(v: unknown) => matcher.schema.parse(v),
|
|
290
294
|
"Response validation failed",
|
|
295
|
+
{ request, response, body },
|
|
291
296
|
);
|
|
292
297
|
return [result.ok ? { ok: false, error: result.value } : result, raw];
|
|
293
298
|
} else {
|
|
294
299
|
return [
|
|
295
|
-
|
|
300
|
+
safeParseResponse(
|
|
296
301
|
data,
|
|
297
302
|
(v: unknown) => matcher.schema.parse(v),
|
|
298
303
|
"Response validation failed",
|
|
304
|
+
{ request, response, body },
|
|
299
305
|
),
|
|
300
306
|
raw,
|
|
301
307
|
];
|
|
@@ -318,25 +324,22 @@ export function unpackHeaders(headers: Headers): Record<string, string[]> {
|
|
|
318
324
|
return out;
|
|
319
325
|
}
|
|
320
326
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
export async function discardResponseBody(res: Response) {
|
|
328
|
-
const reader = res.body?.getReader();
|
|
329
|
-
if (reader == null) {
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
|
|
327
|
+
function safeParseResponse<Inp, Out>(
|
|
328
|
+
rawValue: Inp,
|
|
329
|
+
fn: (value: Inp) => Out,
|
|
330
|
+
errorMessage: string,
|
|
331
|
+
httpMeta: { response: Response; request: Request; body: string },
|
|
332
|
+
): Result<Out, ResponseValidationError> {
|
|
333
333
|
try {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
334
|
+
return OK(fn(rawValue));
|
|
335
|
+
} catch (err) {
|
|
336
|
+
return ERR(
|
|
337
|
+
new ResponseValidationError(errorMessage, {
|
|
338
|
+
cause: err,
|
|
339
|
+
rawValue,
|
|
340
|
+
rawMessage: errorMessage,
|
|
341
|
+
...httpMeta,
|
|
342
|
+
}),
|
|
343
|
+
);
|
|
341
344
|
}
|
|
342
345
|
}
|
|
@@ -8,6 +8,12 @@ import { safeParse } from "../../lib/schemas.js";
|
|
|
8
8
|
import { ClosedEnum } from "../../types/enums.js";
|
|
9
9
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
10
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
import {
|
|
12
|
+
Category,
|
|
13
|
+
Category$inboundSchema,
|
|
14
|
+
Category$Outbound,
|
|
15
|
+
Category$outboundSchema,
|
|
16
|
+
} from "./category.js";
|
|
11
17
|
import {
|
|
12
18
|
ProductAttribute,
|
|
13
19
|
ProductAttribute$inboundSchema,
|
|
@@ -101,6 +107,7 @@ export type Product = {
|
|
|
101
107
|
hasVariant: boolean;
|
|
102
108
|
tags: Array<string> | null;
|
|
103
109
|
categoryIds: Array<string>;
|
|
110
|
+
categories: Array<Category>;
|
|
104
111
|
reviewsRatingSum: number;
|
|
105
112
|
reviewsCount: number;
|
|
106
113
|
attributes: Array<ProductAttribute>;
|
|
@@ -153,6 +160,7 @@ export const Product$inboundSchema: z.ZodType<Product, z.ZodTypeDef, unknown> =
|
|
|
153
160
|
has_variant: z.boolean(),
|
|
154
161
|
tags: z.nullable(z.array(z.string())),
|
|
155
162
|
category_ids: z.array(z.string()),
|
|
163
|
+
categories: z.array(Category$inboundSchema),
|
|
156
164
|
reviews_rating_sum: z.number(),
|
|
157
165
|
reviews_count: z.number().int(),
|
|
158
166
|
attributes: z.array(ProductAttribute$inboundSchema),
|
|
@@ -197,6 +205,7 @@ export type Product$Outbound = {
|
|
|
197
205
|
has_variant: boolean;
|
|
198
206
|
tags: Array<string> | null;
|
|
199
207
|
category_ids: Array<string>;
|
|
208
|
+
categories: Array<Category$Outbound>;
|
|
200
209
|
reviews_rating_sum: number;
|
|
201
210
|
reviews_count: number;
|
|
202
211
|
attributes: Array<ProductAttribute$Outbound>;
|
|
@@ -230,6 +239,7 @@ export const Product$outboundSchema: z.ZodType<
|
|
|
230
239
|
hasVariant: z.boolean(),
|
|
231
240
|
tags: z.nullable(z.array(z.string())),
|
|
232
241
|
categoryIds: z.array(z.string()),
|
|
242
|
+
categories: z.array(Category$outboundSchema),
|
|
233
243
|
reviewsRatingSum: z.number(),
|
|
234
244
|
reviewsCount: z.number().int(),
|
|
235
245
|
attributes: z.array(ProductAttribute$outboundSchema),
|
|
@@ -8,6 +8,12 @@ import { safeParse } from "../../lib/schemas.js";
|
|
|
8
8
|
import { ClosedEnum } from "../../types/enums.js";
|
|
9
9
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
10
10
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
import {
|
|
12
|
+
Category,
|
|
13
|
+
Category$inboundSchema,
|
|
14
|
+
Category$Outbound,
|
|
15
|
+
Category$outboundSchema,
|
|
16
|
+
} from "./category.js";
|
|
11
17
|
import {
|
|
12
18
|
ProductAttribute,
|
|
13
19
|
ProductAttribute$inboundSchema,
|
|
@@ -121,6 +127,7 @@ export type ProductDetail = {
|
|
|
121
127
|
hasVariant: boolean;
|
|
122
128
|
tags: Array<string> | null;
|
|
123
129
|
categoryIds: Array<string>;
|
|
130
|
+
categories: Array<Category>;
|
|
124
131
|
reviewsRatingSum: number;
|
|
125
132
|
reviewsCount: number;
|
|
126
133
|
attributes: Array<ProductAttribute>;
|
|
@@ -192,6 +199,7 @@ export const ProductDetail$inboundSchema: z.ZodType<
|
|
|
192
199
|
has_variant: z.boolean(),
|
|
193
200
|
tags: z.nullable(z.array(z.string())),
|
|
194
201
|
category_ids: z.array(z.string()),
|
|
202
|
+
categories: z.array(Category$inboundSchema),
|
|
195
203
|
reviews_rating_sum: z.number(),
|
|
196
204
|
reviews_count: z.number().int(),
|
|
197
205
|
attributes: z.array(ProductAttribute$inboundSchema),
|
|
@@ -247,6 +255,7 @@ export type ProductDetail$Outbound = {
|
|
|
247
255
|
has_variant: boolean;
|
|
248
256
|
tags: Array<string> | null;
|
|
249
257
|
category_ids: Array<string>;
|
|
258
|
+
categories: Array<Category$Outbound>;
|
|
250
259
|
reviews_rating_sum: number;
|
|
251
260
|
reviews_count: number;
|
|
252
261
|
attributes: Array<ProductAttribute$Outbound>;
|
|
@@ -288,6 +297,7 @@ export const ProductDetail$outboundSchema: z.ZodType<
|
|
|
288
297
|
hasVariant: z.boolean(),
|
|
289
298
|
tags: z.nullable(z.array(z.string())),
|
|
290
299
|
categoryIds: z.array(z.string()),
|
|
300
|
+
categories: z.array(Category$outboundSchema),
|
|
291
301
|
reviewsRatingSum: z.number(),
|
|
292
302
|
reviewsCount: z.number().int(),
|
|
293
303
|
attributes: z.array(ProductAttribute$outboundSchema),
|
|
@@ -14,9 +14,6 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
|
14
14
|
*/
|
|
15
15
|
export const Status = {
|
|
16
16
|
Approved: "approved",
|
|
17
|
-
Rejected: "rejected",
|
|
18
|
-
Archived: "archived",
|
|
19
|
-
Pending: "pending",
|
|
20
17
|
} as const;
|
|
21
18
|
/**
|
|
22
19
|
* Reviews with approved status will be displayed.
|
|
@@ -303,7 +300,7 @@ export const ProductReview$inboundSchema: z.ZodType<
|
|
|
303
300
|
review_text: z.string().optional(),
|
|
304
301
|
name: z.string().optional(),
|
|
305
302
|
email: z.string().optional(),
|
|
306
|
-
status: Status$inboundSchema.
|
|
303
|
+
status: Status$inboundSchema.optional(),
|
|
307
304
|
is_featured: z.boolean().default(false),
|
|
308
305
|
tags: z.array(z.string()).optional(),
|
|
309
306
|
review_date: z.string().datetime({ offset: true }).transform(v => new Date(v))
|
|
@@ -330,7 +327,7 @@ export type ProductReview$Outbound = {
|
|
|
330
327
|
review_text?: string | undefined;
|
|
331
328
|
name?: string | undefined;
|
|
332
329
|
email?: string | undefined;
|
|
333
|
-
status
|
|
330
|
+
status?: string | undefined;
|
|
334
331
|
is_featured: boolean;
|
|
335
332
|
tags?: Array<string> | undefined;
|
|
336
333
|
review_date?: string | undefined;
|
|
@@ -350,7 +347,7 @@ export const ProductReview$outboundSchema: z.ZodType<
|
|
|
350
347
|
reviewText: z.string().optional(),
|
|
351
348
|
name: z.string().optional(),
|
|
352
349
|
email: z.string().optional(),
|
|
353
|
-
status: Status$outboundSchema.
|
|
350
|
+
status: Status$outboundSchema.optional(),
|
|
354
351
|
isFeatured: z.boolean().default(false),
|
|
355
352
|
tags: z.array(z.string()).optional(),
|
|
356
353
|
reviewDate: z.date().transform(v => v.toISOString()).optional(),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import * as z from "zod";
|
|
6
6
|
import { safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { CeStorefrontError } from "./cestorefronterror.js";
|
|
8
9
|
import { SDKValidationError } from "./sdkvalidationerror.js";
|
|
9
10
|
|
|
10
11
|
export type ErrorT = {
|
|
@@ -24,7 +25,7 @@ export type BadRequestData = {
|
|
|
24
25
|
/**
|
|
25
26
|
* Bad request
|
|
26
27
|
*/
|
|
27
|
-
export class BadRequest extends
|
|
28
|
+
export class BadRequest extends CeStorefrontError {
|
|
28
29
|
success: boolean;
|
|
29
30
|
code: string;
|
|
30
31
|
error?: ErrorT | undefined;
|
|
@@ -32,11 +33,13 @@ export class BadRequest extends Error {
|
|
|
32
33
|
/** The original data that was passed to this error instance. */
|
|
33
34
|
data$: BadRequestData;
|
|
34
35
|
|
|
35
|
-
constructor(
|
|
36
|
+
constructor(
|
|
37
|
+
err: BadRequestData,
|
|
38
|
+
httpMeta: { response: Response; request: Request; body: string },
|
|
39
|
+
) {
|
|
36
40
|
const message = err.message || "API error occurred";
|
|
37
|
-
super(message);
|
|
41
|
+
super(message, httpMeta);
|
|
38
42
|
this.data$ = err;
|
|
39
|
-
|
|
40
43
|
this.success = err.success;
|
|
41
44
|
this.code = err.code;
|
|
42
45
|
if (err.error != null) this.error = err.error;
|
|
@@ -102,9 +105,16 @@ export const BadRequest$inboundSchema: z.ZodType<
|
|
|
102
105
|
success: z.boolean(),
|
|
103
106
|
code: z.string(),
|
|
104
107
|
error: z.lazy(() => ErrorT$inboundSchema).optional(),
|
|
108
|
+
request$: z.instanceof(Request),
|
|
109
|
+
response$: z.instanceof(Response),
|
|
110
|
+
body$: z.string(),
|
|
105
111
|
})
|
|
106
112
|
.transform((v) => {
|
|
107
|
-
return new BadRequest(v
|
|
113
|
+
return new BadRequest(v, {
|
|
114
|
+
request: v.request$,
|
|
115
|
+
response: v.response$,
|
|
116
|
+
body: v.body$,
|
|
117
|
+
});
|
|
108
118
|
});
|
|
109
119
|
|
|
110
120
|
/** @internal */
|
|
@@ -2,41 +2,33 @@
|
|
|
2
2
|
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* HTTP status code
|
|
8
|
-
*/
|
|
9
|
-
public readonly statusCode: number;
|
|
10
|
-
/**
|
|
11
|
-
* HTTP content type
|
|
12
|
-
*/
|
|
13
|
-
public readonly contentType: string;
|
|
14
|
-
/**
|
|
15
|
-
* HTTP body
|
|
16
|
-
*/
|
|
17
|
-
public readonly body: string;
|
|
18
|
-
/**
|
|
19
|
-
* Raw response
|
|
20
|
-
*/
|
|
21
|
-
public readonly rawResponse: Response;
|
|
5
|
+
import { CeStorefrontError } from "./cestorefronterror.js";
|
|
22
6
|
|
|
7
|
+
/** The fallback error class if no more specific error class is matched */
|
|
8
|
+
export class CeError extends CeStorefrontError {
|
|
23
9
|
constructor(
|
|
24
10
|
message: string,
|
|
25
|
-
|
|
26
|
-
|
|
11
|
+
httpMeta: {
|
|
12
|
+
response: Response;
|
|
13
|
+
request: Request;
|
|
14
|
+
body: string;
|
|
15
|
+
},
|
|
27
16
|
) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
17
|
+
if (message) {
|
|
18
|
+
message += `: `;
|
|
19
|
+
}
|
|
20
|
+
message += `Status ${httpMeta.response.status}`;
|
|
21
|
+
const contentType = httpMeta.response.headers.get("content-type") || `""`;
|
|
22
|
+
if (contentType !== "application/json") {
|
|
23
|
+
message += ` Content-Type ${
|
|
24
|
+
contentType.includes(" ") ? `"${contentType}"` : contentType
|
|
25
|
+
}`;
|
|
26
|
+
}
|
|
27
|
+
const body = httpMeta.body || `""`;
|
|
28
|
+
message += body.length > 100 ? "\n" : " ";
|
|
29
|
+
message += `Body ${body}`;
|
|
30
|
+
message = message.trim();
|
|
31
|
+
super(message, httpMeta);
|
|
40
32
|
this.name = "CeError";
|
|
41
33
|
}
|
|
42
34
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** The base class for all HTTP error responses */
|
|
6
|
+
export class CeStorefrontError extends Error {
|
|
7
|
+
/** HTTP status code */
|
|
8
|
+
public readonly statusCode: number;
|
|
9
|
+
/** HTTP body */
|
|
10
|
+
public readonly body: string;
|
|
11
|
+
/** HTTP headers */
|
|
12
|
+
public readonly headers: Headers;
|
|
13
|
+
/** HTTP content type */
|
|
14
|
+
public readonly contentType: string;
|
|
15
|
+
/** Raw response */
|
|
16
|
+
public readonly rawResponse: Response;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
message: string,
|
|
20
|
+
httpMeta: {
|
|
21
|
+
response: Response;
|
|
22
|
+
request: Request;
|
|
23
|
+
body: string;
|
|
24
|
+
},
|
|
25
|
+
) {
|
|
26
|
+
super(message);
|
|
27
|
+
this.statusCode = httpMeta.response.status;
|
|
28
|
+
this.body = httpMeta.body;
|
|
29
|
+
this.headers = httpMeta.response.headers;
|
|
30
|
+
this.contentType = httpMeta.response.headers.get("content-type") || "";
|
|
31
|
+
this.rawResponse = httpMeta.response;
|
|
32
|
+
|
|
33
|
+
this.name = "CeStorefrontError";
|
|
34
|
+
}
|
|
35
|
+
}
|