UNPKG

@revmax/agent-sdk

Version:

Official Node.js SDK for RevMax - billing, customer management, and usage tracking

98 lines (97 loc) 2.34 kB
/** * Usage record for API requests (no id, createdAt - those come from response) */ export interface UsageRecord { customerExternalId: string; agentId: string; signalName: string; quantity: number; usageDate?: string | Date; metadata?: Record<string, any>; } /** * Usage record response from API (includes server-generated fields) */ export interface UsageRecordResponse { id: string; customerExternalId: string; organizationId: string; agentId: string; signalId?: string; signalName: string; usageDate: string; quantity: number; metadata?: Record<string, any>; createdAt: string; } /** * Parameters for recording usage (single record) */ export interface RecordUsageParams { customerExternalId: string; agentId: string; signalName: string; quantity: number; usageDate?: string | Date; metadata?: Record<string, any>; } /** * Parameters for batch recording usage */ export interface BatchRecordUsageParams { records: UsageRecord[]; } /** * Track event parameters - supports both single and batch */ export type TrackEventParams = RecordUsageParams | BatchRecordUsageParams; /** * Single event response from API */ export interface SingleEventResponse { success: boolean; signalEvent?: { id: string; customerId: string; subscriptionId: string; signalId: string; quantity: number; usageDate: string; metadata?: Record<string, any>; }; timeline?: Array<{ event_type: string; type: string; timestamp: string; message: string; [key: string]: any; }>; } /** * Result for a single record in batch operation */ export interface BatchRecordResult { success: boolean; error?: string; responseData?: SingleEventResponse; data?: UsageRecord; } /** * Batch event response from API */ export interface BatchEventResponse { success: boolean; totalRecords: number; results?: BatchRecordResult[]; } /** * Track event response - can be single or batch */ export type TrackEventResponse = SingleEventResponse | BatchEventResponse; /** * Response for recording usage (legacy - use SingleEventResponse) */ export interface RecordUsageResponse { success: boolean; usageRecord?: UsageRecordResponse; }