Skip to content

Types API Reference ​

Complete TypeScript type definitions for Flowfull Clients.

Core Types ​

User ​

typescript
interface User {
  id: string;
  email: string;
  name?: string;
  userType?: string;
  [key: string]: any;
}

PubflowInstanceConfig ​

typescript
interface PubflowInstanceConfig {
  id?: string;
  baseUrl: string;
  bridgeBasePath?: string; // Default: '/bridge'
  authBasePath?: string; // Default: '/auth'
  sessionConfig?: SessionConfig;
  storageConfig?: StorageConfig;
  useSecureStorage?: boolean; // React Native only
}

SessionConfig ​

typescript
interface SessionConfig {
  validateOnStartup?: boolean;
  refreshInterval?: number;
  expirationWarning?: number;
}

StorageConfig ​

typescript
interface StorageConfig {
  prefix?: string;
  secure?: boolean;
}

Query Types ​

QueryParams ​

typescript
interface QueryParams {
  page?: number;
  limit?: number;
  orderBy?: string;
  orderDir?: 'asc' | 'desc';
  [key: string]: any;
}

SearchParams ​

typescript
interface SearchParams extends QueryParams {
  q: string;
  entity?: string;
  filters?: Record<string, FilterCondition>;
}

interface FilterCondition {
  operator: FilterOperator;
  value: any;
}

type FilterOperator = 
  | 'eq' | 'ne' 
  | 'gt' | 'gte' | 'lt' | 'lte'
  | 'like' | 'ilike'
  | 'in' | 'nin'
  | 'null' | 'nnull';

PaginatedResponse ​

typescript
interface PaginatedResponse<T> {
  data: T[];
  meta: PaginationMeta;
}

interface PaginationMeta {
  page: number;
  limit: number;
  total: number;
  hasMore: boolean;
}

Mutation Types ​

MutationResult ​

typescript
interface MutationResult<T, M extends MutationType> {
  success: boolean;
  data?: M extends 'delete' ? void : T;
  error?: string;
}

type MutationType = 'create' | 'update' | 'delete';

MutationOptions ​

typescript
interface MutationOptions {
  onSuccess?: (data: any) => void;
  onError?: (error: Error) => void;
  invalidateCache?: boolean;
}

Entity Types ​

EntityData ​

typescript
interface EntityData {
  id: string;
  [key: string]: any;
}

EntityConfig ​

typescript
interface EntityConfig {
  endpoint: string;
  customEndpoints?: Record<string, string>;
}

Authentication Types ​

LoginCredentials ​

typescript
interface LoginCredentials {
  email?: string;
  userName?: string;
  password: string;
}

RegisterData ​

typescript
interface RegisterData {
  email: string;
  password: string;
  name?: string;
  [key: string]: any;
}

SessionValidationResult ​

typescript
interface SessionValidationResult {
  isValid: boolean;
  expiresAt?: string;
  user?: User;
}

Storage Types ​

StorageAdapter ​

typescript
interface StorageAdapter {
  getItem(key: string): Promise<string | null>;
  setItem(key: string, value: string): Promise<void>;
  removeItem(key: string): Promise<void>;
  clear(): Promise<void>;
}

Hook Result Types ​

UseAuthResult ​

typescript
interface UseAuthResult {
  user: User | null;
  isAuthenticated: boolean;
  isLoading: boolean;
  login: (credentials: LoginCredentials) => Promise<any>;
  logout: () => Promise<void>;
  validateSession: () => Promise<SessionValidationResult>;
  refreshUser?: () => Promise<User | null>; // React Native only
}

UseBridgeQueryResult ​

typescript
interface UseBridgeQueryResult<T, Q extends QueryType> {
  data: Q extends 'list' | 'search' ? T[] : T | null;
  meta: Q extends 'list' | 'search' ? PaginationMeta : null;
  isLoading: boolean;
  error: Error | null;
  refetch: () => Promise<void>;
}

UseBridgeMutationResult ​

typescript
interface UseBridgeMutationResult<T, M extends MutationType> {
  mutate: (params: MutationParams<T, M>, options?: MutationOptions) => Promise<MutationResult<T, M>>;
  isLoading: boolean;
  error: Error | null;
  reset: () => void;
}

Next Steps ​