Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/BsFirebase.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type firebaseConfig;
module Auth = BsFirebase__Auth;
module Firestore = BsFirebase__Firestore;

[@bs.module] external firebase: firebase = "firebase";
[@bs.module] external firebase: firebase = "firebase/app";

[@bs.send]
external initializeApp: (firebase, firebaseConfig) => unit = "initializeApp";

[@bs.send] external auth: (firebase, unit) => Auth.t = "auth";
[@bs.send] external firestore: (firebase, unit) => Firestore.t = "firestore";
[@bs.send] external auth: firebase => Auth.t = "auth";
[@bs.send] external firestore: firebase => Firestore.t = "firestore";
6 changes: 3 additions & 3 deletions src/BsFirebase.rei
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ type firebaseConfig;
module Auth = BsFirebase__Auth;
module Firestore = BsFirebase__Firestore;

[@bs.module] external firebase: firebase = "firebase";
[@bs.module] external firebase: firebase = "firebase/app";

[@bs.send]
external initializeApp: (firebase, firebaseConfig) => unit = "initializeApp";

[@bs.send] external auth: (firebase, unit) => Auth.t = "auth";
[@bs.send] external firestore: (firebase, unit) => Firestore.t = "firestore";
[@bs.send] external auth: firebase => Auth.t = "auth";
[@bs.send] external firestore: firebase => Firestore.t = "firestore";
9 changes: 8 additions & 1 deletion src/BsFirebase__Auth.re
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
type t;

[@bs.module] external require: t = "firebase/auth";

module User = {
type t;

Expand Down Expand Up @@ -65,6 +67,9 @@ module Provider = {
external twitter: unit => t = "TwitterAuthProvider";
};

[@bs.send]
external signInAnonymously: t => Js.Promise.t(Result.t) = "signInAnonymously";

[@bs.send]
external signInWithEmailAndPassword:
(t, ~email: string, ~password: string) => Js.Promise.t(Result.t) =
Expand All @@ -78,4 +83,6 @@ external signInWithPopup: (t, Provider.t) => Js.Promise.t(Result.t) =
external onAuthStateChanged: (t, Js.Nullable.t(User.t) => unit) => unit =
"onAuthStateChanged";

[@bs.send] external signOut: (t, unit) => unit = "signOut";
[@bs.send] external signOut: (t, unit) => unit = "signOut";

[@bs.get] external currentUser: t => User.t = "currentUser";
30 changes: 23 additions & 7 deletions src/BsFirebase__Firestore.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type t;

module DocRef = {
module DocSnapshot = {
type t;

[@bs.get] external exists: t => bool = "exists";
Expand All @@ -11,28 +11,29 @@ module DocRef = {
module QuerySnapshot = {
type t;

[@bs.get] external docs: t => array(DocRef.t) = "docs";
[@bs.get] external docs: t => array(DocSnapshot.t) = "docs";
[@bs.get] external size: t => int = "size";
};

module Collection = {
type t;

module Doc = {
module DocRef = {
type t;

[@bs.deriving abstract]
type setOptions = {merge: bool};

[@bs.send] external get: (t, unit) => Js.Promise.t(DocRef.t) = "get";
[@bs.send] external get: (t, unit) => Js.Promise.t(DocSnapshot.t) = "get";
[@bs.send] external delete: (t, unit) => Js.Promise.t(unit) = "delete";
[@bs.send]
external set: (t, 'a, ~options: setOptions=?) => Js.Promise.t(unit) =
external set: (t, 'a, ~options: setOptions=?, unit) => Js.Promise.t(unit) =
"set";
};

[@bs.send] external add: (t, 'a) => Js.Promise.t(DocRef.t) = "add";
[@bs.send] external get: (t, unit) => Js.Promise.t(QuerySnapshot.t) = "get";
[@bs.send] external doc: (t, string) => Doc.t = "doc";
[@bs.send] external doc: (t, string) => DocRef.t = "doc";
[@bs.send]
external where:
(
Expand All @@ -54,4 +55,19 @@ module Collection = {

[@bs.module] external require: t = "firebase/firestore";

[@bs.send] external collection: (t, string) => Collection.t = "collection";
[@bs.send] external collection: (t, string) => Collection.t = "collection";

module Transaction = {
type firestore = t;
type t;

type updateFunction('a) = t => Js.Promise.t('a);

[@bs.send] external get: (t, Collection.DocRef.t) => Js.Promise.t(DocSnapshot.t) = "get";
[@bs.send] external update: (t, Collection.DocRef.t, 'a) => t = "update";
[@bs.send] external set: (t, Collection.DocRef.t, 'a, ~options: Collection.DocRef.setOptions=?, unit) => t = "set";
[@bs.send] external delete: (t, Collection.DocRef.t) => t = "delete";
}


[@bs.send] external runTransaction: (t, Transaction.updateFunction('a)) => Js.Promise.t('a) = "runTransaction";