Comparing version 4.0.0-alpha.4 to 4.0.1-alpha.6
@@ -16,4 +16,6 @@ HOW TO CONTRIBUTE | ||
Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie --save` for the app your are developing. | ||
Dexie uses pnpm package manager. Refer to [pnpm.io/installation](https://pnpm.io/installation) for how to install pnpm. | ||
Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie` for the app your are developing. | ||
1. Fork Dexie.js from the web gui on github | ||
@@ -26,18 +28,20 @@ 2. Clone your fork locally by launching a shell/command window and cd to a neutral place (like `~repos/`, `c:\repos` or whatever) | ||
cd dexie | ||
npm install | ||
npm run build | ||
npm link | ||
pnpm install | ||
pnpm run build | ||
npm link # Or yarn link or pnpm link --global depending on what package manager you are using. | ||
``` | ||
3. cd to your app directory and write: | ||
``` | ||
npm link dexie | ||
npm link dexie # Or yarn link dexie / pnpm link dexie depending on your package manager. | ||
``` | ||
Your app's `node_modules/dexie/` is now sym-linked to the Dexie.js clone on your hard drive so any change you do there will propagate to your app. Build dexie.js using `npm run build` or `npm run watch`. The latter will react on any source file change and rebuild the dist files. | ||
Your app's `node_modules/dexie/` is now sym-linked to the Dexie.js clone on your hard drive so any change you do there will propagate to your app. Build dexie.js using `pnpm run build` or `pnpm run watch`. The latter will react on any source file change and rebuild the dist files. | ||
That's it. Now you're up and running to test and commit changes to files under dexie/src/* or dexie/test/* and the changes will instantly affect the app you are developing. | ||
If you're on yarn or pnpm, do the same procedures using yarn link / pnpm link. | ||
Pull requests are more than welcome. Some advices are: | ||
* Run npm test before making a pull request. | ||
* Run pnpm test before making a pull request. | ||
* If you find an issue, a unit test that reproduces it is lovely ;). If you don't know where to put it, put it in `test/tests-misc.js`. We use qunit. Just look at existing tests in `tests-misc.js` to see how they should be written. Tests are transpiled in the build script so you can use ES6 if you like. | ||
@@ -48,4 +52,5 @@ | ||
``` | ||
npm install | ||
npm run build | ||
# To install pnpm, see https://pnpm.io/installation | ||
pnpm install | ||
pnpm run build | ||
``` | ||
@@ -56,3 +61,3 @@ | ||
``` | ||
npm test | ||
pnpm test | ||
``` | ||
@@ -63,3 +68,3 @@ | ||
``` | ||
npm run watch | ||
pnpm run watch | ||
``` |
@@ -7,3 +7,3 @@ /* | ||
* | ||
* Version 4.0.0-alpha.4, Tue May 31 2022 | ||
* Version 4.0.1-alpha.6, Tue Jan 17 2023 | ||
* | ||
@@ -89,3 +89,3 @@ * https://dexie.org | ||
export interface TableHooks<T = any, TKey = IndexableType> extends DexieEventSet { | ||
(eventName: "creating", subscriber: (this: CreatingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => any): void; | ||
(eventName: "creating", subscriber: (this: CreatingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => void | undefined | TKey): void; | ||
(eventName: "reading", subscriber: (obj: T) => T | any): void; | ||
@@ -393,2 +393,3 @@ (eventName: "updating", subscriber: (this: UpdatingHookContext<T, TKey>, modifications: Object, primKey: TKey, obj: T, transaction: Transaction) => any): void; | ||
}) => any): PromiseExtended<void>; | ||
filter<S extends T>(filter: (x: T) => x is S): Collection<S, TKey>; | ||
filter(filter: (x: T) => boolean): Collection<T, TKey>; | ||
@@ -470,5 +471,8 @@ first(): PromiseExtended<T | undefined>; | ||
}; // Common changeSpec for each key | ||
changeSpecs?: { | ||
[keyPath: string]: any; | ||
}[]; // changeSpec per key. | ||
updates?: { | ||
keys: any[]; | ||
changeSpecs: { | ||
[keyPath: string]: any; | ||
}[]; // changeSpec per key. | ||
}; | ||
/** @deprecated Will always get results since 3.1.0-alpha.5 */ | ||
@@ -588,19 +592,10 @@ wantResults?: boolean; | ||
} | ||
export type MethodProps<T> = { | ||
[P in keyof T]: T[P] extends (...args: any[]) => any ? P : never; | ||
}[keyof T]; | ||
export type InsertType<T, TOptionalProperties, TKeyPropNameOrKeyType> = string extends MethodProps<T> ? T : Omit<T, TOptionalProperties extends keyof T ? TKeyPropNameOrKeyType extends keyof T ? MethodProps<T> | TOptionalProperties | TKeyPropNameOrKeyType : MethodProps<T> | TOptionalProperties : MethodProps<T>> & (TOptionalProperties extends keyof T ? TKeyPropNameOrKeyType extends keyof T ? { | ||
[P in (TOptionalProperties | TKeyPropNameOrKeyType)]?: T[P]; | ||
} : { | ||
[P in TOptionalProperties]?: T[P]; | ||
} : {}); | ||
export type IDType<T, TKey> = TKey extends keyof T ? T[TKey] : TKey; | ||
export interface Table<T = any, TKeyPropNameOrKeyType = IndexableType, TOpt = void> { | ||
export interface Table<T = any, TKey = IndexableType, TInsertType = T> { | ||
db: Dexie; | ||
name: string; | ||
schema: TableSchema; | ||
hook: TableHooks<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
hook: TableHooks<T, TKey>; | ||
core: DBCoreTable; | ||
get(key: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<T | undefined>; | ||
get<R>(key: IDType<T, TKeyPropNameOrKeyType>, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
get(key: TKey): PromiseExtended<T | undefined>; | ||
get<R>(key: TKey, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
get(equalityCriterias: { | ||
@@ -612,49 +607,53 @@ [key: string]: any; | ||
}, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>; | ||
where(index: string | string[]): WhereClause<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
where(index: string | string[]): WhereClause<T, TKey>; | ||
where(equalityCriterias: { | ||
[key: string]: any; | ||
}): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
filter(fn: (obj: T) => boolean): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
}): Collection<T, TKey>; | ||
filter(fn: (obj: T) => boolean): Collection<T, TKey>; | ||
count(): PromiseExtended<number>; | ||
count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>; | ||
offset(n: number): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
limit(n: number): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
offset(n: number): Collection<T, TKey>; | ||
limit(n: number): Collection<T, TKey>; | ||
each(callback: (obj: T, cursor: { | ||
key: any; | ||
primaryKey: IDType<T, TKeyPropNameOrKeyType>; | ||
primaryKey: TKey; | ||
}) => any): PromiseExtended<void>; | ||
toArray(): PromiseExtended<Array<T>>; | ||
toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>; | ||
toCollection(): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
orderBy(index: string | string[]): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
reverse(): Collection<T, IDType<T, TKeyPropNameOrKeyType>>; | ||
toCollection(): Collection<T, TKey>; | ||
orderBy(index: string | string[]): Collection<T, TKey>; | ||
reverse(): Collection<T, TKey>; | ||
mapToClass(constructor: Function): Function; | ||
add(item: InsertType<T, TOpt, TKeyPropNameOrKeyType>, key?: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>; | ||
update(key: IDType<T, TKeyPropNameOrKeyType> | T, changes: UpdateSpec<T> | ((obj: T, ctx: { | ||
add(item: TInsertType, key?: TKey): PromiseExtended<TKey>; | ||
update(key: TKey | T, changes: UpdateSpec<T> | ((obj: T, ctx: { | ||
value: any; | ||
primKey: IndexableType; | ||
}) => void | boolean)): PromiseExtended<number>; | ||
put(item: InsertType<T, TOpt, TKeyPropNameOrKeyType>, key?: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>; | ||
delete(key: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<void>; | ||
put(item: TInsertType, key?: TKey): PromiseExtended<TKey>; | ||
delete(key: TKey): PromiseExtended<void>; | ||
clear(): PromiseExtended<void>; | ||
bulkGet(keys: IDType<T, TKeyPropNameOrKeyType>[]): PromiseExtended<(T | undefined)[]>; | ||
bulkAdd<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys: IndexableTypeArrayReadonly, options: { | ||
bulkGet(keys: TKey[]): PromiseExtended<(T | undefined)[]>; | ||
bulkAdd<B extends boolean>(items: readonly TInsertType[], keys: IndexableTypeArrayReadonly, options: { | ||
allKeys: B; | ||
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkAdd<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], options: { | ||
}): PromiseExtended<B extends true ? TKey[] : TKey>; | ||
bulkAdd<B extends boolean>(items: readonly TInsertType[], options: { | ||
allKeys: B; | ||
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkAdd(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys?: IndexableTypeArrayReadonly, options?: { | ||
}): PromiseExtended<B extends true ? TKey[] : TKey>; | ||
bulkAdd(items: readonly TInsertType[], keys?: IndexableTypeArrayReadonly, options?: { | ||
allKeys: boolean; | ||
}): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkPut<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys: IndexableTypeArrayReadonly, options: { | ||
}): PromiseExtended<TKey>; | ||
bulkPut<B extends boolean>(items: readonly TInsertType[], keys: IndexableTypeArrayReadonly, options: { | ||
allKeys: B; | ||
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkPut<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], options: { | ||
}): PromiseExtended<B extends true ? TKey[] : TKey>; | ||
bulkPut<B extends boolean>(items: readonly TInsertType[], options: { | ||
allKeys: B; | ||
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkPut(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys?: IndexableTypeArrayReadonly, options?: { | ||
}): PromiseExtended<B extends true ? TKey[] : TKey>; | ||
bulkPut(items: readonly TInsertType[], keys?: IndexableTypeArrayReadonly, options?: { | ||
allKeys: boolean; | ||
}): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>; | ||
bulkDelete(keys: IDType<T, TKeyPropNameOrKeyType>[]): PromiseExtended<void>; | ||
}): PromiseExtended<TKey>; | ||
bulkUpdate(keysAndChanges: ReadonlyArray<{ | ||
key: TKey; | ||
changes: UpdateSpec<T>; | ||
}>): PromiseExtended<number>; | ||
bulkDelete(keys: TKey[]): PromiseExtended<void>; | ||
} | ||
@@ -1048,2 +1047,23 @@ export interface Version { | ||
} | ||
export type IsStrictlyAny<T> = (T extends never ? true : false) extends false ? false : true; | ||
/** Extract the union of literal method names in T | ||
*/ | ||
export type MethodProps<T> = { | ||
[P in keyof T]: IsStrictlyAny<T[P]> extends true ? never // Plain property of type any (not method) | ||
: T[P] extends (...args: any[]) => any ? P // a function (method) | ||
: never; | ||
}[keyof T]; | ||
/** Default insert type of T is a subset of T where: | ||
* * given optional props (such as an auto-generated primary key) are made optional | ||
* * methods are omitted | ||
*/ | ||
export type InsertType<T, OptionalProps extends keyof T> = Omit<T, OptionalProps | MethodProps<T>> & { | ||
[P in OptionalProps]?: T[P]; | ||
}; | ||
/** IDType extract the actual type of the primary key: | ||
* * If TKey is a literal type that names a property of T, extract the type using T[TKey] | ||
* * Else, use TKey as is. | ||
*/ | ||
export type IDType<T, TKeyPropNameOrKeyType> = IsStrictlyAny<T> extends true ? TKeyPropNameOrKeyType : TKeyPropNameOrKeyType extends string ? TKeyPropNameOrKeyType extends keyof T ? T[TKeyPropNameOrKeyType] : TKeyPropNameOrKeyType : TKeyPropNameOrKeyType; | ||
export type EntityTable<T, TKeyPropName extends keyof T = never, TInsertType = InsertType<T, TKeyPropName>> = Table<T, IDType<T, TKeyPropName>, TInsertType>; | ||
export declare var Dexie: DexieConstructor; | ||
@@ -1050,0 +1070,0 @@ export interface _Table<T, TKey> extends Table<T, TKey> { |
{ | ||
"name": "dexie", | ||
"version": "4.0.0-alpha.4", | ||
"version": "4.0.1-alpha.6", | ||
"description": "A Minimalistic Wrapper for IndexedDB", | ||
@@ -35,2 +35,3 @@ "main": "dist/dexie.js", | ||
"typings": "dist/dexie.d.ts", | ||
"packageManager": "^pnpm@7.9.5", | ||
"jspm": { | ||
@@ -63,11 +64,2 @@ "format": "cjs", | ||
}, | ||
"scripts": { | ||
"build": "just-build", | ||
"watch": "just-build --watch", | ||
"clean": "rm -rf tools/tmp && rm dist/*.js && rm dist/*.map && rm dist/*.ts && rm dist/*.mjs", | ||
"test": "npm run build && npm run test:typings && npm run test:unit", | ||
"test:unit": "karma start test/karma.conf.js --single-run", | ||
"test:typings": "tsc -p test/typings-test/", | ||
"test:debug": "karma start test/karma.conf.js --log-level debug" | ||
}, | ||
"just-build": { | ||
@@ -119,9 +111,6 @@ "default": [ | ||
}, | ||
"engines": { | ||
"node": ">=6.0" | ||
}, | ||
"homepage": "https://dexie.org", | ||
"devDependencies": { | ||
"dts-bundle-generator": "^5.9.0", | ||
"just-build": "^0.9.19", | ||
"just-build": "^0.9.24", | ||
"karma": "^6.1.1", | ||
@@ -148,3 +137,12 @@ "karma-browserstack-launcher": "^1.5.2", | ||
"uglify-js": "^3.9.2" | ||
}, | ||
"scripts": { | ||
"build": "just-build", | ||
"watch": "just-build --watch", | ||
"clean": "rm -rf tools/tmp && rm dist/*.js && rm dist/*.map && rm dist/*.ts && rm dist/*.mjs", | ||
"test": "pnpm run build && pnpm run test:typings && pnpm run test:unit", | ||
"test:unit": "karma start test/karma.conf.js --single-run", | ||
"test:typings": "tsc -p test/typings-test/", | ||
"test:debug": "karma start test/karma.conf.js --log-level debug" | ||
} | ||
} | ||
} |
@@ -232,34 +232,9 @@ Dexie.js | ||
============ | ||
Here is a little cheat-sheet for how to symlink your app's `node_modules/dexie` to a place where you can edit the source, version control your changes and create pull requests back to Dexie. Assuming you've already ran `npm install dexie --save` for the app your are developing. | ||
See [CONTRIBUTING.md](CONTRIBUTING.md) | ||
1. Fork Dexie.js from the web gui on github | ||
2. Clone your fork locally by launching a shell/command window and cd to a neutral place (like `~repos/`, `c:\repos` or whatever) | ||
3. Run the following commands: | ||
``` | ||
git clone https://github.com/YOUR-USERNAME/Dexie.js.git dexie | ||
cd dexie | ||
npm install | ||
npm run build | ||
npm link | ||
``` | ||
3. cd to your app directory and write: | ||
``` | ||
npm link dexie | ||
``` | ||
Your app's `node_modules/dexie/` is now sym-linked to the Dexie.js clone on your hard drive so any change you do there will propagate to your app. Build dexie.js using `npm run build` or `npm run watch`. The latter will react on any source file change and rebuild the dist files. | ||
That's it. Now you're up and running to test and commit changes to files under dexie/src/* or dexie/test/* and the changes will instantly affect the app you are developing. | ||
Pull requests are more than welcome. Some advices are: | ||
* Run npm test before making a pull request. | ||
* If you find an issue, a unit test that reproduces it is lovely ;). If you don't know where to put it, put it in `test/tests-misc.js`. We use qunit. Just look at existing tests in `tests-misc.js` to see how they should be written. Tests are transpiled in the build script so you can use ES6 if you like. | ||
Build | ||
----- | ||
``` | ||
npm install | ||
npm run build | ||
pnpm install | ||
pnpm run build | ||
``` | ||
@@ -270,3 +245,3 @@ | ||
``` | ||
npm test | ||
pnpm test | ||
``` | ||
@@ -277,3 +252,3 @@ | ||
``` | ||
npm run watch | ||
pnpm run watch | ||
``` | ||
@@ -280,0 +255,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
2621410
21
16635
256