"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = updateUserConfig; const fs_1 = __importDefault(require("fs")); const grab_dir_names_1 = __importDefault(require("../names/grab-dir-names")); const grab_config_1 = __importDefault(require("./grab-config")); const lodash_1 = __importDefault(require("lodash")); function updateUserConfig({ newConfig, userId, }) { if (!userId || !newConfig) { return { success: false, msg: `UserID or newConfig not provided`, }; } const { userConfigJSONFilePath } = (0, grab_dir_names_1.default)({ userId, }); if (!userConfigJSONFilePath || !fs_1.default.existsSync(userConfigJSONFilePath)) { return { success: false, msg: `userConfigJSONFilePath not found!`, }; } const { userConfig: existingUserConfig } = (0, grab_config_1.default)({ userId }); const updateConfig = lodash_1.default.merge(existingUserConfig, newConfig); fs_1.default.writeFileSync(userConfigJSONFilePath, JSON.stringify(updateConfig), "utf-8"); return { success: true }; }