Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 69b78a3

Browse files
committed
chore: build typings
1 parent 6b8209d commit 69b78a3

File tree

6 files changed

+411
-411
lines changed

6 files changed

+411
-411
lines changed

src/app/firestore/index.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import { firebase } from "../../firebase";
1+
import { firestore as fStore } from "../../firebase";
22
// import * as firebaseSdk from 'firebase/app';
33

44
export namespace firestore {
55
export class Firestore /*implements firebaseSdk.firestore.Firestore*/ {
6-
collection(collectionPath: string): firebase.firestore.CollectionReference {
7-
return firebase.firestore.collection(collectionPath);
6+
collection(collectionPath: string): fStore.CollectionReference {
7+
return fStore.collection(collectionPath);
88
}
99

10-
collectionGroup(id: string): firebase.firestore.CollectionGroup {
11-
return firebase.firestore.collectionGroup(id);
10+
collectionGroup(id: string): fStore.CollectionGroup {
11+
return fStore.collectionGroup(id);
1212
}
1313

14-
doc(path: string): firebase.firestore.DocumentReference {
15-
return firebase.firestore.docRef(path);
14+
doc(path: string): fStore.DocumentReference {
15+
return fStore.docRef(path);
1616
}
1717

1818
FieldValue(): firebase.firestore.FieldValue {
@@ -21,30 +21,30 @@ export namespace firestore {
2121
value: undefined,
2222
serverTimestamp: () => "SERVER_TIMESTAMP",
2323
delete: () => "DELETE_FIELD",
24-
arrayUnion: (...elements: any[]) => new firebase.firestore.FieldValue("ARRAY_UNION", elements),
25-
arrayRemove: (...elements: any[]) => new firebase.firestore.FieldValue("ARRAY_REMOVE", elements),
26-
increment: (n: number) => new firebase.firestore.FieldValue("INCREMENT", n)
24+
arrayUnion: (...elements: any[]) => new fStore.FieldValue("ARRAY_UNION", elements),
25+
arrayRemove: (...elements: any[]) => new fStore.FieldValue("ARRAY_REMOVE", elements),
26+
increment: (n: number) => new fStore.FieldValue("INCREMENT", n)
2727
};
2828
}
2929

30-
GeoPoint(latitude: number, longitude: number): firebase.firestore.GeoPoint {
31-
return firebase.firestore.GeoPoint(latitude, longitude);
30+
GeoPoint(latitude: number, longitude: number): fStore.GeoPoint {
31+
return fStore.GeoPoint(latitude, longitude);
3232
}
3333

34-
runTransaction<T>(updateFunction: (transaction: firebase.firestore.Transaction) => Promise<any>): Promise<void> {
35-
return firebase.firestore.runTransaction(updateFunction);
34+
runTransaction<T>(updateFunction: (transaction: fStore.Transaction) => Promise<any>): Promise<void> {
35+
return fStore.runTransaction(updateFunction);
3636
}
3737

38-
batch(): firebase.firestore.WriteBatch {
39-
return firebase.firestore.batch();
38+
batch(): fStore.WriteBatch {
39+
return fStore.batch();
4040
}
4141

42-
settings(settings: firebase.firestore.Settings): void {
43-
firebase.firestore.settings(settings);
42+
settings(settings: fStore.Settings): void {
43+
fStore.settings(settings);
4444
}
4545

4646
clearPersistence(): Promise<void> {
47-
return firebase.firestore.clearPersistence();
47+
return fStore.clearPersistence();
4848
}
4949
}
5050
}

src/app/functions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { firebase } from "../../firebase";
1+
import { functions as fNamepspace } from "../../firebase";
22

33
export namespace functions {
44
// tslint:disable-next-line:class-name
55
export class Functions {
6-
httpsCallable<I, O>(functionName: string, region?: firebase.functions.SupportedRegions) {
7-
return firebase.functions.httpsCallable<I, O>(functionName, region);
6+
httpsCallable<I, O>(functionName: string, region?: fNamepspace.SupportedRegions) {
7+
return fNamepspace.httpsCallable<I, O>(functionName, region);
88
}
99
}
1010
}

src/firebase-common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { prompt, ApplicationSettings } from "@nativescript/core";
2-
import { firebase as fbNamespace } from "./firebase";
2+
import { firestore as fsNamespace } from "./firebase";
33
import * as admob from "./admob/admob";
44
import * as analytics from "./analytics/analytics";
55
import * as crashlytics from "./crashlytics/crashlytics";
@@ -9,15 +9,15 @@ import * as mlkit from "./mlkit";
99

1010
// note that this implementation is overridden for iOS
1111
export class FieldValue {
12-
constructor(public type: fbNamespace.firestore.FieldValueType,
12+
constructor(public type: fsNamespace.FieldValueType,
1313
public value: any) {
1414
}
1515

1616
static serverTimestamp = () => "SERVER_TIMESTAMP";
1717
static delete = () => "DELETE_FIELD";
1818
static arrayUnion = (...elements: any[]) => new FieldValue("ARRAY_UNION", elements);
1919
static arrayRemove = (...elements: any[]) => new FieldValue("ARRAY_REMOVE", elements);
20-
static increment = (n: number) => new fbNamespace.firestore.FieldValue("INCREMENT", n);
20+
static increment = (n: number) => new FieldValue("INCREMENT", n);
2121
}
2222

2323
export class GeoPoint {

src/firebase.android.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import lazy from "@nativescript/core/utils/lazy";
33
import { DocumentSnapshot as DocumentSnapshotBase, FieldValue, firebase, GeoPoint, isDocumentReference } from "./firebase-common";
44
import * as firebaseFunctions from "./functions/functions";
55
import * as firebaseMessaging from "./messaging/messaging";
6-
import { firestore } from "./platforms/web/typings/firebase-webapi";
6+
import { firestore } from "./firebase";
77

88
export enum QueryOrderByType {
99
KEY,
@@ -2226,7 +2226,7 @@ const ensureFirestore = (): void => {
22262226
}
22272227
};
22282228

2229-
class FirestoreWriteBatch implements firestore.WriteBatch {
2229+
class FirestoreWriteBatch {
22302230

22312231
public nativeWriteBatch: com.google.firebase.firestore.WriteBatch;
22322232

@@ -2239,7 +2239,7 @@ class FirestoreWriteBatch implements firestore.WriteBatch {
22392239
return this;
22402240
}
22412241

2242-
public update = (documentRef: firestore.DocumentReference, data: firestore.UpdateData): any => {
2242+
public update(documentRef: firestore.DocumentReference, data: firestore.UpdateData): any {
22432243
this.nativeWriteBatch.update((<any>documentRef).android, firebase.toValue(data));
22442244
return this;
22452245
}
@@ -2494,7 +2494,7 @@ firebase.firestore._getDocumentReference = (docRef?: JDocumentReference): firest
24942494
get: (options?: firestore.GetOptions) => firebase.firestore.getDocument(collectionPath, docRef.getId(), options),
24952495
update: (data: any) => firebase.firestore.update(collectionPath, docRef.getId(), data),
24962496
delete: () => firebase.firestore.delete(collectionPath, docRef.getId()),
2497-
onSnapshot: (optionsOrCallback: firestore.SnapshotListenOptions | ((snapshot: DocumentSnapshot) => void), callbackOrOnError?: (docOrError: DocumentSnapshot | Error) => void, onError?: (error: Error) => void) => firebase.firestore.onDocumentSnapshot(docRef, optionsOrCallback, callbackOrOnError, onError),
2497+
onSnapshot: (optionsOrCallback: firestore.SnapshotListenOptions | ((snapshot: firestore.DocumentSnapshot) => void), callbackOrOnError?: (docOrError: firestore.DocumentSnapshot | Error) => void, onError?: (error: Error) => void) => firebase.onDocumentSnapshot(docRef, optionsOrCallback, callbackOrOnError, onError),
24982498
android: docRef
24992499
};
25002500
};
@@ -2729,7 +2729,7 @@ firebase.firestore.getDocument = (collectionPath: string, documentPath: string,
27292729
reject(ex && ex.getReason ? ex.getReason() : ex);
27302730
} else {
27312731
const result: com.google.firebase.firestore.DocumentSnapshot = task.getResult();
2732-
resolve(new DocumentSnapshot(result));
2732+
resolve(new firebase.DocumentSnapshot(result));
27332733
}
27342734
}
27352735
});
@@ -2759,7 +2759,7 @@ firebase.firestore._getQuery = (collectionPath: string, query: com.google.fireba
27592759
return {
27602760
get: () => new Promise((resolve, reject) => {
27612761
const onCompleteListener = new gmsTasks.OnCompleteListener({
2762-
onComplete: task => {
2762+
onComplete: (task: any) => {
27632763
if (!task.isSuccessful()) {
27642764
const ex = task.getException();
27652765
reject(ex && ex.getReason ? ex.getReason() : ex);
@@ -2874,7 +2874,7 @@ function convertDocChangeType(type: com.google.firebase.firestore.DocumentChange
28742874
}
28752875

28762876
function convertDocument(qDoc: com.google.firebase.firestore.QueryDocumentSnapshot): firestore.QueryDocumentSnapshot {
2877-
return new DocumentSnapshot(qDoc);
2877+
return new firebase.DocumentSnapshot(qDoc);
28782878
}
28792879

28802880
export class QuerySnapshot implements firestore.QuerySnapshot {
@@ -2893,7 +2893,7 @@ export class QuerySnapshot implements firestore.QuerySnapshot {
28932893
const docSnapshots: firestore.QueryDocumentSnapshot[] = [];
28942894
for (let i = 0; i < this.snapshot.size(); i++) {
28952895
const documentSnapshot: com.google.firebase.firestore.DocumentSnapshot = this.snapshot.getDocuments().get(i);
2896-
docSnapshots.push(new DocumentSnapshot(documentSnapshot));
2896+
docSnapshots.push(new firebase.DocumentSnapshot(documentSnapshot));
28972897
}
28982898
this._docSnapshots = docSnapshots;
28992899

0 commit comments

Comments
 (0)