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.
@@ -335,7 +335,10 @@
335
335
  }));
336
336
  })));
337
337
  // Sort by time to get a true order of the operations (between tables)
338
- const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.ts - b.mut.ts);
338
+ const sorted = flatten(allMutsOnTables).sort((a, b) => a.mut.txid === b.mut.txid
339
+ ? a.mut.opNo - b.mut.opNo // Within same transaction, sort by opNo
340
+ : a.mut.ts - b.mut.ts // Different transactions - sort by timestamp when mutation resolved
341
+ );
339
342
  const result = [];
340
343
  let currentEntry = null;
341
344
  let currentTxid = null;
@@ -3005,6 +3008,7 @@
3005
3008
  if (mode === 'readwrite') {
3006
3009
  // Give each transaction a globally unique id.
3007
3010
  tx.txid = randomString$1(16);
3011
+ tx.opCount = 0;
3008
3012
  // Introduce the concept of current user that lasts through the entire transaction.
3009
3013
  // This is important because the tracked mutations must be connected to the user.
3010
3014
  tx.currentUser = currentUserObservable.value;
@@ -3111,6 +3115,7 @@
3111
3115
  trans.mutationsAdded = true;
3112
3116
  const { txid, currentUser: { userId } } = trans;
3113
3117
  const { type } = req;
3118
+ const opNo = ++trans.opCount;
3114
3119
  return table.mutate(req).then((res) => {
3115
3120
  const { numFailures: hasFailures, failures } = res;
3116
3121
  let keys = type === 'delete' ? req.keys : res.results;
@@ -3125,6 +3130,7 @@
3125
3130
  ? {
3126
3131
  type: 'delete',
3127
3132
  ts,
3133
+ opNo,
3128
3134
  keys,
3129
3135
  criteria: req.criteria,
3130
3136
  txid,
@@ -4440,7 +4446,7 @@
4440
4446
  });
4441
4447
  const syncComplete = new rxjs.Subject();
4442
4448
  dexie.cloud = {
4443
- version: '4.0.1-beta.40',
4449
+ version: '4.0.1-beta.42',
4444
4450
  options: Object.assign({}, DEFAULT_OPTIONS),
4445
4451
  schema: null,
4446
4452
  get currentUserId() {
@@ -4701,7 +4707,7 @@
4701
4707
  });
4702
4708
  }
4703
4709
  }
4704
- dexieCloud.version = '4.0.1-beta.40';
4710
+ dexieCloud.version = '4.0.1-beta.42';
4705
4711
  Dexie__default["default"].Cloud = dexieCloud;
4706
4712
 
4707
4713
  // In case the SW lives for a while, let it reuse already opened connections: