fix(mail): migrate filesystem helpers to fsUtils, update DKIM and mail APIs, harden SMTP client, and bump dependencies

This commit is contained in:
2026-02-01 14:17:54 +00:00
parent dd4ac9fa3d
commit d54831765b
38 changed files with 3923 additions and 5335 deletions

View File

@@ -93,3 +93,71 @@ export {
uuid,
ip,
}
// Filesystem utilities (compatibility helpers for smartfile v13+)
export const fsUtils = {
/**
* Ensure a directory exists, creating it recursively if needed (sync)
*/
ensureDirSync: (dirPath: string): void => {
fs.mkdirSync(dirPath, { recursive: true });
},
/**
* Ensure a directory exists, creating it recursively if needed (async)
*/
ensureDir: async (dirPath: string): Promise<void> => {
await fs.promises.mkdir(dirPath, { recursive: true });
},
/**
* Write JSON content to a file synchronously
*/
toFsSync: (content: any, filePath: string): void => {
const data = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
fs.writeFileSync(filePath, data);
},
/**
* Write JSON content to a file asynchronously
*/
toFs: async (content: any, filePath: string): Promise<void> => {
const data = typeof content === 'string' ? content : JSON.stringify(content, null, 2);
await fs.promises.writeFile(filePath, data);
},
/**
* Check if a file or directory exists
*/
fileExistsSync: (filePath: string): boolean => {
return fs.existsSync(filePath);
},
/**
* Check if a file or directory exists (async)
*/
fileExists: async (filePath: string): Promise<boolean> => {
try {
await fs.promises.access(filePath);
return true;
} catch {
return false;
}
},
/**
* Read a JSON file synchronously
*/
toObjectSync: <T = any>(filePath: string): T => {
const content = fs.readFileSync(filePath, 'utf8');
return JSON.parse(content) as T;
},
/**
* Read a JSON file asynchronously
*/
toObject: async <T = any>(filePath: string): Promise<T> => {
const content = await fs.promises.readFile(filePath, 'utf8');
return JSON.parse(content) as T;
},
};