Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/mgt-element

Package Overview
Dependencies
Maintainers
2
Versions
831
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/mgt-element - npm Package Compare versions

Comparing version 4.0.0-next.mgt-chat.eeea1d6 to 4.0.0-preview.3d893b2

2

dist/es6/components/baseTaskComponent.d.ts

@@ -139,3 +139,3 @@ /**

*/
protected render(): TemplateResult<1 | 2>;
protected render(): TemplateResult;
/**

@@ -142,0 +142,0 @@ * A default loading template.

@@ -55,3 +55,3 @@ /**

*/
forComponent(component: Element | string, version?: string): Graph;
forComponent(component: Element | string): Graph;
/**

@@ -89,3 +89,3 @@ * Returns a new graph request for a specific component

*/
export declare const createFromProvider: (provider: IProvider, version?: string, component?: Element | string) => Graph;
export declare const createFromProvider: (provider: IProvider, version?: string, component?: Element) => Graph;
//# sourceMappingURL=Graph.d.ts.map

@@ -69,4 +69,4 @@ /**

*/
forComponent(component, version) {
const graph = new Graph(this._client, version || this._version);
forComponent(component) {
const graph = new Graph(this._client, this._version);
graph.setComponent(component);

@@ -73,0 +73,0 @@ return graph;

@@ -45,3 +45,3 @@ /**

*/
forComponent(component: Element | string, version?: string): IGraph;
forComponent(component: Element): IGraph;
/**

@@ -48,0 +48,0 @@ * use this method to make calls directly to the Graph.

@@ -20,4 +20,7 @@ /**

export * from './providers/SimpleProvider';
export * from './utils/CacheItem';
export * from './utils/CacheSchema';
export * from './utils/CacheService';
export * from './utils/CacheStore';
export * from './utils/dbListKey';
export * from './utils/EventDispatcher';

@@ -35,3 +38,2 @@ export * from './utils/equals';

export * from './utils/CustomElement';
export * from './utils/Logging';
export * from './utils/registerComponent';

@@ -38,0 +40,0 @@ export { PACKAGE_VERSION } from './utils/version';

@@ -20,4 +20,7 @@ /**

export * from './providers/SimpleProvider';
export * from './utils/CacheItem';
export * from './utils/CacheSchema';
export * from './utils/CacheService';
export * from './utils/CacheStore';
export * from './utils/dbListKey';
export * from './utils/EventDispatcher';

@@ -35,3 +38,2 @@ export * from './utils/equals';

export * from './utils/CustomElement';
export * from './utils/Logging';
export * from './utils/registerComponent';

@@ -38,0 +40,0 @@ export { PACKAGE_VERSION } from './utils/version';

@@ -34,4 +34,4 @@ /**

*/
forComponent(component: MgtBaseComponent | string): MockGraph;
forComponent(component: MgtBaseComponent): MockGraph;
}
//# sourceMappingURL=MockGraph.d.ts.map

@@ -223,3 +223,2 @@ /**

export interface ActiveAccountChanged {
detail: IProviderAccount;
}

@@ -233,3 +232,2 @@ /**

export interface LoginChangedEvent {
detail: ProviderState;
}

@@ -236,0 +234,0 @@ /**

@@ -165,3 +165,3 @@ /**

this._state = state;
this._loginChangedDispatcher.fire({ detail: this._state });
this._loginChangedDispatcher.fire({});
}

@@ -195,3 +195,3 @@ }

setActiveAccount(user) {
this.fireActiveAccountChanged({ detail: user });
this.fireActiveAccountChanged();
}

@@ -221,4 +221,4 @@ /**

*/
fireActiveAccountChanged(account) {
this._activeAccountChangedDispatcher.fire(account);
fireActiveAccountChanged() {
this._activeAccountChangedDispatcher.fire({});
}

@@ -225,0 +225,0 @@ /**

@@ -8,10 +8,5 @@ /**

import { CacheStore } from './CacheStore';
import { CacheSchema } from './CacheSchema';
import { CacheItem } from './CacheItem';
/**
* Localstorage key for storing names of cache databases
*
* @type {string}
*
*/
export declare const dbListKey = "mgt-db-list";
/**
* Holds the cache options for cache store

@@ -93,9 +88,2 @@ *

fileLists: CacheOptions;
/**
* Cache options for conversation store
*
* @type {CacheOptions}
* @memberof CacheConfig
*/
conversation: CacheOptions;
}

@@ -172,56 +160,2 @@ /**

}
export interface Index {
name: string;
field: string;
}
/**
* Represents organization for a cache
*
* @export
* @interface CacheSchema
*/
export interface CacheSchema {
/**
* version number of cache, useful for upgrading
*
* @type {number}
* @memberof CacheSchema
*/
version: number;
/**
* name of the cache
*
* @type {string}
* @memberof CacheSchema
*/
name: string;
/**
* list of stores in the cache
*
* @type {{ [name: string]: CacheSchemaStore }}
* @memberof CacheSchema
*/
stores: Record<string, string>;
/**
* Optional field to define indexed fields on a per store basis
* K is the name of the store for which the indexes should be applied
* T is the names of the fields on the stored data to be indexed
*/
indexes?: Record<string, Index[]>;
}
/**
* item that is stored in cache
*
* @export
* @interface CacheItem
*/
export interface CacheItem {
/**
* date and time that item was retrieved from api/stored in cache
*
* @type {number}
* @memberof CacheItem
*/
timeCached?: number;
}
//# sourceMappingURL=CacheService.d.ts.map

@@ -19,11 +19,4 @@ /**

import { CacheStore } from './CacheStore';
import { error } from './Logging';
import { dbListKey } from './dbListKey';
/**
* Localstorage key for storing names of cache databases
*
* @type {string}
*
*/
export const dbListKey = 'mgt-db-list';
/**
* class in charge of managing all the caches and their stores

@@ -73,3 +66,3 @@ *

delReq.onerror = () => {
error(`${delReq.error.name} occurred deleting cache: ${x}`, delReq.error.message);
console.error(`🦒: ${delReq.error.name} occurred deleting cache: ${x}`, delReq.error.message);
reject();

@@ -165,8 +158,4 @@ };

isEnabled: true
},
conversation: {
invalidationPeriod: 5 * 24 * 60 * 60 * 1000,
isEnabled: true
}
};
//# sourceMappingURL=CacheService.js.map

@@ -7,4 +7,4 @@ /**

*/
import { IDBPObjectStore } from 'idb';
import { CacheItem, CacheSchema } from './CacheService';
import { CacheItem } from './CacheItem';
import { CacheSchema } from './CacheSchema';
/**

@@ -27,12 +27,4 @@ * Represents a store in the cache

*/
getValue(key: string): Promise<T | null>;
getValue(key: string): Promise<T>;
/**
* removes a value from the cache for the given key
*
* @param {string} key
* @returns {Promise<void>}
* @memberof Cache
*/
delete(key: string): Promise<void>;
/**
* inserts value into cache for the given key

@@ -58,9 +50,3 @@ *

private getDb;
queryDb(indexName: string, query: IDBKeyRange | IDBValidKey): Promise<T[]>;
/**
* Helper function to get a wrapping transaction for an action function
* @param action a function that takes an object store uses it to make changes to the cache
*/
transaction(action: (store: IDBPObjectStore<unknown, [string], string, 'readwrite'>) => Promise<void>): Promise<void>;
}
//# sourceMappingURL=CacheStore.d.ts.map

