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