dexie-cloud-addon 4.0.0-beta.13 → 4.0.0-beta.16
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 +154 -49
- 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 +152 -46
- 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/module-es5/dexie-cloud-addon.js +109 -45
- package/dist/module-es5/dexie-cloud-addon.js.map +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js +1 -1
- package/dist/module-es5/dexie-cloud-addon.min.js.map +1 -1
- package/dist/types/DexieCloudAPI.d.ts +4 -1
- package/dist/types/DexieCloudEntity.d.ts +8 -0
- package/dist/types/Invite.d.ts +1 -1
- package/dist/types/WSObservable.d.ts +1 -0
- package/dist/types/WebSocketStatus.d.ts +1 -0
- package/dist/types/createMyMembersObservable.d.ts +14 -0
- package/dist/types/currentUserObservable.d.ts +3 -0
- package/dist/types/dexie-cloud-client.d.ts +1 -0
- package/dist/types/getGlobalRolesObservable.d.ts +5 -0
- package/dist/types/getInvitesObservable.d.ts +1 -1
- package/dist/types/helpers/BroadcastedLocalEvent.d.ts +8 -0
- package/dist/types/helpers/visibleState.d.ts +1 -0
- package/dist/types/permissionsLookup.d.ts +9 -0
- package/dist/types/permissionsLookupObservable.d.ts +14 -0
- package/dist/types/sync/globalizePrivateIds.d.ts +4 -0
- package/dist/types/sync/syncServerToClientOnly.d.ts +3 -0
- package/dist/types/types/CloudConnectionStatus.d.ts +0 -0
- package/dist/types/types/ConnectionStatus.d.ts +0 -0
- package/dist/types/types/LoginState.d.ts +41 -0
- package/dist/types/types/SyncConnectionStatus.d.ts +1 -0
- package/dist/types/types/SyncFlowStatus.d.ts +6 -0
- package/dist/types/types/SyncStatus.d.ts +6 -0
- package/dist/umd/dexie-cloud-addon.js +129 -64
- 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 +175 -69
- 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/dist/umd-modern/dexie-cloud-addon.js +172 -66
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +5 -3
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('dexie'), require('rxjs')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'dexie', 'rxjs'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DexieCloud = {}, global.Dexie, global.rxjs));
|
|
5
|
-
}(this, (function (exports, Dexie, rxjs) { 'use strict';
|
|
5
|
+
})(this, (function (exports, Dexie, rxjs) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
*
|
|
109
109
|
* ==========================================================================
|
|
110
110
|
*
|
|
111
|
-
* Version 4.0.0-beta.
|
|
111
|
+
* Version 4.0.0-beta.16, Fri Apr 01 2022
|
|
112
112
|
*
|
|
113
113
|
* https://dexie.org
|
|
114
114
|
*
|
|
@@ -818,7 +818,8 @@
|
|
|
818
818
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
819
819
|
args[_i] = arguments[_i];
|
|
820
820
|
}
|
|
821
|
-
|
|
821
|
+
var delegate = timeoutProvider.delegate;
|
|
822
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) || setTimeout).apply(void 0, __spreadArray([], __read(args)));
|
|
822
823
|
},
|
|
823
824
|
clearTimeout: function (handle) {
|
|
824
825
|
return (clearTimeout)(handle);
|
|
@@ -858,23 +859,20 @@
|
|
|
858
859
|
return new SafeSubscriber(next, error, complete);
|
|
859
860
|
};
|
|
860
861
|
Subscriber.prototype.next = function (value) {
|
|
861
|
-
if (this.isStopped)
|
|
862
|
-
;
|
|
862
|
+
if (this.isStopped) ;
|
|
863
863
|
else {
|
|
864
864
|
this._next(value);
|
|
865
865
|
}
|
|
866
866
|
};
|
|
867
867
|
Subscriber.prototype.error = function (err) {
|
|
868
|
-
if (this.isStopped)
|
|
869
|
-
;
|
|
868
|
+
if (this.isStopped) ;
|
|
870
869
|
else {
|
|
871
870
|
this.isStopped = true;
|
|
872
871
|
this._error(err);
|
|
873
872
|
}
|
|
874
873
|
};
|
|
875
874
|
Subscriber.prototype.complete = function () {
|
|
876
|
-
if (this.isStopped)
|
|
877
|
-
;
|
|
875
|
+
if (this.isStopped) ;
|
|
878
876
|
else {
|
|
879
877
|
this.isStopped = true;
|
|
880
878
|
this._complete();
|
|
@@ -1329,7 +1327,8 @@
|
|
|
1329
1327
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
1330
1328
|
args[_i] = arguments[_i];
|
|
1331
1329
|
}
|
|
1332
|
-
|
|
1330
|
+
var delegate = intervalProvider.delegate;
|
|
1331
|
+
return ((delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) || setInterval).apply(void 0, __spreadArray([], __read(args)));
|
|
1333
1332
|
},
|
|
1334
1333
|
clearInterval: function (handle) {
|
|
1335
1334
|
return (clearInterval)(handle);
|
|
@@ -2127,7 +2126,7 @@
|
|
|
2127
2126
|
resolve(res);
|
|
2128
2127
|
}, onCancel: function () {
|
|
2129
2128
|
userInteraction.next(undefined);
|
|
2130
|
-
reject(new Dexie__default[
|
|
2129
|
+
reject(new Dexie__default["default"].AbortError("User cancelled"));
|
|
2131
2130
|
} });
|
|
2132
2131
|
userInteraction.next(interactionProps);
|
|
2133
2132
|
// Start subscribing for external updates to db.cloud.userInteraction, and if so, cancel this request.
|
|
@@ -3581,7 +3580,7 @@
|
|
|
3581
3580
|
var rewrittenKey = JSON.stringify(key);
|
|
3582
3581
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
3583
3582
|
if (rewriteValues) {
|
|
3584
|
-
Dexie__default[
|
|
3583
|
+
Dexie__default["default"].setByKeyPath(mutClone.values[keyIndex], primaryKey.keyPath, rewrittenKey);
|
|
3585
3584
|
}
|
|
3586
3585
|
}
|
|
3587
3586
|
else if (key[0] === '#') {
|
|
@@ -3594,7 +3593,7 @@
|
|
|
3594
3593
|
var rewrittenKey = "".concat(key, ":").concat(currentUser.userId);
|
|
3595
3594
|
mutClone.keys[keyIndex] = rewrittenKey;
|
|
3596
3595
|
if (rewriteValues) {
|
|
3597
|
-
Dexie__default[
|
|
3596
|
+
Dexie__default["default"].setByKeyPath(mutClone.values[keyIndex], primaryKey.keyPath, rewrittenKey);
|
|
3598
3597
|
}
|
|
3599
3598
|
}
|
|
3600
3599
|
});
|
|
@@ -3744,7 +3743,7 @@
|
|
|
3744
3743
|
}
|
|
3745
3744
|
function throwIfCancelled(cancelToken) {
|
|
3746
3745
|
if (cancelToken === null || cancelToken === void 0 ? void 0 : cancelToken.cancelled)
|
|
3747
|
-
throw new Dexie__default[
|
|
3746
|
+
throw new Dexie__default["default"].AbortError("Operation was cancelled");
|
|
3748
3747
|
}
|
|
3749
3748
|
/* Need this because navigator.onLine seems to say "false" when it is actually online.
|
|
3750
3749
|
This function relies initially on navigator.onLine but then uses online and offline events
|
|
@@ -3804,7 +3803,7 @@
|
|
|
3804
3803
|
}
|
|
3805
3804
|
}
|
|
3806
3805
|
else {
|
|
3807
|
-
Dexie__default[
|
|
3806
|
+
Dexie__default["default"].setByKeyPath(obj, keyPath, value);
|
|
3808
3807
|
}
|
|
3809
3808
|
}
|
|
3810
3809
|
resultKeys.push(key);
|
|
@@ -3827,7 +3826,7 @@
|
|
|
3827
3826
|
return __generator$1(this, function (_g) {
|
|
3828
3827
|
switch (_g.label) {
|
|
3829
3828
|
case 0:
|
|
3830
|
-
console.debug('Applying server changes', changes, Dexie__default[
|
|
3829
|
+
console.debug('Applying server changes', changes, Dexie__default["default"].currentTransaction);
|
|
3831
3830
|
_loop_3 = function (tableName, muts) {
|
|
3832
3831
|
var table, primaryKey, keyDecoder, _loop_4, _h, muts_2, mut;
|
|
3833
3832
|
return __generator$1(this, function (_j) {
|
|
@@ -3882,7 +3881,7 @@
|
|
|
3882
3881
|
case 3:
|
|
3883
3882
|
keys.forEach(function (key, i) {
|
|
3884
3883
|
// Make sure inbound keys are consistent
|
|
3885
|
-
Dexie__default[
|
|
3884
|
+
Dexie__default["default"].setByKeyPath(mut.values[i], primaryKey.keyPath, key);
|
|
3886
3885
|
});
|
|
3887
3886
|
return [4 /*yield*/, table.bulkAdd(mut.values)];
|
|
3888
3887
|
case 4:
|
|
@@ -3898,7 +3897,7 @@
|
|
|
3898
3897
|
case 8:
|
|
3899
3898
|
keys.forEach(function (key, i) {
|
|
3900
3899
|
// Make sure inbound keys are consistent
|
|
3901
|
-
Dexie__default[
|
|
3900
|
+
Dexie__default["default"].setByKeyPath(mut.values[i], primaryKey.keyPath, key);
|
|
3902
3901
|
});
|
|
3903
3902
|
return [4 /*yield*/, table.bulkPut(mut.values)];
|
|
3904
3903
|
case 9:
|
|
@@ -4570,7 +4569,7 @@
|
|
|
4570
4569
|
}
|
|
4571
4570
|
return [2 /*return*/]; // Ignore message
|
|
4572
4571
|
}
|
|
4573
|
-
return [4 /*yield*/, Dexie__default[
|
|
4572
|
+
return [4 /*yield*/, Dexie__default["default"].waitFor(
|
|
4574
4573
|
// Keep TX in non-IDB work
|
|
4575
4574
|
computeRealmSetHash(syncState))];
|
|
4576
4575
|
case 2:
|
|
@@ -4777,7 +4776,7 @@
|
|
|
4777
4776
|
}
|
|
4778
4777
|
var IS_SERVICE_WORKER = typeof self !== "undefined" && "clients" in self && !self.document;
|
|
4779
4778
|
function throwVersionIncrementNeeded() {
|
|
4780
|
-
throw new Dexie__default[
|
|
4779
|
+
throw new Dexie__default["default"].SchemaError("Version increment needed to allow dexie-cloud change tracking");
|
|
4781
4780
|
}
|
|
4782
4781
|
var toString = {}.toString;
|
|
4783
4782
|
function toStringTag(o) {
|
|
@@ -4891,14 +4890,14 @@
|
|
|
4891
4890
|
if (!table.schema.primaryKey.outbound) {
|
|
4892
4891
|
if (!valueClones)
|
|
4893
4892
|
valueClones = req.values.slice();
|
|
4894
|
-
valueClones[idx] = Dexie__default[
|
|
4895
|
-
Dexie__default[
|
|
4893
|
+
valueClones[idx] = Dexie__default["default"].deepClone(valueClones[idx]);
|
|
4894
|
+
Dexie__default["default"].setByKeyPath(valueClones[idx], table.schema.primaryKey.keyPath, keys[idx]);
|
|
4896
4895
|
}
|
|
4897
4896
|
}
|
|
4898
4897
|
else if (typeof key !== 'string' ||
|
|
4899
4898
|
(!key.startsWith(idPrefix) && !key.startsWith('#' + idPrefix))) {
|
|
4900
4899
|
// Key was specified by caller. Verify it complies with id prefix.
|
|
4901
|
-
throw new Dexie__default[
|
|
4900
|
+
throw new Dexie__default["default"].ConstraintError("The ID \"".concat(key, "\" is not valid for table \"").concat(tableName, "\". ") +
|
|
4902
4901
|
"Primary '@' keys requires the key to be prefixed with \"".concat(idPrefix, "\" (or \"#").concat(idPrefix, ").\n") +
|
|
4903
4902
|
"If you want to generate IDs programmatically, remove '@' from the schema to get rid of this constraint. Dexie Cloud supports custom IDs as long as they are random and globally unique.");
|
|
4904
4903
|
}
|
|
@@ -4923,7 +4922,7 @@
|
|
|
4923
4922
|
var type = Array.isArray(key)
|
|
4924
4923
|
? key.map(toStringTag).join(',')
|
|
4925
4924
|
: toStringTag(key);
|
|
4926
|
-
throw new Dexie__default[
|
|
4925
|
+
throw new Dexie__default["default"].ConstraintError("Invalid primary key type ".concat(type, " for table ").concat(tableName, ". Tables marked for sync has primary keys of type string or Array of string (and optional numbers)"));
|
|
4927
4926
|
}
|
|
4928
4927
|
});
|
|
4929
4928
|
}
|
|
@@ -5463,7 +5462,7 @@
|
|
|
5463
5462
|
});
|
|
5464
5463
|
});
|
|
5465
5464
|
}
|
|
5466
|
-
var USER_INACTIVITY_TIMEOUT =
|
|
5465
|
+
var USER_INACTIVITY_TIMEOUT = 180000; // 3 minutes
|
|
5467
5466
|
var INACTIVE_WAIT_TIME = 20000;
|
|
5468
5467
|
// This observable will be emitted to later down....
|
|
5469
5468
|
var userIsActive = new rxjs.BehaviorSubject(true);
|
|
@@ -5477,9 +5476,12 @@
|
|
|
5477
5476
|
// for just a short time.
|
|
5478
5477
|
var userIsReallyActive = new rxjs.BehaviorSubject(true);
|
|
5479
5478
|
userIsActive
|
|
5480
|
-
.pipe(switchMap(function (isActive) {
|
|
5481
|
-
|
|
5482
|
-
|
|
5479
|
+
.pipe(switchMap(function (isActive) {
|
|
5480
|
+
//console.debug('SyncStatus: DUBB: isActive changed to', isActive);
|
|
5481
|
+
return isActive
|
|
5482
|
+
? rxjs.of(true)
|
|
5483
|
+
: rxjs.of(false).pipe(delay(INACTIVE_WAIT_TIME));
|
|
5484
|
+
}), distinctUntilChanged())
|
|
5483
5485
|
.subscribe(userIsReallyActive);
|
|
5484
5486
|
//
|
|
5485
5487
|
// First create some corner-stone observables to build the flow on
|
|
@@ -5494,7 +5496,7 @@
|
|
|
5494
5496
|
var documentBecomesVisible = visibilityStateIsChanged.pipe(filter(function () { return document.visibilityState === 'visible'; }));
|
|
5495
5497
|
// Any of various user-activity-related events happen:
|
|
5496
5498
|
var userDoesSomething = typeof window !== 'undefined'
|
|
5497
|
-
? rxjs.merge(documentBecomesVisible, rxjs.fromEvent(window, 'mousemove'), rxjs.fromEvent(window, 'keydown'), rxjs.fromEvent(window, 'wheel'), rxjs.fromEvent(window, 'touchmove'))
|
|
5499
|
+
? rxjs.merge(documentBecomesVisible, rxjs.fromEvent(window, 'mousedown'), rxjs.fromEvent(window, 'mousemove'), rxjs.fromEvent(window, 'keydown'), rxjs.fromEvent(window, 'wheel'), rxjs.fromEvent(window, 'touchmove'))
|
|
5498
5500
|
: rxjs.of({});
|
|
5499
5501
|
if (typeof document !== 'undefined') {
|
|
5500
5502
|
//
|
|
@@ -5549,6 +5551,7 @@
|
|
|
5549
5551
|
function WSConnection(databaseUrl, rev, realmSetHash, clientIdentity, token, tokenExpiration, subscriber, messageProducer, webSocketStatus) {
|
|
5550
5552
|
var _this_1 = _super_1.call(this, function () { return _this_1.teardown(); }) || this;
|
|
5551
5553
|
_this_1.id = ++counter;
|
|
5554
|
+
_this_1.reconnecting = false;
|
|
5552
5555
|
console.debug('New WebSocket Connection', _this_1.id, token ? 'authorized' : 'unauthorized');
|
|
5553
5556
|
_this_1.databaseUrl = databaseUrl;
|
|
5554
5557
|
_this_1.rev = rev;
|
|
@@ -5569,7 +5572,7 @@
|
|
|
5569
5572
|
this.disconnect();
|
|
5570
5573
|
};
|
|
5571
5574
|
WSConnection.prototype.disconnect = function () {
|
|
5572
|
-
this.webSocketStatus.next(
|
|
5575
|
+
this.webSocketStatus.next('disconnected');
|
|
5573
5576
|
if (this.pinger) {
|
|
5574
5577
|
clearInterval(this.pinger);
|
|
5575
5578
|
this.pinger = null;
|
|
@@ -5587,17 +5590,25 @@
|
|
|
5587
5590
|
}
|
|
5588
5591
|
};
|
|
5589
5592
|
WSConnection.prototype.reconnect = function () {
|
|
5590
|
-
this
|
|
5591
|
-
this.
|
|
5593
|
+
var _this_1 = this;
|
|
5594
|
+
if (this.reconnecting)
|
|
5595
|
+
return;
|
|
5596
|
+
this.reconnecting = true;
|
|
5597
|
+
try {
|
|
5598
|
+
this.disconnect();
|
|
5599
|
+
}
|
|
5600
|
+
catch (_e) { }
|
|
5601
|
+
this.connect()
|
|
5602
|
+
.catch(function () { })
|
|
5603
|
+
.then(function () { return (_this_1.reconnecting = false); }); // finally()
|
|
5592
5604
|
};
|
|
5593
5605
|
WSConnection.prototype.connect = function () {
|
|
5594
5606
|
return __awaiter$1(this, void 0, void 0, function () {
|
|
5595
|
-
var wsUrl, searchParams, ws;
|
|
5607
|
+
var wsUrl, searchParams, ws, everConnected_1;
|
|
5596
5608
|
var _this_1 = this;
|
|
5597
5609
|
return __generator$1(this, function (_e) {
|
|
5598
5610
|
switch (_e.label) {
|
|
5599
5611
|
case 0:
|
|
5600
|
-
this.webSocketStatus.next("connecting");
|
|
5601
5612
|
this.lastServerActivity = new Date();
|
|
5602
5613
|
if (this.pauseUntil && this.pauseUntil > new Date()) {
|
|
5603
5614
|
console.debug('WS not reconnecting just yet', {
|
|
@@ -5612,12 +5623,14 @@
|
|
|
5612
5623
|
if (!this.databaseUrl)
|
|
5613
5624
|
throw new Error("Cannot connect without a database URL");
|
|
5614
5625
|
if (this.closed) {
|
|
5626
|
+
//console.debug('SyncStatus: DUBB: Ooops it was closed!');
|
|
5615
5627
|
return [2 /*return*/];
|
|
5616
5628
|
}
|
|
5617
5629
|
if (this.tokenExpiration && this.tokenExpiration < new Date()) {
|
|
5618
5630
|
this.subscriber.error(new TokenExpiredError()); // Will be handled in connectWebSocket.ts.
|
|
5619
5631
|
return [2 /*return*/];
|
|
5620
5632
|
}
|
|
5633
|
+
this.webSocketStatus.next('connecting');
|
|
5621
5634
|
this.pinger = setInterval(function () { return __awaiter$1(_this_1, void 0, void 0, function () {
|
|
5622
5635
|
var _this_1 = this;
|
|
5623
5636
|
return __generator$1(this, function (_e) {
|
|
@@ -5667,7 +5680,7 @@
|
|
|
5667
5680
|
searchParams = new URLSearchParams();
|
|
5668
5681
|
if (this.subscriber.closed)
|
|
5669
5682
|
return [2 /*return*/];
|
|
5670
|
-
searchParams.set('v',
|
|
5683
|
+
searchParams.set('v', '2');
|
|
5671
5684
|
searchParams.set('rev', this.rev);
|
|
5672
5685
|
searchParams.set('realmsHash', this.realmSetHash);
|
|
5673
5686
|
searchParams.set('clientId', this.clientIdentity);
|
|
@@ -5708,17 +5721,23 @@
|
|
|
5708
5721
|
_e.label = 1;
|
|
5709
5722
|
case 1:
|
|
5710
5723
|
_e.trys.push([1, 3, , 4]);
|
|
5724
|
+
everConnected_1 = false;
|
|
5711
5725
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
5712
5726
|
ws.onopen = function (event) {
|
|
5713
5727
|
console.debug('dexie-cloud WebSocket onopen');
|
|
5728
|
+
everConnected_1 = true;
|
|
5714
5729
|
resolve(null);
|
|
5715
5730
|
};
|
|
5716
5731
|
ws.onerror = function (event) {
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5732
|
+
if (!everConnected_1) {
|
|
5733
|
+
var error = event.error || new Error('WebSocket Error');
|
|
5734
|
+
_this_1.subscriber.error(error);
|
|
5735
|
+
_this_1.webSocketStatus.next('error');
|
|
5736
|
+
reject(error);
|
|
5737
|
+
}
|
|
5738
|
+
else {
|
|
5739
|
+
_this_1.reconnect();
|
|
5740
|
+
}
|
|
5722
5741
|
};
|
|
5723
5742
|
})];
|
|
5724
5743
|
case 2:
|
|
@@ -5726,8 +5745,9 @@
|
|
|
5726
5745
|
this.messageProducerSubscription = this.messageProducer.subscribe(function (msg) {
|
|
5727
5746
|
var _e;
|
|
5728
5747
|
if (!_this_1.closed) {
|
|
5729
|
-
if (msg.type === 'ready' &&
|
|
5730
|
-
_this_1.webSocketStatus.
|
|
5748
|
+
if (msg.type === 'ready' &&
|
|
5749
|
+
_this_1.webSocketStatus.value !== 'connected') {
|
|
5750
|
+
_this_1.webSocketStatus.next('connected');
|
|
5731
5751
|
}
|
|
5732
5752
|
(_e = _this_1.ws) === null || _e === void 0 ? void 0 : _e.send(TSON.stringify(msg));
|
|
5733
5753
|
}
|
|
@@ -5836,7 +5856,10 @@
|
|
|
5836
5856
|
else {
|
|
5837
5857
|
return rxjs.throwError(error);
|
|
5838
5858
|
}
|
|
5839
|
-
}), catchError(function (error) {
|
|
5859
|
+
}), catchError(function (error) {
|
|
5860
|
+
db.cloud.webSocketStatus.next("error");
|
|
5861
|
+
return rxjs.from(waitAndReconnectWhenUserDoesSomething(error)).pipe(switchMap(function () { return createObservable(); }));
|
|
5862
|
+
}));
|
|
5840
5863
|
}
|
|
5841
5864
|
return createObservable().subscribe(function (msg) {
|
|
5842
5865
|
if (msg) {
|
|
@@ -6027,11 +6050,11 @@
|
|
|
6027
6050
|
var table = _h[_g];
|
|
6028
6051
|
if ((_f = (_e = db.cloud.schema) === null || _e === void 0 ? void 0 : _e[table.name]) === null || _f === void 0 ? void 0 : _f.markedForSync) {
|
|
6029
6052
|
if (table.schema.primKey.auto) {
|
|
6030
|
-
throw new Dexie__default[
|
|
6053
|
+
throw new Dexie__default["default"].SchemaError("Table ".concat(table.name, " is both autoIncremented and synced. ") +
|
|
6031
6054
|
"Use db.cloud.configure({unsyncedTables: [".concat(JSON.stringify(table.name), "]}) to blacklist it from sync"));
|
|
6032
6055
|
}
|
|
6033
6056
|
if (!table.schema.primKey.keyPath) {
|
|
6034
|
-
throw new Dexie__default[
|
|
6057
|
+
throw new Dexie__default["default"].SchemaError("Table ".concat(table.name, " cannot be both synced and outbound. ") +
|
|
6035
6058
|
"Use db.cloud.configure({unsyncedTables: [".concat(JSON.stringify(table.name), "]}) to blacklist it from sync"));
|
|
6036
6059
|
}
|
|
6037
6060
|
}
|
|
@@ -6205,7 +6228,7 @@
|
|
|
6205
6228
|
}
|
|
6206
6229
|
catch (l) {
|
|
6207
6230
|
n = l;
|
|
6208
|
-
} throw n; }, __v: 0 }, p$1.prototype.setState = function (n, l) { var u; u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = c$1({}, this.state), "function" == typeof n && (n = n(c$1({}, u), this.props)), n && c$1(u, n), null != n && this.__v && (l && this.__h.push(l), k$1(this)); }, p$1.prototype.forceUpdate = function (n) { this.__v && (this.__e = !0, n && this.__h.push(n), k$1(this)); }, p$1.prototype.render = y, u$1 = [], i$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b$1.__r = 0
|
|
6231
|
+
} throw n; }, __v: 0 }, p$1.prototype.setState = function (n, l) { var u; u = null != this.__s && this.__s !== this.state ? this.__s : this.__s = c$1({}, this.state), "function" == typeof n && (n = n(c$1({}, u), this.props)), n && c$1(u, n), null != n && this.__v && (l && this.__h.push(l), k$1(this)); }, p$1.prototype.forceUpdate = function (n) { this.__v && (this.__e = !0, n && this.__h.push(n), k$1(this)); }, p$1.prototype.render = y, u$1 = [], i$1 = "function" == typeof Promise ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, b$1.__r = 0;
|
|
6209
6232
|
var Styles = {
|
|
6210
6233
|
Error: {
|
|
6211
6234
|
color: "red",
|
|
@@ -6477,6 +6500,21 @@
|
|
|
6477
6500
|
rv.getValue = function () { return currentValue; };
|
|
6478
6501
|
return rv;
|
|
6479
6502
|
}
|
|
6503
|
+
var getGlobalRolesObservable = associate(function (db) {
|
|
6504
|
+
return createSharedValueObservable(Dexie.liveQuery(function () { return db.roles
|
|
6505
|
+
.where({ realmId: 'rlm-public' })
|
|
6506
|
+
.toArray()
|
|
6507
|
+
.then(function (roles) {
|
|
6508
|
+
var rv = {};
|
|
6509
|
+
for (var _e = 0, _f = roles
|
|
6510
|
+
.slice()
|
|
6511
|
+
.sort(function (a, b) { return (a.sortOrder || 0) - (b.sortOrder || 0); }); _e < _f.length; _e++) {
|
|
6512
|
+
var role = _f[_e];
|
|
6513
|
+
rv[role.name] = role;
|
|
6514
|
+
}
|
|
6515
|
+
return rv;
|
|
6516
|
+
}); }), {});
|
|
6517
|
+
});
|
|
6480
6518
|
var getCurrentUserEmitter = associate(function (db) { return new rxjs.BehaviorSubject(UNAUTHORIZED_USER); });
|
|
6481
6519
|
var getInternalAccessControlObservable = associate(function (db) {
|
|
6482
6520
|
return createSharedValueObservable(getCurrentUserEmitter(db._novip).pipe(switchMap(function (currentUser) { return Dexie.liveQuery(function () { return db.transaction('r', 'realms', 'members', function () { return Promise.all([
|
|
@@ -6579,17 +6617,40 @@
|
|
|
6579
6617
|
return reduced;
|
|
6580
6618
|
}
|
|
6581
6619
|
var getPermissionsLookupObservable = associate(function (db) {
|
|
6582
|
-
var o =
|
|
6620
|
+
var o = createSharedValueObservable(rxjs.combineLatest([
|
|
6621
|
+
getInternalAccessControlObservable(db._novip),
|
|
6622
|
+
getGlobalRolesObservable(db._novip),
|
|
6623
|
+
]).pipe(map(function (_e) {
|
|
6624
|
+
var _f = _e[0], selfMembers = _f.selfMembers, realms = _f.realms, userId = _f.userId, globalRoles = _e[1];
|
|
6625
|
+
return ({
|
|
6626
|
+
selfMembers: selfMembers,
|
|
6627
|
+
realms: realms,
|
|
6628
|
+
userId: userId,
|
|
6629
|
+
globalRoles: globalRoles,
|
|
6630
|
+
});
|
|
6631
|
+
})), {
|
|
6632
|
+
selfMembers: [],
|
|
6633
|
+
realms: [],
|
|
6634
|
+
userId: UNAUTHORIZED_USER.userId,
|
|
6635
|
+
globalRoles: {},
|
|
6636
|
+
});
|
|
6583
6637
|
return mapValueObservable(o, function (_e) {
|
|
6584
6638
|
var _f;
|
|
6585
|
-
var selfMembers = _e.selfMembers, realms = _e.realms, userId = _e.userId;
|
|
6639
|
+
var selfMembers = _e.selfMembers, realms = _e.realms, userId = _e.userId, globalRoles = _e.globalRoles;
|
|
6586
6640
|
var rv = realms
|
|
6587
|
-
.map(function (realm) {
|
|
6588
|
-
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6641
|
+
.map(function (realm) {
|
|
6642
|
+
var selfRealmMembers = selfMembers.filter(function (m) { return m.realmId === realm.realmId; });
|
|
6643
|
+
var directPermissionSets = selfRealmMembers
|
|
6644
|
+
.map(function (m) { return m.permissions; })
|
|
6645
|
+
.filter(function (p) { return p; });
|
|
6646
|
+
var rolePermissionSets = flatten(selfRealmMembers.map(function (m) { return m.roles; }).filter(function (roleName) { return roleName; }))
|
|
6647
|
+
.map(function (role) { return globalRoles[role]; })
|
|
6648
|
+
.filter(function (role) { return role; })
|
|
6649
|
+
.map(function (role) { return role.permissions; });
|
|
6650
|
+
return __assign(__assign({}, realm), { permissions: realm.owner === userId
|
|
6651
|
+
? { manage: '*' }
|
|
6652
|
+
: mergePermissions.apply(void 0, __spreadArray$1(__spreadArray$1([], directPermissionSets, false), rolePermissionSets, false)) });
|
|
6653
|
+
})
|
|
6593
6654
|
.reduce(function (p, c) {
|
|
6594
6655
|
var _e;
|
|
6595
6656
|
return (__assign(__assign({}, p), (_e = {}, _e[c.realmId] = c, _e)));
|
|
@@ -6687,7 +6748,7 @@
|
|
|
6687
6748
|
var realm = permissionsLookup[realmId || dexie.cloud.currentUserId];
|
|
6688
6749
|
if (!realm)
|
|
6689
6750
|
return new PermissionChecker({}, tableName, !owner || owner === dexie.cloud.currentUserId);
|
|
6690
|
-
return new PermissionChecker(realm.permissions, tableName,
|
|
6751
|
+
return new PermissionChecker(realm.permissions, tableName, realmId === dexie.cloud.currentUserId || owner === dexie.cloud.currentUserId);
|
|
6691
6752
|
};
|
|
6692
6753
|
var o = source.pipe(map(mapper));
|
|
6693
6754
|
o.getValue = function () { return mapper(source.getValue()); };
|
|
@@ -6725,6 +6786,7 @@
|
|
|
6725
6786
|
//
|
|
6726
6787
|
var currentUserEmitter = getCurrentUserEmitter(dexie);
|
|
6727
6788
|
var subscriptions = [];
|
|
6789
|
+
var configuredProgramatically = false;
|
|
6728
6790
|
// local sync worker - used when there's no service worker.
|
|
6729
6791
|
var localSyncWorker = null;
|
|
6730
6792
|
dexie.on('ready', function (dexie) { return __awaiter$1(_this_1, void 0, void 0, function () {
|
|
@@ -6750,7 +6812,7 @@
|
|
|
6750
6812
|
var closed = false;
|
|
6751
6813
|
function throwIfClosed() {
|
|
6752
6814
|
if (closed)
|
|
6753
|
-
throw new Dexie__default[
|
|
6815
|
+
throw new Dexie__default["default"].DatabaseClosedError();
|
|
6754
6816
|
}
|
|
6755
6817
|
dbOnClosed(dexie, function () {
|
|
6756
6818
|
subscriptions.forEach(function (subscription) { return subscription.unsubscribe(); });
|
|
@@ -6760,7 +6822,7 @@
|
|
|
6760
6822
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
6761
6823
|
});
|
|
6762
6824
|
dexie.cloud = {
|
|
6763
|
-
version: '4.0.0-beta.
|
|
6825
|
+
version: '4.0.0-beta.16',
|
|
6764
6826
|
options: __assign({}, DEFAULT_OPTIONS),
|
|
6765
6827
|
schema: null,
|
|
6766
6828
|
serverState: null,
|
|
@@ -6794,8 +6856,10 @@
|
|
|
6794
6856
|
});
|
|
6795
6857
|
},
|
|
6796
6858
|
invites: getInvitesObservable(dexie),
|
|
6859
|
+
roles: getGlobalRolesObservable(dexie),
|
|
6797
6860
|
configure: function (options) {
|
|
6798
6861
|
options = dexie.cloud.options = __assign(__assign({}, dexie.cloud.options), options);
|
|
6862
|
+
configuredProgramatically = true;
|
|
6799
6863
|
if (options.databaseUrl && options.nameSuffix) {
|
|
6800
6864
|
// @ts-ignore
|
|
6801
6865
|
dexie.name = "".concat(origIdbName, "-").concat(getDbNameFromDbUrl(options.databaseUrl));
|
|
@@ -6868,7 +6932,7 @@
|
|
|
6868
6932
|
return permissions(dexie._novip, obj, tableName);
|
|
6869
6933
|
},
|
|
6870
6934
|
};
|
|
6871
|
-
dexie.Version.prototype['_parseStoresSpec'] = Dexie__default[
|
|
6935
|
+
dexie.Version.prototype['_parseStoresSpec'] = Dexie__default["default"].override(dexie.Version.prototype['_parseStoresSpec'], function (origFunc) { return overrideParseStoresSpec(origFunc, dexie); });
|
|
6872
6936
|
dexie.Table.prototype.newId = function (_e) {
|
|
6873
6937
|
var _f = _e === void 0 ? {} : _e, colocateWith = _f.colocateWith;
|
|
6874
6938
|
var shardKey = colocateWith && colocateWith.substr(colocateWith.length - 3);
|
|
@@ -6930,7 +6994,7 @@
|
|
|
6930
6994
|
])];
|
|
6931
6995
|
case 1:
|
|
6932
6996
|
_f = _m.sent(), persistedOptions = _f[0], persistedSchema = _f[1], persistedSyncState = _f[2];
|
|
6933
|
-
if (!!
|
|
6997
|
+
if (!!configuredProgramatically) return [3 /*break*/, 2];
|
|
6934
6998
|
// Options not specified programatically (use case for SW!)
|
|
6935
6999
|
// Take persisted options:
|
|
6936
7000
|
db.cloud.options = persistedOptions || null;
|
|
@@ -6939,9 +7003,10 @@
|
|
|
6939
7003
|
if (!(!persistedOptions ||
|
|
6940
7004
|
JSON.stringify(persistedOptions) !== JSON.stringify(options))) return [3 /*break*/, 4];
|
|
6941
7005
|
// Update persisted options:
|
|
7006
|
+
if (!options)
|
|
7007
|
+
throw new Error("Internal error"); // options cannot be null if configuredProgramatically is set.
|
|
6942
7008
|
return [4 /*yield*/, db.$syncState.put(options, 'options')];
|
|
6943
7009
|
case 3:
|
|
6944
|
-
// Update persisted options:
|
|
6945
7010
|
_m.sent();
|
|
6946
7011
|
_m.label = 4;
|
|
6947
7012
|
case 4:
|
|
@@ -7087,15 +7152,15 @@
|
|
|
7087
7152
|
});
|
|
7088
7153
|
}
|
|
7089
7154
|
}
|
|
7090
|
-
dexieCloud.version = '4.0.0-beta.
|
|
7091
|
-
Dexie__default[
|
|
7155
|
+
dexieCloud.version = '4.0.0-beta.16';
|
|
7156
|
+
Dexie__default["default"].Cloud = dexieCloud;
|
|
7092
7157
|
|
|
7093
|
-
exports
|
|
7158
|
+
exports["default"] = dexieCloud;
|
|
7094
7159
|
exports.dexieCloud = dexieCloud;
|
|
7095
7160
|
exports.getTiedObjectId = getTiedObjectId;
|
|
7096
7161
|
exports.getTiedRealmId = getTiedRealmId;
|
|
7097
7162
|
|
|
7098
7163
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7099
7164
|
|
|
7100
|
-
}))
|
|
7165
|
+
}));
|
|
7101
7166
|
//# sourceMappingURL=dexie-cloud-addon.js.map
|