@@ -18,3 +18,3 @@ /**

import { Providers } from '../providers/Providers';
import { dbListKey } from './CacheService';
import { dbListKey } from './dbListKey';
/**

@@ -56,23 +56,2 @@ * Represents a store in the cache

/**
* removes a value from the cache for the given key
*
* @param {string} key
* @returns {Promise<void>}
* @memberof Cache
*/
delete(key) {
return __awaiter(this, void 0, void 0, function* () {
if (!window.indexedDB) {
return;
}
try {
const db = yield this.getDb();
return db.delete(this.store, key);
}
catch (e) {
return;
}
});
}
/**
* inserts value into cache for the given key

@@ -134,4 +113,3 @@ *

// eslint-disable-next-line @typescript-eslint/no-unused-vars
upgrade: (db, _oldVersion, _newVersion, transaction) => {
var _a, _b;
upgrade: (db, _oldVersion, _newVersion, _transaction) => {
const dbArray = JSON.parse(localStorage.getItem(dbListKey)) || [];

@@ -143,18 +121,5 @@ if (!dbArray.includes(dbName)) {

for (const storeName in this.schema.stores) {
if (Object.prototype.hasOwnProperty.call(this.schema.stores, storeName)) {
const indexes = (_b = (_a = this.schema.indexes) === null || _a === void 0 ? void 0 : _a[storeName]) !== null && _b !== void 0 ? _b : [];
if (!db.objectStoreNames.contains(storeName)) {
const objectStore = db.createObjectStore(storeName);
indexes.forEach(i => {
objectStore.createIndex(i.name, i.field);
});
}
else {
const store = transaction.objectStore(storeName);
indexes.forEach(i => {
if (store && !store.indexNames.contains(i.name)) {
store.createIndex(i.name, i.field);
}
});
}
if (Object.prototype.hasOwnProperty.call(this.schema.stores, storeName) &&
!db.objectStoreNames.contains(storeName)) {
db.createObjectStore(storeName);
}

@@ -167,22 +132,3 @@ }

}
queryDb(indexName, query) {
return __awaiter(this, void 0, void 0, function* () {
const db = yield this.getDb();
return (yield db.getAllFromIndex(this.store, indexName, query));
});
}
/**
* Helper function to get a wrapping transaction for an action function
* @param action a function that takes an object store uses it to make changes to the cache
*/
transaction(action) {
return __awaiter(this, void 0, void 0, function* () {
const db = yield this.getDb();
const tx = db.transaction(this.store, 'readwrite');
const store = tx.objectStore(this.store);
yield action(store);
yield tx.done;
});
}
}
//# sourceMappingURL=CacheStore.js.map

