/** * Resolving credentials, and the multi-account model. * * ThriveCart accounts multiply faster than most services. One person routinely * runs a personal cart, a business cart and a client's cart, because ThriveCart * licenses per account rather than per seat. Holding one API key in the * environment means restarting the server to look at a different cart, which is * exactly the moment somebody reads the wrong revenue figure and believes it. * * Two sources, in priority order: * 1. THRIVECART_ACCOUNTS a JSON array, for several carts at once * 2. THRIVECART_API_KEY the single-account variable * * Every tool takes an optional `account` argument matched against the name, and * the cart that answers when none is named is chosen deliberately (see * `selectAccount`) rather than being whichever one happened to be first. */ export type Account = { /** Short label used in the `account` argument, e.g. "navid-media". */ name: string; /** ThriveCart API key from Settings > API & Webhooks. */ apiKey: string; /** API base. Overridable only so a test can point somewhere else. */ baseUrl: string; }; export type Config = { accounts: Account[]; /** Account names preferred, in order, when a tool is called without `account`. */ preferred: string[]; readOnly: boolean; allowDestructive: boolean; requestTimeoutMs: number; minRequestIntervalMs: number; maxRetries: number; /** Hard ceiling on pages walked when a tool fetches everything. */ maxPages: number; userAgent: string; auditPath?: string; }; /** * ThriveCart's external API answers on thrivecart.com, NOT api.thrivecart.com. * The api. host resolves and then refuses everything, which reads like a bad * key rather than a bad host, so it costs an hour the first time. */ export declare const DEFAULT_BASE_URL = "https://thrivecart.com/api/external"; /** Lowercase and collapse spacing so "Navid Media" and "navid-media" both match. */ export declare function normalizeName(raw: string): string; /** * Read `THRIVECART_ACCOUNTS`, a JSON array. * * Both snake_case and camelCase keys are accepted, because the same JSON gets * pasted between a shell export and a client config file, and the two * conventions do not survive the trip intact. */ export declare function accountsFromJson(raw: string | undefined): Account[]; export declare function loadConfig(): Config; /** * Pick which cart a call reads or acts on. * * With no hint: the first configured `THRIVECART_DEFAULT_ACCOUNT` that is * actually present, else the first account. Exact name match beats prefix * match, because "navid" is a prefix of both "navid-media" and "navid-personal" * and a pure prefix search would quietly answer with the wrong cart's money. */ export declare function selectAccount(config: Config, hint?: string): Account;