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
|
*
|
|
@@ -3677,8 +3677,6 @@ function prodLog(level, ...args) {
|
|
|
3677
3677
|
*/
|
|
3678
3678
|
function setCurrentUser(db, user) {
|
|
3679
3679
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3680
|
-
if (user.userId === db.cloud.currentUserId)
|
|
3681
|
-
return; // Already this user.
|
|
3682
3680
|
const $logins = db.table('$logins');
|
|
3683
3681
|
yield db.transaction('rw', $logins, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
3684
3682
|
const existingLogins = yield $logins.toArray();
|
|
@@ -6158,8 +6156,14 @@ function createIdGenerationMiddleware(db) {
|
|
|
6158
6156
|
}
|
|
6159
6157
|
return Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6160
6158
|
var _a, _b;
|
|
6161
|
-
|
|
6162
|
-
if (
|
|
6159
|
+
const idbtrans = req.trans;
|
|
6160
|
+
if (idbtrans.mode === 'versionchange') {
|
|
6161
|
+
// Tell all the other middlewares to skip bothering. We're in versionchange mode.
|
|
6162
|
+
// dexie-cloud is not initialized yet.
|
|
6163
|
+
idbtrans.disableChangeTracking = true;
|
|
6164
|
+
idbtrans.disableAccessControl = true;
|
|
6165
|
+
}
|
|
6166
|
+
if (idbtrans.disableChangeTracking) {
|
|
6163
6167
|
// Disable ID policy checks and ID generation
|
|
6164
6168
|
return table.mutate(req);
|
|
6165
6169
|
}
|
|
@@ -6216,17 +6220,13 @@ function createImplicitPropSetterMiddleware(db) {
|
|
|
6216
6220
|
return Object.assign(Object.assign({}, core), { table: (tableName) => {
|
|
6217
6221
|
const table = core.table(tableName);
|
|
6218
6222
|
return Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6219
|
-
var _a, _b, _c, _d;
|
|
6220
|
-
|
|
6221
|
-
if (
|
|
6223
|
+
var _a, _b, _c, _d, _e, _f;
|
|
6224
|
+
const trans = req.trans;
|
|
6225
|
+
if (trans.disableChangeTracking) {
|
|
6222
6226
|
return table.mutate(req);
|
|
6223
6227
|
}
|
|
6224
|
-
const
|
|
6225
|
-
if ((
|
|
6226
|
-
if (trans.mode === 'versionchange') {
|
|
6227
|
-
// Don't mutate tables marked for sync in versionchange transactions.
|
|
6228
|
-
return Promise.reject(new Dexie.UpgradeError(`Dexie Cloud Addon: Cannot upgrade or populate synced table "${tableName}". See https://dexie.org/cloud/docs/best-practices`));
|
|
6229
|
-
}
|
|
6228
|
+
const currentUserId = (_b = (_a = trans.currentUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : UNAUTHORIZED_USER.userId;
|
|
6229
|
+
if ((_d = (_c = db.cloud.schema) === null || _c === void 0 ? void 0 : _c[tableName]) === null || _d === void 0 ? void 0 : _d.markedForSync) {
|
|
6230
6230
|
if (req.type === 'add' || req.type === 'put') {
|
|
6231
6231
|
if (tableName === 'members') {
|
|
6232
6232
|
for (const member of req.values) {
|
|
@@ -6250,12 +6250,12 @@ function createImplicitPropSetterMiddleware(db) {
|
|
|
6250
6250
|
// and expect them to be returned. That scenario must work also when db.cloud.currentUserId === 'unauthorized'.
|
|
6251
6251
|
for (const obj of req.values) {
|
|
6252
6252
|
if (!obj.owner) {
|
|
6253
|
-
obj.owner =
|
|
6253
|
+
obj.owner = currentUserId;
|
|
6254
6254
|
}
|
|
6255
6255
|
if (!obj.realmId) {
|
|
6256
|
-
obj.realmId =
|
|
6256
|
+
obj.realmId = currentUserId;
|
|
6257
6257
|
}
|
|
6258
|
-
const key = (
|
|
6258
|
+
const key = (_f = (_e = table.schema.primaryKey).extractKey) === null || _f === void 0 ? void 0 : _f.call(_e, obj);
|
|
6259
6259
|
if (typeof key === 'string' && key[0] === '#') {
|
|
6260
6260
|
// Add $ts prop for put operations and
|
|
6261
6261
|
// disable update operations as well as consistent
|
|
@@ -6351,16 +6351,14 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
|
|
|
6351
6351
|
name: 'MutationTrackingMiddleware',
|
|
6352
6352
|
level: 1,
|
|
6353
6353
|
create: (core) => {
|
|
6354
|
+
const allTableNames = new Set(core.schema.tables.map((t) => t.name));
|
|
6354
6355
|
const ordinaryTables = core.schema.tables.filter((t) => !/^\$/.test(t.name));
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
}
|
|
6362
|
-
catch (_a) {
|
|
6363
|
-
throwVersionIncrementNeeded();
|
|
6356
|
+
const mutTableMap = new Map();
|
|
6357
|
+
for (const tbl of ordinaryTables) {
|
|
6358
|
+
const mutationTableName = `$${tbl.name}_mutations`;
|
|
6359
|
+
if (allTableNames.has(mutationTableName)) {
|
|
6360
|
+
mutTableMap.set(tbl.name, core.table(mutationTableName));
|
|
6361
|
+
}
|
|
6364
6362
|
}
|
|
6365
6363
|
return Object.assign(Object.assign({}, core), { transaction: (tables, mode) => {
|
|
6366
6364
|
let tx;
|
|
@@ -6438,6 +6436,11 @@ function createMutationTrackingMiddleware({ currentUserObservable, db, }) {
|
|
|
6438
6436
|
}
|
|
6439
6437
|
const { schema } = table;
|
|
6440
6438
|
const mutsTable = mutTableMap.get(tableName);
|
|
6439
|
+
if (!mutsTable) {
|
|
6440
|
+
// We cannot track mutations on this table because there is no mutations table for it.
|
|
6441
|
+
// This might happen in upgraders that executes before cloud schema is applied.
|
|
6442
|
+
return table;
|
|
6443
|
+
}
|
|
6441
6444
|
return guardedTable(Object.assign(Object.assign({}, table), { mutate: (req) => {
|
|
6442
6445
|
var _a, _b, _c;
|
|
6443
6446
|
const trans = req.trans;
|
|
@@ -8351,7 +8354,7 @@ function dexieCloud(dexie) {
|
|
|
8351
8354
|
const syncComplete = new Subject();
|
|
8352
8355
|
dexie.cloud = {
|
|
8353
8356
|
// @ts-ignore
|
|
8354
|
-
version: "4.1.0-beta.
|
|
8357
|
+
version: "4.1.0-beta.44",
|
|
8355
8358
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
8356
8359
|
schema: null,
|
|
8357
8360
|
get currentUserId() {
|
|
@@ -8669,7 +8672,7 @@ function dexieCloud(dexie) {
|
|
|
8669
8672
|
}
|
|
8670
8673
|
}
|
|
8671
8674
|
// @ts-ignore
|
|
8672
|
-
dexieCloud.version = "4.1.0-beta.
|
|
8675
|
+
dexieCloud.version = "4.1.0-beta.44";
|
|
8673
8676
|
Dexie.Cloud = dexieCloud;
|
|
8674
8677
|
|
|
8675
8678
|
export { dexieCloud as default, defineYDocTrigger, dexieCloud, getTiedObjectId, getTiedRealmId, resolveText };
|