@react-native-firebase/database 24.1.1 → 25.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/module/DatabaseDataSnapshot.js +144 -0
  3. package/dist/module/DatabaseDataSnapshot.js.map +1 -0
  4. package/dist/module/DatabaseOnDisconnect.js +84 -0
  5. package/dist/module/DatabaseOnDisconnect.js.map +1 -0
  6. package/dist/module/DatabaseQuery.js +298 -0
  7. package/dist/module/DatabaseQuery.js.map +1 -0
  8. package/{lib → dist/module}/DatabaseQueryModifiers.js +49 -98
  9. package/dist/module/DatabaseQueryModifiers.js.map +1 -0
  10. package/dist/module/DatabaseReference.js +169 -0
  11. package/dist/module/DatabaseReference.js.map +1 -0
  12. package/dist/module/DatabaseStatics.js +35 -0
  13. package/dist/module/DatabaseStatics.js.map +1 -0
  14. package/{lib → dist/module}/DatabaseSyncTree.js +74 -156
  15. package/dist/module/DatabaseSyncTree.js.map +1 -0
  16. package/{lib → dist/module}/DatabaseThenableReference.js +12 -12
  17. package/dist/module/DatabaseThenableReference.js.map +1 -0
  18. package/{lib → dist/module}/DatabaseTransaction.js +26 -89
  19. package/dist/module/DatabaseTransaction.js.map +1 -0
  20. package/dist/module/index.js +27 -0
  21. package/dist/module/index.js.map +1 -0
  22. package/dist/module/modular/query.js +138 -0
  23. package/dist/module/modular/query.js.map +1 -0
  24. package/dist/module/modular/transaction.js +24 -0
  25. package/dist/module/modular/transaction.js.map +1 -0
  26. package/dist/module/modular.js +76 -0
  27. package/dist/module/modular.js.map +1 -0
  28. package/dist/module/namespaced.js +147 -0
  29. package/dist/module/namespaced.js.map +1 -0
  30. package/dist/module/package.json +1 -0
  31. package/dist/module/types/database.js +21 -0
  32. package/dist/module/types/database.js.map +1 -0
  33. package/dist/module/types/internal.js +4 -0
  34. package/dist/module/types/internal.js.map +1 -0
  35. package/dist/module/types/namespaced.js +67 -0
  36. package/dist/module/types/namespaced.js.map +1 -0
  37. package/dist/module/version.js +5 -0
  38. package/dist/module/version.js.map +1 -0
  39. package/dist/module/web/RNFBDatabaseModule.android.js +6 -0
  40. package/dist/module/web/RNFBDatabaseModule.android.js.map +1 -0
  41. package/dist/module/web/RNFBDatabaseModule.ios.js +6 -0
  42. package/dist/module/web/RNFBDatabaseModule.ios.js.map +1 -0
  43. package/dist/module/web/RNFBDatabaseModule.js +375 -0
  44. package/dist/module/web/RNFBDatabaseModule.js.map +1 -0
  45. package/{lib → dist/module}/web/query.js +19 -24
  46. package/dist/module/web/query.js.map +1 -0
  47. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts +20 -0
  48. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts.map +1 -0
  49. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts +19 -0
  50. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts.map +1 -0
  51. package/dist/typescript/lib/DatabaseQuery.d.ts +32 -0
  52. package/dist/typescript/lib/DatabaseQuery.d.ts.map +1 -0
  53. package/dist/typescript/lib/DatabaseQueryModifiers.d.ts +55 -0
  54. package/dist/typescript/lib/DatabaseQueryModifiers.d.ts.map +1 -0
  55. package/dist/typescript/lib/DatabaseReference.d.ts +21 -0
  56. package/dist/typescript/lib/DatabaseReference.d.ts.map +1 -0
  57. package/dist/typescript/lib/DatabaseStatics.d.ts +10 -0
  58. package/dist/typescript/lib/DatabaseStatics.d.ts.map +1 -0
  59. package/dist/typescript/lib/DatabaseSyncTree.d.ts +72 -0
  60. package/dist/typescript/lib/DatabaseSyncTree.d.ts.map +1 -0
  61. package/dist/typescript/lib/DatabaseThenableReference.d.ts +13 -0
  62. package/dist/typescript/lib/DatabaseThenableReference.d.ts.map +1 -0
  63. package/dist/typescript/lib/DatabaseTransaction.d.ts +15 -0
  64. package/dist/typescript/lib/DatabaseTransaction.d.ts.map +1 -0
  65. package/dist/typescript/lib/index.d.ts +6 -0
  66. package/dist/typescript/lib/index.d.ts.map +1 -0
  67. package/dist/typescript/lib/modular/query.d.ts +41 -0
  68. package/dist/typescript/lib/modular/query.d.ts.map +1 -0
  69. package/dist/typescript/lib/modular/transaction.d.ts +3 -0
  70. package/dist/typescript/lib/modular/transaction.d.ts.map +1 -0
  71. package/dist/typescript/lib/modular.d.ts +24 -0
  72. package/dist/typescript/lib/modular.d.ts.map +1 -0
  73. package/dist/typescript/lib/namespaced.d.ts +13 -0
  74. package/dist/typescript/lib/namespaced.d.ts.map +1 -0
  75. package/dist/typescript/lib/types/database.d.ts +93 -0
  76. package/dist/typescript/lib/types/database.d.ts.map +1 -0
  77. package/dist/typescript/lib/types/internal.d.ts +189 -0
  78. package/dist/typescript/lib/types/internal.d.ts.map +1 -0
  79. package/dist/typescript/lib/types/namespaced.d.ts +1230 -0
  80. package/dist/typescript/lib/types/namespaced.d.ts.map +1 -0
  81. package/dist/typescript/lib/version.d.ts +2 -0
  82. package/dist/typescript/lib/version.d.ts.map +1 -0
  83. package/dist/typescript/lib/web/RNFBDatabaseModule.android.d.ts +3 -0
  84. package/dist/typescript/lib/web/RNFBDatabaseModule.android.d.ts.map +1 -0
  85. package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts +3 -0
  86. package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts.map +1 -0
  87. package/dist/typescript/lib/web/RNFBDatabaseModule.ios.d.ts +3 -0
  88. package/dist/typescript/lib/web/RNFBDatabaseModule.ios.d.ts.map +1 -0
  89. package/dist/typescript/lib/web/query.d.ts +13 -0
  90. package/dist/typescript/lib/web/query.d.ts.map +1 -0
  91. package/dist/typescript/package.json +1 -0
  92. package/lib/{DatabaseDataSnapshot.js → DatabaseDataSnapshot.ts} +62 -88
  93. package/lib/{DatabaseOnDisconnect.js → DatabaseOnDisconnect.ts} +25 -23
  94. package/lib/{DatabaseQuery.js → DatabaseQuery.ts} +130 -144
  95. package/lib/DatabaseQueryModifiers.ts +283 -0
  96. package/lib/{DatabaseReference.js → DatabaseReference.ts} +103 -85
  97. package/lib/{DatabaseStatics.js → DatabaseStatics.ts} +4 -2
  98. package/lib/DatabaseSyncTree.ts +390 -0
  99. package/lib/DatabaseThenableReference.ts +73 -0
  100. package/lib/DatabaseTransaction.ts +172 -0
  101. package/lib/index.ts +25 -0
  102. package/lib/modular/query.ts +410 -0
  103. package/lib/modular/transaction.ts +34 -0
  104. package/lib/modular.ts +134 -0
  105. package/lib/{index.js → namespaced.ts} +91 -90
  106. package/lib/types/database.ts +144 -0
  107. package/lib/types/internal.ts +317 -0
  108. package/lib/{index.d.ts → types/namespaced.ts} +48 -9
  109. package/lib/version.ts +2 -0
  110. package/lib/web/RNFBDatabaseModule.android.ts +4 -0
  111. package/lib/web/RNFBDatabaseModule.ios.ts +4 -0
  112. package/lib/web/RNFBDatabaseModule.ts +534 -0
  113. package/lib/web/query.ts +97 -0
  114. package/package.json +42 -7
  115. package/tsconfig.json +21 -0
  116. package/typedoc.json +3 -3
  117. package/lib/modular/index.d.ts +0 -246
  118. package/lib/modular/index.js +0 -134
  119. package/lib/modular/query.d.ts +0 -972
  120. package/lib/modular/query.js +0 -305
  121. package/lib/modular/transaction.d.ts +0 -54
  122. package/lib/modular/transaction.js +0 -24
  123. package/lib/version.js +0 -2
  124. package/lib/web/RNFBDatabaseModule.android.js +0 -2
  125. package/lib/web/RNFBDatabaseModule.ios.js +0 -2
  126. package/lib/web/RNFBDatabaseModule.js +0 -558
