Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

functions-public.d.ts 6.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. /**
  2. * Cloud Functions for Firebase
  3. *
  4. * @packageDocumentation
  5. */
  6. import { FirebaseApp } from '@firebase/app';
  7. import { FirebaseError } from '@firebase/util';
  8. /**
  9. * Modify this instance to communicate with the Cloud Functions emulator.
  10. *
  11. * Note: this must be called before this instance has been used to do any operations.
  12. *
  13. * @param host - The emulator host (ex: localhost)
  14. * @param port - The emulator port (ex: 5001)
  15. * @public
  16. */
  17. export declare function connectFunctionsEmulator(functionsInstance: Functions, host: string, port: number): void;
  18. /**
  19. * A `Functions` instance.
  20. * @public
  21. */
  22. export declare interface Functions {
  23. /**
  24. * The {@link @firebase/app#FirebaseApp} this `Functions` instance is associated with.
  25. */
  26. app: FirebaseApp;
  27. /**
  28. * The region the callable Cloud Functions are located in.
  29. * Default is `us-central-1`.
  30. */
  31. region: string;
  32. /**
  33. * A custom domain hosting the callable Cloud Functions.
  34. * ex: https://mydomain.com
  35. */
  36. customDomain: string | null;
  37. }
  38. /**
  39. * An error returned by the Firebase Functions client SDK.
  40. * @public
  41. */
  42. export declare interface FunctionsError extends FirebaseError {
  43. /**
  44. * A standard error code that will be returned to the client. This also
  45. * determines the HTTP status code of the response, as defined in code.proto.
  46. */
  47. readonly code: FunctionsErrorCode;
  48. /**
  49. * Extra data to be converted to JSON and included in the error response.
  50. */
  51. readonly details?: unknown;
  52. }
  53. /**
  54. * The set of Firebase Functions status codes. The codes are the same at the
  55. * ones exposed by gRPC here:
  56. * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
  57. *
  58. * Possible values:
  59. * - 'cancelled': The operation was cancelled (typically by the caller).
  60. * - 'unknown': Unknown error or an error from a different error domain.
  61. * - 'invalid-argument': Client specified an invalid argument. Note that this
  62. * differs from 'failed-precondition'. 'invalid-argument' indicates
  63. * arguments that are problematic regardless of the state of the system
  64. * (e.g. an invalid field name).
  65. * - 'deadline-exceeded': Deadline expired before operation could complete.
  66. * For operations that change the state of the system, this error may be
  67. * returned even if the operation has completed successfully. For example,
  68. * a successful response from a server could have been delayed long enough
  69. * for the deadline to expire.
  70. * - 'not-found': Some requested document was not found.
  71. * - 'already-exists': Some document that we attempted to create already
  72. * exists.
  73. * - 'permission-denied': The caller does not have permission to execute the
  74. * specified operation.
  75. * - 'resource-exhausted': Some resource has been exhausted, perhaps a
  76. * per-user quota, or perhaps the entire file system is out of space.
  77. * - 'failed-precondition': Operation was rejected because the system is not
  78. * in a state required for the operation's execution.
  79. * - 'aborted': The operation was aborted, typically due to a concurrency
  80. * issue like transaction aborts, etc.
  81. * - 'out-of-range': Operation was attempted past the valid range.
  82. * - 'unimplemented': Operation is not implemented or not supported/enabled.
  83. * - 'internal': Internal errors. Means some invariants expected by
  84. * underlying system has been broken. If you see one of these errors,
  85. * something is very broken.
  86. * - 'unavailable': The service is currently unavailable. This is most likely
  87. * a transient condition and may be corrected by retrying with a backoff.
  88. * - 'data-loss': Unrecoverable data loss or corruption.
  89. * - 'unauthenticated': The request does not have valid authentication
  90. * credentials for the operation.
  91. * @public
  92. */
  93. export declare type FunctionsErrorCode = `functions/${FunctionsErrorCodeCore}`;
  94. /**
  95. * Functions error code string appended after "functions/" product prefix.
  96. * See {@link FunctionsErrorCode} for full documentation of codes.
  97. * @public
  98. */
  99. export declare type FunctionsErrorCodeCore = 'ok' | 'cancelled' | 'unknown' | 'invalid-argument' | 'deadline-exceeded' | 'not-found' | 'already-exists' | 'permission-denied' | 'resource-exhausted' | 'failed-precondition' | 'aborted' | 'out-of-range' | 'unimplemented' | 'internal' | 'unavailable' | 'data-loss' | 'unauthenticated';
  100. /**
  101. * Returns a {@link Functions} instance for the given app.
  102. * @param app - The {@link @firebase/app#FirebaseApp} to use.
  103. * @param regionOrCustomDomain - one of:
  104. * a) The region the callable functions are located in (ex: us-central1)
  105. * b) A custom domain hosting the callable functions (ex: https://mydomain.com)
  106. * @public
  107. */
  108. export declare function getFunctions(app?: FirebaseApp, regionOrCustomDomain?: string): Functions;
  109. /**
  110. * A reference to a "callable" HTTP trigger in Google Cloud Functions.
  111. * @param data - Data to be passed to callable function.
  112. * @public
  113. */
  114. export declare type HttpsCallable<RequestData = unknown, ResponseData = unknown> = (data?: RequestData | null) => Promise<HttpsCallableResult<ResponseData>>;
  115. /**
  116. * Returns a reference to the callable HTTPS trigger with the given name.
  117. * @param name - The name of the trigger.
  118. * @public
  119. */
  120. export declare function httpsCallable<RequestData = unknown, ResponseData = unknown>(functionsInstance: Functions, name: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData>;
  121. /**
  122. * Returns a reference to the callable HTTPS trigger with the specified url.
  123. * @param url - The url of the trigger.
  124. * @public
  125. */
  126. export declare function httpsCallableFromURL<RequestData = unknown, ResponseData = unknown>(functionsInstance: Functions, url: string, options?: HttpsCallableOptions): HttpsCallable<RequestData, ResponseData>;
  127. /**
  128. * An interface for metadata about how calls should be executed.
  129. * @public
  130. */
  131. export declare interface HttpsCallableOptions {
  132. /**
  133. * Time in milliseconds after which to cancel if there is no response.
  134. * Default is 70000.
  135. */
  136. timeout?: number;
  137. }
  138. /**
  139. * An `HttpsCallableResult` wraps a single result from a function call.
  140. * @public
  141. */
  142. export declare interface HttpsCallableResult<ResponseData = unknown> {
  143. /**
  144. * Data returned from callable function.
  145. */
  146. readonly data: ResponseData;
  147. }
  148. export { }