@@ -9,3 +9,2 @@ /**

import { customElementHelper } from '../components/customElementHelper';
import { error } from './Logging';
/**

@@ -28,3 +27,4 @@ * This is a wrapper decorator for `customElement` from `lit`

return (classOrDescriptor) => {
error(`Tag name ${mgtTagName} is already defined using class ${mgtElement.name} version ${version(mgtElement)}\n`, `Currently registering class ${classOrDescriptor.name} with version ${version(classOrDescriptor)}\n`, 'Please use the disambiguation feature to define a unique tag name for this component see: https://github.com/microsoftgraph/microsoft-graph-toolkit/tree/main/packages/mgt-components#disambiguation');
// eslint-disable-next-line no-console
console.error(`🦒: Tag name ${mgtTagName} is already defined using class ${mgtElement.name} version ${version(mgtElement)}\n`, `Currently registering class ${classOrDescriptor.name} with version ${version(classOrDescriptor)}\n`, 'Please use the disambiguation feature to define a unique tag name for this component see: https://github.com/microsoftgraph/microsoft-graph-toolkit/tree/main/packages/mgt-components#disambiguation');
return classOrDescriptor;

@@ -31,0 +31,0 @@ };

@@ -7,3 +7,3 @@ /**

*/
export declare const PACKAGE_VERSION = "4.0.0-next.mgt-chat.eeea1d6";
export declare const PACKAGE_VERSION = "4.0.0-preview.3d893b2";
//# sourceMappingURL=version.d.ts.map

