import deepmerge from "deepmerge" ; import { inject , injectable } from "inversify" ; import TYPES from "ioc/types" ; import { IDirectoryManager , IKeysManager } from "managers" ; import ConfigManager from "managers/ConfigManager" ; import { IKeyMap } from "models" ; import applicationKeys from "settings/internal/keys" ; /** Manages parsing key maps from application and user settings files. */ @ injectable ( ) class KeysManager extends ConfigManager implements IKeysManager { /** The internally held key map for this manager. */ private _keyMap ? : IKeyMap ; param directoryManager public constructor ( @ inject ( TYPES . IDirectoryManager ) directoryManager ) { super ( directoryManager ) ; } inheritDoc public get keyMap ( ) : IKeyMap { if ( ! this . _keyMap ) { this . _keyMap = this . retrieve ( ) ; } return this . _keyMap ; } returns private retrieve ( ) { const userKeys = this . parseFile < IKeyMap > ( "freeman.keys.json" ) ; return userKeys ? deepmerge ( applicationKeys , userKeys , { arrayMerge : ( destination , source ) => source } ) : applicationKeys ; } } export default KeysManager ;