{"version":3,"sources":["../../src/sdk/index.ts","../../src/sdk/types.ts","../../src/sdk/errors.ts","../../src/sdk/client.ts","../../src/sdk/admin-client.ts"],"sourcesContent":["/**\r\n * Credits SDK - barrel exports\r\n *\r\n * Provides TypeScript SDK for consuming the credits REST API\r\n * from external services or other applications.\r\n */\r\n\r\n// Clients\r\nexport { CreditsClient } from \"./client.js\";\r\nexport { AdminCreditsClient } from \"./admin-client.js\";\r\n\r\n// Types\r\nexport type {\r\n  CreditsClientConfig,\r\n  AdminCreditsClientConfig,\r\n  UserCredits,\r\n  CreditReservation,\r\n  CreditCheckResult,\r\n  ReservationResult,\r\n  PaginationOptions,\r\n  UsageHistoryEntry,\r\n  UsageHistoryResponse,\r\n  ApiResponse,\r\n  SDKErrorCodeType,\r\n  SubscriptionTier,\r\n} from \"./types.js\";\r\n\r\nexport { SDKErrorCode } from \"./types.js\";\r\n\r\n// Errors\r\nexport {\r\n  CreditsSDKError,\r\n  NetworkError,\r\n  AuthenticationError,\r\n  AuthorizationError,\r\n  InsufficientCreditsError,\r\n  ReservationNotFoundError,\r\n  ReservationExpiredError,\r\n  ValidationError,\r\n  ServerError,\r\n  parseApiError,\r\n} from \"./errors.js\";\r\n\r\n// Admin client types\r\nexport type {\r\n  CreditsConfig,\r\n  ListUsersResponse,\r\n  ListUsersOptions,\r\n} from \"./admin-client.js\";\r\n","/**\r\n * SDK types for the credits system\r\n *\r\n * These types are used by the client SDKs for REST API consumption.\r\n */\r\n\r\n// Re-export core types for SDK consumers\r\nexport type {\r\n  PortableUserCredits as UserCredits,\r\n  PortableReservation as CreditReservation,\r\n  CreditCheckResult,\r\n  SubscriptionTier,\r\n} from \"../core/types.js\";\r\n\r\n/**\r\n * Configuration for CreditsClient\r\n */\r\nexport interface CreditsClientConfig {\r\n  /** Base URL of the credits API (e.g., \"https://api.example.com\") */\r\n  baseUrl: string;\r\n  /** Function to get the auth token for session-based auth */\r\n  getAuthToken?: () => Promise<string>;\r\n  /** Optional custom fetch function for testing */\r\n  fetch?: typeof fetch;\r\n}\r\n\r\n/**\r\n * Configuration for AdminCreditsClient\r\n */\r\nexport interface AdminCreditsClientConfig {\r\n  /** Base URL of the credits API */\r\n  baseUrl: string;\r\n  /** Admin API key */\r\n  apiKey: string;\r\n  /** Optional custom fetch function for testing */\r\n  fetch?: typeof fetch;\r\n}\r\n\r\n/**\r\n * Result of a credit reservation\r\n */\r\nexport interface ReservationResult {\r\n  /** The reservation ID */\r\n  reservationId: string;\r\n  /** Amount of credits reserved */\r\n  amount: number;\r\n  /** When the reservation expires (ISO 8601) */\r\n  expiresAt: string;\r\n}\r\n\r\n/**\r\n * Pagination options for API requests\r\n */\r\nexport interface PaginationOptions {\r\n  /** Page number (1-indexed) */\r\n  page?: number;\r\n  /** Number of items per page */\r\n  limit?: number;\r\n}\r\n\r\n/**\r\n * Usage history entry\r\n */\r\nexport interface UsageHistoryEntry {\r\n  /** Unique ID of the usage log */\r\n  id: string;\r\n  /** Type of operation */\r\n  operationType: string;\r\n  /** AI provider used */\r\n  provider: string;\r\n  /** Credits consumed */\r\n  creditsUsed: number;\r\n  /** Whether the operation was successful */\r\n  success: boolean;\r\n  /** Error message if unsuccessful */\r\n  errorMessage?: string;\r\n  /** ID of the related resource */\r\n  resourceId?: string;\r\n  /** Type of the related resource */\r\n  resourceType?: string;\r\n  /** When the operation occurred (ISO 8601) */\r\n  createdAt: string;\r\n}\r\n\r\n/**\r\n * Response from usage history endpoint\r\n */\r\nexport interface UsageHistoryResponse {\r\n  /** List of usage entries */\r\n  entries: UsageHistoryEntry[];\r\n  /** Whether there are more results */\r\n  hasMore: boolean;\r\n  /** Total count (if available) */\r\n  total?: number;\r\n}\r\n\r\n/**\r\n * Generic API response wrapper\r\n */\r\nexport interface ApiResponse<T> {\r\n  success: boolean;\r\n  data?: T;\r\n  error?: {\r\n    code: string;\r\n    message: string;\r\n    details?: unknown;\r\n  };\r\n}\r\n\r\n/**\r\n * SDK error codes\r\n */\r\nexport const SDKErrorCode = {\r\n  NETWORK_ERROR: \"NETWORK_ERROR\",\r\n  AUTHENTICATION_ERROR: \"AUTHENTICATION_ERROR\",\r\n  AUTHORIZATION_ERROR: \"AUTHORIZATION_ERROR\",\r\n  INSUFFICIENT_CREDITS: \"INSUFFICIENT_CREDITS\",\r\n  RESERVATION_NOT_FOUND: \"RESERVATION_NOT_FOUND\",\r\n  RESERVATION_EXPIRED: \"RESERVATION_EXPIRED\",\r\n  VALIDATION_ERROR: \"VALIDATION_ERROR\",\r\n  SERVER_ERROR: \"SERVER_ERROR\",\r\n  UNKNOWN_ERROR: \"UNKNOWN_ERROR\",\r\n} as const;\r\n\r\nexport type SDKErrorCodeType = (typeof SDKErrorCode)[keyof typeof SDKErrorCode];\r\n","/**\r\n * SDK error classes\r\n *\r\n * Provides typed error handling for SDK operations.\r\n */\r\n\r\nimport { SDKErrorCode, type SDKErrorCodeType } from \"./types.js\";\r\n\r\n/**\r\n * Base error class for SDK errors\r\n */\r\nexport class CreditsSDKError extends Error {\r\n  public readonly code: SDKErrorCodeType;\r\n  public readonly details?: Record<string, unknown>;\r\n  public readonly statusCode?: number;\r\n\r\n  constructor(\r\n    message: string,\r\n    code: SDKErrorCodeType,\r\n    options?: {\r\n      details?: Record<string, unknown>;\r\n      statusCode?: number;\r\n      cause?: Error;\r\n    }\r\n  ) {\r\n    super(message, { cause: options?.cause });\r\n    this.name = \"CreditsSDKError\";\r\n    this.code = code;\r\n    this.details = options?.details;\r\n    this.statusCode = options?.statusCode;\r\n  }\r\n\r\n  /**\r\n   * Check if this is a specific error type\r\n   */\r\n  is(code: SDKErrorCodeType): boolean {\r\n    return this.code === code;\r\n  }\r\n\r\n  /**\r\n   * Create a JSON representation for logging\r\n   */\r\n  toJSON(): Record<string, unknown> {\r\n    return {\r\n      name: this.name,\r\n      message: this.message,\r\n      code: this.code,\r\n      details: this.details,\r\n      statusCode: this.statusCode,\r\n    };\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when a network request fails\r\n */\r\nexport class NetworkError extends CreditsSDKError {\r\n  constructor(message: string, cause?: Error) {\r\n    super(message, SDKErrorCode.NETWORK_ERROR, { cause });\r\n    this.name = \"NetworkError\";\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when authentication fails\r\n */\r\nexport class AuthenticationError extends CreditsSDKError {\r\n  constructor(message: string = \"Authentication required\") {\r\n    super(message, SDKErrorCode.AUTHENTICATION_ERROR, { statusCode: 401 });\r\n    this.name = \"AuthenticationError\";\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when authorization fails\r\n */\r\nexport class AuthorizationError extends CreditsSDKError {\r\n  constructor(message: string = \"Access denied\") {\r\n    super(message, SDKErrorCode.AUTHORIZATION_ERROR, { statusCode: 403 });\r\n    this.name = \"AuthorizationError\";\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when credits are insufficient\r\n */\r\nexport class InsufficientCreditsError extends CreditsSDKError {\r\n  public readonly available: number;\r\n  public readonly required: number;\r\n\r\n  constructor(available: number, required: number) {\r\n    super(\r\n      `Insufficient credits: available ${available}, required ${required}`,\r\n      SDKErrorCode.INSUFFICIENT_CREDITS,\r\n      {\r\n        statusCode: 402,\r\n        details: { available, required },\r\n      }\r\n    );\r\n    this.name = \"InsufficientCreditsError\";\r\n    this.available = available;\r\n    this.required = required;\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when a reservation is not found\r\n */\r\nexport class ReservationNotFoundError extends CreditsSDKError {\r\n  public readonly reservationId: string;\r\n\r\n  constructor(reservationId: string) {\r\n    super(\r\n      `Reservation not found: ${reservationId}`,\r\n      SDKErrorCode.RESERVATION_NOT_FOUND,\r\n      {\r\n        statusCode: 404,\r\n        details: { reservationId },\r\n      }\r\n    );\r\n    this.name = \"ReservationNotFoundError\";\r\n    this.reservationId = reservationId;\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown when a reservation has expired\r\n */\r\nexport class ReservationExpiredError extends CreditsSDKError {\r\n  public readonly reservationId: string;\r\n\r\n  constructor(reservationId: string) {\r\n    super(\r\n      `Reservation expired: ${reservationId}`,\r\n      SDKErrorCode.RESERVATION_EXPIRED,\r\n      {\r\n        statusCode: 410,\r\n        details: { reservationId },\r\n      }\r\n    );\r\n    this.name = \"ReservationExpiredError\";\r\n    this.reservationId = reservationId;\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown for validation failures\r\n */\r\nexport class ValidationError extends CreditsSDKError {\r\n  public readonly field?: string;\r\n\r\n  constructor(message: string, field?: string) {\r\n    super(message, SDKErrorCode.VALIDATION_ERROR, {\r\n      statusCode: 400,\r\n      details: field ? { field } : undefined,\r\n    });\r\n    this.name = \"ValidationError\";\r\n    this.field = field;\r\n  }\r\n}\r\n\r\n/**\r\n * Error thrown for server errors\r\n */\r\nexport class ServerError extends CreditsSDKError {\r\n  constructor(message: string = \"Internal server error\") {\r\n    super(message, SDKErrorCode.SERVER_ERROR, { statusCode: 500 });\r\n    this.name = \"ServerError\";\r\n  }\r\n}\r\n\r\n/**\r\n * Parse an API error response into the appropriate SDK error\r\n */\r\nexport function parseApiError(\r\n  statusCode: number,\r\n  body: { error?: { code?: string; message?: string; details?: unknown } }\r\n): CreditsSDKError {\r\n  const errorCode = body.error?.code || \"\";\r\n  const errorMessage = body.error?.message || \"An error occurred\";\r\n  const details = body.error?.details as Record<string, unknown> | undefined;\r\n\r\n  switch (statusCode) {\r\n    case 401:\r\n      return new AuthenticationError(errorMessage);\r\n    case 403:\r\n      return new AuthorizationError(errorMessage);\r\n    case 402:\r\n      // Parse insufficient credits details\r\n      if (details?.available !== undefined && details?.required !== undefined) {\r\n        return new InsufficientCreditsError(\r\n          details.available as number,\r\n          details.required as number\r\n        );\r\n      }\r\n      return new CreditsSDKError(errorMessage, SDKErrorCode.INSUFFICIENT_CREDITS, {\r\n        statusCode,\r\n        details,\r\n      });\r\n    case 404:\r\n      if (errorCode === \"RESERVATION_NOT_FOUND\" && details?.reservationId) {\r\n        return new ReservationNotFoundError(details.reservationId as string);\r\n      }\r\n      return new CreditsSDKError(errorMessage, SDKErrorCode.RESERVATION_NOT_FOUND, {\r\n        statusCode,\r\n        details,\r\n      });\r\n    case 410:\r\n      if (errorCode === \"RESERVATION_EXPIRED\" && details?.reservationId) {\r\n        return new ReservationExpiredError(details.reservationId as string);\r\n      }\r\n      return new CreditsSDKError(errorMessage, SDKErrorCode.RESERVATION_EXPIRED, {\r\n        statusCode,\r\n        details,\r\n      });\r\n    case 400:\r\n    case 422:\r\n      return new ValidationError(errorMessage, details?.field as string | undefined);\r\n    case 500:\r\n    default:\r\n      if (statusCode >= 500) {\r\n        return new ServerError(errorMessage);\r\n      }\r\n      return new CreditsSDKError(errorMessage, SDKErrorCode.UNKNOWN_ERROR, {\r\n        statusCode,\r\n        details,\r\n      });\r\n  }\r\n}\r\n","/**\r\n * CreditsClient - REST API client for the credits system\r\n *\r\n * Provides a type-safe interface for consuming credits API endpoints\r\n * from external services or other applications.\r\n *\r\n * @example\r\n * ```typescript\r\n * const client = new CreditsClient({\r\n *   baseUrl: process.env.CREDITS_API_URL,\r\n *   getAuthToken: async () => session.accessToken,\r\n * });\r\n *\r\n * // Check if user has sufficient credits\r\n * const check = await client.checkAvailability(\"story_generation\");\r\n * if (!check.hasCredits) {\r\n *   console.log(\"Insufficient credits\");\r\n *   return;\r\n * }\r\n *\r\n * // Two-phase commit pattern\r\n * const reservation = await client.reserve(\"story_generation\");\r\n * try {\r\n *   const result = await doExpensiveWork();\r\n *   await client.commit(reservation.reservationId);\r\n *   return result;\r\n * } catch (error) {\r\n *   await client.release(reservation.reservationId);\r\n *   throw error;\r\n * }\r\n * ```\r\n */\r\n\r\nimport type {\r\n  CreditsClientConfig,\r\n  UserCredits,\r\n  CreditCheckResult,\r\n  ReservationResult,\r\n  UsageHistoryResponse,\r\n  PaginationOptions,\r\n} from \"./types.js\";\r\nimport { parseApiError, NetworkError } from \"./errors.js\";\r\n\r\nexport class CreditsClient {\r\n  private readonly baseUrl: string;\r\n  private readonly getAuthToken?: () => Promise<string>;\r\n  private readonly fetchFn: typeof fetch;\r\n\r\n  constructor(config: CreditsClientConfig) {\r\n    // Ensure baseUrl doesn't have trailing slash\r\n    this.baseUrl = config.baseUrl.replace(/\\/$/, \"\");\r\n    this.getAuthToken = config.getAuthToken;\r\n    this.fetchFn = config.fetch ?? fetch;\r\n  }\r\n\r\n  /**\r\n   * Make an authenticated request to the API\r\n   */\r\n  private async request<T>(\r\n    path: string,\r\n    options: {\r\n      method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\r\n      body?: unknown;\r\n      params?: Record<string, string | number | undefined>;\r\n    } = {}\r\n  ): Promise<T> {\r\n    const { method = \"GET\", body, params } = options;\r\n\r\n    // Build URL with query params\r\n    let url = `${this.baseUrl}${path}`;\r\n    if (params) {\r\n      const searchParams = new URLSearchParams();\r\n      for (const [key, value] of Object.entries(params)) {\r\n        if (value !== undefined) {\r\n          searchParams.set(key, String(value));\r\n        }\r\n      }\r\n      const queryString = searchParams.toString();\r\n      if (queryString) {\r\n        url += `?${queryString}`;\r\n      }\r\n    }\r\n\r\n    // Build headers\r\n    const headers: Record<string, string> = {\r\n      \"Content-Type\": \"application/json\",\r\n    };\r\n\r\n    // Add auth token if available\r\n    if (this.getAuthToken) {\r\n      try {\r\n        const token = await this.getAuthToken();\r\n        if (token) {\r\n          headers[\"Authorization\"] = `Bearer ${token}`;\r\n        }\r\n      } catch {\r\n        // Auth token not available, proceed without it\r\n      }\r\n    }\r\n\r\n    // Make the request\r\n    let response: Response;\r\n    try {\r\n      response = await this.fetchFn(url, {\r\n        method,\r\n        headers,\r\n        body: body ? JSON.stringify(body) : undefined,\r\n      });\r\n    } catch (error) {\r\n      throw new NetworkError(\r\n        error instanceof Error ? error.message : \"Network request failed\",\r\n        error instanceof Error ? error : undefined\r\n      );\r\n    }\r\n\r\n    // Parse response\r\n    const responseBody = (await response.json()) as {\r\n      data?: T;\r\n      error?: { code?: string; message?: string; details?: unknown };\r\n    };\r\n\r\n    // Handle errors\r\n    if (!response.ok) {\r\n      throw parseApiError(response.status, responseBody);\r\n    }\r\n\r\n    // Return data\r\n    return responseBody.data as T;\r\n  }\r\n\r\n  /**\r\n   * Get the current user's credit balance\r\n   *\r\n   * @returns User's credit information\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async getBalance(): Promise<UserCredits> {\r\n    return this.request<UserCredits>(\"/api/v1/credits/balance\");\r\n  }\r\n\r\n  /**\r\n   * Check if the user has sufficient credits for an operation\r\n   *\r\n   * @param operationType - Type of operation to check\r\n   * @param customCost - Optional custom cost to check against\r\n   * @returns Credit availability status\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async checkAvailability(\r\n    operationType: string,\r\n    customCost?: number\r\n  ): Promise<CreditCheckResult> {\r\n    return this.request<CreditCheckResult>(\"/api/v1/credits/availability\", {\r\n      params: {\r\n        operationType,\r\n        customCost: customCost?.toString(),\r\n      },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Reserve credits for an operation\r\n   *\r\n   * This is the first step in the two-phase commit pattern.\r\n   * Reserved credits are held for 5 minutes before expiring.\r\n   *\r\n   * @param operationType - Type of operation\r\n   * @param options - Optional reservation options\r\n   * @returns Reservation details including ID and expiry\r\n   * @throws InsufficientCreditsError if not enough credits\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async reserve(\r\n    operationType: string,\r\n    options?: {\r\n      customCost?: number;\r\n      resourceId?: string;\r\n      resourceType?: string;\r\n    }\r\n  ): Promise<ReservationResult> {\r\n    return this.request<ReservationResult>(\"/api/v1/credits/reserve\", {\r\n      method: \"POST\",\r\n      body: {\r\n        operationType,\r\n        ...options,\r\n      },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Commit a reservation (deduct credits)\r\n   *\r\n   * This is the second step in the two-phase commit pattern.\r\n   * Call this after your operation succeeds.\r\n   *\r\n   * @param reservationId - ID of the reservation to commit\r\n   * @throws ReservationNotFoundError if reservation doesn't exist\r\n   * @throws ReservationExpiredError if reservation has expired\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async commit(reservationId: string): Promise<void> {\r\n    await this.request<{ message: string }>(\"/api/v1/credits/commit\", {\r\n      method: \"POST\",\r\n      body: { reservationId },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Release a reservation (refund credits)\r\n   *\r\n   * Call this if your operation fails after reserving credits.\r\n   *\r\n   * @param reservationId - ID of the reservation to release\r\n   * @throws ReservationNotFoundError if reservation doesn't exist\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async release(reservationId: string): Promise<void> {\r\n    await this.request<{ message: string }>(\"/api/v1/credits/release\", {\r\n      method: \"POST\",\r\n      body: { reservationId },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Get usage history for the current user\r\n   *\r\n   * @param options - Optional pagination options\r\n   * @returns Paginated list of usage entries\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async getHistory(options?: PaginationOptions): Promise<UsageHistoryResponse> {\r\n    return this.request<UsageHistoryResponse>(\"/api/v1/credits/history\", {\r\n      params: {\r\n        page: options?.page,\r\n        limit: options?.limit,\r\n      },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Get the available credits (balance + bonus - reserved)\r\n   *\r\n   * Convenience method that calculates available credits from balance.\r\n   *\r\n   * @returns Number of available credits\r\n   * @throws AuthenticationError if not authenticated\r\n   */\r\n  async getAvailableCredits(): Promise<number> {\r\n    const balance = await this.getBalance();\r\n    return balance.balance + balance.bonusCredits - balance.reserved;\r\n  }\r\n\r\n  /**\r\n   * Execute an operation with automatic credit handling\r\n   *\r\n   * This is a convenience method that handles the full two-phase commit\r\n   * pattern automatically.\r\n   *\r\n   * @param operationType - Type of operation\r\n   * @param operation - The operation to execute\r\n   * @param options - Optional reservation options\r\n   * @returns Result of the operation\r\n   * @throws InsufficientCreditsError if not enough credits\r\n   * @throws AuthenticationError if not authenticated\r\n   *\r\n   * @example\r\n   * ```typescript\r\n   * const result = await client.withCredits(\r\n   *   \"story_generation\",\r\n   *   async () => {\r\n   *     return generateStory(data);\r\n   *   }\r\n   * );\r\n   * ```\r\n   */\r\n  async withCredits<T>(\r\n    operationType: string,\r\n    operation: () => Promise<T>,\r\n    options?: {\r\n      customCost?: number;\r\n      resourceId?: string;\r\n      resourceType?: string;\r\n    }\r\n  ): Promise<T> {\r\n    const reservation = await this.reserve(operationType, options);\r\n\r\n    try {\r\n      const result = await operation();\r\n      await this.commit(reservation.reservationId);\r\n      return result;\r\n    } catch (error) {\r\n      // Always attempt to release on failure\r\n      try {\r\n        await this.release(reservation.reservationId);\r\n      } catch {\r\n        // Ignore release errors, original error is more important\r\n      }\r\n      throw error;\r\n    }\r\n  }\r\n}\r\n","/**\r\n * AdminCreditsClient - Admin REST API client for the credits system\r\n *\r\n * Provides administrative access to the credits system for managing\r\n * user credits, configurations, and subscriptions.\r\n *\r\n * @example\r\n * ```typescript\r\n * const adminClient = new AdminCreditsClient({\r\n *   baseUrl: process.env.CREDITS_API_URL,\r\n *   apiKey: process.env.CREDITS_ADMIN_API_KEY,\r\n * });\r\n *\r\n * // Add credits to a user\r\n * await adminClient.addCredits(\"user-123\", 100, \"Support credit grant\");\r\n *\r\n * // Update subscription tier\r\n * await adminClient.updateSubscription(\"user-123\", \"premium\", \"2027-01-01T00:00:00Z\");\r\n *\r\n * // Update operation costs\r\n * await adminClient.updateCosts({\r\n *   story_generation: 8,\r\n *   image_generation: 12,\r\n * });\r\n * ```\r\n */\r\n\r\nimport type { AdminCreditsClientConfig, UserCredits } from \"./types.js\";\r\nimport { parseApiError, NetworkError } from \"./errors.js\";\r\n\r\n/**\r\n * Credits configuration returned by the API\r\n */\r\nexport interface CreditsConfig {\r\n  operationCosts: Record<string, number>;\r\n  tierConfigs: Record<\r\n    string,\r\n    {\r\n      monthlyLimit: number;\r\n      features: string[];\r\n    }\r\n  >;\r\n}\r\n\r\n/**\r\n * Response from listing users\r\n */\r\nexport interface ListUsersResponse {\r\n  users: Array<{\r\n    userId: string;\r\n    balance: number;\r\n    bonusCredits?: number;\r\n    tier: string;\r\n    monthlyUsed?: number;\r\n  }>;\r\n  hasMore: boolean;\r\n  total?: number;\r\n}\r\n\r\n/**\r\n * Options for listing users\r\n */\r\nexport interface ListUsersOptions {\r\n  page?: number;\r\n  limit?: number;\r\n  tier?: string;\r\n  search?: string;\r\n}\r\n\r\nexport class AdminCreditsClient {\r\n  private readonly baseUrl: string;\r\n  private readonly apiKey: string;\r\n  private readonly fetchFn: typeof fetch;\r\n\r\n  constructor(config: AdminCreditsClientConfig) {\r\n    // Ensure baseUrl doesn't have trailing slash\r\n    this.baseUrl = config.baseUrl.replace(/\\/$/, \"\");\r\n    this.apiKey = config.apiKey;\r\n    this.fetchFn = config.fetch ?? fetch;\r\n  }\r\n\r\n  /**\r\n   * Make an authenticated admin request to the API\r\n   */\r\n  private async request<T>(\r\n    path: string,\r\n    options: {\r\n      method?: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\r\n      body?: unknown;\r\n      params?: Record<string, string | number | undefined>;\r\n    } = {}\r\n  ): Promise<T> {\r\n    const { method = \"GET\", body, params } = options;\r\n\r\n    // Build URL with query params\r\n    let url = `${this.baseUrl}${path}`;\r\n    if (params) {\r\n      const searchParams = new URLSearchParams();\r\n      for (const [key, value] of Object.entries(params)) {\r\n        if (value !== undefined) {\r\n          searchParams.set(key, String(value));\r\n        }\r\n      }\r\n      const queryString = searchParams.toString();\r\n      if (queryString) {\r\n        url += `?${queryString}`;\r\n      }\r\n    }\r\n\r\n    // Build headers with admin API key\r\n    const headers: Record<string, string> = {\r\n      \"Content-Type\": \"application/json\",\r\n      \"x-api-key\": this.apiKey,\r\n    };\r\n\r\n    // Make the request\r\n    let response: Response;\r\n    try {\r\n      response = await this.fetchFn(url, {\r\n        method,\r\n        headers,\r\n        body: body ? JSON.stringify(body) : undefined,\r\n      });\r\n    } catch (error) {\r\n      throw new NetworkError(\r\n        error instanceof Error ? error.message : \"Network request failed\",\r\n        error instanceof Error ? error : undefined\r\n      );\r\n    }\r\n\r\n    // Parse response\r\n    const responseBody = (await response.json()) as {\r\n      data?: T;\r\n      error?: { code?: string; message?: string; details?: unknown };\r\n    };\r\n\r\n    // Handle errors\r\n    if (!response.ok) {\r\n      throw parseApiError(response.status, responseBody);\r\n    }\r\n\r\n    // Return data\r\n    return responseBody.data as T;\r\n  }\r\n\r\n  /**\r\n   * Get a specific user's credits\r\n   *\r\n   * @param userId - ID of the user\r\n   * @returns User's credit information\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async getUserCredits(userId: string): Promise<UserCredits> {\r\n    return this.request<UserCredits>(`/api/admin/credits/users/${userId}`);\r\n  }\r\n\r\n  /**\r\n   * Add credits to a user's account\r\n   *\r\n   * Credits are added to bonusCredits, which don't expire on monthly reset.\r\n   *\r\n   * @param userId - ID of the user\r\n   * @param amount - Amount of credits to add\r\n   * @param description - Reason for adding credits\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async addCredits(\r\n    userId: string,\r\n    amount: number,\r\n    description: string\r\n  ): Promise<void> {\r\n    await this.request<{ message: string; newBalance: number }>(\r\n      `/api/admin/credits/users/${userId}/add`,\r\n      {\r\n        method: \"POST\",\r\n        body: { amount, description },\r\n      }\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Update a user's subscription tier\r\n   *\r\n   * @param userId - ID of the user\r\n   * @param tier - New subscription tier\r\n   * @param expiresAt - Optional expiration date (ISO 8601)\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async updateSubscription(\r\n    userId: string,\r\n    tier: string,\r\n    expiresAt?: string\r\n  ): Promise<void> {\r\n    const body: { tier: string; expiresAt?: string } = { tier };\r\n    if (expiresAt) {\r\n      body.expiresAt = expiresAt;\r\n    }\r\n\r\n    await this.request<{ message: string }>(\r\n      `/api/admin/credits/users/${userId}/subscription`,\r\n      {\r\n        method: \"PUT\",\r\n        body,\r\n      }\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Get the current credits configuration\r\n   *\r\n   * @returns Credits system configuration\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async getConfig(): Promise<CreditsConfig> {\r\n    return this.request<CreditsConfig>(\"/api/admin/credits/config\");\r\n  }\r\n\r\n  /**\r\n   * Update operation costs\r\n   *\r\n   * @param costs - New operation costs (operation type -> cost)\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async updateCosts(costs: Record<string, number>): Promise<void> {\r\n    await this.request<{ message: string }>(\"/api/admin/credits/config/costs\", {\r\n      method: \"PUT\",\r\n      body: { operationCosts: costs },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * List all users with their credits\r\n   *\r\n   * @param options - Pagination and filtering options\r\n   * @returns Paginated list of users\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async listUsers(options?: ListUsersOptions): Promise<ListUsersResponse> {\r\n    return this.request<ListUsersResponse>(\"/api/admin/credits/users\", {\r\n      params: {\r\n        page: options?.page,\r\n        limit: options?.limit,\r\n        tier: options?.tier,\r\n        search: options?.search,\r\n      },\r\n    });\r\n  }\r\n\r\n  /**\r\n   * Deduct credits from a user's account\r\n   *\r\n   * @param userId - ID of the user\r\n   * @param amount - Amount of credits to deduct\r\n   * @param description - Reason for deducting credits\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async deductCredits(\r\n    userId: string,\r\n    amount: number,\r\n    description: string\r\n  ): Promise<void> {\r\n    await this.request<{ message: string; newBalance: number }>(\r\n      `/api/admin/credits/users/${userId}/deduct`,\r\n      {\r\n        method: \"POST\",\r\n        body: { amount, description },\r\n      }\r\n    );\r\n  }\r\n\r\n  /**\r\n   * Get usage statistics for a user\r\n   *\r\n   * @param userId - ID of the user\r\n   * @param options - Optional date range\r\n   * @returns Usage statistics\r\n   * @throws AuthorizationError if API key is invalid\r\n   */\r\n  async getUserStats(\r\n    userId: string,\r\n    options?: { startDate?: string; endDate?: string }\r\n  ): Promise<{\r\n    totalCreditsUsed: number;\r\n    operationBreakdown: Record<string, number>;\r\n    successRate: number;\r\n  }> {\r\n    return this.request<{\r\n      totalCreditsUsed: number;\r\n      operationBreakdown: Record<string, number>;\r\n      successRate: number;\r\n    }>(`/api/admin/credits/users/${userId}/stats`, {\r\n      params: {\r\n        startDate: options?.startDate,\r\n        endDate: options?.endDate,\r\n      },\r\n    });\r\n  }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgHO,IAAM,eAAe;AAAA,EAC1B,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,EACrB,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,qBAAqB;AAAA,EACrB,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd,eAAe;AACjB;;;AC/GO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EAEhB,YACE,SACA,MACA,SAKA;AACA,UAAM,SAAS,EAAE,OAAO,SAAS,MAAM,CAAC;AACxC,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,UAAU,SAAS;AACxB,SAAK,aAAa,SAAS;AAAA,EAC7B;AAAA;AAAA;AAAA;AAAA,EAKA,GAAG,MAAiC;AAClC,WAAO,KAAK,SAAS;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,SAAkC;AAChC,WAAO;AAAA,MACL,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,MACd,YAAY,KAAK;AAAA,IACnB;AAAA,EACF;AACF;AAKO,IAAM,eAAN,cAA2B,gBAAgB;AAAA,EAChD,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,aAAa,eAAe,EAAE,MAAM,CAAC;AACpD,SAAK,OAAO;AAAA,EACd;AACF;AAKO,IAAM,sBAAN,cAAkC,gBAAgB;AAAA,EACvD,YAAY,UAAkB,2BAA2B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