@microsoft/mgt-element
Advanced tools
Comparing version 2.2.0-preview.95603a4 to 2.2.0-preview.9d9833e
@@ -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); |
@@ -29,2 +29,3 @@ /** | ||
private _loginChangedDispatcher; | ||
private _activeAccountChangedDispatcher; | ||
/** | ||
@@ -82,4 +83,38 @@ * returns state of Provider | ||
/** | ||
* uses scopes to receive access token | ||
* 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 | ||
* | ||
* @param {...string[]} scopes | ||
@@ -101,2 +136,10 @@ * @returns {Promise<string>} | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged { | ||
} | ||
/** | ||
* loginChangedEvent | ||
@@ -145,2 +188,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; | ||
@@ -72,4 +73,39 @@ } | ||
/** | ||
* uses scopes to receive access token | ||
* 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 | ||
* | ||
* @param {...string[]} scopes | ||
@@ -76,0 +112,0 @@ * @returns {Promise<string>} |
@@ -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 |
@@ -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; | ||
} | ||
}); | ||
@@ -179,0 +202,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); |
{ | ||
"name": "@microsoft/mgt-element", | ||
"version": "2.2.0-preview.95603a4", | ||
"version": "2.2.0-preview.9d9833e", | ||
"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); |
@@ -31,2 +31,3 @@ /** | ||
private _loginChangedDispatcher = new EventDispatcher<LoginChangedEvent>(); | ||
private _activeAccountChangedDispatcher = new EventDispatcher<ActiveAccountChanged>(); | ||
/** | ||
@@ -106,4 +107,51 @@ * returns state of Provider | ||
/** | ||
* uses scopes to receive access token | ||
* 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 | ||
* | ||
* @param {...string[]} scopes | ||
@@ -129,2 +177,9 @@ * @returns {Promise<string>} | ||
/** | ||
* ActiveAccountChanged Event | ||
* | ||
* @export | ||
* @interface ActiveAccountChanged | ||
*/ | ||
export interface ActiveAccountChanged {} | ||
/** | ||
* loginChangedEvent | ||
@@ -175,1 +230,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 @@ |
@@ -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; | ||
} | ||
} | ||
@@ -323,0 +355,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); |
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
1029158
7361
+ Addedidb@6.1.5(transitive)
- Removedidb@5.0.8(transitive)
Updatedidb@^6.0.0