@react-native-firebase/database 25.1.0 → 26.1.0

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 (136) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/RNFBDatabase.podspec +20 -7
  3. package/android/build.gradle +19 -0
  4. package/android/src/main/java/io/invertase/firebase/database/UniversalFirebaseDatabaseModule.java +4 -14
  5. package/android/src/reactnative/java/io/invertase/firebase/database/DatabaseTurboModuleSupport.java +56 -0
  6. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseModule.java → NativeRNFBTurboDatabase.java} +16 -36
  7. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseOnDisconnectModule.java → NativeRNFBTurboDatabaseOnDisconnect.java} +19 -14
  8. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseQueryModule.java → NativeRNFBTurboDatabaseQuery.java} +41 -105
  9. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseReferenceModule.java → NativeRNFBTurboDatabaseReference.java} +27 -20
  10. package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseTransactionModule.java → NativeRNFBTurboDatabaseTransaction.java} +41 -19
  11. package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabasePackage.java +5 -5
  12. package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseTransactionHandler.java +11 -0
  13. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseOnDisconnectSpec.java +55 -0
  14. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseQuerySpec.java +52 -0
  15. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseReferenceSpec.java +55 -0
  16. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseSpec.java +57 -0
  17. package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseTransactionSpec.java +42 -0
  18. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/CMakeLists.txt +36 -0
  19. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules-generated.cpp +182 -0
  20. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules.h +63 -0
  21. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
  22. package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI.h +440 -0
  23. package/dist/module/DatabaseDataSnapshot.js +20 -6
  24. package/dist/module/DatabaseDataSnapshot.js.map +1 -1
  25. package/dist/module/DatabaseOnDisconnect.js.map +1 -1
  26. package/dist/module/DatabaseQuery.js +13 -16
  27. package/dist/module/DatabaseQuery.js.map +1 -1
  28. package/dist/module/DatabaseReference.js +16 -15
  29. package/dist/module/DatabaseReference.js.map +1 -1
  30. package/dist/module/DatabaseSyncTree.js +5 -4
  31. package/dist/module/DatabaseSyncTree.js.map +1 -1
  32. package/dist/module/DatabaseThenableReference.js +1 -2
  33. package/dist/module/DatabaseThenableReference.js.map +1 -1
  34. package/dist/module/index.js +210 -5
  35. package/dist/module/index.js.map +1 -1
  36. package/dist/module/modular/query.js +14 -15
  37. package/dist/module/modular/query.js.map +1 -1
  38. package/dist/module/modular/transaction.js +1 -2
  39. package/dist/module/modular/transaction.js.map +1 -1
  40. package/dist/module/version.js +1 -1
  41. package/dist/module/web/RNFBDatabaseModule.js +4 -8
  42. package/dist/module/web/RNFBDatabaseModule.js.map +1 -1
  43. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts +9 -7
  44. package/dist/typescript/lib/DatabaseDataSnapshot.d.ts.map +1 -1
  45. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts +3 -3
  46. package/dist/typescript/lib/DatabaseOnDisconnect.d.ts.map +1 -1
  47. package/dist/typescript/lib/DatabaseQuery.d.ts +18 -18
  48. package/dist/typescript/lib/DatabaseQuery.d.ts.map +1 -1
  49. package/dist/typescript/lib/DatabaseReference.d.ts +8 -8
  50. package/dist/typescript/lib/DatabaseReference.d.ts.map +1 -1
  51. package/dist/typescript/lib/DatabaseSyncTree.d.ts +2 -2
  52. package/dist/typescript/lib/DatabaseSyncTree.d.ts.map +1 -1
  53. package/dist/typescript/lib/DatabaseThenableReference.d.ts +8 -8
  54. package/dist/typescript/lib/DatabaseThenableReference.d.ts.map +1 -1
  55. package/dist/typescript/lib/index.d.ts +57 -4
  56. package/dist/typescript/lib/index.d.ts.map +1 -1
  57. package/dist/typescript/lib/modular/query.d.ts.map +1 -1
  58. package/dist/typescript/lib/modular/transaction.d.ts.map +1 -1
  59. package/dist/typescript/lib/types/database.d.ts +5 -5
  60. package/dist/typescript/lib/types/database.d.ts.map +1 -1
  61. package/dist/typescript/lib/types/internal.d.ts +32 -31
  62. package/dist/typescript/lib/types/internal.d.ts.map +1 -1
  63. package/dist/typescript/lib/version.d.ts +1 -1
  64. package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts.map +1 -1
  65. package/ios/RNFBDatabase/RNFBDatabaseCommon.h +13 -6
  66. package/ios/RNFBDatabase/RNFBDatabaseCommon.m +2 -10
  67. package/ios/RNFBDatabase/RNFBDatabaseConstants.h +25 -0
  68. package/ios/RNFBDatabase/RNFBDatabaseModule.mm +90 -0
  69. package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.h +39 -0
  70. package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.m +64 -0
  71. package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectHelper.h +59 -0
  72. package/ios/RNFBDatabase/{RNFBDatabaseOnDisconnectModule.m → RNFBDatabaseOnDisconnectHelper.m} +41 -47
  73. package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectModule.mm +121 -0
  74. package/ios/RNFBDatabase/RNFBDatabaseQuery.h +11 -0
  75. package/ios/RNFBDatabase/RNFBDatabaseQueryHelper.h +49 -0
  76. package/ios/RNFBDatabase/{RNFBDatabaseQueryModule.m → RNFBDatabaseQueryHelper.m} +77 -91
  77. package/ios/RNFBDatabase/RNFBDatabaseQueryModule.h +5 -1
  78. package/ios/RNFBDatabase/RNFBDatabaseQueryModule.mm +105 -0
  79. package/ios/RNFBDatabase/RNFBDatabaseQueue.h +29 -0
  80. package/ios/RNFBDatabase/RNFBDatabaseQueue.m +31 -0
  81. package/ios/RNFBDatabase/RNFBDatabaseReferenceHelper.h +59 -0
  82. package/ios/RNFBDatabase/{RNFBDatabaseReferenceModule.m → RNFBDatabaseReferenceHelper.m} +42 -48
  83. package/ios/RNFBDatabase/RNFBDatabaseReferenceModule.mm +125 -0
  84. package/ios/RNFBDatabase/RNFBDatabaseTransactionHelper.h +38 -0
  85. package/ios/RNFBDatabase/{RNFBDatabaseTransactionModule.m → RNFBDatabaseTransactionHelper.m} +52 -51
  86. package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.h +0 -1
  87. package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.mm +86 -0
  88. package/ios/RNFBDatabase.xcodeproj/project.pbxproj +24 -24
  89. package/ios/generated/RCTAppDependencyProvider.h +25 -0
  90. package/ios/generated/RCTAppDependencyProvider.mm +55 -0
  91. package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
  92. package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
  93. package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
  94. package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
  95. package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules-generated.mm +254 -0
  96. package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules.h +264 -0
  97. package/ios/generated/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
  98. package/ios/generated/RNFBDatabaseTurboModulesJSI.h +440 -0
  99. package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
  100. package/lib/DatabaseDataSnapshot.ts +43 -38
  101. package/lib/DatabaseOnDisconnect.ts +3 -3
  102. package/lib/DatabaseQuery.ts +45 -77
  103. package/lib/DatabaseReference.ts +37 -66
  104. package/lib/DatabaseSyncTree.ts +8 -11
  105. package/lib/DatabaseThenableReference.ts +9 -17
  106. package/lib/index.ts +325 -6
  107. package/lib/modular/query.ts +14 -70
  108. package/lib/modular/transaction.ts +1 -4
  109. package/lib/types/database.ts +5 -5
  110. package/lib/types/internal.ts +31 -56
  111. package/lib/version.ts +1 -1
  112. package/lib/web/RNFBDatabaseModule.ts +6 -10
  113. package/package.json +26 -4
  114. package/react-native.config.js +10 -0
  115. package/specs/NativeRNFBTurboDatabase.ts +13 -0
  116. package/specs/NativeRNFBTurboDatabaseOnDisconnect.ts +18 -0
  117. package/specs/NativeRNFBTurboDatabaseQuery.ts +25 -0
  118. package/specs/NativeRNFBTurboDatabaseReference.ts +13 -0
  119. package/specs/NativeRNFBTurboDatabaseTransaction.ts +16 -0
  120. package/typedoc.json +1 -1
  121. package/dist/module/modular.js +0 -76
  122. package/dist/module/modular.js.map +0 -1
  123. package/dist/module/namespaced.js +0 -147
  124. package/dist/module/namespaced.js.map +0 -1
  125. package/dist/module/types/namespaced.js +0 -67
  126. package/dist/module/types/namespaced.js.map +0 -1
  127. package/dist/typescript/lib/modular.d.ts +0 -24
  128. package/dist/typescript/lib/modular.d.ts.map +0 -1
  129. package/dist/typescript/lib/namespaced.d.ts +0 -13
  130. package/dist/typescript/lib/namespaced.d.ts.map +0 -1
  131. package/dist/typescript/lib/types/namespaced.d.ts +0 -1230
  132. package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
  133. package/ios/RNFBDatabase/RNFBDatabaseModule.m +0 -100
  134. package/lib/modular.ts +0 -134
  135. package/lib/namespaced.ts +0 -253
  136. package/lib/types/namespaced.ts +0 -1366
