dexie 4.0.1 → 4.0.2

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.mjs CHANGED
@@ -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.2, Wed Apr 10 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1144,7 +1144,7 @@ function tempTransaction(db, mode, storeNames, fn) {
1144
1144
  }
1145
1145
  }
1146
1146
 
1147
- var DEXIE_VERSION = '4.0.1';
1147
+ var DEXIE_VERSION = '4.0.2';
1148
1148
  var maxString = String.fromCharCode(65535);
1149
1149
  var minKey = -Infinity;
1150
1150
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -4579,8 +4579,9 @@ var observabilityMiddleware = {
4579
4579
  }, table: function (tableName) {
4580
4580
  var table = core.table(tableName);
4581
4581
  var schema = table.schema;
4582
- var primaryKey = schema.primaryKey;
4582
+ var primaryKey = schema.primaryKey, indexes = schema.indexes;
4583
4583
  var extractKey = primaryKey.extractKey, outbound = primaryKey.outbound;
4584
+ var indexesWithAutoIncPK = primaryKey.autoIncrement && indexes.filter(function (index) { return index.compound && index.keyPath.includes(primaryKey.keyPath); });
4584
4585
  var tableClone = __assign(__assign({}, table), { mutate: function (req) {
4585
4586
  var trans = req.trans;
4586
4587
  var mutatedParts = req.mutatedParts || (req.mutatedParts = {});
@@ -4623,6 +4624,14 @@ var observabilityMiddleware = {
4623
4624
  return table.mutate(req).then(function (res) {
4624
4625
  if (keys && (req.type === 'add' || req.type === 'put')) {
4625
4626
  pkRangeSet.addKeys(res.results);
4627
+ if (indexesWithAutoIncPK) {
4628
+ indexesWithAutoIncPK.forEach(function (idx) {
4629
+ var idxVals = req.values.map(function (v) { return idx.extractKey(v); });
4630
+ var pkPos = idx.keyPath.findIndex(function (prop) { return prop === primaryKey.keyPath; });
4631
+ res.results.forEach(function (pk) { return idxVals[pkPos] = pk; });
4632
+ getRangeSet(idx.name).addKeys(idxVals);
4633
+ });
4634
+ }
4626
4635
  }
4627
4636
  trans.mutatedParts = extendObservabilitySet(trans.mutatedParts || {}, mutatedParts);
4628
4637
  return res;