dexie-cloud-addon 4.0.1-beta.40 → 4.0.1-beta.42

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.
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.40, Mon May 08 2023
11
+ * Version 4.0.1-beta.42, Sat Jul 01 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2757,7 +2757,10 @@
2757
2757
  }));
2758
2758
  })));
2759
2759
  // Sort by time to get a true order of the operations (between tables)
2760
- const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.ts - b.mut.ts);
2760
+ const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.txid === b.mut.txid
2761
+ ? a.mut.opNo - b.mut.opNo // Within same transaction, sort by opNo
2762
+ : a.mut.ts - b.mut.ts // Different transactions - sort by timestamp when mutation resolved
2763
+ );
2761
2764
  const result = [];
2762
2765
  let currentEntry = null;
2763
2766
  let currentTxid = null;
@@ -4644,6 +4647,7 @@
4644
4647
  if (mode === 'readwrite') {
4645
4648
  // Give each transaction a globally unique id.
4646
4649
  tx.txid = randomString(16);
4650
+ tx.opCount = 0;
4647
4651
  // Introduce the concept of current user that lasts through the entire transaction.
4648
4652
  // This is important because the tracked mutations must be connected to the user.
4649
4653
  tx.currentUser = currentUserObservable.value;
@@ -4750,6 +4754,7 @@
4750
4754
  trans.mutationsAdded = true;
4751
4755
  const { txid, currentUser: { userId } } = trans;
4752
4756
  const { type } = req;
4757
+ const opNo = ++trans.opCount;
4753
4758
  return table.mutate(req).then((res) => {
4754
4759
  const { numFailures: hasFailures, failures } = res;
4755
4760
  let keys = type === 'delete' ? req.keys : res.results;
@@ -4764,6 +4769,7 @@
4764
4769
  ? {
4765
4770
  type: 'delete',
4766
4771
  ts,
4772
+ opNo,
4767
4773
  keys,
4768
4774
  criteria: req.criteria,
4769
4775
  txid,
@@ -6086,7 +6092,7 @@
6086
6092
  });
6087
6093
  const syncComplete = new rxjs.Subject();
6088
6094
  dexie.cloud = {
6089
- version: '4.0.1-beta.40',
6095
+ version: '4.0.1-beta.42',
6090
6096
  options: Object.assign({}, DEFAULT_OPTIONS),
6091
6097
  schema: null,
6092
6098
  get currentUserId() {
@@ -6347,7 +6353,7 @@
6347
6353
  });
6348
6354
  }
6349
6355
  }
6350
- dexieCloud.version = '4.0.1-beta.40';
6356
+ dexieCloud.version = '4.0.1-beta.42';
6351
6357
  Dexie__default["default"].Cloud = dexieCloud;
6352
6358
 
6353
6359
  exports["default"] = dexieCloud;