{"version":3,"sources":["../../../packages/core/security/connection-manager-settings/connection-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAExE;;GAEG;AAEH,MAAM,WAAW,8BAA+B,SAAQ,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC;CAAI;AACnG;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,eAAe;IAEnD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa,CAG1B;IAEF;;OAEG;IACH,IAAW,aAAa,IAAI,MAAM,CAEjC;IAED;;;OAGG;IACH,IAAW,MAAM,IAAI,wBAAwB,CAW5C;IAED;;;OAGG;IACH,IAAW,UAAU,IAAI,8BAA8B,CAEtD;IAED;;OAEG;IACH,IAAW,UAAU,CAAC,KAAK,EAAE,8BAA8B,EAE1D;IAED;;;OAGG;IACH,SAAS,CAAC,OAAO;CAepB","file":"connection-settings.d.ts","sourcesContent":["import { PlainVersionedObject, VersionedObject } from '../../base/versioned-object';\r\nimport { CommonConnectionSettings } from './common-connection-settings';\r\n\r\n/**\r\n * Defines The extension settings object for the connection. Each key identifies the settings for one extension\r\n */\r\n\r\nexport interface ExtensionConnectionSettingsMap extends MsftSme.StringMap<PlainVersionedObject> { }\r\n/**\r\n * The Versioned representation of the Connection Settings.\r\n */\r\nexport class ConnectionSettings extends VersionedObject {\r\n\r\n    /**\r\n     * The names of properties that are saved into the versioned object\r\n     */\r\n    private static propertyNames = {\r\n        common: 'common',\r\n        extensions: 'extensions'\r\n    };\r\n\r\n    /**\r\n     * Getter for the latest version of the user profile.\r\n     */\r\n    public get latestVersion(): number {\r\n        return 1;\r\n    }\r\n\r\n    /**\r\n     * Getter for common connection settings object\r\n     * The settings in the object are available to all extensions\r\n     */\r\n    public get common(): CommonConnectionSettings {\r\n        return new CommonConnectionSettings(\r\n            <PlainVersionedObject>this.getProperty(ConnectionSettings.propertyNames.common),\r\n            {\r\n                save: (object) => {\r\n                    return this.trySave(() => {\r\n                        this.setProperty(ConnectionSettings.propertyNames.common, object);\r\n                    });\r\n                }\r\n            }\r\n        );\r\n    }\r\n\r\n    /**\r\n     * Getter for extension connection settings object map\r\n     * Each extension has its own object in this map.\r\n     */\r\n    public get extensions(): ExtensionConnectionSettingsMap {\r\n        return <ExtensionConnectionSettingsMap>this.getProperty(ConnectionSettings.propertyNames.extensions);\r\n    }\r\n\r\n    /**\r\n     * Setter for extension connection settings object map\r\n     */\r\n    public set extensions(value: ExtensionConnectionSettingsMap) {\r\n        this.setProperty(ConnectionSettings.propertyNames.extensions, value);\r\n    }\r\n\r\n    /**\r\n     * upgrades the current properties to the latest version\r\n     * if this.currentVersion is null or undefined, then the upgrade should initialize to the latest version\r\n     */\r\n    protected upgrade() {\r\n        // For now, we dont need to do anything but initialize to the latest version.\r\n        // NOTE: When latestVersion is updated, then we need to add logic here to upgrade old connection settings objects.\r\n        if (MsftSme.isNullOrUndefined(this.currentVersion)) {\r\n            this.clear();\r\n            this.setProperty(ConnectionSettings.propertyNames.common, <PlainVersionedObject>{ properties: {}, version: null });\r\n            this.extensions = {};\r\n            this.currentVersion = 0;\r\n            return;\r\n        } else if (this.currentVersion === 0) {\r\n            // version 0 previously set common to {} which is incorrect for a versioned object.\r\n            this.setProperty(ConnectionSettings.propertyNames.common, <PlainVersionedObject>{ properties: {}, version: null });\r\n            this.currentVersion = 1;\r\n        }\r\n    }\r\n}\r\n"]}