├── .gitignore ├── .npmrc ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── lib ├── index.d.ts ├── index.js ├── internal │ ├── augmentation.d.ts │ ├── augmentation.js │ ├── operation.d.ts │ ├── operation.js │ ├── reference │ │ ├── generated │ │ │ ├── abandoned_carts.v3.d.ts │ │ │ ├── abandoned_carts.v3.js │ │ │ ├── carts.sf.d.ts │ │ │ ├── carts.sf.js │ │ │ ├── carts.v3.d.ts │ │ │ ├── carts.v3.js │ │ │ ├── catalog.v3.d.ts │ │ │ ├── catalog.v3.js │ │ │ ├── channels.v3.d.ts │ │ │ ├── channels.v3.js │ │ │ ├── checkouts.sf.d.ts │ │ │ ├── checkouts.sf.js │ │ │ ├── checkouts.v3.d.ts │ │ │ ├── checkouts.v3.js │ │ │ ├── consent.sf.d.ts │ │ │ ├── consent.sf.js │ │ │ ├── currencies.v2.d.ts │ │ │ ├── currencies.v2.js │ │ │ ├── current_customer.d.ts │ │ │ ├── current_customer.js │ │ │ ├── custom_template_associations.v3.d.ts │ │ │ ├── custom_template_associations.v3.js │ │ │ ├── customer_login.d.ts │ │ │ ├── customer_login.js │ │ │ ├── customers.sf.d.ts │ │ │ ├── customers.sf.js │ │ │ ├── customers.v2.d.ts │ │ │ ├── customers.v2.js │ │ │ ├── customers.v3.d.ts │ │ │ ├── customers.v3.js │ │ │ ├── email_templates.v3.d.ts │ │ │ ├── email_templates.v3.js │ │ │ ├── form_fields.sf.d.ts │ │ │ ├── form_fields.sf.js │ │ │ ├── geography.v2.d.ts │ │ │ ├── geography.v2.js │ │ │ ├── marketing.v2.d.ts │ │ │ ├── marketing.v2.js │ │ │ ├── misc.d.ts │ │ │ ├── misc.js │ │ │ ├── orders.sf.d.ts │ │ │ ├── orders.sf.js │ │ │ ├── orders.v2.oas2.d.ts │ │ │ ├── orders.v2.oas2.js │ │ │ ├── orders.v3.d.ts │ │ │ ├── orders.v3.js │ │ │ ├── pages.v3.d.ts │ │ │ ├── pages.v3.js │ │ │ ├── payment_methods.v2.d.ts │ │ │ ├── payment_methods.v2.js │ │ │ ├── payment_processing.d.ts │ │ │ ├── payment_processing.js │ │ │ ├── price_lists.v3.d.ts │ │ │ ├── price_lists.v3.js │ │ │ ├── pricing.sf.d.ts │ │ │ ├── pricing.sf.js │ │ │ ├── redirects.v3.d.ts │ │ │ ├── redirects.v3.js │ │ │ ├── scripts.v3.d.ts │ │ │ ├── scripts.v3.js │ │ │ ├── settings.v3.d.ts │ │ │ ├── settings.v3.js │ │ │ ├── sf.d.ts │ │ │ ├── sf.js │ │ │ ├── shipping.v2.d.ts │ │ │ ├── shipping.v2.js │ │ │ ├── shipping.v3.d.ts │ │ │ ├── shipping.v3.js │ │ │ ├── shipping_provider.d.ts │ │ │ ├── shipping_provider.js │ │ │ ├── sites.v3.d.ts │ │ │ ├── sites.v3.js │ │ │ ├── store_content.v2.d.ts │ │ │ ├── store_content.v2.js │ │ │ ├── store_information.v2.d.ts │ │ │ ├── store_information.v2.js │ │ │ ├── storefront_tokens.v3.d.ts │ │ │ ├── storefront_tokens.v3.js │ │ │ ├── subscribers.v3.d.ts │ │ │ ├── subscribers.v3.js │ │ │ ├── subscriptions.sf.d.ts │ │ │ ├── subscriptions.sf.js │ │ │ ├── tax.v3.d.ts │ │ │ ├── tax.v3.js │ │ │ ├── tax_classes.v2.d.ts │ │ │ ├── tax_classes.v2.js │ │ │ ├── tax_provider.d.ts │ │ │ ├── tax_provider.js │ │ │ ├── themes.v3.d.ts │ │ │ ├── themes.v3.js │ │ │ ├── v2.d.ts │ │ │ ├── v2.js │ │ │ ├── v3.d.ts │ │ │ ├── v3.js │ │ │ ├── webhooks.v3.d.ts │ │ │ ├── webhooks.v3.js │ │ │ ├── widgets.v3.d.ts │ │ │ ├── widgets.v3.js │ │ │ ├── wishlists.v3.d.ts │ │ │ └── wishlists.v3.js │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── operation-inference.d.ts │ │ └── operation-inference.js │ ├── type-utils.d.ts │ └── type-utils.js ├── management │ ├── index.d.ts │ ├── index.js │ ├── v2 │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── response-narrowing.d.ts │ │ └── response-narrowing.js │ └── v3 │ │ ├── index.d.ts │ │ ├── index.js │ │ ├── response-narrowing.d.ts │ │ ├── response-narrowing.js │ │ ├── spec-sniffer.d.ts │ │ └── spec-sniffer.js └── storefront │ ├── index.d.ts │ ├── index.js │ ├── response-narrowing.d.ts │ └── response-narrowing.js ├── package-lock.json ├── package.json ├── src ├── index.ts ├── internal │ ├── augmentation.ts │ ├── operation.ts │ ├── reference │ │ ├── files.js │ │ ├── generate.js │ │ ├── generated │ │ │ ├── abandoned_carts.v3.ts │ │ │ ├── carts.sf.ts │ │ │ ├── carts.v3.ts │ │ │ ├── catalog.v3.ts │ │ │ ├── channels.v3.ts │ │ │ ├── checkouts.sf.ts │ │ │ ├── checkouts.v3.ts │ │ │ ├── consent.sf.ts │ │ │ ├── currencies.v2.ts │ │ │ ├── current_customer.ts │ │ │ ├── custom_template_associations.v3.ts │ │ │ ├── customer_login.ts │ │ │ ├── customers.sf.ts │ │ │ ├── customers.v2.ts │ │ │ ├── customers.v3.ts │ │ │ ├── email_templates.v3.ts │ │ │ ├── form_fields.sf.ts │ │ │ ├── geography.v2.ts │ │ │ ├── marketing.v2.ts │ │ │ ├── misc.ts │ │ │ ├── orders.sf.ts │ │ │ ├── orders.v2.oas2.ts │ │ │ ├── orders.v3.ts │ │ │ ├── pages.v3.ts │ │ │ ├── payment_methods.v2.ts │ │ │ ├── payment_processing.ts │ │ │ ├── price_lists.v3.ts │ │ │ ├── pricing.sf.ts │ │ │ ├── redirects.v3.ts │ │ │ ├── scripts.v3.ts │ │ │ ├── settings.v3.ts │ │ │ ├── sf.ts │ │ │ ├── shipping.v2.ts │ │ │ ├── shipping.v3.ts │ │ │ ├── shipping_provider.ts │ │ │ ├── sites.v3.ts │ │ │ ├── store_content.v2.ts │ │ │ ├── store_information.v2.ts │ │ │ ├── storefront_tokens.v3.ts │ │ │ ├── subscribers.v3.ts │ │ │ ├── subscriptions.sf.ts │ │ │ ├── tax.v3.ts │ │ │ ├── tax_classes.v2.ts │ │ │ ├── tax_provider.ts │ │ │ ├── themes.v3.ts │ │ │ ├── v2.ts │ │ │ ├── v3.ts │ │ │ ├── webhooks.v3.ts │ │ │ ├── widgets.v3.ts │ │ │ └── wishlists.v3.ts │ │ ├── index.ts │ │ └── operation-inference.ts │ └── type-utils.ts ├── management │ ├── README.md │ ├── index.ts │ ├── v2 │ │ ├── README.md │ │ ├── index.ts │ │ └── response-narrowing.ts │ └── v3 │ │ ├── README.md │ │ ├── index.ts │ │ ├── response-narrowing.ts │ │ └── spec-sniffer.ts └── storefront │ ├── README.md │ ├── index.ts │ └── response-narrowing.ts ├── tsconfig.json └── tsconfig.publish.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .vscode 3 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | @space48:registry=https://registry.npmjs.org 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contribution instructions will be here soon. 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Space 48 Limited 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # bigcommerce-api-js 2 | 3 | A JavaScript client for BigCommerce's [Management](src/management/README.md) API with full TypeScript typings for all API endpoints. 4 | 5 | ## Features 6 | 7 | - Full coverage of BigCommerce's Storefront (coming soon) and Management APIs. 8 | - Up-to-date TypeScript typings for all of BigCommerce's API endpoints. 9 | - Easy IDE autocompeletion of endpoints, parameters and response data thanks to TypeScript. 10 | - Automatic retry of intermittent errors such as 429 and 5xx with exponential backoff. 11 | 12 | ### Coming soon 13 | 14 | - Type declarations for webhook payloads. 15 | - Browser support. 16 | 17 | ## Supported environments 18 | 19 | - Node.js >=10 20 | - Browser support is coming soon. 21 | 22 | # Getting started 23 | 24 | To get started with the JavaScript client you'll need to install it, and then follow the instructions for either the Storefront API client or the Management API client. 25 | 26 | - [Installation](#installation) 27 | - [Getting started with the Storefront API client](src/storefront/README.md#getting-started) 28 | - [Getting started with the Management API client](src/management/README.md#getting-started) 29 | 30 | ## Installation 31 | 32 | ### Node 33 | 34 | ```sh 35 | npm install @space48/bigcommerce-api 36 | ``` 37 | 38 | ### Browser 39 | 40 | Coming soon. 41 | 42 | ### Typings 43 | 44 | This library also comes with typings to use with TypeScript. 45 | 46 | ## Versioning 47 | 48 | This project strictly follows [Semantic Versioning](http://semver.org/). 49 | 50 | ## Support 51 | 52 | If you have a problem with this library, please file an [issue](https://github.com/Space48/bigcommerce-api-js/issues/new) here on GitHub. 53 | 54 | ## Contributing 55 | 56 | See [CONTRIBUTING.md](CONTRIBUTING.md) 57 | 58 | ## License 59 | 60 | MIT 61 | -------------------------------------------------------------------------------- /lib/index.d.ts: -------------------------------------------------------------------------------- 1 | export * as Management from "./management"; 2 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 10 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 11 | }) : function(o, v) { 12 | o["default"] = v; 13 | }); 14 | var __importStar = (this && this.__importStar) || function (mod) { 15 | if (mod && mod.__esModule) return mod; 16 | var result = {}; 17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 18 | __setModuleDefault(result, mod); 19 | return result; 20 | }; 21 | Object.defineProperty(exports, "__esModule", { value: true }); 22 | exports.Management = void 0; 23 | exports.Management = __importStar(require("./management")); 24 | // export * as Storefront from "./storefront" 25 | -------------------------------------------------------------------------------- /lib/internal/augmentation.d.ts: -------------------------------------------------------------------------------- 1 | import type { Operation, OperationIndex } from "./operation"; 2 | export declare type AugmentOps = { 3 | [K in keyof Base]: K extends keyof Augmentation ? AugmentOp : Base[K]; 4 | }; 5 | declare type OperationIndexAugmentation = Record; 6 | export declare type AugmentOp = { 7 | [K in keyof Base | keyof Augmentation]: K extends keyof Base & keyof Augmentation & 'parameters' ? Augmentation['parameters'] extends ParamAugmentation ? AugmentParams : Base['parameters'] : K extends keyof Augmentation & 'response' ? Augmentation[K] : K extends keyof Base ? Base[K] : never; 8 | }; 9 | declare type OperationAugmentation = { 10 | parameters?: ParamAugmentation; 11 | response?: any; 12 | }; 13 | export declare type AugmentParams = { 14 | [K in keyof Base | keyof Augmentation]: K extends keyof Augmentation & 'query' ? AugmentRecord, Exclude> : K extends keyof Augmentation & 'body' ? Augmentation['body'] : K extends keyof Base ? Base[K] : never; 15 | }; 16 | declare type ParamAugmentation = { 17 | query?: Record; 18 | body?: any; 19 | }; 20 | declare type AugmentRecord = 1 extends 0 ? never : { 21 | [K in (keyof Base) | (keyof Augmentation)]: K extends keyof Augmentation ? Augmentation[K] : K extends keyof Base ? Base[K] : never; 22 | }; 23 | export {}; 24 | -------------------------------------------------------------------------------- /lib/internal/augmentation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/operation.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { Agent } from "http"; 3 | import { Response as FetchResponse } from "node-fetch"; 4 | export declare type RequestMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT'; 5 | export declare type Request = { 6 | readonly requestLine: ReqLine; 7 | readonly parameters: Params; 8 | }; 9 | export declare type RequestLine = `${RequestMethod} ${string}`; 10 | export declare type Parameters = { 11 | readonly path?: Record; 12 | readonly query?: any; 13 | readonly body?: any; 14 | readonly header?: Record; 15 | }; 16 | export declare type Response = { 17 | readonly status: number | string; 18 | readonly body?: any; 19 | }; 20 | export declare namespace Response { 21 | type Success = T extends { 22 | status: 200 | 201 | 204; 23 | } ? T : T extends Operation ? Success : never; 24 | } 25 | export declare type Operation = { 26 | readonly parameters: Request['parameters']; 27 | readonly response: Response; 28 | }; 29 | export declare namespace Operation { 30 | export type MinimalInput = InputParameters; 31 | type InputParameters = MakeEmptyObjectOptional<{ 32 | [K in keyof OpParams]: K extends 'query' ? Partial : K extends 'header' ? Omit : OpParams[K]; 33 | }>; 34 | export {}; 35 | } 36 | export declare type OperationIndex = Record; 37 | export declare namespace OperationIndex { 38 | type FilterOptionalParams = { 39 | [K in keyof Ops as {} extends Operation.MinimalInput ? K : never]: Ops[K]; 40 | }; 41 | } 42 | declare type MakeEmptyObjectOptional = 1 extends 0 ? never : ({ 43 | readonly [K in keyof T as {} extends T[K] ? K : never]?: T[K]; 44 | } & { 45 | readonly [K in keyof T as {} extends T[K] ? never : K]: T[K]; 46 | }); 47 | export declare function resolvePath(parameterizedPath: string, pathParams: Record): string; 48 | export declare type Transport = (requestLine: string, params?: Parameters) => Promise; 49 | export declare type FetchTransportOptions = { 50 | readonly baseUrl: string; 51 | readonly headers: Record; 52 | readonly agent?: Agent; 53 | readonly retry?: boolean | { 54 | /** 55 | * Return true if the request should be retried, false otherwise 56 | */ 57 | readonly shouldRetry?: (attemptNum: number, response: FetchResponse, requestLine: string) => boolean; 58 | /** 59 | * Return the backoff time in ms 60 | */ 61 | readonly backoffTime?: (numFailures: number, response: FetchResponse, requestLine: string) => number; 62 | }; 63 | }; 64 | export declare function fetchTransport(options: FetchTransportOptions): Transport; 65 | export {}; 66 | -------------------------------------------------------------------------------- /lib/internal/operation.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __importDefault = (this && this.__importDefault) || function (mod) { 3 | return (mod && mod.__esModule) ? mod : { "default": mod }; 4 | }; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.fetchTransport = exports.resolvePath = void 0; 7 | const query_string_1 = require("query-string"); 8 | const https_1 = require("https"); 9 | const node_fetch_1 = __importDefault(require("node-fetch")); 10 | function resolvePath(parameterizedPath, pathParams) { 11 | return parameterizedPath 12 | .split("/") 13 | .map(el => { 14 | const match = el.match(/^\{(.+)\}$/); 15 | if (!match) { 16 | return el; 17 | } 18 | const paramName = match[1]; 19 | const param = pathParams[paramName]; 20 | if (param === null || param === undefined || param === '') { 21 | throw new Error(`Path param ${paramName} must be specified.`); 22 | } 23 | return encodeURIComponent(param); 24 | }) 25 | .join('/'); 26 | } 27 | exports.resolvePath = resolvePath; 28 | const defaultRetryConfig = { 29 | shouldRetry: (attemptNum, response) => { 30 | if (response.status === 429 && attemptNum < 50) { 31 | return true; 32 | } 33 | if (response.status >= 500 && response.status < 600 && attemptNum < 5) { 34 | return true; 35 | } 36 | return false; 37 | }, 38 | backoffTime: numFailures => { 39 | const maxRandomization = 0.2; 40 | const randomization = 0.9 + Math.random() * maxRandomization; 41 | return numFailures * 500 * randomization; 42 | }, 43 | }; 44 | function fetchTransport(options) { 45 | const { agent, baseUrl, headers, retry, } = options; 46 | const _agent = agent || new https_1.Agent({ maxSockets: 10, keepAlive: true }); 47 | const shouldRetry = retry === false ? () => false 48 | : retry === true || (retry === null || retry === void 0 ? void 0 : retry.shouldRetry) === undefined ? defaultRetryConfig.shouldRetry 49 | : retry.shouldRetry; 50 | const backoffTime = retry === false ? () => { throw new Error(); } 51 | : retry === true || (retry === null || retry === void 0 ? void 0 : retry.backoffTime) === undefined ? defaultRetryConfig.backoffTime 52 | : retry.backoffTime; 53 | const staticHeaders = { 54 | "Accept-Encoding": "gzip", 55 | "Accept": "application/json", 56 | ...headers, 57 | }; 58 | return async (requestLine, params) => { 59 | var _a, _b; 60 | const [method, paramaterizedPath] = requestLine.split(" ", 2); 61 | const path = resolvePath(paramaterizedPath, (_a = params === null || params === void 0 ? void 0 : params.path) !== null && _a !== void 0 ? _a : {}); 62 | const queryParams = (0, query_string_1.stringify)((_b = params === null || params === void 0 ? void 0 : params.query) !== null && _b !== void 0 ? _b : {}, { arrayFormat: "comma" }); 63 | const queryString = queryParams.length ? `?${queryParams}` : ""; 64 | const isformDataContent = (params === null || params === void 0 ? void 0 : params.header) ? ("content-type" in params.header) ? params === null || params === void 0 ? void 0 : params.header["content-type"].toLowerCase().includes("multipart/form-data") : 65 | ("Content-Type" in params.header) ? params === null || params === void 0 ? void 0 : params.header["Content-Type"].toLowerCase().includes("multipart/form-data") : false : false; 66 | const body = (params === null || params === void 0 ? void 0 : params.body) && (isformDataContent ? params.body : JSON.stringify(params.body)); 67 | if (isformDataContent) { 68 | staticHeaders.Accept = "*/*"; 69 | } 70 | const fetchFn = () => (0, node_fetch_1.default)(`${baseUrl}${path}${queryString}`, { 71 | method, 72 | headers: { 73 | 'Content-Type': (params === null || params === void 0 ? void 0 : params.body) ? isformDataContent ? 'multipart/form-data' : 'application/json' : undefined, 74 | ...staticHeaders, 75 | ...params === null || params === void 0 ? void 0 : params.header, 76 | }, 77 | agent: _agent, 78 | body, 79 | }); 80 | let response; 81 | for (let attemptNum = 1;; attemptNum++) { 82 | response = await fetchFn(); 83 | if (!response.ok && shouldRetry(attemptNum, response, requestLine)) { 84 | await new Promise(resolve => setTimeout(() => resolve(), backoffTime(attemptNum, response, requestLine))); 85 | } 86 | else { 87 | break; 88 | } 89 | } 90 | const responseBody = await response.text(); 91 | return { 92 | status: response.status, 93 | body: responseBody && JSON.parse(responseBody), 94 | }; 95 | }; 96 | } 97 | exports.fetchTransport = fetchTransport; 98 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/abandoned_carts.v3.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/abandoned-carts/{token}": { 7 | /** 8 | * Returns the `cart_id` corresponding to the abandoned cart `{token}` passed in. 9 | * 10 | * **Usage Notes**: 11 | * * `{token}` is the token in the query string of the abandoned cart link found in abandoned cart email notifications to shoppers 12 | */ 13 | readonly get: operations["getAbandonedCarts"]; 14 | readonly parameters: { 15 | readonly path: { 16 | /** 17 | * Unique cart `UUID`. 18 | * 19 | * Unique cart `UUID` token that is generated for abandoned cart emails. 20 | */ 21 | readonly token: string; 22 | }; 23 | }; 24 | }; 25 | } 26 | export interface definitions { 27 | readonly metaEmpty_Full: { 28 | readonly [key: string]: any; 29 | }; 30 | readonly error_Full: { 31 | /** The HTTP status code. */ 32 | readonly status?: number; 33 | /** The error title describing the particular error. */ 34 | readonly title?: string; 35 | readonly type?: string; 36 | }; 37 | readonly errorDetailed_Full: { 38 | readonly errors?: { 39 | readonly [key: string]: string; 40 | }; 41 | }; 42 | readonly abandonedCartInfo_Full: { 43 | /** The `cart_id` of the abandoned cart. Can be used to display the abanded cart to the customer via storefront cart or */ 44 | readonly cart_id?: string; 45 | }; 46 | } 47 | export interface parameters { 48 | /** Accept */ 49 | readonly Accept: string; 50 | /** Content-Type */ 51 | readonly "Content-Type": string; 52 | } 53 | export interface responses { 54 | /** If something happens during the request that causes it to fail, a 502 response will be returned. A new request should be made; however, it could fail. */ 55 | readonly "502_GatewayError": { 56 | readonly schema: definitions["error_Full"]; 57 | }; 58 | /** If this occurs, you should retry the request. Typically retrying the request several times will result in a successful request; However, if you are unable to successfully make a request, please check the BigCommerce system status [here](https://status.bigcommerce.com/). A service is likely down and the request will need to be made again when it is back up (in several hours usually) */ 59 | readonly "504_GatewayTimeout": { 60 | readonly schema: definitions["errorDetailed_Full"]; 61 | }; 62 | readonly "403_Unauthorized": { 63 | readonly schema: definitions["error_Full"]; 64 | }; 65 | /** 66 | * Malformed request syntax. Typically need to fix the JSON 67 | * Body to resend successfully. 68 | */ 69 | readonly "400_BadRequest": { 70 | readonly schema: definitions["error_Full"]; 71 | }; 72 | /** If the requested account resource is not found for the franchise, return a 404 Not Found. */ 73 | readonly "404_NotFound": { 74 | readonly schema: definitions["error_Full"]; 75 | }; 76 | /** This occurs when missing or unacceptable data is passed for one or more fields. Please correct the values for the fields listed in the errors object. */ 77 | readonly "422_UnprocessableEntity": { 78 | readonly schema: definitions["errorDetailed_Full"]; 79 | }; 80 | /** If this occurs, you should retry the request. If you are unable to successfully make a request, please check the BigCommerce system status [here](https://status.bigcommerce.com/). A service is likely down and the request will need to be made again when it is back up (in several hours usually) */ 81 | readonly "503_ServiceUnavailable": { 82 | readonly schema: definitions["error_Full"]; 83 | }; 84 | /** Returned on `GET` requests to `/abandoned_carts`. */ 85 | readonly abandonedCart_Resp: { 86 | readonly schema: { 87 | readonly data?: definitions["abandonedCartInfo_Full"]; 88 | readonly meta?: definitions["metaEmpty_Full"]; 89 | }; 90 | }; 91 | } 92 | export interface operations { 93 | /** 94 | * Returns the `cart_id` corresponding to the abandoned cart `{token}` passed in. 95 | * 96 | * **Usage Notes**: 97 | * * `{token}` is the token in the query string of the abandoned cart link found in abandoned cart email notifications to shoppers 98 | */ 99 | readonly getAbandonedCarts: { 100 | readonly parameters: { 101 | readonly path: { 102 | /** 103 | * Unique cart `UUID`. 104 | * 105 | * Unique cart `UUID` token that is generated for abandoned cart emails. 106 | */ 107 | readonly token: string; 108 | }; 109 | }; 110 | readonly responses: { 111 | readonly 200: responses["abandonedCart_Resp"]; 112 | readonly 400: responses["400_BadRequest"]; 113 | readonly 404: responses["404_NotFound"]; 114 | readonly 422: responses["422_UnprocessableEntity"]; 115 | readonly 502: responses["502_GatewayError"]; 116 | readonly 503: responses["503_ServiceUnavailable"]; 117 | readonly 504: responses["504_GatewayTimeout"]; 118 | readonly default: unknown; 119 | }; 120 | }; 121 | } 122 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/abandoned_carts.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/carts.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/carts.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/catalog.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/channels.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/checkouts.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/checkouts.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/consent.sf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/consent": { 7 | /** 8 | * Sets the status of a customer's consent to allow data collection by cookies and scripts according to the following consent categories: 9 | * 10 | * 11 | * 2. Analytics — These cookies provide statistical information on site usage so the store owner can improve the website over time. 12 | * 3. Functional — These cookies enable enhanced functionality, such as videos and live chat. If a shopper does not allow these, then some or all of these functions may not work properly. 13 | * 4. Targeting; Advertising — These cookies allow merchants to create profiles or personalize content to enhance users' shopping experience. 14 | * 15 | * 16 | * This endpoint only works if the cookie consent feature is enabled. It is assumed the shopper has not consented to anything until a value is explicitly set. The request body must be populated with a complete set of allowed and denied categories. 17 | * 18 | * Once set, consent preferences will be saved as a cookie for guest shoppers. Consent preferences will be persisted to a shopper's account to be used for future sessions once they have logged in. Consent preferences can also be managed using the [Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/) V3 endpoint. 19 | */ 20 | readonly post: operations["postConsent"]; 21 | readonly parameters: {}; 22 | }; 23 | } 24 | export interface components { 25 | readonly schemas: { 26 | /** 27 | * List of allowed and denied consent categories. Must be populated with a complete set of allowed and denied categories. 28 | * 29 | * Configurable categories are: 30 | * 31 | * 2 - Functional 32 | * 3 - Analytics 33 | * 4 - Targeting; Advertising 34 | * 35 | * For further definition of these categories, see [Scripts API](https://developer.bigcommerce.com/api-docs/store-management/scripts). 36 | */ 37 | readonly ConsentPreferences: { 38 | /** Explicitly allowed consent categories. Allowed values are 2, 3, 4. */ 39 | readonly allow: readonly (2 | 3 | 4)[]; 40 | /** Denied consent categories. Allowed values are 2, 3, 4. */ 41 | readonly deny: readonly (2 | 3 | 4)[]; 42 | }; 43 | }; 44 | } 45 | export interface operations { 46 | /** 47 | * Sets the status of a customer's consent to allow data collection by cookies and scripts according to the following consent categories: 48 | * 49 | * 50 | * 2. Analytics — These cookies provide statistical information on site usage so the store owner can improve the website over time. 51 | * 3. Functional — These cookies enable enhanced functionality, such as videos and live chat. If a shopper does not allow these, then some or all of these functions may not work properly. 52 | * 4. Targeting; Advertising — These cookies allow merchants to create profiles or personalize content to enhance users' shopping experience. 53 | * 54 | * 55 | * This endpoint only works if the cookie consent feature is enabled. It is assumed the shopper has not consented to anything until a value is explicitly set. The request body must be populated with a complete set of allowed and denied categories. 56 | * 57 | * Once set, consent preferences will be saved as a cookie for guest shoppers. Consent preferences will be persisted to a shopper's account to be used for future sessions once they have logged in. Consent preferences can also be managed using the [Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/) V3 endpoint. 58 | */ 59 | readonly postConsent: { 60 | readonly parameters: {}; 61 | readonly responses: { 62 | /** Consent Settings Saved */ 63 | readonly 200: unknown; 64 | /** Invalid input */ 65 | readonly 400: unknown; 66 | }; 67 | /** Data sent to the [Update Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/customersconsentbycustomerid-put) Customers V3 endpoint when creating a customer during checkout */ 68 | readonly requestBody: { 69 | readonly content: { 70 | readonly "application/json": components["schemas"]["ConsentPreferences"]; 71 | }; 72 | }; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/consent.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/currencies.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/current_customer.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/customer/current.jwt": { 7 | /** 8 | *
9 | *
10 | *
11 | * 12 | * > ### Note 13 | * > The Send a Test Request feature is not currently supported for this endpoint. 14 | * 15 | *
16 | *
17 | *
18 | */ 19 | readonly get: operations["getCurrentCustomer"]; 20 | }; 21 | } 22 | export interface operations { 23 | /** 24 | *
25 | *
26 | *
27 | * 28 | * > ### Note 29 | * > The Send a Test Request feature is not currently supported for this endpoint. 30 | * 31 | *
32 | *
33 | *
34 | */ 35 | readonly getCurrentCustomer: { 36 | readonly parameters: { 37 | readonly query: { 38 | readonly app_client_id: string; 39 | }; 40 | }; 41 | readonly responses: { 42 | readonly default: { 43 | readonly schema: { 44 | readonly customer?: { 45 | /** Unique numeric ID of the customer. */ 46 | readonly id?: number; 47 | /** Email address of the customer. */ 48 | readonly email?: string; 49 | /** The group to which the customer belongs. */ 50 | readonly group_id?: string; 51 | }; 52 | /** Indicates the token’s issuer. This is your application’s client ID, which is obtained during application registration in Developer Portal. */ 53 | readonly iss?: string; 54 | /** The subject of the JWT - same as `store_hash`. */ 55 | readonly sub?: string; 56 | /** Time when the token was generated. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 57 | readonly iat?: number; 58 | /** Time when the token expires. The token usually expires after 15 minutes. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 59 | readonly exp?: number; 60 | /** Version of the Current Customer JWT */ 61 | readonly version?: number; 62 | /** The "aud" (audience) claim identifies the recipients that the JWT is intended for. This should match the *App Client ID* and the `application_id`. */ 63 | readonly aud?: string; 64 | /** The client ID created when the token was generated. */ 65 | readonly application_id?: string; 66 | /** Store hash identifying the store you are logging into. */ 67 | readonly store_hash?: string; 68 | /** Must contain the string “current_customer”. */ 69 | readonly operation?: string; 70 | }; 71 | }; 72 | }; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/current_customer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/custom_template_associations.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customer_login.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/login/token/{jwt_token}": { 7 | /** 8 | * The customer login access point URL. 9 | * 10 | * [Learn more about the Customer Login API](https://developer.bigcommerce.com/api-docs/customers/customer-login-api). 11 | * 12 | * ## Example 13 | * 14 | * ``` 15 | * https://storedomain.com/login/token/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7Y2xpZW50X2lkfSIsImlhdCI6MTUzNTM5MzExMywianRpIjoie3V1aWR9Iiwib3BlcmF0aW9uIjoiY3VzdG9tZXJfbG9naW4iLCJzdG9yZV9oYXNoIjoie3N0b3JlX2hhc2h9IiwiY3VzdG9tZXJfaWQiOjJ9.J-fAtbjRFGdLsT744DhoprFEDqIfVq72HbDzrbFy6Is 16 | * ``` 17 | */ 18 | readonly get: { 19 | readonly parameters: { 20 | readonly path: { 21 | readonly jwt_token: string; 22 | }; 23 | }; 24 | readonly responses: {}; 25 | }; 26 | readonly parameters: { 27 | readonly path: { 28 | readonly jwt_token: string; 29 | }; 30 | }; 31 | }; 32 | } 33 | export interface definitions { 34 | readonly customerLoginSSO: { 35 | /** Indicates the token’s issuer. This is your application’s client ID, which is obtained during application registration in Developer Portal. */ 36 | readonly iss?: string; 37 | /** Time when the token was generated. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 38 | readonly iat?: number; 39 | /** Request ID string that must be unique across all requests made by your app. A UUID or other random string would be an appropriate value. Most libraries contain a method for generating a uuid. For testing a [UUID generator](https://www.uuidgenerator.net/) can be used, but it recommended to use built in libraries. */ 40 | readonly jti?: string; 41 | /** Must contain the string “customer_login”. */ 42 | readonly operation?: string; 43 | /** Store hash identifying the store you are logging into. */ 44 | readonly store_hash?: string; 45 | /** ID of the customer you are logging in, as obtained through the Customer API. */ 46 | readonly customer_id?: number; 47 | /** Optional field containing a relative path for the shopper’s destination after login. Will default to `/account.php`. */ 48 | readonly redirect_to?: string; 49 | /** **(Optional)** Field containing the expected IP address for the request. If provided, BigCommerce will check that it matches the browser trying to log in. If there is not a match, it will be rejected. */ 50 | readonly request_ip?: string; 51 | }; 52 | } 53 | export interface operations { 54 | } 55 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customer_login.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customers.sf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/customers": { 7 | /** 8 | * Creates a *Customer*. 9 | * 10 | *
11 | *
12 | *
13 | * 14 | * > ### Note 15 | * > The Send a Test Request feature is not currently supported for this endpoint. 16 | * 17 | *
18 | *
19 | *
20 | */ 21 | readonly post: operations["createACustomer"]; 22 | }; 23 | } 24 | export interface components { 25 | readonly schemas: { 26 | readonly CustomerCreateData: { 27 | /** First name of customer */ 28 | readonly firstName?: string; 29 | /** Last name of customer */ 30 | readonly lastName?: string; 31 | /** Email of customer */ 32 | readonly email?: string; 33 | /** Password of customer */ 34 | readonly password?: string; 35 | /** Has customer provided consent to receive marketing emails. */ 36 | readonly acceptsMarketingEmails?: boolean; 37 | readonly customFields?: readonly components["schemas"]["CustomFields"][]; 38 | }; 39 | readonly CustomFields: { 40 | readonly fieldId?: string; 41 | readonly fieldValue?: string; 42 | }; 43 | }; 44 | } 45 | export interface operations { 46 | /** 47 | * Creates a *Customer*. 48 | * 49 | *
50 | *
51 | *
52 | * 53 | * > ### Note 54 | * > The Send a Test Request feature is not currently supported for this endpoint. 55 | * 56 | *
57 | *
58 | *
59 | */ 60 | readonly createACustomer: { 61 | readonly responses: { 62 | /** Customer succesfully created */ 63 | readonly 204: never; 64 | /** Could not create customer */ 65 | readonly 400: unknown; 66 | /** Missing Required Fields */ 67 | readonly 422: unknown; 68 | /** Spam Protection Failed */ 69 | readonly 429: unknown; 70 | }; 71 | /** Data sent the the customer endpoint when creating a customer during checkout. */ 72 | readonly requestBody: { 73 | readonly content: { 74 | readonly "application/json": components["schemas"]["CustomerCreateData"]; 75 | }; 76 | }; 77 | }; 78 | } 79 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customers.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customers.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/customers.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/email_templates.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/form_fields.sf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/form-fields": { 7 | /** 8 | * Gets form fields. 9 | * 10 | *
11 | *
12 | *
13 | * 14 | * > ### Note 15 | * > The Send a Test Request feature is not currently supported for this endpoint. 16 | * 17 | *
18 | *
19 | *
20 | */ 21 | readonly get: { 22 | readonly parameters: { 23 | readonly query: { 24 | readonly filter?: unknown; 25 | }; 26 | }; 27 | readonly responses: { 28 | /** Returns an object with form fields groups. */ 29 | readonly 200: { 30 | readonly schema: definitions["FormFieldGroups"]; 31 | }; 32 | }; 33 | }; 34 | }; 35 | } 36 | export interface definitions { 37 | /** Group of form field groups */ 38 | readonly FormFieldGroups: { 39 | readonly customerAccount?: definitions["FormFields"]; 40 | readonly shippingAddress?: definitions["FormFields"]; 41 | readonly billingAddress?: definitions["FormFields"]; 42 | }; 43 | /** List of form fields for the group */ 44 | readonly FormFields: readonly definitions["FormField"][]; 45 | /** Form Field */ 46 | readonly FormField: { 47 | /** Field unique ID */ 48 | readonly id?: string; 49 | /** Field name */ 50 | readonly name?: string; 51 | /** Wether is a custom field or system built-in field. */ 52 | readonly custom?: boolean; 53 | /** User-friendly label */ 54 | readonly label?: string; 55 | /** Wether this field is required or not */ 56 | readonly required?: boolean; 57 | /** The field unique ID */ 58 | readonly default?: string | null; 59 | /** Type of the value hold by the field */ 60 | readonly type?: ("integer" | "string" | "array" | "date") | null; 61 | /** Type of the field */ 62 | readonly fieldType?: ("checkbox" | "text" | "date" | "multiline" | "radio" | "dropdown") | null; 63 | /** The minimun valid value for the field (integer and date type only) */ 64 | readonly min?: string | null; 65 | /** The minimun valid value for the field (integer and date type only) */ 66 | readonly max?: string | null; 67 | /** The maximum length for the value (string type only) */ 68 | readonly maxLength?: number | null; 69 | /** Whether the field represents a password field */ 70 | readonly secret?: boolean | null; 71 | /** Extra data for radio, dropdown and checkbox field types. */ 72 | readonly options?: { 73 | /** Placeholder text for dropdown field type. */ 74 | readonly helperLabel?: string | null; 75 | /** List of possible values for this field. */ 76 | readonly items?: { 77 | /** Field option value. */ 78 | readonly value?: string; 79 | /** User friendly label. */ 80 | readonly label?: string; 81 | }; 82 | } | null; 83 | }; 84 | } 85 | export interface operations { 86 | } 87 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/form_fields.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/geography.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/marketing.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/misc.d.ts: -------------------------------------------------------------------------------- 1 | import type { InferOperationIndex } from "../operation-inference"; 2 | import type * as current_customer from "./current_customer"; 3 | import type * as customer_login from "./customer_login"; 4 | import type * as payment_processing from "./payment_processing"; 5 | import type * as shipping_provider from "./shipping_provider"; 6 | import type * as tax_provider from "./tax_provider"; 7 | export declare type Operation = InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex; 8 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/misc.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/orders.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/orders.v2.oas2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/orders.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/pages.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/payment_methods.v2.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/payments/methods": { 7 | /** Gets the list of enabled payment methods. Default sorting is by payment method, alphabetically from A to Z. */ 8 | readonly get: { 9 | readonly parameters: { 10 | readonly header: { 11 | readonly Accept: string; 12 | readonly "Content-Type": string; 13 | }; 14 | readonly query: { 15 | /** Optional filter param `/api/v2/payments/methods?page={number}` */ 16 | readonly page?: number; 17 | /** Optional filter param `/api/v2/payments/methods?limit={count}` */ 18 | readonly limit?: number; 19 | }; 20 | }; 21 | readonly responses: { 22 | readonly 200: responses["paymentCollection_Resp"]; 23 | }; 24 | }; 25 | }; 26 | } 27 | export interface definitions { 28 | readonly payment_Base: { 29 | /** Unique platform-wide code identifying the payment method. */ 30 | readonly code?: string; 31 | /** Descriptive name of the payment method. */ 32 | readonly name?: string; 33 | /** Determines whether the payment gateway is in test mode. Always false for offline payment methods. */ 34 | readonly test_mode?: boolean; 35 | }; 36 | } 37 | export interface responses { 38 | readonly paymentCollection_Resp: { 39 | readonly schema: readonly definitions["payment_Base"][]; 40 | }; 41 | } 42 | export interface operations { 43 | } 44 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/payment_methods.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/payment_processing.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/price_lists.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/pricing.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/redirects.v3.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/storefront/redirects": { 7 | /** Returns a collection of the store's 301 redirects across all sites. */ 8 | readonly get: operations["GetRedirects"]; 9 | /** Upserts new redirect data across all storefronts. */ 10 | readonly put: operations["UpsertRedirects"]; 11 | /** Deletes redirects. */ 12 | readonly delete: operations["DeleteRedirects"]; 13 | }; 14 | } 15 | export interface definitions { 16 | readonly Error: { 17 | readonly status?: number; 18 | readonly message?: string; 19 | }; 20 | readonly ErrorResponse400: { 21 | readonly schema?: definitions["Error"]; 22 | }; 23 | readonly ErrorResponse404: { 24 | readonly schema?: definitions["Error"]; 25 | }; 26 | readonly ErrorResponse409: { 27 | readonly schema?: definitions["Error"]; 28 | }; 29 | readonly ErrorResponse422: { 30 | readonly schema?: definitions["Error"]; 31 | }; 32 | /** Data necessary to create or update a redirect. If there's a conflict on the from_path and site_id, the redirect will be overwritten with new data. */ 33 | readonly "301RedirectUpsert": { 34 | readonly from_path: string; 35 | readonly site_id: number; 36 | readonly to?: definitions["RedirectTo"]; 37 | }; 38 | /** Full detail of a Redirect, optionally including the full destination URL. */ 39 | readonly "301RedirectRead": { 40 | readonly from_path: string; 41 | readonly site_id: number; 42 | readonly to?: definitions["RedirectTo"]; 43 | readonly id?: number; 44 | /** Full destination URL for the redirect. Must be explicitly included via URL parameter. */ 45 | readonly to_url?: string; 46 | }; 47 | readonly MetaPaginationObject: { 48 | readonly pagination?: { 49 | readonly total?: number; 50 | readonly count?: number; 51 | readonly per_page?: number; 52 | readonly current_page?: number; 53 | readonly total_pages?: number; 54 | readonly links?: { 55 | readonly next?: string; 56 | readonly current?: string; 57 | }; 58 | }; 59 | }; 60 | readonly RedirectTo: { 61 | readonly type?: "product" | "brand" | "category" | "page" | "post" | "url"; 62 | readonly entity_id?: number; 63 | readonly url?: string; 64 | }; 65 | readonly DetailedErrors: { 66 | readonly [key: string]: string; 67 | }; 68 | /** Error payload for the BigCommerce API. */ 69 | readonly BaseError: { 70 | /** The HTTP status code. */ 71 | readonly status?: number; 72 | /** The error title describing the particular error. */ 73 | readonly title?: string; 74 | readonly type?: string; 75 | readonly instance?: string; 76 | }; 77 | readonly ErrorResponse: definitions["BaseError"] & { 78 | readonly errors?: definitions["DetailedErrors"]; 79 | }; 80 | } 81 | export interface operations { 82 | /** Returns a collection of the store's 301 redirects across all sites. */ 83 | readonly GetRedirects: { 84 | readonly parameters: { 85 | readonly query: { 86 | /** Filters items by `site_id`. */ 87 | readonly site_id?: number; 88 | /** Filters items by redirect `id`. Also accepts comma-separated values to filter for multiple redirects. */ 89 | readonly "id:in"?: readonly string[]; 90 | /** Controls the number of items to return per page. */ 91 | readonly limit?: number; 92 | /** Specifies the page number in a limited (paginated) list of items. Used to paginate large collections. */ 93 | readonly page?: number; 94 | /** Field name to sort by. Note: Since redirect `id` increments when new redirects are added, you can use that field to sort by redirect create date. */ 95 | readonly sort?: "from_path" | "type" | "site_id"; 96 | /** Sort direction. Acceptable values are `asc`, `desc`. */ 97 | readonly direction?: "asc" | "desc"; 98 | /** Indicates whether to include redirect sub-resources. Only `to_url` is supported. */ 99 | readonly include?: "to_url"; 100 | /** Filters redirects by the specified keyword. Will only search from the beginning of a URL path. For example, `blue` will match `/blue` and `/blue-shirt` , **not** `/royal-blue-shirt`. */ 101 | readonly keyword?: string; 102 | }; 103 | }; 104 | readonly responses: { 105 | readonly 200: { 106 | readonly schema: { 107 | readonly data?: definitions["301RedirectRead"]; 108 | readonly meta?: definitions["MetaPaginationObject"]; 109 | }; 110 | }; 111 | }; 112 | }; 113 | /** Upserts new redirect data across all storefronts. */ 114 | readonly UpsertRedirects: { 115 | readonly parameters: { 116 | readonly body: { 117 | readonly body?: readonly definitions["301RedirectUpsert"][]; 118 | }; 119 | }; 120 | readonly responses: { 121 | readonly 201: { 122 | readonly schema: { 123 | readonly data?: readonly definitions["301RedirectRead"][]; 124 | readonly meta?: definitions["MetaPaginationObject"]; 125 | }; 126 | }; 127 | }; 128 | }; 129 | /** Deletes redirects. */ 130 | readonly DeleteRedirects: { 131 | readonly parameters: { 132 | readonly query: { 133 | /** List of Redirect IDs to delete explicitly */ 134 | readonly "id:in": readonly number[]; 135 | /** Site ID provided to delete all redirects for a given Site */ 136 | readonly site_id?: number; 137 | }; 138 | }; 139 | readonly responses: { 140 | /** No Content */ 141 | readonly 204: never; 142 | }; 143 | }; 144 | } 145 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/redirects.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/scripts.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/settings.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/sf.d.ts: -------------------------------------------------------------------------------- 1 | import type { InferOperationIndex } from "../operation-inference"; 2 | import type * as carts from "./carts.sf"; 3 | import type * as checkouts from "./checkouts.sf"; 4 | import type * as consent from "./consent.sf"; 5 | import type * as customers from "./customers.sf"; 6 | import type * as form_fields from "./form_fields.sf"; 7 | import type * as orders from "./orders.sf"; 8 | import type * as pricing from "./pricing.sf"; 9 | import type * as subscriptions from "./subscriptions.sf"; 10 | export declare type Operation = InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex; 11 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/shipping.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/shipping.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/shipping_provider.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/sites.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/store_content.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/store_information.v2.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/store": { 7 | /** Returns metadata about a store. */ 8 | readonly get: { 9 | readonly parameters: { 10 | readonly header: { 11 | readonly Accept: string; 12 | readonly "Content-Type": string; 13 | }; 14 | }; 15 | readonly responses: { 16 | readonly 200: { 17 | readonly schema: definitions["StoreInformation"]; 18 | }; 19 | }; 20 | }; 21 | }; 22 | readonly "/time": { 23 | /** Returns the system timestamp at the time of the request. The time resource is useful for validating API authentication details and testing client connections. */ 24 | readonly get: { 25 | readonly parameters: { 26 | readonly header: { 27 | readonly Accept: string; 28 | readonly "Content-Type": string; 29 | }; 30 | }; 31 | readonly responses: { 32 | readonly 200: { 33 | readonly schema: definitions["timeStamp_Full"]; 34 | }; 35 | }; 36 | }; 37 | }; 38 | } 39 | export interface definitions { 40 | readonly StoreInformation: { 41 | /** Unique store identifier. */ 42 | readonly id?: string; 43 | /** Primary domain name. */ 44 | readonly domain?: string; 45 | /** Store’s current HTTPS URL. */ 46 | readonly secure_url?: string; 47 | /** The secure hostname of the control panel. */ 48 | readonly control_panel_base_url?: string; 49 | /** Store's name. */ 50 | readonly name?: string; 51 | /** Primary contact’s first name (as defined during the store sign-up process). */ 52 | readonly first_name?: string; 53 | /** Primary contact’s last name (as defined during the store sign-up process). */ 54 | readonly last_name?: string; 55 | /** Display address. */ 56 | readonly address?: string; 57 | /** Country where the store is located (as defined during the store sign-up process). */ 58 | readonly country?: string; 59 | /** Display phone number. */ 60 | readonly phone?: string; 61 | /** Email address of the store administrator/owner. */ 62 | readonly admin_email?: string; 63 | /** Email address for orders and fulfillment. */ 64 | readonly order_email?: string; 65 | readonly timezone?: definitions["Timezone"]; 66 | /** Default language code. */ 67 | readonly language?: string; 68 | /** Default currency code */ 69 | readonly currency?: string; 70 | /** Default symbol for values in the currency. */ 71 | readonly currency_symbol?: string; 72 | /** Default decimal separator for values in the currency. */ 73 | readonly decimal_separator?: string; 74 | /** Default thousands separator for values in the currency. */ 75 | readonly thousands_separator?: string; 76 | /** Default decimal places for values in the currency. */ 77 | readonly decimal_places?: number; 78 | /** Default position of the currency symbol (left or right). */ 79 | readonly currency_symbol_location?: string; 80 | /** Default weight units (metric or imperial). */ 81 | readonly weight_units?: string; 82 | /** Default dimension units (metric or imperial). */ 83 | readonly dimension_units?: string; 84 | /** The number of decimal places. */ 85 | readonly dimension_decimal_places?: number; 86 | /** The symbol that separates the whole numbers from the decimal points. */ 87 | readonly dimension_decimal_token?: string; 88 | /** The symbol used to denote thousands. */ 89 | readonly "dimension_thousands_token:"?: string; 90 | /** Name of the BigCommerce plan to which this store is subscribed. */ 91 | readonly plan_name?: string; 92 | /** Level of the BigCommerce plan to which this store is subscribed. */ 93 | readonly plan_level?: string; 94 | /** Industry, or vertical category, in which the business operates. (As selected from drop-down list during the store sign-up process.) */ 95 | readonly industry?: string; 96 | readonly logo?: { 97 | readonly url?: string; 98 | }; 99 | /** A Boolean value that indicates whether or not prices are entered with tax. */ 100 | readonly is_price_entered_with_tax?: boolean; 101 | readonly active_comparison_modules?: readonly { 102 | readonly [key: string]: any; 103 | }[]; 104 | /** 105 | * + `stencil_enabled`: `true` (boolean) 106 | * + `sitewidehttps_enabled`: `false` (boolean) 107 | * + `facebook_catalog_id` (string) 108 | */ 109 | readonly features?: { 110 | /** Indicates whether a store is using a Stencil theme. */ 111 | readonly stencil_enabled?: boolean; 112 | /** Indicates if there is sitewide https. */ 113 | readonly sitewidehttps_enabled?: string; 114 | /** Id of the facebook catalog. If there is none, it returns an empty string. */ 115 | readonly facebook_catalog_id?: string; 116 | /** What type of checkout is enabled on the store. Possible values returned are optimized, single (one page), single_customizable (one page for developers), klarna. */ 117 | readonly checkout_type?: string; 118 | }; 119 | }; 120 | readonly Timezone: { 121 | /** a string identifying the time zone, in the format: /. */ 122 | readonly name?: string; 123 | /** a negative or positive number, identifying the offset from UTC/GMT, in seconds, during winter/standard time. */ 124 | readonly raw_offset?: number; 125 | /** "-/+" offset from UTC/GMT, in seconds, during summer/daylight saving time. */ 126 | readonly dst_offset?: number; 127 | /** a boolean indicating whether this time zone observes daylight saving time. */ 128 | readonly dst_correction?: boolean; 129 | readonly date_format?: definitions["DateFormat"]; 130 | }; 131 | readonly DateFormat: { 132 | /** string that defines dates’ display format, in the pattern: M jS Y */ 133 | readonly display?: string; 134 | /** string that defines the CSV export format for orders, customers, and products, in the pattern: M jS Y */ 135 | readonly export?: string; 136 | /** string that defines dates’ extended-display format, in the pattern: M jS Y @ g:i A. */ 137 | readonly extended_display?: string; 138 | }; 139 | /** Store Time in Unix format. */ 140 | readonly timeStamp_Full: { 141 | readonly time?: number; 142 | }; 143 | } 144 | export interface operations { 145 | } 146 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/store_information.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/storefront_tokens.v3.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/storefront/api-token": { 7 | /** 8 | * Creates a Storefront API token. 9 | * 10 | * **Required Scopes** 11 | * * `Manage` `Storefront API Tokens` 12 | */ 13 | readonly post: operations["createToken"]; 14 | /** Revoke access for a Storefront API token. */ 15 | readonly delete: operations["revokeToken"]; 16 | }; 17 | readonly "/storefront/api-token-customer-impersonation": { 18 | /** 19 | * Creates a Storefront API token that allows for customer impersonation. 20 | * 21 | * **Required Scopes** 22 | * * `Manage` `Storefront API Customer Impersonation Tokens` 23 | * 24 | * **Headers**: 25 | * * `X-Bc-Customer-Id` - The ID of the Customer to impersonate 26 | */ 27 | readonly post: operations["createTokenWithCustomerImpersonation"]; 28 | }; 29 | } 30 | export interface definitions { 31 | readonly TokenPostImpersonation: { 32 | /** Channel ID for requested token */ 33 | readonly channel_id: number; 34 | /** Unix timestamp (UTC time) defining when the token should expire. */ 35 | readonly expires_at: number; 36 | }; 37 | readonly TokenPostSimple: { 38 | /** List of allowed domains for Cross-Origin Request Sharing. Currently only accepts a single element. */ 39 | readonly allowed_cors_origins?: readonly string[]; 40 | }; 41 | readonly Token_Full: { 42 | readonly data?: definitions["Token_Base"]; 43 | readonly meta?: { 44 | readonly [key: string]: any; 45 | }; 46 | }; 47 | readonly Token_Base: { 48 | /** JWT Token for accessing the Storefront API */ 49 | readonly token?: string; 50 | }; 51 | readonly ErrorResponse: definitions["BaseError"] & { 52 | readonly errors?: definitions["DetailedErrors"]; 53 | }; 54 | /** Error payload for the BigCommerce API. */ 55 | readonly BaseError: { 56 | /** The HTTP status code. */ 57 | readonly status?: number; 58 | /** The error title describing the particular error. */ 59 | readonly title?: string; 60 | readonly type?: string; 61 | }; 62 | readonly DetailedErrors: { 63 | readonly [key: string]: string; 64 | }; 65 | } 66 | export interface responses { 67 | readonly TokenResponse: { 68 | readonly schema: definitions["Token_Full"]; 69 | }; 70 | } 71 | export interface operations { 72 | /** 73 | * Creates a Storefront API token. 74 | * 75 | * **Required Scopes** 76 | * * `Manage` `Storefront API Tokens` 77 | */ 78 | readonly createToken: { 79 | readonly parameters: { 80 | readonly body: { 81 | readonly body?: definitions["TokenPostSimple"] & definitions["TokenPostImpersonation"]; 82 | }; 83 | }; 84 | readonly responses: { 85 | readonly 200: responses["TokenResponse"]; 86 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 87 | readonly 401: unknown; 88 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 89 | readonly 403: unknown; 90 | /** Invalid JSON request body - missing or invalid data. */ 91 | readonly 422: unknown; 92 | }; 93 | }; 94 | /** Revoke access for a Storefront API token. */ 95 | readonly revokeToken: { 96 | readonly parameters: { 97 | readonly header: { 98 | /** An existing JWT token that you want to revoke. */ 99 | readonly "Sf-Api-Token": string; 100 | }; 101 | }; 102 | readonly responses: { 103 | /** A storefront API token revocation has been scheduled. */ 104 | readonly 200: unknown; 105 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 106 | readonly 401: unknown; 107 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 108 | readonly 403: unknown; 109 | /** Invalid JWT Token provided or missing JWT token header */ 110 | readonly 422: unknown; 111 | }; 112 | }; 113 | /** 114 | * Creates a Storefront API token that allows for customer impersonation. 115 | * 116 | * **Required Scopes** 117 | * * `Manage` `Storefront API Customer Impersonation Tokens` 118 | * 119 | * **Headers**: 120 | * * `X-Bc-Customer-Id` - The ID of the Customer to impersonate 121 | */ 122 | readonly createTokenWithCustomerImpersonation: { 123 | readonly parameters: { 124 | readonly header: { 125 | /** Ther Customer ID for the customer to impersonate */ 126 | readonly "X-Bc-Customer-Id": number; 127 | }; 128 | readonly body: { 129 | readonly body?: definitions["TokenPostImpersonation"]; 130 | }; 131 | }; 132 | readonly responses: { 133 | readonly 200: responses["TokenResponse"]; 134 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 135 | readonly 401: unknown; 136 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 137 | readonly 403: unknown; 138 | /** Invalid JSON request body - missing or invalid data */ 139 | readonly 422: unknown; 140 | }; 141 | }; 142 | } 143 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/storefront_tokens.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/subscribers.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/subscriptions.sf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/subscriptions": { 7 | /** 8 | * Creates or updates an email subscription. 9 | * 10 | * By default, customers receive abandoned cart emails as soon as they provide their email address in the checkout flow. They can opt out using this endpoint. 11 | * 12 | * However, if **Store Settings > Miscellaneous > Require Consent** is enabled, Abandoned Cart Emails are not sent by default, and the customer should opt-in. 13 | * 14 | *
15 | *
16 | *
17 | * 18 | * > ### Note 19 | * > The Send a Test Request feature is not currently supported for this endpoint. 20 | * 21 | *
22 | *
23 | *
24 | */ 25 | readonly post: { 26 | readonly parameters: { 27 | readonly body: { 28 | readonly body?: definitions["SubscriptionRequest"]; 29 | }; 30 | }; 31 | readonly responses: { 32 | readonly 200: { 33 | readonly schema: definitions["Subscription"]; 34 | }; 35 | }; 36 | }; 37 | }; 38 | } 39 | export interface definitions { 40 | readonly SubscriptionRequest: { 41 | /** Email of subscriber */ 42 | readonly email?: string; 43 | /** Has subscriber provided consent for receiving Marketing emails. */ 44 | readonly acceptsMarketingNewsletter?: boolean; 45 | /** Has subscriber provided consent for receiving Abandon Cart emails. */ 46 | readonly acceptsAbandonedCartEmails?: boolean; 47 | }; 48 | /** Subscription properties. */ 49 | readonly Subscription: { 50 | /** The unique numeric ID of the subscriber; increments sequentially. */ 51 | readonly id?: number; 52 | /** The email of the subscriber. Must be unique. */ 53 | readonly email?: string; 54 | /** The first name of the subscriber. */ 55 | readonly firstName?: string; 56 | /** The last name of the subscriber. */ 57 | readonly lastName?: string; 58 | /** The source of the subscriber. Values are: `storefront`, `order`, or `custom`. */ 59 | readonly source?: string; 60 | /** The ID of the source order, if source was an order. */ 61 | readonly orderId?: number; 62 | /** The collection of consents the shopper is subscribing to. */ 63 | readonly consents?: readonly any[]; 64 | }; 65 | } 66 | export interface operations { 67 | } 68 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/subscriptions.sf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/tax.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/tax_classes.v2.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | export interface paths { 6 | readonly "/tax_classes": { 7 | /** 8 | * Returns a list of all *Tax Classes* in a store. 9 | * 10 | * Default sorting is by tax-class id, from lowest to highest. 11 | */ 12 | readonly get: operations["getAllTaxClasses"]; 13 | }; 14 | readonly "/tax_classes/{id}": { 15 | /** Returns a single *Tax Class*. */ 16 | readonly get: operations["getATaxClass"]; 17 | }; 18 | } 19 | export interface definitions { 20 | readonly taxClass_Full: { 21 | /** The unique numerical ID of the tax class. A read-only value which is automatically assigned and increments sequentially. */ 22 | readonly id?: string; 23 | /** The name of the tax class. */ 24 | readonly name?: string; 25 | /** Date and time of the tax class' creation. Read-Only. */ 26 | readonly created_at?: string; 27 | /** Date and time when the tax class was last updated. Read-Only. */ 28 | readonly updated_at?: string; 29 | }; 30 | } 31 | export interface operations { 32 | /** 33 | * Returns a list of all *Tax Classes* in a store. 34 | * 35 | * Default sorting is by tax-class id, from lowest to highest. 36 | */ 37 | readonly getAllTaxClasses: { 38 | readonly parameters: { 39 | readonly header: { 40 | readonly Accept: string; 41 | readonly "Content-Type": string; 42 | }; 43 | readonly query: { 44 | /** Optional filter param. Number of pages. */ 45 | readonly page?: number; 46 | /** Optional filter param. Number of items per page */ 47 | readonly limit?: number; 48 | }; 49 | }; 50 | readonly responses: { 51 | readonly 200: { 52 | readonly schema: readonly definitions["taxClass_Full"][]; 53 | }; 54 | }; 55 | }; 56 | /** Returns a single *Tax Class*. */ 57 | readonly getATaxClass: { 58 | readonly parameters: { 59 | readonly path: { 60 | /** Id of the tax class. */ 61 | readonly id: number; 62 | }; 63 | readonly header: { 64 | readonly Accept: string; 65 | readonly "Content-Type": string; 66 | }; 67 | }; 68 | readonly responses: { 69 | readonly 200: { 70 | readonly schema: definitions["taxClass_Full"]; 71 | }; 72 | }; 73 | }; 74 | } 75 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/tax_classes.v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/tax_provider.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/themes.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/v2.d.ts: -------------------------------------------------------------------------------- 1 | import type { InferOperationIndex } from "../operation-inference"; 2 | import type * as currencies from "./currencies.v2"; 3 | import type * as customers from "./customers.v2"; 4 | import type * as geography from "./geography.v2"; 5 | import type * as marketing from "./marketing.v2"; 6 | import type * as orders from "./orders.v2.oas2"; 7 | import type * as payment_methods from "./payment_methods.v2"; 8 | import type * as shipping from "./shipping.v2"; 9 | import type * as store_content from "./store_content.v2"; 10 | import type * as store_information from "./store_information.v2"; 11 | import type * as tax_classes from "./tax_classes.v2"; 12 | export declare type Operation = InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex; 13 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/v2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/v3.d.ts: -------------------------------------------------------------------------------- 1 | import type { InferOperationIndex } from "../operation-inference"; 2 | import type * as abandoned_carts from "./abandoned_carts.v3"; 3 | import type * as carts from "./carts.v3"; 4 | import type * as catalog from "./catalog.v3"; 5 | import type * as channels from "./channels.v3"; 6 | import type * as checkouts from "./checkouts.v3"; 7 | import type * as custom_template_associations from "./custom_template_associations.v3"; 8 | import type * as customers from "./customers.v3"; 9 | import type * as email_templates from "./email_templates.v3"; 10 | import type * as orders from "./orders.v3"; 11 | import type * as pages from "./pages.v3"; 12 | import type * as price_lists from "./price_lists.v3"; 13 | import type * as redirects from "./redirects.v3"; 14 | import type * as scripts from "./scripts.v3"; 15 | import type * as settings from "./settings.v3"; 16 | import type * as shipping from "./shipping.v3"; 17 | import type * as sites from "./sites.v3"; 18 | import type * as storefront_tokens from "./storefront_tokens.v3"; 19 | import type * as subscribers from "./subscribers.v3"; 20 | import type * as tax from "./tax.v3"; 21 | import type * as themes from "./themes.v3"; 22 | import type * as webhooks from "./webhooks.v3"; 23 | import type * as widgets from "./widgets.v3"; 24 | import type * as wishlists from "./wishlists.v3"; 25 | export declare type Operation = InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex & InferOperationIndex; 26 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/webhooks.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/widgets.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/generated/wishlists.v3.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * This file was auto-generated by openapi-typescript. 4 | * Do not make direct changes to the file. 5 | */ 6 | Object.defineProperty(exports, "__esModule", { value: true }); 7 | -------------------------------------------------------------------------------- /lib/internal/reference/index.d.ts: -------------------------------------------------------------------------------- 1 | export * as Storefront from "./generated/sf"; 2 | export * as V2 from "./generated/v2"; 3 | export * as V3 from "./generated/v3"; 4 | -------------------------------------------------------------------------------- /lib/internal/reference/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 10 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 11 | }) : function(o, v) { 12 | o["default"] = v; 13 | }); 14 | var __importStar = (this && this.__importStar) || function (mod) { 15 | if (mod && mod.__esModule) return mod; 16 | var result = {}; 17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 18 | __setModuleDefault(result, mod); 19 | return result; 20 | }; 21 | Object.defineProperty(exports, "__esModule", { value: true }); 22 | exports.V3 = exports.V2 = exports.Storefront = void 0; 23 | exports.Storefront = __importStar(require("./generated/sf")); 24 | exports.V2 = __importStar(require("./generated/v2")); 25 | exports.V3 = __importStar(require("./generated/v3")); 26 | -------------------------------------------------------------------------------- /lib/internal/reference/operation-inference.d.ts: -------------------------------------------------------------------------------- 1 | import type { RequestMethod } from "../operation"; 2 | export declare type InferOperationIndex = Flatten<{ 3 | [PathStr in (keyof PathsSpec) & string]: PathOperationIndex; 4 | }>; 5 | declare type Flatten> = UnionToIntersection; 6 | declare type UnionToIntersection = (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never; 7 | declare type PathOperationIndex = 1 extends 0 ? never : { 8 | [K in keyof PathSpec as K extends RequestMethodLc ? `${Uppercase} ${Path}` : never]: PathSpec[K] extends { 9 | parameters?: infer Params; 10 | responses?: infer Responses; 11 | requestBody: { 12 | content: { 13 | "application/json": infer RequestBody; 14 | }; 15 | }; 16 | } ? { 17 | readonly parameters: (unknown extends Params ? {} : Params) & { 18 | body: RequestBody; 19 | }; 20 | readonly response: Response; 21 | } : PathSpec[K] extends { 22 | parameters?: infer Params; 23 | responses?: infer Responses; 24 | } ? { 25 | readonly parameters: unknown extends Params ? {} : CorrectOas2RequestBody; 26 | readonly response: Response; 27 | } : never; 28 | }; 29 | declare type CorrectOas2RequestBody = Params extends { 30 | body: { 31 | [nonsenseKey: string]: infer RealBody; 32 | }; 33 | } ? Omit & { 34 | body: RealBody; 35 | } : Params extends { 36 | body?: { 37 | [nonsenseKey: string]: infer RealBody; 38 | }; 39 | } ? Omit & { 40 | body?: RealBody; 41 | } : Params; 42 | declare type RequestMethodLc = Lowercase; 43 | declare type Response = 1 extends 0 ? never : { 44 | [Status in keyof ResponsesSpec]: { 45 | status: Status; 46 | body: ResponsesSpec[Status] extends { 47 | content: { 48 | "application/json": infer ResponseBody; 49 | }; 50 | } ? ResponseBody : ResponsesSpec[Status] extends { 51 | schema: infer Schema; 52 | } ? Schema : never; 53 | }; 54 | }[keyof ResponsesSpec]; 55 | export {}; 56 | -------------------------------------------------------------------------------- /lib/internal/reference/operation-inference.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/internal/type-utils.d.ts: -------------------------------------------------------------------------------- 1 | export declare type Const = (A extends Narrowable ? A : never) | ({ 2 | [K in keyof A]: Const; 3 | }); 4 | declare type Narrowable = string | number | bigint | boolean | readonly any[]; 5 | export declare type RemoveStart = Subject extends `${Start}${infer End}` ? End : never; 6 | export {}; 7 | -------------------------------------------------------------------------------- /lib/internal/type-utils.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/management/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import { Agent } from "http"; 3 | import * as V2 from "./v2"; 4 | import * as V3 from "./v3"; 5 | export * as V2 from "./v2"; 6 | export * as V3 from "./v3"; 7 | export declare type Config = { 8 | readonly storeHash: string; 9 | readonly accessToken: string; 10 | readonly agent?: Agent; 11 | }; 12 | /** 13 | * If you need to use a path which is not part if the spec, you can pass it 14 | * into the client via a type parameter to avoid TypeScript errors, e.g.: 15 | * 16 | * type MyExtraEndpoints = 17 | * | 'GET /v3/foo/bar' 18 | * | 'POST /v3/foo/bar' 19 | * | 'GET /v2/foo/baz' 20 | * ; 21 | * 22 | * bigCommerce = new Client(config) 23 | */ 24 | export declare class Client { 25 | private readonly config; 26 | constructor(config: Config); 27 | readonly v2: V2.Client>; 28 | readonly v3: V3.Client>; 29 | } 30 | declare type ExtractSubpaths = AllCustomEndpoints extends `${infer Method} ${Path}${infer Subpath}` ? `${Method} ${Subpath}` : never; 31 | -------------------------------------------------------------------------------- /lib/management/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { 3 | if (k2 === undefined) k2 = k; 4 | Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); 5 | }) : (function(o, m, k, k2) { 6 | if (k2 === undefined) k2 = k; 7 | o[k2] = m[k]; 8 | })); 9 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { 10 | Object.defineProperty(o, "default", { enumerable: true, value: v }); 11 | }) : function(o, v) { 12 | o["default"] = v; 13 | }); 14 | var __importStar = (this && this.__importStar) || function (mod) { 15 | if (mod && mod.__esModule) return mod; 16 | var result = {}; 17 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); 18 | __setModuleDefault(result, mod); 19 | return result; 20 | }; 21 | Object.defineProperty(exports, "__esModule", { value: true }); 22 | exports.Client = exports.V3 = exports.V2 = void 0; 23 | const V2 = __importStar(require("./v2")); 24 | const V3 = __importStar(require("./v3")); 25 | exports.V2 = __importStar(require("./v2")); 26 | exports.V3 = __importStar(require("./v3")); 27 | /** 28 | * If you need to use a path which is not part if the spec, you can pass it 29 | * into the client via a type parameter to avoid TypeScript errors, e.g.: 30 | * 31 | * type MyExtraEndpoints = 32 | * | 'GET /v3/foo/bar' 33 | * | 'POST /v3/foo/bar' 34 | * | 'GET /v2/foo/baz' 35 | * ; 36 | * 37 | * bigCommerce = new Client(config) 38 | */ 39 | class Client { 40 | constructor(config) { 41 | this.config = config; 42 | this.v2 = new V2.Client(this.config); 43 | this.v3 = new V3.Client(this.config); 44 | } 45 | } 46 | exports.Client = Client; 47 | -------------------------------------------------------------------------------- /lib/management/v2/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { V2 as reference } from "../../internal/reference"; 2 | import type { NarrowResponse } from "./response-narrowing"; 3 | import { Operation, OperationIndex, Parameters, Request, RequestMethod, Response, Transport, FetchTransportOptions } from "../../internal/operation"; 4 | import { Const, RemoveStart } from "../../internal/type-utils"; 5 | export declare type Operations = reference.Operation; 6 | export declare type RequestLine = keyof Operations; 7 | export declare type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; 8 | export declare type InferResponse = NarrowResponse, Operations[ReqLine]['response']>; 9 | export declare type ResponseData = Response.Success> extends { 10 | readonly body: infer Data; 11 | } ? Data : never; 12 | export declare type Config = Omit & { 13 | readonly storeHash: string; 14 | readonly accessToken: string; 15 | }; 16 | export declare class Client { 17 | constructor(config: Config); 18 | constructor(transport: Transport); 19 | private readonly transport; 20 | send(requestLine: ReqLine): Promise>; 21 | send>(requestLine: ReqLine, params: Const>): Promise>; 22 | send(requestLine: string, params?: Parameters): Promise; 23 | delete>(requestLine: Path): Promise | null>; 24 | delete, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 25 | delete(path: RemoveStart<'DELETE ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 26 | get>(requestLine: Path): Promise | null>; 27 | get, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 28 | get(path: RemoveStart<'GET ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 29 | post>(requestLine: Path): Promise>; 30 | post, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 31 | post(path: RemoveStart<'POST ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 32 | put>(requestLine: Path): Promise>; 33 | put, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 34 | put(path: RemoveStart<'PUT ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 35 | private checkResponseStatus; 36 | } 37 | declare type ResolveResponse = unknown extends Params ? Operations[ReqLine]['response'] : Params extends Parameters ? InferResponse : never; 38 | declare type RequestPath = RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 39 | declare type NoParamsRequestPath = NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 40 | /** 41 | * A list of known BigCommerce endpoints which are not part of the Open API specs 42 | */ 43 | declare type UntypedEndpoints = never; 44 | export {}; 45 | -------------------------------------------------------------------------------- /lib/management/v2/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Client = void 0; 4 | const operation_1 = require("../../internal/operation"); 5 | class Client { 6 | constructor(configOrTransport) { 7 | this.transport = 8 | typeof configOrTransport === 'function' 9 | ? configOrTransport 10 | : (0, operation_1.fetchTransport)({ 11 | agent: configOrTransport.agent, 12 | baseUrl: `https://api.bigcommerce.com/stores/${configOrTransport.storeHash}/v2`, 13 | headers: { "X-Auth-Token": configOrTransport.accessToken }, 14 | }); 15 | } 16 | async send(requestLine, params) { 17 | return this.transport(requestLine, params); 18 | } 19 | async delete(path, params) { 20 | const res = await this.send(`DELETE ${path}`, params); 21 | if (res.status === 204) { 22 | return null; 23 | } 24 | this.checkResponseStatus(`DELETE ${path}`, res); 25 | return res.body; 26 | } 27 | async get(path, params) { 28 | const res = await this.send(`GET ${path}`, params); 29 | if (res.status === 204 || res.status === 404) { 30 | return null; 31 | } 32 | this.checkResponseStatus(`GET ${path}`, res); 33 | return res.body; 34 | } 35 | async post(path, params) { 36 | const res = await this.send(`POST ${path}`, params); 37 | this.checkResponseStatus(`POST ${path}`, res); 38 | return res.body; 39 | } 40 | async put(path, params) { 41 | const res = await this.send(`PUT ${path}`, params); 42 | this.checkResponseStatus(`PUT ${path}`, res); 43 | return res.body; 44 | } 45 | checkResponseStatus(requestLine, response) { 46 | if (response.status > 299) { 47 | throw new Error(`ERROR DURING ${requestLine}: ${response.status} - ${JSON.stringify(response.body)}`); 48 | } 49 | } 50 | } 51 | exports.Client = Client; 52 | -------------------------------------------------------------------------------- /lib/management/v2/response-narrowing.d.ts: -------------------------------------------------------------------------------- 1 | import type { OperationIndex, Request, Response } from "../../internal/operation"; 2 | /** 3 | * This module contains functionality for narrowing the response type based on input parameters. 4 | * 5 | * See v3 for examples of how this can be done. 6 | */ 7 | export declare type NarrowResponse = Rep; 8 | -------------------------------------------------------------------------------- /lib/management/v2/response-narrowing.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/management/v3/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { V3 as reference } from "../../internal/reference"; 2 | import type { NarrowResponse } from "./response-narrowing"; 3 | import { Operation, OperationIndex, Parameters, Request, RequestMethod, Response, Transport, FetchTransportOptions } from "../../internal/operation"; 4 | import { Const } from "../../internal/type-utils"; 5 | import { RemoveStart } from "../../internal/type-utils"; 6 | export declare type Operations = reference.Operation; 7 | export declare type RequestLine = keyof Operations; 8 | export declare type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; 9 | export declare type InferResponse = NarrowResponse, Operations[ReqLine]['response']>; 10 | export declare type ResponseData = Response.Success> extends { 11 | readonly body: { 12 | readonly data?: infer Data; 13 | }; 14 | } ? Data : never; 15 | export declare type Config = Omit & { 16 | readonly storeHash: string; 17 | readonly accessToken: string; 18 | }; 19 | export declare class Client { 20 | constructor(config: Config); 21 | constructor(transport: Transport); 22 | private readonly transport; 23 | send(requestLine: ReqLine): Promise>; 24 | send>(requestLine: ReqLine, params: Const>): Promise>; 25 | send(requestLine: string, params?: Parameters): Promise; 26 | get>(path: Path): Promise | null>; 27 | get, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 28 | get(path: RemoveStart<'GET ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 29 | list(path: Path): AsyncIterable>; 30 | list>(path: Path, params: Const>): AsyncIterable>; 31 | list(path: RemoveStart<'GET ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): AsyncIterable; 32 | post>(path: Path): Promise>; 33 | post, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 34 | post(path: RemoveStart<'POST ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 35 | put>(path: Path): Promise>; 36 | put, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 37 | put(path: RemoveStart<'PUT ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 38 | delete>(path: Path): Promise | null>; 39 | delete, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 40 | delete(path: RemoveStart<'DELETE ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise; 41 | private checkResponseStatus; 42 | } 43 | declare type ListItemType = ResponseData<`GET ${Path}` & RequestLine, Params> extends ReadonlyArray ? T : never; 44 | declare type ListablePath = ListablePath_; 45 | declare type NoParamsListablePath = ListablePath & NoParamsRequestPath<'GET'>; 46 | declare type ListablePath_ = { 47 | [ReqLine in keyof Ops]: Response.Success extends { 48 | body: { 49 | data?: ReadonlyArray; 50 | }; 51 | } ? ReqLine extends `GET ${infer Path}` ? Path : never : never; 52 | }[keyof Ops]; 53 | declare type ResolveResponse = unknown extends Params ? Operations[ReqLine]['response'] : Params extends Parameters ? InferResponse : never; 54 | declare type RequestPath = RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 55 | declare type NoParamsRequestPath = NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 56 | /** 57 | * A list of known BigCommerce endpoints which are not part of the Open API specs 58 | */ 59 | declare type UntypedEndpoints = PromoEndpoints | PromoCodeEndpoints; 60 | declare type PromoEndpoints = 'GET /promotions' | 'GET /promotions/{id}' | 'POST /promotions' | 'PUT /promotions/{id}' | 'DELETE /promotions' | 'DELETE /promotions/{id}'; 61 | declare type PromoCodeEndpoints = 'GET /promotions/{promotion_id}/codes' | 'POST /promotions/{promotion_id}/codes' | 'DELETE /promotions/{promotion_id}/codes' | 'DELETE /promotions/{promotion_id}/codes/{code_id}'; 62 | export {}; 63 | -------------------------------------------------------------------------------- /lib/management/v3/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.Client = void 0; 4 | const operation_1 = require("../../internal/operation"); 5 | class Client { 6 | constructor(configOrTransport) { 7 | this.transport = 8 | typeof configOrTransport === 'function' 9 | ? configOrTransport 10 | : (0, operation_1.fetchTransport)({ 11 | headers: { "X-Auth-Token": configOrTransport.accessToken }, 12 | baseUrl: `https://api.bigcommerce.com/stores/${configOrTransport.storeHash}/v3`, 13 | agent: configOrTransport.agent, 14 | }); 15 | } 16 | send(requestLine, params) { 17 | return this.transport(requestLine, params); 18 | } 19 | async get(path, params) { 20 | const res = await this.send(`GET ${path}`, params); 21 | if (res.status === 204 || res.status === 404) { 22 | return null; 23 | } 24 | this.checkResponseStatus(`GET ${path}`, res); 25 | return res.body.data; 26 | } 27 | async *list(path, params) { 28 | const MAX_PAGES = Number.MAX_SAFE_INTEGER; 29 | for (let page = 1; page < MAX_PAGES; page++) { 30 | const res = await this.send(`GET ${path}`, { ...params, query: { ...params === null || params === void 0 ? void 0 : params.query, page } }); 31 | this.checkResponseStatus(`GET ${path}`, res); 32 | const items = res.body.data; 33 | if (!(items === null || items === void 0 ? void 0 : items.length)) { 34 | break; 35 | } 36 | yield* res.body.data; 37 | } 38 | } 39 | async post(path, params) { 40 | const res = await this.send(`POST ${path}`, params); 41 | this.checkResponseStatus(`POST ${path}`, res); 42 | return res.body.data; 43 | } 44 | async put(path, params) { 45 | const res = await this.send(`PUT ${path}`, params); 46 | this.checkResponseStatus(`PUT ${path}`, res); 47 | return res.body.data; 48 | } 49 | async delete(path, params) { 50 | const res = await this.send(`DELETE ${path}`, params); 51 | this.checkResponseStatus(`DELETE ${path}`, res); 52 | if (res.status === 204) { 53 | return null; 54 | } 55 | return res.body.data; 56 | } 57 | checkResponseStatus(requestLine, response) { 58 | if (response.status > 299) { 59 | throw new Error(`ERROR DURING ${requestLine}: ${response.status} - ${JSON.stringify(response.body)}`); 60 | } 61 | } 62 | } 63 | exports.Client = Client; 64 | -------------------------------------------------------------------------------- /lib/management/v3/response-narrowing.d.ts: -------------------------------------------------------------------------------- 1 | import type { Operation, OperationIndex, Parameters, Request, Response } from "../../internal/operation"; 2 | /** 3 | * This module contains functionality for narrowing the response type based on input parameters. 4 | * 5 | * For example, when requesting a product, specifying `{ include_fields: ['sku'] }` will cause BigCommerce 6 | * to only return the `id` and `sku` fields (as `id` is always returned). This module ensures that response 7 | * types reflect the query parameters which were passed in the request. 8 | * 9 | * Currently, this module supports `include`, `include_fields` and `exclude_fields`. 10 | */ 11 | export declare type NarrowResponse = NarrowResponse_>; 12 | declare type Includes = Op['parameters'] extends { 13 | query?: { 14 | include?: infer T; 15 | }; 16 | } ? T extends ReadonlyArray ? E : T extends string ? T : never : never; 17 | declare type NarrowResponse_ = Rep extends { 18 | body: { 19 | data?: infer Data; 20 | meta?: infer Meta; 21 | }; 22 | } ? { 23 | status: Rep['status']; 24 | body: { 25 | data: NarrowData; 26 | meta: Meta; 27 | }; 28 | } : Rep; 29 | declare type NarrowData | undefined, Includes extends string> = Data extends ReadonlyArray ? ReadonlyArray> : Required, Query> & NarrowIncludes, Query>>; 30 | declare type NarrowFields | undefined> = Query extends { 31 | include_fields: ReadonlyArray; 32 | } ? Pick : Query extends { 33 | exclude_fields: ReadonlyArray; 34 | } ? Omit : Data; 35 | declare type NarrowIncludes | undefined> = Query extends { 36 | include: ReadonlyArray; 37 | } ? Pick : {}; 38 | export {}; 39 | -------------------------------------------------------------------------------- /lib/management/v3/response-narrowing.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/management/v3/spec-sniffer.d.ts: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /lib/management/v3/spec-sniffer.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/storefront/index.d.ts: -------------------------------------------------------------------------------- 1 | import type { Storefront as reference } from "../internal/reference"; 2 | import type { NarrowResponse } from "./response-narrowing"; 3 | import type { Operation, OperationIndex, Parameters, Request, RequestMethod, Response } from "../internal/operation"; 4 | import { Const } from "../internal/type-utils"; 5 | export declare type Operations = reference.Operation; 6 | export declare type RequestLine = keyof Operations; 7 | export declare type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; 8 | export declare type InferResponse = NarrowResponse, Operations[ReqLine]['response']>; 9 | export declare type ResponseData = Response.Success> extends { 10 | readonly body: infer Data; 11 | } ? Data : never; 12 | export interface Client { 13 | send(requestLine: ReqLine): Promise>; 14 | send>(requestLine: ReqLine, params: Const>): Promise>; 15 | delete>(requestLine: Path): Promise | null>; 16 | delete, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 17 | get>(requestLine: Path): Promise | null>; 18 | get, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise | null>; 19 | post>(requestLine: Path): Promise>; 20 | post, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 21 | put>(requestLine: Path): Promise>; 22 | put, Params extends Operation.MinimalInput>(path: Path, params: Const>): Promise>; 23 | } 24 | declare type ResolveResponse = unknown extends Params ? Operations[ReqLine]['response'] : Params extends Parameters ? InferResponse : never; 25 | declare type RequestPath = RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 26 | declare type NoParamsRequestPath = NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 27 | export {}; 28 | -------------------------------------------------------------------------------- /lib/storefront/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /lib/storefront/response-narrowing.d.ts: -------------------------------------------------------------------------------- 1 | import type { OperationIndex, Request, Response } from "../internal/operation"; 2 | /** 3 | * This module contains functionality for narrowing the response type based on input parameters. 4 | * 5 | * See management/v3 for examples of how this can be done. 6 | */ 7 | export declare type NarrowResponse = Rep; 8 | -------------------------------------------------------------------------------- /lib/storefront/response-narrowing.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@space48/bigcommerce-api", 3 | "version": "0.3.2", 4 | "description": "", 5 | "main": "lib/index.js", 6 | "types": "lib/index.d.ts", 7 | "files": [ 8 | "lib" 9 | ], 10 | "scripts": { 11 | "build": "tsc", 12 | "build-reference-types": "node src/internal/reference/generate", 13 | "clean": "rimraf lib", 14 | "prepare": "npm run clean && npm run build -- --build tsconfig.publish.json" 15 | }, 16 | "engines": { 17 | "node": ">=14" 18 | }, 19 | "repository": { 20 | "type": "git", 21 | "url": "git+https://github.com/Space48/bigcommerce-api-js.git" 22 | }, 23 | "author": "Josh Di Fabio ", 24 | "license": "MIT", 25 | "devDependencies": { 26 | "@types/node": "^15.3.1", 27 | "openapi-typescript": "^3.4.1", 28 | "rimraf": "^3.0.2", 29 | "shell-escape": "^0.2.0", 30 | "temp-dir": "^2.0.0", 31 | "typescript": "^4.4.2", 32 | "uuid": "^8.3.2" 33 | }, 34 | "dependencies": { 35 | "@types/node-fetch": "^2.5.12", 36 | "form-data": "^4.0.0", 37 | "node-fetch": "^2.6.1", 38 | "query-string": "^7.0.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export * as Management from "./management"; 2 | // export * as Storefront from "./storefront" 3 | -------------------------------------------------------------------------------- /src/internal/augmentation.ts: -------------------------------------------------------------------------------- 1 | import type { Operation, OperationIndex } from "./operation"; 2 | 3 | export type AugmentOps = { 4 | [K in keyof Base]: 5 | K extends keyof Augmentation 6 | ? AugmentOp 7 | : Base[K] 8 | }; 9 | 10 | type OperationIndexAugmentation = Record; 11 | 12 | export type AugmentOp = { 13 | [K in keyof Base | keyof Augmentation]: 14 | K extends keyof Base & keyof Augmentation & 'parameters' 15 | ? Augmentation['parameters'] extends ParamAugmentation 16 | ? AugmentParams 17 | : Base['parameters'] 18 | : K extends keyof Augmentation & 'response' 19 | ? Augmentation[K] 20 | : K extends keyof Base 21 | ? Base[K] 22 | : never 23 | } 24 | 25 | type OperationAugmentation = { 26 | parameters?: ParamAugmentation 27 | response?: any 28 | }; 29 | 30 | export type AugmentParams = { 31 | [K in keyof Base | keyof Augmentation]: 32 | K extends keyof Augmentation & 'query' 33 | ? AugmentRecord, Exclude> 34 | : K extends keyof Augmentation & 'body' 35 | ? Augmentation['body'] 36 | : K extends keyof Base 37 | ? Base[K] 38 | : never 39 | } 40 | 41 | type ParamAugmentation = { 42 | query?: Record 43 | body?: any 44 | }; 45 | 46 | type AugmentRecord = 1 extends 0 ? never : { 47 | [K in (keyof Base) | (keyof Augmentation)]: 48 | K extends keyof Augmentation ? Augmentation[K] 49 | : K extends keyof Base ? Base[K] 50 | : never 51 | } 52 | -------------------------------------------------------------------------------- /src/internal/operation.ts: -------------------------------------------------------------------------------- 1 | import { stringify } from "query-string"; 2 | import { Agent } from "http"; 3 | import { Agent as HttpsAgent } from "https"; 4 | import fetch, { Response as FetchResponse } from "node-fetch"; 5 | 6 | export type RequestMethod = 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT'; 7 | 8 | export type Request = { 9 | readonly requestLine: ReqLine 10 | readonly parameters: Params 11 | }; 12 | 13 | export type RequestLine = `${RequestMethod} ${string}`; 14 | 15 | export type Parameters = { 16 | readonly path?: Record 17 | readonly query?: any 18 | readonly body?: any 19 | readonly header?: Record 20 | }; 21 | 22 | export type Response = { 23 | readonly status: number | string 24 | readonly body?: any 25 | }; 26 | 27 | export namespace Response { 28 | export type Success = 29 | T extends { status: 200 | 201 | 204 } ? T 30 | : T extends Operation ? Success 31 | : never; 32 | } 33 | 34 | export type Operation = { 35 | readonly parameters: Request['parameters'] 36 | readonly response: Response 37 | }; 38 | 39 | export namespace Operation { 40 | export type MinimalInput = InputParameters; 41 | 42 | type InputParameters = 43 | MakeEmptyObjectOptional<{ 44 | [K in keyof OpParams]: 45 | K extends 'query' ? Partial 46 | : K extends 'header' ? Omit 47 | : OpParams[K] 48 | }> 49 | ; 50 | } 51 | 52 | export type OperationIndex = Record; 53 | 54 | export namespace OperationIndex { 55 | export type FilterOptionalParams = { 56 | [K in keyof Ops as {} extends Operation.MinimalInput ? K : never]: Ops[K] 57 | }; 58 | } 59 | 60 | type MakeEmptyObjectOptional = 1 extends 0 ? never : ({ 61 | readonly [K in keyof T as {} extends T[K] ? K : never]?: T[K] 62 | } & { 63 | readonly [K in keyof T as {} extends T[K] ? never : K]: T[K] 64 | }); 65 | 66 | export function resolvePath(parameterizedPath: string, pathParams: Record): string { 67 | return parameterizedPath 68 | .split("/") 69 | .map(el => { 70 | const match = el.match(/^\{(.+)\}$/) 71 | if (!match) { 72 | return el; 73 | } 74 | const paramName = match[1]; 75 | const param = pathParams[paramName]; 76 | if (param === null || param === undefined || param === '') { 77 | throw new Error(`Path param ${paramName} must be specified.`); 78 | } 79 | return encodeURIComponent(param); 80 | }) 81 | .join('/'); 82 | } 83 | 84 | export type Transport = (requestLine: string, params?: Parameters) => Promise; 85 | 86 | export type FetchTransportOptions = { 87 | readonly baseUrl: string 88 | readonly headers: Record 89 | readonly agent?: Agent 90 | readonly retry?: boolean | { 91 | /** 92 | * Return true if the request should be retried, false otherwise 93 | */ 94 | readonly shouldRetry?: (attemptNum: number, response: FetchResponse, requestLine: string) => boolean 95 | 96 | /** 97 | * Return the backoff time in ms 98 | */ 99 | readonly backoffTime?: (numFailures: number, response: FetchResponse, requestLine: string) => number 100 | } 101 | }; 102 | 103 | const defaultRetryConfig: Exclude = { 104 | shouldRetry: (attemptNum, response) => { 105 | if (response.status === 429 && attemptNum < 50) { 106 | return true; 107 | } 108 | if (response.status >= 500 && response.status < 600 && attemptNum < 5) { 109 | return true; 110 | } 111 | return false; 112 | }, 113 | 114 | backoffTime: numFailures => { 115 | const maxRandomization = 0.2; 116 | const randomization = 0.9 + Math.random() * maxRandomization; 117 | return numFailures * 500 * randomization; 118 | }, 119 | }; 120 | 121 | export function fetchTransport(options: FetchTransportOptions): Transport { 122 | const { 123 | agent, 124 | baseUrl, 125 | headers, 126 | retry, 127 | } = options; 128 | 129 | const _agent = agent || new HttpsAgent({ maxSockets: 10, keepAlive: true }); 130 | 131 | const shouldRetry = 132 | retry === false ? () => false 133 | : retry === true || retry?.shouldRetry === undefined ? defaultRetryConfig.shouldRetry! 134 | : retry.shouldRetry; 135 | 136 | const backoffTime = 137 | retry === false ? () => { throw new Error() } 138 | : retry === true || retry?.backoffTime === undefined ? defaultRetryConfig.backoffTime! 139 | : retry.backoffTime; 140 | 141 | const staticHeaders = { 142 | "Accept-Encoding": "gzip", 143 | "Accept": "application/json", 144 | ...headers, 145 | }; 146 | 147 | return async (requestLine, params) => { 148 | const [method, paramaterizedPath] = requestLine.split(" ", 2); 149 | const path = resolvePath(paramaterizedPath, params?.path ?? {}); 150 | const queryParams = stringify(params?.query ?? {}, { arrayFormat: "comma" }); 151 | const queryString = queryParams.length ? `?${queryParams}` : ""; 152 | const isformDataContent = params?.header ? ("content-type" in params.header) ? params?.header["content-type"].toLowerCase().includes("multipart/form-data") : 153 | ("Content-Type" in params.header) ? params?.header["Content-Type"].toLowerCase().includes("multipart/form-data") : false : false; 154 | const body = params?.body && (isformDataContent ? params.body : JSON.stringify(params.body)); 155 | 156 | if (isformDataContent) { 157 | staticHeaders.Accept = "*/*"; 158 | } 159 | 160 | const fetchFn = () => fetch( 161 | `${baseUrl}${path}${queryString}`, 162 | { 163 | method, 164 | headers: { 165 | 'Content-Type': params?.body ? isformDataContent ? 'multipart/form-data' : 'application/json' : undefined, 166 | ...staticHeaders, 167 | ...params?.header, 168 | }, 169 | agent: _agent, 170 | body, 171 | } as any, 172 | ); 173 | 174 | let response: FetchResponse; 175 | for (let attemptNum = 1; ; attemptNum++) { 176 | response = await fetchFn(); 177 | if (!response.ok && shouldRetry(attemptNum, response, requestLine)) { 178 | await new Promise( 179 | resolve => setTimeout(() => resolve(), backoffTime(attemptNum, response, requestLine)), 180 | ); 181 | } else { 182 | break; 183 | } 184 | } 185 | 186 | const responseBody = await response!.text(); 187 | 188 | return { 189 | status: response!.status, 190 | body: responseBody && JSON.parse(responseBody), 191 | }; 192 | }; 193 | } 194 | -------------------------------------------------------------------------------- /src/internal/reference/files.js: -------------------------------------------------------------------------------- 1 | const blacklist = [ 2 | ".spectral.yaml", 3 | //"channels.v3.yml", // fails to build 4 | "customers_v2.yml", // duplicate of customers.v2.yml 5 | //"orders.v2.oas2.yml", 6 | //"tax.v3.yml", // fails to build 7 | ]; 8 | 9 | /** 10 | * To get latest files, navigate to https://github.com/bigcommerce/api-specs/tree/master/reference 11 | * and execute following in JS console: 12 | * JSON.stringify([...document.querySelectorAll('div[role=rowheader] a')].slice(1).map(a => a.innerText), null, 2) 13 | */ 14 | 15 | const allFiles = [ 16 | ".spectral.yaml", 17 | "abandoned_carts.v3.yml", 18 | "carts.sf.yml", 19 | "carts.v3.yml", 20 | "catalog.v3.yml", 21 | "channels.v3.yml", 22 | "checkouts.sf.yml", 23 | "checkouts.v3.yml", 24 | "consent.sf.yml", 25 | "currencies.v2.yml", 26 | "current_customer.yml", 27 | "custom-template-associations.v3.yml", 28 | "customer_login.yml", 29 | "customers.sf.yml", 30 | "customers.v2.yml", 31 | "customers.v3.yml", 32 | "customers_v2.yml", 33 | "email_templates.v3.yml", 34 | "form_fields.sf.yml", 35 | "geography.v2.yml", 36 | "marketing.v2.yml", 37 | "orders.sf.yml", 38 | "orders.v2.oas2.yml", 39 | "orders.v3.yml", 40 | "pages.v3.yml", 41 | "payment_methods.v2.yml", 42 | "payment_processing.yml", 43 | "price_lists.v3.yml", 44 | "pricing.sf.yml", 45 | "redirects.v3.yml", 46 | "scripts.v3.yml", 47 | "settings.v3.yml", 48 | "shipping.v2.yml", 49 | "shipping.v3.yml", 50 | "shipping_provider.yml", 51 | "sites.v3.yml", 52 | "store_content.v2.yml", 53 | "store_information.v2.yml", 54 | "storefront_tokens.v3.yml", 55 | "subscribers.v3.yml", 56 | "subscriptions.sf.yml", 57 | "tax.v3.yml", 58 | "tax_classes.v2.yml", 59 | "tax_provider.yml", 60 | "themes.v3.yml", 61 | "webhooks.v3.yml", 62 | "widgets.v3.yml", 63 | "wishlists.v3.yml", 64 | ]; 65 | 66 | module.exports = allFiles.filter(name => !blacklist.includes(name)); 67 | -------------------------------------------------------------------------------- /src/internal/reference/generate.js: -------------------------------------------------------------------------------- 1 | const files = require('./files'); 2 | const escape = require('shell-escape'); 3 | const { exec } = require('child_process'); 4 | const tempDir = require('temp-dir'); 5 | const { name: packageName } = require('../../../package.json'); 6 | const { v4: uuidv4 } = require('uuid'); 7 | const { writeFile } = require('fs'); 8 | const { promisify } = require('util'); 9 | const rimraf = require('rimraf'); 10 | 11 | const execAsync = promisify(exec); 12 | const writeFileAsync = promisify(writeFile); 13 | 14 | // files with weird names need to be grouped into sf/v2/v3 manually 15 | const fileGroupAssociations = { 16 | 'orders.v2.oas2': 'v2', 17 | }; 18 | 19 | async function main() { 20 | const sourceDir = process.argv[2] || 'https://raw.githubusercontent.com/Space48/api-specs/space48-fixes/reference' // '/Users/joshdifabio/projects/bigcommerce-api-specs/reference' // 'https://raw.githubusercontent.com/bigcommerce/api-specs/master/reference'; 21 | const tempOutputDir = await makeTempDir(); 22 | const outputDir = `${__dirname}/generated`; 23 | 24 | try { 25 | await generateTypeScript(sourceDir, tempOutputDir, files); 26 | await replaceDir(tempOutputDir, outputDir); 27 | } catch (e) { 28 | console.error(e); 29 | process.exit(1); 30 | } 31 | } 32 | 33 | async function makeTempDir() { 34 | const tempOutputDir = `${tempDir}/${packageName.split('/').slice(-1)[0]}-${uuidv4()}`; 35 | await execAsync(`mkdir ${escape([tempOutputDir])}`); 36 | return tempOutputDir; 37 | } 38 | 39 | async function generateTypeScript(sourceDir, outputDir, yamlFiles) { 40 | const modules = yamlFiles.map(yamlFilename => { 41 | const jsIdentifier = value => value.replace(/-/g, '_'); 42 | const filenameParts = yamlFilename.split('.').slice(0, -1); 43 | const exportName = jsIdentifier(filenameParts[0]); 44 | const moduleName = jsIdentifier(filenameParts.join('.')); 45 | return { 46 | moduleName, 47 | groupName: 48 | fileGroupAssociations[moduleName] || (filenameParts.length === 2 ? jsIdentifier(filenameParts.slice(-1)[0]) : null), 49 | yamlFilename, 50 | tsFilename: `${moduleName}.ts`, 51 | exportName, 52 | //importStatement: `import type * as ${exportName} from "./${moduleName}"`, 53 | /* 54 | typeDefinition: ` 55 | ${exportName}: { 56 | paths: ${exportName}.paths 57 | } 58 | `, 59 | */ 60 | }; 61 | }); 62 | 63 | await Promise.all(modules.map(async ({ yamlFilename, tsFilename }) => { 64 | const sourcePath = `${sourceDir}/${yamlFilename}`; 65 | const outputPath = `${outputDir}/${tsFilename}`; 66 | await execAsync(`npx openapi-typescript ${escape([sourcePath])} --immutable-types > ${escape([outputPath])}`); 67 | })); 68 | 69 | const exportGroups = [...new Set(modules.map(mod => mod.groupName))]; 70 | 71 | await Promise.all(exportGroups.map(async groupName => { 72 | const fileContent = ` 73 | import type { InferOperationIndex } from "../operation-inference"; 74 | 75 | ${ 76 | modules 77 | .filter(module => module.groupName === groupName) 78 | .map(({ moduleName, exportName }) => `import type * as ${exportName} from "./${moduleName}"`) 79 | .join("\n") 80 | } 81 | 82 | export type Operation = 83 | ${ 84 | modules 85 | .filter(module => module.groupName === groupName) 86 | .map(({ groupName, exportName }) => `& InferOperationIndex<${exportName}.paths>`) 87 | .join("\n") 88 | } 89 | ; 90 | ` 91 | await writeFileAsync(`${outputDir}/${groupName || 'misc'}.ts`, fileContent); 92 | })); 93 | 94 | return; 95 | 96 | const groupExports = exportGroups.map(groupName => `export { Resources as ${groupName} } from "./${groupName}"`); 97 | const otherExports = modules.filter(mod => mod.groupName === null).map(mod => mod.exportStatement) 98 | const indexExports = [...groupExports, ...otherExports]; 99 | await writeFileAsync(`${outputDir}/index.ts`, indexExports.join("\n")); 100 | } 101 | 102 | async function replaceDir(source, destination) { 103 | await promisify(rimraf)(destination); 104 | await execAsync(`mv ${escape([source])} ${escape([destination])}`); 105 | } 106 | 107 | main(); 108 | -------------------------------------------------------------------------------- /src/internal/reference/generated/abandoned_carts.v3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/abandoned-carts/{token}": { 8 | /** 9 | * Returns the `cart_id` corresponding to the abandoned cart `{token}` passed in. 10 | * 11 | * **Usage Notes**: 12 | * * `{token}` is the token in the query string of the abandoned cart link found in abandoned cart email notifications to shoppers 13 | */ 14 | readonly get: operations["getAbandonedCarts"]; 15 | readonly parameters: { 16 | readonly path: { 17 | /** 18 | * Unique cart `UUID`. 19 | * 20 | * Unique cart `UUID` token that is generated for abandoned cart emails. 21 | */ 22 | readonly token: string; 23 | }; 24 | }; 25 | }; 26 | } 27 | 28 | export interface definitions { 29 | readonly metaEmpty_Full: { readonly [key: string]: any }; 30 | readonly error_Full: { 31 | /** The HTTP status code. */ 32 | readonly status?: number; 33 | /** The error title describing the particular error. */ 34 | readonly title?: string; 35 | readonly type?: string; 36 | }; 37 | readonly errorDetailed_Full: { 38 | readonly errors?: { readonly [key: string]: string }; 39 | }; 40 | readonly abandonedCartInfo_Full: { 41 | /** The `cart_id` of the abandoned cart. Can be used to display the abanded cart to the customer via storefront cart or */ 42 | readonly cart_id?: string; 43 | }; 44 | } 45 | 46 | export interface parameters { 47 | /** Accept */ 48 | readonly Accept: string; 49 | /** Content-Type */ 50 | readonly "Content-Type": string; 51 | } 52 | 53 | export interface responses { 54 | /** If something happens during the request that causes it to fail, a 502 response will be returned. A new request should be made; however, it could fail. */ 55 | readonly "502_GatewayError": { 56 | readonly schema: definitions["error_Full"]; 57 | }; 58 | /** If this occurs, you should retry the request. Typically retrying the request several times will result in a successful request; However, if you are unable to successfully make a request, please check the BigCommerce system status [here](https://status.bigcommerce.com/). A service is likely down and the request will need to be made again when it is back up (in several hours usually) */ 59 | readonly "504_GatewayTimeout": { 60 | readonly schema: definitions["errorDetailed_Full"]; 61 | }; 62 | readonly "403_Unauthorized": { 63 | readonly schema: definitions["error_Full"]; 64 | }; 65 | /** 66 | * Malformed request syntax. Typically need to fix the JSON 67 | * Body to resend successfully. 68 | */ 69 | readonly "400_BadRequest": { 70 | readonly schema: definitions["error_Full"]; 71 | }; 72 | /** If the requested account resource is not found for the franchise, return a 404 Not Found. */ 73 | readonly "404_NotFound": { 74 | readonly schema: definitions["error_Full"]; 75 | }; 76 | /** This occurs when missing or unacceptable data is passed for one or more fields. Please correct the values for the fields listed in the errors object. */ 77 | readonly "422_UnprocessableEntity": { 78 | readonly schema: definitions["errorDetailed_Full"]; 79 | }; 80 | /** If this occurs, you should retry the request. If you are unable to successfully make a request, please check the BigCommerce system status [here](https://status.bigcommerce.com/). A service is likely down and the request will need to be made again when it is back up (in several hours usually) */ 81 | readonly "503_ServiceUnavailable": { 82 | readonly schema: definitions["error_Full"]; 83 | }; 84 | /** Returned on `GET` requests to `/abandoned_carts`. */ 85 | readonly abandonedCart_Resp: { 86 | readonly schema: { 87 | readonly data?: definitions["abandonedCartInfo_Full"]; 88 | readonly meta?: definitions["metaEmpty_Full"]; 89 | }; 90 | }; 91 | } 92 | 93 | export interface operations { 94 | /** 95 | * Returns the `cart_id` corresponding to the abandoned cart `{token}` passed in. 96 | * 97 | * **Usage Notes**: 98 | * * `{token}` is the token in the query string of the abandoned cart link found in abandoned cart email notifications to shoppers 99 | */ 100 | readonly getAbandonedCarts: { 101 | readonly parameters: { 102 | readonly path: { 103 | /** 104 | * Unique cart `UUID`. 105 | * 106 | * Unique cart `UUID` token that is generated for abandoned cart emails. 107 | */ 108 | readonly token: string; 109 | }; 110 | }; 111 | readonly responses: { 112 | readonly 200: responses["abandonedCart_Resp"]; 113 | readonly 400: responses["400_BadRequest"]; 114 | readonly 404: responses["404_NotFound"]; 115 | readonly 422: responses["422_UnprocessableEntity"]; 116 | readonly 502: responses["502_GatewayError"]; 117 | readonly 503: responses["503_ServiceUnavailable"]; 118 | readonly 504: responses["504_GatewayTimeout"]; 119 | readonly default: unknown; 120 | }; 121 | }; 122 | } 123 | -------------------------------------------------------------------------------- /src/internal/reference/generated/consent.sf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/consent": { 8 | /** 9 | * Sets the status of a customer's consent to allow data collection by cookies and scripts according to the following consent categories: 10 | * 11 | * 12 | * 2. Analytics — These cookies provide statistical information on site usage so the store owner can improve the website over time. 13 | * 3. Functional — These cookies enable enhanced functionality, such as videos and live chat. If a shopper does not allow these, then some or all of these functions may not work properly. 14 | * 4. Targeting; Advertising — These cookies allow merchants to create profiles or personalize content to enhance users' shopping experience. 15 | * 16 | * 17 | * This endpoint only works if the cookie consent feature is enabled. It is assumed the shopper has not consented to anything until a value is explicitly set. The request body must be populated with a complete set of allowed and denied categories. 18 | * 19 | * Once set, consent preferences will be saved as a cookie for guest shoppers. Consent preferences will be persisted to a shopper's account to be used for future sessions once they have logged in. Consent preferences can also be managed using the [Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/) V3 endpoint. 20 | */ 21 | readonly post: operations["postConsent"]; 22 | readonly parameters: {}; 23 | }; 24 | } 25 | 26 | export interface components { 27 | readonly schemas: { 28 | /** 29 | * List of allowed and denied consent categories. Must be populated with a complete set of allowed and denied categories. 30 | * 31 | * Configurable categories are: 32 | * 33 | * 2 - Functional 34 | * 3 - Analytics 35 | * 4 - Targeting; Advertising 36 | * 37 | * For further definition of these categories, see [Scripts API](https://developer.bigcommerce.com/api-docs/store-management/scripts). 38 | */ 39 | readonly ConsentPreferences: { 40 | /** Explicitly allowed consent categories. Allowed values are 2, 3, 4. */ 41 | readonly allow: readonly (2 | 3 | 4)[]; 42 | /** Denied consent categories. Allowed values are 2, 3, 4. */ 43 | readonly deny: readonly (2 | 3 | 4)[]; 44 | }; 45 | }; 46 | } 47 | 48 | export interface operations { 49 | /** 50 | * Sets the status of a customer's consent to allow data collection by cookies and scripts according to the following consent categories: 51 | * 52 | * 53 | * 2. Analytics — These cookies provide statistical information on site usage so the store owner can improve the website over time. 54 | * 3. Functional — These cookies enable enhanced functionality, such as videos and live chat. If a shopper does not allow these, then some or all of these functions may not work properly. 55 | * 4. Targeting; Advertising — These cookies allow merchants to create profiles or personalize content to enhance users' shopping experience. 56 | * 57 | * 58 | * This endpoint only works if the cookie consent feature is enabled. It is assumed the shopper has not consented to anything until a value is explicitly set. The request body must be populated with a complete set of allowed and denied categories. 59 | * 60 | * Once set, consent preferences will be saved as a cookie for guest shoppers. Consent preferences will be persisted to a shopper's account to be used for future sessions once they have logged in. Consent preferences can also be managed using the [Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/) V3 endpoint. 61 | */ 62 | readonly postConsent: { 63 | readonly parameters: {}; 64 | readonly responses: { 65 | /** Consent Settings Saved */ 66 | readonly 200: unknown; 67 | /** Invalid input */ 68 | readonly 400: unknown; 69 | }; 70 | /** Data sent to the [Update Customer Consent](https://developer.bigcommerce.com/api-reference/store-management/customers-v3/customer-consent/customersconsentbycustomerid-put) Customers V3 endpoint when creating a customer during checkout */ 71 | readonly requestBody: { 72 | readonly content: { 73 | readonly "application/json": components["schemas"]["ConsentPreferences"]; 74 | }; 75 | }; 76 | }; 77 | } 78 | -------------------------------------------------------------------------------- /src/internal/reference/generated/current_customer.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/customer/current.jwt": { 8 | /** 9 | *
10 | *
11 | *
12 | * 13 | * > ### Note 14 | * > The Send a Test Request feature is not currently supported for this endpoint. 15 | * 16 | *
17 | *
18 | *
19 | */ 20 | readonly get: operations["getCurrentCustomer"]; 21 | }; 22 | } 23 | 24 | export interface operations { 25 | /** 26 | *
27 | *
28 | *
29 | * 30 | * > ### Note 31 | * > The Send a Test Request feature is not currently supported for this endpoint. 32 | * 33 | *
34 | *
35 | *
36 | */ 37 | readonly getCurrentCustomer: { 38 | readonly parameters: { 39 | readonly query: { 40 | readonly app_client_id: string; 41 | }; 42 | }; 43 | readonly responses: { 44 | readonly default: { 45 | readonly schema: { 46 | readonly customer?: { 47 | /** Unique numeric ID of the customer. */ 48 | readonly id?: number; 49 | /** Email address of the customer. */ 50 | readonly email?: string; 51 | /** The group to which the customer belongs. */ 52 | readonly group_id?: string; 53 | }; 54 | /** Indicates the token’s issuer. This is your application’s client ID, which is obtained during application registration in Developer Portal. */ 55 | readonly iss?: string; 56 | /** The subject of the JWT - same as `store_hash`. */ 57 | readonly sub?: string; 58 | /** Time when the token was generated. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 59 | readonly iat?: number; 60 | /** Time when the token expires. The token usually expires after 15 minutes. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 61 | readonly exp?: number; 62 | /** Version of the Current Customer JWT */ 63 | readonly version?: number; 64 | /** The "aud" (audience) claim identifies the recipients that the JWT is intended for. This should match the *App Client ID* and the `application_id`. */ 65 | readonly aud?: string; 66 | /** The client ID created when the token was generated. */ 67 | readonly application_id?: string; 68 | /** Store hash identifying the store you are logging into. */ 69 | readonly store_hash?: string; 70 | /** Must contain the string “current_customer”. */ 71 | readonly operation?: string; 72 | }; 73 | }; 74 | }; 75 | }; 76 | } 77 | -------------------------------------------------------------------------------- /src/internal/reference/generated/custom_template_associations.v3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/storefront/custom-template-associations": { 8 | /** Get a collection of the store's custom template associations across all storefronts */ 9 | readonly get: operations["GetCustomTemplateAssociations"]; 10 | /** Upsert new custom template associations data across all storefronts. If an existing record is found for the combination of channel ID, entity ID, and type, the existing record will be overwritten with the new template. */ 11 | readonly put: operations["UpsertCustomTemplateAssociations"]; 12 | /** Delete custom template associations. At least one query parameter must be used. */ 13 | readonly delete: operations["DeleteCustomTemplateAssociations"]; 14 | readonly parameters: {}; 15 | }; 16 | } 17 | 18 | export interface components { 19 | readonly schemas: { 20 | readonly Error: { 21 | readonly status?: number; 22 | readonly message?: string; 23 | }; 24 | readonly ErrorResponse400: { 25 | readonly schema?: components["schemas"]["Error"]; 26 | }; 27 | readonly ErrorResponse404: { 28 | readonly schema?: components["schemas"]["Error"]; 29 | }; 30 | readonly ErrorResponse409: { 31 | readonly schema?: components["schemas"]["Error"]; 32 | }; 33 | readonly ErrorResponse422: { 34 | readonly schema?: components["schemas"]["Error"]; 35 | }; 36 | readonly MetaPaginationObject: { 37 | readonly pagination?: { 38 | readonly total?: number; 39 | readonly count?: number; 40 | readonly per_page?: number; 41 | readonly current_page?: number; 42 | readonly total_pages?: number; 43 | readonly links?: { 44 | readonly next?: string; 45 | readonly current?: string; 46 | }; 47 | }; 48 | }; 49 | readonly DetailedErrors: { readonly [key: string]: string }; 50 | /** Error payload for the BigCommerce API. */ 51 | readonly BaseError: { 52 | /** The HTTP status code. */ 53 | readonly status?: number; 54 | /** The error title describing the particular error. */ 55 | readonly title?: string; 56 | readonly type?: string; 57 | readonly instance?: string; 58 | }; 59 | readonly ErrorResponse: components["schemas"]["BaseError"] & { 60 | readonly errors?: components["schemas"]["DetailedErrors"]; 61 | }; 62 | readonly CustomTemplateAssociation: { 63 | readonly id?: number; 64 | readonly channel_id?: number; 65 | readonly entity_type?: "product" | "category" | "brand" | "page"; 66 | readonly entity_id?: number; 67 | readonly file_name?: string; 68 | /** An invalid file name does not match with an existing custom layout file in the currently active theme for the channel. When an association is invalid the store will fallback to using the default for that entity type. */ 69 | readonly is_valid?: boolean; 70 | readonly date_created?: string; 71 | readonly date_modified?: string; 72 | }; 73 | readonly CustomTemplateAssociationUpsert: { 74 | readonly channel_id: number; 75 | readonly entity_type: "product" | "category" | "brand" | "page"; 76 | readonly entity_id: number; 77 | readonly file_name: string; 78 | }; 79 | }; 80 | } 81 | 82 | export interface operations { 83 | /** Get a collection of the store's custom template associations across all storefronts */ 84 | readonly GetCustomTemplateAssociations: { 85 | readonly parameters: { 86 | readonly query: { 87 | /** Channel ID to return only custom template associations for a given Channel */ 88 | readonly channel_id?: number; 89 | /** Filter by a list of entity IDs. Must be used together with "type" filter. */ 90 | readonly "entity_id:in"?: string; 91 | /** Number of results to return per page */ 92 | readonly limit?: number; 93 | /** Which page number to return, based on the page size. Used to paginate large collections. */ 94 | readonly page?: number; 95 | /** Filter associations by type */ 96 | readonly type?: "product" | "category" | "brand" | "page"; 97 | /** Optional toggle to filter for exclusively valid or invalid associations entries. An invalid entry is one where it's file name does not match up to an existing custom layout file in the currently active theme for the channel. */ 98 | readonly is_valid?: boolean; 99 | }; 100 | }; 101 | readonly responses: { 102 | /** OK */ 103 | readonly 200: { 104 | readonly content: { 105 | readonly "application/json": { 106 | readonly data?: readonly components["schemas"]["CustomTemplateAssociation"][]; 107 | readonly meta?: components["schemas"]["MetaPaginationObject"]; 108 | }; 109 | }; 110 | }; 111 | }; 112 | }; 113 | /** Upsert new custom template associations data across all storefronts. If an existing record is found for the combination of channel ID, entity ID, and type, the existing record will be overwritten with the new template. */ 114 | readonly UpsertCustomTemplateAssociations: { 115 | readonly parameters: {}; 116 | readonly responses: { 117 | /** Success response for batch upsert of custom template associations */ 118 | readonly 200: { 119 | readonly content: { 120 | readonly "application/json": { readonly [key: string]: any }; 121 | }; 122 | }; 123 | /** Error response for batch PUT of Custom template associations. Includes the errors for each reference id. */ 124 | readonly 422: { 125 | readonly content: { 126 | readonly "application/json": components["schemas"]["ErrorResponse"]; 127 | }; 128 | }; 129 | }; 130 | readonly requestBody: { 131 | readonly content: { 132 | readonly "application/json": readonly components["schemas"]["CustomTemplateAssociationUpsert"][]; 133 | }; 134 | }; 135 | }; 136 | /** Delete custom template associations. At least one query parameter must be used. */ 137 | readonly DeleteCustomTemplateAssociations: { 138 | readonly parameters: { 139 | readonly query: { 140 | /** List of Association IDs to delete explicitly. */ 141 | readonly "id:in"?: number; 142 | /** List of Entity IDs to delete explicitly. Must be used together with "type" */ 143 | readonly "entity_id:in"?: number; 144 | /** Channel ID provided to delete all custom template associations for a given Channel */ 145 | readonly channel_id?: number; 146 | /** Filter associations by type */ 147 | readonly type?: "product" | "category" | "brand" | "page"; 148 | }; 149 | }; 150 | readonly responses: { 151 | /** No Content */ 152 | readonly 204: never; 153 | }; 154 | }; 155 | } 156 | -------------------------------------------------------------------------------- /src/internal/reference/generated/customer_login.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/login/token/{jwt_token}": { 8 | /** 9 | * The customer login access point URL. 10 | * 11 | * [Learn more about the Customer Login API](https://developer.bigcommerce.com/api-docs/customers/customer-login-api). 12 | * 13 | * ## Example 14 | * 15 | * ``` 16 | * https://storedomain.com/login/token/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJ7Y2xpZW50X2lkfSIsImlhdCI6MTUzNTM5MzExMywianRpIjoie3V1aWR9Iiwib3BlcmF0aW9uIjoiY3VzdG9tZXJfbG9naW4iLCJzdG9yZV9oYXNoIjoie3N0b3JlX2hhc2h9IiwiY3VzdG9tZXJfaWQiOjJ9.J-fAtbjRFGdLsT744DhoprFEDqIfVq72HbDzrbFy6Is 17 | * ``` 18 | */ 19 | readonly get: { 20 | readonly parameters: { 21 | readonly path: { 22 | readonly jwt_token: string; 23 | }; 24 | }; 25 | readonly responses: {}; 26 | }; 27 | readonly parameters: { 28 | readonly path: { 29 | readonly jwt_token: string; 30 | }; 31 | }; 32 | }; 33 | } 34 | 35 | export interface definitions { 36 | readonly customerLoginSSO: { 37 | /** Indicates the token’s issuer. This is your application’s client ID, which is obtained during application registration in Developer Portal. */ 38 | readonly iss?: string; 39 | /** Time when the token was generated. This is a numeric value indicating the number of seconds since the [Unix epoch](https://en.wikipedia.org/wiki/Unix_time). */ 40 | readonly iat?: number; 41 | /** Request ID string that must be unique across all requests made by your app. A UUID or other random string would be an appropriate value. Most libraries contain a method for generating a uuid. For testing a [UUID generator](https://www.uuidgenerator.net/) can be used, but it recommended to use built in libraries. */ 42 | readonly jti?: string; 43 | /** Must contain the string “customer_login”. */ 44 | readonly operation?: string; 45 | /** Store hash identifying the store you are logging into. */ 46 | readonly store_hash?: string; 47 | /** ID of the customer you are logging in, as obtained through the Customer API. */ 48 | readonly customer_id?: number; 49 | /** Optional field containing a relative path for the shopper’s destination after login. Will default to `/account.php`. */ 50 | readonly redirect_to?: string; 51 | /** **(Optional)** Field containing the expected IP address for the request. If provided, BigCommerce will check that it matches the browser trying to log in. If there is not a match, it will be rejected. */ 52 | readonly request_ip?: string; 53 | }; 54 | } 55 | 56 | export interface operations {} 57 | -------------------------------------------------------------------------------- /src/internal/reference/generated/customers.sf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/customers": { 8 | /** 9 | * Creates a *Customer*. 10 | * 11 | *
12 | *
13 | *
14 | * 15 | * > ### Note 16 | * > The Send a Test Request feature is not currently supported for this endpoint. 17 | * 18 | *
19 | *
20 | *
21 | */ 22 | readonly post: operations["createACustomer"]; 23 | }; 24 | } 25 | 26 | export interface components { 27 | readonly schemas: { 28 | readonly CustomerCreateData: { 29 | /** First name of customer */ 30 | readonly firstName?: string; 31 | /** Last name of customer */ 32 | readonly lastName?: string; 33 | /** Email of customer */ 34 | readonly email?: string; 35 | /** Password of customer */ 36 | readonly password?: string; 37 | /** Has customer provided consent to receive marketing emails. */ 38 | readonly acceptsMarketingEmails?: boolean; 39 | readonly customFields?: readonly components["schemas"]["CustomFields"][]; 40 | }; 41 | readonly CustomFields: { 42 | readonly fieldId?: string; 43 | readonly fieldValue?: string; 44 | }; 45 | }; 46 | } 47 | 48 | export interface operations { 49 | /** 50 | * Creates a *Customer*. 51 | * 52 | *
53 | *
54 | *
55 | * 56 | * > ### Note 57 | * > The Send a Test Request feature is not currently supported for this endpoint. 58 | * 59 | *
60 | *
61 | *
62 | */ 63 | readonly createACustomer: { 64 | readonly responses: { 65 | /** Customer succesfully created */ 66 | readonly 204: never; 67 | /** Could not create customer */ 68 | readonly 400: unknown; 69 | /** Missing Required Fields */ 70 | readonly 422: unknown; 71 | /** Spam Protection Failed */ 72 | readonly 429: unknown; 73 | }; 74 | /** Data sent the the customer endpoint when creating a customer during checkout. */ 75 | readonly requestBody: { 76 | readonly content: { 77 | readonly "application/json": components["schemas"]["CustomerCreateData"]; 78 | }; 79 | }; 80 | }; 81 | } 82 | -------------------------------------------------------------------------------- /src/internal/reference/generated/form_fields.sf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/form-fields": { 8 | /** 9 | * Gets form fields. 10 | * 11 | *
12 | *
13 | *
14 | * 15 | * > ### Note 16 | * > The Send a Test Request feature is not currently supported for this endpoint. 17 | * 18 | *
19 | *
20 | *
21 | */ 22 | readonly get: { 23 | readonly parameters: { 24 | readonly query: { 25 | readonly filter?: unknown; 26 | }; 27 | }; 28 | readonly responses: { 29 | /** Returns an object with form fields groups. */ 30 | readonly 200: { 31 | readonly schema: definitions["FormFieldGroups"]; 32 | }; 33 | }; 34 | }; 35 | }; 36 | } 37 | 38 | export interface definitions { 39 | /** Group of form field groups */ 40 | readonly FormFieldGroups: { 41 | readonly customerAccount?: definitions["FormFields"]; 42 | readonly shippingAddress?: definitions["FormFields"]; 43 | readonly billingAddress?: definitions["FormFields"]; 44 | }; 45 | /** List of form fields for the group */ 46 | readonly FormFields: readonly definitions["FormField"][]; 47 | /** Form Field */ 48 | readonly FormField: { 49 | /** Field unique ID */ 50 | readonly id?: string; 51 | /** Field name */ 52 | readonly name?: string; 53 | /** Wether is a custom field or system built-in field. */ 54 | readonly custom?: boolean; 55 | /** User-friendly label */ 56 | readonly label?: string; 57 | /** Wether this field is required or not */ 58 | readonly required?: boolean; 59 | /** The field unique ID */ 60 | readonly default?: string | null; 61 | /** Type of the value hold by the field */ 62 | readonly type?: ("integer" | "string" | "array" | "date") | null; 63 | /** Type of the field */ 64 | readonly fieldType?: 65 | | ("checkbox" | "text" | "date" | "multiline" | "radio" | "dropdown") 66 | | null; 67 | /** The minimun valid value for the field (integer and date type only) */ 68 | readonly min?: string | null; 69 | /** The minimun valid value for the field (integer and date type only) */ 70 | readonly max?: string | null; 71 | /** The maximum length for the value (string type only) */ 72 | readonly maxLength?: number | null; 73 | /** Whether the field represents a password field */ 74 | readonly secret?: boolean | null; 75 | /** Extra data for radio, dropdown and checkbox field types. */ 76 | readonly options?: { 77 | /** Placeholder text for dropdown field type. */ 78 | readonly helperLabel?: string | null; 79 | /** List of possible values for this field. */ 80 | readonly items?: { 81 | /** Field option value. */ 82 | readonly value?: string; 83 | /** User friendly label. */ 84 | readonly label?: string; 85 | }; 86 | } | null; 87 | }; 88 | } 89 | 90 | export interface operations {} 91 | -------------------------------------------------------------------------------- /src/internal/reference/generated/misc.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { InferOperationIndex } from "../operation-inference"; 3 | 4 | import type * as current_customer from "./current_customer" 5 | import type * as customer_login from "./customer_login" 6 | import type * as payment_processing from "./payment_processing" 7 | import type * as shipping_provider from "./shipping_provider" 8 | import type * as tax_provider from "./tax_provider" 9 | 10 | export type Operation = 11 | & InferOperationIndex 12 | & InferOperationIndex 13 | & InferOperationIndex 14 | & InferOperationIndex 15 | & InferOperationIndex 16 | ; 17 | -------------------------------------------------------------------------------- /src/internal/reference/generated/payment_methods.v2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/payments/methods": { 8 | /** Gets the list of enabled payment methods. Default sorting is by payment method, alphabetically from A to Z. */ 9 | readonly get: { 10 | readonly parameters: { 11 | readonly header: { 12 | readonly Accept: string; 13 | readonly "Content-Type": string; 14 | }; 15 | readonly query: { 16 | /** Optional filter param `/api/v2/payments/methods?page={number}` */ 17 | readonly page?: number; 18 | /** Optional filter param `/api/v2/payments/methods?limit={count}` */ 19 | readonly limit?: number; 20 | }; 21 | }; 22 | readonly responses: { 23 | readonly 200: responses["paymentCollection_Resp"]; 24 | }; 25 | }; 26 | }; 27 | } 28 | 29 | export interface definitions { 30 | readonly payment_Base: { 31 | /** Unique platform-wide code identifying the payment method. */ 32 | readonly code?: string; 33 | /** Descriptive name of the payment method. */ 34 | readonly name?: string; 35 | /** Determines whether the payment gateway is in test mode. Always false for offline payment methods. */ 36 | readonly test_mode?: boolean; 37 | }; 38 | } 39 | 40 | export interface responses { 41 | readonly paymentCollection_Resp: { 42 | readonly schema: readonly definitions["payment_Base"][]; 43 | }; 44 | } 45 | 46 | export interface operations {} 47 | -------------------------------------------------------------------------------- /src/internal/reference/generated/redirects.v3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/storefront/redirects": { 8 | /** Returns a collection of the store's 301 redirects across all sites. */ 9 | readonly get: operations["GetRedirects"]; 10 | /** Upserts new redirect data across all storefronts. */ 11 | readonly put: operations["UpsertRedirects"]; 12 | /** Deletes redirects. */ 13 | readonly delete: operations["DeleteRedirects"]; 14 | }; 15 | } 16 | 17 | export interface definitions { 18 | readonly Error: { 19 | readonly status?: number; 20 | readonly message?: string; 21 | }; 22 | readonly ErrorResponse400: { 23 | readonly schema?: definitions["Error"]; 24 | }; 25 | readonly ErrorResponse404: { 26 | readonly schema?: definitions["Error"]; 27 | }; 28 | readonly ErrorResponse409: { 29 | readonly schema?: definitions["Error"]; 30 | }; 31 | readonly ErrorResponse422: { 32 | readonly schema?: definitions["Error"]; 33 | }; 34 | /** Data necessary to create or update a redirect. If there's a conflict on the from_path and site_id, the redirect will be overwritten with new data. */ 35 | readonly "301RedirectUpsert": { 36 | readonly from_path: string; 37 | readonly site_id: number; 38 | readonly to?: definitions["RedirectTo"]; 39 | }; 40 | /** Full detail of a Redirect, optionally including the full destination URL. */ 41 | readonly "301RedirectRead": { 42 | readonly from_path: string; 43 | readonly site_id: number; 44 | readonly to?: definitions["RedirectTo"]; 45 | readonly id?: number; 46 | /** Full destination URL for the redirect. Must be explicitly included via URL parameter. */ 47 | readonly to_url?: string; 48 | }; 49 | readonly MetaPaginationObject: { 50 | readonly pagination?: { 51 | readonly total?: number; 52 | readonly count?: number; 53 | readonly per_page?: number; 54 | readonly current_page?: number; 55 | readonly total_pages?: number; 56 | readonly links?: { 57 | readonly next?: string; 58 | readonly current?: string; 59 | }; 60 | }; 61 | }; 62 | readonly RedirectTo: { 63 | readonly type?: "product" | "brand" | "category" | "page" | "post" | "url"; 64 | readonly entity_id?: number; 65 | readonly url?: string; 66 | }; 67 | readonly DetailedErrors: { readonly [key: string]: string }; 68 | /** Error payload for the BigCommerce API. */ 69 | readonly BaseError: { 70 | /** The HTTP status code. */ 71 | readonly status?: number; 72 | /** The error title describing the particular error. */ 73 | readonly title?: string; 74 | readonly type?: string; 75 | readonly instance?: string; 76 | }; 77 | readonly ErrorResponse: definitions["BaseError"] & { 78 | readonly errors?: definitions["DetailedErrors"]; 79 | }; 80 | } 81 | 82 | export interface operations { 83 | /** Returns a collection of the store's 301 redirects across all sites. */ 84 | readonly GetRedirects: { 85 | readonly parameters: { 86 | readonly query: { 87 | /** Filters items by `site_id`. */ 88 | readonly site_id?: number; 89 | /** Filters items by redirect `id`. Also accepts comma-separated values to filter for multiple redirects. */ 90 | readonly "id:in"?: readonly string[]; 91 | /** Controls the number of items to return per page. */ 92 | readonly limit?: number; 93 | /** Specifies the page number in a limited (paginated) list of items. Used to paginate large collections. */ 94 | readonly page?: number; 95 | /** Field name to sort by. Note: Since redirect `id` increments when new redirects are added, you can use that field to sort by redirect create date. */ 96 | readonly sort?: "from_path" | "type" | "site_id"; 97 | /** Sort direction. Acceptable values are `asc`, `desc`. */ 98 | readonly direction?: "asc" | "desc"; 99 | /** Indicates whether to include redirect sub-resources. Only `to_url` is supported. */ 100 | readonly include?: "to_url"; 101 | /** Filters redirects by the specified keyword. Will only search from the beginning of a URL path. For example, `blue` will match `/blue` and `/blue-shirt` , **not** `/royal-blue-shirt`. */ 102 | readonly keyword?: string; 103 | }; 104 | }; 105 | readonly responses: { 106 | readonly 200: { 107 | readonly schema: { 108 | readonly data?: definitions["301RedirectRead"]; 109 | readonly meta?: definitions["MetaPaginationObject"]; 110 | }; 111 | }; 112 | }; 113 | }; 114 | /** Upserts new redirect data across all storefronts. */ 115 | readonly UpsertRedirects: { 116 | readonly parameters: { 117 | readonly body: { 118 | readonly body?: readonly definitions["301RedirectUpsert"][]; 119 | }; 120 | }; 121 | readonly responses: { 122 | readonly 201: { 123 | readonly schema: { 124 | readonly data?: readonly definitions["301RedirectRead"][]; 125 | readonly meta?: definitions["MetaPaginationObject"]; 126 | }; 127 | }; 128 | }; 129 | }; 130 | /** Deletes redirects. */ 131 | readonly DeleteRedirects: { 132 | readonly parameters: { 133 | readonly query: { 134 | /** List of Redirect IDs to delete explicitly */ 135 | readonly "id:in": readonly number[]; 136 | /** Site ID provided to delete all redirects for a given Site */ 137 | readonly site_id?: number; 138 | }; 139 | }; 140 | readonly responses: { 141 | /** No Content */ 142 | readonly 204: never; 143 | }; 144 | }; 145 | } 146 | -------------------------------------------------------------------------------- /src/internal/reference/generated/sf.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { InferOperationIndex } from "../operation-inference"; 3 | 4 | import type * as carts from "./carts.sf" 5 | import type * as checkouts from "./checkouts.sf" 6 | import type * as consent from "./consent.sf" 7 | import type * as customers from "./customers.sf" 8 | import type * as form_fields from "./form_fields.sf" 9 | import type * as orders from "./orders.sf" 10 | import type * as pricing from "./pricing.sf" 11 | import type * as subscriptions from "./subscriptions.sf" 12 | 13 | export type Operation = 14 | & InferOperationIndex 15 | & InferOperationIndex 16 | & InferOperationIndex 17 | & InferOperationIndex 18 | & InferOperationIndex 19 | & InferOperationIndex 20 | & InferOperationIndex 21 | & InferOperationIndex 22 | ; 23 | -------------------------------------------------------------------------------- /src/internal/reference/generated/store_information.v2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/store": { 8 | /** Returns metadata about a store. */ 9 | readonly get: { 10 | readonly parameters: { 11 | readonly header: { 12 | readonly Accept: string; 13 | readonly "Content-Type": string; 14 | }; 15 | }; 16 | readonly responses: { 17 | readonly 200: { 18 | readonly schema: definitions["StoreInformation"]; 19 | }; 20 | }; 21 | }; 22 | }; 23 | readonly "/time": { 24 | /** Returns the system timestamp at the time of the request. The time resource is useful for validating API authentication details and testing client connections. */ 25 | readonly get: { 26 | readonly parameters: { 27 | readonly header: { 28 | readonly Accept: string; 29 | readonly "Content-Type": string; 30 | }; 31 | }; 32 | readonly responses: { 33 | readonly 200: { 34 | readonly schema: definitions["timeStamp_Full"]; 35 | }; 36 | }; 37 | }; 38 | }; 39 | } 40 | 41 | export interface definitions { 42 | readonly StoreInformation: { 43 | /** Unique store identifier. */ 44 | readonly id?: string; 45 | /** Primary domain name. */ 46 | readonly domain?: string; 47 | /** Store’s current HTTPS URL. */ 48 | readonly secure_url?: string; 49 | /** The secure hostname of the control panel. */ 50 | readonly control_panel_base_url?: string; 51 | /** Store's name. */ 52 | readonly name?: string; 53 | /** Primary contact’s first name (as defined during the store sign-up process). */ 54 | readonly first_name?: string; 55 | /** Primary contact’s last name (as defined during the store sign-up process). */ 56 | readonly last_name?: string; 57 | /** Display address. */ 58 | readonly address?: string; 59 | /** Country where the store is located (as defined during the store sign-up process). */ 60 | readonly country?: string; 61 | /** Display phone number. */ 62 | readonly phone?: string; 63 | /** Email address of the store administrator/owner. */ 64 | readonly admin_email?: string; 65 | /** Email address for orders and fulfillment. */ 66 | readonly order_email?: string; 67 | readonly timezone?: definitions["Timezone"]; 68 | /** Default language code. */ 69 | readonly language?: string; 70 | /** Default currency code */ 71 | readonly currency?: string; 72 | /** Default symbol for values in the currency. */ 73 | readonly currency_symbol?: string; 74 | /** Default decimal separator for values in the currency. */ 75 | readonly decimal_separator?: string; 76 | /** Default thousands separator for values in the currency. */ 77 | readonly thousands_separator?: string; 78 | /** Default decimal places for values in the currency. */ 79 | readonly decimal_places?: number; 80 | /** Default position of the currency symbol (left or right). */ 81 | readonly currency_symbol_location?: string; 82 | /** Default weight units (metric or imperial). */ 83 | readonly weight_units?: string; 84 | /** Default dimension units (metric or imperial). */ 85 | readonly dimension_units?: string; 86 | /** The number of decimal places. */ 87 | readonly dimension_decimal_places?: number; 88 | /** The symbol that separates the whole numbers from the decimal points. */ 89 | readonly dimension_decimal_token?: string; 90 | /** The symbol used to denote thousands. */ 91 | readonly "dimension_thousands_token:"?: string; 92 | /** Name of the BigCommerce plan to which this store is subscribed. */ 93 | readonly plan_name?: string; 94 | /** Level of the BigCommerce plan to which this store is subscribed. */ 95 | readonly plan_level?: string; 96 | /** Industry, or vertical category, in which the business operates. (As selected from drop-down list during the store sign-up process.) */ 97 | readonly industry?: string; 98 | readonly logo?: { 99 | readonly url?: string; 100 | }; 101 | /** A Boolean value that indicates whether or not prices are entered with tax. */ 102 | readonly is_price_entered_with_tax?: boolean; 103 | readonly active_comparison_modules?: readonly { 104 | readonly [key: string]: any; 105 | }[]; 106 | /** 107 | * + `stencil_enabled`: `true` (boolean) 108 | * + `sitewidehttps_enabled`: `false` (boolean) 109 | * + `facebook_catalog_id` (string) 110 | */ 111 | readonly features?: { 112 | /** Indicates whether a store is using a Stencil theme. */ 113 | readonly stencil_enabled?: boolean; 114 | /** Indicates if there is sitewide https. */ 115 | readonly sitewidehttps_enabled?: string; 116 | /** Id of the facebook catalog. If there is none, it returns an empty string. */ 117 | readonly facebook_catalog_id?: string; 118 | /** What type of checkout is enabled on the store. Possible values returned are optimized, single (one page), single_customizable (one page for developers), klarna. */ 119 | readonly checkout_type?: string; 120 | }; 121 | }; 122 | readonly Timezone: { 123 | /** a string identifying the time zone, in the format: /. */ 124 | readonly name?: string; 125 | /** a negative or positive number, identifying the offset from UTC/GMT, in seconds, during winter/standard time. */ 126 | readonly raw_offset?: number; 127 | /** "-/+" offset from UTC/GMT, in seconds, during summer/daylight saving time. */ 128 | readonly dst_offset?: number; 129 | /** a boolean indicating whether this time zone observes daylight saving time. */ 130 | readonly dst_correction?: boolean; 131 | readonly date_format?: definitions["DateFormat"]; 132 | }; 133 | readonly DateFormat: { 134 | /** string that defines dates’ display format, in the pattern: M jS Y */ 135 | readonly display?: string; 136 | /** string that defines the CSV export format for orders, customers, and products, in the pattern: M jS Y */ 137 | readonly export?: string; 138 | /** string that defines dates’ extended-display format, in the pattern: M jS Y @ g:i A. */ 139 | readonly extended_display?: string; 140 | }; 141 | /** Store Time in Unix format. */ 142 | readonly timeStamp_Full: { 143 | readonly time?: number; 144 | }; 145 | } 146 | 147 | export interface operations {} 148 | -------------------------------------------------------------------------------- /src/internal/reference/generated/storefront_tokens.v3.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/storefront/api-token": { 8 | /** 9 | * Creates a Storefront API token. 10 | * 11 | * **Required Scopes** 12 | * * `Manage` `Storefront API Tokens` 13 | */ 14 | readonly post: operations["createToken"]; 15 | /** Revoke access for a Storefront API token. */ 16 | readonly delete: operations["revokeToken"]; 17 | }; 18 | readonly "/storefront/api-token-customer-impersonation": { 19 | /** 20 | * Creates a Storefront API token that allows for customer impersonation. 21 | * 22 | * **Required Scopes** 23 | * * `Manage` `Storefront API Customer Impersonation Tokens` 24 | * 25 | * **Headers**: 26 | * * `X-Bc-Customer-Id` - The ID of the Customer to impersonate 27 | */ 28 | readonly post: operations["createTokenWithCustomerImpersonation"]; 29 | }; 30 | } 31 | 32 | export interface definitions { 33 | readonly TokenPostImpersonation: { 34 | /** Channel ID for requested token */ 35 | readonly channel_id: number; 36 | /** Unix timestamp (UTC time) defining when the token should expire. */ 37 | readonly expires_at: number; 38 | }; 39 | readonly TokenPostSimple: { 40 | /** List of allowed domains for Cross-Origin Request Sharing. Currently only accepts a single element. */ 41 | readonly allowed_cors_origins?: readonly string[]; 42 | }; 43 | readonly Token_Full: { 44 | readonly data?: definitions["Token_Base"]; 45 | readonly meta?: { readonly [key: string]: any }; 46 | }; 47 | readonly Token_Base: { 48 | /** JWT Token for accessing the Storefront API */ 49 | readonly token?: string; 50 | }; 51 | readonly ErrorResponse: definitions["BaseError"] & { 52 | readonly errors?: definitions["DetailedErrors"]; 53 | }; 54 | /** Error payload for the BigCommerce API. */ 55 | readonly BaseError: { 56 | /** The HTTP status code. */ 57 | readonly status?: number; 58 | /** The error title describing the particular error. */ 59 | readonly title?: string; 60 | readonly type?: string; 61 | }; 62 | readonly DetailedErrors: { readonly [key: string]: string }; 63 | } 64 | 65 | export interface responses { 66 | readonly TokenResponse: { 67 | readonly schema: definitions["Token_Full"]; 68 | }; 69 | } 70 | 71 | export interface operations { 72 | /** 73 | * Creates a Storefront API token. 74 | * 75 | * **Required Scopes** 76 | * * `Manage` `Storefront API Tokens` 77 | */ 78 | readonly createToken: { 79 | readonly parameters: { 80 | readonly body: { 81 | readonly body?: definitions["TokenPostSimple"] & 82 | definitions["TokenPostImpersonation"]; 83 | }; 84 | }; 85 | readonly responses: { 86 | readonly 200: responses["TokenResponse"]; 87 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 88 | readonly 401: unknown; 89 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 90 | readonly 403: unknown; 91 | /** Invalid JSON request body - missing or invalid data. */ 92 | readonly 422: unknown; 93 | }; 94 | }; 95 | /** Revoke access for a Storefront API token. */ 96 | readonly revokeToken: { 97 | readonly parameters: { 98 | readonly header: { 99 | /** An existing JWT token that you want to revoke. */ 100 | readonly "Sf-Api-Token": string; 101 | }; 102 | }; 103 | readonly responses: { 104 | /** A storefront API token revocation has been scheduled. */ 105 | readonly 200: unknown; 106 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 107 | readonly 401: unknown; 108 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 109 | readonly 403: unknown; 110 | /** Invalid JWT Token provided or missing JWT token header */ 111 | readonly 422: unknown; 112 | }; 113 | }; 114 | /** 115 | * Creates a Storefront API token that allows for customer impersonation. 116 | * 117 | * **Required Scopes** 118 | * * `Manage` `Storefront API Customer Impersonation Tokens` 119 | * 120 | * **Headers**: 121 | * * `X-Bc-Customer-Id` - The ID of the Customer to impersonate 122 | */ 123 | readonly createTokenWithCustomerImpersonation: { 124 | readonly parameters: { 125 | readonly header: { 126 | /** Ther Customer ID for the customer to impersonate */ 127 | readonly "X-Bc-Customer-Id": number; 128 | }; 129 | readonly body: { 130 | readonly body?: definitions["TokenPostImpersonation"]; 131 | }; 132 | }; 133 | readonly responses: { 134 | readonly 200: responses["TokenResponse"]; 135 | /** Unauthorized - the v3 Auth client ID or token in the request are not a valid combination for this store. */ 136 | readonly 401: unknown; 137 | /** Missing scope - the v3 Auth token is valid but does not have proper permissions to access this endpoint. */ 138 | readonly 403: unknown; 139 | /** Invalid JSON request body - missing or invalid data */ 140 | readonly 422: unknown; 141 | }; 142 | }; 143 | } 144 | -------------------------------------------------------------------------------- /src/internal/reference/generated/subscriptions.sf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/subscriptions": { 8 | /** 9 | * Creates or updates an email subscription. 10 | * 11 | * By default, customers receive abandoned cart emails as soon as they provide their email address in the checkout flow. They can opt out using this endpoint. 12 | * 13 | * However, if **Store Settings > Miscellaneous > Require Consent** is enabled, Abandoned Cart Emails are not sent by default, and the customer should opt-in. 14 | * 15 | *
16 | *
17 | *
18 | * 19 | * > ### Note 20 | * > The Send a Test Request feature is not currently supported for this endpoint. 21 | * 22 | *
23 | *
24 | *
25 | */ 26 | readonly post: { 27 | readonly parameters: { 28 | readonly body: { 29 | readonly body?: definitions["SubscriptionRequest"]; 30 | }; 31 | }; 32 | readonly responses: { 33 | readonly 200: { 34 | readonly schema: definitions["Subscription"]; 35 | }; 36 | }; 37 | }; 38 | }; 39 | } 40 | 41 | export interface definitions { 42 | readonly SubscriptionRequest: { 43 | /** Email of subscriber */ 44 | readonly email?: string; 45 | /** Has subscriber provided consent for receiving Marketing emails. */ 46 | readonly acceptsMarketingNewsletter?: boolean; 47 | /** Has subscriber provided consent for receiving Abandon Cart emails. */ 48 | readonly acceptsAbandonedCartEmails?: boolean; 49 | }; 50 | /** Subscription properties. */ 51 | readonly Subscription: { 52 | /** The unique numeric ID of the subscriber; increments sequentially. */ 53 | readonly id?: number; 54 | /** The email of the subscriber. Must be unique. */ 55 | readonly email?: string; 56 | /** The first name of the subscriber. */ 57 | readonly firstName?: string; 58 | /** The last name of the subscriber. */ 59 | readonly lastName?: string; 60 | /** The source of the subscriber. Values are: `storefront`, `order`, or `custom`. */ 61 | readonly source?: string; 62 | /** The ID of the source order, if source was an order. */ 63 | readonly orderId?: number; 64 | /** The collection of consents the shopper is subscribing to. */ 65 | readonly consents?: readonly any[]; 66 | }; 67 | } 68 | 69 | export interface operations {} 70 | -------------------------------------------------------------------------------- /src/internal/reference/generated/tax_classes.v2.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file was auto-generated by openapi-typescript. 3 | * Do not make direct changes to the file. 4 | */ 5 | 6 | export interface paths { 7 | readonly "/tax_classes": { 8 | /** 9 | * Returns a list of all *Tax Classes* in a store. 10 | * 11 | * Default sorting is by tax-class id, from lowest to highest. 12 | */ 13 | readonly get: operations["getAllTaxClasses"]; 14 | }; 15 | readonly "/tax_classes/{id}": { 16 | /** Returns a single *Tax Class*. */ 17 | readonly get: operations["getATaxClass"]; 18 | }; 19 | } 20 | 21 | export interface definitions { 22 | readonly taxClass_Full: { 23 | /** The unique numerical ID of the tax class. A read-only value which is automatically assigned and increments sequentially. */ 24 | readonly id?: string; 25 | /** The name of the tax class. */ 26 | readonly name?: string; 27 | /** Date and time of the tax class' creation. Read-Only. */ 28 | readonly created_at?: string; 29 | /** Date and time when the tax class was last updated. Read-Only. */ 30 | readonly updated_at?: string; 31 | }; 32 | } 33 | 34 | export interface operations { 35 | /** 36 | * Returns a list of all *Tax Classes* in a store. 37 | * 38 | * Default sorting is by tax-class id, from lowest to highest. 39 | */ 40 | readonly getAllTaxClasses: { 41 | readonly parameters: { 42 | readonly header: { 43 | readonly Accept: string; 44 | readonly "Content-Type": string; 45 | }; 46 | readonly query: { 47 | /** Optional filter param. Number of pages. */ 48 | readonly page?: number; 49 | /** Optional filter param. Number of items per page */ 50 | readonly limit?: number; 51 | }; 52 | }; 53 | readonly responses: { 54 | readonly 200: { 55 | readonly schema: readonly definitions["taxClass_Full"][]; 56 | }; 57 | }; 58 | }; 59 | /** Returns a single *Tax Class*. */ 60 | readonly getATaxClass: { 61 | readonly parameters: { 62 | readonly path: { 63 | /** Id of the tax class. */ 64 | readonly id: number; 65 | }; 66 | readonly header: { 67 | readonly Accept: string; 68 | readonly "Content-Type": string; 69 | }; 70 | }; 71 | readonly responses: { 72 | readonly 200: { 73 | readonly schema: definitions["taxClass_Full"]; 74 | }; 75 | }; 76 | }; 77 | } 78 | -------------------------------------------------------------------------------- /src/internal/reference/generated/v2.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { InferOperationIndex } from "../operation-inference"; 3 | 4 | import type * as currencies from "./currencies.v2" 5 | import type * as customers from "./customers.v2" 6 | import type * as geography from "./geography.v2" 7 | import type * as marketing from "./marketing.v2" 8 | import type * as orders from "./orders.v2.oas2" 9 | import type * as payment_methods from "./payment_methods.v2" 10 | import type * as shipping from "./shipping.v2" 11 | import type * as store_content from "./store_content.v2" 12 | import type * as store_information from "./store_information.v2" 13 | import type * as tax_classes from "./tax_classes.v2" 14 | 15 | export type Operation = 16 | & InferOperationIndex 17 | & InferOperationIndex 18 | & InferOperationIndex 19 | & InferOperationIndex 20 | & InferOperationIndex 21 | & InferOperationIndex 22 | & InferOperationIndex 23 | & InferOperationIndex 24 | & InferOperationIndex 25 | & InferOperationIndex 26 | ; 27 | -------------------------------------------------------------------------------- /src/internal/reference/generated/v3.ts: -------------------------------------------------------------------------------- 1 | 2 | import type { InferOperationIndex } from "../operation-inference"; 3 | 4 | import type * as abandoned_carts from "./abandoned_carts.v3" 5 | import type * as carts from "./carts.v3" 6 | import type * as catalog from "./catalog.v3" 7 | import type * as channels from "./channels.v3" 8 | import type * as checkouts from "./checkouts.v3" 9 | import type * as custom_template_associations from "./custom_template_associations.v3" 10 | import type * as customers from "./customers.v3" 11 | import type * as email_templates from "./email_templates.v3" 12 | import type * as orders from "./orders.v3" 13 | import type * as pages from "./pages.v3" 14 | import type * as price_lists from "./price_lists.v3" 15 | import type * as redirects from "./redirects.v3" 16 | import type * as scripts from "./scripts.v3" 17 | import type * as settings from "./settings.v3" 18 | import type * as shipping from "./shipping.v3" 19 | import type * as sites from "./sites.v3" 20 | import type * as storefront_tokens from "./storefront_tokens.v3" 21 | import type * as subscribers from "./subscribers.v3" 22 | import type * as tax from "./tax.v3" 23 | import type * as themes from "./themes.v3" 24 | import type * as webhooks from "./webhooks.v3" 25 | import type * as widgets from "./widgets.v3" 26 | import type * as wishlists from "./wishlists.v3" 27 | 28 | export type Operation = 29 | & InferOperationIndex 30 | & InferOperationIndex 31 | & InferOperationIndex 32 | & InferOperationIndex 33 | & InferOperationIndex 34 | & InferOperationIndex 35 | & InferOperationIndex 36 | & InferOperationIndex 37 | & InferOperationIndex 38 | & InferOperationIndex 39 | & InferOperationIndex 40 | & InferOperationIndex 41 | & InferOperationIndex 42 | & InferOperationIndex 43 | & InferOperationIndex 44 | & InferOperationIndex 45 | & InferOperationIndex 46 | & InferOperationIndex 47 | & InferOperationIndex 48 | & InferOperationIndex 49 | & InferOperationIndex 50 | & InferOperationIndex 51 | & InferOperationIndex 52 | ; 53 | -------------------------------------------------------------------------------- /src/internal/reference/index.ts: -------------------------------------------------------------------------------- 1 | export * as Storefront from "./generated/sf"; 2 | export * as V2 from "./generated/v2"; 3 | export * as V3 from "./generated/v3"; 4 | -------------------------------------------------------------------------------- /src/internal/reference/operation-inference.ts: -------------------------------------------------------------------------------- 1 | import type { RequestMethod } from "../operation"; 2 | 3 | export type InferOperationIndex = 4 | Flatten< 5 | { 6 | [PathStr in (keyof PathsSpec) & string]: PathOperationIndex 7 | } 8 | >; 9 | 10 | type Flatten> = UnionToIntersection; 11 | 12 | type UnionToIntersection = 13 | (T extends any ? (x: T) => any : never) extends (x: infer R) => any ? R : never; 14 | 15 | type PathOperationIndex = 1 extends 0 ? never : { 16 | [K in keyof PathSpec as K extends RequestMethodLc ? `${Uppercase} ${Path}` : never]: 17 | // oas 3 18 | PathSpec[K] extends { parameters?: infer Params, responses?: infer Responses, requestBody: { content: { "application/json": infer RequestBody } } } 19 | ? { 20 | readonly parameters: (unknown extends Params ? {} : Params) & { body: RequestBody } 21 | readonly response: Response 22 | } 23 | // oas 2 24 | : PathSpec[K] extends { parameters?: infer Params, responses?: infer Responses } 25 | ? { 26 | readonly parameters: unknown extends Params ? {} : CorrectOas2RequestBody 27 | readonly response: Response 28 | } 29 | : never 30 | }; 31 | 32 | type CorrectOas2RequestBody = 33 | Params extends { body: { [nonsenseKey: string]: infer RealBody } } 34 | ? Omit & { body: RealBody } 35 | : Params extends { body?: { [nonsenseKey: string]: infer RealBody } } 36 | ? Omit & { body?: RealBody } 37 | : Params; 38 | 39 | type RequestMethodLc = Lowercase; 40 | 41 | type Response = 1 extends 0 ? never : { 42 | [Status in keyof ResponsesSpec]: { 43 | status: Status 44 | body: 45 | // oas 3 46 | ResponsesSpec[Status] extends { content: { "application/json": infer ResponseBody } } ? ResponseBody 47 | // oas 2 48 | : ResponsesSpec[Status] extends { schema: infer Schema } ? Schema 49 | : never 50 | } 51 | }[keyof ResponsesSpec]; 52 | -------------------------------------------------------------------------------- /src/internal/type-utils.ts: -------------------------------------------------------------------------------- 1 | export type Const
= 2 | | (A extends Narrowable ? A : never) 3 | | ({ [K in keyof A]: Const }); 4 | 5 | type Narrowable = 6 | | string 7 | | number 8 | | bigint 9 | | boolean 10 | | readonly any[]; 11 | 12 | export type RemoveStart = 13 | Subject extends `${Start}${infer End}` ? End : never 14 | -------------------------------------------------------------------------------- /src/management/README.md: -------------------------------------------------------------------------------- 1 | # BigCommerce Management API client 2 | 3 | A JavaScript client for BigCommerce's Management API with full TypeScript typings for all API endpoints. 4 | 5 | # Getting started 6 | 7 | To get started with the Management API client you'll need to install it, and then get credentials which will allow you to read and write data in your BigCommerce store. 8 | 9 | - [Installation](#installation) 10 | - [Authentication](#authentication) 11 | - [Using ES6 import](#using-es6-import) 12 | - [Your first request](#your-first-request) 13 | - [How-to guides](#how-to-guides) 14 | - [References](#references) 15 | 16 | ## Installation 17 | 18 | ### Node: 19 | 20 | ```sh 21 | npm install @space48/bigcommerce-api 22 | ``` 23 | 24 | ### Browser: 25 | 26 | Coming soon. 27 | 28 | ### Typings 29 | 30 | This library also comes with typings to use with TypeScript. 31 | 32 | ## Authentication 33 | 34 | To use the BigCommerce Management API you first need to [obtain the store hash and an access token](https://developer.bigcommerce.com/api-docs/getting-started/authentication/rest-api-authentication#obtaining-store-api-credentials) from your BigCommerce store's control panel. 35 | 36 | ## Using ES6 import 37 | 38 | You can use es6 imports with the Management API: 39 | 40 | ```js 41 | import { Management } from "@space48/bigcommerce-api"; 42 | 43 | const bigCommerce = new Management.Client({ 44 | storeHash: 'your store hash here', 45 | accessToken: 'your access token here', 46 | }); 47 | ``` 48 | 49 | ## Your first request 50 | 51 | The following code snippet will fetch store information from the V2 API and dump it to the console: 52 | 53 | ```js 54 | import { Management } from "@space48/bigcommerce-api"; 55 | 56 | const bigCommerce = new Management.Client({ 57 | storeHash: 'your store hash here', 58 | accessToken: 'your access token here', 59 | }); 60 | 61 | bigCommerce.v2.get('/store').then(console.dir); 62 | ``` 63 | 64 | ## How-to guides 65 | 66 | Start by instantiating a client instance: 67 | 68 | ```js 69 | import { Management } from "@space48/bigcommerce-api"; 70 | 71 | const bigCommerce = new Management.Client({ 72 | storeHash: 'your store hash here', 73 | accessToken: 'your access token here', 74 | }); 75 | ``` 76 | 77 | ### How to send a GET request with no params 78 | 79 | ```js 80 | bigCommerce.v2.get('/store').then( 81 | storeInfo => { // 200 -> response.body; 204, 404 -> null 82 | console.dir(storeInfo), 83 | } 84 | error => { // non-2xx, non-404 85 | console.error(error); 86 | }, 87 | ); 88 | ``` 89 | 90 | > Note: When using the V3 client, `get()`, `post()`, `put()` and `delete()` return response.body.data on success whereas the equivalent V2 methods return response.body. If you require access to response.body.meta when sending a V3 request you should use the `Management.v3.send()` method. 91 | 92 | ### How to send a GET request with params 93 | 94 | ```js 95 | bigCommerce.v3.get('/catalog/products/{product_id}', { 96 | path: { product_id: 1234 }, 97 | query: { include: ['images'] } 98 | }).then( 99 | product => { // 200 -> response.body.data; 204, 404 -> null 100 | console.dir(product), 101 | } 102 | error => { // non-2xx, non-404 103 | console.error(error); 104 | }, 105 | ) 106 | ``` 107 | 108 | > Note: When using the V3 client, `get()`, `post()`, `put()` and `delete()` return response.body.data on success whereas the equivalent V2 methods return response.body. If you require access to response.body.meta when sending a V3 request you should use the `Management.v3.send()` method. 109 | 110 | ### How to retrieve all items from a paginated v3 endpoint 111 | 112 | ```js 113 | async function printAllProducts() { 114 | // list() sends one HTTP request at a time and only sends requests as the iterator is consumed 115 | const products = bigCommerce.v3.list('/catalog/products', { query: { include: ['images'] } }); 116 | for await (const product of products) { 117 | console.dir(product); 118 | } 119 | } 120 | ``` 121 | 122 | > Note: `list()` is currently only available for V3 endpoints as the V2 API does not apply a standardised approach to pagination. 123 | 124 | ### How to send a request with a body 125 | 126 | ```js 127 | bigCommerce.v3.post('/customers', { 128 | body: [ 129 | { 130 | email: 'john.doe@example.com', 131 | first_name: 'John', 132 | last_name: 'Doe', 133 | }, 134 | { 135 | email: 'jane.doe@example.com', 136 | first_name: 'Jane', 137 | last_name: 'Doe', 138 | }, 139 | ], 140 | }).then( 141 | result => { // 200 -> response.body.data; 204 -> null 142 | console.dir(result), 143 | } 144 | error => { // non-2xx 145 | console.error(error); 146 | }, 147 | ) 148 | ``` 149 | 150 | > Note: When using the V3 client, `get()`, `post()`, `put()` and `delete()` return response.body.data on success whereas the equivalent V2 methods return response.body. If you require access to response.body.meta when sending a V3 request you should use the `Management.v3.send()` method. 151 | 152 | ## References 153 | 154 | ### Configuration 155 | 156 | The `Client` constructor supports several options you may set to achieve the expected behavior: 157 | 158 | ```js 159 | import { Management } from "@space48/bigcommerce-api"; 160 | 161 | const bigCommerce = new Management.Client({ 162 | ... your config here ... 163 | }); 164 | ``` 165 | 166 | #### storeHash (required) 167 | 168 | Your BigCommerce store hash. 169 | 170 | #### accessToken (required) 171 | 172 | Your BigCommerce Management API access token. 173 | 174 | #### agent (optional; node runtime only) 175 | 176 | Provide a node HTTP agent to override things like keepalive and connection pool size. 177 | 178 | ### V2 API client 179 | 180 | See the [V2 readme](v2/README.md) for more detail on the Management V2 client methods. 181 | 182 | ### V3 API client 183 | 184 | See the [V3 readme](v3/README.md) for more detail on the Management V3 client methods. 185 | 186 | ### REST API reference 187 | 188 | This library is a wrapper around BigCommerce's REST API. Visit the [BigCommerce API reference](https://developer.bigcommerce.com/api-reference) to see detailed documentation of the available endpoints and parameters. 189 | -------------------------------------------------------------------------------- /src/management/index.ts: -------------------------------------------------------------------------------- 1 | import { Agent } from "http"; 2 | import * as V2 from "./v2"; 3 | import * as V3 from "./v3"; 4 | 5 | export * as V2 from "./v2"; 6 | export * as V3 from "./v3"; 7 | 8 | export type Config = { 9 | readonly storeHash: string; 10 | readonly accessToken: string; 11 | readonly agent?: Agent 12 | }; 13 | 14 | /** 15 | * If you need to use a path which is not part if the spec, you can pass it 16 | * into the client via a type parameter to avoid TypeScript errors, e.g.: 17 | * 18 | * type MyExtraEndpoints = 19 | * | 'GET /v3/foo/bar' 20 | * | 'POST /v3/foo/bar' 21 | * | 'GET /v2/foo/baz' 22 | * ; 23 | * 24 | * bigCommerce = new Client(config) 25 | */ 26 | 27 | export class Client { 28 | constructor( 29 | private readonly config: Config 30 | ) {} 31 | 32 | readonly v2 = new V2.Client>(this.config); 33 | readonly v3 = new V3.Client>(this.config); 34 | } 35 | 36 | type ExtractSubpaths 37 | = AllCustomEndpoints extends `${infer Method} ${Path}${infer Subpath}` 38 | ? `${Method} ${Subpath}` 39 | : never 40 | ; 41 | -------------------------------------------------------------------------------- /src/management/v2/README.md: -------------------------------------------------------------------------------- 1 | # BigCommerce Management V2 API client 2 | 3 | A JavaScript client for BigCommerce's Management V2 API with full TypeScript typings for all API endpoints. 4 | 5 | For non-V2 specific documentation see the [Management API readme](../README.md). 6 | 7 | # V2 client methods 8 | 9 | The V2 client provides several high-level methods which should generally be used when interacting with the V2 API, as well as a lower level `send` method which can be used when the behavior of the higher-level methods is insufficient. 10 | 11 | ## High-level methods 12 | 13 | ### v2.get() 14 | 15 | `v2.get(path, params?): Promise` 16 | 17 | Sends a GET request to /v2/{path} with the specified parameters. Returns response.body on success and `null` in the case of a 404. Throws an error if some other error status (4xx or 5xx) is returned. 18 | 19 | ### v2.post() 20 | 21 | `v2.post(path, params?): Promise` 22 | 23 | Sends a POST request to /v2/{path} with the specified parameters. Returns response.body on success. Throws an error if any error status (4xx or 5xx) is returned. 24 | 25 | ### v2.put() 26 | 27 | `v2.put(path, params?): Promise` 28 | 29 | Sends a PUT request to /v2/{path} with the specified parameters. Returns response.body on success. Throws an error if any error status (4xx or 5xx) is returned. 30 | 31 | ### v2.delete() 32 | 33 | `v2.delete(path, params?): Promise` 34 | 35 | Sends a DELETE request to /v2/{path} with the specified parameters. Returns response.body on a 200 response and `null` on 204. Throws an error if any error status (4xx or 5xx) is returned. 36 | 37 | ## Low-level send() method 38 | 39 | `v2.send(requestLine, params?): Promise` 40 | 41 | Sends a request and returns the response as is. Only throws if there is a network error. 4xx and 5xx responses are simply returned. 42 | 43 | For example: 44 | ```js 45 | const response = await Management.v2.send('GET /customers/{customer_id}', { path: { customer_id: 123 } }); 46 | if (response.status === 200) { 47 | response.body // { data: { id: 123, ... }, meta: { ... } } 48 | } else if (response.status === 404) { 49 | // customer does not exist 50 | } 51 | ``` 52 | -------------------------------------------------------------------------------- /src/management/v2/index.ts: -------------------------------------------------------------------------------- 1 | import type { V2 as reference } from "../../internal/reference"; 2 | import type { NarrowResponse } from "./response-narrowing" 3 | import { Operation, OperationIndex, Parameters, Request, RequestMethod, Response, fetchTransport, Transport, FetchTransportOptions } from "../../internal/operation"; 4 | import { Const, RemoveStart } from "../../internal/type-utils"; 5 | 6 | export type Operations = reference.Operation; 7 | 8 | export type RequestLine = keyof Operations; 9 | 10 | export type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; 11 | 12 | export type InferResponse = 13 | NarrowResponse< 14 | Operations, 15 | Request, 16 | Operations[ReqLine]['response'] 17 | >; 18 | 19 | export type ResponseData = 20 | Response.Success> extends { readonly body: infer Data } 21 | ? Data 22 | : never; 23 | 24 | export type Config = Omit & { 25 | readonly storeHash: string 26 | readonly accessToken: string 27 | }; 28 | 29 | export class Client { 30 | constructor(config: Config) 31 | 32 | constructor(transport: Transport) 33 | 34 | constructor(configOrTransport: Config | Transport) { 35 | this.transport = 36 | typeof configOrTransport === 'function' 37 | ? configOrTransport 38 | : fetchTransport({ 39 | agent: configOrTransport.agent, 40 | baseUrl: `https://api.bigcommerce.com/stores/${configOrTransport.storeHash}/v2`, 41 | headers: { "X-Auth-Token": configOrTransport.accessToken }, 42 | }); 43 | } 44 | 45 | private readonly transport: Transport; 46 | 47 | send(requestLine: ReqLine): Promise> 48 | 49 | send> ( 50 | requestLine: ReqLine, 51 | params: Const> 52 | ): Promise> 53 | 54 | send(requestLine: string, params?: Parameters): Promise 55 | 56 | async send(requestLine: string, params?: Parameters): Promise { 57 | return this.transport(requestLine, params); 58 | } 59 | 60 | delete>(requestLine: Path): Promise | null> 61 | 62 | delete, Params extends Operation.MinimalInput> ( 63 | path: Path, 64 | params: Const> 65 | ): Promise | null> 66 | 67 | delete(path: RemoveStart<'DELETE ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise 68 | 69 | async delete(path: string, params?: Parameters): Promise { 70 | const res = await this.send(`DELETE ${path}`, params); 71 | if (res.status === 204) { 72 | return null; 73 | } 74 | this.checkResponseStatus(`DELETE ${path}`, res); 75 | return res.body; 76 | } 77 | 78 | get>(requestLine: Path): Promise | null> 79 | 80 | get, Params extends Operation.MinimalInput> ( 81 | path: Path, 82 | params: Const> 83 | ): Promise | null> 84 | 85 | get(path: RemoveStart<'GET ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise 86 | 87 | async get(path: string, params?: Parameters): Promise { 88 | const res = await this.send(`GET ${path}`, params); 89 | if (res.status === 204 || res.status === 404) { 90 | return null; 91 | } 92 | this.checkResponseStatus(`GET ${path}`, res); 93 | return res.body; 94 | } 95 | 96 | post>(requestLine: Path): Promise> 97 | 98 | post, Params extends Operation.MinimalInput> ( 99 | path: Path, 100 | params: Const> 101 | ): Promise> 102 | 103 | post(path: RemoveStart<'POST ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise 104 | 105 | async post(path: string, params?: Parameters): Promise { 106 | const res = await this.send(`POST ${path}`, params); 107 | this.checkResponseStatus(`POST ${path}`, res); 108 | return res.body; 109 | } 110 | 111 | put>(requestLine: Path): Promise> 112 | 113 | put, Params extends Operation.MinimalInput> ( 114 | path: Path, 115 | params: Const> 116 | ): Promise> 117 | 118 | put(path: RemoveStart<'PUT ', UntypedEndpoints | CustomEndpoints>, params?: Parameters): Promise 119 | 120 | async put(path: string, params?: Parameters): Promise { 121 | const res = await this.send(`PUT ${path}`, params); 122 | this.checkResponseStatus(`PUT ${path}`, res); 123 | return res.body; 124 | } 125 | 126 | private checkResponseStatus(requestLine: string, response: Response): void { 127 | if (response.status > 299) { 128 | throw new Error(`ERROR DURING ${requestLine}: ${response.status} - ${JSON.stringify(response.body)}`); 129 | } 130 | } 131 | } 132 | 133 | type ResolveResponse = 134 | unknown extends Params 135 | ? Operations[ReqLine]['response'] 136 | : Params extends Parameters 137 | ? InferResponse 138 | : never; 139 | 140 | type RequestPath = 141 | RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 142 | 143 | type NoParamsRequestPath = 144 | NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 145 | 146 | /** 147 | * A list of known BigCommerce endpoints which are not part of the Open API specs 148 | */ 149 | type UntypedEndpoints = 150 | | never 151 | ; 152 | -------------------------------------------------------------------------------- /src/management/v2/response-narrowing.ts: -------------------------------------------------------------------------------- 1 | import type { OperationIndex, Request, Response } from "../../internal/operation"; 2 | 3 | /** 4 | * This module contains functionality for narrowing the response type based on input parameters. 5 | * 6 | * See v3 for examples of how this can be done. 7 | */ 8 | 9 | export type NarrowResponse = Rep; 10 | -------------------------------------------------------------------------------- /src/management/v3/README.md: -------------------------------------------------------------------------------- 1 | # BigCommerce Management V3 API client 2 | 3 | A JavaScript client for BigCommerce's Management V3 API with full TypeScript typings for all API endpoints. 4 | 5 | For non-V3 specific documentation see the [Management API readme](../README.md). 6 | 7 | # V3 client methods 8 | 9 | The V3 client provides several high-level methods which should generally be used when interacting with the V3 API, as well as a lower level `send` method which can be used when the behavior of the higher-level methods is insufficient. 10 | 11 | ## High-level methods 12 | 13 | ### v3.get() 14 | 15 | `v3.get(path, params?): Promise` 16 | 17 | Sends a GET request to /v3/{path} with the specified parameters. Returns response.body.data on success and `null` in the case of a 404. Throws an error if some other error status (4xx or 5xx) is returned. 18 | 19 | ### v3.post() 20 | 21 | `v3.post(path, params?): Promise` 22 | 23 | Sends a POST request to /v3/{path} with the specified parameters. Returns response.body.data on success. Throws an error if any error status (4xx or 5xx) is returned. 24 | 25 | ### v3.put() 26 | 27 | `v3.put(path, params?): Promise` 28 | 29 | Sends a PUT request to /v3/{path} with the specified parameters. Returns response.body.data on success. Throws an error if any error status (4xx or 5xx) is returned. 30 | 31 | ### v3.delete() 32 | 33 | `v3.delete(path, params?): Promise` 34 | 35 | Sends a DELETE request to /v3/{path} with the specified parameters. Returns response.body.data on a 200 response and `null` on 204. Throws an error if any error status (4xx or 5xx) is returned. 36 | 37 | ### v3.list() 38 | 39 | `v3.list(path, params?): AsyncIterable` 40 | 41 | Sends GET requests to the paginated endpoint /v3/{path} with the specified parameters, automatically iterating through the pages and yielding the items using an `AsyncIterable`. Throws an error if any error status (4xx or 5xx) is returned. 42 | 43 | ## Low-level send() method 44 | 45 | `v3.send(requestLine, params?): Promise` 46 | 47 | Sends a request and returns the response as is. Only throws if there is a network error. 4xx and 5xx responses are simply returned. 48 | 49 | For example: 50 | ```js 51 | const response = await Management.v3.send('GET /catalog/products/{product_id}', { path: { product_id: 123 } }); 52 | if (response.status === 200) { 53 | response.body // { data: { id: 123, ... }, meta: { ... } } 54 | } else if (response.status === 404) { 55 | // product does not exist 56 | } 57 | ``` 58 | -------------------------------------------------------------------------------- /src/management/v3/response-narrowing.ts: -------------------------------------------------------------------------------- 1 | import type { Operation, OperationIndex, Parameters, Request, Response } from "../../internal/operation"; 2 | 3 | /** 4 | * This module contains functionality for narrowing the response type based on input parameters. 5 | * 6 | * For example, when requesting a product, specifying `{ include_fields: ['sku'] }` will cause BigCommerce 7 | * to only return the `id` and `sku` fields (as `id` is always returned). This module ensures that response 8 | * types reflect the query parameters which were passed in the request. 9 | * 10 | * Currently, this module supports `include`, `include_fields` and `exclude_fields`. 11 | */ 12 | 13 | export type NarrowResponse = 14 | NarrowResponse_>; 15 | 16 | type Includes = 17 | Op['parameters'] extends { query?: { include?: infer T } } 18 | ? T extends ReadonlyArray 19 | ? E 20 | : T extends string 21 | ? T 22 | : never 23 | : never; 24 | 25 | type NarrowResponse_< 26 | Params extends Parameters, 27 | Rep extends Response, 28 | Includes extends string 29 | > = 30 | Rep extends { body: { data?: infer Data, meta?: infer Meta } } 31 | ? { 32 | status: Rep['status'], 33 | body: { 34 | data: NarrowData, 35 | meta: Meta, 36 | } 37 | } 38 | : Rep; 39 | 40 | type NarrowData< 41 | Data, 42 | Query extends Record | undefined, 43 | Includes extends string, 44 | > = 45 | Data extends ReadonlyArray 46 | ? ReadonlyArray> 47 | : Required< 48 | NarrowFields, Query> 49 | & NarrowIncludes, Query> 50 | >; 51 | 52 | type NarrowFields | undefined> = 53 | Query extends { include_fields: ReadonlyArray } 54 | ? Pick 55 | : Query extends { exclude_fields: ReadonlyArray } 56 | ? Omit 57 | : Data 58 | 59 | type NarrowIncludes | undefined> = 60 | Query extends { include: ReadonlyArray } 61 | ? Pick 62 | : {}; 63 | -------------------------------------------------------------------------------- /src/management/v3/spec-sniffer.ts: -------------------------------------------------------------------------------- 1 | import type { Operations as Ops } from "."; 2 | 3 | /** 4 | * This file is for rules which sniff bugs in the BigCommerce API specs. 5 | */ 6 | 7 | /** 8 | * NoDataElementInResponse should resolve to `never`. Any request lines which are resolved 9 | * are missing data elements in the response schema. 10 | */ 11 | type NoDataElementInResponse = { 12 | [K in keyof Ops]: 13 | Ops[K]['response'] extends { status: 200 | 201 } 14 | ? Ops[K]['response']['body'] extends { data?: any } 15 | ? never 16 | : K 17 | : never 18 | }[keyof Ops]; 19 | -------------------------------------------------------------------------------- /src/storefront/README.md: -------------------------------------------------------------------------------- 1 | Storefront support is coming soon. 2 | -------------------------------------------------------------------------------- /src/storefront/index.ts: -------------------------------------------------------------------------------- 1 | import type { Storefront as reference } from "../internal/reference"; 2 | import type { NarrowResponse } from "./response-narrowing" 3 | import type { Operation, OperationIndex, Parameters, Request, RequestMethod, Response } from "../internal/operation"; 4 | import { Const } from "../internal/type-utils"; 5 | 6 | export type Operations = reference.Operation; 7 | 8 | export type RequestLine = keyof Operations; 9 | 10 | export type NoParamsRequestLine = keyof OperationIndex.FilterOptionalParams; 11 | 12 | export type InferResponse = 13 | NarrowResponse< 14 | Operations, 15 | Request, 16 | Operations[ReqLine]['response'] 17 | >; 18 | 19 | export type ResponseData = 20 | Response.Success> extends { readonly body: infer Data } 21 | ? Data 22 | : never; 23 | 24 | export interface Client { 25 | send(requestLine: ReqLine): Promise> 26 | 27 | send> ( 28 | requestLine: ReqLine, 29 | params: Const> 30 | ): Promise> 31 | 32 | //Todo investigate and resolve issue no paramter request paths 33 | //delete>(requestLine: Path): Promise | null> 34 | 35 | delete, Params extends Operation.MinimalInput> ( 36 | path: Path, 37 | params: Const> 38 | ): Promise | null> 39 | 40 | get>(requestLine: Path): Promise | null> 41 | 42 | get, Params extends Operation.MinimalInput> ( 43 | path: Path, 44 | params: Const> 45 | ): Promise | null> 46 | 47 | post>(requestLine: Path): Promise> 48 | 49 | post, Params extends Operation.MinimalInput> ( 50 | path: Path, 51 | params: Const> 52 | ): Promise> 53 | 54 | //Todo investigate and resolve issue no paramter request paths 55 | //put>(requestLine: Path): Promise> 56 | 57 | put, Params extends Operation.MinimalInput> ( 58 | path: Path, 59 | params: Const> 60 | ): Promise> 61 | } 62 | 63 | type ResolveResponse = 64 | unknown extends Params 65 | ? Operations[ReqLine]['response'] 66 | : Params extends Parameters 67 | ? InferResponse 68 | : never; 69 | 70 | type RequestPath = 71 | RequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 72 | 73 | type NoParamsRequestPath = 74 | NoParamsRequestLine & `${Method} ${any}` extends `${Method} ${infer Path}` ? Path : never; 75 | -------------------------------------------------------------------------------- /src/storefront/response-narrowing.ts: -------------------------------------------------------------------------------- 1 | import type { OperationIndex, Request, Response } from "../internal/operation"; 2 | 3 | /** 4 | * This module contains functionality for narrowing the response type based on input parameters. 5 | * 6 | * See management/v3 for examples of how this can be done. 7 | */ 8 | 9 | export type NarrowResponse = Rep; 10 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "strict": true, 5 | "outDir": "lib", 6 | "removeComments": false, 7 | "target": "es2020", 8 | "sourceMap": true, 9 | "typeRoots": [ 10 | "node_modules/@types" 11 | ], 12 | "esModuleInterop": true, 13 | "resolveJsonModule": true, 14 | "declaration": true, 15 | "strictNullChecks": true 16 | }, 17 | "include": ["src"] 18 | } 19 | -------------------------------------------------------------------------------- /tsconfig.publish.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "strict": true, 5 | "outDir": "lib", 6 | "removeComments": false, 7 | "target": "es2018", 8 | "sourceMap": false, 9 | "typeRoots": [ 10 | "node_modules/@types" 11 | ], 12 | "lib": ["ES2018"], 13 | "esModuleInterop": true, 14 | "resolveJsonModule": true, 15 | "declaration": true, 16 | "strictNullChecks": true 17 | }, 18 | "include": ["src"] 19 | } 20 | --------------------------------------------------------------------------------