UNPKG

@microsoft/windows-admin-center-sdk

Version:

Microsoft - Windows Admin Center Shell

69 lines (67 loc) 2.52 kB
import { VersionedObject } from '../../base/versioned-object'; import { CommonConnectionSettings } from './common-connection-settings'; /** * The Versioned representation of the Connection Settings. */ export class ConnectionSettings extends VersionedObject { /** * The names of properties that are saved into the versioned object */ static propertyNames = { common: 'common', extensions: 'extensions' }; /** * Getter for the latest version of the user profile. */ get latestVersion() { return 1; } /** * Getter for common connection settings object * The settings in the object are available to all extensions */ get common() { return new CommonConnectionSettings(this.getProperty(ConnectionSettings.propertyNames.common), { save: (object) => { return this.trySave(() => { this.setProperty(ConnectionSettings.propertyNames.common, object); }); } }); } /** * Getter for extension connection settings object map * Each extension has its own object in this map. */ get extensions() { return this.getProperty(ConnectionSettings.propertyNames.extensions); } /** * Setter for extension connection settings object map */ set extensions(value) { this.setProperty(ConnectionSettings.propertyNames.extensions, value); } /** * upgrades the current properties to the latest version * if this.currentVersion is null or undefined, then the upgrade should initialize to the latest version */ upgrade() { // For now, we dont need to do anything but initialize to the latest version. // NOTE: When latestVersion is updated, then we need to add logic here to upgrade old connection settings objects. if (MsftSme.isNullOrUndefined(this.currentVersion)) { this.clear(); this.setProperty(ConnectionSettings.propertyNames.common, { properties: {}, version: null }); this.extensions = {}; this.currentVersion = 0; return; } else if (this.currentVersion === 0) { // version 0 previously set common to {} which is incorrect for a versioned object. this.setProperty(ConnectionSettings.propertyNames.common, { properties: {}, version: null }); this.currentVersion = 1; } } } //# sourceMappingURL=connection-settings.js.map