diff --git a/framework/bigcommerce/api/cart/index.ts b/framework/bigcommerce/api/cart/index.ts
index 7c49434de..043097654 100644
--- a/framework/bigcommerce/api/cart/index.ts
+++ b/framework/bigcommerce/api/cart/index.ts
@@ -1,4 +1,4 @@
-import { EndpointSchema, GetAPISchema } from '@commerce/api'
+import { GetAPISchema } from '@commerce/api'
import getCart from './get-cart'
import addItem from './add-item'
import updateItem from './handlers/update-item'
diff --git a/framework/bigcommerce/api/index.ts b/framework/bigcommerce/api/index.ts
index 1411e7bce..d11f168b8 100644
--- a/framework/bigcommerce/api/index.ts
+++ b/framework/bigcommerce/api/index.ts
@@ -2,11 +2,9 @@ import type { RequestInit } from '@vercel/fetch'
import {
CommerceAPI as CoreCommerceAPI,
CommerceAPIConfig,
- GetEndpointsSchema,
} from '@commerce/api'
import fetchGraphqlApi from './utils/fetch-graphql-api'
import fetchStoreApi from './utils/fetch-store-api'
-import { CartEndpointSchema } from './cart'
export interface BigcommerceConfig extends CommerceAPIConfig {
// Indicates if the returned metadata with translations should be applied to the
@@ -106,8 +104,6 @@ export const provider = {
export type Provider = typeof provider
-export type EndpointsSchema = { cart: CartEndpointSchema }
-
export class CommerceAPI<
P extends Provider = Provider
> extends CoreCommerceAPI
{
@@ -116,11 +112,6 @@ export class CommerceAPI<
}
}
-export type CommerceAPIEndpoints = GetEndpointsSchema<
- CommerceAPI,
- EndpointsSchema
->
-
export function getConfig(userConfig?: Partial) {
return config.getConfig(userConfig)
}
diff --git a/framework/commerce/api/endpoints/cart.ts b/framework/commerce/api/endpoints/cart.ts
index 770245a27..30e2ff72d 100644
--- a/framework/commerce/api/endpoints/cart.ts
+++ b/framework/commerce/api/endpoints/cart.ts
@@ -1,12 +1,11 @@
import type { APIEndpoint } from '../utils/types'
import { CommerceAPIError } from '../utils/errors'
import isAllowedOperation from '../utils/is-allowed-operation'
-import type { GetAPISchema, CommerceAPI, CartSchema } from '..'
+import type { GetAPISchema, CartSchema } from '..'
-const cartApi: GetAPISchema<
- CommerceAPI,
- CartSchema
->['endpoint']['handler'] = async (ctx) => {
+const cartApi: GetAPISchema['endpoint']['handler'] = async (
+ ctx
+) => {
const { req, res, handlers, config } = ctx
if (
@@ -20,6 +19,7 @@ const cartApi: GetAPISchema<
return
}
+ const body2 = req.body
const { cookies } = req
const cartId = cookies[config.cartCookie]
diff --git a/framework/commerce/api/index.ts b/framework/commerce/api/index.ts
index e170e06c4..c8d1d78f7 100644
--- a/framework/commerce/api/index.ts
+++ b/framework/commerce/api/index.ts
@@ -3,49 +3,6 @@ import type { RequestInit, Response } from '@vercel/fetch'
import type { APIEndpoint, APIHandler } from './utils/types'
import type { Cart } from '../types'
-export type CartEndpoint = APIEndpoint, any>
-
-export type CartHandlersBase = {
- getCart: APIHandler<
- any,
- CartHandlersBase,
- Cart | null,
- any,
- { yay: string }
- >
- addItem: APIHandler, Cart, any>
- updateItem: APIHandler, Cart, any>
- removeItem: APIHandler, Cart, any>
-}
-
-export type CartHandlers<
- C extends CommerceAPI,
- T extends CartHandlersBase = CartHandlersBase
-> = T
-
-export type CartHandlersType = {
- getCart: { data: Cart | null; body: any; options: {} }
- addItem: { data: Cart; body: any; options: {} }
- updateItem: { data: Cart; body: any; options: {} }
- removeItem: { data: Cart; body: any; options: {} }
-}
-
-export type CartHandlers2<
- C extends CommerceAPI,
- T extends CartHandlersType = CartHandlersType
-> = {
- getCart: APIHandler<
- any,
- CartHandlersBase,
- Cart | null,
- any,
- { yay: string }
- >
- addItem: APIHandler, Cart, any>
- updateItem: APIHandler, Cart, any>
- removeItem: APIHandler, Cart, any>
-}
-
export type CartSchema = {
endpoint: {
options: {}
@@ -65,10 +22,10 @@ export type GetAPISchema<
S extends APISchemas = APISchemas
> = {
schema: S
- endpoint: EndpointContext2
+ endpoint: EndpointContext
}
-export type EndpointContext2<
+export type EndpointContext<
C extends CommerceAPI,
E extends EndpointSchemaBase
> = {
@@ -76,31 +33,6 @@ export type EndpointContext2<
operations: EndpointHandlers
}
-export type EndpointsSchema = {
- cart?: {
- options: {}
- operations: {
- getCart: { data?: Cart | null; body?: any }
- addItem: { data?: Cart; body?: any }
- updateItem: { data?: Cart; body?: any }
- removeItem: { data?: Cart; body?: any }
- }
- }
-}
-
-export type GetEndpointsSchema<
- C extends CommerceAPI,
- Schema extends EndpointsSchema
-> = {
- [E in keyof EndpointsSchema]-?: {
- schema: Schema[E]
- } & EndpointContext>
-}
-
-export type GetEndpointsFromSchema = T[keyof T] extends { endpoint: infer E }
- ? E
- : never
-
export type EndpointSchemaBase = {
options: {}
operations: {
@@ -108,24 +40,10 @@ export type EndpointSchemaBase = {
}
}
-export type OperationData = T extends { data?: infer D; body?: any }
- ? D
- : never
-
-export type EndpointSchema<
- E extends keyof EndpointsSchema,
- Handlers extends EndpointsSchema[E]
-> = Handlers
-
export type Endpoint<
C extends CommerceAPI,
E extends EndpointSchemaBase
-> = APIEndpoint<
- C,
- EndpointHandlers,
- OperationData,
- E['options']
->
+> = APIEndpoint, any, E['options']>
export type EndpointHandlers<
C extends CommerceAPI,
@@ -140,26 +58,10 @@ export type EndpointHandlers<
>
}
-export type HandlerOperations = E extends APIEndpoint
- ? T
- : never
-
-export type HandlerOptions = E extends APIEndpoint
- ? T
- : never
-
export type APIProvider = {
config: CommerceAPIConfig
}
-export type EndpointContext<
- C extends CommerceAPI,
- E extends EndpointSchemaBase
-> = {
- endpoint: Endpoint
- operations: EndpointHandlers
-}
-
export class CommerceAPI {
constructor(readonly provider: P) {
this.provider = provider