import * as ynab from "ynab"; import type { CategoryBudgetAssignment, CreateScheduledTransactionInput, CreateTransactionInput, NameLookup, ScheduledTransactionSnapshot, TransactionSearchQuery, TransactionSnapshot, UpdateScheduledTransactionInput, UpdateTransactionInput } from "./types.js"; interface GetAccountsOptions { type?: string; onBudget?: boolean; includeClosed?: boolean; } interface GetCategoriesOptions { month?: string; groupId?: string; includeHidden?: boolean; } interface GetScheduledTransactionsOptions { accountId?: string; categoryId?: string; dueAfter?: string; dueBefore?: string; } export declare class YnabClient { private readonly api; private readonly cache; private resolvedLastUsedId; readonly readOnly: boolean; private readonly timeoutMs; private readonly maxRetries; constructor(accessToken: string, endpointUrl?: string, options?: { readOnly?: boolean; timeoutMs?: number; maxRetries?: number; }); /** * Wraps the ynab API so that every SDK method call on known sub-APIs * automatically passes through the rate limiter, applies a timeout, * and retries transient failures for read-only (get/list) methods. */ private withRateLimitAndResilience; private assertWriteAllowed; resolveBudgetId(budgetId?: string): string; resolveRealBudgetId(budgetId?: string): Promise; listBudgets(): Promise; getBudgetSettings(budgetId?: string): Promise; getBudgetSummary(budgetId?: string): Promise<{ budget_id: string; month: string; net_worth_milliunits: number; net_worth: import("./format.js").CurrencyUnits; income_milliunits: number; income: import("./format.js").CurrencyUnits; budgeted_milliunits: number; budgeted: import("./format.js").CurrencyUnits; activity_milliunits: number; activity: import("./format.js").CurrencyUnits; to_be_budgeted_milliunits: number; to_be_budgeted: import("./format.js").CurrencyUnits; age_of_money: number | null; overspent_category_count: number; account_summary_by_type: { type: string; count: number; total_balance_milliunits: number; total_balance: import("./format.js").CurrencyUnits; }[]; }>; getAccounts(budgetId?: string, options?: GetAccountsOptions): Promise; getCategories(budgetId?: string, options?: GetCategoriesOptions): Promise>; getMonthSummary(budgetId?: string, month?: string): Promise; getScheduledTransactions(budgetId?: string, options?: GetScheduledTransactionsOptions): Promise; getPayees(budgetId?: string): Promise; getNameLookup(budgetId?: string): Promise; searchTransactions(budgetId: string | undefined, query: TransactionSearchQuery): Promise; getTransactionById(budgetId: string | undefined, transactionId: string): Promise; createTransactions(budgetId: string | undefined, transactions: CreateTransactionInput[]): Promise; updateTransactions(budgetId: string | undefined, transactions: UpdateTransactionInput[]): Promise; replaceTransaction(budgetId: string | undefined, transactionId: string, replacement: CreateTransactionInput): Promise<{ transaction: ynab.TransactionDetail; previousId: string; }>; deleteTransaction(budgetId: string | undefined, transactionId: string, options?: { skipPhantomFlush?: boolean; }): Promise; /** * Work around a YNAB API bug: deleting a split transaction does not remove * its subtransactions' budget activity. Creating (then deleting) a small * non-split transaction in each affected category forces a recalculation. * * When {@link replacementTransaction} is provided, categories already present * in the replacement are skipped since the create already flushed them. */ private flushSplitPhantoms; getScheduledTransactionById(budgetId: string | undefined, scheduledTransactionId: string): Promise; createScheduledTransaction(budgetId: string | undefined, transaction: CreateScheduledTransactionInput): Promise; updateScheduledTransaction(budgetId: string | undefined, transaction: UpdateScheduledTransactionInput, prefetchedExisting?: ynab.ScheduledTransactionDetail): Promise; deleteScheduledTransaction(budgetId: string | undefined, scheduledTransactionId: string): Promise; setCategoryBudget(budgetId: string | undefined, assignment: CategoryBudgetAssignment): Promise; updateCategory(budgetId: string, categoryId: string, updates: { goal_target?: number | null; goal_target_date?: string | null; }): Promise; getCategoryById(budgetId: string, categoryId: string): Promise; getMonthCategoryById(budgetId: string | undefined, month: string, categoryId: string): Promise; snapshotTransaction(transaction: ynab.TransactionDetail): TransactionSnapshot; snapshotScheduledTransaction(transaction: ynab.ScheduledTransactionDetail): ScheduledTransactionSnapshot; getTransactionsInRange(budgetId: string | undefined, sinceDate: string, untilDate?: string): Promise; /** * Force a delta refresh on all collections for a budget. * Called by the `sync_budget_data` tool. */ syncBudgetData(budgetId?: string): Promise<{ accounts: { added: number; updated: number; deleted: number; }; categories: { added: number; updated: number; deleted: number; }; payees: { added: number; updated: number; deleted: number; }; scheduled_transactions: { added: number; updated: number; deleted: number; }; transactions: { added: number; updated: number; deleted: number; }; }>; private refreshAccounts; private refreshCategories; private refreshPayees; private refreshScheduledTransactions; /** * Ensure the transaction cache covers at least `sinceDate`. * - If uncovered or requesting older data: full fetch (resets SK). * - If covered but stale/TTL-expired: delta refresh. * - If covered and fresh: no-op. */ private ensureTransactionsCovered; /** Full fetch (no SK). Replaces the transaction cache entirely. */ private fullFetchTransactions; /** Delta refresh using stored SK + coveredSinceDate. */ private refreshTransactions; } export {};