From eb5dd53f38054ad44d103d389301a089d79b8c71 Mon Sep 17 00:00:00 2001 From: David Fahlander Date: Thu, 17 Nov 2016 13:39:51 +0100 Subject: [PATCH 1/2] Dexie bundles its d.ts file in its own npm package and should not have old versions on DefinitelyTyped. --- dexie/dexie-tests.ts | 25 ---- dexie/index.d.ts | 323 ------------------------------------------- dexie/tsconfig.json | 19 --- 3 files changed, 367 deletions(-) delete mode 100644 dexie/dexie-tests.ts delete mode 100644 dexie/index.d.ts delete mode 100644 dexie/tsconfig.json diff --git a/dexie/dexie-tests.ts b/dexie/dexie-tests.ts deleted file mode 100644 index 7eb6a75dbb..0000000000 --- a/dexie/dexie-tests.ts +++ /dev/null @@ -1,25 +0,0 @@ -import Dexie from "dexie"; - -interface IFriend { - id?: number, - name?: string, - age?: number -} - -class MyDB extends Dexie { - friends: Dexie.Table; - constructor() { - super("MyDB"); - this.version(1).stores({ - friends: "++id,name,age" - }); - } -} - -var db = new MyDB(); - -db.friends.add({name: "Kalle", age: 23}).then(()=>{ - db.friends.where('age').below(30).count(count => { - console.log("Num yound friends: " + count); - }); -}); diff --git a/dexie/index.d.ts b/dexie/index.d.ts deleted file mode 100644 index 720d38fb29..0000000000 --- a/dexie/index.d.ts +++ /dev/null @@ -1,323 +0,0 @@ -// Type definitions for Dexie v1.3.1 -// Project: https://github.com/dfahlander/Dexie.js -// Definitions by: David Fahlander -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface Thenable { - then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Thenable; - then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Thenable; - then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Thenable; - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable; -} - -declare type IndexableType = string | number | Date | Array; - -declare class Dexie { - constructor(databaseName: string); - - constructor(databaseName: string, options: { addons: Array<(db: Dexie) => void> }); - - name: string; - tables: Dexie.Table[]; - verno: number; - - static addons: Array<(db: Dexie) => void>; - static version: number; - - static getDatabaseNames(): Dexie.Promise>; - - static getDatabaseNames(onFulfilled: (value: Array) => Thenable): Dexie.Promise; - - static getDatabaseNames(onFulfilled: (value: Array) => U): Dexie.Promise; - - static getByKeyPath(obj: Object, keyPath: string): any; - - static setByKeyPath(obj: Object, keyPath: string, value: any): void; - - static delByKeyPath(obj: Object, keyPath: string): void; - - static shallowClone(obj: Object): Object; - - static deepClone(obj: Object): Object; - - static delete(databaseName : string): Dexie.Promise; - - static exists(databaseName : string): Dexie.Promise; - - version(versionNumber: Number): Dexie.Version - - on: { - (eventName: string, subscriber: () => any): void; - (eventName: string, subscriber: () => any, bSticky: boolean): void; - ready: Dexie.DexieOnReadyEvent; - error: Dexie.DexieErrorEvent; - populate: Dexie.DexieEvent; - blocked: Dexie.DexieEvent; - versionchange: Dexie.DexieVersionChangeEvent; - } - - open(): Dexie.Promise; - - table(tableName: string): Dexie.Table; - - table(tableName: string): Dexie.Table; - - table(tableName: string): Dexie.Table; - - transaction(mode: string, table: Dexie.Table, scope: () => Thenable): Dexie.Promise; - - transaction(mode: string, table: Dexie.Table, table2: Dexie.Table, scope: () => Thenable): Dexie.Promise; - - transaction(mode: string, table: Dexie.Table, table2: Dexie.Table, table3: Dexie.Table, scope: () => Thenable): Dexie.Promise; - - transaction(mode: string, tables: Dexie.Table[], scope: () => Thenable): Dexie.Promise; - - transaction(mode: string, table: Dexie.Table, scope: () => U): Dexie.Promise; - - transaction(mode: string, table: Dexie.Table, table2: Dexie.Table, scope: () => U): Dexie.Promise; - - transaction(mode: string, table: Dexie.Table, table2: Dexie.Table, table3: Dexie.Table, scope: () => U): Dexie.Promise; - - transaction(mode: string, tables: Dexie.Table[], scope: () => U): Dexie.Promise; - - close(): void; - - delete(): Dexie.Promise; - - exists(name : string) : Dexie.Promise; - - isOpen(): boolean; - - hasFailed(): boolean; - - backendDB(): IDBDatabase; - - vip(scopeFunction: () => U): U; -} - -declare namespace Dexie { - - class Promise implements Thenable { - constructor(callback: (resolve: (value?: Thenable) => void, reject: (error?: any) => void) => void); - - constructor(callback: (resolve: (value?: R) => void, reject: (error?: any) => void) => void); - - then(onFulfilled: (value: R) => Thenable, onRejected: (error: any) => Thenable): Promise; - - then(onFulfilled: (value: R) => Thenable, onRejected?: (error: any) => U): Promise; - - then(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable): Promise; - - then(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Promise; - - catch(onRejected: (error: any) => Thenable): Promise; - - catch(onRejected: (error: any) => U): Promise; - - catch(ExceptionType: Function, onRejected: (error: any) => Promise): Promise; - - catch(ExceptionType: Function, onRejected: (error: any) => U): Promise; - - catch(errorName: string, onRejected: (error: any) => Promise): Promise; - - catch(errorName: string, onRejected: (error: any) => U): Promise; - - finally(onFinally: () => any): Promise; - - onuncatched: () => any; - } - - namespace Promise { - function resolve(value?: Thenable): Promise; - - function resolve(value?: R): Promise; - - function reject(error: any): Promise; - - function all(promises: Thenable[]): Promise; - - function all(...promises: Thenable[]): Promise; - - function race(promises: Thenable[]): Promise; - - function newPSD(scope: () => R): R; - - var PSD: any; - - var on: { - (eventName: string, subscriber: (...args: any[]) => any): void; - error: DexieErrorEvent; - } - } - - - interface Version { - stores(schema: { [key: string]: string }): Version; - upgrade(fn: (trans: Transaction) => void): Version; - } - - interface Transaction { - active: boolean; - db: Dexie; - mode: string; - idbtrans: IDBTransaction; - tables: { [type: string]: Table }; - storeNames: Array; - on: { - (eventName: string, subscriber: () => any): void; - complete: DexieEvent; - abort: DexieEvent; - error: DexieEvent; - } - abort(): void; - table(tableName: string): Table; - table(tableName: string): Table; - table(tableName: string): Table; - } - - interface DexieEvent { - subscribe(fn: () => any): void; - unsubscribe(fn: () => any): void; - fire(): any; - } - - interface DexieErrorEvent { - subscribe(fn: (error: any) => any): void; - unsubscribe(fn: (error: any) => any): void; - fire(error: any): any; - } - - interface DexieVersionChangeEvent { - subscribe(fn: (event: IDBVersionChangeEvent) => any): void; - unsubscribe(fn: (event: IDBVersionChangeEvent) => any): void; - fire(event: IDBVersionChangeEvent): any; - } - - interface DexieOnReadyEvent { - subscribe(fn: () => any, bSticky: boolean): void; - unsubscribe(fn: () => any): void; - fire(): any; - } - - interface Table { - name: string; - schema: TableSchema; - hook: { - (eventName: string, subscriber: () => any): void; - creating: DexieEvent; - reading: DexieEvent; - updating: DexieEvent; - deleting: DexieEvent; - } - - get(key: Key): Promise; - where(index: string): WhereClause; - - filter(fn: (obj: T) => boolean): Collection; - - count(): Promise; - count(onFulfilled: (value: number) => Thenable): Promise; - count(onFulfilled: (value: number) => U): Promise; - - offset(n: number): Collection; - - limit(n: number): Collection; - - each(callback: (obj: T, cursor: IDBCursor) => any): Promise; - - toArray(): Promise>; - toArray(onFulfilled: (value: Array) => Thenable): Promise; - toArray(onFulfilled: (value: Array) => U): Promise; - - toCollection(): Collection; - orderBy(index: string): Collection; - reverse(): Collection; - mapToClass(constructor: Function): Function; - add(item: T, key?: Key): Promise; - update(key: Key, changes: { [keyPath: string]: any }): Promise; - put(item: T, key?: Key): Promise; - delete(key: Key): Promise; - clear(): Promise; - } - - interface WhereClause { - above(key: IndexableType): Collection; - aboveOrEqual(key: IndexableType): Collection; - anyOf(keys: IndexableType[]): Collection; - anyOf(...keys: IndexableType[]): Collection; - anyOfIgnoreCase(keys: string[]): Collection; - anyOfIgnoreCase(...keys: string[]): Collection; - below(key: IndexableType): Collection; - belowOrEqual(key: IndexableType): Collection; - between(lower: IndexableType, upper: IndexableType, includeLower?: boolean, includeUpper?: boolean): Collection; - equals(key: IndexableType): Collection; - equalsIgnoreCase(key: string): Collection; - inAnyRange(ranges: Array): Collection; - startsWith(key: string): Collection; - startsWithAnyOf(prefixes: string[]): Collection; - startsWithAnyOf(...prefixes: string[]): Collection; - startsWithIgnoreCase(key: string): Collection; - startsWithAnyOfIgnoreCase(prefixes: string[]): Collection; - startsWithAnyOfIgnoreCase(...prefixes: string[]): Collection; - noneOf(keys: Array): Collection; - notEqual(key: IndexableType): Collection; - } - - interface Collection { - and(filter: (x: T) => boolean): Collection; - count(): Promise; - count(onFulfilled: (value: number) => Thenable): Promise; - count(onFulfilled: (value: number) => U): Promise; - distinct(): Collection; - each(callback: (obj: T, cursor: IDBCursor) => any): Promise; - eachKey(callback: (key: Key, cursor: IDBCursor) => any): Promise; - eachUniqueKey(callback: (key: Key, cursor: IDBCursor) => any): Promise; - first(): Promise; - first(onFulfilled: (value: T) => Thenable): Promise; - first(onFulfilled: (value: T) => U): Promise; - keys(): Promise; - keys(onFulfilled: (value: Key[]) => Thenable): Promise; - keys(onFulfilled: (value: Key[]) => U): Promise; - last(): Promise; - last(onFulfilled: (value: T) => Thenable): Promise; - last(onFulfilled: (value: T) => U): Promise; - limit(n: number): Collection; - offset(n: number): Collection; - or(indexOrPrimayKey: string): WhereClause; - reverse(): Collection; - sortBy(keyPath: string): Promise; - sortBy(keyPath: string, onFulfilled: (value: T[]) => Thenable): Promise; - sortBy(keyPath: string, onFulfilled: (value: T[]) => U): Promise; - toArray(): Promise>; - toArray(onFulfilled: (value: Array) => Thenable): Promise; - toArray(onFulfilled: (value: Array) => U): Promise; - uniqueKeys(): Promise; - uniqueKeys(onFulfilled: (value: Key[]) => Thenable): Promise; - uniqueKeys(onFulfilled: (value: Key[]) => U): Promise; - until(filter: (value: T) => boolean, includeStopEntry?: boolean): Collection; - // WriteableCollection: - delete(): Promise; - modify(changes: { [keyPath: string]: any }): Promise; - modify(changeCallback: (obj: T) => void): Promise; - } - - interface TableSchema { - name: string; - primKey: IndexSpec; - indexes: IndexSpec[]; - mappedClass: Function; - } - - interface IndexSpec { - name: string; - keyPath: any; // string | Array - unique: boolean; - multi: boolean; - auto: boolean; - compound: boolean; - src: string; - } -} - -export default Dexie; - diff --git a/dexie/tsconfig.json b/dexie/tsconfig.json deleted file mode 100644 index 5448c02b96..0000000000 --- a/dexie/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "noImplicitAny": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "dexie-tests.ts" - ] -} \ No newline at end of file From 921351b05c3740076c91a9f9b6d2f9701d1ded70 Mon Sep 17 00:00:00 2001 From: David Fahlander Date: Thu, 24 Nov 2016 13:16:02 +0100 Subject: [PATCH 2/2] Added Dexie to notNeededPackages.json --- notNeededPackages.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/notNeededPackages.json b/notNeededPackages.json index 0f32a6dcad..59686d86eb 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -34,6 +34,12 @@ "typingsPackageName": "protractor", "sourceRepoURL": "https://github.com/angular/protractor", "asOfVersion": "4.0.0" + }, + { + "libraryName": "Dexie.js", + "typingsPackageName": "dexie", + "sourceRepoURL": "https://github.com/dfahlander/Dexie.js", + "asOfVersion": "1.3.1" } ] }