@@ -21,71 +21,85 @@ import {
21
21
  isNumber,
22
22
  isString,
23
23
  MODULAR_DEPRECATION_ARG,
24
+ createDeprecationProxy,
24
25
  } from '@react-native-firebase/app/dist/module/common';
25
26
  import {
26
27
  createModuleNamespace,
27
28
  FirebaseModule,
28
29
  getFirebaseRoot,
30
+ type ModuleConfig,
29
31
  } from '@react-native-firebase/app/dist/module/internal';
30
32
  import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
33
+ import type { ReactNativeFirebase } from '@react-native-firebase/app';
34
+ import type {
35
+ DatabaseInternal,
36
+ DatabaseReferenceInternal,
37
+ DatabaseTransactionInternal,
38
+ RNFBDatabaseModule,
39
+ } from './types/internal';
40
+ import type { FirebaseDatabaseTypes } from './types/namespaced';
41
+ import './types/internal';
31
42
  import DatabaseReference from './DatabaseReference';
32
43
  import DatabaseStatics from './DatabaseStatics';
33
44
  import DatabaseTransaction from './DatabaseTransaction';
34
- import version from './version';
45
+ import { version } from './version';
35
46
  import fallBackModule from './web/RNFBDatabaseModule';
36
47
 
37
- import { createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
38
-
39
48
  const namespace = 'database';
40
49
 
41
- const nativeModuleName = [
42
- 'RNFBDatabaseModule',
50
+ const nativeModuleName = 'RNFBDatabaseModule';
51
+
52
+ const nativeModuleNames = [
53
+ nativeModuleName,
43
54
  'RNFBDatabaseReferenceModule',
44
55
  'RNFBDatabaseQueryModule',
45
56
  'RNFBDatabaseOnDisconnectModule',
46
57
  'RNFBDatabaseTransactionModule',
47
- ];
58
+ ] as const;
59
+
60
+ function ap(reference: DatabaseReference): DatabaseReferenceInternal {
61
+ return reference as DatabaseReferenceInternal;
62
+ }
63
+
64
+ class FirebaseDatabaseModule extends FirebaseModule<typeof nativeModuleName> {
65
+ readonly type = 'database' as const;
66
+ _serverTimeOffset: number;
67
+ _customUrlOrRegion: string | null;
68
+ _transaction: DatabaseTransactionInternal;
48
69
 
49
- class FirebaseDatabaseModule extends FirebaseModule {
50
- constructor(app, config, databaseUrl) {
70
+ private get nativeModule(): RNFBDatabaseModule {
71
+ return this.native as RNFBDatabaseModule;
72
+ }
73
+
74
+ constructor(
75
+ app: ReactNativeFirebase.FirebaseAppBase,
76
+ config: ModuleConfig,
77
+ databaseUrl?: string | null,
78
+ ) {
51
79
  super(app, config, databaseUrl);
52
80
  this._serverTimeOffset = 0;
53
- this._customUrlOrRegion = databaseUrl || this.app.options.databaseURL;
54
- this._transaction = new DatabaseTransaction(this);
81
+ this._customUrlOrRegion = databaseUrl || this.app.options.databaseURL || null;
82
+ this._transaction = new DatabaseTransaction(this as unknown as DatabaseInternal);
55
83
  setTimeout(() => {
56
84
  this._syncServerTimeOffset();
57
85
  }, 100);
58
86
  }
59
87
 
60
- /**
61
- * Keep the server time offset in sync with the server time
62
- * @private
63
- */
64
- _syncServerTimeOffset() {
65
- this.ref('.info/serverTimeOffset').on(
88
+ _syncServerTimeOffset(): void {
89
+ ap(this.ref('.info/serverTimeOffset')).on(
66
90
  'value',
67
- snapshot => {
91
+ (snapshot: { val(): number }) => {
68
92
  this._serverTimeOffset = snapshot.val();
69
93
  },
70
94
  MODULAR_DEPRECATION_ARG,
71
95
  );
72
96
  }
73
97
 
74
- /**
75
- *
76
- * @returns {Date}
77
- * @private
78
- */
79
- getServerTime() {
98
+ getServerTime(): Date {
80
99
  return new Date(Date.now() + this._serverTimeOffset);
81
100
  }
82
101
 
83
- /**
84
- * Returns a new Reference instance from a given path. Defaults to the root reference.
85
- * @param path
86
- * @returns {DatabaseReference}
87
- */
88
- ref(path = '/') {
102
+ ref(path = '/'): DatabaseReference {
89
103
  if (!isString(path)) {
90
104
  throw new Error("firebase.app().database().ref(*) 'path' must be a string value.");
91
105
  }
@@ -99,27 +113,20 @@ class FirebaseDatabaseModule extends FirebaseModule {
99
113
  return createDeprecationProxy(new DatabaseReference(this, path));
100
114
  }
101
115
 
102
- /**
103
- * Generates a Reference from a database URL.
104
- * Note domain must be the same.
105
- * Any query parameters are stripped as per the web SDK.
106
- * @param url
107
- * @returns {DatabaseReference}
108
- */
109
- refFromURL(url) {
116
+ refFromURL(url: string): DatabaseReference {
110
117
  if (!isString(url) || !url.startsWith('https://')) {
111
118
  throw new Error(
112
119
  "firebase.app().database().refFromURL(*) 'url' must be a valid database URL.",
113
120
  );
114
121
  }
115
122
 
116
- if (!url.includes(this._customUrlOrRegion)) {
123
+ if (!url.includes(this._customUrlOrRegion as string)) {
117
124
  throw new Error(
118
125
  `firebase.app().database().refFromURL(*) 'url' must be the same domain as the current instance (${this._customUrlOrRegion}). To use a different database domain, create a new Firebase instance.`,
119
126
  );
120
127
  }
121
128
 
122
- let path = url.replace(this._customUrlOrRegion, '');
129
+ let path = url.replace(this._customUrlOrRegion as string, '');
123
130
  if (path.includes('?')) {
124
131
  path = path.slice(0, path.indexOf('?'));
125
132
  }
@@ -127,53 +134,35 @@ class FirebaseDatabaseModule extends FirebaseModule {
127
134
  return createDeprecationProxy(new DatabaseReference(this, path || '/'));
128
135
  }
129
136
 
130
- /**
131
- * goOnline
132
- */
133
- goOnline() {
134
- return this.native.goOnline();
137
+ goOnline(): Promise<void> {
138
+ return this.nativeModule.goOnline();
135
139
  }
136
140
 
137
- /**
138
- * goOffline
139
- */
140
- goOffline() {
141
- return this.native.goOffline();
141
+ goOffline(): Promise<void> {
142
+ return this.nativeModule.goOffline();
142
143
  }
143
144
 
144
- /**
145
- *
146
- * @param enabled
147
- */
148
- setPersistenceEnabled(enabled) {
145
+ setPersistenceEnabled(enabled: boolean): Promise<void> {
149
146
  if (!isBoolean(enabled)) {
150
147
  throw new Error(
151
148
  "firebase.app().database().setPersistenceEnabled(*) 'enabled' must be a boolean value.",
152
149
  );
153
150
  }
154
151
 
155
- return this.native.setPersistenceEnabled(enabled);
152
+ return this.nativeModule.setPersistenceEnabled(enabled);
156
153
  }
157
154
 
158
- /**
159
- *
160
- * @param enabled
161
- */
162
- setLoggingEnabled(enabled) {
155
+ setLoggingEnabled(enabled: boolean): Promise<void> {
163
156
  if (!isBoolean(enabled)) {
164
157
  throw new Error(
165
158
  "firebase.app().database().setLoggingEnabled(*) 'enabled' must be a boolean value.",
166
159
  );
167
160
  }
168
161
 
169
- return this.native.setLoggingEnabled(enabled);
162
+ return this.nativeModule.setLoggingEnabled(enabled);
170
163
  }
171
164
 
172
- /**
173
- *
174
- * @param bytes
175
- */
176
- setPersistenceCacheSizeBytes(bytes) {
165
+ setPersistenceCacheSizeBytes(bytes: number): Promise<void> {
177
166
  if (!isNumber(bytes)) {
178
167
  throw new Error(
179
168
  "firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be a number value.",
@@ -192,61 +181,73 @@ class FirebaseDatabaseModule extends FirebaseModule {
192
181
  );
193
182
  }
194
183
 
195
- return this.native.setPersistenceCacheSizeBytes(bytes);
184
+ return this.nativeModule.setPersistenceCacheSizeBytes(bytes);
196
185
  }
197
186
 
198
- useEmulator(host, port) {
187
+ useEmulator(host: string, port: number): [string, number] {
199
188
  if (!host || !isString(host) || !port || !isNumber(port)) {
200
189
  throw new Error('firebase.database().useEmulator() takes a non-empty host and port');
201
190
  }
202
- let _host = host;
191
+ let remappedHost = host;
203
192
  const androidBypassEmulatorUrlRemap =
204
193
  typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' &&
205
194
  this.firebaseJson.android_bypass_emulator_url_remap;
206
- if (!androidBypassEmulatorUrlRemap && isAndroid && _host) {
207
- if (_host.startsWith('localhost')) {
208
- _host = _host.replace('localhost', '10.0.2.2');
195
+ if (!androidBypassEmulatorUrlRemap && isAndroid && remappedHost) {
196
+ if (remappedHost.startsWith('localhost')) {
197
+ remappedHost = remappedHost.replace('localhost', '10.0.2.2');
209
198
  // eslint-disable-next-line no-console
210
199
  console.log(
211
200
  'Mapping database host "localhost" to "10.0.2.2" for android emulators. Use real IP on real devices. You can bypass this behaviour with "android_bypass_emulator_url_remap" flag.',
212
201
  );
213
202
  }
214
- if (_host.startsWith('127.0.0.1')) {
215
- _host = _host.replace('127.0.0.1', '10.0.2.2');
203
+ if (remappedHost.startsWith('127.0.0.1')) {
204
+ remappedHost = remappedHost.replace('127.0.0.1', '10.0.2.2');
216
205
  // eslint-disable-next-line no-console
217
206
  console.log(
218
207
  'Mapping database host "127.0.0.1" to "10.0.2.2" for android emulators. Use real IP on real devices. You can bypass this behaviour with "android_bypass_emulator_url_remap" flag.',
219
208
  );
220
209
  }
221
210
  }
222
- this.native.useEmulator(_host, port);
223
- return [_host, port]; // undocumented return, just used to unit test android host remapping
211
+ this.nativeModule.useEmulator(remappedHost, port);
212
+ return [remappedHost, port];
224
213
  }
225
214
  }
226
215
 
227
- // import { SDK_VERSION } from '@react-native-firebase/database';
228
216
  export const SDK_VERSION = version;
229
217
 
230
- // import database from '@react-native-firebase/database';
231
- // database().X(...);
232
- export default createModuleNamespace({
218
+ const databaseNamespace = createModuleNamespace({
233
219
  statics: DatabaseStatics,
234
220
  version,
235
221
  namespace,
236
- nativeModuleName,
222
+ nativeModuleName: [...nativeModuleNames],
237
223
  nativeEvents: ['database_transaction_event', 'database_sync_event'],
238
224
  hasMultiAppSupport: true,
239
225
  hasCustomUrlOrRegionSupport: true,
240
226
  ModuleClass: FirebaseDatabaseModule,
241
227
  });
242
228
 
243
- export * from './modular';
244
-
245
- // import database, { firebase } from '@react-native-firebase/database';
246
- // database().X(...);
247
- // firebase.database().X(...);
248
- export const firebase = getFirebaseRoot();
249
-
250
- for (let i = 0; i < nativeModuleName.length; i++) {
251
- setReactNativeModule(nativeModuleName[i], fallBackModule);
229
+ type DatabaseNamespace = ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
230
+ FirebaseDatabaseTypes.Module,
231
+ FirebaseDatabaseTypes.Statics
232
+ > & {
233
+ database: ReactNativeFirebase.FirebaseModuleWithStaticsAndApp<
234
+ FirebaseDatabaseTypes.Module,
235
+ FirebaseDatabaseTypes.Statics
236
+ >;
237
+ firebase: ReactNativeFirebase.Module;
238
+ app(name?: string): ReactNativeFirebase.FirebaseApp;
239
+ };
240
+
241
+ export default databaseNamespace as unknown as DatabaseNamespace;
242
+
243
+ export const firebase =
244
+ getFirebaseRoot() as unknown as ReactNativeFirebase.FirebaseNamespacedExport<
245
+ 'database',
246
+ FirebaseDatabaseTypes.Module,
247
+ FirebaseDatabaseTypes.Statics,
248
+ true
249
+ >;
250
+
251
+ for (const moduleName of nativeModuleNames) {
252
+ setReactNativeModule(moduleName, fallBackModule as unknown as Record<string, unknown>);
252
253
  }
@@ -0,0 +1,144 @@
1
+ /*
2
+ * Copyright (c) 2016-present Invertase Limited & Contributors
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this library except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ import type { ReactNativeFirebase } from '@react-native-firebase/app';
19
+
20
+ type FirebaseApp = ReactNativeFirebase.FirebaseApp;
21
+
22
+ type FirebaseSignInProvider =
23
+ | 'custom'
24
+ | 'email'
25
+ | 'password'
26
+ | 'phone'
27
+ | 'anonymous'
28
+ | 'google.com'
29
+ | 'facebook.com'
30
+ | 'github.com'
31
+ | 'twitter.com'
32
+ | 'microsoft.com'
33
+ | 'apple.com';
34
+
35
+ interface FirebaseIdToken {
36
+ iss: string;
37
+ aud: string;
38
+ sub: string;
39
+ iat: number;
40
+ exp: number;
41
+ user_id: string;
42
+ auth_time: number;
43
+ provider_id?: 'anonymous';
44
+ email?: string;
45
+ email_verified?: boolean;
46
+ phone_number?: string;
47
+ name?: string;
48
+ picture?: string;
49
+ firebase: {
50
+ sign_in_provider: FirebaseSignInProvider;
51
+ identities?: { [provider in FirebaseSignInProvider]?: string[] };
52
+ };
53
+ [claim: string]: unknown;
54
+ uid?: never;
55
+ }
56
+
57
+ export type EmulatorMockTokenOptions = ({ user_id: string } | { sub: string }) &
58
+ Partial<FirebaseIdToken>;
59
+
60
+ export declare class Database {
61
+ readonly app: FirebaseApp;
62
+ readonly type: 'database';
63
+ }
64
+
65
+ export declare class TransactionResult {
66
+ readonly committed: boolean;
67
+ readonly snapshot: DataSnapshot;
68
+ toJSON(): object;
69
+ }
70
+
71
+ export interface Query {
72
+ readonly ref: DatabaseReference;
73
+ isEqual(other: Query | null): boolean;
74
+ toJSON(): string;
75
+ toString(): string;
76
+ }
77
+
78
+ export interface DatabaseReference extends Query {
79
+ readonly key: string | null;
80
+ readonly parent: DatabaseReference | null;
81
+ readonly root: DatabaseReference;
82
+ }
83
+
84
+ export interface ThenableReference
85
+ extends DatabaseReference, Pick<Promise<DatabaseReference>, 'then' | 'catch'> {
86
+ key: string;
87
+ parent: DatabaseReference;
88
+ }
89
+
90
+ export type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
91
+
92
+ export interface IteratedDataSnapshot extends DataSnapshot {
93
+ key: string;
94
+ }
95
+
96
+ export declare class DataSnapshot {
97
+ readonly key: string | null;
98
+ readonly priority: string | number | null;
99
+ readonly ref: DatabaseReference;
100
+ readonly size: number;
101
+ child(path: string): DataSnapshot;
102
+ exists(): boolean;
103
+ exportVal(): any;
104
+ forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean;
105
+ hasChild(path: string): boolean;
106
+ hasChildren(): boolean;
107
+ toJSON(): object | null;
108
+ val(): any;
109
+ }
110
+
111
+ export declare class OnDisconnect {
112
+ cancel(): Promise<void>;
113
+ remove(): Promise<void>;
114
+ set(value: unknown): Promise<void>;
115
+ setWithPriority(value: unknown, priority: string | number | null): Promise<void>;
116
+ update(values: object): Promise<void>;
117
+ }
118
+
119
+ export type Unsubscribe = () => void;
120
+
121
+ export interface ListenOptions {
122
+ readonly onlyOnce?: boolean;
123
+ }
124
+
125
+ export type QueryConstraintType =
126
+ | 'endAt'
127
+ | 'endBefore'
128
+ | 'startAt'
129
+ | 'startAfter'
130
+ | 'limitToFirst'
131
+ | 'limitToLast'
132
+ | 'orderByChild'
133
+ | 'orderByKey'
134
+ | 'orderByPriority'
135
+ | 'orderByValue'
136
+ | 'equalTo';
137
+
138
+ export abstract class QueryConstraint {
139
+ abstract readonly type: QueryConstraintType;
140
+ }
141
+
142
+ export interface TransactionOptions {
143
+ readonly applyLocally?: boolean;
144
+ }