dexie-cloud-addon 4.0.0-beta.24 → 4.0.1-beta.27
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 +42 -27
- 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 +41 -26
- 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 +41 -25
- 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/DXCWebSocketStatus.d.ts +1 -1
- package/dist/types/DexieCloudTable.d.ts +18 -2
- package/dist/types/PermissionChecker.d.ts +1 -1
- package/dist/types/TSON.d.ts +1 -1
- package/dist/types/WSObservable.d.ts +2 -2
- package/dist/types/authentication/authenticate.d.ts +1 -1
- package/dist/types/db/DexieCloudDB.d.ts +1 -1
- package/dist/types/extend-dexie-interface.d.ts +5 -3
- package/dist/types/getInternalAccessControlObservable.d.ts +1 -1
- package/dist/types/getPermissionsLookupObservable.d.ts +2 -2
- package/dist/types/sync/getTablesToSyncify.d.ts +1 -1
- package/dist/types/sync/messagesFromServerQueue.d.ts +1 -1
- package/dist/types/types/DXCAlert.d.ts +1 -1
- package/dist/types/types/DXCInputField.d.ts +1 -1
- package/dist/types/types/DXCUserInteraction.d.ts +1 -1
- package/dist/types/types/SWSyncEvent.d.ts +1 -1
- package/dist/types/types/SyncState.d.ts +2 -2
- package/dist/umd/dexie-cloud-addon.js +40 -24
- 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 +40 -25
- 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 +38 -23
- package/dist/umd-modern/dexie-cloud-addon.js.map +1 -1
- package/package.json +5 -6
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.0.
|
|
11
|
+
* Version 4.0.1-beta.27, Mon Mar 06 2023
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import Dexie, { cmp, liveQuery } from 'dexie';
|
|
20
|
-
import { Observable as Observable$1, BehaviorSubject, Subject, fromEvent, of, merge, Subscription as Subscription$1, from as from$1, throwError, combineLatest, map as map$1, share, timer as timer$1
|
|
20
|
+
import { Observable as Observable$1, BehaviorSubject, Subject, fromEvent, of, merge, Subscription as Subscription$1, from as from$1, throwError, combineLatest, map as map$1, share, timer as timer$1 } from 'rxjs';
|
|
21
21
|
|
|
22
22
|
/******************************************************************************
|
|
23
23
|
Copyright (c) Microsoft Corporation.
|
|
@@ -152,7 +152,7 @@ function __asyncValues(o) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
//@ts-check
|
|
155
|
-
const randomFillSync = crypto.getRandomValues;
|
|
155
|
+
const randomFillSync = crypto.getRandomValues.bind(crypto);
|
|
156
156
|
|
|
157
157
|
function assert(b) {
|
|
158
158
|
if (!b)
|
|
@@ -214,17 +214,17 @@ function setByKeyPath(obj, keyPath, value) {
|
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
const randomString$1 = typeof
|
|
218
|
-
// Node
|
|
219
|
-
const buf = Buffer.alloc(bytes);
|
|
220
|
-
randomFillSync(buf);
|
|
221
|
-
return buf.toString("base64");
|
|
222
|
-
} : (bytes) => {
|
|
217
|
+
const randomString$1 = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes) => {
|
|
223
218
|
// Web
|
|
224
219
|
const buf = new Uint8Array(bytes);
|
|
225
220
|
crypto.getRandomValues(buf);
|
|
226
221
|
return btoa(String.fromCharCode.apply(null, buf));
|
|
227
|
-
}
|
|
222
|
+
} : typeof Buffer !== 'undefined' ? (bytes) => {
|
|
223
|
+
// Node
|
|
224
|
+
const buf = Buffer.alloc(bytes);
|
|
225
|
+
randomFillSync(buf);
|
|
226
|
+
return buf.toString("base64");
|
|
227
|
+
} : () => { throw new Error("No implementation of randomString was found"); };
|
|
228
228
|
|
|
229
229
|
/** Verifies that given primary key is valid.
|
|
230
230
|
* The reason we narrow validity for valid keys are twofold:
|
|
@@ -3275,14 +3275,14 @@ var undefinedDef = {
|
|
|
3275
3275
|
// serverRev.rev = bigIntDef.bigint.revive(server.rev)
|
|
3276
3276
|
// else
|
|
3277
3277
|
// serverRev.rev = new FakeBigInt(server.rev)
|
|
3278
|
-
const hasBigIntSupport = typeof BigInt(0) === 'bigint';
|
|
3278
|
+
const hasBigIntSupport = typeof BigInt === 'function' && typeof BigInt(0) === 'bigint';
|
|
3279
3279
|
class FakeBigInt {
|
|
3280
|
-
constructor(value) {
|
|
3281
|
-
this.v = value;
|
|
3282
|
-
}
|
|
3283
3280
|
toString() {
|
|
3284
3281
|
return this.v;
|
|
3285
3282
|
}
|
|
3283
|
+
constructor(value) {
|
|
3284
|
+
this.v = value;
|
|
3285
|
+
}
|
|
3286
3286
|
}
|
|
3287
3287
|
const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
|
|
3288
3288
|
? {}
|
|
@@ -4143,7 +4143,16 @@ function DexieCloudDB(dx) {
|
|
|
4143
4143
|
return db.$syncState.get('syncState');
|
|
4144
4144
|
},
|
|
4145
4145
|
getSchema() {
|
|
4146
|
-
return db.$syncState.get('schema')
|
|
4146
|
+
return db.$syncState.get('schema').then((schema) => {
|
|
4147
|
+
if (schema) {
|
|
4148
|
+
for (const table of db.tables) {
|
|
4149
|
+
if (table.schema.primKey && table.schema.primKey.keyPath && schema[table.name]) {
|
|
4150
|
+
schema[table.name].primaryKey = nameFromKeyPath(table.schema.primKey.keyPath);
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
return schema;
|
|
4155
|
+
});
|
|
4147
4156
|
},
|
|
4148
4157
|
getOptions() {
|
|
4149
4158
|
return db.$syncState.get('options');
|
|
@@ -4161,6 +4170,11 @@ function DexieCloudDB(dx) {
|
|
|
4161
4170
|
}
|
|
4162
4171
|
return db;
|
|
4163
4172
|
}
|
|
4173
|
+
function nameFromKeyPath(keyPath) {
|
|
4174
|
+
return typeof keyPath === 'string' ?
|
|
4175
|
+
keyPath :
|
|
4176
|
+
keyPath ? ('[' + [].join.call(keyPath, '+') + ']') : "";
|
|
4177
|
+
}
|
|
4164
4178
|
|
|
4165
4179
|
// @ts-ignore
|
|
4166
4180
|
const isFirefox = typeof InstallTrigger !== 'undefined';
|
|
@@ -4416,7 +4430,7 @@ function createImplicitPropSetterMiddleware(db) {
|
|
|
4416
4430
|
// modify operations. Reason: Server may not have
|
|
4417
4431
|
// the object. Object should be created on server only
|
|
4418
4432
|
// if is being updated. An update operation won't create it
|
|
4419
|
-
// so we must delete req.changeSpec to
|
|
4433
|
+
// so we must delete req.changeSpec to degrade operation to
|
|
4420
4434
|
// an upsert operation with timestamp so that it will be created.
|
|
4421
4435
|
// We must also degrade from consistent modify operations for the
|
|
4422
4436
|
// same reason - object might be there on server. Must but put up instead.
|
|
@@ -4428,7 +4442,7 @@ function createImplicitPropSetterMiddleware(db) {
|
|
|
4428
4442
|
if (req.type === 'put') {
|
|
4429
4443
|
delete req.criteria;
|
|
4430
4444
|
delete req.changeSpec;
|
|
4431
|
-
delete req.
|
|
4445
|
+
delete req.updates;
|
|
4432
4446
|
obj.$ts = Date.now();
|
|
4433
4447
|
}
|
|
4434
4448
|
}
|
|
@@ -4633,11 +4647,10 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
4633
4647
|
const { numFailures: hasFailures, failures } = res;
|
|
4634
4648
|
let keys = type === 'delete' ? req.keys : res.results;
|
|
4635
4649
|
let values = 'values' in req ? req.values : [];
|
|
4636
|
-
let
|
|
4650
|
+
let updates = 'updates' in req && req.updates;
|
|
4637
4651
|
if (hasFailures) {
|
|
4638
4652
|
keys = keys.filter((_, idx) => !failures[idx]);
|
|
4639
4653
|
values = values.filter((_, idx) => !failures[idx]);
|
|
4640
|
-
changeSpecs = changeSpecs.filter((_, idx) => !failures[idx]);
|
|
4641
4654
|
}
|
|
4642
4655
|
const ts = Date.now();
|
|
4643
4656
|
const mut = req.type === 'delete'
|
|
@@ -4669,13 +4682,13 @@ function createMutationTrackingMiddleware({ currentUserObservable, db }) {
|
|
|
4669
4682
|
txid,
|
|
4670
4683
|
userId
|
|
4671
4684
|
}
|
|
4672
|
-
:
|
|
4685
|
+
: updates
|
|
4673
4686
|
? {
|
|
4674
4687
|
// One changeSpec per key
|
|
4675
4688
|
type: 'update',
|
|
4676
4689
|
ts,
|
|
4677
|
-
keys,
|
|
4678
|
-
changeSpecs,
|
|
4690
|
+
keys: updates.keys,
|
|
4691
|
+
changeSpecs: updates.changeSpecs,
|
|
4679
4692
|
txid,
|
|
4680
4693
|
userId
|
|
4681
4694
|
}
|
|
@@ -5856,10 +5869,10 @@ function permissions(dexie, obj, tableName) {
|
|
|
5856
5869
|
}
|
|
5857
5870
|
|
|
5858
5871
|
const getInvitesObservable = associate((db) => {
|
|
5859
|
-
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(switchMap
|
|
5872
|
+
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => liveQuery(() => db.members.where({ email: currentUser.email || '' }).toArray())));
|
|
5860
5873
|
const permissions = getPermissionsLookupObservable(db._novip);
|
|
5861
5874
|
const accessControl = getInternalAccessControlObservable(db._novip);
|
|
5862
|
-
return createSharedValueObservable(combineLatest([membersByEmail, accessControl, permissions]).pipe(map
|
|
5875
|
+
return createSharedValueObservable(combineLatest([membersByEmail, accessControl, permissions]).pipe(map(([membersByEmail, accessControl, realmLookup]) => {
|
|
5863
5876
|
const reducer = (result, m) => (Object.assign(Object.assign({}, result), { [m.id]: Object.assign(Object.assign({}, m), { realm: realmLookup[m.realmId] }) }));
|
|
5864
5877
|
const emailMembersById = membersByEmail.reduce(reducer, {});
|
|
5865
5878
|
const membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
|
|
@@ -5922,7 +5935,7 @@ function dexieCloud(dexie) {
|
|
|
5922
5935
|
currentUserEmitter.next(UNAUTHORIZED_USER);
|
|
5923
5936
|
});
|
|
5924
5937
|
dexie.cloud = {
|
|
5925
|
-
version: '4.0.
|
|
5938
|
+
version: '4.0.1-beta.27',
|
|
5926
5939
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
5927
5940
|
schema: null,
|
|
5928
5941
|
get currentUserId() {
|
|
@@ -6052,7 +6065,9 @@ function dexieCloud(dexie) {
|
|
|
6052
6065
|
// Update persisted options:
|
|
6053
6066
|
if (!options)
|
|
6054
6067
|
throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
|
|
6055
|
-
|
|
6068
|
+
const newPersistedOptions = Object.assign({}, options);
|
|
6069
|
+
delete newPersistedOptions.fetchTokens;
|
|
6070
|
+
yield db.$syncState.put(newPersistedOptions, 'options');
|
|
6056
6071
|
}
|
|
6057
6072
|
if (((_h = db.cloud.options) === null || _h === void 0 ? void 0 : _h.tryUseServiceWorker) &&
|
|
6058
6073
|
'serviceWorker' in navigator &&
|
|
@@ -6175,7 +6190,7 @@ function dexieCloud(dexie) {
|
|
|
6175
6190
|
});
|
|
6176
6191
|
}
|
|
6177
6192
|
}
|
|
6178
|
-
dexieCloud.version = '4.0.
|
|
6193
|
+
dexieCloud.version = '4.0.1-beta.27';
|
|
6179
6194
|
Dexie.Cloud = dexieCloud;
|
|
6180
6195
|
|
|
6181
6196
|
export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId };
|