-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathindex.d.ts
581 lines (521 loc) · 16.8 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* Core React Native Firebase package.
*
* #### Example 1
*
* Access the default firebase app from the `app` package:
*
* ```js
* import firebase from '@react-native-firebase/app';
*
* console.log(firebase.app().name);
* ```
*
* @firebase app
*/
export namespace ReactNativeFirebase {
export interface NativeFirebaseError extends Error {
/**
* Firebase error code, e.g. `auth/invalid-email`
*/
readonly code: string;
/**
* Firebase error message
*/
readonly message: string;
/**
* The email address of the user's account used in the operation that triggered the error, if applicable
*/
readonly email?: string;
/**
* The firebase module namespace that this error originated from, e.g. 'analytics'
*/
readonly namespace: string;
/**
* The native sdks returned error code, different per platform
*/
readonly nativeErrorCode: string | number;
/**
* The native sdks returned error message, different per platform
*/
readonly nativeErrorMessage: string;
}
export type LogLevelString = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'silent';
export interface FirebaseAppOptions {
/**
* The Google App ID that is used to uniquely identify an instance of an app.
*/
appId: string;
/**
* An API key used for authenticating requests from your app, e.g.
* "AIzaSyDdVgKwhZl0sTTTLZ7iTmt1r3N2cJLnaDk", used to identify your app to Google servers.
*/
apiKey?: string;
/**
* The database root URL, e.g. "http://abc-xyz-123.firebaseio.com".
*/
databaseURL?: string;
/**
* The Project ID from the Firebase console, for example "abc-xyz-123".
*/
projectId: string;
/**
* The tracking ID for Google Analytics, e.g. "UA-12345678-1", used to configure Google Analytics.
*/
gaTrackingId?: string;
/**
* The Google Cloud Storage bucket name, e.g. "abc-xyz-123.storage.firebase.com".
*/
storageBucket?: string;
/**
* The Project Number from the Google Developer's console, for example "012345678901", used to
* configure Google Cloud Messaging.
*/
messagingSenderId?: string;
/**
* iOS only - The OAuth2 client ID for iOS application used to authenticate Google users, for example
* "12345.apps.googleusercontent.com", used for signing in with Google.
*/
clientId?: string;
/**
* iOS only - The Android client ID used in Google AppInvite when an iOS app has its Android version, for
* example "12345.apps.googleusercontent.com".
*/
androidClientId?: string;
/**
* iOS only - The URL scheme used to set up Durable Deep Link service.
*/
deepLinkURLScheme?: string;
[name: string]: any;
}
export interface FirebaseAppConfig {
/**
* The Firebase App name, defaults to [DEFAULT] if none provided.
*/
name?: string;
/**
* Default setting for data collection on startup that affects all Firebase module startup data collection settings,
* in the absence of module-specific overrides. This will start as false if you set "app_data_collection_default_enabled"
* to false in firebase.json and may be used in opt-in flows, for example a GDPR-compliant app.
* If configured false initially, set to true after obtaining consent, then enable module-specific settings as needed afterwards.
*/
automaticDataCollectionEnabled?: boolean;
/**
* If set to true it indicates that Firebase should close database connections
* automatically when the app is in the background. Disabled by default.
*/
automaticResourceManagement?: boolean;
}
export interface FirebaseApp {
/**
* The name (identifier) for this App. '[DEFAULT]' is the default App.
*/
readonly name: string;
/**
* The (read-only) configuration options from the app initialization.
*/
readonly options: FirebaseAppOptions;
/**
* Make this app unusable and free up resources.
*/
delete(): Promise<void>;
utils(): Utils.Module;
}
export interface Module {
/**
* Create (and initialize) a FirebaseApp.
*
* @param options Options to configure the services used in the App.
* @param config The optional config for your firebase app
*/
initializeApp(options: FirebaseAppOptions, config?: FirebaseAppConfig): Promise<FirebaseApp>;
/**
* Create (and initialize) a FirebaseApp.
*
* @param options Options to configure the services used in the App.
* @param name The optional name of the app to initialize ('[DEFAULT]' if
* omitted)
*/
initializeApp(options: FirebaseAppOptions, name?: string): Promise<FirebaseApp>;
/**
* Retrieve an instance of a FirebaseApp.
*
* @example
* ```js
* const app = firebase.app('foo');
* ```
*
* @param name The optional name of the app to return ('[DEFAULT]' if omitted)
*/
app(name?: string): FirebaseApp;
/**
* Set the log level across all modules. Only applies to iOS currently, has no effect on Android.
* Should be one of 'error', 'warn', 'info', or 'debug'.
* Logs messages at the configured level or lower (less verbose / more important).
* Note that if an app is running from AppStore, it will never log above info even if
* level is set to a higher (more verbose) setting.
* Note that iOS is missing firebase-js-sdk log levels 'verbose' and 'silent'.
* 'verbose' if used will map to 'debug', 'silent' has no valid mapping and will return an error if used.
*
* @ios
*/
setLogLevel(logLevel: LogLevelString): void;
/**
* A (read-only) array of all the initialized Apps.
*/
apps: FirebaseApp[];
/**
* The current React Native Firebase version.
*/
readonly SDK_VERSION: string;
/**
* Utils provides a collection of utilities to aid in using Firebase
* and related services inside React Native, e.g. Test Lab helpers
* and Google Play Services version helpers.
*/
utils: typeof utils;
}
/**
* A class that all React Native Firebase modules extend from to provide default behaviour.
*/
export class FirebaseModule {
/**
* The current `FirebaseApp` instance for this Firebase service.
*/
app: FirebaseApp;
/**
* The native module instance for this Firebase service.
*/
private native: any;
/**
* Returns the shared event emitter instance used for all JS event routing.
*/
private emitter: any;
}
// eslint-disable-next-line @typescript-eslint/ban-types
export type FirebaseModuleWithStatics<M, S = {}> = {
(): M;
/**
* This React Native Firebase module version.
*/
readonly SDK_VERSION: string;
} & S;
// eslint-disable-next-line @typescript-eslint/ban-types
export type FirebaseModuleWithStaticsAndApp<M, S = {}> = {
(app?: FirebaseApp): M;
/**
* This React Native Firebase module version.
*/
readonly SDK_VERSION: string;
} & S;
}
/*
* @firebase utils
*/
export namespace Utils {
import FirebaseModule = ReactNativeFirebase.FirebaseModule;
/**
* A collection of native device file paths to aid in the usage of file path based methods.
*
* Concatenate a file path with your target file name when using with Storage `putFile` or `writeToFile`.
*
* ```js
* firebase.utils.FilePath;
* ```
*/
export interface FilePath {
/**
* Returns an absolute path to the applications main bundle.
*
* ```js
* firebase.utils.FilePath.MAIN_BUNDLE;
* ```
*
* @ios iOS only
*/
MAIN_BUNDLE: string;
/**
* Returns an absolute path to the application specific cache directory on the filesystem.
*
* The system will automatically delete files in this directory when disk space is needed elsewhere on the device, starting with the oldest files first.
*
* ```js
* firebase.utils.FilePath.CACHES_DIRECTORY;
* ```
*/
CACHES_DIRECTORY: string;
/**
* Returns an absolute path to the users Documents directory.
*
* Use this directory to place documents that have been created by the user.
*
* Normally this is the external files directory on Android but if no external storage directory found,
* e.g. removable media has been ejected by the user, it will fall back to internal storage. This may
* under rare circumstances where device storage environment changes cause the directory to be different
* between runs of the application
*
* ```js
* firebase.utils.FilePath.DOCUMENT_DIRECTORY;
* ```
*/
DOCUMENT_DIRECTORY: string;
/**
* Returns an absolute path to a temporary directory.
*
* Use this directory to create temporary files. The system will automatically delete files in this directory when disk space is needed elsewhere on the device, starting with the oldest files first.
*
* ```js
* firebase.utils.FilePath.TEMP_DIRECTORY;
* ```
*/
TEMP_DIRECTORY: string;
/**
* Returns an absolute path to the apps library/resources directory.
*
* E.g. this can be used for things like documentation, support files, and configuration files and generic resources.
*
* ```js
* firebase.utils.FilePath.LIBRARY_DIRECTORY;
* ```
*/
LIBRARY_DIRECTORY: string;
/**
* Returns an absolute path to the directory on the primary shared/external storage device.
*
* Here your application can place persistent files it owns. These files are internal to the application, and not typically visible to the user as media.
*
* Returns null if no external storage directory found, e.g. removable media has been ejected by the user.
*
* ```js
* firebase.utils.FilePath.EXTERNAL_DIRECTORY;
* ```
*
* @android Android only - iOS returns null
*/
EXTERNAL_DIRECTORY: string | null;
/**
* Returns an absolute path to the primary shared/external storage directory.
*
* Traditionally this is an SD card, but it may also be implemented as built-in storage on a device.
*
* Returns null if no external storage directory found, e.g. removable media has been ejected by the user.
* Requires special permission granted by Play Store review team on Android, is unlikely to be a valid path.
*
* ```js
* firebase.utils.FilePath.EXTERNAL_STORAGE_DIRECTORY;
* ```
*
* @android Android only - iOS returns null
*/
EXTERNAL_STORAGE_DIRECTORY: string | null;
/**
* Returns an absolute path to a directory in which to place pictures that are available to the user.
* Requires special permission granted by Play Store review team on Android, is unlikely to be a valid path.
*
* ```js
* firebase.utils.FilePath.PICTURES_DIRECTORY;
* ```
*/
PICTURES_DIRECTORY: string;
/**
* Returns an absolute path to a directory in which to place movies that are available to the user.
* Requires special permission granted by Play Store review team on Android, is unlikely to be a valid path.
*
* ```js
* firebase.utils.FilePath.MOVIES_DIRECTORY;
* ```
*/
MOVIES_DIRECTORY: string;
}
export interface Statics {
FilePath: FilePath;
}
/**
* For further information on the status codes available & what they represent, please head over
* to ConnectionResult documentation:
* https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult
*/
export enum PlayServicesAvailabilityStatusCodes {
API_UNAVAILABLE = 16,
CANCELED = 13,
DEVELOPER_ERROR = 10,
DRIVE_EXTERNAL_STORAGE_REQUIRED = 1500,
INTERNAL_ERROR = 8,
INTERRUPTED = 15,
INVALID_ACCOUNT = 5,
LICENSE_CHECK_FAILED = 11,
NETWORK_ERROR = 7,
RESOLUTION_REQUIRED = 6,
RESTRICTED_PROFILE = 20,
SERVICE_DISABLED = 3,
SERVICE_INVALID = 9,
SERVICE_MISSING = 1,
SERVICE_MISSING_PERMISSION = 19,
SERVICE_UPDATING = 18,
SERVICE_VERSION_UPDATE_REQUIRED = 2,
SIGN_IN_FAILED = 17,
SIGN_IN_REQUIRED = 4,
SUCCESS = 0,
TIMEOUT = 14,
}
export interface PlayServicesAvailability {
/**
* Returns a numeric status code. Please refer to Android documentation
* for further information:
* https://developers.google.com/android/reference/com/google/android/gms/common/ConnectionResult
*
* ```js
* firebase.utils().playServicesAvailability.status;
* ```
*
* @android Android only - iOS returns 0
*/
status: PlayServicesAvailabilityStatusCodes;
/**
* Returns a boolean indicating whether Play Store is available on the device
*
* ```js
* firebase.utils().playServicesAvailability.isAvailable;
* ```
*
* @android Android only - iOS returns true
*/
isAvailable: boolean;
/**
* If Play Services is not available on the device, hasResolution indicates
* whether it is possible to do something about it (e.g. install Play Services).
*
* ```js
* firebase.utils().playServicesAvailability.hasResolution;
* ```
* @android Android only - iOS returns undefined
*/
hasResolution: boolean | undefined;
/**
* If an error was received, this indicates whether the error is resolvable
*
* ```js
* firebase.utils().playServicesAvailability.isUserResolvableError;
* ```
* @android Android only - iOS returns undefined
*/
isUserResolvableError: boolean | undefined;
/**
* A human readable error string
*
* ```js
* firebase.utils().playServicesAvailability.error;
* ```
* @android Android only - iOS returns undefined
*/
error: string | undefined;
}
/**
* The React Native Firebase Utils service interface.
*
* > This module is available for the default app only.
*
* #### Example
*
* Get the Utils service for the default app:
*
* ```js
* const defaultAppUtils = firebase.utils();
* ```
*/
export class Module extends FirebaseModule {
/**
* Returns true if this app is running inside a Firebase Test Lab environment.
*
* #### Example
*
* ```js
* const isRunningInTestLab = await firebase.utils().isRunningInTestLab;
* ```
* @android Android only - iOS returns false
*/
isRunningInTestLab: boolean;
/**
* Returns PlayServicesAvailability properties
*
* #### Example
*
* ```js
* const PlayServicesAvailability = await firebase.utils().playServicesAvailability;
* ```
*
* @android Android only - iOS always returns { isAvailable: true, status: 0 }
*/
playServicesAvailability: PlayServicesAvailability;
/**
* Returns PlayServicesAvailability properties
*
* #### Example
*
* ```js
* const PlayServicesAvailability = await firebase.utils().getPlayServicesStatus();
* ```
*
* @android Android only - iOS always returns { isAvailable: true, status: 0 }
*/
getPlayServicesStatus(): Promise<PlayServicesAvailability>;
/**
* A prompt appears on the device to ask the user to update play services
*
* #### Example
*
* ```js
* await firebase.utils().promptForPlayServices();
* ```
*
* @android Android only - iOS returns undefined
*/
promptForPlayServices(): Promise<void>;
/**
* Attempts to make Google Play services available on this device
*
* #### Example
*
* ```js
* await firebase.utils().makePlayServicesAvailable();
* ```
*
* @android Android only - iOS returns undefined
*/
makePlayServicesAvailable(): Promise<void>;
/**
* Resolves an error by starting any intents requiring user interaction.
*
* #### Example
*
* ```js
* await firebase.utils().resolutionForPlayServices();
* ```
*
* @android Android only - iOS returns undefined
*/
resolutionForPlayServices(): Promise<void>;
}
}
/**
* Add Utils module as a named export for `app`.
*/
export const utils: ReactNativeFirebase.FirebaseModuleWithStatics<Utils.Module, Utils.Statics>;
declare const module: ReactNativeFirebase.Module;
export default module;