// fetchSchemas.js
/**
 * Fetches available schema names from the server.
 * @param {function} onSuccess - Callback function to handle success.
 * @param {function} onError - Callback function to handle error.
 * @param {string} apiEndpoint - API endpoint to fetch schemas.
 * @param {array} excludedSchemas - List of schemas to be excluded.
 */
export const fetchSchemas = (onSuccess, onError, apiEndpoint, excludedSchemas) => {
    fetch(`${apiEndpoint}/schema`)
        .then(res => res.json())
        .then(data => {
            const filteredSchemas = data
                .filter(schema => !excludedSchemas.includes(schema))
                .sort((a, b) => a.localeCompare(b)); // Sort schemas alphabetically
            onSuccess(filteredSchemas);
        })
        .catch(error => onError(error));
};
