1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | export interface HttpsCallableResult {
|
22 | readonly data: any;
|
23 | }
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | export interface HttpsCallable {
|
30 | (data?: {} | null): Promise<HttpsCallableResult>;
|
31 | }
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export interface HttpsCallableOptions {
|
37 | timeout?: number;
|
38 | }
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | export class FirebaseFunctions {
|
45 | private constructor();
|
46 |
|
47 | /**
|
48 | * Gets an `HttpsCallable` instance that refers to the function with the given
|
49 | * name.
|
50 | *
|
51 | * @param name The name of the https callable function.
|
52 | * @return The `HttpsCallable` instance.
|
53 | */
|
54 | httpsCallable(name: string, options?: HttpsCallableOptions): HttpsCallable;
|
55 |
|
56 | /**
|
57 | * Modify this instance to communicate with the Cloud Functions emulator.
|
58 | *
|
59 | * Note: this must be called before this instance has been used to do any operations.
|
60 | *
|
61 | * @param host The emulator host (ex: localhost)
|
62 | * @param port The emulator port (ex: 5001)
|
63 | */
|
64 | useEmulator(host: string, port: number): void;
|
65 |
|
66 | /**
|
67 | * Changes this instance to point to a Cloud Functions emulator running
|
68 | * locally. See https://firebase.google.com/docs/functions/local-emulator
|
69 | *
|
70 | * @deprecated Prefer the useEmulator(host, port) method.
|
71 | * @param origin The origin of the local emulator, such as
|
72 | * "http://localhost:5005".
|
73 | */
|
74 | useFunctionsEmulator(origin: string): void;
|
75 | }
|
76 |
|
77 | /**
|
78 | * The set of Firebase Functions status codes. The codes are the same at the
|
79 | * ones exposed by gRPC here:
|
80 | * https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
|
81 | *
|
82 | * Possible values:
|
83 | * - 'cancelled': The operation was cancelled (typically by the caller).
|
84 | * - 'unknown': Unknown error or an error from a different error domain.
|
85 | * - 'invalid-argument': Client specified an invalid argument. Note that this
|
86 | * differs from 'failed-precondition'. 'invalid-argument' indicates
|
87 | * arguments that are problematic regardless of the state of the system
|
88 | * (e.g. an invalid field name).
|
89 | * - 'deadline-exceeded': Deadline expired before operation could complete.
|
90 | * For operations that change the state of the system, this error may be
|
91 | * returned even if the operation has completed successfully. For example,
|
92 | * a successful response from a server could have been delayed long enough
|
93 | * for the deadline to expire.
|
94 | * - 'not-found': Some requested document was not found.
|
95 | * - 'already-exists': Some document that we attempted to create already
|
96 | * exists.
|
97 | * - 'permission-denied': The caller does not have permission to execute the
|
98 | * specified operation.
|
99 | * - 'resource-exhausted': Some resource has been exhausted, perhaps a
|
100 | * per-user quota, or perhaps the entire file system is out of space.
|
101 | * - 'failed-precondition': Operation was rejected because the system is not
|
102 | * in a state required for the operation's execution.
|
103 | * - 'aborted': The operation was aborted, typically due to a concurrency
|
104 | * issue like transaction aborts, etc.
|
105 | * - 'out-of-range': Operation was attempted past the valid range.
|
106 | * - 'unimplemented': Operation is not implemented or not supported/enabled.
|
107 | * - 'internal': Internal errors. Means some invariants expected by
|
108 | * underlying system has been broken. If you see one of these errors,
|
109 | * something is very broken.
|
110 | * - 'unavailable': The service is currently unavailable. This is most likely
|
111 | * a transient condition and may be corrected by retrying with a backoff.
|
112 | * - 'data-loss': Unrecoverable data loss or corruption.
|
113 | * - 'unauthenticated': The request does not have valid authentication
|
114 | * credentials for the operation.
|
115 | */
|
116 | export type FunctionsErrorCode =
|
117 | | 'ok'
|
118 | | 'cancelled'
|
119 | | 'unknown'
|
120 | | 'invalid-argument'
|
121 | | 'deadline-exceeded'
|
122 | | 'not-found'
|
123 | | 'already-exists'
|
124 | | 'permission-denied'
|
125 | | 'resource-exhausted'
|
126 | | 'failed-precondition'
|
127 | | 'aborted'
|
128 | | 'out-of-range'
|
129 | | 'unimplemented'
|
130 | | 'internal'
|
131 | | 'unavailable'
|
132 | | 'data-loss'
|
133 | | 'unauthenticated';
|
134 |
|
135 | export interface HttpsError extends Error {
|
136 | |
137 |
|
138 |
|
139 |
|
140 | readonly code: FunctionsErrorCode;
|
141 |
|
142 | |
143 |
|
144 |
|
145 | readonly details?: any;
|
146 | }
|
147 |
|
148 | declare module '@firebase/component' {
|
149 | interface NameServiceMapping {
|
150 | 'functions-compat': FirebaseFunctions;
|
151 | }
|
152 | }
|