Files
react-native-firebase/packages/utils/lib/index.js.flow
Salakar c7c304e599 [storage] initial work to move storage.Path statics out of storage module and into core utils
TODO: move native storage code into utils
TODO: move utils module into core
2019-07-22 09:14:21 +01:00

192 lines
5.3 KiB
Plaintext

/* eslint-disable import/no-duplicates */
/*
* 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.
*
*/
import type { ReactNativeFirebaseModule } from '@react-native-firebase/app-types/index.js.flow';
/**
* 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.
*
* ```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.
*
* ```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.
*
* ```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.
*
* ```js
* firebase.utils.FilePath.MOVIES_DIRECTORY;
* ```
*/
MOVIES_DIRECTORY: string;
}
export interface Statics {
FilePath: FilePath;
}
export interface Module extends ReactNativeFirebaseModule {
/**
* Returns true if this app is running inside a Firebase Test Lab environment. Always returns false on iOS.
*
* @android
*/
isRunningInTestLab: boolean;
}
declare module '@react-native-firebase/utils' {
import type {
ReactNativeFirebaseNamespace,
ReactNativeFirebaseModuleAndStatics,
} from '@react-native-firebase/app-types/index.js.flow';
/**
* @example
* ```js
* import { firebase } from '@react-native-firebase/utils';
* firebase.utils().X(...);
* ```
*/
declare export var firebase: {} & ReactNativeFirebaseNamespace;
/**
* @example
* ```js
* import utils from '@react-native-firebase/utils';
* utils().X(...);
* ```
*/
declare export default ReactNativeFirebaseModuleAndStatics<Module, Statics>;
}
/**
* Attach namespace to `firebase.` and `FirebaseApp.`.
*/
declare module '@react-native-firebase/app-types' {
import type { ReactNativeFirebaseModuleAndStatics } from '@react-native-firebase/app-types/index.js.flow';
declare interface ReactNativeFirebaseNamespace {
/**
* Utils
*/
utils: ReactNativeFirebaseModuleAndStatics<Module, Statics>;
}
declare interface FirebaseApp {
/**
* Utils
*/
utils(): Module;
}
}