dexie-cloud-addon 4.0.1-beta.52 → 4.0.1-beta.54

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.
@@ -8,9 +8,7 @@ export interface Realm {
8
8
  */
9
9
  name?: string;
10
10
  /** Contains the user-ID of the owner. An owner has implicit full write-access to the realm
11
- * and all obejcts connected to it. Ownership does not imply read (sync) access though,
12
- * so realm owners still needs to add themself as a member if they are going to use the realm
13
- * themselves.
11
+ * and all obejcts connected to it.
14
12
  */
15
13
  owner?: string;
16
14
  }
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.52, Mon Oct 30 2023
11
+ * Version 4.0.1-beta.54, Mon Dec 18 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2016,7 +2016,7 @@ function alertUser(userInteraction, title, ...alerts) {
2016
2016
  function promptForEmail(userInteraction, title, emailHint) {
2017
2017
  return __awaiter(this, void 0, void 0, function* () {
2018
2018
  let email = emailHint || '';
2019
- while (!email || !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
2019
+ while (!email || !/^[\w-+.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
2020
2020
  email = (yield interactWithUser(userInteraction, {
2021
2021
  type: 'email',
2022
2022
  title,
@@ -4637,6 +4637,21 @@ function createImplicitPropSetterMiddleware(db) {
4637
4637
  const trans = req.trans;
4638
4638
  if ((_b = (_a = db.cloud.schema) === null || _a === void 0 ? void 0 : _a[tableName]) === null || _b === void 0 ? void 0 : _b.markedForSync) {
4639
4639
  if (req.type === 'add' || req.type === 'put') {
4640
+ if (tableName === 'members') {
4641
+ for (const member of req.values) {
4642
+ if (typeof member.email === 'string') {
4643
+ // Resolve https://github.com/dexie/dexie-cloud/issues/4
4644
+ // If adding a member, make sure email is lowercase and trimmed.
4645
+ // This is to avoid issues where the APP does not check this
4646
+ // and just allows the user to enter an email address that might
4647
+ // have been pasted by the user from a source that had a trailing
4648
+ // space or was in uppercase. We want to avoid that the user
4649
+ // creates a new member with a different email address than
4650
+ // the one he/she intended to create.
4651
+ member.email = member.email.trim().toLowerCase();
4652
+ }
4653
+ }
4654
+ }
4640
4655
  // No matter if user is logged in or not, make sure "owner" and "realmId" props are set properly.
4641
4656
  // If not logged in, this will be changed upon syncification of the tables (next sync after login),
4642
4657
  // however, application code will work better if we can always rely on that the properties realmId
@@ -4704,7 +4719,7 @@ function readLock(fn, prop) {
4704
4719
  const numWriters = writers.length;
4705
4720
  const promise = (numWriters > 0
4706
4721
  ? writers[numWriters - 1].then(() => fn(req), () => fn(req))
4707
- : fn(req)).finally(() => readers.splice(readers.indexOf(promise)));
4722
+ : fn(req)).finally(() => { readers.splice(readers.indexOf(promise)); });
4708
4723
  readers.push(promise);
4709
4724
  return promise;
4710
4725
  };
@@ -4716,7 +4731,7 @@ function writeLock(fn, prop) {
4716
4731
  ? writers[writers.length - 1].then(() => fn(req), () => fn(req))
4717
4732
  : readers.length > 0
4718
4733
  ? allSettled(readers).then(() => fn(req))
4719
- : fn(req)).finally(() => writers.shift());
4734
+ : fn(req)).finally(() => { writers.shift(); });
4720
4735
  writers.push(promise);
4721
4736
  return promise;
4722
4737
  };
@@ -6217,7 +6232,7 @@ function dexieCloud(dexie) {
6217
6232
  const syncComplete = new Subject();
6218
6233
  dexie.cloud = {
6219
6234
  // @ts-ignore
6220
- version: "4.0.1-beta.52",
6235
+ version: "4.0.1-beta.54",
6221
6236
  options: Object.assign({}, DEFAULT_OPTIONS),
6222
6237
  schema: null,
6223
6238
  get currentUserId() {
@@ -6494,7 +6509,7 @@ function dexieCloud(dexie) {
6494
6509
  }
6495
6510
  }
6496
6511
  // @ts-ignore
6497
- dexieCloud.version = "4.0.1-beta.52";
6512
+ dexieCloud.version = "4.0.1-beta.54";
6498
6513
  Dexie.Cloud = dexieCloud;
6499
6514
 
6500
6515
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId, resolveText };