@@ -9,3 +9,3 @@ /**

// ANY CHANGES WILL BE LOST DURING BUILD
export const PACKAGE_VERSION = '4.0.0-next.mgt-chat.eeea1d6';
export const PACKAGE_VERSION = '4.0.0-preview.3d893b2';
//# sourceMappingURL=version.js.map
{
"name": "@microsoft/mgt-element",
"version": "4.0.0-next.mgt-chat.eeea1d6",
"version": "4.0.0-preview.3d893b2",
"description": "Microsoft Graph Toolkit base classes",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/microsoftgraph/microsoft-graph-toolkit",

@@ -92,4 +92,4 @@ /**

*/
public forComponent(component: Element | string, version?: string): Graph {
const graph = new Graph(this._client, version || this._version);
public forComponent(component: Element | string): Graph {
const graph = new Graph(this._client, this._version);
graph.setComponent(component);

@@ -151,3 +151,3 @@ return graph;

*/
export const createFromProvider = (provider: IProvider, version?: string, component?: Element | string): Graph => {
export const createFromProvider = (provider: IProvider, version?: string, component?: Element): Graph => {
const middleware: Middleware[] = [

@@ -154,0 +154,0 @@ new AuthenticationHandler(provider),

@@ -50,3 +50,3 @@ /**

*/
forComponent(component: Element | string, version?: string): IGraph;
forComponent(component: Element): IGraph;

@@ -53,0 +53,0 @@ /**

@@ -24,4 +24,7 @@ /**

export * from './utils/CacheItem';
export * from './utils/CacheSchema';
export * from './utils/CacheService';
export * from './utils/CacheStore';
export * from './utils/dbListKey';
export * from './utils/EventDispatcher';

@@ -39,3 +42,2 @@ export * from './utils/equals';

export * from './utils/CustomElement';
export * from './utils/Logging';
export * from './utils/registerComponent';

@@ -42,0 +44,0 @@

@@ -65,3 +65,3 @@ /**

// eslint-disable-next-line @typescript-eslint/no-unused-vars
public forComponent(component: MgtBaseComponent | string): MockGraph {
public forComponent(component: MgtBaseComponent): MockGraph {
// The purpose of the forComponent pattern is to update the headers of any outgoing Graph requests.

@@ -68,0 +68,0 @@ // The MockGraph isn't making real Graph requests, so we can simply no-op and return the same instance.

@@ -196,3 +196,3 @@ /**

this._state = state;
this._loginChangedDispatcher.fire({ detail: this._state });
this._loginChangedDispatcher.fire({});
}

@@ -260,3 +260,3 @@ }

public setActiveAccount?(user: IProviderAccount) {
this.fireActiveAccountChanged({ detail: user });
this.fireActiveAccountChanged();
}

@@ -289,4 +289,4 @@

*/
private fireActiveAccountChanged(account: { detail: IProviderAccount }) {
this._activeAccountChangedDispatcher.fire(account);
private fireActiveAccountChanged() {
this._activeAccountChangedDispatcher.fire({});
}

@@ -323,5 +323,3 @@

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ActiveAccountChanged {
detail: IProviderAccount;
}
export interface ActiveAccountChanged {}
/**

@@ -334,5 +332,3 @@ * loginChangedEvent

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface LoginChangedEvent {
detail: ProviderState;
}
export interface LoginChangedEvent {}

@@ -339,0 +335,0 @@ /**

@@ -11,14 +11,7 @@ /**

import { CacheStore } from './CacheStore';
import { error } from './Logging';
import { CacheSchema } from './CacheSchema';
import { CacheItem } from './CacheItem';
import { dbListKey } from './dbListKey';
/**
* Localstorage key for storing names of cache databases
*
* @type {string}
*
*/
export const dbListKey = 'mgt-db-list';
/**
* Holds the cache options for cache store

@@ -103,9 +96,2 @@ *

fileLists: CacheOptions;
/**
* Cache options for conversation store
*
* @type {CacheOptions}
* @memberof CacheConfig
*/
conversation: CacheOptions;
}

@@ -185,3 +171,3 @@

delReq.onerror = () => {
error(`${delReq.error.name} occurred deleting cache: ${x}`, delReq.error.message);
console.error(`🦒: ${delReq.error.name} occurred deleting cache: ${x}`, delReq.error.message);
reject();

@@ -241,6 +227,2 @@ };

isEnabled: true
},
conversation: {
invalidationPeriod: 5 * 24 * 60 * 60 * 1000,
isEnabled: true
}

@@ -288,58 +270,1 @@ };

}
export interface Index {
name: string;
field: string;
}
/**
* Represents organization for a cache
*
* @export
* @interface CacheSchema
*/
export interface CacheSchema {
/**
* version number of cache, useful for upgrading
*
* @type {number}
* @memberof CacheSchema
*/
version: number;
/**
* name of the cache
*
* @type {string}
* @memberof CacheSchema
*/
name: string;
/**
* list of stores in the cache
*
* @type {{ [name: string]: CacheSchemaStore }}
* @memberof CacheSchema
*/
stores: Record<string, string>;
/**
* Optional field to define indexed fields on a per store basis
* K is the name of the store for which the indexes should be applied
* T is the names of the fields on the stored data to be indexed
*/
indexes?: Record<string, Index[]>;
}
/**
* item that is stored in cache
*
* @export
* @interface CacheItem
*/
export interface CacheItem {
/**
* date and time that item was retrieved from api/stored in cache
*
* @type {number}
* @memberof CacheItem
*/
timeCached?: number;
}

@@ -8,5 +8,7 @@ /**

import { IDBPObjectStore, openDB } from 'idb';
import { openDB } from 'idb';
import { Providers } from '../providers/Providers';
import { CacheItem, CacheSchema, Index, dbListKey } from './CacheService';
import { dbListKey } from './dbListKey';
import { CacheItem } from './CacheItem';
import { CacheSchema } from './CacheSchema';

@@ -40,3 +42,3 @@ /**

*/
public async getValue(key: string): Promise<T | null> {
public async getValue(key: string): Promise<T> {
if (!window.indexedDB) {

@@ -54,21 +56,2 @@ return null;

/**
* removes a value from the cache for the given key
*
* @param {string} key
* @returns {Promise<void>}
* @memberof Cache
*/
public async delete(key: string): Promise<void> {
if (!window.indexedDB) {
return;
}
try {
const db = await this.getDb();
return db.delete(this.store, key);
} catch (e) {
return;
}
}
/**
* inserts value into cache for the given key

@@ -124,3 +107,3 @@ *

// eslint-disable-next-line @typescript-eslint/no-unused-vars
upgrade: (db, _oldVersion, _newVersion, transaction) => {
upgrade: (db, _oldVersion, _newVersion, _transaction) => {
const dbArray: string[] = (JSON.parse(localStorage.getItem(dbListKey)) as string[]) || [];

@@ -132,17 +115,7 @@ if (!dbArray.includes(dbName)) {

for (const storeName in this.schema.stores) {
if (Object.prototype.hasOwnProperty.call(this.schema.stores, storeName)) {
const indexes: Index[] = this.schema.indexes?.[storeName] ?? [];
if (!db.objectStoreNames.contains(storeName)) {
const objectStore = db.createObjectStore(storeName);
indexes.forEach(i => {
objectStore.createIndex(i.name, i.field);
});
} else {
const store = transaction.objectStore(storeName);
indexes.forEach(i => {
if (store && !store.indexNames.contains(i.name)) {
store.createIndex(i.name, i.field);
}
});
}
if (
Object.prototype.hasOwnProperty.call(this.schema.stores, storeName) &&
!db.objectStoreNames.contains(storeName)
) {
db.createObjectStore(storeName);
}

@@ -154,19 +127,2 @@ }

}
public async queryDb(indexName: string, query: IDBKeyRange | IDBValidKey): Promise<T[]> {
const db = await this.getDb();
return (await db.getAllFromIndex(this.store, indexName, query)) as T[];
}
/**
* Helper function to get a wrapping transaction for an action function
* @param action a function that takes an object store uses it to make changes to the cache
*/
public async transaction(action: (store: IDBPObjectStore<unknown, [string], string, 'readwrite'>) => Promise<void>) {
const db = await this.getDb();
const tx = db.transaction(this.store, 'readwrite');
const store = tx.objectStore(this.store);
await action(store);
await tx.done;
}
}

@@ -10,3 +10,2 @@ /**

import { customElementHelper } from '../components/customElementHelper';
import { error } from './Logging';

@@ -30,4 +29,5 @@ /**

return (classOrDescriptor: CustomElementConstructor) => {
error(
`Tag name ${mgtTagName} is already defined using class ${mgtElement.name} version ${version(mgtElement)}\n`,
// eslint-disable-next-line no-console
console.error(
`🦒: Tag name ${mgtTagName} is already defined using class ${mgtElement.name} version ${version(mgtElement)}\n`,
`Currently registering class ${classOrDescriptor.name} with version ${version(classOrDescriptor)}\n`,

@@ -34,0 +34,0 @@ 'Please use the disambiguation feature to define a unique tag name for this component see: https://github.com/microsoftgraph/microsoft-graph-toolkit/tree/main/packages/mgt-components#disambiguation'

@@ -11,2 +11,2 @@ /**

export const PACKAGE_VERSION = '4.0.0-next.mgt-chat.eeea1d6';
export const PACKAGE_VERSION = '4.0.0-preview.3d893b2';

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc