dexie 3.2.1 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/SECURITY.md +3 -2
- package/dist/dexie.d.ts +188 -143
- package/dist/dexie.js +81 -36
- package/dist/dexie.js.map +1 -1
- package/dist/dexie.min.js +1 -1
- package/dist/dexie.min.js.map +1 -1
- package/dist/dexie.mjs +80 -37
- package/dist/dexie.mjs.map +1 -1
- package/dist/modern/dexie.min.mjs +1 -1
- package/dist/modern/dexie.min.mjs.map +1 -1
- package/dist/modern/dexie.mjs +40 -19
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Dexie.js
|
|
2
2
|
========
|
|
3
3
|
|
|
4
|
-
[![NPM Version][npm-image]][npm-url] [](https://travis-ci.com/dexie/Dexie.js)[](https://www.browserstack.com)
|
|
5
5
|
|
|
6
6
|
Dexie.js is a wrapper library for indexedDB - the standard database in the browser. https://dexie.org
|
|
7
7
|
|
|
@@ -191,7 +191,7 @@ Samples
|
|
|
191
191
|
-------
|
|
192
192
|
https://dexie.org/docs/Samples
|
|
193
193
|
|
|
194
|
-
https://github.com/
|
|
194
|
+
https://github.com/dexie/Dexie.js/tree/master/samples
|
|
195
195
|
|
|
196
196
|
Knowledge Base
|
|
197
197
|
-----
|
package/SECURITY.md
CHANGED
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
| Version | Supported | Branch
|
|
6
6
|
| ------- | ------------------ | --------
|
|
7
|
-
|
|
|
7
|
+
| 4.x | :white_check_mark: | master
|
|
8
|
+
| 3.x | :white_check_mark: | master-3
|
|
8
9
|
| 2.0.x | :thinking: | master-2
|
|
9
10
|
| 1.5.x | :x: | master-1
|
|
10
11
|
| < 1.5.1 | :x: |
|
|
11
12
|
|
|
12
13
|
## Reporting a Vulnerability
|
|
13
14
|
|
|
14
|
-
To report a security vulnerability in Dexie.js,
|
|
15
|
+
To report a security vulnerability in Dexie.js, please send an email to code@dexie.org describing the vulnerability and how to reproduce it.
|
|
15
16
|
|
|
16
17
|
If we find an issue to be regarded as a security vulnerability, we will patch and release a new version in all the supported versions as soon as possible.
|
|
17
18
|
Keep in mind though that this is an uncommercial open source project which means that sometimes you might have to be the one that
|
package/dist/dexie.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version
|
|
7
|
+
* Version 4.0.0-alpha.3, Wed Apr 27 2022
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -51,7 +51,78 @@ export interface DexieEventSet {
|
|
|
51
51
|
]);
|
|
52
52
|
}): DexieEvent;
|
|
53
53
|
}
|
|
54
|
-
export
|
|
54
|
+
export interface TransactionEvents extends DexieEventSet {
|
|
55
|
+
(eventName: "complete", subscriber: () => any): void;
|
|
56
|
+
(eventName: "abort", subscriber: () => any): void;
|
|
57
|
+
(eventName: "error", subscriber: (error: any) => any): void;
|
|
58
|
+
complete: DexieEvent;
|
|
59
|
+
abort: DexieEvent;
|
|
60
|
+
error: DexieEvent;
|
|
61
|
+
}
|
|
62
|
+
export interface Transaction {
|
|
63
|
+
db: Dexie;
|
|
64
|
+
active: boolean;
|
|
65
|
+
mode: IDBTransactionMode;
|
|
66
|
+
//tables: { [type: string]: Table<any, any> }; Deprecated since 2.0. Obsolete from v3.0.
|
|
67
|
+
storeNames: Array<string>;
|
|
68
|
+
parent?: Transaction;
|
|
69
|
+
on: TransactionEvents;
|
|
70
|
+
abort(): void;
|
|
71
|
+
table(tableName: string): Table<any, any>;
|
|
72
|
+
table<T>(tableName: string): Table<T, any>;
|
|
73
|
+
table<T, Key>(tableName: string): Table<T, Key>;
|
|
74
|
+
}
|
|
75
|
+
export interface CreatingHookContext<T, Key> {
|
|
76
|
+
onsuccess?: (primKey: Key) => void;
|
|
77
|
+
onerror?: (err: any) => void;
|
|
78
|
+
}
|
|
79
|
+
export interface UpdatingHookContext<T, Key> {
|
|
80
|
+
onsuccess?: (updatedObj: T) => void;
|
|
81
|
+
onerror?: (err: any) => void;
|
|
82
|
+
}
|
|
83
|
+
export interface DeletingHookContext<T, Key> {
|
|
84
|
+
onsuccess?: () => void;
|
|
85
|
+
onerror?: (err: any) => void;
|
|
86
|
+
}
|
|
87
|
+
export interface TableHooks<T = any, TKey = IndexableType> extends DexieEventSet {
|
|
88
|
+
(eventName: "creating", subscriber: (this: CreatingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
89
|
+
(eventName: "reading", subscriber: (obj: T) => T | any): void;
|
|
90
|
+
(eventName: "updating", subscriber: (this: UpdatingHookContext<T, TKey>, modifications: Object, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
91
|
+
(eventName: "deleting", subscriber: (this: DeletingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
92
|
+
creating: DexieEvent;
|
|
93
|
+
reading: DexieEvent;
|
|
94
|
+
updating: DexieEvent;
|
|
95
|
+
deleting: DexieEvent;
|
|
96
|
+
}
|
|
97
|
+
export type ThenShortcut<T, TResult> = (value: T) => TResult | PromiseLike<TResult>;
|
|
98
|
+
export interface WhereClause<T = any, TKey = IndexableType> {
|
|
99
|
+
above(key: any): Collection<T, TKey>;
|
|
100
|
+
aboveOrEqual(key: any): Collection<T, TKey>;
|
|
101
|
+
anyOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
|
|
102
|
+
anyOf(...keys: Array<IndexableType>): Collection<T, TKey>;
|
|
103
|
+
anyOfIgnoreCase(keys: string[]): Collection<T, TKey>;
|
|
104
|
+
anyOfIgnoreCase(...keys: string[]): Collection<T, TKey>;
|
|
105
|
+
below(key: any): Collection<T, TKey>;
|
|
106
|
+
belowOrEqual(key: any): Collection<T, TKey>;
|
|
107
|
+
between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): Collection<T, TKey>;
|
|
108
|
+
equals(key: IndexableType): Collection<T, TKey>;
|
|
109
|
+
equalsIgnoreCase(key: string): Collection<T, TKey>;
|
|
110
|
+
inAnyRange(ranges: ReadonlyArray<{
|
|
111
|
+
0: any;
|
|
112
|
+
1: any;
|
|
113
|
+
}>, options?: {
|
|
114
|
+
includeLowers?: boolean;
|
|
115
|
+
includeUppers?: boolean;
|
|
116
|
+
}): Collection<T, TKey>;
|
|
117
|
+
startsWith(key: string): Collection<T, TKey>;
|
|
118
|
+
startsWithAnyOf(prefixes: string[]): Collection<T, TKey>;
|
|
119
|
+
startsWithAnyOf(...prefixes: string[]): Collection<T, TKey>;
|
|
120
|
+
startsWithIgnoreCase(key: string): Collection<T, TKey>;
|
|
121
|
+
startsWithAnyOfIgnoreCase(prefixes: string[]): Collection<T, TKey>;
|
|
122
|
+
startsWithAnyOfIgnoreCase(...prefixes: string[]): Collection<T, TKey>;
|
|
123
|
+
noneOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
|
|
124
|
+
notEqual(key: IndexableType): Collection<T, TKey>;
|
|
125
|
+
}
|
|
55
126
|
export interface PromiseExtendedConstructor extends PromiseConstructor {
|
|
56
127
|
readonly prototype: PromiseExtended;
|
|
57
128
|
new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): PromiseExtended<T>;
|
|
@@ -285,9 +356,17 @@ export interface PromiseExtended<T = any> extends Promise<T> {
|
|
|
285
356
|
finally<U>(onFinally?: () => U | PromiseLike<U>): PromiseExtended<T>;
|
|
286
357
|
timeout(ms: number, msg?: string): PromiseExtended<T>;
|
|
287
358
|
}
|
|
288
|
-
export type
|
|
359
|
+
export type KeyPaths<T> = {
|
|
360
|
+
[P in keyof T]: P extends string ? T[P] extends any[] ? P : T[P] extends (...args: any[]) => any // Method
|
|
361
|
+
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
|
|
362
|
+
}[keyof T];
|
|
363
|
+
export type Extract<T, P> = P extends keyof T ? T[P] : void;
|
|
364
|
+
export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? Extract<T[R], S> : void : Extract<T, PATH>;
|
|
365
|
+
export type UpdateSpec<T> = {
|
|
366
|
+
[KP in KeyPaths<T>]?: KeyPathValue<T, KP>;
|
|
367
|
+
};
|
|
289
368
|
export interface Collection<T = any, TKey = IndexableType> {
|
|
290
|
-
|
|
369
|
+
db: Dexie;
|
|
291
370
|
and(filter: (x: T) => boolean): Collection<T, TKey>;
|
|
292
371
|
clone(props?: Object): Collection<T, TKey>;
|
|
293
372
|
count(): PromiseExtended<number>;
|
|
@@ -335,91 +414,7 @@ export interface Collection<T = any, TKey = IndexableType> {
|
|
|
335
414
|
modify(changeCallback: (obj: T, ctx: {
|
|
336
415
|
value: T;
|
|
337
416
|
}) => void | boolean): PromiseExtended<number>;
|
|
338
|
-
modify(changes:
|
|
339
|
-
[keyPath: string]: any;
|
|
340
|
-
}): PromiseExtended<number>;
|
|
341
|
-
}
|
|
342
|
-
export interface WhereClause<T = any, TKey = IndexableType> {
|
|
343
|
-
above(key: any): Collection<T, TKey>;
|
|
344
|
-
aboveOrEqual(key: any): Collection<T, TKey>;
|
|
345
|
-
anyOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
|
|
346
|
-
anyOf(...keys: Array<IndexableType>): Collection<T, TKey>;
|
|
347
|
-
anyOfIgnoreCase(keys: string[]): Collection<T, TKey>;
|
|
348
|
-
anyOfIgnoreCase(...keys: string[]): Collection<T, TKey>;
|
|
349
|
-
below(key: any): Collection<T, TKey>;
|
|
350
|
-
belowOrEqual(key: any): Collection<T, TKey>;
|
|
351
|
-
between(lower: any, upper: any, includeLower?: boolean, includeUpper?: boolean): Collection<T, TKey>;
|
|
352
|
-
equals(key: IndexableType): Collection<T, TKey>;
|
|
353
|
-
equalsIgnoreCase(key: string): Collection<T, TKey>;
|
|
354
|
-
inAnyRange(ranges: ReadonlyArray<{
|
|
355
|
-
0: any;
|
|
356
|
-
1: any;
|
|
357
|
-
}>, options?: {
|
|
358
|
-
includeLowers?: boolean;
|
|
359
|
-
includeUppers?: boolean;
|
|
360
|
-
}): Collection<T, TKey>;
|
|
361
|
-
startsWith(key: string): Collection<T, TKey>;
|
|
362
|
-
startsWithAnyOf(prefixes: string[]): Collection<T, TKey>;
|
|
363
|
-
startsWithAnyOf(...prefixes: string[]): Collection<T, TKey>;
|
|
364
|
-
startsWithIgnoreCase(key: string): Collection<T, TKey>;
|
|
365
|
-
startsWithAnyOfIgnoreCase(prefixes: string[]): Collection<T, TKey>;
|
|
366
|
-
startsWithAnyOfIgnoreCase(...prefixes: string[]): Collection<T, TKey>;
|
|
367
|
-
noneOf(keys: ReadonlyArray<IndexableType>): Collection<T, TKey>;
|
|
368
|
-
notEqual(key: IndexableType): Collection<T, TKey>;
|
|
369
|
-
}
|
|
370
|
-
export interface Database {
|
|
371
|
-
readonly name: string;
|
|
372
|
-
readonly tables: Table[];
|
|
373
|
-
table<T = any, TKey = any>(tableName: string): Table<T, TKey>;
|
|
374
|
-
transaction<U>(mode: TransactionMode, table: Table, scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
375
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
376
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
377
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, table4: Table, scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
378
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, table4: Table, table5: Table, scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
379
|
-
transaction<U>(mode: TransactionMode, tables: Table[], scope: () => PromiseLike<U> | U): PromiseExtended<U>;
|
|
380
|
-
}
|
|
381
|
-
export interface TransactionEvents extends DexieEventSet {
|
|
382
|
-
(eventName: "complete", subscriber: () => any): void;
|
|
383
|
-
(eventName: "abort", subscriber: () => any): void;
|
|
384
|
-
(eventName: "error", subscriber: (error: any) => any): void;
|
|
385
|
-
complete: DexieEvent;
|
|
386
|
-
abort: DexieEvent;
|
|
387
|
-
error: DexieEvent;
|
|
388
|
-
}
|
|
389
|
-
export interface Transaction {
|
|
390
|
-
db: Database;
|
|
391
|
-
active: boolean;
|
|
392
|
-
mode: IDBTransactionMode;
|
|
393
|
-
//tables: { [type: string]: Table<any, any> }; Deprecated since 2.0. Obsolete from v3.0.
|
|
394
|
-
storeNames: Array<string>;
|
|
395
|
-
parent?: Transaction;
|
|
396
|
-
on: TransactionEvents;
|
|
397
|
-
abort(): void;
|
|
398
|
-
table(tableName: string): Table<any, any>;
|
|
399
|
-
table<T>(tableName: string): Table<T, any>;
|
|
400
|
-
table<T, Key>(tableName: string): Table<T, Key>;
|
|
401
|
-
}
|
|
402
|
-
export interface CreatingHookContext<T, Key> {
|
|
403
|
-
onsuccess?: (primKey: Key) => void;
|
|
404
|
-
onerror?: (err: any) => void;
|
|
405
|
-
}
|
|
406
|
-
export interface UpdatingHookContext<T, Key> {
|
|
407
|
-
onsuccess?: (updatedObj: T) => void;
|
|
408
|
-
onerror?: (err: any) => void;
|
|
409
|
-
}
|
|
410
|
-
export interface DeletingHookContext<T, Key> {
|
|
411
|
-
onsuccess?: () => void;
|
|
412
|
-
onerror?: (err: any) => void;
|
|
413
|
-
}
|
|
414
|
-
export interface TableHooks<T = any, TKey = IndexableType> extends DexieEventSet {
|
|
415
|
-
(eventName: "creating", subscriber: (this: CreatingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
416
|
-
(eventName: "reading", subscriber: (obj: T) => T | any): void;
|
|
417
|
-
(eventName: "updating", subscriber: (this: UpdatingHookContext<T, TKey>, modifications: Object, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
418
|
-
(eventName: "deleting", subscriber: (this: DeletingHookContext<T, TKey>, primKey: TKey, obj: T, transaction: Transaction) => any): void;
|
|
419
|
-
creating: DexieEvent;
|
|
420
|
-
reading: DexieEvent;
|
|
421
|
-
updating: DexieEvent;
|
|
422
|
-
deleting: DexieEvent;
|
|
417
|
+
modify(changes: UpdateSpec<T>): PromiseExtended<number>;
|
|
423
418
|
}
|
|
424
419
|
export const enum DBCoreRangeType {
|
|
425
420
|
Equal = 1,
|
|
@@ -452,7 +447,7 @@ export interface DBCoreMutateResponse {
|
|
|
452
447
|
export interface DBCoreAddRequest {
|
|
453
448
|
type: "add";
|
|
454
449
|
trans: DBCoreTransaction;
|
|
455
|
-
values: any[];
|
|
450
|
+
values: readonly any[];
|
|
456
451
|
keys?: any[];
|
|
457
452
|
/** @deprecated Will always get results since 3.1.0-alpha.5 */
|
|
458
453
|
wantResults?: boolean;
|
|
@@ -460,7 +455,7 @@ export interface DBCoreAddRequest {
|
|
|
460
455
|
export interface DBCorePutRequest {
|
|
461
456
|
type: "put";
|
|
462
457
|
trans: DBCoreTransaction;
|
|
463
|
-
values: any[];
|
|
458
|
+
values: readonly any[];
|
|
464
459
|
keys?: any[];
|
|
465
460
|
criteria?: {
|
|
466
461
|
index: string | null;
|
|
@@ -586,66 +581,76 @@ export interface DBCoreTable {
|
|
|
586
581
|
openCursor(req: DBCoreOpenCursorRequest): Promise<DBCoreCursor | null>;
|
|
587
582
|
count(req: DBCoreCountRequest): Promise<number>;
|
|
588
583
|
}
|
|
589
|
-
export
|
|
590
|
-
|
|
584
|
+
export type MethodProps<T> = {
|
|
585
|
+
[P in keyof T]: T[P] extends (...args: any[]) => any ? P : never;
|
|
586
|
+
}[keyof T];
|
|
587
|
+
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 ? {
|
|
588
|
+
[P in (TOptionalProperties | TKeyPropNameOrKeyType)]?: T[P];
|
|
589
|
+
} : {
|
|
590
|
+
[P in TOptionalProperties]?: T[P];
|
|
591
|
+
} : {});
|
|
592
|
+
export type IDType<T, TKey> = TKey extends keyof T ? T[TKey] : TKey;
|
|
593
|
+
export interface Table<T = any, TKeyPropNameOrKeyType = IndexableType, TOpt = void> {
|
|
594
|
+
db: Dexie;
|
|
591
595
|
name: string;
|
|
592
596
|
schema: TableSchema;
|
|
593
|
-
hook: TableHooks<T,
|
|
597
|
+
hook: TableHooks<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
594
598
|
core: DBCoreTable;
|
|
595
|
-
get(key:
|
|
596
|
-
get<R>(key:
|
|
599
|
+
get(key: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<T | undefined>;
|
|
600
|
+
get<R>(key: IDType<T, TKeyPropNameOrKeyType>, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
|
|
597
601
|
get(equalityCriterias: {
|
|
598
602
|
[key: string]: any;
|
|
599
603
|
}): PromiseExtended<T | undefined>;
|
|
600
604
|
get<R>(equalityCriterias: {
|
|
601
605
|
[key: string]: any;
|
|
602
606
|
}, thenShortcut: ThenShortcut<T | undefined, R>): PromiseExtended<R>;
|
|
603
|
-
where(index: string | string[]): WhereClause<T,
|
|
607
|
+
where(index: string | string[]): WhereClause<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
604
608
|
where(equalityCriterias: {
|
|
605
609
|
[key: string]: any;
|
|
606
|
-
}): Collection<T,
|
|
607
|
-
filter(fn: (obj: T) => boolean): Collection<T,
|
|
610
|
+
}): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
611
|
+
filter(fn: (obj: T) => boolean): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
608
612
|
count(): PromiseExtended<number>;
|
|
609
613
|
count<R>(thenShortcut: ThenShortcut<number, R>): PromiseExtended<R>;
|
|
610
|
-
offset(n: number): Collection<T,
|
|
611
|
-
limit(n: number): Collection<T,
|
|
614
|
+
offset(n: number): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
615
|
+
limit(n: number): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
612
616
|
each(callback: (obj: T, cursor: {
|
|
613
617
|
key: any;
|
|
614
|
-
primaryKey:
|
|
618
|
+
primaryKey: IDType<T, TKeyPropNameOrKeyType>;
|
|
615
619
|
}) => any): PromiseExtended<void>;
|
|
616
620
|
toArray(): PromiseExtended<Array<T>>;
|
|
617
621
|
toArray<R>(thenShortcut: ThenShortcut<T[], R>): PromiseExtended<R>;
|
|
618
|
-
toCollection(): Collection<T,
|
|
619
|
-
orderBy(index: string | string[]): Collection<T,
|
|
620
|
-
reverse(): Collection<T,
|
|
622
|
+
toCollection(): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
623
|
+
orderBy(index: string | string[]): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
624
|
+
reverse(): Collection<T, IDType<T, TKeyPropNameOrKeyType>>;
|
|
621
625
|
mapToClass(constructor: Function): Function;
|
|
622
|
-
add(item: T, key?:
|
|
623
|
-
update(key:
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
626
|
+
add(item: InsertType<T, TOpt, TKeyPropNameOrKeyType>, key?: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>;
|
|
627
|
+
update(key: IDType<T, TKeyPropNameOrKeyType> | T, changes: UpdateSpec<T> | ((obj: T, ctx: {
|
|
628
|
+
value: any;
|
|
629
|
+
primKey: IndexableType;
|
|
630
|
+
}) => void | boolean)): PromiseExtended<number>;
|
|
631
|
+
put(item: InsertType<T, TOpt, TKeyPropNameOrKeyType>, key?: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>;
|
|
632
|
+
delete(key: IDType<T, TKeyPropNameOrKeyType>): PromiseExtended<void>;
|
|
628
633
|
clear(): PromiseExtended<void>;
|
|
629
|
-
bulkGet(keys:
|
|
630
|
-
bulkAdd<B extends boolean>(items: readonly T[], keys: IndexableTypeArrayReadonly, options: {
|
|
634
|
+
bulkGet(keys: IDType<T, TKeyPropNameOrKeyType>[]): PromiseExtended<(T | undefined)[]>;
|
|
635
|
+
bulkAdd<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys: IndexableTypeArrayReadonly, options: {
|
|
631
636
|
allKeys: B;
|
|
632
|
-
}): PromiseExtended<B extends true ?
|
|
633
|
-
bulkAdd<B extends boolean>(items: readonly T[], options: {
|
|
637
|
+
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>;
|
|
638
|
+
bulkAdd<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], options: {
|
|
634
639
|
allKeys: B;
|
|
635
|
-
}): PromiseExtended<B extends true ?
|
|
636
|
-
bulkAdd(items: readonly T[], keys?: IndexableTypeArrayReadonly, options?: {
|
|
640
|
+
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>;
|
|
641
|
+
bulkAdd(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys?: IndexableTypeArrayReadonly, options?: {
|
|
637
642
|
allKeys: boolean;
|
|
638
|
-
}): PromiseExtended<
|
|
639
|
-
bulkPut<B extends boolean>(items: readonly T[], keys: IndexableTypeArrayReadonly, options: {
|
|
643
|
+
}): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>;
|
|
644
|
+
bulkPut<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys: IndexableTypeArrayReadonly, options: {
|
|
640
645
|
allKeys: B;
|
|
641
|
-
}): PromiseExtended<B extends true ?
|
|
642
|
-
bulkPut<B extends boolean>(items: readonly T[], options: {
|
|
646
|
+
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>;
|
|
647
|
+
bulkPut<B extends boolean>(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], options: {
|
|
643
648
|
allKeys: B;
|
|
644
|
-
}): PromiseExtended<B extends true ?
|
|
645
|
-
bulkPut(items: readonly T[], keys?: IndexableTypeArrayReadonly, options?: {
|
|
649
|
+
}): PromiseExtended<B extends true ? IDType<T, TKeyPropNameOrKeyType>[] : IDType<T, TKeyPropNameOrKeyType>>;
|
|
650
|
+
bulkPut(items: readonly InsertType<T, TOpt, TKeyPropNameOrKeyType>[], keys?: IndexableTypeArrayReadonly, options?: {
|
|
646
651
|
allKeys: boolean;
|
|
647
|
-
}): PromiseExtended<
|
|
648
|
-
bulkDelete(keys:
|
|
652
|
+
}): PromiseExtended<IDType<T, TKeyPropNameOrKeyType>>;
|
|
653
|
+
bulkDelete(keys: IDType<T, TKeyPropNameOrKeyType>[]): PromiseExtended<void>;
|
|
649
654
|
}
|
|
650
655
|
export interface Version {
|
|
651
656
|
stores(schema: {
|
|
@@ -696,9 +701,34 @@ export interface DbEvents extends DexieEventSet {
|
|
|
696
701
|
versionchange: DexieVersionChangeEvent;
|
|
697
702
|
close: DexieCloseEvent;
|
|
698
703
|
}
|
|
704
|
+
/** Set of mutated parts of the database
|
|
705
|
+
*/
|
|
699
706
|
export type ObservabilitySet = {
|
|
700
|
-
|
|
701
|
-
|
|
707
|
+
/** Database part having been mutated.
|
|
708
|
+
*
|
|
709
|
+
* This structure is produced in observability-middleware.ts
|
|
710
|
+
* and consumed in live-query.ts.
|
|
711
|
+
*
|
|
712
|
+
* Format of 'part':
|
|
713
|
+
*
|
|
714
|
+
* `idb://${dbName}/${tableName}/${indexName}`
|
|
715
|
+
*
|
|
716
|
+
* * dbName is the database name
|
|
717
|
+
* * tableName is the table name
|
|
718
|
+
* * indexName is any of:
|
|
719
|
+
* 1. An empty string - represents the primary keys of the affected objs
|
|
720
|
+
* 2. ":dels" - represents primary keys of deleted objects in the table
|
|
721
|
+
* 3. The keyPath of an index, such as "name", "age" or "address.city" -
|
|
722
|
+
* represents indexes that, if used in a query, might affect the
|
|
723
|
+
* result of that query.
|
|
724
|
+
*
|
|
725
|
+
* IntervalTree
|
|
726
|
+
* * See definition of IntervalTree type in rangeset.d.ts
|
|
727
|
+
* * See rangesOverlap() in rangeset.ts that can be used to compare two
|
|
728
|
+
* IntervalTrees and detect collissions.
|
|
729
|
+
* * See RangeSet class that can be used to create an IntervalTree and add
|
|
730
|
+
* ranges to it.
|
|
731
|
+
*/
|
|
702
732
|
[part: string]: IntervalTree;
|
|
703
733
|
};
|
|
704
734
|
export interface DexieOnStorageMutatedEvent {
|
|
@@ -710,6 +740,7 @@ export interface GlobalDexieEvents extends DexieEventSet {
|
|
|
710
740
|
(eventName: "storagemutated", subscriber: (parts: ObservabilitySet) => any): void;
|
|
711
741
|
storagemutated: DexieOnStorageMutatedEvent;
|
|
712
742
|
}
|
|
743
|
+
export type TransactionMode = "readonly" | "readwrite" | "r" | "r!" | "r?" | "rw" | "rw!" | "rw?";
|
|
713
744
|
export type DbSchema = {
|
|
714
745
|
[tableName: string]: TableSchema;
|
|
715
746
|
};
|
|
@@ -724,7 +755,20 @@ export interface Middleware<TStack extends {
|
|
|
724
755
|
export interface DexieStacks {
|
|
725
756
|
dbcore: DBCore;
|
|
726
757
|
}
|
|
727
|
-
export
|
|
758
|
+
export type TableProp<DX extends Dexie> = {
|
|
759
|
+
[K in keyof DX]: DX[K] extends {
|
|
760
|
+
schema: any;
|
|
761
|
+
get: any;
|
|
762
|
+
put: any;
|
|
763
|
+
add: any;
|
|
764
|
+
where: any;
|
|
765
|
+
} ? K : never;
|
|
766
|
+
}[keyof DX] & string;
|
|
767
|
+
export type TXWithTables<DX extends Dexie> = Dexie extends DX ? Transaction // If not subclassed, just expect a Transaction without table props
|
|
768
|
+
: Transaction & {
|
|
769
|
+
[P in TableProp<DX>]: DX[P];
|
|
770
|
+
};
|
|
771
|
+
export interface Dexie {
|
|
728
772
|
readonly name: string;
|
|
729
773
|
readonly tables: Table[];
|
|
730
774
|
readonly verno: number;
|
|
@@ -734,23 +778,18 @@ export interface Dexie extends Database {
|
|
|
734
778
|
};
|
|
735
779
|
readonly core: DBCore;
|
|
736
780
|
_createTransaction: (this: Dexie, mode: IDBTransactionMode, storeNames: ArrayLike<string>, dbschema: DbSchema, parentTransaction?: Transaction | null) => Transaction;
|
|
781
|
+
readonly _novip: Dexie;
|
|
737
782
|
_dbSchema: DbSchema;
|
|
738
783
|
version(versionNumber: number): Version;
|
|
739
784
|
on: DbEvents;
|
|
740
785
|
open(): PromiseExtended<Dexie>;
|
|
741
786
|
table<T = any, TKey = IndexableType>(tableName: string): Table<T, TKey>;
|
|
742
|
-
transaction<U>(mode: TransactionMode,
|
|
743
|
-
transaction<U>(mode: TransactionMode, table: string, scope: (trans:
|
|
744
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, scope: (trans:
|
|
745
|
-
transaction<U>(mode: TransactionMode, table: string, table2: string, scope: (trans:
|
|
746
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, scope: (trans:
|
|
747
|
-
transaction<U>(mode: TransactionMode, table: string, table2: string, table3: string, scope: (trans:
|
|
748
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, table4: Table, scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
749
|
-
transaction<U>(mode: TransactionMode, table: string, table2: string, table3: string, table4: string, scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
750
|
-
transaction<U>(mode: TransactionMode, table: Table, table2: Table, table3: Table, table4: Table, table5: Table, scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
751
|
-
transaction<U>(mode: TransactionMode, table: string, table2: string, table3: string, table4: string, table5: string, scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
752
|
-
transaction<U>(mode: TransactionMode, tables: Table[], scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
753
|
-
transaction<U>(mode: TransactionMode, tables: string[], scope: (trans: Transaction) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
787
|
+
transaction<U>(mode: TransactionMode, tables: readonly (string | Table)[], scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
788
|
+
transaction<U>(mode: TransactionMode, table: string | Table, scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
789
|
+
transaction<U>(mode: TransactionMode, table: string | Table, table2: string | Table, scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
790
|
+
transaction<U>(mode: TransactionMode, table: string | Table, table2: string | Table, table3: string | Table, scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
791
|
+
transaction<U>(mode: TransactionMode, table: string | Table, table2: string | Table, table3: string | Table, table4: string | Table, scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
792
|
+
transaction<U>(mode: TransactionMode, table: string | Table, table2: string | Table, table3: string | Table, table5: string | Table, scope: (trans: TXWithTables<this>) => PromiseLike<U> | U): PromiseExtended<U>;
|
|
754
793
|
close(): void;
|
|
755
794
|
delete(): PromiseExtended<void>;
|
|
756
795
|
isOpen(): boolean;
|
|
@@ -976,9 +1015,9 @@ export interface DexieConstructor extends DexieExceptionClasses {
|
|
|
976
1015
|
liveQuery<T>(fn: () => T | Promise<T>): Observable<T>;
|
|
977
1016
|
extendObservabilitySet(target: ObservabilitySet, newSet: ObservabilitySet): ObservabilitySet;
|
|
978
1017
|
override<F>(origFunc: F, overridedFactory: (fn: any) => any): F; // ?
|
|
979
|
-
getByKeyPath(obj: Object, keyPath: string): any;
|
|
980
|
-
setByKeyPath(obj: Object, keyPath: string, value: any): void;
|
|
981
|
-
delByKeyPath(obj: Object, keyPath: string): void;
|
|
1018
|
+
getByKeyPath(obj: Object, keyPath: string | string[]): any;
|
|
1019
|
+
setByKeyPath(obj: Object, keyPath: string | string[], value: any): void;
|
|
1020
|
+
delByKeyPath(obj: Object, keyPath: string | string[]): void;
|
|
982
1021
|
shallowClone<T>(obj: T): T;
|
|
983
1022
|
deepClone<T>(obj: T): T;
|
|
984
1023
|
asap(fn: Function): void; //?
|
|
@@ -995,6 +1034,11 @@ export interface DexieConstructor extends DexieExceptionClasses {
|
|
|
995
1034
|
on: GlobalDexieEvents;
|
|
996
1035
|
errnames: DexieErrors;
|
|
997
1036
|
}
|
|
1037
|
+
export class Entity<TDexieSubClass extends Dexie = Dexie> {
|
|
1038
|
+
protected constructor();
|
|
1039
|
+
protected readonly db: TDexieSubClass;
|
|
1040
|
+
table(): TableProp<TDexieSubClass>;
|
|
1041
|
+
}
|
|
998
1042
|
export declare var Dexie: DexieConstructor;
|
|
999
1043
|
export interface _Table<T, TKey> extends Table<T, TKey> {
|
|
1000
1044
|
}
|
|
@@ -1013,6 +1057,7 @@ export declare module Dexie {
|
|
|
1013
1057
|
export function liveQuery<T>(querier: () => T | Promise<T>): Observable<T>;
|
|
1014
1058
|
export function mergeRanges(target: IntervalTree, newSet: IntervalTree): void;
|
|
1015
1059
|
export function rangesOverlap(rangeSet1: IntervalTree, rangeSet2: IntervalTree): boolean;
|
|
1060
|
+
export function cmp(a: any, b: any): number;
|
|
1016
1061
|
/** Exporting 'Dexie' as the default export.
|
|
1017
1062
|
**/
|
|
1018
1063
|
export default Dexie;
|