@thefittingroom/sdk 1.0.3 → 1.1.0

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.
@@ -1,6 +1,7 @@
1
1
  import * as firebase from 'firebase/app';
2
2
  import * as firebaseAuth from 'firebase/auth';
3
- import { DocumentData, Firestore, QuerySnapshot } from 'firebase/firestore';
3
+ import { Firestore } from 'firebase/firestore';
4
+ import { FirestoreUser } from '../types';
4
5
  export type BrandUserId = string | number;
5
6
  export declare class FirebaseUser {
6
7
  private readonly firestore;
@@ -13,8 +14,8 @@ export declare class FirebaseUser {
13
14
  setUser(user: firebaseAuth.User): void;
14
15
  setBrandUserId(brandUserId: BrandUserId): void;
15
16
  getToken(): Promise<string>;
16
- getUserProfile(): Promise<DocumentData>;
17
- watchUserProfileForChanges(predicate: (data: QuerySnapshot<DocumentData>) => Promise<boolean>, timeout: number): Promise<DocumentData>;
17
+ getUserProfile(): Promise<import("@firebase/firestore").DocumentData>;
18
+ watchUserProfileForChanges(callback: (data: FirestoreUser) => void): () => void;
18
19
  login(username: string, password: string): Promise<void>;
19
20
  logout(): Promise<void>;
20
21
  sendPasswordResetEmail(email: string): Promise<void>;
package/dist/esm/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * thefittingroom v1.0.3 (2024-02-16T14:55:02.187Z)
2
+ * thefittingroom v1.1.0 (2024-02-16T20:34:26.286Z)
3
3
  * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
4
  */
5
5
  // Code generated by tygo. DO NOT EDIT.
@@ -22840,19 +22840,11 @@ class FirebaseUser {
22840
22840
  const userProfile = await Ol(Aa(this.firestore, 'users', this.id));
22841
22841
  return userProfile.data();
22842
22842
  }
22843
- watchUserProfileForChanges(predicate, timeout) {
22843
+ watchUserProfileForChanges(callback) {
22844
22844
  let unsub;
22845
22845
  const q = sl(Ta(this.firestore, 'users'), rl(Eh(), '==', this.id));
22846
- const cancel = setTimeout(() => unsub(), timeout);
22847
- return new Promise((resolve) => {
22848
- unsub = jl(q, async (snapshot) => {
22849
- if (!(await predicate(snapshot)))
22850
- return;
22851
- clearTimeout(cancel);
22852
- unsub();
22853
- resolve(snapshot.docs[0].data());
22854
- });
22855
- });
22846
+ unsub = jl(q, (snapshot) => callback(snapshot.docs[0].data()));
22847
+ return () => unsub();
22856
22848
  }
22857
22849
  async login(username, password) {
22858
22850
  if (this.auth.currentUser)