import { FetchTransportOptions, OperationIndex, Parameters, Request, RequestMethod, Response, Transport } from '../../internal/operation.js'; import type { V3 as reference } from '../../internal/reference/index.js'; import type { Const, RemovePrefix, SimplifyDeep } from '../../internal/type-utils.js'; import type { NarrowResponse } from './response-narrowing.js'; /** * @description Represents all possible API Operations in the v3 API * e.g. "GET /catalog/products", "POST /orders", etc. and their matching request specifications */ export type Operations = reference.Operation; /** * @description Represents all possible API Request paths in the v3 API * e.g. "GET /catalog/products", "POST /orders", etc. */ type RequestLine = keyof Operations; /** * @description Represents API paths that have no required parameters in the v3 API * e.g. "GET /catalog/products" would be included, but "GET /catalog/products/{id}" would not */ type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; /** * @description Infer and simplify the response type for a given request line and parameters */ type InferResponse = SimplifyDeep, Operations[ReqLine]['response']>>; /** * @description Infer and simplify the response data type for a given request line and parameters * Returns `never` for invalid requests */ type ResponseData = Response.Success> extends { readonly body: { readonly data?: infer Data; }; } ? SimplifyDeep : never; /** * @description Configuration options for the V3 client */ type Config = Omit & { readonly storeHash: string; readonly accessToken: string; }; /** * @description Client for interacting with the BigCommerce V3 Management API * @template CustomEndpoints - A string literal type representing custom API paths * that are not part of the official BigCommerce API specification. This allows * type-safe access to non-standard endpoints. * @example * ```ts * const client = new Client({ storeHash: '1234567890', accessToken: '1234567890' }); */ export declare class Client { constructor(config: Config); constructor(transport: Transport); private readonly transport; send(requestLine: ReqLine): Promise>; send(requestLine: ReqLine, params: Const): Promise>; send(requestLine: string, params?: Parameters): Promise; get>(path: Path): Promise | null>; get, Params extends Operations[`GET ${Path}`]['parameters']>(path: Path, params: Const): Promise | null>; get(path: RemovePrefix<'GET ', CustomEndpoints>, params?: Parameters): Promise; list(path: Path): AsyncIterable>; list(path: Path, params: Const): AsyncIterable>; list(path: RemovePrefix<'GET ', CustomEndpoints>, params?: Parameters): AsyncIterable; post>(path: Path): Promise>; post, Params extends Operations[`POST ${Path}`]['parameters']>(path: Path, params: Const): Promise>; post(path: RemovePrefix<'POST ', CustomEndpoints>, params?: Parameters): Promise; put>(path: Path): Promise>; put, Params extends Operations[`PUT ${Path}`]['parameters']>(path: Path, params: Const): Promise>; put(path: RemovePrefix<'PUT ', CustomEndpoints>, params?: Parameters): Promise; delete>(path: Path): Promise | null>; delete, Params extends Operations[`DELETE ${Path}`]['parameters']>(path: Path, params: Const): Promise | null>; delete(path: RemovePrefix<'DELETE ', CustomEndpoints>, params?: Parameters): Promise; private checkResponseStatus; } type ListItemType = ResponseData<`GET ${Path}` & RequestLine, Params> extends ReadonlyArray ? T : never; type ListablePath = ListablePath_; type NoParamsListablePath = ListablePath & NoParamsRequestPath<'GET'>; type ListablePath_ = { [ReqLine in keyof Ops]: Response.Success extends { body: { data?: readonly any[]; }; } ? ReqLine extends `GET ${infer Path}` ? Path : never : never; }[keyof Ops]; type ResolveResponse = unknown extends Params ? Operations[ReqLine]['response'] : Params extends Parameters ? InferResponse : never; type RequestPath = RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; type NoParamsRequestPath = NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; export {};