database.d.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * Copyright 2020 Google Inc.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /// <reference types="node" />
  18. import { FirebaseDatabase } from '@firebase/database-types';
  19. import { App } from '../app';
  20. /**
  21. * The Firebase Database service interface. Extends the
  22. * {@link https://firebase.google.com/docs/reference/js/v8/firebase.database.Database | Database}
  23. * interface provided by the `@firebase/database-compat` package.
  24. */
  25. export interface Database extends FirebaseDatabase {
  26. /**
  27. * Gets the currently applied security rules as a string. The return value consists of
  28. * the rules source including comments.
  29. *
  30. * @returns A promise fulfilled with the rules as a raw string.
  31. */
  32. getRules(): Promise<string>;
  33. /**
  34. * Gets the currently applied security rules as a parsed JSON object. Any comments in
  35. * the original source are stripped away.
  36. *
  37. * @returns A promise fulfilled with the parsed rules object.
  38. */
  39. getRulesJSON(): Promise<object>;
  40. /**
  41. * Sets the specified rules on the Firebase Realtime Database instance. If the rules source is
  42. * specified as a string or a Buffer, it may include comments.
  43. *
  44. * @param source - Source of the rules to apply. Must not be `null` or empty.
  45. * @returns Resolves when the rules are set on the Realtime Database.
  46. */
  47. setRules(source: string | Buffer | object): Promise<void>;
  48. }
  49. export declare class DatabaseService {
  50. private readonly appInternal;
  51. private tokenListener;
  52. private tokenRefreshTimeout;
  53. private databases;
  54. constructor(app: App);
  55. private get firebaseApp();
  56. /**
  57. * Returns the app associated with this DatabaseService instance.
  58. *
  59. * @returns The app associated with this DatabaseService instance.
  60. */
  61. get app(): App;
  62. getDatabase(url?: string): Database;
  63. private onTokenChange;
  64. private scheduleTokenRefresh;
  65. private ensureUrl;
  66. }