"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useSyncApi = void 0;
const react_1 = require("react");
const hooks_1 = require("@bluefly/bfui/hooks");
const useSyncApi = () => {
    const api = (0, hooks_1.useApi)();
    const getStats = (0, react_1.useCallback)(async () => {
        const response = await api.get('/api/v1/sync/stats');
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const getOperations = (0, react_1.useCallback)(async (params) => {
        const response = await api.get('/api/v1/sync/operations', { params });
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const getConflicts = (0, react_1.useCallback)(async (params) => {
        const response = await api.get('/api/v1/sync/conflicts', { params });
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const getConfigs = (0, react_1.useCallback)(async (params) => {
        const response = await api.get('/api/v1/sync/configs', { params });
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const getConfig = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/api/v1/sync/configs/${configId}`);
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const createConfig = (0, react_1.useCallback)(async (config) => {
        const response = await api.post('/api/v1/sync/configs', config);
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const updateConfig = (0, react_1.useCallback)(async (configId, config) => {
        const response = await api.put(`/api/v1/sync/configs/${configId}`, config);
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const deleteConfig = (0, react_1.useCallback)(async (configId) => {
        const response = await api.delete(`/api/v1/sync/configs/${configId}`);
        if (response.error) {
            throw new Error(response.error.message);
        }
    }, [api]);
    const triggerSync = (0, react_1.useCallback)(async (configId) => {
        const response = await api.post(`/api/v1/sync/configs/${configId}/sync`);
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    const resolveConflict = (0, react_1.useCallback)(async (request) => {
        const response = await api.post(`/api/v1/sync/conflicts/${request.conflictId}/resolve`, request);
        if (response.error) {
            throw new Error(response.error.message);
        }
        return response.data;
    }, [api]);
    // Sync Intelligence Methods
    const getSyncIntelligence = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/intelligence/${configId}`);
        return response.data;
    }, [api]);
    const getSyncPredictions = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/predictions/${configId}`);
        return response.data;
    }, [api]);
    const getSyncSchedule = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/schedule/${configId}`);
        return response.data;
    }, [api]);
    const updateSyncSchedule = (0, react_1.useCallback)(async (configId, schedule) => {
        const response = await api.patch(`/sync/schedule/${configId}`, schedule);
        return response.data;
    }, [api]);
    const applyHealingStrategy = (0, react_1.useCallback)(async (operationId, strategy) => {
        await api.post(`/sync/healing/${operationId}`, strategy);
    }, [api]);
    const getSyncPatterns = (0, react_1.useCallback)(async (configId, timeRange) => {
        const response = await api.get(`/sync/patterns/${configId}`, {
            params: timeRange,
        });
        return response.data;
    }, [api]);
    const getRecommendedTransformations = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/transformations/${configId}`);
        return response.data;
    }, [api]);
    const getValidationRules = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/validation/${configId}`);
        return response.data;
    }, [api]);
    const getConflictStrategies = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/conflicts/strategies/${configId}`);
        return response.data;
    }, [api]);
    const getPerformanceMetrics = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/performance/${configId}`);
        return response.data;
    }, [api]);
    const getErrorPatterns = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/errors/patterns/${configId}`);
        return response.data;
    }, [api]);
    const getSystemHealth = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/health/${configId}`);
        return response.data;
    }, [api]);
    const getResourceUtilization = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/resources/${configId}`);
        return response.data;
    }, [api]);
    const getOperationRecommendations = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/recommendations/${configId}`);
        return response.data;
    }, [api]);
    const getOperationHistory = (0, react_1.useCallback)(async (configId, options) => {
        const response = await api.get(`/sync/history/${configId}`, {
            params: options,
        });
        return response.data;
    }, [api]);
    const getOperationDetails = (0, react_1.useCallback)(async (operationId) => {
        const response = await api.get(`/sync/operations/${operationId}`);
        return response.data;
    }, [api]);
    const getConfigurationRecommendations = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/config/recommendations/${configId}`);
        return response.data;
    }, [api]);
    const getEndpointHealth = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/endpoints/health/${configId}`);
        return response.data;
    }, [api]);
    const getDataQualityMetrics = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/quality/${configId}`);
        return response.data;
    }, [api]);
    const getSecurityInsights = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/security/${configId}`);
        return response.data;
    }, [api]);
    const getComplianceStatus = (0, react_1.useCallback)(async (configId) => {
        const response = await api.get(`/sync/compliance/${configId}`);
        return response.data;
    }, [api]);
    const getAuditLogs = (0, react_1.useCallback)(async (configId, options) => {
        const response = await api.get(`/sync/audit/${configId}`, {
            params: options,
        });
        return response.data;
    }, [api]);
    return {
        getStats,
        getOperations,
        getConflicts,
        getConfigs,
        getConfig,
        createConfig,
        updateConfig,
        deleteConfig,
        triggerSync,
        resolveConflict,
        getSyncIntelligence,
        getSyncPredictions,
        getSyncSchedule,
        updateSyncSchedule,
        applyHealingStrategy,
        getSyncPatterns,
        getRecommendedTransformations,
        getValidationRules,
        getConflictStrategies,
        getPerformanceMetrics,
        getErrorPatterns,
        getSystemHealth,
        getResourceUtilization,
        getOperationRecommendations,
        getOperationHistory,
        getOperationDetails,
        getConfigurationRecommendations,
        getEndpointHealth,
        getDataQualityMetrics,
        getSecurityInsights,
        getComplianceStatus,
        getAuditLogs,
    };
};
exports.useSyncApi = useSyncApi;
//# sourceMappingURL=useSyncApi.js.map