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EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IACxG,+BAA+B,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/G,yBAAyB,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;CAC5G;AAED;;GAEG;AACH,qBAAa,eAAgB,YAAW,aAAa;IAOrC,OAAO,CAAC,GAAG;IAAO,OAAO,CAAC,cAAc;IALpD;;;;OAIG;gBACiB,GAAG,EAAE,GAAG,EAAU,cAAc,EAAE,iBAAiB;IAEvE;;OAEG;IACH,IAAI,gBAAgB,IAAI,MAAM,CAE7B;IAED;;OAEG;IACI,qBAAqB,IAAI,UAAU,CAAC,kBAAkB,CAAC;IA2B9D;;OAEG;IACI,4BAA4B,IAAI,UAAU,CAAC,yBAAyB,CAAC;IA2B5E;;OAEG;IACI,sBAAsB,IAAI,UAAU,CAAC,mBAAmB,CAAC;IA8BhE;;;;;OAKG;IACI,wBAAwB,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA2B9G;;;;;OAKG;IACI,+BAA+B,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IA2BrH;;;;;OAKG;IACI,yBAAyB,CAAC,CAAC,SAAS,eAAe,EAAE,IAAI,EAAE,0BAA0B,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;CA0BlH","file":"settings-manager.d.ts","sourcesContent":["import { from, Observable } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { JsonObject } from '../base/json';\r\nimport { PlainVersionedObject, VersionedObject, VersionedObjectConstructor, VersionedObjectHandlers } from '../base/versioned-object';\r\nimport { Rpc } from '../rpc/rpc';\r\nimport { RpcSettingsClient } from '../rpc/settings/rpc-settings-client';\r\nimport { RpcSettings, RpcSettingsOperationType, RpcSettingsProviderType, RpcSettingsScope } from '../rpc/settings/rpc-settings-model';\r\nimport { GatewayConnection } from './gateway-connection';\r\n\r\nexport const enum BannerHideType {\r\n    /**\r\n     * Indicates banner is not hidden (unusual)\r\n     */\r\n    None,\r\n    /**\r\n     * Indicates banner is hidden for the current session\r\n     */\r\n    Session,\r\n    /**\r\n     * Indicates banner is hidden permanently\r\n     */\r\n    Permanent\r\n}\r\n\r\n/**\r\n * Defines banner settings for the current user shared across the application\r\n */\r\nexport interface BannerUserSettings extends JsonObject {\r\n    id: string;\r\n    hideType: BannerHideType;\r\n}\r\n\r\n/**\r\n * The Versioned representation of the Shell User Settings\r\n * This object is used for settings that specific to the current user and to shell\r\n */\r\nexport class CommonUserSettings extends VersionedObject {\r\n\r\n    private static propertyNames = {\r\n        banners: 'banners'\r\n    };\r\n\r\n    /**\r\n     * Getter for the latest version of the common user settings\r\n     */\r\n    public get latestVersion(): number {\r\n        return 1;\r\n    }\r\n\r\n    /**\r\n     * Getter for the users preference on banner settings\r\n     */\r\n    public get banners(): BannerUserSettings[] {\r\n        return <BannerUserSettings[]>this.getProperty(CommonUserSettings.propertyNames.banners);\r\n    }\r\n\r\n    /**\r\n     * Setter for the users preference on banner settings\r\n     */\r\n    public set banners(value: BannerUserSettings[]) {\r\n        this.setProperty(CommonUserSettings.propertyNames.banners, value);\r\n    }\r\n\r\n    constructor(objectWrapper: PlainVersionedObject, handlers: VersionedObjectHandlers) {\r\n        super(objectWrapper, handlers);\r\n    }\r\n\r\n    /**\r\n     * Attempts to upgrade the current version of the object at least one version toward the latest version.\r\n     * if this.currentVersion is null or undefined, then the upgrade should initialize to the latest version\r\n     * this is called iteratively until the current version is equal 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 user profile objects.\r\n        // In this case, we ALWAYS must maintain backwards and forwards compatibility. This object is shared back and forth be\r\n        if (MsftSme.isNullOrUndefined(this.currentVersion)) {\r\n            this.clear();\r\n            this.banners = [];\r\n            this.currentVersion = this.latestVersion;\r\n            return;\r\n        } else if (this.currentVersion < this.latestVersion) {\r\n            this.currentVersion = this.latestVersion;\r\n        } else {\r\n            // current version is newer than the version we know about. TODO: there may need to be handling here in the future.\r\n        }\r\n    }\r\n}\r\n\r\n/**\r\n * Defines the common application settings object that is shared through the whole application.\r\n */\r\nexport class CommonApplicationSettings extends VersionedObject {\r\n    private static propertyNames = {\r\n        // TODO: add properties when needed\r\n    };\r\n\r\n    /**\r\n     * Getter for the latest version of the common application settings\r\n     */\r\n    public get latestVersion(): number {\r\n        return 1;\r\n    }\r\n\r\n    constructor(objectWrapper: PlainVersionedObject, handlers: VersionedObjectHandlers) {\r\n        super(objectWrapper, handlers);\r\n    }\r\n\r\n    /**\r\n     * Attempts to upgrade the current version of the object at least one version toward the latest version.\r\n     * if this.currentVersion is null or undefined, then the upgrade should initialize to the latest version\r\n     * this is called iteratively until the current version is equal 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 application settings objects.\r\n        // In this case, we ALWAYS must maintain backwards and forwards compatibility. This object is shared back and forth be\r\n        if (MsftSme.isNullOrUndefined(this.currentVersion)) {\r\n            this.clear();\r\n            this.currentVersion = this.latestVersion;\r\n            return;\r\n        } else if (this.currentVersion < this.latestVersion) {\r\n            this.currentVersion = this.latestVersion;\r\n        } else {\r\n            // current version is newer than the version we know about. TODO: there may need to be handling here in the future.\r\n        }\r\n    }\r\n}\r\n\r\n/**\r\n * Defines the common admin settings object that is shared through the whole application.\r\n */\r\nexport class CommonAdminSettings extends VersionedObject {\r\n    private static propertyNames = {\r\n        connectivityLevel: 'connectivityLevel',\r\n        autoGatewayUpdate: 'autoGatewayUpdate',\r\n        autoExtensionsUpdate: 'autoExtensionsUpdate',\r\n        scheduledUpdateTime: 'scheduledUpdateTime',\r\n        updateRescheduled: 'updateRescheduled',\r\n        sessionsExpirationMinutes: 'sessionsExpirationMinutes',\r\n        credentialsExpirationTimeInMs: 'credentialsExpirationTimeInMs'\r\n    };\r\n\r\n    /**\r\n     * Getter for the latest version of the common admin settings\r\n     */\r\n    public get latestVersion(): number {\r\n        return 1;\r\n    }\r\n\r\n    /**\r\n     * Getter for the admin's preference on the connectivity level\r\n     */\r\n    public get connectivityLevel(): string {\r\n        return <string>this.getProperty(CommonAdminSettings.propertyNames.connectivityLevel);\r\n    }\r\n\r\n    /**\r\n     * Setter for the admin's preference on the connectivity level\r\n     */\r\n    public set connectivityLevel(value: string) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.connectivityLevel, value);\r\n    }\r\n\r\n    public get autoGatewayUpdate(): boolean {\r\n        return <boolean>this.getProperty(CommonAdminSettings.propertyNames.autoGatewayUpdate);\r\n    }\r\n\r\n    public set autoGatewayUpdate(value: boolean) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.autoGatewayUpdate, value);\r\n    }\r\n\r\n    public get autoExtensionsUpdate(): boolean {\r\n        return <boolean>this.getProperty(CommonAdminSettings.propertyNames.autoExtensionsUpdate);\r\n    }\r\n\r\n    public set autoExtensionsUpdate(value: boolean) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.autoExtensionsUpdate, value);\r\n    }\r\n\r\n    public get scheduledUpdateTime(): string {\r\n        return <string>this.getProperty(CommonAdminSettings.propertyNames.scheduledUpdateTime);\r\n    }\r\n\r\n    public set scheduledUpdateTime(value: string) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.scheduledUpdateTime, value);\r\n    }\r\n\r\n    public get updateRescheduled(): boolean {\r\n        return <boolean>this.getProperty(CommonAdminSettings.propertyNames.updateRescheduled);\r\n    }\r\n\r\n    private sessionsExpirationMinutesCache: number;\r\n\r\n    public get sessionsExpirationMinutes(): number {\r\n        if (MsftSme.isNullOrUndefined(this.sessionsExpirationMinutesCache)) {\r\n            this.sessionsExpirationMinutesCache = <number>this.getProperty(CommonAdminSettings.propertyNames.sessionsExpirationMinutes);\r\n        }\r\n        MsftSme.self().Init.sessionExpiration = this.sessionsExpirationMinutesCache;\r\n        return this.sessionsExpirationMinutesCache;\r\n    }\r\n\r\n    public set sessionsExpirationMinutes(value: number) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.sessionsExpirationMinutes, value);\r\n        this.sessionsExpirationMinutesCache = undefined;\r\n        MsftSme.self().Init.sessionExpiration = undefined;\r\n    }\r\n\r\n    private credentialsExpirationTimeInMsCache: number;\r\n\r\n    /**\r\n     * Get stored manage as credentials expiration time in milliseconds\r\n     */\r\n    public get credentialsExpirationTimeInMs(): number {\r\n        if (MsftSme.isNullOrUndefined(this.credentialsExpirationTimeInMsCache)) {\r\n            this.credentialsExpirationTimeInMsCache = <number>this.getProperty(\r\n                CommonAdminSettings.propertyNames.credentialsExpirationTimeInMs);\r\n        }\r\n        return this.credentialsExpirationTimeInMsCache;\r\n    }\r\n\r\n    /**\r\n     * Store manage as credentials expiration time in milliseconds\r\n     */\r\n    public set credentialsExpirationTimeInMs(value: number) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.credentialsExpirationTimeInMs, value);\r\n        this.credentialsExpirationTimeInMsCache = undefined;\r\n    }\r\n\r\n    public set updateRescheduled(value: boolean) {\r\n        this.setProperty(CommonAdminSettings.propertyNames.updateRescheduled, value);\r\n    }\r\n\r\n    constructor(objectWrapper: PlainVersionedObject, handlers: VersionedObjectHandlers, gatewayService: GatewayConnection) {\r\n        super(objectWrapper, handlers, gatewayService);\r\n    }\r\n    /**\r\n     * Attempts to upgrade the current version of the object at least one version toward the latest version.\r\n     * if this.currentVersion is null or undefined, then the upgrade should initialize to the latest version\r\n     * this is called iteratively until the current version is equal 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 admin settings objects.\r\n        // In this case, we ALWAYS must maintain backwards and forwards compatibility. This object is shared back and forth be\r\n\r\n        if (MsftSme.isNullOrUndefined(this.currentVersion)) {\r\n            this.clear();\r\n            this.currentVersion = this.latestVersion;\r\n            this.connectivityLevel = '';\r\n            this.scheduledUpdateTime = null;\r\n            this.updateRescheduled = false;\r\n            this.autoExtensionsUpdate = true;\r\n\r\n            this.autoGatewayUpdate = false;\r\n            this.gatewayService.get('gateway/autoupdate').subscribe((result: any) => this.autoGatewayUpdate = result.autoUpdate);\r\n\r\n            return;\r\n        } else if (this.currentVersion < this.latestVersion) {\r\n            this.currentVersion = this.latestVersion;\r\n        } else {\r\n            // current version is newer than the version we know about. TODO: there may need to be handling here in the future.\r\n        }\r\n    }\r\n}\r\n\r\n/**\r\n * Defines the interface for the settings manager.\r\n */\r\nexport interface SettingsQuery {\r\n    httpServerHeader: string;\r\n    getCommonUserSettings(): Observable<CommonUserSettings>;\r\n    getCommonApplicationSettings(): Observable<CommonApplicationSettings>;\r\n    getCommonAdminSettings(): Observable<CommonAdminSettings>;\r\n    getExtensionUserSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T>;\r\n    getExtensionApplicationSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T>;\r\n    getExtensionAdminSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T>;\r\n}\r\n\r\n/**\r\n * Manager for the settings. Provides an api for managing user and application settings.\r\n */\r\nexport class SettingsManager implements SettingsQuery {\r\n\r\n    /**\r\n     * Initializes a new instance of the SettingsManager class.\r\n     *\r\n     * @param rpc the RPC class instance.\r\n     */\r\n    constructor(private rpc: Rpc, private gatewayService: GatewayConnection) { }\r\n\r\n    /**\r\n     * Gets the http server header if any.\r\n     */\r\n    get httpServerHeader(): string {\r\n        return null;\r\n    }\r\n\r\n    /**\r\n     * Get common user settings. This is currently read-only\r\n     */\r\n    public getCommonUserSettings(): Observable<CommonUserSettings> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.User,\r\n                provider: RpcSettingsProviderType.Common\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new CommonUserSettings(settings, {\r\n                    save: (object) => {\r\n                        return <Observable<any>>from(RpcSettingsClient.settings(\r\n                            this.rpc,\r\n                            <RpcSettings>{\r\n                                operation: RpcSettingsOperationType.Set,\r\n                                scope: RpcSettingsScope.User,\r\n                                provider: RpcSettingsProviderType.Common,\r\n                                value: object\r\n                            }));\r\n                    }\r\n                });\r\n            }));\r\n    }\r\n\r\n    /**\r\n     * Get common application settings. This is currently read-only\r\n     */\r\n    public getCommonApplicationSettings(): Observable<CommonApplicationSettings> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.Application,\r\n                provider: RpcSettingsProviderType.Common\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new CommonApplicationSettings(settings, {\r\n                    save: (object) => {\r\n                        return <Observable<any>>from(RpcSettingsClient.settings(\r\n                            this.rpc,\r\n                            <RpcSettings>{\r\n                                operation: RpcSettingsOperationType.Set,\r\n                                scope: RpcSettingsScope.Application,\r\n                                provider: RpcSettingsProviderType.Common,\r\n                                value: object\r\n                            }));\r\n                    }\r\n                });\r\n            }));\r\n    }\r\n\r\n    /**\r\n     * Get common admin settings. This is currently read-only\r\n     */\r\n    public getCommonAdminSettings(): Observable<CommonAdminSettings> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.Admin,\r\n                provider: RpcSettingsProviderType.Common\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new CommonAdminSettings(\r\n                    settings,\r\n                    {\r\n                        save: (object) => {\r\n                            return <Observable<any>>from(RpcSettingsClient.settings(\r\n                                this.rpc,\r\n                                <RpcSettings>{\r\n                                    operation: RpcSettingsOperationType.Set,\r\n                                    scope: RpcSettingsScope.Admin,\r\n                                    provider: RpcSettingsProviderType.Common,\r\n                                    value: object\r\n                                }));\r\n                        }\r\n                    },\r\n                    this.gatewayService);\r\n            }));\r\n    }\r\n\r\n    /**\r\n     * Get extension user settings\r\n     * Extension settings objects must be an object that extends VersionedObject or implements the VersionedObjectConstructor\r\n     * example: if TestObject extends VersionedObject, then getExtensionUserSettings(TestObject) will return an Observable<TestObject>\r\n     * you should only create 1 versioned object for your extensions user settings.\r\n     */\r\n    public getExtensionUserSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.User,\r\n                provider: RpcSettingsProviderType.Extension\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new type(settings, {\r\n                    save: (object) => {\r\n                        return <Observable<any>>from(RpcSettingsClient.settings(\r\n                            this.rpc,\r\n                            <RpcSettings>{\r\n                                operation: RpcSettingsOperationType.Set,\r\n                                scope: RpcSettingsScope.User,\r\n                                provider: RpcSettingsProviderType.Extension,\r\n                                value: object\r\n                            }));\r\n                    }\r\n                });\r\n            }));\r\n    }\r\n\r\n    /**\r\n     * Get extension application settings\r\n     * Extension settings objects must be an object that extends VersionedObject or implements the VersionedObjectConstructor\r\n     * example: if TestObject extends VersionedObject, then getExtensionApplicationSettings(TestObject) will return an\r\n     * Observable<TestObject>. You should only create 1 versioned object for your extensions application settings.\r\n     */\r\n    public getExtensionApplicationSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.Application,\r\n                provider: RpcSettingsProviderType.Extension\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new type(settings, {\r\n                    save: (object) => {\r\n                        return <Observable<any>>from(RpcSettingsClient.settings(\r\n                            this.rpc,\r\n                            <RpcSettings>{\r\n                                operation: RpcSettingsOperationType.Set,\r\n                                scope: RpcSettingsScope.Application,\r\n                                provider: RpcSettingsProviderType.Extension,\r\n                                value: object\r\n                            }));\r\n                    }\r\n                });\r\n            }));\r\n    }\r\n\r\n    /**\r\n     * Get extension admin settings\r\n     * Extension settings objects must be an object that extends VersionedObject or implements the VersionedObjectConstructor\r\n     * example: if TestObject extends VersionedObject, then getExtensionAdminSettings(TestObject) will return an\r\n     * Observable<TestObject>. You should only create 1 versioned object for your extensions admin settings.\r\n     */\r\n    public getExtensionAdminSettings<T extends VersionedObject>(type: VersionedObjectConstructor<T>): Observable<T> {\r\n        return from(RpcSettingsClient.settings(\r\n            this.rpc,\r\n            <RpcSettings>{\r\n                operation: RpcSettingsOperationType.Get,\r\n                scope: RpcSettingsScope.Admin,\r\n                provider: RpcSettingsProviderType.Extension\r\n            })\r\n        )\r\n            .pipe(map(response => {\r\n                // If the extension settings are not versioned (or not defined), then start with an empty settings.\r\n                const settings = VersionedObject.ensureIsVersionedObject(response.data);\r\n                return new type(settings, {\r\n                    save: (object) => {\r\n                        return <Observable<any>>from(RpcSettingsClient.settings(\r\n                            this.rpc,\r\n                            <RpcSettings>{\r\n                                operation: RpcSettingsOperationType.Set,\r\n                                scope: RpcSettingsScope.Admin,\r\n                                provider: RpcSettingsProviderType.Extension,\r\n                                value: object\r\n                            }));\r\n                    }\r\n                });\r\n            }));\r\n    }\r\n}\r\n"]}