dexie-cloud-addon 4.1.0-alpha.19 → 4.1.0-alpha.20
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/TSON.d.ts +1 -1
- package/dist/modern/dexie-cloud-addon.js +41 -40
- 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/getInvitesObservable.d.ts +11 -11
- package/dist/modern/service-worker.js +42 -41
- 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/TSON.d.ts +1 -1
- package/dist/umd/dexie-cloud-addon.js +41 -40
- 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/getInvitesObservable.d.ts +11 -11
- package/dist/umd/service-worker.js +42 -41
- 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 +2 -2
|
@@ -3,21 +3,21 @@ export declare const getInvitesObservable: (x: Dexie) => import("./mapValueObser
|
|
|
3
3
|
accept(): Promise<void>;
|
|
4
4
|
reject(): Promise<void>;
|
|
5
5
|
id: string;
|
|
6
|
-
userId?: string
|
|
7
|
-
email?: string
|
|
8
|
-
name?: string
|
|
9
|
-
invite?: boolean
|
|
10
|
-
invitedDate?: Date
|
|
6
|
+
userId?: string;
|
|
7
|
+
email?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
invite?: boolean;
|
|
10
|
+
invitedDate?: Date;
|
|
11
11
|
invitedBy?: {
|
|
12
12
|
name: string;
|
|
13
13
|
email: string;
|
|
14
14
|
userId: string;
|
|
15
|
-
}
|
|
16
|
-
accepted?: Date
|
|
17
|
-
rejected?: Date
|
|
18
|
-
roles?: string[]
|
|
19
|
-
permissions?: import("dexie-cloud-common").DBPermissionSet
|
|
15
|
+
};
|
|
16
|
+
accepted?: Date;
|
|
17
|
+
rejected?: Date;
|
|
18
|
+
roles?: string[];
|
|
19
|
+
permissions?: import("dexie-cloud-common").DBPermissionSet;
|
|
20
20
|
realmId: string;
|
|
21
21
|
owner: string;
|
|
22
|
-
$ts?: number
|
|
22
|
+
$ts?: number;
|
|
23
23
|
}[]>;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.1.0-alpha.
|
|
11
|
+
* Version 4.1.0-alpha.20, Wed Oct 23 2024
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -1768,8 +1768,8 @@
|
|
|
1768
1768
|
});
|
|
1769
1769
|
}
|
|
1770
1770
|
function registerPeriodicSyncEvent(db) {
|
|
1771
|
-
var _a;
|
|
1772
1771
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1772
|
+
var _a;
|
|
1773
1773
|
try {
|
|
1774
1774
|
// Register periodicSync event to SW:
|
|
1775
1775
|
// @ts-ignore
|
|
@@ -1834,8 +1834,8 @@
|
|
|
1834
1834
|
return btoa(strs.join(""));
|
|
1835
1835
|
};
|
|
1836
1836
|
|
|
1837
|
-
function computeRealmSetHash(
|
|
1838
|
-
return __awaiter(this,
|
|
1837
|
+
function computeRealmSetHash(_a) {
|
|
1838
|
+
return __awaiter(this, arguments, void 0, function* ({ realms, inviteRealms, }) {
|
|
1839
1839
|
const data = JSON.stringify([
|
|
1840
1840
|
...realms.map((realmId) => ({ realmId, accepted: true })),
|
|
1841
1841
|
...inviteRealms.map((realmId) => ({ realmId, accepted: false })),
|
|
@@ -1871,8 +1871,8 @@
|
|
|
1871
1871
|
return concat.apply([], a);
|
|
1872
1872
|
}
|
|
1873
1873
|
|
|
1874
|
-
function listClientChanges(
|
|
1875
|
-
return __awaiter(this,
|
|
1874
|
+
function listClientChanges(mutationTables_1, db_1) {
|
|
1875
|
+
return __awaiter(this, arguments, void 0, function* (mutationTables, db, { since = {}, limit = Infinity } = {}) {
|
|
1876
1876
|
const allMutsOnTables = yield Promise.all(mutationTables.map((mutationTable) => __awaiter(this, void 0, void 0, function* () {
|
|
1877
1877
|
const tableName = getTableFromMutationTable(mutationTable.name);
|
|
1878
1878
|
const lastRevision = since[tableName];
|
|
@@ -3519,8 +3519,8 @@
|
|
|
3519
3519
|
}
|
|
3520
3520
|
|
|
3521
3521
|
function loadAccessToken(db) {
|
|
3522
|
-
var _a, _b, _c;
|
|
3523
3522
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3523
|
+
var _a, _b, _c;
|
|
3524
3524
|
const currentUser = yield db.getCurrentUser();
|
|
3525
3525
|
const { accessToken, accessTokenExpiration, refreshToken, refreshTokenExpiration, claims, } = currentUser;
|
|
3526
3526
|
if (!accessToken)
|
|
@@ -4350,8 +4350,8 @@
|
|
|
4350
4350
|
// seconds (given that there is a Ratelimit-Reset header).
|
|
4351
4351
|
let syncRatelimitDelays = new WeakMap();
|
|
4352
4352
|
function checkSyncRateLimitDelay(db) {
|
|
4353
|
-
var _a, _b;
|
|
4354
4353
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4354
|
+
var _a, _b;
|
|
4355
4355
|
const delatMilliseconds = ((_b = (_a = syncRatelimitDelays.get(db)) === null || _a === void 0 ? void 0 : _a.getTime()) !== null && _b !== void 0 ? _b : 0) - Date.now();
|
|
4356
4356
|
if (delatMilliseconds > 0) {
|
|
4357
4357
|
console.debug(`Stalling sync request ${delatMilliseconds} ms to spare ratelimits`);
|
|
@@ -4755,8 +4755,8 @@
|
|
|
4755
4755
|
}
|
|
4756
4756
|
|
|
4757
4757
|
function applyYServerMessages(yMessages, db) {
|
|
4758
|
-
var _a;
|
|
4759
4758
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4759
|
+
var _a;
|
|
4760
4760
|
const result = {};
|
|
4761
4761
|
for (const m of yMessages) {
|
|
4762
4762
|
switch (m.type) {
|
|
@@ -4821,8 +4821,8 @@
|
|
|
4821
4821
|
}
|
|
4822
4822
|
|
|
4823
4823
|
function updateYSyncStates(lastUpdateIdsBeforeSync, receivedUntilsAfterSync, db, serverRevision) {
|
|
4824
|
-
var _a, _b, _c, _d, _e;
|
|
4825
4824
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4825
|
+
var _a, _b, _c, _d, _e;
|
|
4826
4826
|
// We want to update unsentFrom for each yTable to the value specified in first argument
|
|
4827
4827
|
// because we got those values before we synced with server and here we are back from server
|
|
4828
4828
|
// that has successfully received all those messages - no matter if the last update was a client or server update,
|
|
@@ -4887,8 +4887,8 @@
|
|
|
4887
4887
|
const BINSTREAM_TYPE_REALMID = 1;
|
|
4888
4888
|
const BINSTREAM_TYPE_TABLE_AND_PROP = 2;
|
|
4889
4889
|
const BINSTREAM_TYPE_DOCUMENT = 3;
|
|
4890
|
-
function downloadYDocsFromServer(
|
|
4891
|
-
return __awaiter(this,
|
|
4890
|
+
function downloadYDocsFromServer(db_1, databaseUrl_1, _a) {
|
|
4891
|
+
return __awaiter(this, arguments, void 0, function* (db, databaseUrl, { yDownloadedRealms, realms }) {
|
|
4892
4892
|
if (yDownloadedRealms &&
|
|
4893
4893
|
realms &&
|
|
4894
4894
|
realms.every((realmId) => yDownloadedRealms[realmId] === '*')) {
|
|
@@ -5046,11 +5046,11 @@
|
|
|
5046
5046
|
return Promise.reject(error);
|
|
5047
5047
|
}));
|
|
5048
5048
|
}
|
|
5049
|
-
function _sync(
|
|
5050
|
-
isInitialSync
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5049
|
+
function _sync(db_1, options_1, schema_1) {
|
|
5050
|
+
return __awaiter(this, arguments, void 0, function* (db, options, schema, { isInitialSync, cancelToken, justCheckIfNeeded, purpose } = {
|
|
5051
|
+
isInitialSync: false,
|
|
5052
|
+
}) {
|
|
5053
|
+
var _a;
|
|
5054
5054
|
if (!justCheckIfNeeded) {
|
|
5055
5055
|
console.debug('SYNC STARTED', { isInitialSync, purpose });
|
|
5056
5056
|
}
|
|
@@ -5092,7 +5092,7 @@
|
|
|
5092
5092
|
const [clientChangeSet, syncState, baseRevs, { yMessages, lastUpdateIds }] = yield db.transaction('r', db.tables, () => __awaiter(this, void 0, void 0, function* () {
|
|
5093
5093
|
const syncState = yield db.getPersistedSyncState();
|
|
5094
5094
|
const baseRevs = yield db.$baseRevs.toArray();
|
|
5095
|
-
let clientChanges = yield listClientChanges(mutationTables);
|
|
5095
|
+
let clientChanges = yield listClientChanges(mutationTables, db);
|
|
5096
5096
|
const yResults = yield listYClientMessagesAndStateVector(db, tablesToSync);
|
|
5097
5097
|
throwIfCancelled(cancelToken);
|
|
5098
5098
|
if (doSyncify) {
|
|
@@ -5361,8 +5361,8 @@
|
|
|
5361
5361
|
event.next(null);
|
|
5362
5362
|
}
|
|
5363
5363
|
function consumeQueue() {
|
|
5364
|
-
var _a, _b, _c, _d, _e, _f;
|
|
5365
5364
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5365
|
+
var _a, _b, _c, _d, _e, _f;
|
|
5366
5366
|
while (queue.length > 0) {
|
|
5367
5367
|
const msg = queue.shift();
|
|
5368
5368
|
try {
|
|
@@ -5677,8 +5677,8 @@
|
|
|
5677
5677
|
}
|
|
5678
5678
|
});
|
|
5679
5679
|
}
|
|
5680
|
-
function _logout(
|
|
5681
|
-
return __awaiter(this,
|
|
5680
|
+
function _logout(db_1) {
|
|
5681
|
+
return __awaiter(this, arguments, void 0, function* (db, { deleteUnsyncedData = false } = {}) {
|
|
5682
5682
|
// Clear the database without emptying configuration options.
|
|
5683
5683
|
const [numUnsynced, loggedOut] = yield db.dx.transaction('rw', db.dx.tables, (tx) => __awaiter(this, void 0, void 0, function* () {
|
|
5684
5684
|
// @ts-ignore
|
|
@@ -5716,11 +5716,11 @@
|
|
|
5716
5716
|
|
|
5717
5717
|
function otpFetchTokenCallback(db) {
|
|
5718
5718
|
const { userInteraction } = db.cloud;
|
|
5719
|
-
return function otpAuthenticate(
|
|
5720
|
-
|
|
5721
|
-
|
|
5719
|
+
return function otpAuthenticate(_a) {
|
|
5720
|
+
return __awaiter(this, arguments, void 0, function* ({ public_key, hints }) {
|
|
5721
|
+
var _b;
|
|
5722
5722
|
let tokenRequest;
|
|
5723
|
-
const url = (
|
|
5723
|
+
const url = (_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.databaseUrl;
|
|
5724
5724
|
if (!url)
|
|
5725
5725
|
throw new Error(`No database URL given.`);
|
|
5726
5726
|
if ((hints === null || hints === void 0 ? void 0 : hints.grant_type) === 'demo') {
|
|
@@ -5886,8 +5886,8 @@
|
|
|
5886
5886
|
}
|
|
5887
5887
|
|
|
5888
5888
|
function login(db, hints) {
|
|
5889
|
-
var _a;
|
|
5890
5889
|
return __awaiter(this, void 0, void 0, function* () {
|
|
5890
|
+
var _a;
|
|
5891
5891
|
const currentUser = yield db.getCurrentUser();
|
|
5892
5892
|
const origUserId = currentUser.userId;
|
|
5893
5893
|
if (currentUser.isLoggedIn && (!hints || (!hints.email && !hints.userId))) {
|
|
@@ -7100,7 +7100,7 @@
|
|
|
7100
7100
|
return db.cloud.persistedSyncState.pipe(filter((syncState) => (syncState === null || syncState === void 0 ? void 0 : syncState.realms.includes(userLogin.userId)) || false), take(1), map((syncState) => [userLogin, syncState]));
|
|
7101
7101
|
}
|
|
7102
7102
|
return new rxjs.BehaviorSubject([userLogin, syncState]);
|
|
7103
|
-
}), switchMap((
|
|
7103
|
+
}), switchMap((_a) => __awaiter(this, [_a], void 0, function* ([userLogin, syncState]) { return [userLogin, yield computeRealmSetHash(syncState)]; })), distinctUntilChanged(([prevUser, prevHash], [currUser, currHash]) => prevUser === currUser && prevHash === currHash), switchMap(([userLogin, realmSetHash]) => {
|
|
7104
7104
|
var _a;
|
|
7105
7105
|
if (!((_a = db.cloud.persistedSyncState) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
7106
7106
|
// Restart the flow if persistedSyncState is not yet available.
|
|
@@ -7161,8 +7161,8 @@
|
|
|
7161
7161
|
}
|
|
7162
7162
|
|
|
7163
7163
|
function isSyncNeeded(db) {
|
|
7164
|
-
var _a;
|
|
7165
7164
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7165
|
+
var _a;
|
|
7166
7166
|
return ((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.databaseUrl) && db.cloud.schema
|
|
7167
7167
|
? yield sync(db, db.cloud.options, db.cloud.schema, { justCheckIfNeeded: true })
|
|
7168
7168
|
: false;
|
|
@@ -7846,6 +7846,7 @@
|
|
|
7846
7846
|
// If user can update any prop in any table in this realm, return true unless
|
|
7847
7847
|
// it regards to ownership change:
|
|
7848
7848
|
if (this.permissions.update === '*') {
|
|
7849
|
+
// @ts-ignore
|
|
7849
7850
|
return props.every((prop) => prop !== 'owner');
|
|
7850
7851
|
}
|
|
7851
7852
|
const tablePermissions = (_b = this.permissions.update) === null || _b === void 0 ? void 0 : _b[this.tableName];
|
|
@@ -7929,8 +7930,8 @@
|
|
|
7929
7930
|
get() {
|
|
7930
7931
|
if (awareness)
|
|
7931
7932
|
return awareness;
|
|
7932
|
-
awarenessWeakMap.set(doc, awareness);
|
|
7933
7933
|
awareness = createAwareness(db, doc, provider);
|
|
7934
|
+
awarenessWeakMap.set(doc, awareness);
|
|
7934
7935
|
return awareness;
|
|
7935
7936
|
}
|
|
7936
7937
|
});
|
|
@@ -8092,7 +8093,7 @@
|
|
|
8092
8093
|
const syncComplete = new rxjs.Subject();
|
|
8093
8094
|
dexie.cloud = {
|
|
8094
8095
|
// @ts-ignore
|
|
8095
|
-
version: "4.1.0-alpha.
|
|
8096
|
+
version: "4.1.0-alpha.20",
|
|
8096
8097
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
8097
8098
|
schema: null,
|
|
8098
8099
|
get currentUserId() {
|
|
@@ -8128,16 +8129,16 @@
|
|
|
8128
8129
|
}
|
|
8129
8130
|
updateSchemaFromOptions(dexie.cloud.schema, dexie.cloud.options);
|
|
8130
8131
|
},
|
|
8131
|
-
logout(
|
|
8132
|
-
return __awaiter(this,
|
|
8132
|
+
logout() {
|
|
8133
|
+
return __awaiter(this, arguments, void 0, function* ({ force } = {}) {
|
|
8133
8134
|
force
|
|
8134
8135
|
? yield _logout(DexieCloudDB(dexie), { deleteUnsyncedData: true })
|
|
8135
8136
|
: yield logout(DexieCloudDB(dexie));
|
|
8136
8137
|
});
|
|
8137
8138
|
},
|
|
8138
|
-
sync(
|
|
8139
|
-
|
|
8140
|
-
|
|
8139
|
+
sync() {
|
|
8140
|
+
return __awaiter(this, arguments, void 0, function* ({ wait, purpose } = { wait: true, purpose: 'push' }) {
|
|
8141
|
+
var _a;
|
|
8141
8142
|
if (wait === undefined)
|
|
8142
8143
|
wait = true;
|
|
8143
8144
|
const db = DexieCloudDB(dexie);
|
|
@@ -8195,8 +8196,8 @@
|
|
|
8195
8196
|
dexie.use(createImplicitPropSetterMiddleware(DexieCloudDB(dexie)));
|
|
8196
8197
|
dexie.use(createIdGenerationMiddleware(DexieCloudDB(dexie)));
|
|
8197
8198
|
function onDbReady(dexie) {
|
|
8198
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
8199
8199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8200
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
8200
8201
|
closed = false; // As Dexie calls us, we are not closed anymore. Maybe reopened? Remember db.ready event is registered with sticky flag!
|
|
8201
8202
|
const db = DexieCloudDB(dexie);
|
|
8202
8203
|
// Setup default GUI:
|
|
@@ -8219,7 +8220,7 @@
|
|
|
8219
8220
|
? yield navigator.serviceWorker.getRegistrations()
|
|
8220
8221
|
: [];
|
|
8221
8222
|
const [initiallySynced, lastSyncedRealms] = yield db.transaction('rw', db.$syncState, () => __awaiter(this, void 0, void 0, function* () {
|
|
8222
|
-
var
|
|
8223
|
+
var _a, _b;
|
|
8223
8224
|
const { options, schema } = db.cloud;
|
|
8224
8225
|
const [persistedOptions, persistedSchema, persistedSyncState] = yield Promise.all([
|
|
8225
8226
|
db.getOptions(),
|
|
@@ -8241,7 +8242,7 @@
|
|
|
8241
8242
|
delete newPersistedOptions.awarenessProtocol;
|
|
8242
8243
|
yield db.$syncState.put(newPersistedOptions, 'options');
|
|
8243
8244
|
}
|
|
8244
|
-
if (((
|
|
8245
|
+
if (((_a = db.cloud.options) === null || _a === void 0 ? void 0 : _a.tryUseServiceWorker) &&
|
|
8245
8246
|
'serviceWorker' in navigator &&
|
|
8246
8247
|
swRegistrations.length > 0 &&
|
|
8247
8248
|
!DISABLE_SERVICEWORKER_STRATEGY) {
|
|
@@ -8255,7 +8256,7 @@
|
|
|
8255
8256
|
// Not configured for using service worker or no service worker
|
|
8256
8257
|
// registration exists. Don't rely on service worker to do any job.
|
|
8257
8258
|
// Use LocalSyncWorker instead.
|
|
8258
|
-
if (((
|
|
8259
|
+
if (((_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.tryUseServiceWorker) &&
|
|
8259
8260
|
!db.cloud.isServiceWorkerDB) {
|
|
8260
8261
|
console.debug('dexie-cloud-addon: Not using service worker.', swRegistrations.length === 0
|
|
8261
8262
|
? 'No SW registrations found.'
|
|
@@ -8394,7 +8395,7 @@
|
|
|
8394
8395
|
}
|
|
8395
8396
|
}
|
|
8396
8397
|
// @ts-ignore
|
|
8397
|
-
dexieCloud.version = "4.1.0-alpha.
|
|
8398
|
+
dexieCloud.version = "4.1.0-alpha.20";
|
|
8398
8399
|
Dexie.Cloud = dexieCloud;
|
|
8399
8400
|
|
|
8400
8401
|
// In case the SW lives for a while, let it reuse already opened connections:
|
|
@@ -8424,8 +8425,8 @@
|
|
|
8424
8425
|
}
|
|
8425
8426
|
return promise;
|
|
8426
8427
|
function _syncDB(dbName, purpose) {
|
|
8427
|
-
var _a;
|
|
8428
8428
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8429
|
+
var _a;
|
|
8429
8430
|
let db = managedDBs.get(dbName);
|
|
8430
8431
|
if (!db) {
|
|
8431
8432
|
console.debug('Dexie Cloud SW: Creating new Dexie instance for', dbName);
|