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
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
//@ts-check
|
|
162
|
-
const randomFillSync = crypto.getRandomValues;
|
|
162
|
+
const randomFillSync = crypto.getRandomValues.bind(crypto);
|
|
163
163
|
|
|
164
164
|
function assert(b) {
|
|
165
165
|
if (!b)
|
|
@@ -221,17 +221,17 @@
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
const randomString$1 = typeof
|
|
225
|
-
// Node
|
|
226
|
-
const buf = Buffer.alloc(bytes);
|
|
227
|
-
randomFillSync(buf);
|
|
228
|
-
return buf.toString("base64");
|
|
229
|
-
} : (bytes) => {
|
|
224
|
+
const randomString$1 = typeof self !== 'undefined' && typeof crypto !== 'undefined' ? (bytes) => {
|
|
230
225
|
// Web
|
|
231
226
|
const buf = new Uint8Array(bytes);
|
|
232
227
|
crypto.getRandomValues(buf);
|
|
233
228
|
return btoa(String.fromCharCode.apply(null, buf));
|
|
234
|
-
}
|
|
229
|
+
} : typeof Buffer !== 'undefined' ? (bytes) => {
|
|
230
|
+
// Node
|
|
231
|
+
const buf = Buffer.alloc(bytes);
|
|
232
|
+
randomFillSync(buf);
|
|
233
|
+
return buf.toString("base64");
|
|
234
|
+
} : () => { throw new Error("No implementation of randomString was found"); };
|
|
235
235
|
|
|
236
236
|
/** Verifies that given primary key is valid.
|
|
237
237
|
* The reason we narrow validity for valid keys are twofold:
|
|
@@ -3282,14 +3282,14 @@
|
|
|
3282
3282
|
// serverRev.rev = bigIntDef.bigint.revive(server.rev)
|
|
3283
3283
|
// else
|
|
3284
3284
|
// serverRev.rev = new FakeBigInt(server.rev)
|
|
3285
|
-
const hasBigIntSupport = typeof BigInt(0) === 'bigint';
|
|
3285
|
+
const hasBigIntSupport = typeof BigInt === 'function' && typeof BigInt(0) === 'bigint';
|
|
3286
3286
|
class FakeBigInt {
|
|
3287
|
-
constructor(value) {
|
|
3288
|
-
this.v = value;
|
|
3289
|
-
}
|
|
3290
3287
|
toString() {
|
|
3291
3288
|
return this.v;
|
|
3292
3289
|
}
|
|
3290
|
+
constructor(value) {
|
|
3291
|
+
this.v = value;
|
|
3292
|
+
}
|
|
3293
3293
|
}
|
|
3294
3294
|
const defs = Object.assign(Object.assign({}, undefinedDef), (hasBigIntSupport
|
|
3295
3295
|
? {}
|
|
@@ -4150,7 +4150,16 @@
|
|
|
4150
4150
|
return db.$syncState.get('syncState');
|
|
4151
4151
|
},
|
|
4152
4152
|
getSchema() {
|
|
4153
|
-
return db.$syncState.get('schema')
|
|
4153
|
+
return db.$syncState.get('schema').then((schema) => {
|
|
4154
|
+
if (schema) {
|
|
4155
|
+
for (const table of db.tables) {
|
|
4156
|
+
if (table.schema.primKey && table.schema.primKey.keyPath && schema[table.name]) {
|
|
4157
|
+
schema[table.name].primaryKey = nameFromKeyPath(table.schema.primKey.keyPath);
|
|
4158
|
+
}
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4161
|
+
return schema;
|
|
4162
|
+
});
|
|
4154
4163
|
},
|
|
4155
4164
|
getOptions() {
|
|
4156
4165
|
return db.$syncState.get('options');
|
|
@@ -4168,6 +4177,11 @@
|
|
|
4168
4177
|
}
|
|
4169
4178
|
return db;
|
|
4170
4179
|
}
|
|
4180
|
+
function nameFromKeyPath(keyPath) {
|
|
4181
|
+
return typeof keyPath === 'string' ?
|
|
4182
|
+
keyPath :
|
|
4183
|
+
keyPath ? ('[' + [].join.call(keyPath, '+') + ']') : "";
|
|
4184
|
+
}
|
|
4171
4185
|
|
|
4172
4186
|
// @ts-ignore
|
|
4173
4187
|
const isFirefox = typeof InstallTrigger !== 'undefined';
|
|
@@ -4423,7 +4437,7 @@
|
|
|
4423
4437
|
// modify operations. Reason: Server may not have
|
|
4424
4438
|
// the object. Object should be created on server only
|
|
4425
4439
|
// if is being updated. An update operation won't create it
|
|
4426
|
-
// so we must delete req.changeSpec to
|
|
4440
|
+
// so we must delete req.changeSpec to degrade operation to
|
|
4427
4441
|
// an upsert operation with timestamp so that it will be created.
|
|
4428
4442
|
// We must also degrade from consistent modify operations for the
|
|
4429
4443
|
// same reason - object might be there on server. Must but put up instead.
|
|
@@ -4435,7 +4449,7 @@
|
|
|
4435
4449
|
if (req.type === 'put') {
|
|
4436
4450
|
delete req.criteria;
|
|
4437
4451
|
delete req.changeSpec;
|
|
4438
|
-
delete req.
|
|
4452
|
+
delete req.updates;
|
|
4439
4453
|
obj.$ts = Date.now();
|
|
4440
4454
|
}
|
|
4441
4455
|
}
|
|
@@ -4640,11 +4654,10 @@
|
|
|
4640
4654
|
const { numFailures: hasFailures, failures } = res;
|
|
4641
4655
|
let keys = type === 'delete' ? req.keys : res.results;
|
|
4642
4656
|
let values = 'values' in req ? req.values : [];
|
|
4643
|
-
let
|
|
4657
|
+
let updates = 'updates' in req && req.updates;
|
|
4644
4658
|
if (hasFailures) {
|
|
4645
4659
|
keys = keys.filter((_, idx) => !failures[idx]);
|
|
4646
4660
|
values = values.filter((_, idx) => !failures[idx]);
|
|
4647
|
-
changeSpecs = changeSpecs.filter((_, idx) => !failures[idx]);
|
|
4648
4661
|
}
|
|
4649
4662
|
const ts = Date.now();
|
|
4650
4663
|
const mut = req.type === 'delete'
|
|
@@ -4676,13 +4689,13 @@
|
|
|
4676
4689
|
txid,
|
|
4677
4690
|
userId
|
|
4678
4691
|
}
|
|
4679
|
-
:
|
|
4692
|
+
: updates
|
|
4680
4693
|
? {
|
|
4681
4694
|
// One changeSpec per key
|
|
4682
4695
|
type: 'update',
|
|
4683
4696
|
ts,
|
|
4684
|
-
keys,
|
|
4685
|
-
changeSpecs,
|
|
4697
|
+
keys: updates.keys,
|
|
4698
|
+
changeSpecs: updates.changeSpecs,
|
|
4686
4699
|
txid,
|
|
4687
4700
|
userId
|
|
4688
4701
|
}
|
|
@@ -5863,10 +5876,10 @@
|
|
|
5863
5876
|
}
|
|
5864
5877
|
|
|
5865
5878
|
const getInvitesObservable = associate((db) => {
|
|
5866
|
-
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(
|
|
5879
|
+
const membersByEmail = getCurrentUserEmitter(db._novip).pipe(switchMap((currentUser) => Dexie.liveQuery(() => db.members.where({ email: currentUser.email || '' }).toArray())));
|
|
5867
5880
|
const permissions = getPermissionsLookupObservable(db._novip);
|
|
5868
5881
|
const accessControl = getInternalAccessControlObservable(db._novip);
|
|
5869
|
-
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(
|
|
5882
|
+
return createSharedValueObservable(rxjs.combineLatest([membersByEmail, accessControl, permissions]).pipe(map(([membersByEmail, accessControl, realmLookup]) => {
|
|
5870
5883
|
const reducer = (result, m) => (Object.assign(Object.assign({}, result), { [m.id]: Object.assign(Object.assign({}, m), { realm: realmLookup[m.realmId] }) }));
|
|
5871
5884
|
const emailMembersById = membersByEmail.reduce(reducer, {});
|
|
5872
5885
|
const membersById = accessControl.selfMembers.reduce(reducer, emailMembersById);
|
|
@@ -6059,7 +6072,9 @@
|
|
|
6059
6072
|
// Update persisted options:
|
|
6060
6073
|
if (!options)
|
|
6061
6074
|
throw new Error(`Internal error`); // options cannot be null if configuredProgramatically is set.
|
|
6062
|
-
|
|
6075
|
+
const newPersistedOptions = Object.assign({}, options);
|
|
6076
|
+
delete newPersistedOptions.fetchTokens;
|
|
6077
|
+
yield db.$syncState.put(newPersistedOptions, 'options');
|
|
6063
6078
|
}
|
|
6064
6079
|
if (((_h = db.cloud.options) === null || _h === void 0 ? void 0 : _h.tryUseServiceWorker) &&
|
|
6065
6080
|
'serviceWorker' in navigator &&
|