UNPKG

firebase-tools-extra

Version:

Extra functionality for firebase-tools with support for emulators and auth through service account.

63 lines (62 loc) 2.28 kB
/// <reference types="node" /> import * as admin from 'firebase-admin'; import { writeFile } from 'fs'; export declare const writeFilePromise: typeof writeFile.__promisify__; /** * Get settings from firebaserc file * @param filePath - Path for file * @returns Firebase settings object */ export declare function readJsonFile(filePath: string): any; /** * Parse fixture path string into JSON with error handling * @param valueToParse - valueToParse string to be parsed into JSON * @returns Parsed fixture value or path */ export declare function tryToJsonParse(valueToParse: any): any; interface ServiceAccount { type: string; project_id: string; private_key_id: string; private_key: string; client_email: string; client_id: string; auth_uri: string; token_uri: string; auth_provider_x509_cert_url: string; client_x509_cert_url: string; } /** * Get service account from either local file or environment variables * @returns Service account object */ export declare function getServiceAccount(): ServiceAccount | null; interface InitOptions { emulator?: boolean; debug?: boolean; } /** * Initialize Firebase instance from service account (from either local * serviceAccount.json or environment variables) * * @returns Initialized Firebase instance * @param options - Options object */ export declare function initializeFirebase(options?: InitOptions): admin.app.App; /** * Convert slash path to Firestore reference * @param firestoreInstance - Instance on which to * create ref * @param slashPath - Path to convert into firestore reference * @param options - Options object * @returns Ref at slash path */ export declare function slashPathToFirestoreRef(firestoreInstance: any, slashPath: string, options?: any): admin.firestore.CollectionReference | admin.firestore.DocumentReference | admin.firestore.Query; /** * @param firestoreInstance - Instance of firestore from which to delete collection * @param collectionPath - Path of collection to delete * @param batchSize - Size of batch * @returns Promise which resolves when collection has been deleted */ export declare function deleteFirestoreCollection(firestoreInstance: any, collectionPath: string, batchSize?: number): Promise<any>; export {};