@microsoft/mgt-element
Advanced tools
Comparing version 2.2.0-preview.3f85553 to 2.2.0-preview.43b849f
@@ -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(); | ||
@@ -227,8 +232,11 @@ } | ||
const provider = Providers.globalProvider; | ||
if (provider.state == ProviderState.SignedOut) { | ||
if (!provider) { | ||
return Promise.resolve(); | ||
} | ||
if (provider.state === ProviderState.SignedOut) { | ||
// Signed out, clear the component state | ||
this.clearState(); | ||
return Promise.resolve(); | ||
return; | ||
} | ||
else if (provider.state == ProviderState.Loading) { | ||
else if (provider.state === ProviderState.Loading) { | ||
// The provider state is indeterminate. Do nothing. | ||
@@ -273,2 +281,11 @@ return Promise.resolve(); | ||
} | ||
handleProviderUpdates() { | ||
this.requestStateUpdate(); | ||
} | ||
handleActiveAccountUpdates() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
this.clearState(); | ||
this.requestStateUpdate(); | ||
}); | ||
} | ||
handleLocalizationChanged() { | ||
@@ -275,0 +292,0 @@ LocalizationHelper.updateStringsForTag(this.tagName, this.strings); |
@@ -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 { |
@@ -124,3 +124,3 @@ /** | ||
new TelemetryHandler(), | ||
new SdkVersionMiddleware(PACKAGE_VERSION), | ||
new SdkVersionMiddleware(PACKAGE_VERSION, provider.name), | ||
new HTTPMessageHandler() | ||
@@ -127,0 +127,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 |
@@ -29,2 +29,3 @@ /** | ||
private _loginChangedDispatcher; | ||
private _activeAccountChangedDispatcher; | ||
/** | ||
@@ -38,2 +39,9 @@ * returns state of Provider | ||
get state(): ProviderState; | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name(): string; | ||
constructor(); | ||
@@ -76,2 +84,36 @@ /** | ||
/** | ||
* Returns all signed in accounts. | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
getAllAccounts?(): 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 +137,10 @@ * | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged { | ||
} | ||
/** | ||
* loginChangedEvent | ||
@@ -139,2 +189,11 @@ * | ||
} | ||
/** | ||
* Account details | ||
* | ||
* @export | ||
*/ | ||
export declare type IProviderAccount = { | ||
username?: string; | ||
id: string; | ||
}; | ||
//# sourceMappingURL=IProvider.d.ts.map |
@@ -19,2 +19,3 @@ /** | ||
this._loginChangedDispatcher = new EventDispatcher(); | ||
this._activeAccountChangedDispatcher = new EventDispatcher(); | ||
this._state = ProviderState.Loading; | ||
@@ -33,2 +34,11 @@ } | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
get name() { | ||
return 'MgtIProvider'; | ||
} | ||
/** | ||
* sets state of Provider and fires loginchangedDispatcher | ||
@@ -64,2 +74,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 +111,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 @@ * |
@@ -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 @@ /** |
@@ -114,2 +114,10 @@ /** | ||
isEnabled: true | ||
}, | ||
files: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
fileLists: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
} | ||
@@ -144,3 +152,8 @@ }; | ||
} | ||
return (yield this.getDb()).get(this.store, key); | ||
try { | ||
return (yield this.getDb()).get(this.store, key); | ||
} | ||
catch (e) { | ||
return null; | ||
} | ||
}); | ||
@@ -161,3 +174,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; | ||
} | ||
}); | ||
@@ -176,3 +194,8 @@ } | ||
} | ||
(yield this.getDb()).clear(this.store); | ||
try { | ||
(yield this.getDb()).clear(this.store); | ||
} | ||
catch (e) { | ||
return; | ||
} | ||
}); | ||
@@ -191,3 +214,3 @@ } | ||
if (this.schema.stores.hasOwnProperty(storeName)) { | ||
db.createObjectStore(storeName); | ||
db.objectStoreNames.contains(storeName) || db.createObjectStore(storeName); | ||
} | ||
@@ -194,0 +217,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); |
@@ -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}`; |
{ | ||
"name": "@microsoft/mgt-element", | ||
"version": "2.2.0-preview.3f85553", | ||
"version": "2.2.0-preview.43b849f", | ||
"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(); | ||
@@ -234,7 +239,11 @@ } | ||
if (provider.state == ProviderState.SignedOut) { | ||
if (!provider) { | ||
return Promise.resolve(); | ||
} | ||
if (provider.state === ProviderState.SignedOut) { | ||
// Signed out, clear the component state | ||
this.clearState(); | ||
return Promise.resolve(); | ||
} else if (provider.state == ProviderState.Loading) { | ||
return; | ||
} else if (provider.state === ProviderState.Loading) { | ||
// The provider state is indeterminate. Do nothing. | ||
@@ -283,2 +292,11 @@ return Promise.resolve(); | ||
private handleProviderUpdates() { | ||
this.requestStateUpdate(); | ||
} | ||
private async handleActiveAccountUpdates() { | ||
this.clearState(); | ||
this.requestStateUpdate(); | ||
} | ||
private handleLocalizationChanged() { | ||
@@ -285,0 +303,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'; | ||
} | ||
} |
@@ -31,2 +31,3 @@ /** | ||
private _loginChangedDispatcher = new EventDispatcher<LoginChangedEvent>(); | ||
private _activeAccountChangedDispatcher = new EventDispatcher<ActiveAccountChanged>(); | ||
/** | ||
@@ -43,2 +44,12 @@ * returns state of Provider | ||
/** | ||
* Name used for analytics | ||
* | ||
* @readonly | ||
* @memberof IProvider | ||
*/ | ||
public get name() { | ||
return 'MgtIProvider'; | ||
} | ||
constructor() { | ||
@@ -97,2 +108,49 @@ this._state = ProviderState.Loading; | ||
/** | ||
* Returns all signed in accounts. | ||
* | ||
* @return {*} {any[]} | ||
* @memberof IProvider | ||
*/ | ||
public getAllAccounts?(): 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 +178,9 @@ * | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged {} | ||
/** | ||
* loginChangedEvent | ||
@@ -166,1 +231,11 @@ * | ||
} | ||
/** | ||
* Account details | ||
* | ||
* @export | ||
*/ | ||
export type IProviderAccount = { | ||
username?: string; | ||
id: 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; | ||
} | ||
@@ -170,2 +185,10 @@ | ||
isEnabled: true | ||
}, | ||
files: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
}, | ||
fileLists: { | ||
invalidationPeriod: null, | ||
isEnabled: true | ||
} | ||
@@ -287,4 +310,7 @@ }; | ||
} | ||
return (await this.getDb()).get(this.store, key); | ||
try { | ||
return (await this.getDb()).get(this.store, key); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
@@ -304,4 +330,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; | ||
} | ||
} | ||
@@ -319,4 +348,7 @@ | ||
} | ||
(await this.getDb()).clear(this.store); | ||
try { | ||
(await this.getDb()).clear(this.store); | ||
} catch (e) { | ||
return; | ||
} | ||
} | ||
@@ -336,3 +368,3 @@ | ||
if (this.schema.stores.hasOwnProperty(storeName)) { | ||
db.createObjectStore(storeName); | ||
db.objectStoreNames.contains(storeName) || db.createObjectStore(storeName); | ||
} | ||
@@ -339,0 +371,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}`; |
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
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
1028046
7361
16815