UNPKG

@visionfi/server-cli

Version:

Command-line interface for VisionFI Server SDK

92 lines (91 loc) 3.3 kB
/** * Admin commands for VisionFI CLI * Copyright (c) 2024-2025 VisionFI. All Rights Reserved. */ import { createClient } from '../utils/config.js'; import { Display } from '../utils/display.js'; /** * Get available product types */ export async function getProductTypes() { const spinner = Display.spinner('Fetching product types...'); try { const client = createClient(); const response = await client.admin.getProductTypes(); spinner.succeed('Product types retrieved'); if (response.productTypes && response.productTypes.length > 0) { Display.table(response.productTypes.map((type) => ({ 'Type': type.type || 'N/A', 'Name': type.name || 'N/A', 'Category': type.category || 'N/A' }))); } else { Display.info('No product types available'); } } catch (error) { spinner.fail('Failed to get product types'); Display.error(error.message); process.exit(1); } } /** * Get available workflows */ export async function getWorkflows() { const spinner = Display.spinner('Fetching workflows...'); try { const client = createClient(); const response = await client.admin.getWorkflows(); spinner.succeed('Workflows retrieved'); if (response.workflows && response.workflows.length > 0) { Display.table(response.workflows.map((workflow) => ({ 'Workflow': workflow.name, 'Description': workflow.description || 'N/A', 'Version': workflow.version || 'N/A', 'Status': workflow.status || 'Active' }))); } else { Display.info('No workflows available'); } } catch (error) { spinner.fail('Failed to get workflows'); Display.error(error.message); process.exit(1); } } /** * Get client information */ export async function getClientInfo() { const spinner = Display.spinner('Fetching client information...'); try { const client = createClient(); const response = await client.admin.getClientInfo(); spinner.succeed('Client information retrieved'); if (!response.success || !response.data) { Display.error(response.message || 'No client information available'); return; } const clientInfo = response.data; Display.header('Client Information'); Display.keyValue('Client ID', clientInfo.id || 'N/A'); Display.keyValue('Client Name', clientInfo.name || 'N/A'); Display.keyValue('Tenant Type', clientInfo.tenantType || 'N/A'); Display.keyValue('Tenant Key', clientInfo.tenantKey || 'N/A'); Display.keyValue('Status', clientInfo.status || 'N/A'); Display.keyValue('Contact Email', clientInfo.contactEmail || 'N/A'); if (clientInfo.settings?.desktop) { Display.header('Desktop Settings'); Display.keyValue('Email Integration', clientInfo.settings.desktop.enableEmailIntegration ? 'Enabled' : 'Disabled'); } } catch (error) { spinner.fail('Failed to get client information'); Display.error(error.message); process.exit(1); } }