UNPKG

@visionfi/desktop-sdk

Version:

Desktop SDK for VisionFI Cloud Run services with Azure AD authentication

60 lines (59 loc) 1.75 kB
/** * Admin Client - handles administrative operations in Desktop SDK * Copyright (c) 2024-2025 VisionFI. All Rights Reserved. */ import { VisionFiError } from '@visionfi/core'; export class AdminClient { apiClient; constructor(apiClient) { this.apiClient = apiClient; } /** * Get available product types */ async getProductTypes() { 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() { 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() { 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 */ handleError(error, defaultMessage) { 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); } }