dexie-cloud-addon 4.1.0-beta.43 → 4.1.0-beta.44
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/modern/dexie-cloud-addon.js +31 -28
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/service-worker.js +31 -28
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.js +31 -28
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +31 -28
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.1.0-beta.
|
|
11
|
+
* Version 4.1.0-beta.44, Fri Feb 14 2025
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -5918,8 +5918,6 @@
|
|
|
5918
5918
|
*/
|
|
5919
5919
|
function setCurrentUser(db, user) {
|
|
5920
5920
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5921
|
-
if (user.userId === db.cloud.currentUserId)
|
|
5922
|
-
return; // Already this user.
|
|
5923
5921
|
const $logins = db.table('$logins');
|
|
5924
5922
|
yield db.transaction('rw', $logins, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
5925
5923
|
const existingLogins = yield $logins.toArray();
|
|
@@ -6161,8 +6159,14 @@
|
|
|
6161
6159
|
}
|
|
6162
6160
|
return Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6163
6161
|
var _a, _b;
|
|
6164
|
-
|
|
6165
|
-
if (
|
|
6162
|
+
const idbtrans = req.trans;
|
|
6163
|
+
if (idbtrans.mode === 'versionchange') {
|
|
6164
|
+
// Tell all the other middlewares to skip bothering. We're in versionchange mode.
|
|
6165
|
+
// dexie-cloud is not initialized yet.
|
|
6166
|
+
idbtrans.disableChangeTracking = true;
|
|
6167
|
+
idbtrans.disableAccessControl = true;
|
|
6168
|
+
}
|
|
6169
|
+
if (idbtrans.disableChangeTracking) {
|
|
6166
6170
|
// Disable ID policy checks and ID generation
|
|
6167
6171
|
return table.mutate(req);
|
|
6168
6172
|
}
|
|
@@ -6219,17 +6223,13 @@
|
|
|
6219
6223
|
return Object.assign(Object.assign({}, core), { table: (tableName) => {
|
|
6220
6224
|
const table = core.table(tableName);
|
|
6221
6225
|
return Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6222
|
-
var _a, _b, _c, _d;
|
|
6223
|
-
|
|
6224
|
-
if (
|
|
6226
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6227
|
+
const trans = req.trans;
|
|
6228
|
+
if (trans.disableChangeTracking) {
|
|
6225
6229
|
return table.mutate(req);
|
|
6226
6230
|
}
|
|
6227
|
-
const
|
|
6228
|
-
if ((
|
|
6229
|
-
if (trans.mode === 'versionchange') {
|
|
6230
|
-
// Don't mutate tables marked for sync in versionchange transactions.
|
|
6231
|
-
return Promise.reject(new Dexie.UpgradeError(`Dexie Cloud Addon: Cannot upgrade or populate synced table "${tableName}". See https://dexie.org/cloud/docs/best-practices`));
|
|
6232
|
-
}
|
|
6231
|
+
const currentUserId = (_b = (_a = trans.currentUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : UNAUTHORIZED_USER.userId;
|
|
6232
|
+
if ((_d = (_c = db.cloud.schema) === null || _c === void 0 ? void 0 : _c[tableName]) === null || _d === void 0 ? void 0 : _d.markedForSync) {
|
|
6233
6233
|
if (req.type === 'add' || req.type === 'put') {
|
|
6234
6234
|
if (tableName === 'members') {
|
|
6235
6235
|
for (const member of req.values) {
|
|
@@ -6253,12 +6253,12 @@
|
|
|
6253
6253
|
// and expect them to be returned. That scenario must work also when db.cloud.currentUserId === 'unauthorized'.
|
|
6254
6254
|
for (const obj of req.values) {
|
|
6255
6255
|
if (!obj.owner) {
|
|
6256
|
-
obj.owner =
|
|
6256
|
+
obj.owner = currentUserId;
|
|
6257
6257
|
}
|
|
6258
6258
|
if (!obj.realmId) {
|
|
6259
|
-
obj.realmId =
|
|
6259
|
+
obj.realmId = currentUserId;
|
|
6260
6260
|
}
|
|
6261
|
-
const key = (
|
|
6261
|
+
const key = (_f = (_e = table.schema.primaryKey).extractKey) === null || _f === void 0 ? void 0 : _f.call(_e, obj);
|
|
6262
6262
|
if (typeof key === 'string' && key[0] === '#') {
|
|
6263
6263
|
// Add $ts prop for put operations and
|
|
6264
6264
|
// disable update operations as well as consistent
|
|
@@ -6354,16 +6354,14 @@
|
|
|
6354
6354
|
name: 'MutationTrackingMiddleware',
|
|
6355
6355
|
level: 1,
|
|
6356
6356
|
create: (core) => {
|
|
6357
|
+
const allTableNames = new Set(core.schema.tables.map((t) => t.name));
|
|
6357
6358
|
const ordinaryTables = core.schema.tables.filter((t) => !/^\$/.test(t.name));
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
}
|
|
6365
|
-
catch (_a) {
|
|
6366
|
-
throwVersionIncrementNeeded();
|
|
6359
|
+
const mutTableMap = new Map();
|
|
6360
|
+
for (const tbl of ordinaryTables) {
|
|
6361
|
+
const mutationTableName = `$${tbl.name}_mutations`;
|
|
6362
|
+
if (allTableNames.has(mutationTableName)) {
|
|
6363
|
+
mutTableMap.set(tbl.name, core.table(mutationTableName));
|
|
6364
|
+
}
|
|
6367
6365
|
}
|
|
6368
6366
|
return Object.assign(Object.assign({}, core), { transaction: (tables, mode) => {
|
|
6369
6367
|
let tx;
|
|
@@ -6441,6 +6439,11 @@
|
|
|
6441
6439
|
}
|
|
6442
6440
|
const { schema } = table;
|
|
6443
6441
|
const mutsTable = mutTableMap.get(tableName);
|
|
6442
|
+
if (!mutsTable) {
|
|
6443
|
+
// We cannot track mutations on this table because there is no mutations table for it.
|
|
6444
|
+
// This might happen in upgraders that executes before cloud schema is applied.
|
|
6445
|
+
return table;
|
|
6446
|
+
}
|
|
6444
6447
|
return guardedTable(Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6445
6448
|
var _a, _b, _c;
|
|
6446
6449
|
const trans = req.trans;
|
|
@@ -8191,7 +8194,7 @@
|
|
|
8191
8194
|
const syncComplete = new rxjs.Subject();
|
|
8192
8195
|
dexie.cloud = {
|
|
8193
8196
|
// @ts-ignore
|
|
8194
|
-
version: "4.1.0-beta.
|
|
8197
|
+
version: "4.1.0-beta.44",
|
|
8195
8198
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
8196
8199
|
schema: null,
|
|
8197
8200
|
get currentUserId() {
|
|
@@ -8509,7 +8512,7 @@
|
|
|
8509
8512
|
}
|
|
8510
8513
|
}
|
|
8511
8514
|
// @ts-ignore
|
|
8512
|
-
dexieCloud.version = "4.1.0-beta.
|
|
8515
|
+
dexieCloud.version = "4.1.0-beta.44";
|
|
8513
8516
|
Dexie.Cloud = dexieCloud;
|
|
8514
8517
|
|
|
8515
8518
|
// In case the SW lives for a while, let it reuse already opened connections:
|