@microsoft/mgt-element
Advanced tools
Comparing version 2.1.0 to 2.2.0-next.build21.ac47b2b
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -145,2 +145,4 @@ /** | ||
private setLoadingState; | ||
private handleProviderUpdates; | ||
private handleActiveAccountUpdates; | ||
private handleLocalizationChanged; | ||
@@ -147,0 +149,0 @@ private handleDirectionChanged; |
@@ -76,2 +76,4 @@ /** | ||
this.handleDirectionChanged = this.handleDirectionChanged.bind(this); | ||
this.handleProviderUpdates = this.handleProviderUpdates.bind(this); | ||
this.handleActiveAccountUpdates = this.handleActiveAccountUpdates.bind(this); | ||
this.handleDirectionChanged(); | ||
@@ -147,2 +149,4 @@ this.handleLocalizationChanged(); | ||
LocalizationHelper.removeOnDirectionUpdated(this.handleDirectionChanged); | ||
Providers.removeProviderUpdatedListener(this.handleProviderUpdates); | ||
Providers.removeActiveAccountChangedListener(this.handleActiveAccountUpdates); | ||
} | ||
@@ -161,3 +165,4 @@ /** | ||
this._isFirstUpdated = true; | ||
Providers.onProviderUpdated(() => this.requestStateUpdate()); | ||
Providers.onProviderUpdated(this.handleProviderUpdates); | ||
Providers.onActiveAccountChanged(this.handleActiveAccountUpdates); | ||
this.requestStateUpdate(); | ||
@@ -275,2 +280,11 @@ } | ||
} | ||
handleProviderUpdates() { | ||
this.requestStateUpdate(); | ||
} | ||
handleActiveAccountUpdates() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.clearState(); | ||
this.requestStateUpdate(); | ||
}); | ||
} | ||
handleLocalizationChanged() { | ||
@@ -277,0 +291,0 @@ LocalizationHelper.updateStringsForTag(this.tagName, this.strings); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -17,2 +17,4 @@ /** | ||
* @extends {MgtBaseComponent} | ||
* | ||
* @fires templateRendered - fires when a template is rendered | ||
*/ | ||
@@ -19,0 +21,0 @@ export declare abstract class MgtTemplatedComponent extends MgtBaseComponent { |
@@ -18,2 +18,4 @@ /** | ||
* @extends {MgtBaseComponent} | ||
* | ||
* @fires templateRendered - fires when a template is rendered | ||
*/ | ||
@@ -20,0 +22,0 @@ export class MgtTemplatedComponent extends MgtBaseComponent { |
@@ -0,0 +0,0 @@ /** |
@@ -124,3 +124,3 @@ /** | ||
new TelemetryHandler(), | ||
new SdkVersionMiddleware(PACKAGE_VERSION), | ||
new SdkVersionMiddleware(PACKAGE_VERSION, provider.name), | ||
new HTTPMessageHandler() | ||
@@ -127,0 +127,0 @@ ]; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -46,3 +46,10 @@ /** | ||
getAccessToken(): Promise<string>; | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name(): string; | ||
} | ||
//# sourceMappingURL=MockProvider.d.ts.map |
@@ -76,3 +76,12 @@ /** | ||
} | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name() { | ||
return 'MgtMockProvider'; | ||
} | ||
} | ||
//# sourceMappingURL=MockProvider.js.map |
@@ -27,4 +27,14 @@ /** | ||
graph: IGraph; | ||
/** | ||
* Enable/Disable multi account functionality | ||
* | ||
* @protected | ||
* @type {boolean} | ||
* @memberof IProvider | ||
*/ | ||
protected isMultipleAccountSupported: boolean; | ||
private _state; | ||
private _loginChangedDispatcher; | ||
private _activeAccountChangedDispatcher; | ||
get isMultiAccountSupported(): boolean; | ||
/** | ||
@@ -38,2 +48,9 @@ * returns state of Provider | ||
get state(): ProviderState; | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name(): string; | ||
constructor(); | ||
@@ -76,2 +93,43 @@ /** | ||
/** | ||
* Returns all signed in accounts. | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
getAllAccounts?(): IProviderAccount[]; | ||
/** | ||
* Returns active account in case of multi-account sign in | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
getActiveAccount?(): IProviderAccount; | ||
/** | ||
* Switch between two signed in accounts | ||
* | ||
* @param {*} user | ||
* @memberof IProvider | ||
*/ | ||
setActiveAccount?(user: IProviderAccount): void; | ||
/** | ||
* Event handler when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
onActiveAccountChanged(eventHandler: EventHandler<ActiveAccountChanged>): void; | ||
/** | ||
* Removes event handler for when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
removeActiveAccountChangedHandler(eventHandler: EventHandler<ActiveAccountChanged>): void; | ||
/** | ||
* Fires event when active account changes | ||
* | ||
* @memberof IProvider | ||
*/ | ||
private fireActiveAccountChanged; | ||
/** | ||
* uses scopes to recieve access token | ||
@@ -95,2 +153,10 @@ * | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged { | ||
} | ||
/** | ||
* loginChangedEvent | ||
@@ -139,2 +205,12 @@ * | ||
} | ||
/** | ||
* Account details | ||
* | ||
* @export | ||
*/ | ||
export declare type IProviderAccount = { | ||
id: string; | ||
mail?: string; | ||
name?: string; | ||
}; | ||
//# sourceMappingURL=IProvider.d.ts.map |
@@ -18,5 +18,17 @@ /** | ||
constructor() { | ||
/** | ||
* Enable/Disable multi account functionality | ||
* | ||
* @protected | ||
* @type {boolean} | ||
* @memberof IProvider | ||
*/ | ||
this.isMultipleAccountSupported = false; | ||
this._loginChangedDispatcher = new EventDispatcher(); | ||
this._activeAccountChangedDispatcher = new EventDispatcher(); | ||
this._state = ProviderState.Loading; | ||
} | ||
get isMultiAccountSupported() { | ||
return this.isMultipleAccountSupported; | ||
} | ||
/** | ||
@@ -33,2 +45,11 @@ * returns state of Provider | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name() { | ||
return 'MgtIProvider'; | ||
} | ||
/** | ||
* sets state of Provider and fires loginchangedDispatcher | ||
@@ -64,2 +85,37 @@ * | ||
/** | ||
* Switch between two signed in accounts | ||
* | ||
* @param {*} user | ||
* @memberof IProvider | ||
*/ | ||
setActiveAccount(user) { | ||
this.fireActiveAccountChanged(); | ||
} | ||
/** | ||
* Event handler when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
onActiveAccountChanged(eventHandler) { | ||
this._activeAccountChangedDispatcher.add(eventHandler); | ||
} | ||
/** | ||
* Removes event handler for when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
removeActiveAccountChangedHandler(eventHandler) { | ||
this._activeAccountChangedDispatcher.remove(eventHandler); | ||
} | ||
/** | ||
* Fires event when active account changes | ||
* | ||
* @memberof IProvider | ||
*/ | ||
fireActiveAccountChanged() { | ||
this._activeAccountChangedDispatcher.fire({}); | ||
} | ||
/** | ||
* uses scopes to recieve access token | ||
@@ -66,0 +122,0 @@ * |
@@ -44,2 +44,18 @@ /** | ||
/** | ||
* Fires event when Provider changes state | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
static onActiveAccountChanged(event: EventHandler<any>): void; | ||
/** | ||
* Remove event handler | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
static removeActiveAccountChangedListener(event: EventHandler<any>): void; | ||
/** | ||
* Gets the current signed in user | ||
@@ -61,5 +77,7 @@ * | ||
private static _eventDispatcher; | ||
private static _activeAccountChangedDispatcher; | ||
private static _globalProvider; | ||
private static _me; | ||
private static handleProviderStateChanged; | ||
private static handleActiveAccountChanged; | ||
} | ||
@@ -66,0 +84,0 @@ /** |
@@ -39,5 +39,7 @@ /** | ||
this._globalProvider.removeStateChangedHandler(this.handleProviderStateChanged); | ||
this._globalProvider.removeActiveAccountChangedHandler(this.handleActiveAccountChanged); | ||
} | ||
if (provider) { | ||
provider.onStateChanged(this.handleProviderStateChanged); | ||
provider.onActiveAccountChanged(this.handleActiveAccountChanged); | ||
} | ||
@@ -69,2 +71,22 @@ this._globalProvider = provider; | ||
/** | ||
* Fires event when Provider changes state | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
static onActiveAccountChanged(event) { | ||
this._activeAccountChangedDispatcher.add(event); | ||
} | ||
/** | ||
* Remove event handler | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
static removeActiveAccountChangedListener(event) { | ||
this._activeAccountChangedDispatcher.remove(event); | ||
} | ||
/** | ||
* Gets the current signed in user | ||
@@ -113,4 +135,8 @@ * | ||
} | ||
static handleActiveAccountChanged() { | ||
Providers._activeAccountChangedDispatcher.fire(null); | ||
} | ||
} | ||
Providers._eventDispatcher = new EventDispatcher(); | ||
Providers._activeAccountChangedDispatcher = new EventDispatcher(); | ||
/** | ||
@@ -117,0 +143,0 @@ * on Provider Change State |
@@ -20,2 +20,9 @@ /** | ||
private _logoutHandler; | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name(): string; | ||
constructor(getAccessTokenHandler: (scopes: string[]) => Promise<string>, loginHandler?: () => Promise<void>, logoutHandler?: () => Promise<void>); | ||
@@ -22,0 +29,0 @@ /** |
@@ -25,2 +25,11 @@ /** | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name() { | ||
return 'MgtSimpleProvider'; | ||
} | ||
/** | ||
* Invokes the getAccessToken function | ||
@@ -27,0 +36,0 @@ * |
@@ -0,0 +0,0 @@ /** |
@@ -130,2 +130,5 @@ /** | ||
} | ||
else if (r.headers['Content-Type'].includes('image/pjpeg')) { | ||
response.content = 'data:image/pjpeg;base64,' + r.body; | ||
} | ||
else { | ||
@@ -132,0 +135,0 @@ response.content = r.body; |
@@ -70,2 +70,16 @@ /** | ||
response: CacheOptions; | ||
/** | ||
* Cache options for files store | ||
* | ||
* @type {CacheOptions} | ||
* @memberof CacheConfig | ||
*/ | ||
files: CacheOptions; | ||
/** | ||
* Cache options for fileLists store | ||
* | ||
* @type {CacheOptions} | ||
* @memberof CacheConfig | ||
*/ | ||
fileLists: CacheOptions; | ||
} | ||
@@ -72,0 +86,0 @@ /** |
@@ -94,3 +94,3 @@ /** | ||
}, | ||
isEnabled: true, | ||
isEnabled: false, | ||
people: { | ||
@@ -115,2 +115,10 @@ invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
files: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
fileLists: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
} | ||
@@ -145,3 +153,8 @@ }; | ||
} | ||
return (yield this.getDb()).get(this.store, key); | ||
try { | ||
return (yield this.getDb()).get(this.store, key); | ||
} | ||
catch (e) { | ||
return null; | ||
} | ||
}); | ||
@@ -162,3 +175,8 @@ } | ||
} | ||
yield (yield this.getDb()).put(this.store, Object.assign(Object.assign({}, item), { timeCached: Date.now() }), key); | ||
try { | ||
yield (yield this.getDb()).put(this.store, Object.assign(Object.assign({}, item), { timeCached: Date.now() }), key); | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
}); | ||
@@ -177,3 +195,8 @@ } | ||
} | ||
(yield this.getDb()).clear(this.store); | ||
try { | ||
(yield this.getDb()).clear(this.store); | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
}); | ||
@@ -180,0 +203,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -46,2 +46,15 @@ /** | ||
static create<T>(graph: IGraph, request: GraphRequest, version?: string): Promise<GraphPageIterator<T>>; | ||
/** | ||
* Creates a new GraphPageIterator from existing value | ||
* | ||
* @static | ||
* @template T - the type of entities expected from this request | ||
* @param {IGraph} graph - the graph instance to use for making requests | ||
* @param value - the existing value | ||
* @param nextLink - optional nextLink to use to get the next page | ||
* from the graph parameter | ||
* @returns a GraphPageIterator | ||
* @memberof GraphPageIterator | ||
*/ | ||
static createFromValue<T>(graph: IGraph, value: any, nextLink?: any): GraphPageIterator<T>; | ||
private _graph; | ||
@@ -48,0 +61,0 @@ private _nextLink; |
@@ -71,2 +71,23 @@ /** | ||
/** | ||
* Creates a new GraphPageIterator from existing value | ||
* | ||
* @static | ||
* @template T - the type of entities expected from this request | ||
* @param {IGraph} graph - the graph instance to use for making requests | ||
* @param value - the existing value | ||
* @param nextLink - optional nextLink to use to get the next page | ||
* from the graph parameter | ||
* @returns a GraphPageIterator | ||
* @memberof GraphPageIterator | ||
*/ | ||
static createFromValue(graph, value, nextLink) { | ||
let iterator = new GraphPageIterator(); | ||
// create iterator from values | ||
iterator._graph = graph; | ||
iterator._value = value; | ||
iterator._nextLink = nextLink ? nextLink : null; | ||
iterator._version = graph.version; | ||
return iterator || null; | ||
} | ||
/** | ||
* Gets the next page for this request | ||
@@ -81,6 +102,3 @@ * | ||
const nextResource = this._nextLink.split(this._version)[1]; | ||
const response = yield this._graph | ||
.api(nextResource) | ||
.version(this._version) | ||
.get(); | ||
const response = yield this._graph.api(nextResource).version(this._version).get(); | ||
if (response && response.value && response.value.length) { | ||
@@ -87,0 +105,0 @@ this._value = this._value.concat(response.value); |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -22,3 +22,4 @@ /** | ||
private _packageVersion; | ||
constructor(packageVersion: string); | ||
private _providerName; | ||
constructor(packageVersion: string, providerName?: string); | ||
execute(context: Context): Promise<void>; | ||
@@ -25,0 +26,0 @@ /** |
@@ -26,4 +26,5 @@ /** | ||
export class SdkVersionMiddleware { | ||
constructor(packageVersion) { | ||
constructor(packageVersion, providerName) { | ||
this._packageVersion = packageVersion; | ||
this._providerName = providerName; | ||
} | ||
@@ -41,2 +42,6 @@ // tslint:disable-next-line: completed-docs | ||
} | ||
if (this._providerName) { | ||
const providerVersion = `${this._providerName}/${this._packageVersion}`; | ||
headerParts.push(providerVersion); | ||
} | ||
// Package version | ||
@@ -43,0 +48,0 @@ const packageVersion = `mgt/${this._packageVersion}`; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -7,3 +7,3 @@ /** | ||
*/ | ||
export declare const PACKAGE_VERSION = "2.1.0"; | ||
export declare const PACKAGE_VERSION = "2.2.0"; | ||
//# sourceMappingURL=version.d.ts.map |
@@ -9,3 +9,3 @@ /** | ||
// ANY CHANGES WILL BE LOST DURING BUILD | ||
export const PACKAGE_VERSION = '2.1.0'; | ||
export const PACKAGE_VERSION = '2.2.0'; | ||
//# sourceMappingURL=version.js.map |
{ | ||
"name": "@microsoft/mgt-element", | ||
"version": "2.1.0", | ||
"version": "2.2.0-next.build21.ac47b2b", | ||
"description": "Microsoft Graph Toolkit base classes", | ||
@@ -36,3 +36,3 @@ "homepage": "https://github.com/microsoftgraph/microsoft-graph-toolkit", | ||
"lit-element": "^2.4.0", | ||
"idb": "^5.0.7" | ||
"idb": "^6.0.0" | ||
}, | ||
@@ -39,0 +39,0 @@ "publishConfig": { |
@@ -116,2 +116,4 @@ /** | ||
this.handleDirectionChanged = this.handleDirectionChanged.bind(this); | ||
this.handleProviderUpdates = this.handleProviderUpdates.bind(this); | ||
this.handleActiveAccountUpdates = this.handleActiveAccountUpdates.bind(this); | ||
this.handleDirectionChanged(); | ||
@@ -141,2 +143,4 @@ this.handleLocalizationChanged(); | ||
LocalizationHelper.removeOnDirectionUpdated(this.handleDirectionChanged); | ||
Providers.removeProviderUpdatedListener(this.handleProviderUpdates); | ||
Providers.removeActiveAccountChangedListener(this.handleActiveAccountUpdates); | ||
} | ||
@@ -156,3 +160,4 @@ | ||
this._isFirstUpdated = true; | ||
Providers.onProviderUpdated(() => this.requestStateUpdate()); | ||
Providers.onProviderUpdated(this.handleProviderUpdates); | ||
Providers.onActiveAccountChanged(this.handleActiveAccountUpdates); | ||
this.requestStateUpdate(); | ||
@@ -286,2 +291,11 @@ } | ||
private handleProviderUpdates() { | ||
this.requestStateUpdate(); | ||
} | ||
private async handleActiveAccountUpdates() { | ||
this.clearState(); | ||
this.requestStateUpdate(); | ||
} | ||
private handleLocalizationChanged() { | ||
@@ -288,0 +302,0 @@ LocalizationHelper.updateStringsForTag(this.tagName, this.strings); |
@@ -38,2 +38,4 @@ /** | ||
* @extends {MgtBaseComponent} | ||
* | ||
* @fires templateRendered - fires when a template is rendered | ||
*/ | ||
@@ -40,0 +42,0 @@ export abstract class MgtTemplatedComponent extends MgtBaseComponent { |
@@ -154,3 +154,3 @@ /** | ||
new TelemetryHandler(), | ||
new SdkVersionMiddleware(PACKAGE_VERSION), | ||
new SdkVersionMiddleware(PACKAGE_VERSION, provider.name), | ||
new HTTPMessageHandler() | ||
@@ -157,0 +157,0 @@ ]; |
@@ -48,2 +48,3 @@ /** | ||
} | ||
/** | ||
@@ -60,2 +61,3 @@ * sets Provider state to signed out | ||
} | ||
/** | ||
@@ -70,2 +72,12 @@ * Promise returning token from graph.microsoft.com | ||
} | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
public get name() { | ||
return 'MgtMockProvider'; | ||
} | ||
} |
@@ -29,4 +29,16 @@ /** | ||
public graph: IGraph; | ||
/** | ||
* Enable/Disable multi account functionality | ||
* | ||
* @protected | ||
* @type {boolean} | ||
* @memberof IProvider | ||
*/ | ||
protected isMultipleAccountSupported: boolean = false; | ||
private _state: ProviderState; | ||
private _loginChangedDispatcher = new EventDispatcher<LoginChangedEvent>(); | ||
private _activeAccountChangedDispatcher = new EventDispatcher<ActiveAccountChanged>(); | ||
public get isMultiAccountSupported(): boolean { | ||
return this.isMultipleAccountSupported; | ||
} | ||
/** | ||
@@ -43,2 +55,12 @@ * returns state of Provider | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
public get name() { | ||
return 'MgtIProvider'; | ||
} | ||
constructor() { | ||
@@ -97,2 +119,57 @@ this._state = ProviderState.Loading; | ||
/** | ||
* Returns all signed in accounts. | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
public getAllAccounts?(): IProviderAccount[]; | ||
/** | ||
* Returns active account in case of multi-account sign in | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
public getActiveAccount?(): IProviderAccount; | ||
/** | ||
* Switch between two signed in accounts | ||
* | ||
* @param {*} user | ||
* @memberof IProvider | ||
*/ | ||
public setActiveAccount?(user: IProviderAccount) { | ||
this.fireActiveAccountChanged(); | ||
} | ||
/** | ||
* Event handler when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
public onActiveAccountChanged(eventHandler: EventHandler<ActiveAccountChanged>) { | ||
this._activeAccountChangedDispatcher.add(eventHandler); | ||
} | ||
/** | ||
* Removes event handler for when Active account changes | ||
* | ||
* @param {EventHandler<ActiveAccountChanged>} eventHandler | ||
* @memberof IProvider | ||
*/ | ||
public removeActiveAccountChangedHandler(eventHandler: EventHandler<ActiveAccountChanged>) { | ||
this._activeAccountChangedDispatcher.remove(eventHandler); | ||
} | ||
/** | ||
* Fires event when active account changes | ||
* | ||
* @memberof IProvider | ||
*/ | ||
private fireActiveAccountChanged() { | ||
this._activeAccountChangedDispatcher.fire({}); | ||
} | ||
/** | ||
* uses scopes to recieve access token | ||
@@ -120,2 +197,9 @@ * | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged {} | ||
/** | ||
* loginChangedEvent | ||
@@ -166,1 +250,12 @@ * | ||
} | ||
/** | ||
* Account details | ||
* | ||
* @export | ||
*/ | ||
export type IProviderAccount = { | ||
id: string; | ||
mail?: string; | ||
name?: string; | ||
}; |
@@ -36,2 +36,3 @@ /** | ||
this._globalProvider.removeStateChangedHandler(this.handleProviderStateChanged); | ||
this._globalProvider.removeActiveAccountChangedHandler(this.handleActiveAccountChanged); | ||
} | ||
@@ -41,2 +42,3 @@ | ||
provider.onStateChanged(this.handleProviderStateChanged); | ||
provider.onActiveAccountChanged(this.handleActiveAccountChanged); | ||
} | ||
@@ -72,2 +74,24 @@ | ||
/** | ||
* Fires event when Provider changes state | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
public static onActiveAccountChanged(event: EventHandler<any>) { | ||
this._activeAccountChangedDispatcher.add(event); | ||
} | ||
/** | ||
* Remove event handler | ||
* | ||
* @static | ||
* @param {EventHandler<ProvidersChangedState>} event | ||
* @memberof Providers | ||
*/ | ||
public static removeActiveAccountChangedListener(event: EventHandler<any>) { | ||
this._activeAccountChangedDispatcher.remove(event); | ||
} | ||
/** | ||
* Gets the current signed in user | ||
@@ -109,6 +133,6 @@ * | ||
private static _eventDispatcher: EventDispatcher<ProvidersChangedState> = new EventDispatcher< | ||
ProvidersChangedState | ||
>(); | ||
private static _eventDispatcher: EventDispatcher<ProvidersChangedState> = new EventDispatcher<ProvidersChangedState>(); | ||
private static _activeAccountChangedDispatcher: EventDispatcher<any> = new EventDispatcher<any>(); | ||
private static _globalProvider: IProvider; | ||
@@ -125,2 +149,6 @@ private static _me: User; | ||
} | ||
private static handleActiveAccountChanged() { | ||
Providers._activeAccountChangedDispatcher.fire(null); | ||
} | ||
} | ||
@@ -127,0 +155,0 @@ |
@@ -24,2 +24,12 @@ /** | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
public get name() { | ||
return 'MgtSimpleProvider'; | ||
} | ||
constructor( | ||
@@ -26,0 +36,0 @@ getAccessTokenHandler: (scopes: string[]) => Promise<string>, |
@@ -190,2 +190,4 @@ /** | ||
response.content = 'data:image/jpeg;base64,' + r.body; | ||
} else if (r.headers['Content-Type'].includes('image/pjpeg')) { | ||
response.content = 'data:image/pjpeg;base64,' + r.body; | ||
} else { | ||
@@ -192,0 +194,0 @@ response.content = r.body; |
@@ -77,2 +77,17 @@ /** | ||
response: CacheOptions; | ||
/** | ||
* Cache options for files store | ||
* | ||
* @type {CacheOptions} | ||
* @memberof CacheConfig | ||
*/ | ||
files: CacheOptions; | ||
/** | ||
* Cache options for fileLists store | ||
* | ||
* @type {CacheOptions} | ||
* @memberof CacheConfig | ||
*/ | ||
fileLists: CacheOptions; | ||
} | ||
@@ -150,3 +165,3 @@ | ||
}, | ||
isEnabled: true, | ||
isEnabled: false, | ||
people: { | ||
@@ -171,2 +186,10 @@ invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
files: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
fileLists: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
} | ||
@@ -288,4 +311,7 @@ }; | ||
} | ||
return (await this.getDb()).get(this.store, key); | ||
try { | ||
return (await this.getDb()).get(this.store, key); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -305,4 +331,7 @@ | ||
} | ||
await (await this.getDb()).put(this.store, { ...item, timeCached: Date.now() }, key); | ||
try { | ||
await (await this.getDb()).put(this.store, { ...item, timeCached: Date.now() }, key); | ||
} catch (e) { | ||
return; | ||
} | ||
} | ||
@@ -320,4 +349,7 @@ | ||
} | ||
(await this.getDb()).clear(this.store); | ||
try { | ||
(await this.getDb()).clear(this.store); | ||
} catch (e) { | ||
return; | ||
} | ||
} | ||
@@ -324,0 +356,0 @@ |
@@ -67,2 +67,26 @@ /** | ||
/** | ||
* Creates a new GraphPageIterator from existing value | ||
* | ||
* @static | ||
* @template T - the type of entities expected from this request | ||
* @param {IGraph} graph - the graph instance to use for making requests | ||
* @param value - the existing value | ||
* @param nextLink - optional nextLink to use to get the next page | ||
* from the graph parameter | ||
* @returns a GraphPageIterator | ||
* @memberof GraphPageIterator | ||
*/ | ||
public static createFromValue<T>(graph: IGraph, value, nextLink?) { | ||
let iterator = new GraphPageIterator<T>(); | ||
// create iterator from values | ||
iterator._graph = graph; | ||
iterator._value = value; | ||
iterator._nextLink = nextLink ? nextLink : null; | ||
iterator._version = graph.version; | ||
return iterator || null; | ||
} | ||
private _graph: IGraph; | ||
@@ -82,6 +106,3 @@ private _nextLink: string; | ||
const nextResource = this._nextLink.split(this._version)[1]; | ||
const response = await this._graph | ||
.api(nextResource) | ||
.version(this._version) | ||
.get(); | ||
const response = await this._graph.api(nextResource).version(this._version).get(); | ||
if (response && response.value && response.value.length) { | ||
@@ -88,0 +109,0 @@ this._value = this._value.concat(response.value); |
@@ -26,5 +26,7 @@ /** | ||
private _packageVersion: string; | ||
private _providerName: string; | ||
constructor(packageVersion: string) { | ||
constructor(packageVersion: string, providerName?: string) { | ||
this._packageVersion = packageVersion; | ||
this._providerName = providerName; | ||
} | ||
@@ -47,2 +49,7 @@ | ||
if (this._providerName) { | ||
const providerVersion: string = `${this._providerName}/${this._packageVersion}`; | ||
headerParts.push(providerVersion); | ||
} | ||
// Package version | ||
@@ -49,0 +56,0 @@ const packageVersion: string = `mgt/${this._packageVersion}`; |
@@ -11,2 +11,2 @@ /** | ||
export const PACKAGE_VERSION = '2.1.0'; | ||
export const PACKAGE_VERSION = '2.2.0'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1029805
7408
16815
1
+ Addedidb@6.1.5(transitive)
- Removedidb@5.0.8(transitive)
Updatedidb@^6.0.0