[typings] Continue work on flow

This commit is contained in:
Chris Bianca 2017-11-23 17:29:40 +00:00
parent fbe73f5dcb
commit ff95c21b9d
36 changed files with 429 additions and 232 deletions

View File

@ -80,7 +80,6 @@
node_modules/fbjs/lib
[libs]
lib/types/flow.js
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow
node_modules/fbjs/flow/lib

View File

@ -1,3 +1,7 @@
/**
* @flow
* AdMob representation wrapper
*/
import ModuleBase from './../../utils/ModuleBase';
import Interstitial from './Interstitial';

View File

@ -1,4 +1,7 @@
// @flow
/**
* @flow
* Analytics representation wrapper
*/
import ModuleBase from './../../utils/ModuleBase';
const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
@ -116,3 +119,5 @@ export default class Analytics extends ModuleBase {
}
}
}
export const statics = {};

View File

@ -5,6 +5,7 @@
import INTERNALS from '../../utils/internals';
import type Auth from './';
import type { AuthCredential } from '../../types';
type NativeUser = {
displayName?: string,

View File

@ -17,8 +17,14 @@ import FacebookAuthProvider from './providers/FacebookAuthProvider';
import PhoneAuthListener from './PhoneAuthListener';
import type { AuthCredential } from '../../types';
import type FirebaseApp from '../core/firebase-app';
type AuthResult = {
authenticated: boolean,
user: Object|null
} | null;
export default class Auth extends ModuleBase {
static _NAMESPACE = 'auth';
static _NATIVE_MODULE = 'RNFirebaseAuth';

View File

@ -2,6 +2,8 @@
* @flow
* EmailAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'password';
export default class EmailAuthProvider {

View File

@ -2,6 +2,8 @@
* @flow
* FacebookAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'facebook.com';
export default class FacebookAuthProvider {

View File

@ -2,6 +2,8 @@
* @flow
* GithubAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'github.com';
export default class GithubAuthProvider {

View File

@ -2,6 +2,8 @@
* @flow
* EmailAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'google.com';
export default class GoogleAuthProvider {

View File

@ -2,6 +2,8 @@
* @flow
* PhoneAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'phone';
export default class PhoneAuthProvider {

View File

@ -2,6 +2,8 @@
* @flow
* TwitterAuthProvider representation wrapper
*/
import type { AuthCredential } from '../../../types';
const providerId = 'twitter.com';
export default class TwitterAuthProvider {

View File

@ -139,3 +139,5 @@ export default class RemoteConfig extends ModuleBase {
this._native.setDefaultsFromResource(resource);
}
}
export const statics = {};

View File

@ -8,38 +8,58 @@ import { isObject, isAndroid } from '../../utils';
import AdMob, { statics as AdMobStatics } from '../admob';
import Auth, { statics as AuthStatics } from '../auth';
import Analytics from '../analytics';
import Crash from '../crash';
import Performance from '../perf';
import RemoteConfig from '../config';
import Storage, { statics as StorageStatics } from '../storage';
import Analytics, { statics as AnalyticsStatics } from '../analytics';
import Config, { statics as ConfigStatics } from '../config';
import Crash, { statics as CrashStatics } from '../crash';
import Database, { statics as DatabaseStatics } from '../database';
import Messaging, { statics as MessagingStatics } from '../messaging';
import Firestore, { statics as FirestoreStatics } from '../firestore';
import Links, { statics as LinksStatics } from '../links';
import Messaging, { statics as MessagingStatics } from '../messaging';
import Performance, { statics as PerformanceStatics } from '../perf';
import Storage, { statics as StorageStatics } from '../storage';
import Utils, { statics as UtilsStatics } from '../utils';
import type {
AdMobModule,
AnalyticsModule,
AuthModule,
ConfigModule,
CrashModule,
DatabaseModule,
FirebaseModule,
FirebaseModuleAndStatics,
FirebaseOptions,
FirebaseStatics,
FirestoreModule,
LinksModule,
MessagingModule,
PerformanceModule,
StorageModule,
UtilsModule,
} from '../../types';
const FirebaseCoreModule = NativeModules.RNFirebase;
export default class FirebaseApp {
_extendedProps: { [string] : boolean };
_initialized: boolean;
_name: string;
_namespaces: { [string]: Object };
_namespaces: { [string]: FirebaseModule };
_nativeInitialized: boolean;
_options: FirebaseOptions;
admob: () => AdMob;
auth: () => Auth;
analytics: () => Analytics;
config: () => RemoteConfig;
crash: () => Crash;
database: () => Database;
firestore: () => Firestore;
links: () => Links;
messaging: () => Messaging;
perf: () => Performance;
storage: () => Storage;
utils: () => Utils;
admob: AdMobModule;
analytics: AnalyticsModule;
auth: AuthModule;
config: ConfigModule;
crash: CrashModule;
database: DatabaseModule;
firestore: FirestoreModule;
links: LinksModule;
messaging: MessagingModule;
perf: PerformanceModule;
storage: StorageModule;
utils: UtilsModule;
constructor(name: string, options: FirebaseOptions) {
this._name = name;
@ -52,15 +72,15 @@ export default class FirebaseApp {
// modules
this.admob = this._staticsOrModuleInstance(AdMobStatics, AdMob);
this.analytics = this._staticsOrModuleInstance(AnalyticsStatics, Analytics);
this.auth = this._staticsOrModuleInstance(AuthStatics, Auth);
this.analytics = this._staticsOrModuleInstance({}, Analytics);
this.config = this._staticsOrModuleInstance({}, RemoteConfig);
this.crash = this._staticsOrModuleInstance({}, Crash);
this.config = this._staticsOrModuleInstance(ConfigStatics, Config);
this.crash = this._staticsOrModuleInstance(CrashStatics, Crash);
this.database = this._staticsOrModuleInstance(DatabaseStatics, Database);
this.firestore = this._staticsOrModuleInstance(FirestoreStatics, Firestore);
this.links = this._staticsOrModuleInstance(LinksStatics, Links);
this.messaging = this._staticsOrModuleInstance(MessagingStatics, Messaging);
this.perf = this._staticsOrModuleInstance({}, Performance);
this.perf = this._staticsOrModuleInstance(PerformanceStatics, Performance);
this.storage = this._staticsOrModuleInstance(StorageStatics, Storage);
this.utils = this._staticsOrModuleInstance(UtilsStatics, Utils);
this._extendedProps = {};
@ -171,8 +191,8 @@ export default class FirebaseApp {
* @return {function()}
* @private
*/
_staticsOrModuleInstance(statics: Object = {}, InstanceClass: Class<*>) {
const getInstance = () => {
_staticsOrModuleInstance<M: FirebaseModule, S:FirebaseStatics>(statics: S, InstanceClass: Class<M>): FirebaseModuleAndStatics<M, S> {
const getInstance = (): M => {
const _name = `_${InstanceClass._NAMESPACE}`;
if (isAndroid && InstanceClass._NAMESPACE !== Utils._NAMESPACE && !INTERNALS.FLAGS.checkedPlayServices) {
@ -187,10 +207,8 @@ export default class FirebaseApp {
return this._namespaces[_name];
};
Object.assign(getInstance, statics, {
return Object.assign(getInstance, statics, {
nativeModuleExists: !!NativeModules[InstanceClass._NATIVE_MODULE],
});
return getInstance;
}
}

View File

@ -11,34 +11,53 @@ import { isObject, isString } from '../../utils';
// module imports
import AdMob, { statics as AdMobStatics } from '../admob';
import Auth, { statics as AuthStatics } from '../auth';
import Analytics from '../analytics';
import Crash from '../crash';
import Performance from '../perf';
import Links, { statics as LinksStatics } from '../links';
import RemoteConfig from '../config';
import Storage, { statics as StorageStatics } from '../storage';
import Analytics, { statics as AnalyticsStatics } from '../analytics';
import Config, { statics as ConfigStatics } from '../config';
import Crash, { statics as CrashStatics } from '../crash';
import Database, { statics as DatabaseStatics } from '../database';
import Messaging, { statics as MessagingStatics } from '../messaging';
import Firestore, { statics as FirestoreStatics } from '../firestore';
import Links, { statics as LinksStatics } from '../links';
import Messaging, { statics as MessagingStatics } from '../messaging';
import Performance, { statics as PerformanceStatics } from '../perf';
import Storage, { statics as StorageStatics } from '../storage';
import Utils, { statics as UtilsStatics } from '../utils';
import type {
AdMobModule,
AnalyticsModule,
AuthModule,
ConfigModule,
CrashModule,
DatabaseModule,
FirebaseModule,
FirebaseModuleAndStatics,
FirebaseOptions,
FirebaseStatics,
FirestoreModule,
LinksModule,
MessagingModule,
PerformanceModule,
StorageModule,
UtilsModule,
} from '../../types';
const FirebaseCoreModule = NativeModules.RNFirebase;
class FirebaseCore {
_nativeEmitters: { [string]: NativeEventEmitter };
_nativeSubscriptions: { [string]: boolean };
admob: () => AdMob;
auth: () => Auth;
analytics: () => Analytics;
config: () => RemoteConfig;
crash: () => Crash;
database: () => Database;
firestore: () => Firestore;
links: () => Links;
messaging: () => Messaging;
perf: () => Performance;
storage: () => Storage;
utils: () => Utils;
admob: AdMobModule;
analytics: AnalyticsModule;
auth: AuthModule;
config: ConfigModule;
crash: CrashModule;
database: DatabaseModule;
firestore: FirestoreModule;
links: LinksModule;
messaging: MessagingModule;
perf: PerformanceModule;
storage: StorageModule;
utils: UtilsModule;
constructor() {
this._nativeEmitters = {};
@ -52,15 +71,15 @@ class FirebaseCore {
// modules
this.admob = this._appNamespaceOrStatics(AdMobStatics, AdMob);
this.analytics = this._appNamespaceOrStatics(AnalyticsStatics, Analytics);
this.auth = this._appNamespaceOrStatics(AuthStatics, Auth);
this.analytics = this._appNamespaceOrStatics({}, Analytics);
this.config = this._appNamespaceOrStatics({}, RemoteConfig);
this.crash = this._appNamespaceOrStatics({}, Crash);
this.config = this._appNamespaceOrStatics(ConfigStatics, Config);
this.crash = this._appNamespaceOrStatics(CrashStatics, Crash);
this.database = this._appNamespaceOrStatics(DatabaseStatics, Database);
this.firestore = this._appNamespaceOrStatics(FirestoreStatics, Firestore);
this.links = this._appNamespaceOrStatics(LinksStatics, Links);
this.messaging = this._appNamespaceOrStatics(MessagingStatics, Messaging);
this.perf = this._appNamespaceOrStatics(DatabaseStatics, Performance);
this.perf = this._appNamespaceOrStatics(PerformanceStatics, Performance);
this.storage = this._appNamespaceOrStatics(StorageStatics, Storage);
this.utils = this._appNamespaceOrStatics(UtilsStatics, Utils);
}
@ -160,7 +179,7 @@ class FirebaseCore {
* A (read-only) array of all initialized apps.
* @return {Array}
*/
get apps(): Array<Object> {
get apps(): Array<FirebaseApp> {
return Object.values(INTERNALS.APPS);
}
@ -201,7 +220,7 @@ class FirebaseCore {
* @return {function(FirebaseApp=)}
* @private
*/
_appNamespaceOrStatics(statics: Object = {}, InstanceClass: Class<*>): Function {
_appNamespaceOrStatics<M: FirebaseModule, S: FirebaseStatics>(statics: S, InstanceClass: Class<M>): FirebaseModuleAndStatics<M, S> {
const namespace = InstanceClass._NAMESPACE;
const getNamespace = (app?: FirebaseApp) => {
@ -216,11 +235,9 @@ class FirebaseCore {
return INTERNALS.APPS[_app._name][namespace](_app);
};
Object.assign(getNamespace, statics, {
return Object.assign(getNamespace, statics, {
nativeModuleExists: !!NativeModules[InstanceClass._NATIVE_MODULE],
});
return getNamespace;
}
/**

View File

@ -1,5 +1,10 @@
// @flow
import ModuleBase from './../../utils/ModuleBase';
/**
* @flow
* Crash Reporting representation wrapper
*/
import ModuleBase from '../../utils/ModuleBase';
import type { FirebaseError } from '../../types';
export default class Crash extends ModuleBase {
static _NAMESPACE = 'crash';
@ -71,3 +76,5 @@ export default class Crash extends ModuleBase {
this._native.report(errorMessage);
}
}
export const statics = {};

View File

@ -3,7 +3,9 @@
*/
import Reference from './reference.js';
import { objectToUniqueId } from './../../utils';
import { objectToUniqueId } from '../../utils';
import type { DatabaseModifier } from '../../types';
// todo doc methods

View File

@ -5,7 +5,7 @@
import Query from './query.js';
import Snapshot from './snapshot';
import Disconnect from './disconnect';
import ReferenceBase from './../../utils/ReferenceBase';
import ReferenceBase from '../../utils/ReferenceBase';
import {
promiseOrCallback,
@ -15,10 +15,12 @@ import {
tryJSONParse,
tryJSONStringify,
generatePushID,
} from './../../utils';
} from '../../utils';
import INTERNALS from '../../utils/internals';
import type { DatabaseModifier, FirebaseError } from '../../types';
// track all event registrations by path
let listeners = 0;
@ -35,6 +37,13 @@ const ReferenceEventTypes = {
child_moved: 'child_moved',
};
type DatabaseListener = {
listenerId: number;
eventName: string;
successCallback: Function;
failureCallback?: Function;
}
/**
* @typedef {String} ReferenceLocation - Path to location in the database, relative
* to the root reference. Consists of a path where segments are separated by a

View File

@ -7,6 +7,7 @@ import Query from './Query';
import { firestoreAutoId } from '../../utils';
import type Firestore from './';
import type { FirestoreQueryDirection, FirestoreQueryOperator } from '../../types';
import type Path from './Path';
import type QuerySnapshot from './QuerySnapshot';

View File

@ -5,6 +5,7 @@
import DocumentSnapshot from './DocumentSnapshot';
import type Firestore from './';
import type { FirestoreNativeDocumentChange } from '../../types';
/**
* @class DocumentChange

View File

@ -8,6 +8,7 @@ import { buildNativeMap } from './utils/serialize';
import { firestoreAutoId, isFunction, isObject, isString } from '../../utils';
import type Firestore from './';
import type { FirestoreNativeDocumentSnapshot, FirestoreWriteOptions } from '../../types';
import type Path from './Path';
type DocumentListenOptions = {

View File

@ -7,6 +7,7 @@ import Path from './Path';
import { parseNativeMap } from './utils/serialize';
import type Firestore from './';
import type { FirestoreNativeDocumentSnapshot, FirestoreSnapshotMetadata } from '../../types';
/**
* @class DocumentSnapshot

View File

@ -8,6 +8,7 @@ import { buildNativeArray, buildTypeMap } from './utils/serialize';
import { firestoreAutoId, isFunction, isObject } from '../../utils';
import type Firestore from './';
import type { FirestoreQueryDirection, FirestoreQueryOperator } from '../../types';
import type Path from './Path';
const DIRECTIONS: { [FirestoreQueryDirection]: string } = {

View File

@ -6,6 +6,7 @@ import DocumentChange from './DocumentChange';
import DocumentSnapshot from './DocumentSnapshot';
import type Firestore from './';
import type { FirestoreNativeDocumentChange, FirestoreNativeDocumentSnapshot, FirestoreSnapshotMetadata } from '../../types';
import type Query from './Query';
type QuerySnapshotNativeData = {

View File

@ -7,6 +7,7 @@ import { isObject, isString } from '../../utils';
import type DocumentReference from './DocumentReference';
import type Firestore from './';
import type { FirestoreWriteOptions } from '../../types';
type DocumentWrite = {
data?: Object,

View File

@ -31,10 +31,7 @@ type DocumentSyncEvent = {
path: string,
}
/**
* @class Firestore
*/
export default class Firestore extends ModuleBase {
class FirestoreInternalModule extends ModuleBase {
static _NAMESPACE = 'firestore';
static _NATIVE_MODULE = 'RNFirebaseFirestore';
@ -44,14 +41,14 @@ export default class Firestore extends ModuleBase {
super(firebaseApp, options, true);
this._referencePath = new Path([]);
this.addListener(
super.addListener(
// sub to internal native event - this fans out to
// public event name: onCollectionSnapshot
super._getAppEventName('firestore_collection_sync_event'),
this._onCollectionSyncEvent.bind(this),
);
this.addListener(
super.addListener(
// sub to internal native event - this fans out to
// public event name: onDocumentSnapshot
super._getAppEventName('firestore_document_sync_event'),
@ -59,58 +56,6 @@ export default class Firestore extends ModuleBase {
);
}
batch(): WriteBatch {
return new WriteBatch(this);
}
/**
*
* @param collectionPath
* @returns {CollectionReference}
*/
collection(collectionPath: string): CollectionReference {
const path = this._referencePath.child(collectionPath);
if (!path.isCollection) {
throw new Error('Argument "collectionPath" must point to a collection.');
}
return new CollectionReference(this, path);
}
/**
*
* @param documentPath
* @returns {DocumentReference}
*/
doc(documentPath: string): DocumentReference {
const path = this._referencePath.child(documentPath);
if (!path.isDocument) {
throw new Error('Argument "documentPath" must point to a document.');
}
return new DocumentReference(this, path);
}
enablePersistence(): Promise<void> {
throw new Error('Persistence is enabled by default on the Firestore SDKs');
}
runTransaction(): Promise<any> {
throw new Error('firebase.firestore().runTransaction() coming soon');
}
setLogLevel(): void {
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Firestore, 'setLogLevel'));
}
settings(): void {
throw new Error('firebase.firestore().settings() coming soon');
}
/**
* INTERNALS
*/
/**
* Internal collection sync listener
* @param event
@ -138,6 +83,63 @@ export default class Firestore extends ModuleBase {
}
}
/**
* @class Firestore
*/
export default class Firestore extends FirestoreInternalModule {
constructor(firebaseApp: FirebaseApp, options: Object = {}) {
super(firebaseApp, options);
}
batch(): WriteBatch {
return new WriteBatch(this);
}
/**
*
* @param collectionPath
* @returns {CollectionReference}
*/
collection(collectionPath: string): CollectionReference {
const path = super._referencePath.child(collectionPath);
if (!path.isCollection) {
throw new Error('Argument "collectionPath" must point to a collection.');
}
return new CollectionReference(this, path);
}
/**
*
* @param documentPath
* @returns {DocumentReference}
*/
doc(documentPath: string): DocumentReference {
const path = super._referencePath.child(documentPath);
if (!path.isDocument) {
throw new Error('Argument "documentPath" must point to a document.');
}
return new DocumentReference(this, path);
}
enablePersistence(): Promise<void> {
throw new Error('Persistence is enabled by default on the Firestore SDKs');
}
runTransaction(): Promise<any> {
throw new Error('firebase.firestore().runTransaction() coming soon');
}
setLogLevel(): void {
throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Firestore, 'setLogLevel'));
}
settings(): void {
throw new Error('firebase.firestore().settings() coming soon');
}
}
export const statics = {
FieldValue,
GeoPoint,

View File

@ -9,6 +9,7 @@ import Path from '../Path';
import { typeOf } from '../../../utils';
import type Firestore from '../';
import type { FirestoreTypeMap } from '../../../types';
/*
* Functions that build up the data needed to represent

View File

@ -29,3 +29,5 @@ export default class PerformanceMonitoring extends ModuleBase {
return new Trace(this, trace);
}
}
export const statics = {};

View File

@ -5,11 +5,20 @@ import { NativeModules } from 'react-native';
import INTERNALS from '../../utils/internals';
import { isIOS } from '../../utils';
import ModuleBase from '../../utils/ModuleBase';
import PACKAGE from '../../../package.json';
const FirebaseCoreModule = NativeModules.RNFirebase;
export default class RNFirebaseUtils {
type GoogleApiAvailabilityType = {
status: number,
isAvailable: boolean,
isUserResolvableError?: boolean,
hasResolution?: boolean,
error?: string
}
export default class RNFirebaseUtils extends ModuleBase {
static _NAMESPACE = 'utils';
static _NATIVE_DISABLED = true;
static _NATIVE_MODULE = 'RNFirebaseUtils';
@ -105,7 +114,7 @@ export default class RNFirebaseUtils {
* @android
* @param bool
*/
set errorOnMissingPlayServices(bool: Boolean) {
set errorOnMissingPlayServices(bool: boolean) {
INTERNALS.OPTIONS.errorOnMissingPlayServices = bool;
}
@ -114,7 +123,7 @@ export default class RNFirebaseUtils {
* @android
* @param bool
*/
set promptOnMissingPlayServices(bool: Boolean) {
set promptOnMissingPlayServices(bool: boolean) {
INTERNALS.OPTIONS.promptOnMissingPlayServices = bool;
}
}

View File

@ -1,93 +0,0 @@
/* eslint-disable */
/* Core types */
declare class FirebaseError {
message: string,
name: string,
code: string,
stack: string,
path: string,
details: string,
modifiers: string
};
declare type FirebaseOptions = {
apiKey: string,
appId: string,
databaseURL: string,
messagingSenderId: string,
projectId: string,
storageBucket: string,
}
/* Auth types */
declare type AuthResult = {
authenticated: boolean,
user: Object|null
} | null;
declare type AuthCredential = {
providerId: string,
token: string,
secret: string
};
/* Database types */
declare type DatabaseListener = {
listenerId: number;
eventName: string;
successCallback: Function;
failureCallback?: Function;
};
declare type DatabaseModifier = {
type: 'orderBy' | 'limit' | 'filter';
name?: string;
key?: string;
limit?: number;
value?: any;
valueType?: string;
};
/* Firestore types */
declare type FirestoreNativeDocumentChange = {
document: FirestoreNativeDocumentSnapshot,
newIndex: number,
oldIndex: number,
type: string,
}
declare type FirestoreNativeDocumentSnapshot = {
data: { [string]: FirestoreTypeMap },
metadata: FirestoreSnapshotMetadata,
path: string,
}
declare type FirestoreSnapshotMetadata = {
fromCache: boolean,
hasPendingWrites: boolean,
}
declare type FirestoreQueryDirection = 'DESC' | 'desc' | 'ASC' | 'asc';
declare type FirestoreQueryOperator = '<' | '<=' | '=' | '==' | '>' | '>=';
declare type FirestoreTypeMap = {
type: 'array' | 'boolean' | 'date' | 'fieldvalue' | 'geopoint' | 'null' | 'number' | 'object' | 'reference' | 'string',
value: any,
}
declare type FirestoreWriteOptions = {
merge?: boolean,
}
/* Util types */
declare type GoogleApiAvailabilityType = {
status: number,
isAvailable: boolean,
isUserResolvableError?: boolean,
hasResolution?: boolean,
error?: string
};

187
lib/types/index.js Normal file
View File

@ -0,0 +1,187 @@
/* @flow */
import type AdMob from '../modules/admob';
import { typeof statics as AdMobStatics } from '../modules/admob';
import type Analytics from '../modules/analytics';
import { typeof statics as AnalyticsStatics } from '../modules/analytics';
import type Auth from '../modules/auth';
import { typeof statics as AuthStatics } from '../modules/auth';
import type Config from '../modules/config';
import { typeof statics as ConfigStatics } from '../modules/config';
import type Crash from '../modules/crash';
import { typeof statics as CrashStatics } from '../modules/crash';
import type Database from '../modules/database';
import { typeof statics as DatabaseStatics } from '../modules/database';
import type Firestore from '../modules/firestore';
import { typeof statics as FirestoreStatics } from '../modules/firestore';
import type Links from '../modules/links';
import { typeof statics as LinksStatics } from '../modules/links';
import type Messaging from '../modules/messaging';
import { typeof statics as MessagingStatics } from '../modules/messaging';
import type ModuleBase from '../utils/ModuleBase';
import type Performance from '../modules/perf';
import { typeof statics as PerformanceStatics } from '../modules/perf';
import type Storage from '../modules/storage';
import { typeof statics as StorageStatics } from '../modules/storage';
import type Utils from '../modules/utils';
import { typeof statics as UtilsStatics } from '../modules/utils';
/* Core types */
export type FirebaseError = {
message: string,
name: string,
code: string,
stack: string,
path: string,
details: string,
modifiers: string
}
export type FirebaseModule = $Subtype<ModuleBase>;
export type FirebaseModuleName = 'admob' | 'analytics' | 'auth' | 'config' | 'crash' | 'database'
| 'firestore' | 'links' | 'messaging' | 'perf' | 'storage' | 'utils';
export type FirebaseOptions = {
apiKey: string,
appId: string,
databaseURL: string,
messagingSenderId: string,
projectId: string,
storageBucket: string,
}
export type FirebaseModuleAndStatics<M: FirebaseModule, S: FirebaseStatics> = {
(): M,
nativeModuleExists: boolean,
} & S;
export type FirebaseStatics = $Subtype<Object>;
/* Admob types */
export type AdMobModule = {
(): AdMob,
nativeModuleExists: boolean,
} & AdMobStatics;
/* Analytics types */
export type AnalyticsModule = {
(): Analytics,
nativeModuleExists: boolean,
} & AnalyticsStatics;
/* Remote Config types */
export type ConfigModule = {
(): Config,
nativeModuleExists: boolean,
} & ConfigStatics;
export type AuthCredential = {
providerId: string,
token: string,
secret: string
}
/* Auth types */
export type AuthModule = {
(): Auth,
nativeModuleExists: boolean,
} & AuthStatics;
/* Crash types */
export type CrashModule = {
(): Crash,
nativeModuleExists: boolean,
} & CrashStatics;
/* Database types */
export type DatabaseModule = {
(): Database,
nativeModuleExists: boolean,
} & DatabaseStatics;
export type DatabaseModifier = {
type: 'orderBy' | 'limit' | 'filter';
name?: string;
key?: string;
limit?: number;
value?: any;
valueType?: string;
}
/* Firestore types */
export type FirestoreModule = {
(): Firestore,
nativeModuleExists: boolean,
} & FirestoreStatics;
export type FirestoreNativeDocumentChange = {
document: FirestoreNativeDocumentSnapshot,
newIndex: number,
oldIndex: number,
type: string,
}
export type FirestoreNativeDocumentSnapshot = {
data: { [string]: FirestoreTypeMap },
metadata: FirestoreSnapshotMetadata,
path: string,
}
export type FirestoreSnapshotMetadata = {
fromCache: boolean,
hasPendingWrites: boolean,
}
export type FirestoreQueryDirection = 'DESC' | 'desc' | 'ASC' | 'asc';
export type FirestoreQueryOperator = '<' | '<=' | '=' | '==' | '>' | '>=';
export type FirestoreTypeMap = {
type: 'array' | 'boolean' | 'date' | 'fieldvalue' | 'geopoint' | 'null' | 'number' | 'object' | 'reference' | 'string',
value: any,
}
export type FirestoreWriteOptions = {
merge?: boolean,
}
/* Links types */
export type LinksModule = {
(): Links,
nativeModuleExists: boolean,
} & LinksStatics;
/* Messaging types */
export type MessagingModule = {
(): Messaging,
nativeModuleExists: boolean,
} & MessagingStatics;
/* Performance types */
export type PerformanceModule = {
(): Performance,
nativeModuleExists: boolean,
} & PerformanceStatics;
/* Storage types */
export type StorageModule = {
(): Storage,
nativeModuleExists: boolean,
} & StorageStatics;
/* Utils types */
export type UtilsModule = {
(): Utils,
nativeModuleExists: boolean,
} & UtilsStatics;

View File

@ -9,6 +9,7 @@ import FirebaseCore from '../modules/core/firebase';
import { nativeWithApp } from '../utils';
import type FirebaseApp from '../modules/core/firebase-app';
import type { FirebaseModuleName } from '../types';
const logs = {};
@ -53,7 +54,7 @@ export default class ModuleBase {
_namespace: string;
_firebaseApp: FirebaseApp;
_eventEmitter: Object;
static _NAMESPACE: string;
static _NAMESPACE: FirebaseModuleName;
static _NATIVE_MODULE: string;
/**

View File

@ -3,10 +3,10 @@
*/
import { NativeEventEmitter } from 'react-native';
import INTERNALS from './../internals';
import DatabaseSnapshot from './../modules/database/snapshot';
import DatabaseReference from './../modules/database/reference';
import { isString, nativeToJSError } from './../utils';
import INTERNALS from './internals';
import DatabaseSnapshot from '../modules/database/snapshot';
import DatabaseReference from '../modules/database/reference';
import { isString, nativeToJSError } from '../utils';
type Registration = {
key: string,

View File

@ -7,6 +7,8 @@ import EventEmitter from './emitter/EventEmitter';
import ModuleBase from './ModuleBase';
import SyncTree from './SyncTree';
import type FirebaseApp from '../modules/core/firebase-app';
const DEFAULT_APP_NAME = Platform.OS === 'ios' ? '__FIRAPP_DEFAULT' : '[DEFAULT]';
const NAMESPACE_PODS = {
@ -53,6 +55,8 @@ const PLAY_SERVICES_CODES = {
},
};
const APPS: { [string]: FirebaseApp } = {};
export default {
// default options
OPTIONS: {
@ -66,9 +70,7 @@ export default {
},
// track all initialized firebase apps
APPS: {
[DEFAULT_APP_NAME]: null,
},
APPS,
STRINGS: {
WARN_INITIALIZE_DEPRECATION: 'Deprecation: Calling \'initializeApp()\' for apps that are already initialised natively ' +

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "3.1.0",
"version": "3.1.1-alpha.11",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "react-native-firebase",
"version": "3.1.1-alpha.4",
"version": "3.1.1-alpha.11",
"author": "Invertase <contact@invertase.io> (http://invertase.io)",
"description": "A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Messaging (FCM), Remote Config, Storage and Performance.",
"main": "dist/index.js",
@ -20,9 +20,6 @@
"tests-watch-start": "npm run test-cli watch init start",
"tests-watch-stop": "npm run test-cli watch stop"
},
"files": [
"dist"
],
"repository": {
"type": "git",
"url": "https://github.com/invertase/react-native-firebase.git"

View File

@ -150,7 +150,7 @@ PODS:
- React/Core
- React/fishhook
- React/RCTBlob
- RNFirebase (3.1.0):
- RNFirebase (3.1.1-alpha.11):
- React
- yoga (0.49.1.React)
@ -208,7 +208,7 @@ SPEC CHECKSUMS:
nanopb: 5601e6bca2dbf1ed831b519092ec110f66982ca3
Protobuf: 03eef2ee0b674770735cf79d9c4d3659cf6908e8
React: cf892fb84b7d06bf5fea7f328e554c6dcabe85ee
RNFirebase: 1b8adf4dfe740fbc4a69a147715c2edfd041eb92
RNFirebase: e959075eb2f348c3586cd92973543b80e373b29c
yoga: 3abf02d6d9aeeb139b4c930eb1367feae690a35a
PODFILE CHECKSUM: b5674be55653f5dda937c8b794d0479900643d45