dexie 4.0.1 → 4.0.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.
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1, Tue Mar 26 2024
7
+ * Version 4.0.3, Wed Apr 10 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1094,7 +1094,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1094
1094
  }
1095
1095
  }
1096
1096
 
1097
- const DEXIE_VERSION = '4.0.1';
1097
+ const DEXIE_VERSION = '4.0.3';
1098
1098
  const maxString = String.fromCharCode(65535);
1099
1099
  const minKey = -Infinity;
1100
1100
  const INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -4467,8 +4467,9 @@ const observabilityMiddleware = {
4467
4467
  table: (tableName) => {
4468
4468
  const table = core.table(tableName);
4469
4469
  const { schema } = table;
4470
- const { primaryKey } = schema;
4470
+ const { primaryKey, indexes } = schema;
4471
4471
  const { extractKey, outbound } = primaryKey;
4472
+ const indexesWithAutoIncPK = primaryKey.autoIncrement && indexes.filter((index) => index.compound && index.keyPath.includes(primaryKey.keyPath));
4472
4473
  const tableClone = {
4473
4474
  ...table,
4474
4475
  mutate: (req) => {
@@ -4513,6 +4514,14 @@ const observabilityMiddleware = {
4513
4514
  return table.mutate(req).then((res) => {
4514
4515
  if (keys && (req.type === 'add' || req.type === 'put')) {
4515
4516
  pkRangeSet.addKeys(res.results);
4517
+ if (indexesWithAutoIncPK) {
4518
+ indexesWithAutoIncPK.forEach(idx => {
4519
+ const idxVals = req.values.map(v => idx.extractKey(v));
4520
+ const pkPos = idx.keyPath.findIndex(prop => prop === primaryKey.keyPath);
4521
+ res.results.forEach(pk => idxVals[pkPos] = pk);
4522
+ getRangeSet(idx.name).addKeys(idxVals);
4523
+ });
4524
+ }
4516
4525
  }
4517
4526
  trans.mutatedParts = extendObservabilitySet(trans.mutatedParts || {}, mutatedParts);
4518
4527
  return res;