diff --git a/framework/bigcommerce/types/cart.ts b/framework/bigcommerce/types/cart.ts index 09b792dee..83076ea09 100644 --- a/framework/bigcommerce/types/cart.ts +++ b/framework/bigcommerce/types/cart.ts @@ -58,9 +58,9 @@ export type RemoveItemHook = CartHooks['removeItem'] export type CartSchema = Core.CartSchema -export type CartOperations = Core.CartOperations +export type CartHandlers = Core.CartHandlers -export type GetCartOperation = CartOperations['getCart'] -export type AddItemOperation = CartOperations['addItem'] -export type UpdateItemOperation = CartOperations['updateItem'] -export type RemoveItemOperation = CartOperations['removeItem'] +export type GetCartHandler = CartHandlers['getCart'] +export type AddItemHandler = CartHandlers['addItem'] +export type UpdateItemHandler = CartHandlers['updateItem'] +export type RemoveItemHandler = CartHandlers['removeItem'] diff --git a/framework/commerce/api/index.ts b/framework/commerce/api/index.ts index 3d1521fbd..b48d2e48b 100644 --- a/framework/commerce/api/index.ts +++ b/framework/commerce/api/index.ts @@ -33,12 +33,12 @@ export type EndpointContext< E extends EndpointSchemaBase > = { handler: Endpoint - operations: EndpointHandlers + handlers: EndpointHandlers } export type EndpointSchemaBase = { options: {} - operations: { + handlers: { [k: string]: { data?: any; body?: any } } } @@ -52,11 +52,11 @@ export type EndpointHandlers< C extends CommerceAPI, E extends EndpointSchemaBase > = { - [H in keyof E['operations']]: APIHandler< + [H in keyof E['handlers']]: APIHandler< C, EndpointHandlers, - E['operations'][H]['data'], - E['operations'][H]['body'], + E['handlers'][H]['data'], + E['handlers'][H]['body'], E['options'] > } @@ -122,7 +122,7 @@ export function getEndpoint< res, commerce, config: cfg, - operations: context.operations, + handlers: context.handlers, options: context.options ?? {}, }) } diff --git a/framework/commerce/api/utils/types.ts b/framework/commerce/api/utils/types.ts index 41055b606..27a95df40 100644 --- a/framework/commerce/api/utils/types.ts +++ b/framework/commerce/api/utils/types.ts @@ -20,7 +20,7 @@ export type APIHandlerContext< res: NextApiResponse> commerce: C config: C['provider']['config'] - operations: H + handlers: H /** * Custom configs that may be used by a particular handler */ diff --git a/framework/commerce/types/cart.ts b/framework/commerce/types/cart.ts index 3c7901dbb..3ab6eb867 100644 --- a/framework/commerce/types/cart.ts +++ b/framework/commerce/types/cart.ts @@ -136,37 +136,33 @@ export type RemoveItemHook = { export type CartSchema = { endpoint: { options: {} - operations: CartOperations + handlers: CartHandlers } } -export type CartOperations = { - getCart: GetCartOperation - addItem: AddItemOperation - updateItem: UpdateItemOperation - removeItem: RemoveItemOperation +export type CartHandlers = { + getCart: GetCartHandler + addItem: AddItemHandler + updateItem: UpdateItemHandler + removeItem: RemoveItemHandler } -export type GetCartOperation< - T extends CartTypes = CartTypes -> = GetCartHook & { +export type GetCartHandler = GetCartHook & { body: { cartId?: string } } -export type AddItemOperation< - T extends CartTypes = CartTypes -> = AddItemHook & { +export type AddItemHandler = AddItemHook & { body: { cartId: string } } -export type UpdateItemOperation< +export type UpdateItemHandler< T extends CartTypes = CartTypes > = UpdateItemHook & { data: T['cart'] body: { cartId: string } } -export type RemoveItemOperation< +export type RemoveItemHandler< T extends CartTypes = CartTypes > = RemoveItemHook & { body: { cartId: string } diff --git a/framework/commerce/types/customer.ts b/framework/commerce/types/customer.ts index 4f603ca4f..46c415f0a 100644 --- a/framework/commerce/types/customer.ts +++ b/framework/commerce/types/customer.ts @@ -8,16 +8,10 @@ export type CustomerTypes = { export type CustomerSchema = { endpoint: { options: {} - operations: { + handlers: { getLoggedInCustomer: { data: { customer: T['customer'] } | null } } } } - -// export type CustomerOperations = { -// getLoggedInCustomer: GetCartOperation -// } - -// export type GetLoggedInCustomerOperation = {} diff --git a/framework/commerce/types/login.ts b/framework/commerce/types/login.ts index 68e09f546..726649719 100644 --- a/framework/commerce/types/login.ts +++ b/framework/commerce/types/login.ts @@ -10,7 +10,7 @@ export type LoginTypes = { export type LoginSchema = { endpoint: { options: {} - operations: { + handlers: { login: { data: null body: T['body'] diff --git a/framework/commerce/types/logout.ts b/framework/commerce/types/logout.ts index 642095e4d..6923237a7 100644 --- a/framework/commerce/types/logout.ts +++ b/framework/commerce/types/logout.ts @@ -1,7 +1,7 @@ export type LogoutSchema = { endpoint: { options: {} - operations: { + handlers: { logout: { data: null body: { redirectTo?: string } diff --git a/framework/commerce/types/signup.ts b/framework/commerce/types/signup.ts index ae25da0f0..5878bedf9 100644 --- a/framework/commerce/types/signup.ts +++ b/framework/commerce/types/signup.ts @@ -12,7 +12,7 @@ export type SignupTypes = { export type SignupSchema = { endpoint: { options: {} - operations: { + handlers: { signup: { data: null body: T['body']