@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.
- package/CHANGELOG.md +21 -0
- package/RNFBDatabase.podspec +20 -7
- package/android/build.gradle +19 -0
- package/android/src/main/java/io/invertase/firebase/database/UniversalFirebaseDatabaseModule.java +4 -14
- package/android/src/reactnative/java/io/invertase/firebase/database/DatabaseTurboModuleSupport.java +56 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseModule.java → NativeRNFBTurboDatabase.java} +16 -36
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseOnDisconnectModule.java → NativeRNFBTurboDatabaseOnDisconnect.java} +19 -14
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseQueryModule.java → NativeRNFBTurboDatabaseQuery.java} +41 -105
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseReferenceModule.java → NativeRNFBTurboDatabaseReference.java} +27 -20
- package/android/src/reactnative/java/io/invertase/firebase/database/{ReactNativeFirebaseDatabaseTransactionModule.java → NativeRNFBTurboDatabaseTransaction.java} +41 -19
- package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabasePackage.java +5 -5
- package/android/src/reactnative/java/io/invertase/firebase/database/ReactNativeFirebaseDatabaseTransactionHandler.java +11 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseOnDisconnectSpec.java +55 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseQuerySpec.java +52 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseReferenceSpec.java +55 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseSpec.java +57 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/java/com/facebook/fbreact/specs/NativeRNFBTurboDatabaseTransactionSpec.java +42 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/CMakeLists.txt +36 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules-generated.cpp +182 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/RNFBDatabaseTurboModules.h +63 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
- package/android/src/reactnative/java/io/invertase/firebase/database/generated/jni/react/renderer/components/RNFBDatabaseTurboModules/RNFBDatabaseTurboModulesJSI.h +440 -0
- package/dist/module/DatabaseDataSnapshot.js +20 -6
- package/dist/module/DatabaseDataSnapshot.js.map +1 -1
- package/dist/module/DatabaseOnDisconnect.js.map +1 -1
- package/dist/module/DatabaseQuery.js +13 -16
- package/dist/module/DatabaseQuery.js.map +1 -1
- package/dist/module/DatabaseReference.js +16 -15
- package/dist/module/DatabaseReference.js.map +1 -1
- package/dist/module/DatabaseSyncTree.js +5 -4
- package/dist/module/DatabaseSyncTree.js.map +1 -1
- package/dist/module/DatabaseThenableReference.js +1 -2
- package/dist/module/DatabaseThenableReference.js.map +1 -1
- package/dist/module/index.js +210 -5
- package/dist/module/index.js.map +1 -1
- package/dist/module/modular/query.js +14 -15
- package/dist/module/modular/query.js.map +1 -1
- package/dist/module/modular/transaction.js +1 -2
- package/dist/module/modular/transaction.js.map +1 -1
- package/dist/module/version.js +1 -1
- package/dist/module/web/RNFBDatabaseModule.js +4 -8
- package/dist/module/web/RNFBDatabaseModule.js.map +1 -1
- package/dist/typescript/lib/DatabaseDataSnapshot.d.ts +9 -7
- package/dist/typescript/lib/DatabaseDataSnapshot.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseOnDisconnect.d.ts +3 -3
- package/dist/typescript/lib/DatabaseOnDisconnect.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseQuery.d.ts +18 -18
- package/dist/typescript/lib/DatabaseQuery.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseReference.d.ts +8 -8
- package/dist/typescript/lib/DatabaseReference.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseSyncTree.d.ts +2 -2
- package/dist/typescript/lib/DatabaseSyncTree.d.ts.map +1 -1
- package/dist/typescript/lib/DatabaseThenableReference.d.ts +8 -8
- package/dist/typescript/lib/DatabaseThenableReference.d.ts.map +1 -1
- package/dist/typescript/lib/index.d.ts +57 -4
- package/dist/typescript/lib/index.d.ts.map +1 -1
- package/dist/typescript/lib/modular/query.d.ts.map +1 -1
- package/dist/typescript/lib/modular/transaction.d.ts.map +1 -1
- package/dist/typescript/lib/types/database.d.ts +5 -5
- package/dist/typescript/lib/types/database.d.ts.map +1 -1
- package/dist/typescript/lib/types/internal.d.ts +32 -31
- package/dist/typescript/lib/types/internal.d.ts.map +1 -1
- package/dist/typescript/lib/version.d.ts +1 -1
- package/dist/typescript/lib/web/RNFBDatabaseModule.d.ts.map +1 -1
- package/ios/RNFBDatabase/RNFBDatabaseCommon.h +13 -6
- package/ios/RNFBDatabase/RNFBDatabaseCommon.m +2 -10
- package/ios/RNFBDatabase/RNFBDatabaseConstants.h +25 -0
- package/ios/RNFBDatabase/RNFBDatabaseModule.mm +90 -0
- package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.h +39 -0
- package/ios/RNFBDatabase/RNFBDatabaseModuleHelper.m +64 -0
- package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectHelper.h +59 -0
- package/ios/RNFBDatabase/{RNFBDatabaseOnDisconnectModule.m → RNFBDatabaseOnDisconnectHelper.m} +41 -47
- package/ios/RNFBDatabase/RNFBDatabaseOnDisconnectModule.mm +121 -0
- package/ios/RNFBDatabase/RNFBDatabaseQuery.h +11 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueryHelper.h +49 -0
- package/ios/RNFBDatabase/{RNFBDatabaseQueryModule.m → RNFBDatabaseQueryHelper.m} +77 -91
- package/ios/RNFBDatabase/RNFBDatabaseQueryModule.h +5 -1
- package/ios/RNFBDatabase/RNFBDatabaseQueryModule.mm +105 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueue.h +29 -0
- package/ios/RNFBDatabase/RNFBDatabaseQueue.m +31 -0
- package/ios/RNFBDatabase/RNFBDatabaseReferenceHelper.h +59 -0
- package/ios/RNFBDatabase/{RNFBDatabaseReferenceModule.m → RNFBDatabaseReferenceHelper.m} +42 -48
- package/ios/RNFBDatabase/RNFBDatabaseReferenceModule.mm +125 -0
- package/ios/RNFBDatabase/RNFBDatabaseTransactionHelper.h +38 -0
- package/ios/RNFBDatabase/{RNFBDatabaseTransactionModule.m → RNFBDatabaseTransactionHelper.m} +52 -51
- package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.h +0 -1
- package/ios/RNFBDatabase/RNFBDatabaseTransactionModule.mm +86 -0
- package/ios/RNFBDatabase.xcodeproj/project.pbxproj +24 -24
- package/ios/generated/RCTAppDependencyProvider.h +25 -0
- package/ios/generated/RCTAppDependencyProvider.mm +55 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.h +16 -0
- package/ios/generated/RCTThirdPartyComponentsProvider.mm +23 -0
- package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules-generated.mm +254 -0
- package/ios/generated/RNFBDatabaseTurboModules/RNFBDatabaseTurboModules.h +264 -0
- package/ios/generated/RNFBDatabaseTurboModulesJSI-generated.cpp +257 -0
- package/ios/generated/RNFBDatabaseTurboModulesJSI.h +440 -0
- package/ios/generated/ReactAppDependencyProvider.podspec +34 -0
- package/lib/DatabaseDataSnapshot.ts +43 -38
- package/lib/DatabaseOnDisconnect.ts +3 -3
- package/lib/DatabaseQuery.ts +45 -77
- package/lib/DatabaseReference.ts +37 -66
- package/lib/DatabaseSyncTree.ts +8 -11
- package/lib/DatabaseThenableReference.ts +9 -17
- package/lib/index.ts +325 -6
- package/lib/modular/query.ts +14 -70
- package/lib/modular/transaction.ts +1 -4
- package/lib/types/database.ts +5 -5
- package/lib/types/internal.ts +31 -56
- package/lib/version.ts +1 -1
- package/lib/web/RNFBDatabaseModule.ts +6 -10
- package/package.json +26 -4
- package/react-native.config.js +10 -0
- package/specs/NativeRNFBTurboDatabase.ts +13 -0
- package/specs/NativeRNFBTurboDatabaseOnDisconnect.ts +18 -0
- package/specs/NativeRNFBTurboDatabaseQuery.ts +25 -0
- package/specs/NativeRNFBTurboDatabaseReference.ts +13 -0
- package/specs/NativeRNFBTurboDatabaseTransaction.ts +16 -0
- package/typedoc.json +1 -1
- package/dist/module/modular.js +0 -76
- package/dist/module/modular.js.map +0 -1
- package/dist/module/namespaced.js +0 -147
- package/dist/module/namespaced.js.map +0 -1
- package/dist/module/types/namespaced.js +0 -67
- package/dist/module/types/namespaced.js.map +0 -1
- package/dist/typescript/lib/modular.d.ts +0 -24
- package/dist/typescript/lib/modular.d.ts.map +0 -1
- package/dist/typescript/lib/namespaced.d.ts +0 -13
- package/dist/typescript/lib/namespaced.d.ts.map +0 -1
- package/dist/typescript/lib/types/namespaced.d.ts +0 -1230
- package/dist/typescript/lib/types/namespaced.d.ts.map +0 -1
- package/ios/RNFBDatabase/RNFBDatabaseModule.m +0 -100
- package/lib/modular.ts +0 -134
- package/lib/namespaced.ts +0 -253
- package/lib/types/namespaced.ts +0 -1366
package/lib/DatabaseQuery.ts
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
createDeprecationProxy,
|
|
20
19
|
isBoolean,
|
|
21
20
|
isFunction,
|
|
22
21
|
isNull,
|
|
@@ -24,7 +23,6 @@ import {
|
|
|
24
23
|
isObject,
|
|
25
24
|
isString,
|
|
26
25
|
isUndefined,
|
|
27
|
-
MODULAR_DEPRECATION_ARG,
|
|
28
26
|
pathIsEmpty,
|
|
29
27
|
pathToUrlEncodedString,
|
|
30
28
|
ReferenceBase,
|
|
@@ -37,7 +35,7 @@ import type {
|
|
|
37
35
|
DatabaseInternal,
|
|
38
36
|
DatabaseListenPropsInternal,
|
|
39
37
|
} from './types/internal';
|
|
40
|
-
import type {
|
|
38
|
+
import type { DatabaseReference, DataSnapshot, EventType, Query } from './types/database';
|
|
41
39
|
|
|
42
40
|
const eventTypes = [
|
|
43
41
|
'value',
|
|
@@ -50,20 +48,7 @@ const eventTypes = [
|
|
|
50
48
|
type DatabaseReferenceConstructor = new (
|
|
51
49
|
database: DatabaseInternal,
|
|
52
50
|
path: string,
|
|
53
|
-
) =>
|
|
54
|
-
|
|
55
|
-
type QueryWithDeprecationArgInternal = FirebaseDatabaseTypes.Query & {
|
|
56
|
-
startAt(
|
|
57
|
-
value: number | string | boolean | null,
|
|
58
|
-
key?: string,
|
|
59
|
-
deprecationArg?: string,
|
|
60
|
-
): FirebaseDatabaseTypes.Query;
|
|
61
|
-
endAt(
|
|
62
|
-
value: number | string | boolean | null,
|
|
63
|
-
key?: string,
|
|
64
|
-
deprecationArg?: string,
|
|
65
|
-
): FirebaseDatabaseTypes.Query;
|
|
66
|
-
};
|
|
51
|
+
) => DatabaseReference;
|
|
67
52
|
|
|
68
53
|
let DatabaseReferenceClass: DatabaseReferenceConstructor | null = null;
|
|
69
54
|
|
|
@@ -71,26 +56,17 @@ export function provideReferenceClass(databaseReference: DatabaseReferenceConstr
|
|
|
71
56
|
DatabaseReferenceClass = databaseReference;
|
|
72
57
|
}
|
|
73
58
|
|
|
74
|
-
function
|
|
75
|
-
return query as QueryWithDeprecationArgInternal;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function createReference(
|
|
79
|
-
database: DatabaseInternal,
|
|
80
|
-
path: string,
|
|
81
|
-
): FirebaseDatabaseTypes.Reference {
|
|
59
|
+
function createReference(database: DatabaseInternal, path: string): DatabaseReference {
|
|
82
60
|
if (!DatabaseReferenceClass) {
|
|
83
61
|
throw new Error('DatabaseReference class has not been provided.');
|
|
84
62
|
}
|
|
85
63
|
|
|
86
|
-
return
|
|
87
|
-
new DatabaseReferenceClass(database, path),
|
|
88
|
-
) as FirebaseDatabaseTypes.Reference;
|
|
64
|
+
return new DatabaseReferenceClass(database, path);
|
|
89
65
|
}
|
|
90
66
|
|
|
91
67
|
let listeners = 0;
|
|
92
68
|
|
|
93
|
-
export default class DatabaseQuery extends ReferenceBase implements
|
|
69
|
+
export default class DatabaseQuery extends ReferenceBase implements Query {
|
|
94
70
|
_database: DatabaseInternal;
|
|
95
71
|
_modifiers: DatabaseQueryModifiers;
|
|
96
72
|
|
|
@@ -100,11 +76,11 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
100
76
|
this._modifiers = modifiers;
|
|
101
77
|
}
|
|
102
78
|
|
|
103
|
-
get ref():
|
|
79
|
+
get ref(): DatabaseReference {
|
|
104
80
|
return createReference(this._database, this.path);
|
|
105
81
|
}
|
|
106
82
|
|
|
107
|
-
endAt(value: number | string | boolean | null, key?: string):
|
|
83
|
+
endAt(value: number | string | boolean | null, key?: string): Query {
|
|
108
84
|
if (!isNumber(value) && !isString(value) && !isBoolean(value) && !isNull(value)) {
|
|
109
85
|
throw new Error(
|
|
110
86
|
"firebase.database().ref().endAt(*) 'value' must be a number, string, boolean or null value.",
|
|
@@ -126,10 +102,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
126
102
|
const modifiers = this._modifiers._copy().endAt(value, key);
|
|
127
103
|
modifiers.validateModifiers('firebase.database().ref().endAt()');
|
|
128
104
|
|
|
129
|
-
return
|
|
105
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
130
106
|
}
|
|
131
107
|
|
|
132
|
-
equalTo(value: number | string | boolean | null, key?: string):
|
|
108
|
+
equalTo(value: number | string | boolean | null, key?: string): Query {
|
|
133
109
|
if (!isNumber(value) && !isString(value) && !isBoolean(value) && !isNull(value)) {
|
|
134
110
|
throw new Error(
|
|
135
111
|
"firebase.database().ref().equalTo(*) 'value' must be a number, string, boolean or null value.",
|
|
@@ -154,14 +130,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
154
130
|
);
|
|
155
131
|
}
|
|
156
132
|
|
|
157
|
-
return
|
|
158
|
-
this,
|
|
159
|
-
value,
|
|
160
|
-
MODULAR_DEPRECATION_ARG,
|
|
161
|
-
);
|
|
133
|
+
return (this.startAt(value, key) as DatabaseQuery).endAt(value, key);
|
|
162
134
|
}
|
|
163
135
|
|
|
164
|
-
isEqual(other:
|
|
136
|
+
isEqual(other: Query): boolean {
|
|
165
137
|
if (!(other instanceof DatabaseQuery)) {
|
|
166
138
|
throw new Error("firebase.database().ref().isEqual(*) 'other' must be an instance of Query.");
|
|
167
139
|
}
|
|
@@ -173,7 +145,7 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
173
145
|
return sameApp && sameDatabasePath && sameModifiers;
|
|
174
146
|
}
|
|
175
147
|
|
|
176
|
-
limitToFirst(limit: number):
|
|
148
|
+
limitToFirst(limit: number): Query {
|
|
177
149
|
if (this._modifiers.isValidLimit(limit)) {
|
|
178
150
|
throw new Error(
|
|
179
151
|
"firebase.database().ref().limitToFirst(*) 'limit' must be a positive integer value.",
|
|
@@ -186,12 +158,14 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
186
158
|
);
|
|
187
159
|
}
|
|
188
160
|
|
|
189
|
-
return
|
|
190
|
-
|
|
191
|
-
|
|
161
|
+
return new DatabaseQuery(
|
|
162
|
+
this._database,
|
|
163
|
+
this.path,
|
|
164
|
+
this._modifiers._copy().limitToFirst(limit),
|
|
165
|
+
);
|
|
192
166
|
}
|
|
193
167
|
|
|
194
|
-
limitToLast(limit: number):
|
|
168
|
+
limitToLast(limit: number): Query {
|
|
195
169
|
if (this._modifiers.isValidLimit(limit)) {
|
|
196
170
|
throw new Error(
|
|
197
171
|
"firebase.database().ref().limitToLast(*) 'limit' must be a positive integer value.",
|
|
@@ -204,14 +178,12 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
204
178
|
);
|
|
205
179
|
}
|
|
206
180
|
|
|
207
|
-
return
|
|
208
|
-
new DatabaseQuery(this._database, this.path, this._modifiers._copy().limitToLast(limit)),
|
|
209
|
-
) as FirebaseDatabaseTypes.Query;
|
|
181
|
+
return new DatabaseQuery(this._database, this.path, this._modifiers._copy().limitToLast(limit));
|
|
210
182
|
}
|
|
211
183
|
|
|
212
184
|
off(
|
|
213
|
-
eventType?:
|
|
214
|
-
callback?: (a:
|
|
185
|
+
eventType?: EventType,
|
|
186
|
+
callback?: (a: DataSnapshot, b?: string | null) => void,
|
|
215
187
|
context?: Record<string, any>,
|
|
216
188
|
): void {
|
|
217
189
|
if (arguments.length === 0) {
|
|
@@ -261,11 +233,11 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
261
233
|
}
|
|
262
234
|
|
|
263
235
|
on(
|
|
264
|
-
eventType:
|
|
265
|
-
callback: (data:
|
|
236
|
+
eventType: EventType,
|
|
237
|
+
callback: (data: DataSnapshot, previousChildKey?: string | null) => void,
|
|
266
238
|
cancelCallbackOrContext?: ((a: Error) => void) | Record<string, any> | null,
|
|
267
239
|
context?: Record<string, any> | null,
|
|
268
|
-
): (a:
|
|
240
|
+
): (a: DataSnapshot | null, b?: string | null) => void {
|
|
269
241
|
if (!eventTypes.includes(eventType)) {
|
|
270
242
|
throw new Error(
|
|
271
243
|
`firebase.database().ref().on(*) 'eventType' must be one of ${eventTypes.join(', ')}.`,
|
|
@@ -341,15 +313,15 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
341
313
|
|
|
342
314
|
listeners += 1;
|
|
343
315
|
|
|
344
|
-
return callback as (a:
|
|
316
|
+
return callback as (a: DataSnapshot | null, b?: string | null) => void;
|
|
345
317
|
}
|
|
346
318
|
|
|
347
319
|
once(
|
|
348
|
-
eventType:
|
|
349
|
-
successCallBack?: (a:
|
|
320
|
+
eventType: EventType,
|
|
321
|
+
successCallBack?: (a: DataSnapshot, b?: string | null) => any,
|
|
350
322
|
failureCallbackOrContext?: ((a: Error) => void) | Record<string, any> | null,
|
|
351
323
|
context?: Record<string, any>,
|
|
352
|
-
): Promise<
|
|
324
|
+
): Promise<DataSnapshot> {
|
|
353
325
|
if (!eventTypes.includes(eventType)) {
|
|
354
326
|
throw new Error(
|
|
355
327
|
`firebase.database().ref().once(*) 'eventType' must be one of ${eventTypes.join(', ')}.`,
|
|
@@ -381,21 +353,17 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
381
353
|
return this._database.native
|
|
382
354
|
.once(this.path, modifiers, eventType)
|
|
383
355
|
.then(result => {
|
|
384
|
-
let dataSnapshot:
|
|
356
|
+
let dataSnapshot: DataSnapshot;
|
|
385
357
|
let previousChildName: string | null | undefined;
|
|
386
358
|
|
|
387
359
|
if (eventType === 'value') {
|
|
388
|
-
dataSnapshot =
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
),
|
|
393
|
-
) as FirebaseDatabaseTypes.DataSnapshot;
|
|
360
|
+
dataSnapshot = new DatabaseDataSnapshot(
|
|
361
|
+
this.ref,
|
|
362
|
+
result as ConstructorParameters<typeof DatabaseDataSnapshot>[1],
|
|
363
|
+
);
|
|
394
364
|
} else {
|
|
395
365
|
const childResult = result as DatabaseChildSnapshotResultInternal;
|
|
396
|
-
dataSnapshot =
|
|
397
|
-
new DatabaseDataSnapshot(this.ref, childResult.snapshot),
|
|
398
|
-
) as FirebaseDatabaseTypes.DataSnapshot;
|
|
366
|
+
dataSnapshot = new DatabaseDataSnapshot(this.ref, childResult.snapshot);
|
|
399
367
|
previousChildName = childResult.previousChildName;
|
|
400
368
|
}
|
|
401
369
|
|
|
@@ -419,7 +387,7 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
419
387
|
});
|
|
420
388
|
}
|
|
421
389
|
|
|
422
|
-
orderByChild(path: string):
|
|
390
|
+
orderByChild(path: string): Query {
|
|
423
391
|
if (!isString(path)) {
|
|
424
392
|
throw new Error("firebase.database().ref().orderByChild(*) 'path' must be a string value.");
|
|
425
393
|
}
|
|
@@ -439,10 +407,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
439
407
|
const modifiers = this._modifiers._copy().orderByChild(path);
|
|
440
408
|
modifiers.validateModifiers('firebase.database().ref().orderByChild()');
|
|
441
409
|
|
|
442
|
-
return
|
|
410
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
443
411
|
}
|
|
444
412
|
|
|
445
|
-
orderByKey():
|
|
413
|
+
orderByKey(): Query {
|
|
446
414
|
if (this._modifiers.hasOrderBy()) {
|
|
447
415
|
throw new Error(
|
|
448
416
|
"firebase.database().ref().orderByKey() You can't combine multiple orderBy calls.",
|
|
@@ -452,10 +420,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
452
420
|
const modifiers = this._modifiers._copy().orderByKey();
|
|
453
421
|
modifiers.validateModifiers('firebase.database().ref().orderByKey()');
|
|
454
422
|
|
|
455
|
-
return
|
|
423
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
456
424
|
}
|
|
457
425
|
|
|
458
|
-
orderByPriority():
|
|
426
|
+
orderByPriority(): Query {
|
|
459
427
|
if (this._modifiers.hasOrderBy()) {
|
|
460
428
|
throw new Error(
|
|
461
429
|
"firebase.database().ref().orderByPriority() You can't combine multiple orderBy calls.",
|
|
@@ -465,10 +433,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
465
433
|
const modifiers = this._modifiers._copy().orderByPriority();
|
|
466
434
|
modifiers.validateModifiers('firebase.database().ref().orderByPriority()');
|
|
467
435
|
|
|
468
|
-
return
|
|
436
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
469
437
|
}
|
|
470
438
|
|
|
471
|
-
orderByValue():
|
|
439
|
+
orderByValue(): Query {
|
|
472
440
|
if (this._modifiers.hasOrderBy()) {
|
|
473
441
|
throw new Error(
|
|
474
442
|
"firebase.database().ref().orderByValue() You can't combine multiple orderBy calls.",
|
|
@@ -478,10 +446,10 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
478
446
|
const modifiers = this._modifiers._copy().orderByValue();
|
|
479
447
|
modifiers.validateModifiers('firebase.database().ref().orderByValue()');
|
|
480
448
|
|
|
481
|
-
return
|
|
449
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
482
450
|
}
|
|
483
451
|
|
|
484
|
-
startAt(value: number | string | boolean | null, key?: string):
|
|
452
|
+
startAt(value: number | string | boolean | null, key?: string): Query {
|
|
485
453
|
if (!isNumber(value) && !isString(value) && !isBoolean(value) && !isNull(value)) {
|
|
486
454
|
throw new Error(
|
|
487
455
|
"firebase.database().ref().startAt(*) 'value' must be a number, string, boolean or null value.",
|
|
@@ -503,7 +471,7 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
503
471
|
const modifiers = this._modifiers._copy().startAt(value, key);
|
|
504
472
|
modifiers.validateModifiers('firebase.database().ref().startAt()');
|
|
505
473
|
|
|
506
|
-
return
|
|
474
|
+
return new DatabaseQuery(this._database, this.path, modifiers);
|
|
507
475
|
}
|
|
508
476
|
|
|
509
477
|
toJSON(): string {
|
|
@@ -535,7 +503,7 @@ export default class DatabaseQuery extends ReferenceBase implements FirebaseData
|
|
|
535
503
|
}$${this._modifiers.toString()}`;
|
|
536
504
|
}
|
|
537
505
|
|
|
538
|
-
_generateQueryEventKey(eventType:
|
|
506
|
+
_generateQueryEventKey(eventType: EventType): string {
|
|
539
507
|
return `${this._generateQueryKey()}$${listeners}$${eventType}`;
|
|
540
508
|
}
|
|
541
509
|
}
|
package/lib/DatabaseReference.ts
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import {
|
|
19
|
-
createDeprecationProxy,
|
|
20
19
|
generateDatabaseId,
|
|
21
20
|
isBoolean,
|
|
22
21
|
isFunction,
|
|
@@ -26,7 +25,6 @@ import {
|
|
|
26
25
|
isString,
|
|
27
26
|
isUndefined,
|
|
28
27
|
isValidPath,
|
|
29
|
-
MODULAR_DEPRECATION_ARG,
|
|
30
28
|
pathChild,
|
|
31
29
|
pathParent,
|
|
32
30
|
promiseWithOptionalCallback,
|
|
@@ -40,35 +38,18 @@ import DatabaseQueryModifiers from './DatabaseQueryModifiers';
|
|
|
40
38
|
import DatabaseThenableReference, {
|
|
41
39
|
provideReferenceClass as provideReferenceClassForThenable,
|
|
42
40
|
} from './DatabaseThenableReference';
|
|
43
|
-
import type { DatabaseInternal } from './types/internal';
|
|
44
|
-
import type {
|
|
41
|
+
import type { DatabaseInternal, DatabaseReferenceWithMethodsInternal } from './types/internal';
|
|
42
|
+
import type {
|
|
43
|
+
DatabaseReference as DatabaseReferenceType,
|
|
44
|
+
DataSnapshot,
|
|
45
|
+
OnDisconnect,
|
|
46
|
+
ThenableReference,
|
|
47
|
+
TransactionResult,
|
|
48
|
+
} from './types/database';
|
|
45
49
|
|
|
46
50
|
const internalRefs = ['.info/connected', '.info/serverTimeOffset'] as const;
|
|
47
51
|
|
|
48
|
-
|
|
49
|
-
child(path: string, deprecationArg?: string): FirebaseDatabaseTypes.Reference;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
type ReferenceWithSetInternal = FirebaseDatabaseTypes.Reference & {
|
|
53
|
-
set(
|
|
54
|
-
value: unknown,
|
|
55
|
-
onComplete?: (error: Error | null) => void,
|
|
56
|
-
deprecationArg?: string,
|
|
57
|
-
): Promise<void>;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
function apChild(reference: FirebaseDatabaseTypes.Reference): ReferenceWithChildInternal {
|
|
61
|
-
return reference as ReferenceWithChildInternal;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function apSet(reference: FirebaseDatabaseTypes.Reference): ReferenceWithSetInternal {
|
|
65
|
-
return reference as ReferenceWithSetInternal;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export default class DatabaseReference
|
|
69
|
-
extends DatabaseQuery
|
|
70
|
-
implements FirebaseDatabaseTypes.Reference
|
|
71
|
-
{
|
|
52
|
+
export default class DatabaseReference extends DatabaseQuery implements DatabaseReferenceType {
|
|
72
53
|
readonly _database: DatabaseInternal;
|
|
73
54
|
|
|
74
55
|
constructor(database: DatabaseInternal, path: string) {
|
|
@@ -82,29 +63,23 @@ export default class DatabaseReference
|
|
|
82
63
|
this._database = database;
|
|
83
64
|
}
|
|
84
65
|
|
|
85
|
-
get parent():
|
|
66
|
+
get parent(): DatabaseReferenceType | null {
|
|
86
67
|
const parentPath = pathParent(this.path);
|
|
87
68
|
if (parentPath === null) {
|
|
88
69
|
return null;
|
|
89
70
|
}
|
|
90
|
-
return
|
|
91
|
-
new DatabaseReference(this._database, parentPath),
|
|
92
|
-
) as FirebaseDatabaseTypes.Reference;
|
|
71
|
+
return new DatabaseReference(this._database, parentPath);
|
|
93
72
|
}
|
|
94
73
|
|
|
95
|
-
get root():
|
|
96
|
-
return
|
|
97
|
-
new DatabaseReference(this._database, '/'),
|
|
98
|
-
) as FirebaseDatabaseTypes.Reference;
|
|
74
|
+
get root(): DatabaseReferenceType {
|
|
75
|
+
return new DatabaseReference(this._database, '/');
|
|
99
76
|
}
|
|
100
77
|
|
|
101
|
-
child(path: string):
|
|
78
|
+
child(path: string): DatabaseReferenceType {
|
|
102
79
|
if (!isString(path)) {
|
|
103
80
|
throw new Error("firebase.database().ref().child(*) 'path' must be a string value.");
|
|
104
81
|
}
|
|
105
|
-
return
|
|
106
|
-
new DatabaseReference(this._database, pathChild(this.path, path)),
|
|
107
|
-
) as FirebaseDatabaseTypes.Reference;
|
|
82
|
+
return new DatabaseReference(this._database, pathChild(this.path, path));
|
|
108
83
|
}
|
|
109
84
|
|
|
110
85
|
set(value: any, onComplete?: (error: Error | null) => void): Promise<void> {
|
|
@@ -195,10 +170,10 @@ export default class DatabaseReference
|
|
|
195
170
|
onComplete?: (
|
|
196
171
|
error: Error | null,
|
|
197
172
|
committed: boolean,
|
|
198
|
-
finalResult:
|
|
173
|
+
finalResult: DataSnapshot | null,
|
|
199
174
|
) => void,
|
|
200
175
|
applyLocally?: boolean,
|
|
201
|
-
): Promise<
|
|
176
|
+
): Promise<TransactionResult> {
|
|
202
177
|
if (!isFunction(transactionUpdate)) {
|
|
203
178
|
throw new Error(
|
|
204
179
|
"firebase.database().ref().transaction(*) 'transactionUpdate' must be a function.",
|
|
@@ -230,12 +205,10 @@ export default class DatabaseReference
|
|
|
230
205
|
onComplete(
|
|
231
206
|
null,
|
|
232
207
|
committed,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
),
|
|
238
|
-
) as FirebaseDatabaseTypes.DataSnapshot,
|
|
208
|
+
new DatabaseDataSnapshot(
|
|
209
|
+
this,
|
|
210
|
+
snapshotData as ConstructorParameters<typeof DatabaseDataSnapshot>[1],
|
|
211
|
+
),
|
|
239
212
|
);
|
|
240
213
|
}
|
|
241
214
|
}
|
|
@@ -245,14 +218,17 @@ export default class DatabaseReference
|
|
|
245
218
|
return;
|
|
246
219
|
}
|
|
247
220
|
|
|
221
|
+
const snapshot = new DatabaseDataSnapshot(
|
|
222
|
+
this,
|
|
223
|
+
snapshotData as ConstructorParameters<typeof DatabaseDataSnapshot>[1],
|
|
224
|
+
);
|
|
225
|
+
|
|
248
226
|
resolve({
|
|
249
227
|
committed,
|
|
250
|
-
snapshot
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
),
|
|
255
|
-
) as FirebaseDatabaseTypes.DataSnapshot,
|
|
228
|
+
snapshot,
|
|
229
|
+
toJSON() {
|
|
230
|
+
return { committed, snapshot: snapshot.toJSON() };
|
|
231
|
+
},
|
|
256
232
|
});
|
|
257
233
|
};
|
|
258
234
|
|
|
@@ -282,10 +258,7 @@ export default class DatabaseReference
|
|
|
282
258
|
);
|
|
283
259
|
}
|
|
284
260
|
|
|
285
|
-
push(
|
|
286
|
-
value?: any,
|
|
287
|
-
onComplete?: (error: Error | null) => void,
|
|
288
|
-
): FirebaseDatabaseTypes.ThenableReference {
|
|
261
|
+
push(value?: any, onComplete?: (error: Error | null) => void): ThenableReference {
|
|
289
262
|
if (!isUndefined(onComplete) && !isFunction(onComplete)) {
|
|
290
263
|
throw new Error(
|
|
291
264
|
"firebase.database().ref().push(_, *) 'onComplete' must be a function if provided.",
|
|
@@ -298,15 +271,13 @@ export default class DatabaseReference
|
|
|
298
271
|
return new DatabaseThenableReference(
|
|
299
272
|
this._database,
|
|
300
273
|
pathChild(this.path, id),
|
|
301
|
-
Promise.resolve(
|
|
302
|
-
) as unknown as
|
|
274
|
+
Promise.resolve(this.child(id)),
|
|
275
|
+
) as unknown as ThenableReference;
|
|
303
276
|
}
|
|
304
277
|
|
|
305
|
-
const pushRef =
|
|
278
|
+
const pushRef = this.child(id) as DatabaseReferenceWithMethodsInternal;
|
|
306
279
|
|
|
307
|
-
const promise =
|
|
308
|
-
.set.call(pushRef, value, onComplete, MODULAR_DEPRECATION_ARG)
|
|
309
|
-
.then(() => pushRef);
|
|
280
|
+
const promise = pushRef.set(value, onComplete).then(() => pushRef);
|
|
310
281
|
|
|
311
282
|
if (onComplete) {
|
|
312
283
|
promise.catch(() => {});
|
|
@@ -316,10 +287,10 @@ export default class DatabaseReference
|
|
|
316
287
|
this._database,
|
|
317
288
|
pathChild(this.path, id),
|
|
318
289
|
promise,
|
|
319
|
-
) as unknown as
|
|
290
|
+
) as unknown as ThenableReference;
|
|
320
291
|
}
|
|
321
292
|
|
|
322
|
-
onDisconnect():
|
|
293
|
+
onDisconnect(): OnDisconnect {
|
|
323
294
|
return new DatabaseOnDisconnect(this);
|
|
324
295
|
}
|
|
325
296
|
}
|
package/lib/DatabaseSyncTree.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import {
|
|
18
|
+
import { isString } from '@react-native-firebase/app/dist/module/common';
|
|
19
19
|
import NativeError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
|
|
20
20
|
import SharedEventEmitter from '@react-native-firebase/app/dist/module/internal/SharedEventEmitter';
|
|
21
21
|
import { getReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
|
|
@@ -26,11 +26,11 @@ import type {
|
|
|
26
26
|
DatabaseSnapshotInternal,
|
|
27
27
|
RNFBDatabaseModule,
|
|
28
28
|
} from './types/internal';
|
|
29
|
-
import type {
|
|
29
|
+
import type { DatabaseReference, DataSnapshot } from './types/database';
|
|
30
30
|
|
|
31
31
|
interface DatabaseSyncTreeRegistration {
|
|
32
32
|
eventType: string;
|
|
33
|
-
ref:
|
|
33
|
+
ref: DatabaseReference;
|
|
34
34
|
path: string;
|
|
35
35
|
key: string;
|
|
36
36
|
appName: string;
|
|
@@ -79,7 +79,8 @@ class DatabaseSyncTree {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
private get native(): RNFBDatabaseModule {
|
|
82
|
-
|
|
82
|
+
// NewArch-AD-18 E9: query host for sync tree off(); merged surface exposes off via composite.
|
|
83
|
+
return getReactNativeModule('NativeRNFBTurboDatabaseQuery') as unknown as RNFBDatabaseModule;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
private _allocate(
|
|
@@ -145,7 +146,7 @@ class DatabaseSyncTree {
|
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
let snapshot:
|
|
149
|
+
let snapshot: DataSnapshot;
|
|
149
150
|
let previousChildName: string | null | undefined;
|
|
150
151
|
|
|
151
152
|
if (!event.data) {
|
|
@@ -153,14 +154,10 @@ class DatabaseSyncTree {
|
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
if (event.eventType === 'value') {
|
|
156
|
-
snapshot =
|
|
157
|
-
new DatabaseDataSnapshot(registration.ref, event.data as DatabaseSnapshotInternal),
|
|
158
|
-
) as FirebaseDatabaseTypes.DataSnapshot;
|
|
157
|
+
snapshot = new DatabaseDataSnapshot(registration.ref, event.data as DatabaseSnapshotInternal);
|
|
159
158
|
} else {
|
|
160
159
|
const childData = event.data as DatabaseChildSnapshotResultInternal;
|
|
161
|
-
snapshot =
|
|
162
|
-
new DatabaseDataSnapshot(registration.ref, childData.snapshot),
|
|
163
|
-
) as FirebaseDatabaseTypes.DataSnapshot;
|
|
160
|
+
snapshot = new DatabaseDataSnapshot(registration.ref, childData.snapshot);
|
|
164
161
|
previousChildName = childData.previousChildName;
|
|
165
162
|
}
|
|
166
163
|
|
|
@@ -15,15 +15,13 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
|
|
19
|
-
|
|
20
18
|
import type { DatabaseInternal } from './types/internal';
|
|
21
|
-
import type {
|
|
19
|
+
import type { DatabaseReference } from './types/database';
|
|
22
20
|
|
|
23
21
|
type DatabaseReferenceConstructor = new (
|
|
24
22
|
database: DatabaseInternal,
|
|
25
23
|
path: string,
|
|
26
|
-
) =>
|
|
24
|
+
) => DatabaseReference;
|
|
27
25
|
|
|
28
26
|
let DatabaseReferenceClass: DatabaseReferenceConstructor | null = null;
|
|
29
27
|
|
|
@@ -32,24 +30,18 @@ export function provideReferenceClass(databaseReference: DatabaseReferenceConstr
|
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
export default class DatabaseThenableReference implements Pick<
|
|
35
|
-
Promise<
|
|
33
|
+
Promise<DatabaseReference>,
|
|
36
34
|
'then' | 'catch'
|
|
37
35
|
> {
|
|
38
|
-
_ref:
|
|
39
|
-
_promise: Promise<
|
|
36
|
+
_ref: DatabaseReference;
|
|
37
|
+
_promise: Promise<DatabaseReference>;
|
|
40
38
|
|
|
41
|
-
constructor(
|
|
42
|
-
database: DatabaseInternal,
|
|
43
|
-
path: string,
|
|
44
|
-
promise: Promise<FirebaseDatabaseTypes.Reference>,
|
|
45
|
-
) {
|
|
39
|
+
constructor(database: DatabaseInternal, path: string, promise: Promise<DatabaseReference>) {
|
|
46
40
|
if (!DatabaseReferenceClass) {
|
|
47
41
|
throw new Error('DatabaseReference class has not been provided.');
|
|
48
42
|
}
|
|
49
43
|
|
|
50
|
-
this._ref =
|
|
51
|
-
new DatabaseReferenceClass(database, path),
|
|
52
|
-
) as FirebaseDatabaseTypes.Reference;
|
|
44
|
+
this._ref = new DatabaseReferenceClass(database, path);
|
|
53
45
|
this._promise = promise;
|
|
54
46
|
|
|
55
47
|
return new Proxy(this, {
|
|
@@ -63,11 +55,11 @@ export default class DatabaseThenableReference implements Pick<
|
|
|
63
55
|
}) as unknown as DatabaseThenableReference;
|
|
64
56
|
}
|
|
65
57
|
|
|
66
|
-
get then(): Promise<
|
|
58
|
+
get then(): Promise<DatabaseReference>['then'] {
|
|
67
59
|
return this._promise.then.bind(this._promise);
|
|
68
60
|
}
|
|
69
61
|
|
|
70
|
-
get catch(): Promise<
|
|
62
|
+
get catch(): Promise<DatabaseReference>['catch'] {
|
|
71
63
|
return this._promise.catch.bind(this._promise);
|
|
72
64
|
}
|
|
73
65
|
}
|