extensions.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2022 Google Inc.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. import { App } from '../app';
  19. import { SettableProcessingState } from './extensions-api';
  20. /**
  21. * The Firebase `Extensions` service interface.
  22. */
  23. export declare class Extensions {
  24. readonly app: App;
  25. private readonly client;
  26. /**
  27. * The runtime() method returns a new Runtime, which provides methods to modify an extension instance's runtime data.
  28. *
  29. * @remarks
  30. * This method will throw an error if called outside an Extensions environment.
  31. *
  32. * @returns A new {@link Runtime} object.
  33. */
  34. runtime(): Runtime;
  35. }
  36. /**
  37. * Runtime provides methods to modify an extension instance's runtime data.
  38. */
  39. export declare class Runtime {
  40. private projectId;
  41. private extensionInstanceId;
  42. private readonly client;
  43. /**
  44. * Sets the processing state of an extension instance.
  45. *
  46. * @remarks
  47. * Use this method to report the results of a lifecycle event handler.
  48. *
  49. * If the lifecycle event failed & the extension instance will no longer work
  50. * correctly, use {@link Runtime.setFatalError} instead.
  51. *
  52. * To report the status of function calls other than lifecycle event handlers,
  53. * use `console.log` or the Cloud Functions logger SDK.
  54. *
  55. * @param state - The state to set the instance to.
  56. * @param detailMessage - A message explaining the results of the lifecycle function.
  57. */
  58. setProcessingState(state: SettableProcessingState, detailMessage: string): Promise<void>;
  59. /**
  60. * Reports a fatal error while running a lifecycle event handler.
  61. *
  62. * @remarks
  63. * Call this method when a lifecycle event handler fails in a way that makes
  64. * the Instance inoperable.
  65. * If the lifecycle event failed but the instance will still work as expected,
  66. * call `setProcessingState` with the "PROCESSING_WARNING" or
  67. * "PROCESSING_FAILED" state instead.
  68. *
  69. * @param errorMessage - A message explaining what went wrong and how to fix it.
  70. */
  71. setFatalError(errorMessage: string): Promise<void>;
  72. private getProjectId;
  73. }