-
Notifications
You must be signed in to change notification settings - Fork 387
/
Copy pathcore.ts
218 lines (195 loc) · 6.53 KB
/
core.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
/*!
* @license
* Copyright 2021 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Agent } from 'http';
import { Credential } from './credential';
import { RetryConfig } from '.'
/**
* Available options to pass to {@link firebase-admin.app#initializeApp}.
*/
export interface AppOptions {
/**
* A {@link firebase-admin.app#Credential} object used to
* authenticate the Admin SDK.
*
* See {@link https://firebase.google.com/docs/admin/setup#initialize_the_sdk | Initialize the SDK}
* for detailed documentation and code samples.
*/
credential?: Credential;
/**
* The object to use as the {@link https://firebase.google.com/docs/reference/security/database/#auth | auth}
* variable in your Realtime Database Rules when the Admin SDK reads from or
* writes to the Realtime Database. This allows you to downscope the Admin SDK
* from its default full read and write privileges.
*
* You can pass `null` to act as an unauthenticated client.
*
* See
* {@link https://firebase.google.com/docs/database/admin/start#authenticate-with-limited-privileges |
* Authenticate with limited privileges}
* for detailed documentation and code samples.
*/
databaseAuthVariableOverride?: object | null;
/**
* The URL of the Realtime Database from which to read and write data.
*/
databaseURL?: string;
/**
* The ID of the service account to be used for signing custom tokens. This
* can be found in the `client_email` field of a service account JSON file.
*/
serviceAccountId?: string;
/**
* The name of the Google Cloud Storage bucket used for storing application data.
* Use only the bucket name without any prefixes or additions (do *not* prefix
* the name with "gs://").
*/
storageBucket?: string;
/**
* The ID of the Google Cloud project associated with the App.
*/
projectId?: string;
/**
* An {@link https://nodejs.org/api/http.html#http_class_http_agent | HTTP Agent}
* to be used when making outgoing HTTP calls. This Agent instance is used
* by all services that make REST calls (e.g. `auth`, `messaging`,
* `projectManagement`).
*
* Realtime Database and Firestore use other means of communicating with
* the backend servers, so they do not use this HTTP Agent. `Credential`
* instances also do not use this HTTP Agent, but instead support
* specifying an HTTP Agent in the corresponding factory methods.
*/
httpAgent?: Agent;
/**
* The retry configuration that will be used in HttpClient for API Requests.
*/
retryConfig?: RetryConfig;
/**
* Completely disable the retry strategy in HttpClient.
*/
disableRetry?: boolean;
}
/**
* A Firebase app holds the initialization information for a collection of
* services.
*/
export interface App {
/**
* The (read-only) name for this app.
*
* The default app's name is `"[DEFAULT]"`.
*
* @example
* ```javascript
* // The default app's name is "[DEFAULT]"
* initializeApp(defaultAppConfig);
* console.log(admin.app().name); // "[DEFAULT]"
* ```
*
* @example
* ```javascript
* // A named app's name is what you provide to initializeApp()
* const otherApp = initializeApp(otherAppConfig, "other");
* console.log(otherApp.name); // "other"
* ```
*/
name: string;
/**
* The (read-only) configuration options for this app. These are the original
* parameters given in {@link firebase-admin.app#initializeApp}.
*
* @example
* ```javascript
* const app = initializeApp(config);
* console.log(app.options.credential === config.credential); // true
* console.log(app.options.databaseURL === config.databaseURL); // true
* ```
*/
options: AppOptions;
}
/**
* `FirebaseError` is a subclass of the standard JavaScript `Error` object. In
* addition to a message string and stack trace, it contains a string code.
*/
export interface FirebaseError {
/**
* Error codes are strings using the following format: `"service/string-code"`.
* Some examples include `"auth/invalid-uid"` and
* `"messaging/invalid-recipient"`.
*
* While the message for a given error can change, the code will remain the same
* between backward-compatible versions of the Firebase SDK.
*/
code: string;
/**
* An explanatory message for the error that just occurred.
*
* This message is designed to be helpful to you, the developer. Because
* it generally does not convey meaningful information to end users,
* this message should not be displayed in your application.
*/
message: string;
/**
* A string value containing the execution backtrace when the error originally
* occurred.
*
* This information can be useful for troubleshooting the cause of the error with
* {@link https://firebase.google.com/support | Firebase Support}.
*/
stack?: string;
/**
* Returns a JSON-serializable object representation of this error.
*
* @returns A JSON-serializable representation of this object.
*/
toJSON(): object;
}
/**
* Composite type which includes both a `FirebaseError` object and an index
* which can be used to get the errored item.
*
* @example
* ```javascript
* var registrationTokens = [token1, token2, token3];
* admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
* .then(function(response) {
* if (response.failureCount > 0) {
* console.log("Following devices unsucessfully subscribed to topic:");
* response.errors.forEach(function(error) {
* var invalidToken = registrationTokens[error.index];
* console.log(invalidToken, error.error);
* });
* } else {
* console.log("All devices successfully subscribed to topic:", response);
* }
* })
* .catch(function(error) {
* console.log("Error subscribing to topic:", error);
* });
*```
*/
export interface FirebaseArrayIndexError {
/**
* The index of the errored item within the original array passed as part of the
* called API method.
*/
index: number;
/**
* The error object.
*/
error: FirebaseError;
}