dexie-cloud-addon 4.0.1-beta.36 → 4.0.1-beta.38

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.
@@ -108,7 +108,7 @@
108
108
  *
109
109
  * ==========================================================================
110
110
  *
111
- * Version 4.0.1-beta.36, Mon Apr 17 2023
111
+ * Version 4.0.1-beta.38, Mon Apr 17 2023
112
112
  *
113
113
  * https://dexie.org
114
114
  *
@@ -3758,7 +3758,10 @@
3758
3758
  function cloneChange(change, rewriteValues) {
3759
3759
  // clone on demand:
3760
3760
  return Object.assign(Object.assign({}, change), { muts: rewriteValues
3761
- ? change.muts.map(function (m) { return (Object.assign(Object.assign({}, m), { keys: m.keys.slice(), values: m.values.slice() })); })
3761
+ ? change.muts.map(function (m) {
3762
+ return (m.type === 'insert' || m.type === 'upsert') && m.values
3763
+ ? Object.assign(Object.assign({}, m), { keys: m.keys.slice(), values: m.values.slice() }) : Object.assign(Object.assign({}, m), { keys: m.keys.slice() });
3764
+ })
3762
3765
  : change.muts.map(function (m) { return (Object.assign(Object.assign({}, m), { keys: m.keys.slice() })); }) });
3763
3766
  }
3764
3767
  //import {BisonWebStreamReader} from "dreambase-library/dist/typeson-simplified/BisonWebStreamReader";
@@ -5448,6 +5451,38 @@
5448
5451
  function overrideParseStoresSpec(origFunc, dexie) {
5449
5452
  return function (stores, dbSchema) {
5450
5453
  var storesClone = Object.assign(Object.assign({}, DEXIE_CLOUD_SCHEMA), stores);
5454
+ // Merge indexes of DEXIE_CLOUD_SCHEMA with stores
5455
+ Object.keys(DEXIE_CLOUD_SCHEMA).forEach(function (tableName) {
5456
+ var schemaSrc = storesClone[tableName];
5457
+ // Verify that they don't try to delete a table that is needed for access control of Dexie Cloud
5458
+ if (schemaSrc == null) {
5459
+ // They try to delete one of the built-in schema tables.
5460
+ throw new Error("Cannot delete table ".concat(tableName, " as it is needed for access control of Dexie Cloud"));
5461
+ }
5462
+ // If not trying to override a built-in table, then we can skip this and continue to next table.
5463
+ if (!stores[tableName]) {
5464
+ // They haven't tried to declare this table. No need to merge indexes.
5465
+ return; // Continue
5466
+ }
5467
+ // They have declared this table. Merge indexes in case they didn't declare all indexes we need.
5468
+ var requestedIndexes = schemaSrc.split(',').map(function (spec) { return spec.trim(); });
5469
+ var builtInIndexes = DEXIE_CLOUD_SCHEMA[tableName].split(',').map(function (spec) { return spec.trim(); });
5470
+ var requestedIndexSet = new Set(requestedIndexes.map(function (index) { return index.replace(/([&*]|\+\+)/g, ""); }));
5471
+ // Verify that primary key is unchanged
5472
+ if (requestedIndexes[0] !== builtInIndexes[0]) {
5473
+ // Primary key must match exactly
5474
+ throw new Error("Cannot override primary key of table ".concat(tableName, ". Please declare it as {").concat(tableName, ": ").concat(JSON.stringify(DEXIE_CLOUD_SCHEMA[tableName])));
5475
+ }
5476
+ // Merge indexes
5477
+ for (var i_6 = 1; i_6 < builtInIndexes.length; ++i_6) {
5478
+ var builtInIndex = builtInIndexes[i_6];
5479
+ if (!requestedIndexSet.has(builtInIndex.replace(/([&*]|\+\+)/g, ""))) {
5480
+ // Add built-in index if not already requested
5481
+ storesClone[tableName] += ",".concat(builtInIndex);
5482
+ }
5483
+ }
5484
+ });
5485
+ // Populate dexie.cloud.schema
5451
5486
  var cloudSchema = dexie.cloud.schema || (dexie.cloud.schema = {});
5452
5487
  var allPrefixes = new Set();
5453
5488
  Object.keys(storesClone).forEach(function (tableName) {
@@ -7046,7 +7081,7 @@
7046
7081
  });
7047
7082
  var syncComplete = new rxjs.Subject();
7048
7083
  dexie.cloud = {
7049
- version: '4.0.1-beta.36',
7084
+ version: '4.0.1-beta.38',
7050
7085
  options: Object.assign({}, DEFAULT_OPTIONS),
7051
7086
  schema: null,
7052
7087
  get currentUserId() {
@@ -7385,7 +7420,7 @@
7385
7420
  });
7386
7421
  }
7387
7422
  }
7388
- dexieCloud.version = '4.0.1-beta.36';
7423
+ dexieCloud.version = '4.0.1-beta.38';
7389
7424
  Dexie__default["default"].Cloud = dexieCloud;
7390
7425
 
7391
7426
  exports["default"] = dexieCloud;