diff --git a/framework/bigcommerce/api/cart/add-item.ts b/framework/bigcommerce/api/cart/add-item.ts index 77c8a19ba..fd4387833 100644 --- a/framework/bigcommerce/api/cart/add-item.ts +++ b/framework/bigcommerce/api/cart/add-item.ts @@ -1,9 +1,9 @@ import { normalizeCart } from '@framework/lib/normalize' import { parseCartItem } from '../utils/parse-item' import getCartCookie from '../utils/get-cart-cookie' -import type { CartHandlers } from '.' +import type { CartEndpoint } from '.' -const addItem: CartHandlers['addItem'] = async ({ +const addItem: CartEndpoint['operations']['addItem'] = async ({ res, body: { cartId, item }, config, diff --git a/framework/bigcommerce/api/cart/get-cart.ts b/framework/bigcommerce/api/cart/get-cart.ts index 52a33b630..56fd23218 100644 --- a/framework/bigcommerce/api/cart/get-cart.ts +++ b/framework/bigcommerce/api/cart/get-cart.ts @@ -2,10 +2,10 @@ import { normalizeCart } from '@framework/lib/normalize' import { BigcommerceApiError } from '../utils/errors' import getCartCookie from '../utils/get-cart-cookie' import type { BigcommerceCart } from '../../types' -import type { CartHandlers } from '.' +import type { CartEndpoint } from '.' // Return current cart info -const getCart: CartHandlers['getCart'] = async ({ +const getCart: CartEndpoint['operations']['getCart'] = async ({ res, body: { cartId }, config, diff --git a/framework/bigcommerce/api/cart/index.ts b/framework/bigcommerce/api/cart/index.ts index 5d825d952..7c49434de 100644 --- a/framework/bigcommerce/api/cart/index.ts +++ b/framework/bigcommerce/api/cart/index.ts @@ -1,4 +1,4 @@ -import { EndpointSchema } from '@commerce/api' +import { EndpointSchema, GetAPISchema } from '@commerce/api' import getCart from './get-cart' import addItem from './add-item' import updateItem from './handlers/update-item' @@ -10,25 +10,27 @@ import type { RemoveCartItemHandlerBody, Cart, } from '../../types' -import type { CommerceAPIEndpoints } from '..' +import type { CommerceAPI } from '..' -export type CartEndpointSchema = EndpointSchema< - 'cart', +export type CartAPI = GetAPISchema< + CommerceAPI, { - options: {} - operations: { - getCart: { - data: Cart | null - body: GetCartHandlerBody - options: { yay: string } + endpoint: { + options: {} + operations: { + getCart: { + data: Cart | null + body: GetCartHandlerBody + options: { yay: string } + } + addItem: { data: Cart; body: AddCartItemHandlerBody; options: {} } + updateItem: { data: Cart; body: UpdateCartItemHandlerBody; options: {} } + removeItem: { data: Cart; body: RemoveCartItemHandlerBody; options: {} } } - addItem: { data: Cart; body: AddCartItemHandlerBody; options: {} } - updateItem: { data: Cart; body: UpdateCartItemHandlerBody; options: {} } - removeItem: { data: Cart; body: RemoveCartItemHandlerBody; options: {} } } } > -export type CartAPI = CommerceAPIEndpoints['cart'] +export type CartEndpoint = CartAPI['endpoint'] export const operations = { getCart, addItem } diff --git a/framework/bigcommerce/api/index.ts b/framework/bigcommerce/api/index.ts index e9acbfffc..1411e7bce 100644 --- a/framework/bigcommerce/api/index.ts +++ b/framework/bigcommerce/api/index.ts @@ -109,15 +109,17 @@ export type Provider = typeof provider export type EndpointsSchema = { cart: CartEndpointSchema } export class CommerceAPI< - P extends Provider = Provider, - E extends EndpointsSchema = EndpointsSchema -> extends CoreCommerceAPI
{ + P extends Provider = Provider +> extends CoreCommerceAPI
{
constructor(readonly provider: P = provider) {
super(provider)
}
}
-export type CommerceAPIEndpoints = GetEndpointsSchema {
constructor(readonly provider: P) {
this.provider = provider
}
@@ -146,12 +176,12 @@ export class CommerceAPI<
Object.assign(this.provider.config, newConfig)
}
- endpoint(context: {
- handler: E
- config?: P['config']
- operations: HandlerOperations