diff --git a/framework/bigcommerce/api/operations/login.ts b/framework/bigcommerce/api/operations/login.ts index 797418745..275ea4a2c 100644 --- a/framework/bigcommerce/api/operations/login.ts +++ b/framework/bigcommerce/api/operations/login.ts @@ -3,7 +3,8 @@ import type { OperationContext, OperationOptions, } from '@commerce/api/operations' -import type { LoginMutation, LoginMutationVariables } from '../../schema' +import type { LoginOperation } from '../../types/login' +import type { LoginMutation } from '../../schema' import type { RecursivePartial } from '../utils/types' import concatHeader from '../utils/concat-cookie' import type { BigcommerceConfig, Provider } from '..' @@ -16,24 +17,20 @@ export const loginMutation = /* GraphQL */ ` } ` -export type LoginResult = T - -export type LoginVariables = LoginMutationVariables - function loginOperation({ commerce }: OperationContext) { async function login(opts: { - variables: LoginVariables + variables: LoginOperation['variables'] config?: BigcommerceConfig res: ServerResponse - }): Promise + }): Promise - async function login( + async function login( opts: { - variables: V + variables: T['variables'] config?: BigcommerceConfig res: ServerResponse } & OperationOptions - ): Promise> + ): Promise async function login({ query = loginMutation, @@ -42,10 +39,10 @@ function loginOperation({ commerce }: OperationContext) { config, }: { query?: string - variables: LoginVariables + variables: LoginOperation['variables'] res: ServerResponse config?: BigcommerceConfig - }): Promise { + }): Promise { config = commerce.getConfig(config) const { data, res } = await config.fetch>( diff --git a/framework/bigcommerce/types/login.ts b/framework/bigcommerce/types/login.ts index 3313c60d8..24d5077ff 100644 --- a/framework/bigcommerce/types/login.ts +++ b/framework/bigcommerce/types/login.ts @@ -1 +1,8 @@ +import * as Core from '@commerce/types/login' +import type { LoginMutationVariables } from '../schema' + export * from '@commerce/types/login' + +export type LoginOperation = Core.LoginOperation & { + variables: LoginMutationVariables +} diff --git a/framework/commerce/api/operations.ts b/framework/commerce/api/operations.ts index 3902fdaeb..e46b02e97 100644 --- a/framework/commerce/api/operations.ts +++ b/framework/commerce/api/operations.ts @@ -1,3 +1,5 @@ +import type { LoginOperation } from '../types/login' +import type { GetAllPagesResult } from '../types/page' import type { ServerResponse } from 'http' import type { APIProvider, CommerceAPI, CommerceAPICore } from '.' @@ -14,23 +16,34 @@ export const defaultOperations = OPERATIONS.reduce((ops, k) => { export type AllowedOperations = typeof OPERATIONS[number] -export type LoginResult = T - export type Operations

= { login: { - (opts: { - variables: any + (opts: { + variables: T['variables'] config?: P['config'] res: ServerResponse - }): Promise + }): Promise - ( + ( opts: { - variables: V + variables: T['variables'] config?: P['config'] res: ServerResponse } & OperationOptions - ): Promise> + ): Promise + } + getAllPages: { + (opts?: { + config?: P['config'] + preview?: boolean + }): Promise + + ( + opts: { + config?: P['config'] + preview?: boolean + } & OperationOptions + ): Promise } } diff --git a/framework/commerce/types/login.ts b/framework/commerce/types/login.ts index 5974ed2db..68e09f546 100644 --- a/framework/commerce/types/login.ts +++ b/framework/commerce/types/login.ts @@ -18,3 +18,8 @@ export type LoginSchema = { } } } + +export type LoginOperation = { + data: { result?: string } + variables: unknown +}