5427 translations (#5429)

* Outlook agent via Entra Application

* translations
This commit is contained in:
Timothy Carambat
2026-04-14 13:38:03 -07:00
committed by GitHub
parent 3d9c210a32
commit 4172751858
48 changed files with 6336 additions and 60 deletions

View File

@@ -18,6 +18,21 @@ function isNullOrNaN(value) {
return isNaN(value);
}
/**
* Merges a string field from source to target if it passes validation.
* @param {Object} target - The target object to merge into
* @param {Object} source - The source object to read from
* @param {string} fieldName - The field name to merge
* @param {Function|null} validator - Optional validator function that returns false to reject the value
*/
function mergeStringField(target, source, fieldName, validator = null) {
const value = source[fieldName];
if (value && typeof value === "string" && value.trim()) {
if (validator && !validator(value)) return;
target[fieldName] = value.trim();
}
}
const SystemSettings = {
/** A default system prompt that is used when no other system prompt is set or available to the function caller. */
saneDefaultSystemPrompt:
@@ -38,6 +53,8 @@ const SystemSettings = {
"disabled_gmail_skills",
"gmail_deployment_id",
"gmail_api_key",
"disabled_outlook_skills",
"outlook_agent_config",
"imported_agent_skills",
"custom_app_name",
"feature_flags",
@@ -60,6 +77,8 @@ const SystemSettings = {
"disabled_gmail_skills",
"gmail_deployment_id",
"gmail_api_key",
"disabled_outlook_skills",
"outlook_agent_config",
"agent_sql_connections",
"custom_app_name",
"default_system_prompt",
@@ -207,6 +226,56 @@ const SystemSettings = {
GmailBridge.reset();
}
},
disabled_outlook_skills: (updates) => {
try {
const skills = updates.split(",").filter((skill) => !!skill);
return JSON.stringify(skills);
} catch {
console.error(`Could not validate disabled outlook skills.`);
return JSON.stringify([]);
}
},
outlook_agent_config: async (update) => {
const OutlookBridge = require("../utils/agents/aibitat/plugins/outlook/lib");
try {
if (!update) return JSON.stringify({});
const newConfig =
typeof update === "string" ? safeJsonParse(update, {}) : update;
const existingConfig = safeJsonParse(
(await SystemSettings.get({ label: "outlook_agent_config" }))?.value,
{}
);
const mergedConfig = { ...existingConfig };
mergeStringField(mergedConfig, newConfig, "clientId");
mergeStringField(mergedConfig, newConfig, "tenantId");
mergeStringField(
mergedConfig,
newConfig,
"clientSecret",
(v) => !v.match(/^\*+$/)
);
if (newConfig.accessToken !== undefined) {
mergedConfig.accessToken = newConfig.accessToken;
}
if (newConfig.refreshToken !== undefined) {
mergedConfig.refreshToken = newConfig.refreshToken;
}
if (newConfig.tokenExpiry !== undefined) {
mergedConfig.tokenExpiry = newConfig.tokenExpiry;
}
return JSON.stringify(mergedConfig);
} catch (e) {
console.error(`Could not validate outlook agent config:`, e.message);
return JSON.stringify({});
} finally {
OutlookBridge.reset();
}
},
agent_sql_connections: async (updates) => {
const existingConnections = safeJsonParse(
(await SystemSettings.get({ label: "agent_sql_connections" }))?.value,
@@ -434,6 +503,18 @@ const SystemSettings = {
return this._updateSettings(updates);
},
delete: async function (clause = {}) {
try {
if (!Object.keys(clause).length)
throw new Error("Clause cannot be empty");
await prisma.system_settings.deleteMany({ where: clause });
return true;
} catch (error) {
console.error(error.message);
return false;
}
},
// Explicit update of settings + key validations.
// Only use this method when directly setting a key value
// that takes no user input for the keys being modified.