import type Stripe from "stripe" import { defineAction } from "../../../automation/actions" import { stripeAction, fromStripe, getStripeApi, stripeActionSchemas, stripeInputSchema, stripeObjectSchema, toStripeParams, type StripeInputValue, } from "../lib" /** Retrieves identity, business profile, capabilities, and settings. */ export const getCurrentStripeAccount = stripeAction< StripeInputValue, Stripe.Account >( defineAction("Get current Stripe account") .describe( "Retrieves the Stripe account represented by the connected API key.", ) .account("stripe") .input( stripeInputSchema( stripeActionSchemas.empty, ), ) .output(stripeObjectSchema()) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => fromStripe( await getStripeApi(account).accounts.retrieveCurrent( toStripeParams(input), ), ), ), ) /** Retrieves available, pending, and instant-available Stripe balances. */ export const getStripeBalance = stripeAction< StripeInputValue, Stripe.Balance >( defineAction("Get Stripe balance") .describe("Retrieves balances grouped by currency and availability state.") .account("stripe") .input( stripeInputSchema( stripeActionSchemas.empty, ), ) .output(stripeObjectSchema()) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => fromStripe( await getStripeApi(account).balance.retrieve(toStripeParams(input)), ), ), ) /** Lists transactions that changed the connected Stripe account balance. */ export const listStripeBalanceTransactions = stripeAction< StripeInputValue, Stripe.ApiList >( defineAction("List Stripe balance transactions") .describe( "Lists balance changes with Stripe cursor pagination and filters.", ) .account("stripe") .input( stripeInputSchema( stripeActionSchemas.list, ), ) .output(stripeObjectSchema>()) .retry({ replaySafety: "safe" }) .handler(async ({ account, input }) => fromStripe( await getStripeApi(account).balanceTransactions.list( toStripeParams(input), ), ), ), )