dexie 4.0.5 → 4.0.8
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/dist/dexie.d.ts +14 -10
- package/dist/dexie.js +37 -31
- 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 +37 -31
- 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 +37 -31
- package/dist/modern/dexie.mjs.map +1 -1
- package/package.json +2 -2
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 4.0.
|
|
7
|
+
* Version 4.0.8, Wed Jul 10 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -360,19 +360,20 @@ export interface PromiseExtended<T = any> extends Promise<T> {
|
|
|
360
360
|
timeout(ms: number, msg?: string): PromiseExtended<T>;
|
|
361
361
|
}
|
|
362
362
|
export type KeyPaths<T> = {
|
|
363
|
-
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends
|
|
363
|
+
[P in keyof T]: P extends string ? T[P] extends Array<infer K> ? K extends any[] // Array of arrays (issue #2026)
|
|
364
|
+
? P | `${P}.${number}` | `${P}.${number}.${number}` : K extends object // only drill into the array element if it's an object
|
|
364
365
|
? P | `${P}.${number}` | `${P}.${number}.${KeyPaths<K>}` : P | `${P}.${number}` : T[P] extends (...args: any[]) => any // Method
|
|
365
366
|
? never : T[P] extends object ? P | `${P}.${KeyPaths<T[P]>}` : P : never;
|
|
366
367
|
}[keyof T];
|
|
367
|
-
export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? KeyPathValue<T[R], S> : T extends any[] ? PATH extends `${number}.${infer S}` ? KeyPathValue<T[number], S> : void : void : PATH extends `${number}` ? T extends any[] ? T[number] : void : PATH extends keyof T ? T[PATH] :
|
|
368
|
+
export type KeyPathValue<T, PATH> = PATH extends `${infer R}.${infer S}` ? R extends keyof T ? KeyPathValue<T[R], S> : T extends any[] ? PATH extends `${number}.${infer S}` ? KeyPathValue<T[number], S> : void : void : PATH extends `${number}` ? T extends any[] ? T[number] : void : PATH extends keyof T ? T[PATH] : any;
|
|
368
369
|
export declare const PropModSymbol: unique symbol;
|
|
369
370
|
export type PropModSpec = {
|
|
370
371
|
replacePrefix?: [
|
|
371
372
|
string,
|
|
372
373
|
string
|
|
373
374
|
];
|
|
374
|
-
add?: number |
|
|
375
|
-
remove?: number |
|
|
375
|
+
add?: number | bigint | Array<string | number>;
|
|
376
|
+
remove?: number | bigint | Array<string | number>;
|
|
376
377
|
};
|
|
377
378
|
export class PropModification implements PropModSpec {
|
|
378
379
|
[PropModSymbol]?: true;
|
|
@@ -380,8 +381,8 @@ export class PropModification implements PropModSpec {
|
|
|
380
381
|
string,
|
|
381
382
|
string
|
|
382
383
|
];
|
|
383
|
-
add?: number |
|
|
384
|
-
remove?: number |
|
|
384
|
+
add?: number | bigint | Array<string | number>;
|
|
385
|
+
remove?: number | bigint | Array<string | number>;
|
|
385
386
|
execute<T>(value: T): T;
|
|
386
387
|
constructor(spec: PropModSpec);
|
|
387
388
|
}
|
|
@@ -444,8 +445,8 @@ export type IntervalTree = IntervalTreeNode | EmptyRange;
|
|
|
444
445
|
export interface IntervalTreeNode {
|
|
445
446
|
from: IndexableType; // lower bound
|
|
446
447
|
to: IndexableType; // upper bound
|
|
447
|
-
l
|
|
448
|
-
r
|
|
448
|
+
l?: IntervalTreeNode | null; // left
|
|
449
|
+
r?: IntervalTreeNode | null; // right
|
|
449
450
|
d: number; // depth
|
|
450
451
|
}
|
|
451
452
|
export interface EmptyRange {
|
|
@@ -572,6 +573,7 @@ export interface DBCorePutRequest {
|
|
|
572
573
|
changeSpec?: {
|
|
573
574
|
[keyPath: string]: any;
|
|
574
575
|
}; // Common changeSpec for each key
|
|
576
|
+
isAdditionalChunk?: boolean;
|
|
575
577
|
updates?: {
|
|
576
578
|
keys: any[];
|
|
577
579
|
changeSpecs: {
|
|
@@ -590,6 +592,7 @@ export interface DBCoreDeleteRequest {
|
|
|
590
592
|
index: string | null;
|
|
591
593
|
range: DBCoreKeyRange;
|
|
592
594
|
};
|
|
595
|
+
isAdditionalChunk?: boolean;
|
|
593
596
|
}
|
|
594
597
|
export interface DBCoreDeleteRangeRequest {
|
|
595
598
|
type: "deleteRange";
|
|
@@ -735,10 +738,11 @@ export interface Table<T = any, TKey = any, TInsertType = T> {
|
|
|
735
738
|
reverse(): Collection<T, TKey, TInsertType>;
|
|
736
739
|
mapToClass(constructor: Function): Function;
|
|
737
740
|
add(item: TInsertType, key?: TKey): PromiseExtended<TKey>;
|
|
738
|
-
update(key: TKey | T, changes:
|
|
741
|
+
update(key: TKey | T, changes: ((obj: T, ctx: {
|
|
739
742
|
value: any;
|
|
740
743
|
primKey: IndexableType;
|
|
741
744
|
}) => void | boolean)): PromiseExtended<number>;
|
|
745
|
+
update(key: TKey | T, changes: UpdateSpec<TInsertType>): PromiseExtended<number>;
|
|
742
746
|
put(item: TInsertType, key?: TKey): PromiseExtended<TKey>;
|
|
743
747
|
delete(key: TKey): PromiseExtended<void>;
|
|
744
748
|
clear(): PromiseExtended<void>;
|
package/dist/dexie.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* By David Fahlander, david.fahlander@gmail.com
|
|
6
6
|
*
|
|
7
|
-
* Version 4.0.
|
|
7
|
+
* Version 4.0.8, Wed Jul 10 2024
|
|
8
8
|
*
|
|
9
9
|
* https://dexie.org
|
|
10
10
|
*
|
|
@@ -1150,7 +1150,7 @@
|
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
-
var DEXIE_VERSION = '4.0.
|
|
1153
|
+
var DEXIE_VERSION = '4.0.8';
|
|
1154
1154
|
var maxString = String.fromCharCode(65535);
|
|
1155
1155
|
var minKey = -Infinity;
|
|
1156
1156
|
var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
|
|
@@ -2154,6 +2154,12 @@
|
|
|
2154
2154
|
}
|
|
2155
2155
|
};
|
|
2156
2156
|
return _this.clone().primaryKeys().then(function (keys) {
|
|
2157
|
+
var criteria = isPlainKeyRange(ctx) &&
|
|
2158
|
+
ctx.limit === Infinity &&
|
|
2159
|
+
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2160
|
+
index: ctx.index,
|
|
2161
|
+
range: ctx.range
|
|
2162
|
+
};
|
|
2157
2163
|
var nextChunk = function (offset) {
|
|
2158
2164
|
var count = Math.min(limit, keys.length - offset);
|
|
2159
2165
|
return coreTable.getMany({
|
|
@@ -2186,12 +2192,6 @@
|
|
|
2186
2192
|
}
|
|
2187
2193
|
}
|
|
2188
2194
|
}
|
|
2189
|
-
var criteria = isPlainKeyRange(ctx) &&
|
|
2190
|
-
ctx.limit === Infinity &&
|
|
2191
|
-
(typeof changes !== 'function' || changes === deleteCallback) && {
|
|
2192
|
-
index: ctx.index,
|
|
2193
|
-
range: ctx.range
|
|
2194
|
-
};
|
|
2195
2195
|
return Promise.resolve(addValues.length > 0 &&
|
|
2196
2196
|
coreTable.mutate({ trans: trans, type: 'add', values: addValues })
|
|
2197
2197
|
.then(function (res) {
|
|
@@ -2207,13 +2207,15 @@
|
|
|
2207
2207
|
values: putValues,
|
|
2208
2208
|
criteria: criteria,
|
|
2209
2209
|
changeSpec: typeof changes !== 'function'
|
|
2210
|
-
&& changes
|
|
2210
|
+
&& changes,
|
|
2211
|
+
isAdditionalChunk: offset > 0
|
|
2211
2212
|
}).then(function (res) { return applyMutateResult(putValues.length, res); }); }).then(function () { return (deleteKeys.length > 0 || (criteria && changes === deleteCallback)) &&
|
|
2212
2213
|
coreTable.mutate({
|
|
2213
2214
|
trans: trans,
|
|
2214
2215
|
type: 'delete',
|
|
2215
2216
|
keys: deleteKeys,
|
|
2216
|
-
criteria: criteria
|
|
2217
|
+
criteria: criteria,
|
|
2218
|
+
isAdditionalChunk: offset > 0
|
|
2217
2219
|
}).then(function (res) { return applyMutateResult(deleteKeys.length, res); }); }).then(function () {
|
|
2218
2220
|
return keys.length > offset + count && nextChunk(offset + limit);
|
|
2219
2221
|
});
|
|
@@ -3797,6 +3799,10 @@
|
|
|
3797
3799
|
var _this = this;
|
|
3798
3800
|
keys.forEach(function (key) { return addRange(_this, key, key); });
|
|
3799
3801
|
return this;
|
|
3802
|
+
},
|
|
3803
|
+
hasKey: function (key) {
|
|
3804
|
+
var node = getRangeSetIterator(this).next(key).value;
|
|
3805
|
+
return node && cmp(node.from, key) <= 0 && cmp(node.to, key) >= 0;
|
|
3800
3806
|
}
|
|
3801
3807
|
},
|
|
3802
3808
|
_a[iteratorSymbol] = function () {
|
|
@@ -4858,19 +4864,23 @@
|
|
|
4858
4864
|
var extractLowLevelIndex = (index.lowLevelIndex || index).extractKey;
|
|
4859
4865
|
var finalResult = ops.reduce(function (result, op) {
|
|
4860
4866
|
var modifedResult = result;
|
|
4861
|
-
var includedValues =
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4867
|
+
var includedValues = [];
|
|
4868
|
+
if (op.type === 'add' || op.type === 'put') {
|
|
4869
|
+
var includedPKs = new RangeSet();
|
|
4870
|
+
for (var i = op.values.length - 1; i >= 0; --i) {
|
|
4871
|
+
var value = op.values[i];
|
|
4872
|
+
var pk = extractPrimKey(value);
|
|
4873
|
+
if (includedPKs.hasKey(pk))
|
|
4874
|
+
continue;
|
|
4875
|
+
var key = extractIndex(value);
|
|
4876
|
+
if (multiEntry && isArray(key)
|
|
4865
4877
|
? key.some(function (k) { return isWithinRange(k, queryRange); })
|
|
4866
|
-
: isWithinRange(key, queryRange)
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
})
|
|
4873
|
-
: [];
|
|
4878
|
+
: isWithinRange(key, queryRange)) {
|
|
4879
|
+
includedPKs.addKey(pk);
|
|
4880
|
+
includedValues.push(value);
|
|
4881
|
+
}
|
|
4882
|
+
}
|
|
4883
|
+
}
|
|
4874
4884
|
switch (op.type) {
|
|
4875
4885
|
case 'add':
|
|
4876
4886
|
modifedResult = result.concat(req.values
|
|
@@ -4880,20 +4890,16 @@
|
|
|
4880
4890
|
case 'put':
|
|
4881
4891
|
var keySet_1 = new RangeSet().addKeys(op.values.map(function (v) { return extractPrimKey(v); }));
|
|
4882
4892
|
modifedResult = result
|
|
4883
|
-
.filter(
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
.concat(req.values
|
|
4893
|
+
.filter(
|
|
4894
|
+
function (item) { return !keySet_1.hasKey(req.values ? extractPrimKey(item) : item); })
|
|
4895
|
+
.concat(
|
|
4896
|
+
req.values
|
|
4888
4897
|
? includedValues
|
|
4889
4898
|
: includedValues.map(function (v) { return extractPrimKey(v); }));
|
|
4890
4899
|
break;
|
|
4891
4900
|
case 'delete':
|
|
4892
4901
|
var keysToDelete_1 = new RangeSet().addKeys(op.keys);
|
|
4893
|
-
modifedResult = result.filter(function (item) {
|
|
4894
|
-
var key = req.values ? extractPrimKey(item) : item;
|
|
4895
|
-
return !rangesOverlap(new RangeSet(key), keysToDelete_1);
|
|
4896
|
-
});
|
|
4902
|
+
modifedResult = result.filter(function (item) { return !keysToDelete_1.hasKey(req.values ? extractPrimKey(item) : item); });
|
|
4897
4903
|
break;
|
|
4898
4904
|
case 'deleteRange':
|
|
4899
4905
|
var range_1 = op.range;
|