Fleeexdocs

Types

The exported TypeScript types — options, responses, and helpers.

All types are exported from the package root:

import type {
  FleeexClientOptions,
  BalanceResponse,
  ConnectionStatus,
  GetConnectionOptions,
  UsageSummary,
  FetchLike,
} from "@fleeex/sdk";

FleeexClientOptions

Constructor options — see the annotated options table.

interface FleeexClientOptions {
  apiKey: string;
  userId: string;
  baseURL?: string;
  onPaymentRequired?: (error: PaymentRequiredError) => void | Promise<void>;
  fetch?: FetchLike;
  maxRetries?: number;
  defaultHeaders?: Record<string, string>;
}

BalanceResponse

Returned by getBalance().

interface BalanceResponse {
  balanceMicros: number; // EUR micro-units: 1_000_000 = €1.00
  currency: "EUR";
}

ConnectionStatus

Returned by getConnection().

interface ConnectionStatus {
  connected: boolean; // an (app, user) → wallet mapping exists
  funded: boolean; // the resolved wallet holds a positive balance
  connectUrl: string; // signed onboarding link to open
}

GetConnectionOptions

Argument to getConnection().

interface GetConnectionOptions {
  // Absolute http(s) URL to return the user to once connected/funded. Must exactly
  // match one of the app's registered redirect URIs, or the call fails 400.
  redirectUri?: string;
}

UsageSummary

Returned by getUsageSummary(). The period is a half-open interval [periodStart, periodEnd) in UTC.

interface UsageSummary {
  spentMicros: number; // EUR micro-units this period
  totalTokens: number;
  requestCount: number;
  currency: "EUR";
  periodStart: string; // ISO 8601, inclusive
  periodEnd: string; // ISO 8601, exclusive
}

FetchLike

The shape accepted by the fetch option.

type FetchLike = typeof fetch;