@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,3 +1,5 @@
1
+ "use strict";
2
+
1
3
  /*
2
4
  * Copyright (c) 2016-present Invertase Limited & Contributors
3
5
  *
@@ -15,41 +17,19 @@
15
17
  *
16
18
  */
17
19
 
18
- import NativeError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
19
20
  import { isOther } from '@react-native-firebase/app/dist/module/common';
20
-
21
+ import NativeError from '@react-native-firebase/app/dist/module/internal/NativeFirebaseError';
21
22
  let transactionId = 0;
22
-
23
- /**
24
- * Uses the push id generator to create a transaction id
25
- * @returns {number}
26
- * @private
27
- */
28
-
29
23
  const generateTransactionId = () => transactionId++;
30
-
31
24
  export default class DatabaseTransaction {
32
25
  constructor(database) {
33
26
  this._database = database;
34
27
  this._emitter = database.emitter;
35
28
  this._transactions = {};
36
-
37
- this._emitter.addListener(
38
- this._database.eventNameForApp('database_transaction_event'),
39
- this._onTransactionEvent.bind(this),
40
- );
29
+ this._emitter.addListener(this._database.eventNameForApp('database_transaction_event'), this._onTransactionEvent.bind(this));
41
30
  }
42
-
43
- /**
44
- *
45
- * @param reference
46
- * @param transactionUpdater
47
- * @param onComplete
48
- * @param applyLocally
49
- */
50
31
  add(reference, transactionUpdater, onComplete, applyLocally = false) {
51
32
  const id = generateTransactionId();
52
-
53
33
  this._transactions[id] = {
54
34
  id,
55
35
  reference,
@@ -57,68 +37,46 @@ export default class DatabaseTransaction {
57
37
  onComplete,
58
38
  applyLocally,
59
39
  completed: false,
60
- started: true,
40
+ started: true
61
41
  };
62
-
63
42
  if (isOther) {
64
43
  this._database.native.transactionStart(reference.path, id, applyLocally, transactionUpdater);
65
44
  } else {
66
45
  this._database.native.transactionStart(reference.path, id, applyLocally);
67
46
  }
68
47
  }
69
-
70
- /**
71
- * Returns a transaction by ID
72
- *
73
- * @param id
74
- * @return {*}
75
- * @private
76
- */
77
48
  _getTransaction(id) {
78
49
  return this._transactions[id];
79
50
  }
80
-
81
- /**
82
- * Removes a transaction by ID on the next event loop
83
- *
84
- * @param id
85
- * @private
86
- */
87
51
  _removeTransaction(id) {
88
52
  setImmediate(() => {
89
53
  delete this._transactions[id];
90
54
  });
91
55
  }
92
-
93
- /**
94
- *
95
- * @param event
96
- * @private
97
- */
98
56
  _onTransactionEvent(event) {
99
57
  switch (event.body.type) {
100
58
  case 'update':
101
- return this._handleUpdate(event);
59
+ this._handleUpdate(event);
60
+ return;
102
61
  case 'error':
103
- return this._handleError(event);
62
+ this._handleError(event);
63
+ return;
104
64
  case 'complete':
105
- return this._handleComplete(event);
65
+ this._handleComplete(event);
66
+ return;
106
67
  default:
107
- return undefined;
68
+ return;
108
69
  }
109
70
  }
110
-
111
- /**
112
- *
113
- * @param event
114
- * @private
115
- */
116
71
  _handleUpdate(event) {
117
72
  let newValue;
118
-
119
- const { id, body } = event;
120
- const { value } = body;
121
-
73
+ const {
74
+ id,
75
+ body
76
+ } = event;
77
+ const {
78
+ value
79
+ } = body;
122
80
  try {
123
81
  const transaction = this._getTransaction(id);
124
82
  if (!transaction) {
@@ -126,32 +84,19 @@ export default class DatabaseTransaction {
126
84
  }
127
85
  newValue = transaction.transactionUpdater(value);
128
86
  } finally {
129
- let abort = false;
130
-
131
- if (newValue === undefined) {
132
- abort = true;
133
- }
134
-
135
- this._database.native.transactionTryCommit(id, {
87
+ const abort = newValue === undefined;
88
+ const updates = {
136
89
  value: newValue,
137
- abort,
138
- });
90
+ abort
91
+ };
92
+ this._database.native.transactionTryCommit(id, updates);
139
93
  }
140
94
  }
141
-
142
- /**
143
- *
144
- * @param event
145
- * @private
146
- */
147
95
  _handleError(event) {
148
96
  const transaction = this._getTransaction(event.id);
149
-
150
97
  if (transaction && !transaction.completed) {
151
98
  transaction.completed = true;
152
-
153
99
  try {
154
- // error, committed, snapshot
155
100
  const error = NativeError.fromEvent(event.body.error, 'database');
156
101
  transaction.onComplete(error, false, null);
157
102
  } finally {
@@ -159,24 +104,16 @@ export default class DatabaseTransaction {
159
104
  }
160
105
  }
161
106
  }
162
-
163
- /**
164
- *
165
- * @param event
166
- * @private
167
- */
168
107
  _handleComplete(event) {
169
108
  const transaction = this._getTransaction(event.id);
170
-
171
109
  if (transaction && !transaction.completed) {
172
110
  transaction.completed = true;
173
-
174
111
  try {
175
- // error, committed, snapshot
176
- transaction.onComplete(null, event.body.committed, Object.assign({}, event.body.snapshot));
112
+ transaction.onComplete(null, !!event.body.committed, Object.assign({}, event.body.snapshot));
177
113
  } finally {
178
114
  this._removeTransaction(event.id);
179
115
  }
180
116
  }
181
117
  }
182
118
  }
119
+ //# sourceMappingURL=DatabaseTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isOther","NativeError","transactionId","generateTransactionId","DatabaseTransaction","constructor","database","_database","_emitter","emitter","_transactions","addListener","eventNameForApp","_onTransactionEvent","bind","add","reference","transactionUpdater","onComplete","applyLocally","id","completed","started","native","transactionStart","path","_getTransaction","_removeTransaction","setImmediate","event","body","type","_handleUpdate","_handleError","_handleComplete","newValue","value","transaction","abort","undefined","updates","transactionTryCommit","error","fromEvent","committed","Object","assign","snapshot"],"sourceRoot":"../../lib","sources":["DatabaseTransaction.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAO,QAAQ,+CAA+C;AACvE,OAAOC,WAAW,MAAM,qEAAqE;AAS7F,IAAIC,aAAa,GAAG,CAAC;AAYrB,MAAMC,qBAAqB,GAAGA,CAAA,KAAcD,aAAa,EAAE;AAE3D,eAAe,MAAME,mBAAmB,CAAC;EAKvCC,WAAWA,CAACC,QAAgC,EAAE;IAC5C,IAAI,CAACC,SAAS,GAAGD,QAAQ;IACzB,IAAI,CAACE,QAAQ,GAAGF,QAAQ,CAACG,OAAO;IAChC,IAAI,CAACC,aAAa,GAAG,CAAC,CAAC;IAEvB,IAAI,CAACF,QAAQ,CAACG,WAAW,CACvB,IAAI,CAACJ,SAAS,CAACK,eAAe,CAAC,4BAA4B,CAAC,EAC5D,IAAI,CAACC,mBAAmB,CAACC,IAAI,CAAC,IAAI,CACpC,CAAC;EACH;EAEAC,GAAGA,CACDC,SAAoC,EACpCC,kBAAqD,EACrDC,UAAuF,EACvFC,YAAY,GAAG,KAAK,EACd;IACN,MAAMC,EAAE,GAAGjB,qBAAqB,CAAC,CAAC;IAElC,IAAI,CAACO,aAAa,CAACU,EAAE,CAAC,GAAG;MACvBA,EAAE;MACFJ,SAAS;MACTC,kBAAkB;MAClBC,UAAU;MACVC,YAAY;MACZE,SAAS,EAAE,KAAK;MAChBC,OAAO,EAAE;IACX,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AA2C,GAAG;QAClDJ,KAAK,EAAED,QAAQ;QACfG;MACF,CAAC;MAED,IAAI,CAAC/B,SAAS,CAACgB,MAAM,CAACkB,oBAAoB,CAACrB,EAAE,EAAEoB,OAAO,CAAC;IACzD;EACF;EAEQP,YAAYA,CAACJ,KAAuC,EAAQ;IAClE,MAAMQ,WAAW,GAAG,IAAI,CAACX,eAAe,CAACG,KAAK,CAACT,EAAE,CAAC;IAElD,IAAIiB,WAAW,IAAI,CAACA,WAAW,CAAChB,SAAS,EAAE;MACzCgB,WAAW,CAAChB,SAAS,GAAG,IAAI;MAE5B,IAAI;QACF,MAAMqB,KAAK,GAAGzC,WAAW,CAAC0C,SAAS,CAChCd,KAAK,CAACC,IAAI,CAAyBY,KAAK,EACzC,UACF,CAAU;QACVL,WAAW,CAACnB,UAAU,CAACwB,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC;MAC5C,CAAC,SAAS;QACR,IAAI,CAACf,kBAAkB,CAACE,KAAK,CAACT,EAAE,CAAC;MACnC;IACF;EACF;EAEQc,eAAeA,CAACL,KAAuC,EAAQ;IACrE,MAAMQ,WAAW,GAAG,IAAI,CAACX,eAAe,CAACG,KAAK,CAACT,EAAE,CAAC;IAElD,IAAIiB,WAAW,IAAI,CAACA,WAAW,CAAChB,SAAS,EAAE;MACzCgB,WAAW,CAAChB,SAAS,GAAG,IAAI;MAE5B,IAAI;QACFgB,WAAW,CAACnB,UAAU,CACpB,IAAI,EACJ,CAAC,CAAEW,KAAK,CAACC,IAAI,CAA6Bc,SAAS,EACnDC,MAAM,CAACC,MAAM,CACX,CAAC,CAAC,EACDjB,KAAK,CAACC,IAAI,CAA6CiB,QAC1D,CACF,CAAC;MACH,CAAC,SAAS;QACR,IAAI,CAACpB,kBAAkB,CAACE,KAAK,CAACT,EAAE,CAAC;MACnC;IACF;EACF;AACF","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ // Export modular API
21
+ export * from "./modular.js";
22
+
23
+ // Export namespaced API
24
+
25
+ export * from "./namespaced.js";
26
+ export { default } from "./namespaced.js";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default"],"sourceRoot":"../../lib","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,cAAW;;AAGzB;;AAEA,cAAc,iBAAc;AAC5B,SAASA,OAAO,QAAQ,iBAAc","ignoreList":[]}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
21
+ import { QueryConstraint } from "../types/database.js";
22
+ class DatabaseQueryConstraint extends QueryConstraint {
23
+ constructor(type, ...args) {
24
+ super();
25
+ this.type = type;
26
+ this.args = args;
27
+ }
28
+ _apply(query) {
29
+ return query[this.type].apply(query, [...this.args, MODULAR_DEPRECATION_ARG]);
30
+ }
31
+ }
32
+ export function endAt(value, key) {
33
+ return new DatabaseQueryConstraint('endAt', value, key);
34
+ }
35
+ export function endBefore(value, key) {
36
+ return new DatabaseQueryConstraint('endBefore', value, key);
37
+ }
38
+ export function startAt(value, key) {
39
+ return new DatabaseQueryConstraint('startAt', value, key);
40
+ }
41
+ export function startAfter(value, key) {
42
+ return new DatabaseQueryConstraint('startAfter', value, key);
43
+ }
44
+ export function limitToFirst(limit) {
45
+ return new DatabaseQueryConstraint('limitToFirst', limit);
46
+ }
47
+ export function limitToLast(limit) {
48
+ return new DatabaseQueryConstraint('limitToLast', limit);
49
+ }
50
+ export function orderByChild(path) {
51
+ return new DatabaseQueryConstraint('orderByChild', path);
52
+ }
53
+ export function orderByKey() {
54
+ return new DatabaseQueryConstraint('orderByKey');
55
+ }
56
+ export function orderByPriority() {
57
+ return new DatabaseQueryConstraint('orderByPriority');
58
+ }
59
+ export function orderByValue() {
60
+ return new DatabaseQueryConstraint('orderByValue');
61
+ }
62
+ export function equalTo(value, key) {
63
+ return new DatabaseQueryConstraint('equalTo', value, key);
64
+ }
65
+ export function query(queryRef, ...queryConstraints) {
66
+ let nextQuery = queryRef;
67
+ for (const queryConstraint of queryConstraints) {
68
+ nextQuery = queryConstraint._apply(nextQuery);
69
+ }
70
+ return nextQuery;
71
+ }
72
+ function addEventListener(queryRef, eventType, callback, cancelCallbackOrListenOptions, options) {
73
+ let cancelCallback = cancelCallbackOrListenOptions;
74
+ if (typeof cancelCallbackOrListenOptions === 'object') {
75
+ cancelCallback = undefined;
76
+ options = cancelCallbackOrListenOptions;
77
+ }
78
+ const queryWithSubscriptions = queryRef;
79
+ let listenerCallback = callback;
80
+ if (options?.onlyOnce) {
81
+ const userCallback = callback;
82
+ listenerCallback = (snapshot, previousChildName) => {
83
+ queryWithSubscriptions.off.call(queryRef, eventType, listenerCallback, null, MODULAR_DEPRECATION_ARG);
84
+ return userCallback(snapshot, previousChildName);
85
+ };
86
+ }
87
+ queryWithSubscriptions.on.call(queryRef, eventType, listenerCallback, cancelCallback, null, MODULAR_DEPRECATION_ARG);
88
+ return () => queryWithSubscriptions.off.call(queryRef, eventType, listenerCallback, null, MODULAR_DEPRECATION_ARG);
89
+ }
90
+ export function onValue(queryRef, callback, cancelCallbackOrListenOptions, options) {
91
+ return addEventListener(queryRef, 'value', callback, cancelCallbackOrListenOptions, options);
92
+ }
93
+ export function onChildAdded(queryRef, callback, cancelCallbackOrListenOptions, options) {
94
+ return addEventListener(queryRef, 'child_added', callback, cancelCallbackOrListenOptions, options);
95
+ }
96
+ export function onChildChanged(queryRef, callback, cancelCallbackOrListenOptions, options) {
97
+ return addEventListener(queryRef, 'child_changed', callback, cancelCallbackOrListenOptions, options);
98
+ }
99
+ export function onChildMoved(queryRef, callback, cancelCallbackOrListenOptions, options) {
100
+ return addEventListener(queryRef, 'child_moved', callback, cancelCallbackOrListenOptions, options);
101
+ }
102
+ export function onChildRemoved(queryRef, callback, cancelCallbackOrListenOptions, options) {
103
+ return addEventListener(queryRef, 'child_removed', callback, cancelCallbackOrListenOptions, options);
104
+ }
105
+ export function set(ref, value) {
106
+ return ref.set.call(ref, value, () => {}, MODULAR_DEPRECATION_ARG);
107
+ }
108
+ export function setPriority(ref, priority) {
109
+ return ref.setPriority.call(ref, priority, () => {}, MODULAR_DEPRECATION_ARG);
110
+ }
111
+ export function setWithPriority(ref, value, priority) {
112
+ return ref.setWithPriority.call(ref, value, priority, () => {}, MODULAR_DEPRECATION_ARG);
113
+ }
114
+ export function get(queryRef) {
115
+ return queryRef.once.call(queryRef, 'value', () => {}, () => {}, {}, MODULAR_DEPRECATION_ARG);
116
+ }
117
+ export function off(_query, _eventType, _callback) {
118
+ throw new Error('off() is not implemented - use unsubscriber callback returned when subscribing');
119
+ }
120
+ export function child(parent, path) {
121
+ return parent.child.call(parent, path, MODULAR_DEPRECATION_ARG);
122
+ }
123
+ export function onDisconnect(ref) {
124
+ return ref.onDisconnect.call(ref, MODULAR_DEPRECATION_ARG);
125
+ }
126
+ export function keepSynced(ref, bool) {
127
+ return ref.keepSynced.call(ref, bool, MODULAR_DEPRECATION_ARG);
128
+ }
129
+ export function push(parent, value) {
130
+ return parent.push.call(parent, value, undefined, MODULAR_DEPRECATION_ARG);
131
+ }
132
+ export function remove(ref) {
133
+ return ref.remove.call(ref, MODULAR_DEPRECATION_ARG);
134
+ }
135
+ export function update(ref, values) {
136
+ return ref.update.call(ref, values, MODULAR_DEPRECATION_ARG);
137
+ }
138
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MODULAR_DEPRECATION_ARG","QueryConstraint","DatabaseQueryConstraint","constructor","type","args","_apply","query","apply","endAt","value","key","endBefore","startAt","startAfter","limitToFirst","limit","limitToLast","orderByChild","path","orderByKey","orderByPriority","orderByValue","equalTo","queryRef","queryConstraints","nextQuery","queryConstraint","addEventListener","eventType","callback","cancelCallbackOrListenOptions","options","cancelCallback","undefined","queryWithSubscriptions","listenerCallback","onlyOnce","userCallback","snapshot","previousChildName","off","call","on","onValue","onChildAdded","onChildChanged","onChildMoved","onChildRemoved","set","ref","setPriority","priority","setWithPriority","get","once","_query","_eventType","_callback","Error","child","parent","onDisconnect","keepSynced","bool","push","remove","update","values"],"sourceRoot":"../../../lib","sources":["modular/query.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,+CAA+C;AAYvF,SAASC,eAAe,QAAQ,sBAAmB;AAQnD,MAAMC,uBAAuB,SAASD,eAAe,CAAC;EAIpDE,WAAWA,CAACC,IAAyB,EAAE,GAAGC,IAAe,EAAE;IACzD,KAAK,CAAC,CAAC;IACP,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChB,IAAI,CAACC,IAAI,GA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AAI,CAClEQ,GAAG,EACHc,IAAI,EACJhE,uBACF,CAAC;AACH;AAEA,OAAO,SAASiE,IAAIA,CAACJ,MAAyB,EAAEnD,KAAe,EAAqB;EAClF,OAAQmD,MAAM,CAA0CI,IAAI,CAACvB,IAAI,CAC/DmB,MAAM,EACNnD,KAAK,EACLwB,SAAS,EACTlC,uBACF,CAAC;AACH;AAEA,OAAO,SAASkE,MAAMA,CAAChB,GAAsB,EAAiB;EAC5D,OAAQA,GAAG,CAA0CgB,MAAM,CAACxB,IAAI,CAACQ,GAAG,EAAElD,uBAAuB,CAAC;AAChG;AAEA,OAAO,SAASmE,MAAMA,CAACjB,GAAsB,EAAEkB,MAAc,EAAiB;EAC5E,OAAQlB,GAAG,CAA0CiB,MAAM,CAACzB,IAAI,CAC9DQ,GAAG,EACHkB,MAAM,EACNpE,uBACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
21
+ export function runTransaction(ref, transactionUpdate, options) {
22
+ return ref.transaction.call(ref, transactionUpdate, undefined, options?.applyLocally, MODULAR_DEPRECATION_ARG);
23
+ }
24
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MODULAR_DEPRECATION_ARG","runTransaction","ref","transactionUpdate","options","transaction","call","undefined","applyLocally"],"sourceRoot":"../../../lib","sources":["modular/transaction.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,+CAA+C;AAIvF,OAAO,SAASC,cAAcA,CAC5BC,GAAsB,EACtBC,iBAAgD,EAChDC,OAA4B,EACA;EAC5B,OAAQF,GAAG,CAA8CG,WAAW,CAACC,IAAI,CACvEJ,GAAG,EACHC,iBAAiB,EACjBI,SAAS,EACTH,OAAO,EAAEI,YAAY,EACrBR,uBACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ /*
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { getApp } from '@react-native-firebase/app';
21
+ import { MODULAR_DEPRECATION_ARG } from '@react-native-firebase/app/dist/module/common';
22
+ import DatabaseStatics from "./DatabaseStatics.js";
23
+ const {
24
+ ServerValue
25
+ } = DatabaseStatics;
26
+ export function getDatabase(app, url) {
27
+ if (app) {
28
+ return getApp(app.name).database(url);
29
+ }
30
+ return getApp().database(url);
31
+ }
32
+ export function connectDatabaseEmulator(db, host, port, options) {
33
+ db.useEmulator.call(db, host, port, options, MODULAR_DEPRECATION_ARG);
34
+ }
35
+ export function goOffline(db) {
36
+ db.goOffline.call(db, MODULAR_DEPRECATION_ARG);
37
+ }
38
+ export function goOnline(db) {
39
+ db.goOnline.call(db, MODULAR_DEPRECATION_ARG);
40
+ }
41
+ export function ref(db, path) {
42
+ return db.ref.call(db, path, MODULAR_DEPRECATION_ARG);
43
+ }
44
+ export function refFromURL(db, url) {
45
+ return db.refFromURL.call(db, url, MODULAR_DEPRECATION_ARG);
46
+ }
47
+ export function setPersistenceEnabled(db, enabled) {
48
+ return db.setPersistenceEnabled.call(db, enabled, MODULAR_DEPRECATION_ARG);
49
+ }
50
+ export function setLoggingEnabled(db, enabled) {
51
+ return db.setLoggingEnabled.call(db, enabled, MODULAR_DEPRECATION_ARG);
52
+ }
53
+ export function setPersistenceCacheSizeBytes(db, bytes) {
54
+ return db.setPersistenceCacheSizeBytes.call(db, bytes, MODULAR_DEPRECATION_ARG);
55
+ }
56
+ export function forceLongPolling() {
57
+ throw new Error('forceLongPolling() is not implemented');
58
+ }
59
+ export function forceWebSockets() {
60
+ throw new Error('forceWebSockets() is not implemented');
61
+ }
62
+ export function serverTimestamp() {
63
+ return ServerValue.TIMESTAMP;
64
+ }
65
+ export function getServerTime(db) {
66
+ return db.getServerTime.call(db, MODULAR_DEPRECATION_ARG);
67
+ }
68
+ export function increment(delta) {
69
+ return ServerValue.increment.call(ServerValue, delta, MODULAR_DEPRECATION_ARG);
70
+ }
71
+ export function enableLogging(_enabledOrLogger, _persistent) {
72
+ throw new Error('enableLogging() is not implemented');
73
+ }
74
+ export * from "./modular/query.js";
75
+ export * from "./modular/transaction.js";
76
+ //# sourceMappingURL=modular.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getApp","MODULAR_DEPRECATION_ARG","DatabaseStatics","ServerValue","getDatabase","app","url","name","database","connectDatabaseEmulator","db","host","port","options","useEmulator","call","goOffline","goOnline","ref","path","refFromURL","setPersistenceEnabled","enabled","setLoggingEnabled","setPersistenceCacheSizeBytes","bytes","forceLongPolling","Error","forceWebSockets","serverTimestamp","TIMESTAMP","getServerTime","increment","delta","enableLogging","_enabledOrLogger","_persistent"],"sourceRoot":"../../lib","sources":["modular.ts"],"mappings":";;AAAA;AACA;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
4
+ * Copyright (c) 2016-present Invertase Limited & Contributors
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this library except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ *
18
+ */
19
+
20
+ import { isAndroid, isBoolean, isNumber, isString, MODULAR_DEPRECATION_ARG, createDeprecationProxy } from '@react-native-firebase/app/dist/module/common';
21
+ import { createModuleNamespace, FirebaseModule, getFirebaseRoot } from '@react-native-firebase/app/dist/module/internal';
22
+ import { setReactNativeModule } from '@react-native-firebase/app/dist/module/internal/nativeModule';
23
+ import "./types/internal.js";
24
+ import DatabaseReference from "./DatabaseReference.js";
25
+ import DatabaseStatics from "./DatabaseStatics.js";
26
+ import DatabaseTransaction from "./DatabaseTransaction.js";
27
+ import { version } from "./version.js";
28
+ import fallBackModule from './web/RNFBDatabaseModule';
29
+ const namespace = 'database';
30
+ const nativeModuleName = 'RNFBDatabaseModule';
31
+ const nativeModuleNames = [nativeModuleName, 'RNFBDatabaseReferenceModule', 'RNFBDatabaseQueryModule', 'RNFBDatabaseOnDisconnectModule', 'RNFBDatabaseTransactionModule'];
32
+ function ap(reference) {
33
+ return reference;
34
+ }
35
+ class FirebaseDatabaseModule extends FirebaseModule {
36
+ type = 'database';
37
+ get nativeModule() {
38
+ return this.native;
39
+ }
40
+ constructor(app, config, databaseUrl) {
41
+ super(app, config, databaseUrl);
42
+ this._serverTimeOffset = 0;
43
+ this._customUrlOrRegion = databaseUrl || this.app.options.databaseURL || null;
44
+ this._transaction = new DatabaseTransaction(this);
45
+ setTimeout(() => {
46
+ this._syncServerTimeOffset();
47
+ }, 100);
48
+ }
49
+ _syncServerTimeOffset() {
50
+ ap(this.ref('.info/serverTimeOffset')).on('value', snapshot => {
51
+ this._serverTimeOffset = snapshot.val();
52
+ }, MODULAR_DEPRECATION_ARG);
53
+ }
54
+ getServerTime() {
55
+ return new Date(Date.now() + this._serverTimeOffset);
56
+ }
57
+ ref(path = '/') {
58
+ if (!isString(path)) {
59
+ throw new Error("firebase.app().database().ref(*) 'path' must be a string value.");
60
+ }
61
+ if (/[#$\[\]'?]/g.test(path)) {
62
+ throw new Error(`Paths must be non-empty strings and can't contain #, $, [, ], ' or ? | path: ${path}`);
63
+ }
64
+ return createDeprecationProxy(new DatabaseReference(this, path));
65
+ }
66
+ refFromURL(url) {
67
+ if (!isString(url) || !url.startsWith('https://')) {
68
+ throw new Error("firebase.app().database().refFromURL(*) 'url' must be a valid database URL.");
69
+ }
70
+ if (!url.includes(this._customUrlOrRegion)) {
71
+ throw new Error(`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.`);
72
+ }
73
+ let path = url.replace(this._customUrlOrRegion, '');
74
+ if (path.includes('?')) {
75
+ path = path.slice(0, path.indexOf('?'));
76
+ }
77
+ return createDeprecationProxy(new DatabaseReference(this, path || '/'));
78
+ }
79
+ goOnline() {
80
+ return this.nativeModule.goOnline();
81
+ }
82
+ goOffline() {
83
+ return this.nativeModule.goOffline();
84
+ }
85
+ setPersistenceEnabled(enabled) {
86
+ if (!isBoolean(enabled)) {
87
+ throw new Error("firebase.app().database().setPersistenceEnabled(*) 'enabled' must be a boolean value.");
88
+ }
89
+ return this.nativeModule.setPersistenceEnabled(enabled);
90
+ }
91
+ setLoggingEnabled(enabled) {
92
+ if (!isBoolean(enabled)) {
93
+ throw new Error("firebase.app().database().setLoggingEnabled(*) 'enabled' must be a boolean value.");
94
+ }
95
+ return this.nativeModule.setLoggingEnabled(enabled);
96
+ }
97
+ setPersistenceCacheSizeBytes(bytes) {
98
+ if (!isNumber(bytes)) {
99
+ throw new Error("firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be a number value.");
100
+ }
101
+ if (bytes < 1048576) {
102
+ throw new Error("firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be greater than 1048576 bytes (1MB).");
103
+ }
104
+ if (bytes > 104857600) {
105
+ throw new Error("firebase.app().database().setPersistenceCacheSizeBytes(*) 'bytes' must be less than 104857600 bytes (100MB).");
106
+ }
107
+ return this.nativeModule.setPersistenceCacheSizeBytes(bytes);
108
+ }
109
+ useEmulator(host, port) {
110
+ if (!host || !isString(host) || !port || !isNumber(port)) {
111
+ throw new Error('firebase.database().useEmulator() takes a non-empty host and port');
112
+ }
113
+ let remappedHost = host;
114
+ const androidBypassEmulatorUrlRemap = typeof this.firebaseJson.android_bypass_emulator_url_remap === 'boolean' && this.firebaseJson.android_bypass_emulator_url_remap;
115
+ if (!androidBypassEmulatorUrlRemap && isAndroid && remappedHost) {
116
+ if (remappedHost.startsWith('localhost')) {
117
+ remappedHost = remappedHost.replace('localhost', '10.0.2.2');
118
+ // eslint-disable-next-line no-console
119
+ console.log('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.');
120
+ }
121
+ if (remappedHost.startsWith('127.0.0.1')) {
122
+ remappedHost = remappedHost.replace('127.0.0.1', '10.0.2.2');
123
+ // eslint-disable-next-line no-console
124
+ console.log('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.');
125
+ }
126
+ }
127
+ this.nativeModule.useEmulator(remappedHost, port);
128
+ return [remappedHost, port];
129
+ }
130
+ }
131
+ export const SDK_VERSION = version;
132
+ const databaseNamespace = createModuleNamespace({
133
+ statics: DatabaseStatics,
134
+ version,
135
+ namespace,
136
+ nativeModuleName: [...nativeModuleNames],
137
+ nativeEvents: ['database_transaction_event', 'database_sync_event'],
138
+ hasMultiAppSupport: true,
139
+ hasCustomUrlOrRegionSupport: true,
140
+ ModuleClass: FirebaseDatabaseModule
141
+ });
142
+ export default databaseNamespace;
143
+ export const firebase = getFirebaseRoot();
144
+ for (const moduleName of nativeModuleNames) {
145
+ setReactNativeModule(moduleName, fallBackModule);
146
+ }
147
+ //# sourceMappingURL=namespaced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isAndroid","isBoolean","isNumber","isString","MODULAR_DEPRECATION_ARG","createDeprecationProxy","createModuleNamespace","FirebaseModule","getFirebaseRoot","setReactNativeModule","DatabaseReference","DatabaseStatics","DatabaseTransaction","version","fallBackModule","namespace","nativeModuleName","nativeModuleNames","ap","reference","FirebaseDatabaseModule","type","nativeModule","native","constructor","app","config","databaseUrl","_serverTimeOffset","_customUrlOrRegion","options","databaseURL","_transaction","setTimeout","_syncServerTimeOffset","ref","on","snapshot","val","getServerTime","Date","now","path","Error","test","refFromURL","url","startsWith","includes","replace","slice","indexOf","goOnline","goOffline","setPersistenceEnabled","enabled","setLoggingEnabled","setPersistenceCacheSizeBytes","bytes","useEmulator","host","port","remappedHost","androidBypassEmulatorUrlRemap","firebaseJson","android_bypass_emulator_url_remap","console","log","SDK_VERSION","databaseNamespace","statics","nativeEvents","hasMultiAppSupport","hasCustomUrlOrRegionSupport","ModuleClass","firebase","moduleName"],"sourceRoot":"../../lib","sources":["namespaced.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACEA,SAAS,EACTC,SAAS,EACTC,QAAQ,EACRC,QAAQ,EACRC,uBAAuB,EACvBC,sBAAsB,QACjB,+CAA+C;AACtD,SACEC,qBAAqB,EACrBC,cAAc,EACdC,eAAe,QAEV,iDAAiD;AACxD,SAASC,oBAAoB,QAAQ,8DAA8D;AASnG,OAAO,qBAAkB;AACzB,OAAOC,iBAAiB,MAAM,wBAAqB;AACnD,OAAOC,eAAe,MAAM,sBAAmB;AAC/C,OAAOC,mBAAmB,MAA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