package/lib/index.ts CHANGED
@@ -15,11 +15,330 @@
15
15
  *
16
16
  */
17
17
 
18
- // Export modular API
19
- export * from './modular';
18
+ import {
19
+ isAndroid,
20
+ isBoolean,
21
+ isNumber,
22
+ isString,
23
+ } from '@react-native-firebase/app/dist/module/common';
24
+ import type { FirebaseApp } from '@react-native-firebase/app';
25
+ import {
26
+ FirebaseModule,
27
+ getOrCreateModularInstance,
28
+ } from '@react-native-firebase/app/dist/module/internal';
29
+ import type { ModuleConfig } from '@react-native-firebase/app/dist/module/internal';
30
+ import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
31
+ import type { ReactNativeFirebase } from '@react-native-firebase/app';
32
+ import type {
33
+ DatabaseInternal,
34
+ DatabaseReferenceInternal,
35
+ DatabaseTransactionInternal,
36
+ DatabaseWithMethodsInternal,
37
+ RNFBDatabaseModule,
38
+ ServerValueStaticInternal,
39
+ } from './types/internal';
40
+ import './types/internal';
41
+ import DatabaseReferenceImpl from './DatabaseReference';
42
+ import DatabaseStatics from './DatabaseStatics';
43
+ import DatabaseTransaction from './DatabaseTransaction';
44
+ import type {
45
+ Database,
46
+ DatabaseReference,
47
+ DataSnapshot,
48
+ EmulatorMockTokenOptions,
49
+ } from './types/database';
50
+ import { version } from './version';
51
+ import fallBackModule from './web/RNFBDatabaseModule';
52
+
53
+ const nativeModuleName = 'NativeRNFBTurboDatabase';
54
+
55
+ const nativeModuleNames = [
56
+ nativeModuleName,
57
+ 'NativeRNFBTurboDatabaseReference',
58
+ 'NativeRNFBTurboDatabaseQuery',
59
+ 'NativeRNFBTurboDatabaseOnDisconnect',
60
+ 'NativeRNFBTurboDatabaseTransaction',
61
+ ] as const;
62
+
63
+ function ap(reference: DatabaseReference): DatabaseReferenceInternal {
64
+ return reference as unknown as DatabaseReferenceInternal;
65
+ }
66
+
67
+ class FirebaseDatabaseModule extends FirebaseModule<typeof nativeModuleName> {
68
+ readonly type = 'database' as const;
69
+ _serverTimeOffset: number;
70
+ _customUrlOrRegion: string | null;
71
+ _transaction: DatabaseTransactionInternal;
72
+
73
+ private get nativeModule(): RNFBDatabaseModule {
74
+ return this.native as RNFBDatabaseModule;
75
+ }
76
+
77
+ constructor(
78
+ app: ReactNativeFirebase.FirebaseAppBase,
79
+ config: ModuleConfig,
80
+ databaseUrl?: string | null,
81
+ ) {
82
+ super(app, config, databaseUrl);
83
+ this._serverTimeOffset = 0;
84
+ this._customUrlOrRegion = databaseUrl || this.app.options.databaseURL || null;
85
+ this._transaction = new DatabaseTransaction(this as unknown as DatabaseInternal);
86
+ setTimeout(() => {
87
+ this._syncServerTimeOffset();
88
+ }, 100);
89
+ }
90
+
91
+ _syncServerTimeOffset(): void {
92
+ ap(this.ref('.info/serverTimeOffset')).on('value', (snapshot: DataSnapshot) => {
93
+ this._serverTimeOffset = snapshot.val();
94
+ });
95
+ }
96
+
97
+ getServerTime(): Date {
98
+ return new Date(Date.now() + this._serverTimeOffset);
99
+ }
100
+
101
+ ref(path = '/'): DatabaseReference {
102
+ if (!isString(path)) {
103
+ throw new Error("firebase.app().database().ref(*) 'path' must be a string value.");
104
+ }
105
+
106
+ if (/[#$\[\]'?]/g.test(path)) {
107
+ throw new Error(
108
+ `Paths must be non-empty strings and can't contain #, $, [, ], ' or ? | path: ${path}`,
109
+ );
110
+ }
111
+
112
+ return new DatabaseReferenceImpl(this, path);
113
+ }
114
+
115
+ refFromURL(url: string): DatabaseReference {
116
+ if (!isString(url) || !url.startsWith('https://')) {
117
+ throw new Error(
118
+ "firebase.app().database().refFromURL(*) 'url' must be a valid database URL.",
119
+ );
120
+ }
121
+
122
+ if (!url.includes(this._customUrlOrRegion as string)) {
123
+ throw new Error(
124
+ `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.`,
125
+ );
126
+ }
127
+
128
+ let path = url.replace(this._customUrlOrRegion as string, '');
129
+ if (path.includes('?')) {
130
+ path = path.slice(0, path.indexOf('?'));
131
+ }
132
+
133
+ return new DatabaseReferenceImpl(this, path || '/');
134
+ }
135
+
136
+ goOnline(): void {
137
+ this.nativeModule.goOnline();
138
+ }
139
+
140
+ goOffline(): void {
141
+ this.nativeModule.goOffline();
142
+ }
143
+
144
+ setPersistenceEnabled(enabled: boolean): Promise<void> {
145
+ if (!isBoolean(enabled)) {
146
+ throw new Error(
147
+ "firebase.app().database().setPersistenceEnabled(*) 'enabled' must be a boolean value.",
148
+ );
149
+ }
150
+
151
+ return this.nativeModule.setPersistenceEnabled(enabled);
152
+ }
153
+
154
+ setLoggingEnabled(enabled: boolean): Promise<void> {
155
+ if (!isBoolean(enabled)) {
156
+ throw new Error(
157
+ "firebase.app().database().setLoggingEnabled(*) 'enabled' must be a boolean value.",
158
+ );
159
+ }
160
+
161
+ return this.nativeModule.setLoggingEnabled(enabled);
162
+ }
163
+
164
+ setPersistenceCacheSizeBytes(bytes: number): Promise<void> {
165
+ if (!isNumber(bytes)) {
166
+ throw new Error(
167
+ "firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be a number value.",
168
+ );
169
+ }
170
+
171
+ if (bytes < 1048576) {
172
+ throw new Error(
173
+ "firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be greater than 1048576 bytes (1MB).",
174
+ );
175
+ }
176
+
177
+ if (bytes > 104857600) {
178
+ throw new Error(
179
+ "firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be less than 104857600 bytes (100MB).",
180
+ );
181
+ }
182
+
183
+ return this.nativeModule.setPersistenceCacheSizeBytes(bytes);
184
+ }
185
+
186
+ useEmulator(host: string, port: number): [string, number] {
187
+ if (!host || !isString(host) || !port || !isNumber(port)) {
188
+ throw new Error('firebase.database().useEmulator() takes a non-empty host and port');
189
+ }
190
+ let remappedHost = host;
191
+ const androidBypassEmulatorUrlRemap =
192
+ typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' &&
193
+ this.firebaseJson.android_bypass_emulator_url_remap;
194
+ if (!androidBypassEmulatorUrlRemap && isAndroid && remappedHost) {
195
+ if (remappedHost.startsWith('localhost')) {
196
+ remappedHost = remappedHost.replace('localhost', '10.0.2.2');
197
+ // eslint-disable-next-line no-console
198
+ console.log(
199
+ '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.',
200
+ );
201
+ }
202
+ if (remappedHost.startsWith('127.0.0.1')) {
203
+ remappedHost = remappedHost.replace('127.0.0.1', '10.0.2.2');
204
+ // eslint-disable-next-line no-console
205
+ console.log(
206
+ '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.',
207
+ );
208
+ }
209
+ }
210
+ this.nativeModule.useEmulator(remappedHost, port);
211
+ return [remappedHost, port];
212
+ }
213
+ }
214
+
215
+ const config: ModuleConfig = {
216
+ namespace: 'database',
217
+ nativeModuleName: [...nativeModuleNames],
218
+ nativeEvents: ['database_transaction_event', 'database_sync_event'],
219
+ hasMultiAppSupport: true,
220
+ hasCustomUrlOrRegionSupport: true,
221
+ turboModule: true,
222
+ };
223
+
224
+ export const SDK_VERSION = version;
225
+
226
+ const { ServerValue } = DatabaseStatics;
227
+
228
+ export function getDatabase(app?: FirebaseApp, url?: string): Database {
229
+ return getOrCreateModularInstance(
230
+ FirebaseDatabaseModule,
231
+ config,
232
+ app,
233
+ url,
234
+ ) as unknown as Database;
235
+ }
236
+
237
+ export function connectDatabaseEmulator(
238
+ db: Database,
239
+ host: string,
240
+ port: number,
241
+ options?: {
242
+ mockUserToken?: EmulatorMockTokenOptions | string;
243
+ },
244
+ ): void {
245
+ (db as DatabaseWithMethodsInternal).useEmulator(host, port, options);
246
+ }
247
+
248
+ /**
249
+ * Manually disconnects the Realtime Database client from the server.
250
+ */
251
+ export function goOffline(db: Database): void {
252
+ (db as DatabaseWithMethodsInternal).goOffline();
253
+ }
254
+
255
+ /**
256
+ * Manually re-establishes the Realtime Database connection.
257
+ */
258
+ export function goOnline(db: Database): void {
259
+ (db as DatabaseWithMethodsInternal).goOnline();
260
+ }
261
+
262
+ export function ref(db: Database, path?: string): DatabaseReference {
263
+ return (db as DatabaseWithMethodsInternal).ref(path);
264
+ }
265
+
266
+ export function refFromURL(db: Database, url: string): DatabaseReference {
267
+ return (db as DatabaseWithMethodsInternal).refFromURL(url);
268
+ }
269
+
270
+ /**
271
+ * Enables or disables disk persistence for the Realtime Database instance.
272
+ *
273
+ * @remarks React Native Firebase-specific API with no firebase-js-sdk modular equivalent.
274
+ * Must be called before any database references are used. Persistence is provided by the
275
+ * native iOS/Android SDK, not the web IndexedDB stack.
276
+ */
277
+ export function setPersistenceEnabled(db: Database, enabled: boolean): Promise<void> {
278
+ return (db as DatabaseWithMethodsInternal).setPersistenceEnabled(enabled) as Promise<void>;
279
+ }
280
+
281
+ export function setLoggingEnabled(db: Database, enabled: boolean): Promise<void> {
282
+ return (db as DatabaseWithMethodsInternal).setLoggingEnabled(enabled) as Promise<void>;
283
+ }
284
+
285
+ /**
286
+ * Sets the on-disk persistence cache size in bytes.
287
+ *
288
+ * @remarks React Native Firebase-specific API with no firebase-js-sdk modular equivalent.
289
+ * Valid range is 1 MB–100 MB. Must be called before any database references are used.
290
+ */
291
+ export function setPersistenceCacheSizeBytes(db: Database, bytes: number): Promise<void> {
292
+ return (db as DatabaseWithMethodsInternal).setPersistenceCacheSizeBytes(bytes) as Promise<void>;
293
+ }
294
+
295
+ /**
296
+ * @remarks **Not implemented on React Native Firebase.** Always throws — transport mode is
297
+ * controlled by the native Realtime Database SDK.
298
+ */
299
+ export function forceLongPolling(): void {
300
+ throw new Error('forceLongPolling() is not implemented');
301
+ }
302
+
303
+ /**
304
+ * @remarks **Not implemented on React Native Firebase.** Always throws — transport mode is
305
+ * controlled by the native Realtime Database SDK.
306
+ */
307
+ export function forceWebSockets(): void {
308
+ throw new Error('forceWebSockets() is not implemented');
309
+ }
310
+
311
+ export function serverTimestamp(): object {
312
+ return ServerValue.TIMESTAMP;
313
+ }
314
+
315
+ /**
316
+ * Returns the current server time as a `Date`, adjusted for clock skew.
317
+ *
318
+ * @remarks React Native Firebase-specific helper with no firebase-js-sdk modular equivalent.
319
+ * Reads the native `.info/serverTimeOffset` listener maintained by the database module.
320
+ */
321
+ export function getServerTime(db: Database): Date {
322
+ return (db as DatabaseWithMethodsInternal).getServerTime();
323
+ }
324
+
325
+ export function increment(delta: number): object {
326
+ return (ServerValue as ServerValueStaticInternal).increment(delta);
327
+ }
328
+
329
+ export function enableLogging(enabled: boolean, persistent?: boolean): any;
330
+ export function enableLogging(logger: (message: string) => unknown): any;
331
+ export function enableLogging(
332
+ _enabledOrLogger: boolean | ((message: string) => unknown),
333
+ _persistent?: boolean,
334
+ ): any {
335
+ throw new Error('enableLogging() is not implemented');
336
+ }
337
+
20
338
  export type * from './types/database';
339
+ export * from './modular/query';
340
+ export * from './modular/transaction';
21
341
 
22
- // Export namespaced API
23
- export type { FirebaseDatabaseTypes } from './types/namespaced';
24
- export * from './namespaced';
25
- export { default } from './namespaced';
342
+ for (const moduleName of nativeModuleNames) {
343
+ setReactNativeModule(moduleName, fallBackModule as unknown as Record<string, unknown>);
344
+ }
@@ -15,7 +15,6 @@
15
15
  *
16
16
  */
17
17
 
18
- import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
19
18
  import type {
20
19
  DataSnapshot,
21
20
  DatabaseReference,
@@ -46,10 +45,7 @@ class DatabaseQueryConstraint extends QueryConstraint {
46
45
  }
47
46
 
48
47
  _apply(query: Query): Query {
49
- return (query as QueryWithModifiersInternal)[this.type].apply(query, [
50
- ...this.args,
51
- MODULAR_DEPRECATION_ARG,
52
- ]);
48
+ return (query as QueryWithModifiersInternal)[this.type](...this.args);
53
49
  }
54
50
  }
55
51
 
@@ -129,12 +125,9 @@ function addEventListener(
129
125
  if (options?.onlyOnce) {
130
126
  const userCallback = callback;
131
127
  listenerCallback = ((snapshot: DataSnapshot, previousChildName?: string | null) => {
132
- queryWithSubscriptions.off.call(
133
- queryRef,
128
+ queryWithSubscriptions.off(
134
129
  eventType,
135
130
  listenerCallback as (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
136
- null,
137
- MODULAR_DEPRECATION_ARG,
138
131
  );
139
132
 
140
133
  return (
@@ -143,22 +136,16 @@ function addEventListener(
143
136
  }) as SnapshotCallbackInternal;
144
137
  }
145
138
 
146
- queryWithSubscriptions.on.call(
147
- queryRef,
139
+ queryWithSubscriptions.on(
148
140
  eventType,
149
141
  listenerCallback as (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
150
142
  cancelCallback as ((error: Error) => unknown) | undefined,
151
- null,
152
- MODULAR_DEPRECATION_ARG,
153
143
  );
154
144
 
155
145
  return () =>
156
- queryWithSubscriptions.off.call(
157
- queryRef,
146
+ queryWithSubscriptions.off(
158
147
  eventType,
159
148
  listenerCallback as (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
160
- null,
161
- MODULAR_DEPRECATION_ARG,
162
149
  );
163
150
  }
164
151
 
@@ -312,24 +299,14 @@ export function onChildRemoved(
312
299
  }
313
300
 
314
301
  export function set(ref: DatabaseReference, value: unknown): Promise<void> {
315
- return (ref as DatabaseReferenceWithMethodsInternal).set.call(
316
- ref,
317
- value,
318
- () => {},
319
- MODULAR_DEPRECATION_ARG,
320
- );
302
+ return (ref as DatabaseReferenceWithMethodsInternal).set(value);
321
303
  }
322
304
 
323
305
  export function setPriority(
324
306
  ref: DatabaseReference,
325
307
  priority: string | number | null,
326
308
  ): Promise<void> {
327
- return (ref as DatabaseReferenceWithMethodsInternal).setPriority.call(
328
- ref,
329
- priority,
330
- () => {},
331
- MODULAR_DEPRECATION_ARG,
332
- );
309
+ return (ref as DatabaseReferenceWithMethodsInternal).setPriority(priority);
333
310
  }
334
311
 
335
312
  export function setWithPriority(
@@ -337,24 +314,11 @@ export function setWithPriority(
337
314
  value: unknown,
338
315
  priority: string | number | null,
339
316
  ): Promise<void> {
340
- return (ref as DatabaseReferenceWithMethodsInternal).setWithPriority.call(
341
- ref,
342
- value,
343
- priority,
344
- () => {},
345
- MODULAR_DEPRECATION_ARG,
346
- );
317
+ return (ref as DatabaseReferenceWithMethodsInternal).setWithPriority(value, priority);
347
318
  }
348
319
 
349
320
  export function get(queryRef: Query): Promise<DataSnapshot> {
350
- return (queryRef as QueryWithSubscriptionMethodsInternal).once.call(
351
- queryRef,
352
- 'value',
353
- () => {},
354
- () => {},
355
- {},
356
- MODULAR_DEPRECATION_ARG,
357
- );
321
+ return (queryRef as QueryWithSubscriptionMethodsInternal).once('value');
358
322
  }
359
323
 
360
324
  export function off(
@@ -366,45 +330,25 @@ export function off(
366
330
  }
367
331
 
368
332
  export function child(parent: DatabaseReference, path: string): DatabaseReference {
369
- return (parent as DatabaseReferenceWithMethodsInternal).child.call(
370
- parent,
371
- path,
372
- MODULAR_DEPRECATION_ARG,
373
- );
333
+ return (parent as DatabaseReferenceWithMethodsInternal).child(path);
374
334
  }
375
335
 
376
336
  export function onDisconnect(ref: DatabaseReference): OnDisconnect {
377
- return (ref as DatabaseReferenceWithMethodsInternal).onDisconnect.call(
378
- ref,
379
- MODULAR_DEPRECATION_ARG,
380
- );
337
+ return (ref as DatabaseReferenceWithMethodsInternal).onDisconnect();
381
338
  }
382
339
 
383
340
  export function keepSynced(ref: DatabaseReference, bool: boolean): Promise<void> {
384
- return (ref as DatabaseReferenceWithMethodsInternal).keepSynced.call(
385
- ref,
386
- bool,
387
- MODULAR_DEPRECATION_ARG,
388
- );
341
+ return (ref as DatabaseReferenceWithMethodsInternal).keepSynced(bool);
389
342
  }
390
343
 
391
344
  export function push(parent: DatabaseReference, value?: unknown): ThenableReference {
392
- return (parent as DatabaseReferenceWithMethodsInternal).push.call(
393
- parent,
394
- value,
395
- undefined,
396
- MODULAR_DEPRECATION_ARG,
397
- );
345
+ return (parent as DatabaseReferenceWithMethodsInternal).push(value);
398
346
  }
399
347
 
400
348
  export function remove(ref: DatabaseReference): Promise<void> {
401
- return (ref as DatabaseReferenceWithMethodsInternal).remove.call(ref, MODULAR_DEPRECATION_ARG);
349
+ return (ref as DatabaseReferenceWithMethodsInternal).remove();
402
350
  }
403
351
 
404
352
  export function update(ref: DatabaseReference, values: object): Promise<void> {
405
- return (ref as DatabaseReferenceWithMethodsInternal).update.call(
406
- ref,
407
- values,
408
- MODULAR_DEPRECATION_ARG,
409
- );
353
+ return (ref as DatabaseReferenceWithMethodsInternal).update(values);
410
354
  }
@@ -15,7 +15,6 @@
15
15
  *
16
16
  */
17
17
 
18
- import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
19
18
  import type { DatabaseReference, TransactionOptions, TransactionResult } from '../types/database';
20
19
  import type { DatabaseReferenceWithTransactionInternal } from '../types/internal';
21
20
 
@@ -24,11 +23,9 @@ export function runTransaction(
24
23
  transactionUpdate: (currentData: any) => unknown,
25
24
  options?: TransactionOptions,
26
25
  ): Promise<TransactionResult> {
27
- return (ref as DatabaseReferenceWithTransactionInternal).transaction.call(
28
- ref,
26
+ return (ref as DatabaseReferenceWithTransactionInternal).transaction(
29
27
  transactionUpdate,
30
28
  undefined,
31
29
  options?.applyLocally,
32
- MODULAR_DEPRECATION_ARG,
33
30
  );
34
31
  }
@@ -59,7 +59,7 @@ export type EmulatorMockTokenOptions = ({ user_id: string } | { sub: string }) &
59
59
 
60
60
  export declare class Database {
61
61
  readonly app: FirebaseApp;
62
- readonly type: 'database';
62
+ readonly 'type' = 'database';
63
63
  }
64
64
 
65
65
  export declare class TransactionResult {
@@ -94,10 +94,10 @@ export interface IteratedDataSnapshot extends DataSnapshot {
94
94
  }
95
95
 
96
96
  export declare class DataSnapshot {
97
- readonly key: string | null;
98
- readonly priority: string | number | null;
99
97
  readonly ref: DatabaseReference;
100
- readonly size: number;
98
+ get key(): string | null;
99
+ get priority(): string | number | null;
100
+ get size(): number;
101
101
  child(path: string): DataSnapshot;
102
102
  exists(): boolean;
103
103
  exportVal(): any;
@@ -112,7 +112,7 @@ export declare class OnDisconnect {
112
112
  cancel(): Promise<void>;
113
113
  remove(): Promise<void>;
114
114
  set(value: unknown): Promise<void>;
115
- setWithPriority(value: unknown, priority: string | number | null): Promise<void>;
115
+ setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
116
116
  update(values: object): Promise<void>;
117
117
  }
118
118