index.d.ts 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*! firebase-admin v12.1.1 */
  2. /*!
  3. * @license
  4. * Copyright 2017 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. /// <reference types="node" />
  19. import { App } from '../app/index';
  20. export declare function getSdkVersion(): string;
  21. /**
  22. * Renames properties on an object given a mapping from old to new property names.
  23. *
  24. * For example, this can be used to map underscore_cased properties to camelCase.
  25. *
  26. * @param obj - The object whose properties to rename.
  27. * @param keyMap - The mapping from old to new property names.
  28. */
  29. export declare function renameProperties(obj: {
  30. [key: string]: any;
  31. }, keyMap: {
  32. [key: string]: string;
  33. }): void;
  34. /**
  35. * Defines a new read-only property directly on an object and returns the object.
  36. *
  37. * @param obj - The object on which to define the property.
  38. * @param prop - The name of the property to be defined or modified.
  39. * @param value - The value associated with the property.
  40. */
  41. export declare function addReadonlyGetter(obj: object, prop: string, value: any): void;
  42. /**
  43. * Returns the Google Cloud project ID associated with a Firebase app, if it's explicitly
  44. * specified in either the Firebase app options, credentials or the local environment.
  45. * Otherwise returns null.
  46. *
  47. * @param app - A Firebase app to get the project ID from.
  48. *
  49. * @returns A project ID string or null.
  50. */
  51. export declare function getExplicitProjectId(app: App): string | null;
  52. /**
  53. * Determines the Google Cloud project ID associated with a Firebase app. This method
  54. * first checks if a project ID is explicitly specified in either the Firebase app options,
  55. * credentials or the local environment in that order. If no explicit project ID is
  56. * configured, but the SDK has been initialized with ComputeEngineCredentials, this
  57. * method attempts to discover the project ID from the local metadata service.
  58. *
  59. * @param app - A Firebase app to get the project ID from.
  60. *
  61. * @returns A project ID string or null.
  62. */
  63. export declare function findProjectId(app: App): Promise<string | null>;
  64. /**
  65. * Returns the service account email associated with a Firebase app, if it's explicitly
  66. * specified in either the Firebase app options, credentials or the local environment.
  67. * Otherwise returns null.
  68. *
  69. * @param app - A Firebase app to get the service account email from.
  70. *
  71. * @returns A service account email string or null.
  72. */
  73. export declare function getExplicitServiceAccountEmail(app: App): string | null;
  74. /**
  75. * Determines the service account email associated with a Firebase app. This method first
  76. * checks if a service account email is explicitly specified in either the Firebase app options,
  77. * credentials or the local environment in that order. If no explicit service account email is
  78. * configured, but the SDK has been initialized with ComputeEngineCredentials, this
  79. * method attempts to discover the service account email from the local metadata service.
  80. *
  81. * @param app - A Firebase app to get the service account email from.
  82. *
  83. * @returns A service account email ID string or null.
  84. */
  85. export declare function findServiceAccountEmail(app: App): Promise<string | null>;
  86. /**
  87. * Encodes data using web-safe-base64.
  88. *
  89. * @param data - The raw data byte input.
  90. * @returns The base64-encoded result.
  91. */
  92. export declare function toWebSafeBase64(data: Buffer): string;
  93. /**
  94. * Formats a string of form 'project/{projectId}/{api}' and replaces
  95. * with corresponding arguments {projectId: '1234', api: 'resource'}
  96. * and returns output: 'project/1234/resource'.
  97. *
  98. * @param str - The original string where the param need to be
  99. * replaced.
  100. * @param params - The optional parameters to replace in the
  101. * string.
  102. * @returns The resulting formatted string.
  103. */
  104. export declare function formatString(str: string, params?: object): string;
  105. /**
  106. * Generates the update mask for the provided object.
  107. * Note this will ignore the last key with value undefined.
  108. *
  109. * @param obj - The object to generate the update mask for.
  110. * @param terminalPaths - The optional map of keys for maximum paths to traverse.
  111. * Nested objects beyond that path will be ignored. This is useful for
  112. * keys with variable object values.
  113. * @param root - The path so far.
  114. * @returns The computed update mask list.
  115. */
  116. export declare function generateUpdateMask(obj: any, terminalPaths?: string[], root?: string): string[];
  117. /**
  118. * Transforms milliseconds to a protobuf Duration type string.
  119. * Returns the duration in seconds with up to nine fractional
  120. * digits, terminated by 's'. Example: "3 seconds 0 nano seconds as 3s,
  121. * 3 seconds 1 nano seconds as 3.000000001s".
  122. *
  123. * @param milliseconds - The duration in milliseconds.
  124. * @returns The resulting formatted string in seconds with up to nine fractional
  125. * digits, terminated by 's'.
  126. */
  127. export declare function transformMillisecondsToSecondsString(milliseconds: number): string;
  128. /**
  129. * Internal type to represent a resource name
  130. */
  131. export type ParsedResource = {
  132. projectId?: string;
  133. locationId?: string;
  134. resourceId: string;
  135. };
  136. /**
  137. * Parses the top level resources of a given resource name.
  138. * Supports both full and partial resources names, example:
  139. * `locations/{location}/functions/{functionName}`,
  140. * `projects/{project}/locations/{location}/functions/{functionName}`, or {functionName}
  141. * Does not support deeply nested resource names.
  142. *
  143. * @param resourceName - The resource name string.
  144. * @param resourceIdKey - The key of the resource name to be parsed.
  145. * @returns A parsed resource name object.
  146. */
  147. export declare function parseResourceName(resourceName: string, resourceIdKey: string): ParsedResource;