|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | import {Bucket} from '@google-cloud/storage'; |
| 18 | +import * as _rtdb from '@firebase/database'; |
18 | 19 | import * as _firestore from '@google-cloud/firestore'; |
19 | 20 |
|
20 | 21 | declare namespace admin { |
@@ -67,7 +68,7 @@ declare namespace admin.app { |
67 | 68 | options: admin.AppOptions; |
68 | 69 |
|
69 | 70 | auth(): admin.auth.Auth; |
70 | | - database(): admin.database.Database; |
| 71 | + database(url?: string): admin.database.Database; |
71 | 72 | firestore(): admin.firestore.Firestore; |
72 | 73 | messaging(): admin.messaging.Messaging; |
73 | 74 | storage(): admin.storage.Storage; |
@@ -174,117 +175,6 @@ declare namespace admin.credential { |
174 | 175 | function refreshToken(refreshTokenPathOrObject: string|Object): admin.credential.Credential; |
175 | 176 | } |
176 | 177 |
|
177 | | -declare namespace admin.database { |
178 | | - interface Database { |
179 | | - app: admin.app.App; |
180 | | - |
181 | | - goOffline(): void; |
182 | | - goOnline(): void; |
183 | | - ref(path?: string): admin.database.Reference; |
184 | | - refFromURL(url: string): admin.database.Reference; |
185 | | - } |
186 | | - |
187 | | - interface DataSnapshot { |
188 | | - key: string|null; |
189 | | - ref: admin.database.Reference; |
190 | | - |
191 | | - child(path: string): admin.database.DataSnapshot; |
192 | | - exists(): boolean; |
193 | | - exportVal(): any; |
194 | | - forEach(action: (a: admin.database.DataSnapshot) => boolean): boolean; |
195 | | - getPriority(): string|number|null; |
196 | | - hasChild(path: string): boolean; |
197 | | - hasChildren(): boolean; |
198 | | - numChildren(): number; |
199 | | - toJSON(): Object; |
200 | | - val(): any; |
201 | | - } |
202 | | - |
203 | | - interface OnDisconnect { |
204 | | - cancel(onComplete?: (a: Error|null) => any): Promise<void>; |
205 | | - remove(onComplete?: (a: Error|null) => any): Promise<void>; |
206 | | - set(value: any, onComplete?: (a: Error|null) => any): Promise<void>; |
207 | | - setWithPriority( |
208 | | - value: any, |
209 | | - priority: number|string|null, |
210 | | - onComplete?: (a: Error|null) => any |
211 | | - ): Promise<void>; |
212 | | - update(values: Object, onComplete?: (a: Error|null) => any): Promise<void>; |
213 | | - } |
214 | | - |
215 | | - type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed'; |
216 | | - interface Query { |
217 | | - ref: admin.database.Reference; |
218 | | - |
219 | | - endAt(value: number|string|boolean|null, key?: string): admin.database.Query; |
220 | | - equalTo(value: number|string|boolean|null, key?: string): admin.database.Query; |
221 | | - isEqual(other: admin.database.Query|null): boolean; |
222 | | - limitToFirst(limit: number): admin.database.Query; |
223 | | - limitToLast(limit: number): admin.database.Query; |
224 | | - off( |
225 | | - eventType?: admin.database.EventType, |
226 | | - callback?: (a: admin.database.DataSnapshot, b?: string|null) => any, |
227 | | - context?: Object|null |
228 | | - ): void; |
229 | | - on( |
230 | | - eventType: admin.database.EventType, |
231 | | - callback: (a: admin.database.DataSnapshot|null, b?: string) => any, |
232 | | - cancelCallbackOrContext?: Object|null, |
233 | | - context?: Object|null |
234 | | - ): (a: admin.database.DataSnapshot|null, b?: string) => any; |
235 | | - once( |
236 | | - eventType: admin.database.EventType, |
237 | | - successCallback?: (a: admin.database.DataSnapshot, b?: string) => any, |
238 | | - failureCallbackOrContext?: Object|null, |
239 | | - context?: Object|null |
240 | | - ): Promise<any>; |
241 | | - orderByChild(path: string): admin.database.Query; |
242 | | - orderByKey(): admin.database.Query; |
243 | | - orderByPriority(): admin.database.Query; |
244 | | - orderByValue(): admin.database.Query; |
245 | | - startAt(value: number|string|boolean|null, key?: string): admin.database.Query; |
246 | | - toJSON(): Object; |
247 | | - toString(): string; |
248 | | - } |
249 | | - |
250 | | - interface Reference extends admin.database.Query { |
251 | | - key: string|null; |
252 | | - parent: admin.database.Reference|null; |
253 | | - root: admin.database.Reference; |
254 | | - |
255 | | - child(path: string): admin.database.Reference; |
256 | | - onDisconnect(): admin.database.OnDisconnect; |
257 | | - push(value?: any, onComplete?: (a: Error|null) => any): admin.database.ThenableReference; |
258 | | - remove(onComplete?: (a: Error|null) => any): Promise<void>; |
259 | | - set(value: any, onComplete?: (a: Error|null) => any): Promise<void>; |
260 | | - setPriority( |
261 | | - priority: string|number|null, |
262 | | - onComplete: (a: Error|null) => any |
263 | | - ): Promise<void>; |
264 | | - setWithPriority( |
265 | | - newVal: any, newPriority: string|number|null, |
266 | | - onComplete?: (a: Error|null) => any |
267 | | - ): Promise<void>; |
268 | | - transaction( |
269 | | - transactionUpdate: (a: any) => any, |
270 | | - onComplete?: (a: Error|null, b: boolean, c: admin.database.DataSnapshot|null) => any, |
271 | | - applyLocally?: boolean |
272 | | - ): Promise<{ |
273 | | - committed: boolean, |
274 | | - snapshot: admin.database.DataSnapshot|null |
275 | | - }>; |
276 | | - update(values: Object, onComplete?: (a: Error|null) => any): Promise<void>; |
277 | | - } |
278 | | - |
279 | | - interface ThenableReference extends admin.database.Reference, Promise<any> {} |
280 | | - |
281 | | - function enableLogging(logger?: boolean|((message: string) => any), persistent?: boolean): any; |
282 | | -} |
283 | | - |
284 | | -declare namespace admin.database.ServerValue { |
285 | | - var TIMESTAMP: number; |
286 | | -} |
287 | | - |
288 | 178 | declare namespace admin.messaging { |
289 | 179 | type DataMessagePayload = { |
290 | 180 | [key: string]: string; |
@@ -405,6 +295,16 @@ declare namespace admin.storage { |
405 | 295 | } |
406 | 296 | } |
407 | 297 |
|
| 298 | +declare namespace admin.database { |
| 299 | + export import Database = _rtdb.Database; |
| 300 | + export import Reference = _rtdb.Reference; |
| 301 | + export import Query = _rtdb.Query; |
| 302 | + export import ServerValue = _rtdb.ServerValue; |
| 303 | + export import enableLogging = _rtdb.enableLogging; |
| 304 | + export import OnDisconnect = _rtdb.OnDisconnect; |
| 305 | + export import DataSnapshot = _rtdb.DataSnapshot; |
| 306 | +} |
| 307 | + |
408 | 308 | declare namespace admin.firestore { |
409 | 309 | export import FieldPath = _firestore.FieldPath; |
410 | 310 | export import FieldValue = _firestore.FieldValue; |
|
0 commit comments