mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor(server): system config (#9517)
This commit is contained in:
parent
7f0f016f2e
commit
984aa8fb41
46 changed files with 599 additions and 770 deletions
|
|
@ -16,6 +16,47 @@ import { ImmichCookie, ImmichHeader } from 'src/dtos/auth.dto';
|
|||
import { ILoggerRepository } from 'src/interfaces/logger.interface';
|
||||
import { Metadata } from 'src/middleware/auth.guard';
|
||||
|
||||
/**
|
||||
* @returns a list of strings representing the keys of the object in dot notation
|
||||
*/
|
||||
export const getKeysDeep = (target: unknown, path: string[] = []) => {
|
||||
if (!target || typeof target !== 'object') {
|
||||
return [];
|
||||
}
|
||||
|
||||
const obj = target as object;
|
||||
|
||||
const properties: string[] = [];
|
||||
for (const key of Object.keys(obj as object)) {
|
||||
const value = obj[key as keyof object];
|
||||
if (value === undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_.isObject(value) && !_.isArray(value)) {
|
||||
properties.push(...getKeysDeep(value, [...path, key]));
|
||||
continue;
|
||||
}
|
||||
|
||||
properties.push([...path, key].join('.'));
|
||||
}
|
||||
|
||||
return properties;
|
||||
};
|
||||
|
||||
export const unsetDeep = (object: unknown, key: string) => {
|
||||
const parts = key.split('.');
|
||||
while (parts.length > 0) {
|
||||
_.unset(object, parts);
|
||||
parts.pop();
|
||||
if (!_.isEmpty(_.get(object, parts))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return _.isEmpty(object) ? undefined : object;
|
||||
};
|
||||
|
||||
const isMachineLearningEnabled = (machineLearning: SystemConfig['machineLearning']) => machineLearning.enabled;
|
||||
export const isSmartSearchEnabled = (machineLearning: SystemConfig['machineLearning']) =>
|
||||
isMachineLearningEnabled(machineLearning) && machineLearning.clip.enabled;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue