@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
@@ -1,305 +0,0 @@
1
- /**
2
- * @typedef {import('../..').DatabaseReference} DatabaseReference
3
- * @typedef {import('../..').DataSnapshot} DataSnapshot
4
- * @typedef {import('./query').QueryConstraint} IQueryConstraint
5
- * @typedef {import('./query').Query} Query
6
- * @typedef {import('./query').OnDisconnect} OnDisconnect
7
- * @typedef {import('./query').ListenOptions} ListenOptions
8
- * @typedef {import('./query').Unsubscribe} Unsubscribe
9
- * @typedef {import('./query').EventType} EventType
10
- * @typedef {import('./query').ThenableReference} ThenableReference
11
- */
12
-
13
- /**
14
- * @implements {IQueryConstraint}
15
- */
16
-
17
- import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
18
-
19
- class QueryConstraint {
20
- constructor(type, ...args) {
21
- this._type = type;
22
- this._args = args;
23
- }
24
-
25
- _apply(query) {
26
- return query[this._type].apply(query, [...this._args, MODULAR_DEPRECATION_ARG]);
27
- }
28
- }
29
-
30
- /**
31
- * @param {number | string | boolean | null} value
32
- * @param {string?} key
33
- * @returns {QueryConstraint}
34
- */
35
- export function endAt(value, key) {
36
- return new QueryConstraint('endAt', value, key);
37
- }
38
-
39
- /**
40
- * @param {number | string | boolean | null} value
41
- * @param {string?} key
42
- * @returns {QueryConstraint}
43
- */
44
- export function endBefore(value, key) {
45
- return new QueryConstraint('endBefore', value, key);
46
- }
47
-
48
- /**
49
- * @param {number | string | boolean | null} value,
50
- * @param {string?} key,
51
- * @returns {QueryConstraint}
52
- */
53
- export function startAt(value, key) {
54
- return new QueryConstraint('startAt', value, key);
55
- }
56
-
57
- /**
58
- * @param {number | string | boolean | null} value,
59
- * @param {string?} key,
60
- * @returns {QueryConstraint}
61
- */
62
- export function startAfter(value, key) {
63
- return new QueryConstraint('startAfter', value, key);
64
- }
65
-
66
- /**
67
- * @param {number} limit
68
- * @returns {QueryConstraint}
69
- */
70
- export function limitToFirst(limit) {
71
- return new QueryConstraint('limitToFirst', limit);
72
- }
73
-
74
- /**
75
- * @param {number} limit
76
- * @returns {QueryConstraint}
77
- */
78
- export function limitToLast(limit) {
79
- return new QueryConstraint('limitToLast', limit);
80
- }
81
-
82
- /**
83
- * @param {string} path
84
- * @returns {QueryConstraint}
85
- */
86
- export function orderByChild(path) {
87
- return new QueryConstraint('orderByChild', path);
88
- }
89
-
90
- export function orderByKey() {
91
- return new QueryConstraint('orderByKey');
92
- }
93
-
94
- export function orderByPriority() {
95
- return new QueryConstraint('orderByPriority');
96
- }
97
-
98
- export function orderByValue() {
99
- return new QueryConstraint('orderByValue');
100
- }
101
-
102
- /**
103
- * @param {number | string | boolean | null} value
104
- * @param {string?} key
105
- * @returns {QueryConstraint}
106
- */
107
- export function equalTo(value, key) {
108
- return new QueryConstraint('equalTo', value, key);
109
- }
110
-
111
- /**
112
- * @param {Query} query
113
- * @param {QueryConstraint[]} queryConstraints
114
- * @returns {Query}
115
- */
116
- export function query(query, ...queryConstraints) {
117
- let q = query;
118
- for (const queryConstraint of queryConstraints) {
119
- q = queryConstraint._apply(q);
120
- }
121
- return q;
122
- }
123
-
124
- /**
125
- * @param {Query} query
126
- * @param {EventType} eventType
127
- * @param {(snapshot: DataSnapshot) => unknown} callback
128
- * @param {((error: Error) => unknown) | ListenOptions} cancelCallbackOrListenOptions
129
- * @param {ListenOptions?} options
130
- * @returns {Unsubscribe}
131
- */
132
- function addEventListener(query, eventType, callback, cancelCallbackOrListenOptions, options) {
133
- let cancelCallback = cancelCallbackOrListenOptions;
134
-
135
- if (typeof cancelCallbackOrListenOptions === 'object') {
136
- cancelCallback = undefined;
137
- options = cancelCallbackOrListenOptions;
138
- }
139
-
140
- if (options && options.onlyOnce) {
141
- const userCallback = callback;
142
- callback = snapshot => {
143
- query.off.call(query, eventType, callback, null, MODULAR_DEPRECATION_ARG);
144
- return userCallback(snapshot);
145
- };
146
- }
147
-
148
- query.on.call(query, eventType, callback, cancelCallback, null, MODULAR_DEPRECATION_ARG);
149
-
150
- return () => query.off.call(query, eventType, callback, null, MODULAR_DEPRECATION_ARG);
151
- }
152
-
153
- /**
154
- * @param {Query} query
155
- * @param {(snapshot: DataSnapshot) => unknown} callback
156
- * @param {((error: Error) => unknown) | ListenOptions | undefined} cancelCallbackOrListenOptions
157
- * @param {ListenOptions?} options
158
- * @returns {Unsubscribe}
159
- */
160
- export function onValue(query, callback, cancelCallbackOrListenOptions, options) {
161
- return addEventListener(query, 'value', callback, cancelCallbackOrListenOptions, options);
162
- }
163
-
164
- /**
165
- * @param {Query} query
166
- * @param {(snapshot: DataSnapshot, previousChildName: string | null) => unknown} callback
167
- * @param {((error: Error) => unknown) | ListenOptions | undefined} cancelCallbackOrListenOptions
168
- * @param {ListenOptions?} options
169
- * @returns {Unsubscribe}
170
- */
171
- export function onChildAdded(query, callback, cancelCallbackOrListenOptions, options) {
172
- return addEventListener(query, 'child_added', callback, cancelCallbackOrListenOptions, options);
173
- }
174
-
175
- /**
176
- * @param {Query} query
177
- * @param {(snapshot: DataSnapshot, previousChildName: string | null) => unknown} callback
178
- * @param {((error: Error) => unknown) | ListenOptions | undefined} cancelCallbackOrListenOptions
179
- * @param {ListenOptions?} options
180
- * @returns {Unsubscribe}
181
- */
182
- export function onChildChanged(query, callback, cancelCallbackOrListenOptions, options) {
183
- return addEventListener(query, 'child_changed', callback, cancelCallbackOrListenOptions, options);
184
- }
185
-
186
- /**
187
- * @param {Query} query
188
- * @param {(snapshot: DataSnapshot, previousChildName: string | null) => unknown} callback
189
- * @param {((error: Error) => unknown) | ListenOptions | undefined} cancelCallbackOrListenOptions
190
- * @param {ListenOptions?} options
191
- * @returns {Unsubscribe}
192
- */
193
- export function onChildMoved(query, callback, cancelCallbackOrListenOptions, options) {
194
- return addEventListener(query, 'child_moved', callback, cancelCallbackOrListenOptions, options);
195
- }
196
-
197
- /**
198
- * @param {Query} query
199
- * @param {(snapshot: DataSnapshot, previousChildName: string | null) => unknown} callback
200
- * @param {((error: Error) => unknown) | ListenOptions | undefined} cancelCallbackOrListenOptions
201
- * @param {ListenOptions?} options
202
- * @returns {Unsubscribe}
203
- */
204
- export function onChildRemoved(query, callback, cancelCallbackOrListenOptions, options) {
205
- return addEventListener(query, 'child_removed', callback, cancelCallbackOrListenOptions, options);
206
- }
207
-
208
- /**
209
- * @param {DatabaseReference} ref
210
- * @param {unknown} value
211
- * @returns {Promise<void>}
212
- */
213
- export function set(ref, value) {
214
- return ref.set.call(ref, value, () => {}, MODULAR_DEPRECATION_ARG);
215
- }
216
-
217
- /**
218
- * @param {DatabaseReference} ref
219
- * @param {string | number | null} priority
220
- * @returns {Promise<void>}
221
- */
222
- export function setPriority(ref, priority) {
223
- return ref.setPriority.call(ref, priority, () => {}, MODULAR_DEPRECATION_ARG);
224
- }
225
-
226
- /**
227
- * @param {DatabaseReference} ref
228
- * @param {unknown} value
229
- * @param {string | number | null} priority
230
- * @returns {Promise<void>}
231
- */
232
- export function setWithPriority(ref, value, priority) {
233
- return ref.setWithPriority.call(ref, value, priority, () => {}, MODULAR_DEPRECATION_ARG);
234
- }
235
-
236
- /**
237
- * @param {Query} query
238
- * @returns {DataSnapshot}
239
- */
240
- export function get(query) {
241
- return query.once.call(
242
- query,
243
- 'value',
244
- () => {},
245
- () => {},
246
- {},
247
- MODULAR_DEPRECATION_ARG,
248
- );
249
- }
250
-
251
- export function off(_query, _eventType, _callback) {
252
- throw new Error('off() is not implemented - use unsubscriber callback returned when subscribing');
253
- }
254
-
255
- /**
256
- * @param {DatabaseReference} parent
257
- * @param {string} path
258
- * @returns {DatabaseReference}
259
- */
260
- export function child(parent, path) {
261
- return parent.child.call(parent, path, MODULAR_DEPRECATION_ARG);
262
- }
263
-
264
- /**
265
- * @param {DatabaseReference} ref
266
- * @returns {OnDisconnect}
267
- */
268
- export function onDisconnect(ref) {
269
- return ref.onDisconnect.call(ref, MODULAR_DEPRECATION_ARG);
270
- }
271
-
272
- /**
273
- * @param {DatabaseReference} ref
274
- * @param {boolean} value
275
- * @returns {Promise<void>}
276
- */
277
- export function keepSynced(ref, value) {
278
- return ref.keepSynced.call(ref, value, MODULAR_DEPRECATION_ARG);
279
- }
280
-
281
- /**
282
- * @param {DatabaseReference} parent
283
- * @param {unknown} value
284
- * @returns {ThenableReference}
285
- */
286
- export function push(parent, value) {
287
- return parent.push.call(parent, value, MODULAR_DEPRECATION_ARG);
288
- }
289
-
290
- /**
291
- * @param {DatabaseReference} ref
292
- * @returns {Promise<void>}
293
- */
294
- export function remove(ref) {
295
- return ref.remove.call(ref, MODULAR_DEPRECATION_ARG);
296
- }
297
-
298
- /**
299
- * @param {DatabaseReference} ref
300
- * @param {object} values
301
- * @returns {Promise<void>}
302
- */
303
- export function update(ref, values) {
304
- return ref.update.call(ref, values, MODULAR_DEPRECATION_ARG);
305
- }
@@ -1,54 +0,0 @@
1
- import { FirebaseDatabaseTypes } from '../..';
2
-
3
- export type TransactionResult = FirebaseDatabaseTypes.TransactionResult;
4
- import DatabaseReference = FirebaseDatabaseTypes.Reference;
5
-
6
- /**
7
- * An options object to configure transactions.
8
- */
9
- export interface TransactionOptions {
10
- readonly applyLocally?: boolean;
11
- }
12
-
13
- /**
14
- * Atomically modifies the data at this location.
15
- *
16
- * Atomically modify the data at this location. Unlike a normal `set()`, which
17
- * just overwrites the data regardless of its previous value, `runTransaction()` is
18
- * used to modify the existing value to a new value, ensuring there are no
19
- * conflicts with other clients writing to the same location at the same time.
20
- *
21
- * To accomplish this, you pass `runTransaction()` an update function which is
22
- * used to transform the current value into a new value. If another client
23
- * writes to the location before your new value is successfully written, your
24
- * update function will be called again with the new current value, and the
25
- * write will be retried. This will happen repeatedly until your write succeeds
26
- * without conflict or you abort the transaction by not returning a value from
27
- * your update function.
28
- *
29
- * Note: Modifying data with `set()` will cancel any pending transactions at
30
- * that location, so extreme care should be taken if mixing `set()` and
31
- * `runTransaction()` to update the same data.
32
- *
33
- * Note: When using transactions with Security and Firebase Rules in place, be
34
- * aware that a client needs `.read` access in addition to `.write` access in
35
- * order to perform a transaction. This is because the client-side nature of
36
- * transactions requires the client to read the data in order to transactionally
37
- * update it.
38
- *
39
- * @param ref - The location to atomically modify.
40
- * @param transactionUpdate - A developer-supplied function which will be passed
41
- * the current data stored at this location (as a JavaScript object). The
42
- * function should return the new value it would like written (as a JavaScript
43
- * object). If `undefined` is returned (i.e. you return with no arguments) the
44
- * transaction will be aborted and the data at this location will not be
45
- * modified.
46
- * @param options - An options object to configure transactions.
47
- * @returns A `Promise` that can optionally be used instead of the `onComplete`
48
- * callback to handle success and failure.
49
- */
50
- export function runTransaction(
51
- ref: DatabaseReference,
52
- transactionUpdate: (currentData: any) => unknown,
53
- options?: TransactionOptions,
54
- ): Promise<TransactionResult>;
@@ -1,24 +0,0 @@
1
- /**
2
- * @typedef {import('./database').DatabaseReference} DatabaseReference
3
- * @typedef {import('./transaction').TransactionOptions} TransactionOptions
4
- * @typedef {import('./transaction').TransactionResult} TransactionResult
5
- */
6
-
7
- /**
8
- * @param {DatabaseReference} ref
9
- * @param {(options: any) => unknown} transactionUpdate
10
- * @param {TransactionOptions?} options
11
- * @returns {Promise<TransactionResult>}
12
- */
13
-
14
- import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
15
-
16
- export function runTransaction(ref, transactionUpdate, options) {
17
- return ref.transaction.call(
18
- ref,
19
- transactionUpdate,
20
- undefined,
21
- options && options.applyLocally,
22
- MODULAR_DEPRECATION_ARG,
23
- );
24
- }
package/lib/version.js DELETED
@@ -1,2 +0,0 @@
1
- // Generated by genversion.
2
- module.exports = '24.1.1';
@@ -1,2 +0,0 @@
1
- // No-op for android.
2
- export default {};
@@ -1,2 +0,0 @@
1
- // No-op for ios.
2
- export default {};