UNPKG

@visionfi/desktop-sdk

Version:

Desktop SDK for VisionFI Cloud Run services with Azure AD authentication

70 lines (61 loc) 1.79 kB
/** * Admin Client - handles administrative operations in Desktop SDK * Copyright (c) 2024-2025 VisionFI. All Rights Reserved. */ import { AxiosInstance } from 'axios'; import { ProductTypesResponse, ClientInfoResponse, VisionFiError } from '@visionfi/core'; export class AdminClient { private apiClient: AxiosInstance; constructor(apiClient: AxiosInstance) { this.apiClient = apiClient; } /** * Get available product types */ async getProductTypes(): Promise<ProductTypesResponse> { try { const response = await this.apiClient.get('/admin/products/types'); return response.data; } catch (error) { throw this.handleError(error, 'Failed to get product types'); } } /** * Get available workflows (legacy - kept for compatibility) */ async getWorkflows(): Promise<any> { try { const response = await this.apiClient.get('/admin/workflows'); return response.data; } catch (error) { throw this.handleError(error, 'Failed to get workflows'); } } /** * Get client information */ async getClientInfo(): Promise<ClientInfoResponse> { try { const response = await this.apiClient.get('/admin/client-info'); return response.data; } catch (error) { throw this.handleError(error, 'Failed to get client info'); } } /** * Handle errors consistently */ private handleError(error: any, defaultMessage: string): Error { if (error instanceof VisionFiError) { return error; } const message = error.response?.data?.message || error.message || defaultMessage; const statusCode = error.response?.status; const code = error.response?.data?.code || 'unknown_error'; return new VisionFiError(message, statusCode, code); } }