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