import { type Agent } from "./_shims/index.js"; import * as Core from "./core.js"; import * as Errors from "./error.js"; import * as Uploads from "./uploads.js"; import * as API from "./resources/index.js"; import { Address, AddressCreateParams, AddressCreateResponse, AddressDeleteResponse, AddressGetResponse, AddressListResponse, AddressResource } from "./resources/address.js"; import { App, AppCreateParams, AppCreateResponse, AppDeleteResponse, AppGetResponse, AppListResponse, AppResource } from "./resources/app.js"; import { Card, CardCollectResponse, CardCreateParams, CardCreateResponse, CardDeleteResponse, CardGetResponse, CardListResponse, CardResource } from "./resources/card.js"; import { Cart, CartClearResponse, CartConvertResponse, CartGetResponse, CartResource, CartSetAddressParams, CartSetAddressResponse, CartSetCardParams, CartSetCardResponse, CartSetItemParams, CartSetItemResponse } from "./resources/cart.js"; import { Email, EmailCreateParams, EmailCreateResponse } from "./resources/email.js"; import { Order, OrderCreateParams, OrderCreateResponse, OrderGetResponse, OrderListResponse, OrderResource } from "./resources/order.js"; import { Product, ProductGetResponse, ProductListResponse, ProductResource, ProductVariant } from "./resources/product.js"; import { Profile, ProfileMeResponse, ProfileResource, ProfileUpdateParams, ProfileUpdateResponse } from "./resources/profile.js"; import { Subscription, SubscriptionCreateParams, SubscriptionCreateResponse, SubscriptionDeleteResponse, SubscriptionGetResponse, SubscriptionListResponse, SubscriptionResource, SubscriptionUpdateParams, SubscriptionUpdateResponse } from "./resources/subscription.js"; import { Token, TokenCreateResponse, TokenDeleteResponse, TokenGetResponse, TokenListResponse, TokenResource } from "./resources/token.js"; import { Region, View, ViewInitResponse } from "./resources/view.js"; declare const environments: { production: string; dev: string; }; type Environment = keyof typeof environments; export interface ClientOptions { /** * Defaults to process.env['TERMINAL_BEARER_TOKEN']. */ bearerToken?: string | undefined; appId?: string | null | undefined; /** * Specifies the environment to use for the API. * * Each environment maps to a different base URL: * - `production` corresponds to `https://api.terminal.shop` * - `dev` corresponds to `https://api.dev.terminal.shop` */ environment?: Environment | undefined; /** * Override the default base URL for the API, e.g., "https://api.example.com/v2/" * * Defaults to process.env['TERMINAL_BASE_URL']. */ baseURL?: string | null | undefined; /** * The maximum amount of time (in milliseconds) that the client should wait for a response * from the server before timing out a single request. * * Note that request timeouts are retried by default, so in a worst-case scenario you may wait * much longer than this timeout before the promise succeeds or fails. * * @unit milliseconds */ timeout?: number | undefined; /** * An HTTP agent used to manage HTTP(S) connections. * * If not provided, an agent will be constructed by default in the Node.js environment, * otherwise no agent is used. */ httpAgent?: Agent | undefined; /** * Specify a custom `fetch` function implementation. * * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is * defined globally. */ fetch?: Core.Fetch | undefined; /** * The maximum number of times that the client will retry a request in case of a * temporary failure, like a network error or a 5XX error from the server. * * @default 2 */ maxRetries?: number | undefined; /** * Default headers to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * header to `undefined` or `null` in request options. */ defaultHeaders?: Core.Headers | undefined; /** * Default query parameters to include with every request to the API. * * These can be removed in individual requests by explicitly setting the * param to `undefined` in request options. */ defaultQuery?: Core.DefaultQuery | undefined; } /** * API Client for interfacing with the Terminal API. */ export declare class Terminal extends Core.APIClient { #private; bearerToken: string; appId: string | null; private _options; /** * API Client for interfacing with the Terminal API. * * @param {string | undefined} [opts.bearerToken=process.env['TERMINAL_BEARER_TOKEN'] ?? undefined] * @param {string | null | undefined} [opts.appId] * @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API. * @param {string} [opts.baseURL=process.env['TERMINAL_BASE_URL'] ?? https://api.terminal.shop] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request. * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API. * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API. */ constructor({ baseURL, bearerToken, appId, ...opts }?: ClientOptions); product: API.ProductResource; profile: API.ProfileResource; address: API.AddressResource; card: API.CardResource; cart: API.CartResource; order: API.OrderResource; subscription: API.SubscriptionResource; token: API.TokenResource; app: API.AppResource; email: API.Email; view: API.View; protected defaultQuery(): Core.DefaultQuery | undefined; protected defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers; protected authHeaders(opts: Core.FinalRequestOptions): Core.Headers; static Terminal: typeof Terminal; static DEFAULT_TIMEOUT: number; static TerminalError: typeof Errors.TerminalError; static APIError: typeof Errors.APIError; static APIConnectionError: typeof Errors.APIConnectionError; static APIConnectionTimeoutError: typeof Errors.APIConnectionTimeoutError; static APIUserAbortError: typeof Errors.APIUserAbortError; static NotFoundError: typeof Errors.NotFoundError; static ConflictError: typeof Errors.ConflictError; static RateLimitError: typeof Errors.RateLimitError; static BadRequestError: typeof Errors.BadRequestError; static AuthenticationError: typeof Errors.AuthenticationError; static InternalServerError: typeof Errors.InternalServerError; static PermissionDeniedError: typeof Errors.PermissionDeniedError; static UnprocessableEntityError: typeof Errors.UnprocessableEntityError; static toFile: typeof Uploads.toFile; static fileFromPath: typeof Uploads.fileFromPath; } export declare namespace Terminal { export type RequestOptions = Core.RequestOptions; export { ProductResource as ProductResource, type Product as Product, type ProductVariant as ProductVariant, type ProductListResponse as ProductListResponse, type ProductGetResponse as ProductGetResponse, }; export { ProfileResource as ProfileResource, type Profile as Profile, type ProfileUpdateResponse as ProfileUpdateResponse, type ProfileMeResponse as ProfileMeResponse, type ProfileUpdateParams as ProfileUpdateParams, }; export { AddressResource as AddressResource, type Address as Address, type AddressCreateResponse as AddressCreateResponse, type AddressListResponse as AddressListResponse, type AddressDeleteResponse as AddressDeleteResponse, type AddressGetResponse as AddressGetResponse, type AddressCreateParams as AddressCreateParams, }; export { CardResource as CardResource, type Card as Card, type CardCreateResponse as CardCreateResponse, type CardListResponse as CardListResponse, type CardDeleteResponse as CardDeleteResponse, type CardCollectResponse as CardCollectResponse, type CardGetResponse as CardGetResponse, type CardCreateParams as CardCreateParams, }; export { CartResource as CartResource, type Cart as Cart, type CartClearResponse as CartClearResponse, type CartConvertResponse as CartConvertResponse, type CartGetResponse as CartGetResponse, type CartSetAddressResponse as CartSetAddressResponse, type CartSetCardResponse as CartSetCardResponse, type CartSetItemResponse as CartSetItemResponse, type CartSetAddressParams as CartSetAddressParams, type CartSetCardParams as CartSetCardParams, type CartSetItemParams as CartSetItemParams, }; export { OrderResource as OrderResource, type Order as Order, type OrderCreateResponse as OrderCreateResponse, type OrderListResponse as OrderListResponse, type OrderGetResponse as OrderGetResponse, type OrderCreateParams as OrderCreateParams, }; export { SubscriptionResource as SubscriptionResource, type Subscription as Subscription, type SubscriptionCreateResponse as SubscriptionCreateResponse, type SubscriptionUpdateResponse as SubscriptionUpdateResponse, type SubscriptionListResponse as SubscriptionListResponse, type SubscriptionDeleteResponse as SubscriptionDeleteResponse, type SubscriptionGetResponse as SubscriptionGetResponse, type SubscriptionCreateParams as SubscriptionCreateParams, type SubscriptionUpdateParams as SubscriptionUpdateParams, }; export { TokenResource as TokenResource, type Token as Token, type TokenCreateResponse as TokenCreateResponse, type TokenListResponse as TokenListResponse, type TokenDeleteResponse as TokenDeleteResponse, type TokenGetResponse as TokenGetResponse, }; export { AppResource as AppResource, type App as App, type AppCreateResponse as AppCreateResponse, type AppListResponse as AppListResponse, type AppDeleteResponse as AppDeleteResponse, type AppGetResponse as AppGetResponse, type AppCreateParams as AppCreateParams, }; export { Email as Email, type EmailCreateResponse as EmailCreateResponse, type EmailCreateParams as EmailCreateParams, }; export { View as View, type Region as Region, type ViewInitResponse as ViewInitResponse }; } export { toFile, fileFromPath } from "./uploads.js"; export { TerminalError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./error.js"; export default Terminal; //# sourceMappingURL=index.d.ts.map