@depup/firebase__database 1.1.1-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/README.md +31 -0
  2. package/changes.json +10 -0
  3. package/dist/index.cjs.js +14089 -0
  4. package/dist/index.cjs.js.map +1 -0
  5. package/dist/index.esm.js +14032 -0
  6. package/dist/index.esm.js.map +1 -0
  7. package/dist/index.node.cjs.js +14109 -0
  8. package/dist/index.node.cjs.js.map +1 -0
  9. package/dist/index.standalone.js +14052 -0
  10. package/dist/index.standalone.js.map +1 -0
  11. package/dist/internal.d.ts +2991 -0
  12. package/dist/node-esm/index.node.esm.js +14048 -0
  13. package/dist/node-esm/index.node.esm.js.map +1 -0
  14. package/dist/node-esm/package.json +1 -0
  15. package/dist/node-esm/src/api/Database.d.ts +137 -0
  16. package/dist/node-esm/src/api/OnDisconnect.d.ts +110 -0
  17. package/dist/node-esm/src/api/Reference.d.ts +124 -0
  18. package/dist/node-esm/src/api/Reference_impl.d.ts +1100 -0
  19. package/dist/node-esm/src/api/ServerValue.d.ts +30 -0
  20. package/dist/node-esm/src/api/Transaction.d.ts +83 -0
  21. package/dist/node-esm/src/api/test_access.d.ts +31 -0
  22. package/dist/node-esm/src/api.d.ts +18 -0
  23. package/dist/node-esm/src/api.standalone.d.ts +30 -0
  24. package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +32 -0
  25. package/dist/node-esm/src/core/AuthTokenProvider.d.ts +49 -0
  26. package/dist/node-esm/src/core/CompoundWrite.d.ts +81 -0
  27. package/dist/node-esm/src/core/PersistentConnection.d.ts +135 -0
  28. package/dist/node-esm/src/core/ReadonlyRestClient.d.ts +60 -0
  29. package/dist/node-esm/src/core/Repo.d.ts +144 -0
  30. package/dist/node-esm/src/core/RepoInfo.d.ts +61 -0
  31. package/dist/node-esm/src/core/ServerActions.d.ts +52 -0
  32. package/dist/node-esm/src/core/SnapshotHolder.d.ts +26 -0
  33. package/dist/node-esm/src/core/SparseSnapshotTree.d.ts +64 -0
  34. package/dist/node-esm/src/core/SyncPoint.d.ts +91 -0
  35. package/dist/node-esm/src/core/SyncTree.d.ts +166 -0
  36. package/dist/node-esm/src/core/WriteTree.d.ts +205 -0
  37. package/dist/node-esm/src/core/operation/AckUserWrite.d.ts +36 -0
  38. package/dist/node-esm/src/core/operation/ListenComplete.d.ts +26 -0
  39. package/dist/node-esm/src/core/operation/Merge.d.ts +33 -0
  40. package/dist/node-esm/src/core/operation/Operation.d.ts +45 -0
  41. package/dist/node-esm/src/core/operation/Overwrite.d.ts +28 -0
  42. package/dist/node-esm/src/core/snap/ChildrenNode.d.ts +112 -0
  43. package/dist/node-esm/src/core/snap/IndexMap.d.ts +43 -0
  44. package/dist/node-esm/src/core/snap/LeafNode.d.ts +83 -0
  45. package/dist/node-esm/src/core/snap/Node.d.ts +126 -0
  46. package/dist/node-esm/src/core/snap/childSet.d.ts +32 -0
  47. package/dist/node-esm/src/core/snap/comparators.d.ts +19 -0
  48. package/dist/node-esm/src/core/snap/indexes/Index.d.ts +50 -0
  49. package/dist/node-esm/src/core/snap/indexes/KeyIndex.d.ts +34 -0
  50. package/dist/node-esm/src/core/snap/indexes/PathIndex.d.ts +29 -0
  51. package/dist/node-esm/src/core/snap/indexes/PriorityIndex.d.ts +33 -0
  52. package/dist/node-esm/src/core/snap/indexes/ValueIndex.d.ts +31 -0
  53. package/dist/node-esm/src/core/snap/nodeFromJSON.d.ts +24 -0
  54. package/dist/node-esm/src/core/snap/snap.d.ts +23 -0
  55. package/dist/node-esm/src/core/stats/StatsCollection.d.ts +26 -0
  56. package/dist/node-esm/src/core/stats/StatsListener.d.ts +30 -0
  57. package/dist/node-esm/src/core/stats/StatsManager.d.ts +20 -0
  58. package/dist/node-esm/src/core/stats/StatsReporter.d.ts +28 -0
  59. package/dist/node-esm/src/core/storage/DOMStorageWrapper.d.ts +46 -0
  60. package/dist/node-esm/src/core/storage/MemoryStorage.d.ts +27 -0
  61. package/dist/node-esm/src/core/storage/storage.d.ts +22 -0
  62. package/dist/node-esm/src/core/util/EventEmitter.d.ts +39 -0
  63. package/dist/node-esm/src/core/util/ImmutableTree.d.ts +117 -0
  64. package/dist/node-esm/src/core/util/NextPushId.d.ts +33 -0
  65. package/dist/node-esm/src/core/util/OnlineMonitor.d.ts +31 -0
  66. package/dist/node-esm/src/core/util/Path.d.ts +94 -0
  67. package/dist/node-esm/src/core/util/ServerValues.d.ts +56 -0
  68. package/dist/node-esm/src/core/util/SortedMap.d.ts +324 -0
  69. package/dist/node-esm/src/core/util/Tree.d.ts +105 -0
  70. package/dist/node-esm/src/core/util/VisibilityMonitor.d.ts +23 -0
  71. package/dist/node-esm/src/core/util/libs/parser.d.ts +32 -0
  72. package/dist/node-esm/src/core/util/misc.d.ts +19 -0
  73. package/dist/node-esm/src/core/util/util.d.ts +176 -0
  74. package/dist/node-esm/src/core/util/validation.d.ts +70 -0
  75. package/dist/node-esm/src/core/version.d.ts +23 -0
  76. package/dist/node-esm/src/core/view/CacheNode.d.ts +41 -0
  77. package/dist/node-esm/src/core/view/Change.d.ts +46 -0
  78. package/dist/node-esm/src/core/view/ChildChangeAccumulator.d.ts +22 -0
  79. package/dist/node-esm/src/core/view/CompleteChildSource.d.ts +55 -0
  80. package/dist/node-esm/src/core/view/Event.d.ts +64 -0
  81. package/dist/node-esm/src/core/view/EventGenerator.d.ts +42 -0
  82. package/dist/node-esm/src/core/view/EventQueue.d.ts +67 -0
  83. package/dist/node-esm/src/core/view/EventRegistration.d.ts +87 -0
  84. package/dist/node-esm/src/core/view/QueryParams.d.ts +95 -0
  85. package/dist/node-esm/src/core/view/View.d.ts +59 -0
  86. package/dist/node-esm/src/core/view/ViewCache.d.ts +32 -0
  87. package/dist/node-esm/src/core/view/ViewProcessor.d.ts +32 -0
  88. package/dist/node-esm/src/core/view/filter/IndexedFilter.d.ts +35 -0
  89. package/dist/node-esm/src/core/view/filter/LimitedFilter.d.ts +47 -0
  90. package/dist/node-esm/src/core/view/filter/NodeFilter.d.ts +54 -0
  91. package/dist/node-esm/src/core/view/filter/RangedFilter.d.ts +47 -0
  92. package/dist/node-esm/src/index.d.ts +28 -0
  93. package/dist/node-esm/src/index.node.d.ts +17 -0
  94. package/dist/node-esm/src/index.standalone.d.ts +17 -0
  95. package/dist/node-esm/src/internal/index.d.ts +38 -0
  96. package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +198 -0
  97. package/dist/node-esm/src/realtime/Connection.d.ts +102 -0
  98. package/dist/node-esm/src/realtime/Constants.d.ts +27 -0
  99. package/dist/node-esm/src/realtime/Transport.d.ts +58 -0
  100. package/dist/node-esm/src/realtime/TransportManager.d.ts +50 -0
  101. package/dist/node-esm/src/realtime/WebSocketConnection.d.ts +127 -0
  102. package/dist/node-esm/src/realtime/polling/PacketReceiver.d.ts +38 -0
  103. package/dist/node-esm/src/register.d.ts +1 -0
  104. package/dist/node-esm/test/helpers/EventAccumulator.d.ts +35 -0
  105. package/dist/node-esm/test/helpers/syncpoint-util.d.ts +29 -0
  106. package/dist/node-esm/test/helpers/util.d.ts +36 -0
  107. package/dist/private.d.ts +2853 -0
  108. package/dist/public.d.ts +1405 -0
  109. package/dist/src/api/Database.d.ts +137 -0
  110. package/dist/src/api/OnDisconnect.d.ts +110 -0
  111. package/dist/src/api/Reference.d.ts +124 -0
  112. package/dist/src/api/Reference_impl.d.ts +1100 -0
  113. package/dist/src/api/ServerValue.d.ts +30 -0
  114. package/dist/src/api/Transaction.d.ts +83 -0
  115. package/dist/src/api/test_access.d.ts +31 -0
  116. package/dist/src/api.d.ts +18 -0
  117. package/dist/src/api.standalone.d.ts +30 -0
  118. package/dist/src/core/AppCheckTokenProvider.d.ts +32 -0
  119. package/dist/src/core/AuthTokenProvider.d.ts +49 -0
  120. package/dist/src/core/CompoundWrite.d.ts +81 -0
  121. package/dist/src/core/PersistentConnection.d.ts +135 -0
  122. package/dist/src/core/ReadonlyRestClient.d.ts +60 -0
  123. package/dist/src/core/Repo.d.ts +144 -0
  124. package/dist/src/core/RepoInfo.d.ts +61 -0
  125. package/dist/src/core/ServerActions.d.ts +52 -0
  126. package/dist/src/core/SnapshotHolder.d.ts +26 -0
  127. package/dist/src/core/SparseSnapshotTree.d.ts +64 -0
  128. package/dist/src/core/SyncPoint.d.ts +91 -0
  129. package/dist/src/core/SyncTree.d.ts +166 -0
  130. package/dist/src/core/WriteTree.d.ts +205 -0
  131. package/dist/src/core/operation/AckUserWrite.d.ts +36 -0
  132. package/dist/src/core/operation/ListenComplete.d.ts +26 -0
  133. package/dist/src/core/operation/Merge.d.ts +33 -0
  134. package/dist/src/core/operation/Operation.d.ts +45 -0
  135. package/dist/src/core/operation/Overwrite.d.ts +28 -0
  136. package/dist/src/core/snap/ChildrenNode.d.ts +112 -0
  137. package/dist/src/core/snap/IndexMap.d.ts +43 -0
  138. package/dist/src/core/snap/LeafNode.d.ts +83 -0
  139. package/dist/src/core/snap/Node.d.ts +126 -0
  140. package/dist/src/core/snap/childSet.d.ts +32 -0
  141. package/dist/src/core/snap/comparators.d.ts +19 -0
  142. package/dist/src/core/snap/indexes/Index.d.ts +50 -0
  143. package/dist/src/core/snap/indexes/KeyIndex.d.ts +34 -0
  144. package/dist/src/core/snap/indexes/PathIndex.d.ts +29 -0
  145. package/dist/src/core/snap/indexes/PriorityIndex.d.ts +33 -0
  146. package/dist/src/core/snap/indexes/ValueIndex.d.ts +31 -0
  147. package/dist/src/core/snap/nodeFromJSON.d.ts +24 -0
  148. package/dist/src/core/snap/snap.d.ts +23 -0
  149. package/dist/src/core/stats/StatsCollection.d.ts +26 -0
  150. package/dist/src/core/stats/StatsListener.d.ts +30 -0
  151. package/dist/src/core/stats/StatsManager.d.ts +20 -0
  152. package/dist/src/core/stats/StatsReporter.d.ts +28 -0
  153. package/dist/src/core/storage/DOMStorageWrapper.d.ts +46 -0
  154. package/dist/src/core/storage/MemoryStorage.d.ts +27 -0
  155. package/dist/src/core/storage/storage.d.ts +22 -0
  156. package/dist/src/core/util/EventEmitter.d.ts +39 -0
  157. package/dist/src/core/util/ImmutableTree.d.ts +117 -0
  158. package/dist/src/core/util/NextPushId.d.ts +33 -0
  159. package/dist/src/core/util/OnlineMonitor.d.ts +31 -0
  160. package/dist/src/core/util/Path.d.ts +94 -0
  161. package/dist/src/core/util/ServerValues.d.ts +56 -0
  162. package/dist/src/core/util/SortedMap.d.ts +324 -0
  163. package/dist/src/core/util/Tree.d.ts +105 -0
  164. package/dist/src/core/util/VisibilityMonitor.d.ts +23 -0
  165. package/dist/src/core/util/libs/parser.d.ts +32 -0
  166. package/dist/src/core/util/misc.d.ts +19 -0
  167. package/dist/src/core/util/util.d.ts +176 -0
  168. package/dist/src/core/util/validation.d.ts +70 -0
  169. package/dist/src/core/version.d.ts +23 -0
  170. package/dist/src/core/view/CacheNode.d.ts +41 -0
  171. package/dist/src/core/view/Change.d.ts +46 -0
  172. package/dist/src/core/view/ChildChangeAccumulator.d.ts +22 -0
  173. package/dist/src/core/view/CompleteChildSource.d.ts +55 -0
  174. package/dist/src/core/view/Event.d.ts +64 -0
  175. package/dist/src/core/view/EventGenerator.d.ts +42 -0
  176. package/dist/src/core/view/EventQueue.d.ts +67 -0
  177. package/dist/src/core/view/EventRegistration.d.ts +87 -0
  178. package/dist/src/core/view/QueryParams.d.ts +95 -0
  179. package/dist/src/core/view/View.d.ts +59 -0
  180. package/dist/src/core/view/ViewCache.d.ts +32 -0
  181. package/dist/src/core/view/ViewProcessor.d.ts +32 -0
  182. package/dist/src/core/view/filter/IndexedFilter.d.ts +35 -0
  183. package/dist/src/core/view/filter/LimitedFilter.d.ts +47 -0
  184. package/dist/src/core/view/filter/NodeFilter.d.ts +54 -0
  185. package/dist/src/core/view/filter/RangedFilter.d.ts +47 -0
  186. package/dist/src/index.d.ts +28 -0
  187. package/dist/src/index.node.d.ts +17 -0
  188. package/dist/src/index.standalone.d.ts +17 -0
  189. package/dist/src/internal/index.d.ts +38 -0
  190. package/dist/src/realtime/BrowserPollConnection.d.ts +198 -0
  191. package/dist/src/realtime/Connection.d.ts +102 -0
  192. package/dist/src/realtime/Constants.d.ts +27 -0
  193. package/dist/src/realtime/Transport.d.ts +58 -0
  194. package/dist/src/realtime/TransportManager.d.ts +50 -0
  195. package/dist/src/realtime/WebSocketConnection.d.ts +127 -0
  196. package/dist/src/realtime/polling/PacketReceiver.d.ts +38 -0
  197. package/dist/src/register.d.ts +1 -0
  198. package/dist/src/tsdoc-metadata.json +11 -0
  199. package/dist/test/helpers/EventAccumulator.d.ts +35 -0
  200. package/dist/test/helpers/syncpoint-util.d.ts +29 -0
  201. package/dist/test/helpers/util.d.ts +36 -0
  202. package/package.json +104 -0
@@ -0,0 +1,1100 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Repo } from '../core/Repo';
18
+ import { Index } from '../core/snap/indexes/Index';
19
+ import { Node } from '../core/snap/Node';
20
+ import { Path } from '../core/util/Path';
21
+ import { Change } from '../core/view/Change';
22
+ import { CancelEvent, DataEvent, EventType } from '../core/view/Event';
23
+ import { CallbackContext, EventRegistration, QueryContext } from '../core/view/EventRegistration';
24
+ import { QueryParams } from '../core/view/QueryParams';
25
+ import { Database } from './Database';
26
+ import { OnDisconnect } from './OnDisconnect';
27
+ import { ListenOptions, Query as Query, DatabaseReference, Unsubscribe, ThenableReference } from './Reference';
28
+ /**
29
+ * @internal
30
+ */
31
+ export declare class QueryImpl implements Query, QueryContext {
32
+ readonly _repo: Repo;
33
+ readonly _path: Path;
34
+ readonly _queryParams: QueryParams;
35
+ readonly _orderByCalled: boolean;
36
+ /**
37
+ * @hideconstructor
38
+ */
39
+ constructor(_repo: Repo, _path: Path, _queryParams: QueryParams, _orderByCalled: boolean);
40
+ get key(): string | null;
41
+ get ref(): DatabaseReference;
42
+ get _queryIdentifier(): string;
43
+ /**
44
+ * An object representation of the query parameters used by this Query.
45
+ */
46
+ get _queryObject(): object;
47
+ isEqual(other: QueryImpl | null): boolean;
48
+ toJSON(): string;
49
+ toString(): string;
50
+ }
51
+ /**
52
+ * @internal
53
+ */
54
+ export declare class ReferenceImpl extends QueryImpl implements DatabaseReference {
55
+ /** @hideconstructor */
56
+ constructor(repo: Repo, path: Path);
57
+ get parent(): ReferenceImpl | null;
58
+ get root(): ReferenceImpl;
59
+ }
60
+ /**
61
+ * A `DataSnapshot` contains data from a Database location.
62
+ *
63
+ * Any time you read data from the Database, you receive the data as a
64
+ * `DataSnapshot`. A `DataSnapshot` is passed to the event callbacks you attach
65
+ * with `on()` or `once()`. You can extract the contents of the snapshot as a
66
+ * JavaScript object by calling the `val()` method. Alternatively, you can
67
+ * traverse into the snapshot by calling `child()` to return child snapshots
68
+ * (which you could then call `val()` on).
69
+ *
70
+ * A `DataSnapshot` is an efficiently generated, immutable copy of the data at
71
+ * a Database location. It cannot be modified and will never change (to modify
72
+ * data, you always call the `set()` method on a `Reference` directly).
73
+ */
74
+ export declare class DataSnapshot {
75
+ readonly _node: Node;
76
+ /**
77
+ * The location of this DataSnapshot.
78
+ */
79
+ readonly ref: DatabaseReference;
80
+ readonly _index: Index;
81
+ /**
82
+ * @param _node - A SnapshotNode to wrap.
83
+ * @param ref - The location this snapshot came from.
84
+ * @param _index - The iteration order for this snapshot
85
+ * @hideconstructor
86
+ */
87
+ constructor(_node: Node,
88
+ /**
89
+ * The location of this DataSnapshot.
90
+ */
91
+ ref: DatabaseReference, _index: Index);
92
+ /**
93
+ * Gets the priority value of the data in this `DataSnapshot`.
94
+ *
95
+ * Applications need not use priority but can order collections by
96
+ * ordinary properties (see
97
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data |Sorting and filtering data}
98
+ * ).
99
+ */
100
+ get priority(): string | number | null;
101
+ /**
102
+ * The key (last part of the path) of the location of this `DataSnapshot`.
103
+ *
104
+ * The last token in a Database location is considered its key. For example,
105
+ * "ada" is the key for the /users/ada/ node. Accessing the key on any
106
+ * `DataSnapshot` will return the key for the location that generated it.
107
+ * However, accessing the key on the root URL of a Database will return
108
+ * `null`.
109
+ */
110
+ get key(): string | null;
111
+ /** Returns the number of child properties of this `DataSnapshot`. */
112
+ get size(): number;
113
+ /**
114
+ * Gets another `DataSnapshot` for the location at the specified relative path.
115
+ *
116
+ * Passing a relative path to the `child()` method of a DataSnapshot returns
117
+ * another `DataSnapshot` for the location at the specified relative path. The
118
+ * relative path can either be a simple child name (for example, "ada") or a
119
+ * deeper, slash-separated path (for example, "ada/name/first"). If the child
120
+ * location has no data, an empty `DataSnapshot` (that is, a `DataSnapshot`
121
+ * whose value is `null`) is returned.
122
+ *
123
+ * @param path - A relative path to the location of child data.
124
+ */
125
+ child(path: string): DataSnapshot;
126
+ /**
127
+ * Returns true if this `DataSnapshot` contains any data. It is slightly more
128
+ * efficient than using `snapshot.val() !== null`.
129
+ */
130
+ exists(): boolean;
131
+ /**
132
+ * Exports the entire contents of the DataSnapshot as a JavaScript object.
133
+ *
134
+ * The `exportVal()` method is similar to `val()`, except priority information
135
+ * is included (if available), making it suitable for backing up your data.
136
+ *
137
+ * @returns The DataSnapshot's contents as a JavaScript value (Object,
138
+ * Array, string, number, boolean, or `null`).
139
+ */
140
+ exportVal(): any;
141
+ /**
142
+ * Enumerates the top-level children in the `IteratedDataSnapshot`.
143
+ *
144
+ * Because of the way JavaScript objects work, the ordering of data in the
145
+ * JavaScript object returned by `val()` is not guaranteed to match the
146
+ * ordering on the server nor the ordering of `onChildAdded()` events. That is
147
+ * where `forEach()` comes in handy. It guarantees the children of a
148
+ * `DataSnapshot` will be iterated in their query order.
149
+ *
150
+ * If no explicit `orderBy*()` method is used, results are returned
151
+ * ordered by key (unless priorities are used, in which case, results are
152
+ * returned by priority).
153
+ *
154
+ * @param action - A function that will be called for each child DataSnapshot.
155
+ * The callback can return true to cancel further enumeration.
156
+ * @returns true if enumeration was canceled due to your callback returning
157
+ * true.
158
+ */
159
+ forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean;
160
+ /**
161
+ * Returns true if the specified child path has (non-null) data.
162
+ *
163
+ * @param path - A relative path to the location of a potential child.
164
+ * @returns `true` if data exists at the specified child path; else
165
+ * `false`.
166
+ */
167
+ hasChild(path: string): boolean;
168
+ /**
169
+ * Returns whether or not the `DataSnapshot` has any non-`null` child
170
+ * properties.
171
+ *
172
+ * You can use `hasChildren()` to determine if a `DataSnapshot` has any
173
+ * children. If it does, you can enumerate them using `forEach()`. If it
174
+ * doesn't, then either this snapshot contains a primitive value (which can be
175
+ * retrieved with `val()`) or it is empty (in which case, `val()` will return
176
+ * `null`).
177
+ *
178
+ * @returns true if this snapshot has any children; else false.
179
+ */
180
+ hasChildren(): boolean;
181
+ /**
182
+ * Returns a JSON-serializable representation of this object.
183
+ */
184
+ toJSON(): object | null;
185
+ /**
186
+ * Extracts a JavaScript value from a `DataSnapshot`.
187
+ *
188
+ * Depending on the data in a `DataSnapshot`, the `val()` method may return a
189
+ * scalar type (string, number, or boolean), an array, or an object. It may
190
+ * also return null, indicating that the `DataSnapshot` is empty (contains no
191
+ * data).
192
+ *
193
+ * @returns The DataSnapshot's contents as a JavaScript value (Object,
194
+ * Array, string, number, boolean, or `null`).
195
+ */
196
+ val(): any;
197
+ }
198
+ /**
199
+ * Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
200
+ */
201
+ export interface IteratedDataSnapshot extends DataSnapshot {
202
+ key: string;
203
+ }
204
+ /**
205
+ *
206
+ * Returns a `Reference` representing the location in the Database
207
+ * corresponding to the provided path. If no path is provided, the `Reference`
208
+ * will point to the root of the Database.
209
+ *
210
+ * @param db - The database instance to obtain a reference for.
211
+ * @param path - Optional path representing the location the returned
212
+ * `Reference` will point. If not provided, the returned `Reference` will
213
+ * point to the root of the Database.
214
+ * @returns If a path is provided, a `Reference`
215
+ * pointing to the provided path. Otherwise, a `Reference` pointing to the
216
+ * root of the Database.
217
+ */
218
+ export declare function ref(db: Database, path?: string): DatabaseReference;
219
+ /**
220
+ * Returns a `Reference` representing the location in the Database
221
+ * corresponding to the provided Firebase URL.
222
+ *
223
+ * An exception is thrown if the URL is not a valid Firebase Database URL or it
224
+ * has a different domain than the current `Database` instance.
225
+ *
226
+ * Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored
227
+ * and are not applied to the returned `Reference`.
228
+ *
229
+ * @param db - The database instance to obtain a reference for.
230
+ * @param url - The Firebase URL at which the returned `Reference` will
231
+ * point.
232
+ * @returns A `Reference` pointing to the provided
233
+ * Firebase URL.
234
+ */
235
+ export declare function refFromURL(db: Database, url: string): DatabaseReference;
236
+ /**
237
+ * Gets a `Reference` for the location at the specified relative path.
238
+ *
239
+ * The relative path can either be a simple child name (for example, "ada") or
240
+ * a deeper slash-separated path (for example, "ada/name/first").
241
+ *
242
+ * @param parent - The parent location.
243
+ * @param path - A relative path from this location to the desired child
244
+ * location.
245
+ * @returns The specified child location.
246
+ */
247
+ export declare function child(parent: DatabaseReference, path: string): DatabaseReference;
248
+ /**
249
+ * Returns an `OnDisconnect` object - see
250
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
251
+ * for more information on how to use it.
252
+ *
253
+ * @param ref - The reference to add OnDisconnect triggers for.
254
+ */
255
+ export declare function onDisconnect(ref: DatabaseReference): OnDisconnect;
256
+ export interface ThenableReferenceImpl extends ReferenceImpl, Pick<Promise<ReferenceImpl>, 'then' | 'catch'> {
257
+ key: string;
258
+ parent: ReferenceImpl;
259
+ }
260
+ /**
261
+ * Generates a new child location using a unique key and returns its
262
+ * `Reference`.
263
+ *
264
+ * This is the most common pattern for adding data to a collection of items.
265
+ *
266
+ * If you provide a value to `push()`, the value is written to the
267
+ * generated location. If you don't pass a value, nothing is written to the
268
+ * database and the child remains empty (but you can use the `Reference`
269
+ * elsewhere).
270
+ *
271
+ * The unique keys generated by `push()` are ordered by the current time, so the
272
+ * resulting list of items is chronologically sorted. The keys are also
273
+ * designed to be unguessable (they contain 72 random bits of entropy).
274
+ *
275
+ * See {@link https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data | Append to a list of data}.
276
+ * See {@link https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html | The 2^120 Ways to Ensure Unique Identifiers}.
277
+ *
278
+ * @param parent - The parent location.
279
+ * @param value - Optional value to be written at the generated location.
280
+ * @returns Combined `Promise` and `Reference`; resolves when write is complete,
281
+ * but can be used immediately as the `Reference` to the child location.
282
+ */
283
+ export declare function push(parent: DatabaseReference, value?: unknown): ThenableReference;
284
+ /**
285
+ * Removes the data at this Database location.
286
+ *
287
+ * Any data at child locations will also be deleted.
288
+ *
289
+ * The effect of the remove will be visible immediately and the corresponding
290
+ * event 'value' will be triggered. Synchronization of the remove to the
291
+ * Firebase servers will also be started, and the returned Promise will resolve
292
+ * when complete. If provided, the onComplete callback will be called
293
+ * asynchronously after synchronization has finished.
294
+ *
295
+ * @param ref - The location to remove.
296
+ * @returns Resolves when remove on server is complete.
297
+ */
298
+ export declare function remove(ref: DatabaseReference): Promise<void>;
299
+ /**
300
+ * Writes data to this Database location.
301
+ *
302
+ * This will overwrite any data at this location and all child locations.
303
+ *
304
+ * The effect of the write will be visible immediately, and the corresponding
305
+ * events ("value", "child_added", etc.) will be triggered. Synchronization of
306
+ * the data to the Firebase servers will also be started, and the returned
307
+ * Promise will resolve when complete. If provided, the `onComplete` callback
308
+ * will be called asynchronously after synchronization has finished.
309
+ *
310
+ * Passing `null` for the new value is equivalent to calling `remove()`; namely,
311
+ * all data at this location and all child locations will be deleted.
312
+ *
313
+ * `set()` will remove any priority stored at this location, so if priority is
314
+ * meant to be preserved, you need to use `setWithPriority()` instead.
315
+ *
316
+ * Note that modifying data with `set()` will cancel any pending transactions
317
+ * at that location, so extreme care should be taken if mixing `set()` and
318
+ * `transaction()` to modify the same data.
319
+ *
320
+ * A single `set()` will generate a single "value" event at the location where
321
+ * the `set()` was performed.
322
+ *
323
+ * @param ref - The location to write to.
324
+ * @param value - The value to be written (string, number, boolean, object,
325
+ * array, or null).
326
+ * @returns Resolves when write to server is complete.
327
+ */
328
+ export declare function set(ref: DatabaseReference, value: unknown): Promise<void>;
329
+ /**
330
+ * Sets a priority for the data at this Database location.
331
+ *
332
+ * Applications need not use priority but can order collections by
333
+ * ordinary properties (see
334
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
335
+ * ).
336
+ *
337
+ * @param ref - The location to write to.
338
+ * @param priority - The priority to be written (string, number, or null).
339
+ * @returns Resolves when write to server is complete.
340
+ */
341
+ export declare function setPriority(ref: DatabaseReference, priority: string | number | null): Promise<void>;
342
+ /**
343
+ * Writes data the Database location. Like `set()` but also specifies the
344
+ * priority for that data.
345
+ *
346
+ * Applications need not use priority but can order collections by
347
+ * ordinary properties (see
348
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
349
+ * ).
350
+ *
351
+ * @param ref - The location to write to.
352
+ * @param value - The value to be written (string, number, boolean, object,
353
+ * array, or null).
354
+ * @param priority - The priority to be written (string, number, or null).
355
+ * @returns Resolves when write to server is complete.
356
+ */
357
+ export declare function setWithPriority(ref: DatabaseReference, value: unknown, priority: string | number | null): Promise<void>;
358
+ /**
359
+ * Writes multiple values to the Database at once.
360
+ *
361
+ * The `values` argument contains multiple property-value pairs that will be
362
+ * written to the Database together. Each child property can either be a simple
363
+ * property (for example, "name") or a relative path (for example,
364
+ * "name/first") from the current location to the data to update.
365
+ *
366
+ * As opposed to the `set()` method, `update()` can be use to selectively update
367
+ * only the referenced properties at the current location (instead of replacing
368
+ * all the child properties at the current location).
369
+ *
370
+ * The effect of the write will be visible immediately, and the corresponding
371
+ * events ('value', 'child_added', etc.) will be triggered. Synchronization of
372
+ * the data to the Firebase servers will also be started, and the returned
373
+ * Promise will resolve when complete. If provided, the `onComplete` callback
374
+ * will be called asynchronously after synchronization has finished.
375
+ *
376
+ * A single `update()` will generate a single "value" event at the location
377
+ * where the `update()` was performed, regardless of how many children were
378
+ * modified.
379
+ *
380
+ * Note that modifying data with `update()` will cancel any pending
381
+ * transactions at that location, so extreme care should be taken if mixing
382
+ * `update()` and `transaction()` to modify the same data.
383
+ *
384
+ * Passing `null` to `update()` will remove the data at this location.
385
+ *
386
+ * See
387
+ * {@link https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html | Introducing multi-location updates and more}.
388
+ *
389
+ * @param ref - The location to write to.
390
+ * @param values - Object containing multiple values.
391
+ * @returns Resolves when update on server is complete.
392
+ */
393
+ export declare function update(ref: DatabaseReference, values: object): Promise<void>;
394
+ /**
395
+ * Gets the most up-to-date result for this query.
396
+ *
397
+ * @param query - The query to run.
398
+ * @returns A `Promise` which resolves to the resulting DataSnapshot if a value is
399
+ * available, or rejects if the client is unable to return a value (e.g., if the
400
+ * server is unreachable and there is nothing cached).
401
+ */
402
+ export declare function get(query: Query): Promise<DataSnapshot>;
403
+ /**
404
+ * Represents registration for 'value' events.
405
+ */
406
+ export declare class ValueEventRegistration implements EventRegistration {
407
+ private callbackContext;
408
+ constructor(callbackContext: CallbackContext);
409
+ respondsTo(eventType: string): boolean;
410
+ createEvent(change: Change, query: QueryContext): DataEvent;
411
+ getEventRunner(eventData: CancelEvent | DataEvent): () => void;
412
+ createCancelEvent(error: Error, path: Path): CancelEvent | null;
413
+ matches(other: EventRegistration): boolean;
414
+ hasAnyCallback(): boolean;
415
+ }
416
+ /**
417
+ * Represents the registration of a child_x event.
418
+ */
419
+ export declare class ChildEventRegistration implements EventRegistration {
420
+ private eventType;
421
+ private callbackContext;
422
+ constructor(eventType: string, callbackContext: CallbackContext | null);
423
+ respondsTo(eventType: string): boolean;
424
+ createCancelEvent(error: Error, path: Path): CancelEvent | null;
425
+ createEvent(change: Change, query: QueryContext): DataEvent;
426
+ getEventRunner(eventData: CancelEvent | DataEvent): () => void;
427
+ matches(other: EventRegistration): boolean;
428
+ hasAnyCallback(): boolean;
429
+ }
430
+ /**
431
+ * Listens for data changes at a particular location.
432
+ *
433
+ * This is the primary way to read data from a Database. Your callback
434
+ * will be triggered for the initial data and again whenever the data changes.
435
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
436
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
437
+ * for more details.
438
+ *
439
+ * An `onValue` event will trigger once with the initial data stored at this
440
+ * location, and then trigger again each time the data changes. The
441
+ * `DataSnapshot` passed to the callback will be for the location at which
442
+ * `on()` was called. It won't trigger until the entire contents has been
443
+ * synchronized. If the location has no data, it will be triggered with an empty
444
+ * `DataSnapshot` (`val()` will return `null`).
445
+ *
446
+ * @param query - The query to run.
447
+ * @param callback - A callback that fires when the specified event occurs. The
448
+ * callback will be passed a DataSnapshot.
449
+ * @param cancelCallback - An optional callback that will be notified if your
450
+ * event subscription is ever canceled because your client does not have
451
+ * permission to read this data (or it had permission but has now lost it).
452
+ * This callback will be passed an `Error` object indicating why the failure
453
+ * occurred.
454
+ * @returns A function that can be invoked to remove the listener.
455
+ */
456
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
457
+ /**
458
+ * Listens for data changes at a particular location.
459
+ *
460
+ * This is the primary way to read data from a Database. Your callback
461
+ * will be triggered for the initial data and again whenever the data changes.
462
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
463
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
464
+ * for more details.
465
+ *
466
+ * An `onValue` event will trigger once with the initial data stored at this
467
+ * location, and then trigger again each time the data changes. The
468
+ * `DataSnapshot` passed to the callback will be for the location at which
469
+ * `on()` was called. It won't trigger until the entire contents has been
470
+ * synchronized. If the location has no data, it will be triggered with an empty
471
+ * `DataSnapshot` (`val()` will return `null`).
472
+ *
473
+ * @param query - The query to run.
474
+ * @param callback - A callback that fires when the specified event occurs. The
475
+ * callback will be passed a DataSnapshot.
476
+ * @param options - An object that can be used to configure `onlyOnce`, which
477
+ * then removes the listener after its first invocation.
478
+ * @returns A function that can be invoked to remove the listener.
479
+ */
480
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
481
+ /**
482
+ * Listens for data changes at a particular location.
483
+ *
484
+ * This is the primary way to read data from a Database. Your callback
485
+ * will be triggered for the initial data and again whenever the data changes.
486
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
487
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
488
+ * for more details.
489
+ *
490
+ * An `onValue` event will trigger once with the initial data stored at this
491
+ * location, and then trigger again each time the data changes. The
492
+ * `DataSnapshot` passed to the callback will be for the location at which
493
+ * `on()` was called. It won't trigger until the entire contents has been
494
+ * synchronized. If the location has no data, it will be triggered with an empty
495
+ * `DataSnapshot` (`val()` will return `null`).
496
+ *
497
+ * @param query - The query to run.
498
+ * @param callback - A callback that fires when the specified event occurs. The
499
+ * callback will be passed a DataSnapshot.
500
+ * @param cancelCallback - An optional callback that will be notified if your
501
+ * event subscription is ever canceled because your client does not have
502
+ * permission to read this data (or it had permission but has now lost it).
503
+ * This callback will be passed an `Error` object indicating why the failure
504
+ * occurred.
505
+ * @param options - An object that can be used to configure `onlyOnce`, which
506
+ * then removes the listener after its first invocation.
507
+ * @returns A function that can be invoked to remove the listener.
508
+ */
509
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
510
+ /**
511
+ * Listens for data changes at a particular location.
512
+ *
513
+ * This is the primary way to read data from a Database. Your callback
514
+ * will be triggered for the initial data and again whenever the data changes.
515
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
516
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
517
+ * for more details.
518
+ *
519
+ * An `onChildAdded` event will be triggered once for each initial child at this
520
+ * location, and it will be triggered again every time a new child is added. The
521
+ * `DataSnapshot` passed into the callback will reflect the data for the
522
+ * relevant child. For ordering purposes, it is passed a second argument which
523
+ * is a string containing the key of the previous sibling child by sort order,
524
+ * or `null` if it is the first child.
525
+ *
526
+ * @param query - The query to run.
527
+ * @param callback - A callback that fires when the specified event occurs.
528
+ * The callback will be passed a DataSnapshot and a string containing the key of
529
+ * the previous child, by sort order, or `null` if it is the first child.
530
+ * @param cancelCallback - An optional callback that will be notified if your
531
+ * event subscription is ever canceled because your client does not have
532
+ * permission to read this data (or it had permission but has now lost it).
533
+ * This callback will be passed an `Error` object indicating why the failure
534
+ * occurred.
535
+ * @returns A function that can be invoked to remove the listener.
536
+ */
537
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
538
+ /**
539
+ * Listens for data changes at a particular location.
540
+ *
541
+ * This is the primary way to read data from a Database. Your callback
542
+ * will be triggered for the initial data and again whenever the data changes.
543
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
544
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
545
+ * for more details.
546
+ *
547
+ * An `onChildAdded` event will be triggered once for each initial child at this
548
+ * location, and it will be triggered again every time a new child is added. The
549
+ * `DataSnapshot` passed into the callback will reflect the data for the
550
+ * relevant child. For ordering purposes, it is passed a second argument which
551
+ * is a string containing the key of the previous sibling child by sort order,
552
+ * or `null` if it is the first child.
553
+ *
554
+ * @param query - The query to run.
555
+ * @param callback - A callback that fires when the specified event occurs.
556
+ * The callback will be passed a DataSnapshot and a string containing the key of
557
+ * the previous child, by sort order, or `null` if it is the first child.
558
+ * @param options - An object that can be used to configure `onlyOnce`, which
559
+ * then removes the listener after its first invocation.
560
+ * @returns A function that can be invoked to remove the listener.
561
+ */
562
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
563
+ /**
564
+ * Listens for data changes at a particular location.
565
+ *
566
+ * This is the primary way to read data from a Database. Your callback
567
+ * will be triggered for the initial data and again whenever the data changes.
568
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
569
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
570
+ * for more details.
571
+ *
572
+ * An `onChildAdded` event will be triggered once for each initial child at this
573
+ * location, and it will be triggered again every time a new child is added. The
574
+ * `DataSnapshot` passed into the callback will reflect the data for the
575
+ * relevant child. For ordering purposes, it is passed a second argument which
576
+ * is a string containing the key of the previous sibling child by sort order,
577
+ * or `null` if it is the first child.
578
+ *
579
+ * @param query - The query to run.
580
+ * @param callback - A callback that fires when the specified event occurs.
581
+ * The callback will be passed a DataSnapshot and a string containing the key of
582
+ * the previous child, by sort order, or `null` if it is the first child.
583
+ * @param cancelCallback - An optional callback that will be notified if your
584
+ * event subscription is ever canceled because your client does not have
585
+ * permission to read this data (or it had permission but has now lost it).
586
+ * This callback will be passed an `Error` object indicating why the failure
587
+ * occurred.
588
+ * @param options - An object that can be used to configure `onlyOnce`, which
589
+ * then removes the listener after its first invocation.
590
+ * @returns A function that can be invoked to remove the listener.
591
+ */
592
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
593
+ /**
594
+ * Listens for data changes at a particular location.
595
+ *
596
+ * This is the primary way to read data from a Database. Your callback
597
+ * will be triggered for the initial data and again whenever the data changes.
598
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
599
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
600
+ * for more details.
601
+ *
602
+ * An `onChildChanged` event will be triggered when the data stored in a child
603
+ * (or any of its descendants) changes. Note that a single `child_changed` event
604
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
605
+ * callback will contain the new child contents. For ordering purposes, the
606
+ * callback is also passed a second argument which is a string containing the
607
+ * key of the previous sibling child by sort order, or `null` if it is the first
608
+ * child.
609
+ *
610
+ * @param query - The query to run.
611
+ * @param callback - A callback that fires when the specified event occurs.
612
+ * The callback will be passed a DataSnapshot and a string containing the key of
613
+ * the previous child, by sort order, or `null` if it is the first child.
614
+ * @param cancelCallback - An optional callback that will be notified if your
615
+ * event subscription is ever canceled because your client does not have
616
+ * permission to read this data (or it had permission but has now lost it).
617
+ * This callback will be passed an `Error` object indicating why the failure
618
+ * occurred.
619
+ * @returns A function that can be invoked to remove the listener.
620
+ */
621
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
622
+ /**
623
+ * Listens for data changes at a particular location.
624
+ *
625
+ * This is the primary way to read data from a Database. Your callback
626
+ * will be triggered for the initial data and again whenever the data changes.
627
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
628
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
629
+ * for more details.
630
+ *
631
+ * An `onChildChanged` event will be triggered when the data stored in a child
632
+ * (or any of its descendants) changes. Note that a single `child_changed` event
633
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
634
+ * callback will contain the new child contents. For ordering purposes, the
635
+ * callback is also passed a second argument which is a string containing the
636
+ * key of the previous sibling child by sort order, or `null` if it is the first
637
+ * child.
638
+ *
639
+ * @param query - The query to run.
640
+ * @param callback - A callback that fires when the specified event occurs.
641
+ * The callback will be passed a DataSnapshot and a string containing the key of
642
+ * the previous child, by sort order, or `null` if it is the first child.
643
+ * @param options - An object that can be used to configure `onlyOnce`, which
644
+ * then removes the listener after its first invocation.
645
+ * @returns A function that can be invoked to remove the listener.
646
+ */
647
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
648
+ /**
649
+ * Listens for data changes at a particular location.
650
+ *
651
+ * This is the primary way to read data from a Database. Your callback
652
+ * will be triggered for the initial data and again whenever the data changes.
653
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
654
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
655
+ * for more details.
656
+ *
657
+ * An `onChildChanged` event will be triggered when the data stored in a child
658
+ * (or any of its descendants) changes. Note that a single `child_changed` event
659
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
660
+ * callback will contain the new child contents. For ordering purposes, the
661
+ * callback is also passed a second argument which is a string containing the
662
+ * key of the previous sibling child by sort order, or `null` if it is the first
663
+ * child.
664
+ *
665
+ * @param query - The query to run.
666
+ * @param callback - A callback that fires when the specified event occurs.
667
+ * The callback will be passed a DataSnapshot and a string containing the key of
668
+ * the previous child, by sort order, or `null` if it is the first child.
669
+ * @param cancelCallback - An optional callback that will be notified if your
670
+ * event subscription is ever canceled because your client does not have
671
+ * permission to read this data (or it had permission but has now lost it).
672
+ * This callback will be passed an `Error` object indicating why the failure
673
+ * occurred.
674
+ * @param options - An object that can be used to configure `onlyOnce`, which
675
+ * then removes the listener after its first invocation.
676
+ * @returns A function that can be invoked to remove the listener.
677
+ */
678
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
679
+ /**
680
+ * Listens for data changes at a particular location.
681
+ *
682
+ * This is the primary way to read data from a Database. Your callback
683
+ * will be triggered for the initial data and again whenever the data changes.
684
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
685
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
686
+ * for more details.
687
+ *
688
+ * An `onChildMoved` event will be triggered when a child's sort order changes
689
+ * such that its position relative to its siblings changes. The `DataSnapshot`
690
+ * passed to the callback will be for the data of the child that has moved. It
691
+ * is also passed a second argument which is a string containing the key of the
692
+ * previous sibling child by sort order, or `null` if it is the first child.
693
+ *
694
+ * @param query - The query to run.
695
+ * @param callback - A callback that fires when the specified event occurs.
696
+ * The callback will be passed a DataSnapshot and a string containing the key of
697
+ * the previous child, by sort order, or `null` if it is the first child.
698
+ * @param cancelCallback - An optional callback that will be notified if your
699
+ * event subscription is ever canceled because your client does not have
700
+ * permission to read this data (or it had permission but has now lost it).
701
+ * This callback will be passed an `Error` object indicating why the failure
702
+ * occurred.
703
+ * @returns A function that can be invoked to remove the listener.
704
+ */
705
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
706
+ /**
707
+ * Listens for data changes at a particular location.
708
+ *
709
+ * This is the primary way to read data from a Database. Your callback
710
+ * will be triggered for the initial data and again whenever the data changes.
711
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
712
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
713
+ * for more details.
714
+ *
715
+ * An `onChildMoved` event will be triggered when a child's sort order changes
716
+ * such that its position relative to its siblings changes. The `DataSnapshot`
717
+ * passed to the callback will be for the data of the child that has moved. It
718
+ * is also passed a second argument which is a string containing the key of the
719
+ * previous sibling child by sort order, or `null` if it is the first child.
720
+ *
721
+ * @param query - The query to run.
722
+ * @param callback - A callback that fires when the specified event occurs.
723
+ * The callback will be passed a DataSnapshot and a string containing the key of
724
+ * the previous child, by sort order, or `null` if it is the first child.
725
+ * @param options - An object that can be used to configure `onlyOnce`, which
726
+ * then removes the listener after its first invocation.
727
+ * @returns A function that can be invoked to remove the listener.
728
+ */
729
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
730
+ /**
731
+ * Listens for data changes at a particular location.
732
+ *
733
+ * This is the primary way to read data from a Database. Your callback
734
+ * will be triggered for the initial data and again whenever the data changes.
735
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
736
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
737
+ * for more details.
738
+ *
739
+ * An `onChildMoved` event will be triggered when a child's sort order changes
740
+ * such that its position relative to its siblings changes. The `DataSnapshot`
741
+ * passed to the callback will be for the data of the child that has moved. It
742
+ * is also passed a second argument which is a string containing the key of the
743
+ * previous sibling child by sort order, or `null` if it is the first child.
744
+ *
745
+ * @param query - The query to run.
746
+ * @param callback - A callback that fires when the specified event occurs.
747
+ * The callback will be passed a DataSnapshot and a string containing the key of
748
+ * the previous child, by sort order, or `null` if it is the first child.
749
+ * @param cancelCallback - An optional callback that will be notified if your
750
+ * event subscription is ever canceled because your client does not have
751
+ * permission to read this data (or it had permission but has now lost it).
752
+ * This callback will be passed an `Error` object indicating why the failure
753
+ * occurred.
754
+ * @param options - An object that can be used to configure `onlyOnce`, which
755
+ * then removes the listener after its first invocation.
756
+ * @returns A function that can be invoked to remove the listener.
757
+ */
758
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
759
+ /**
760
+ * Listens for data changes at a particular location.
761
+ *
762
+ * This is the primary way to read data from a Database. Your callback
763
+ * will be triggered for the initial data and again whenever the data changes.
764
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
765
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
766
+ * for more details.
767
+ *
768
+ * An `onChildRemoved` event will be triggered once every time a child is
769
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
770
+ * the child that was removed. A child will get removed when either:
771
+ *
772
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
773
+ * - a client calls `set(null)` on that child or one of its ancestors
774
+ * - that child has all of its children removed
775
+ * - there is a query in effect which now filters out the child (because it's
776
+ * sort order changed or the max limit was hit)
777
+ *
778
+ * @param query - The query to run.
779
+ * @param callback - A callback that fires when the specified event occurs.
780
+ * The callback will be passed a DataSnapshot and a string containing the key of
781
+ * the previous child, by sort order, or `null` if it is the first child.
782
+ * @param cancelCallback - An optional callback that will be notified if your
783
+ * event subscription is ever canceled because your client does not have
784
+ * permission to read this data (or it had permission but has now lost it).
785
+ * This callback will be passed an `Error` object indicating why the failure
786
+ * occurred.
787
+ * @returns A function that can be invoked to remove the listener.
788
+ */
789
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
790
+ /**
791
+ * Listens for data changes at a particular location.
792
+ *
793
+ * This is the primary way to read data from a Database. Your callback
794
+ * will be triggered for the initial data and again whenever the data changes.
795
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
796
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
797
+ * for more details.
798
+ *
799
+ * An `onChildRemoved` event will be triggered once every time a child is
800
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
801
+ * the child that was removed. A child will get removed when either:
802
+ *
803
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
804
+ * - a client calls `set(null)` on that child or one of its ancestors
805
+ * - that child has all of its children removed
806
+ * - there is a query in effect which now filters out the child (because it's
807
+ * sort order changed or the max limit was hit)
808
+ *
809
+ * @param query - The query to run.
810
+ * @param callback - A callback that fires when the specified event occurs.
811
+ * The callback will be passed a DataSnapshot and a string containing the key of
812
+ * the previous child, by sort order, or `null` if it is the first child.
813
+ * @param options - An object that can be used to configure `onlyOnce`, which
814
+ * then removes the listener after its first invocation.
815
+ * @returns A function that can be invoked to remove the listener.
816
+ */
817
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
818
+ /**
819
+ * Listens for data changes at a particular location.
820
+ *
821
+ * This is the primary way to read data from a Database. Your callback
822
+ * will be triggered for the initial data and again whenever the data changes.
823
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
824
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
825
+ * for more details.
826
+ *
827
+ * An `onChildRemoved` event will be triggered once every time a child is
828
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
829
+ * the child that was removed. A child will get removed when either:
830
+ *
831
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
832
+ * - a client calls `set(null)` on that child or one of its ancestors
833
+ * - that child has all of its children removed
834
+ * - there is a query in effect which now filters out the child (because it's
835
+ * sort order changed or the max limit was hit)
836
+ *
837
+ * @param query - The query to run.
838
+ * @param callback - A callback that fires when the specified event occurs.
839
+ * The callback will be passed a DataSnapshot and a string containing the key of
840
+ * the previous child, by sort order, or `null` if it is the first child.
841
+ * @param cancelCallback - An optional callback that will be notified if your
842
+ * event subscription is ever canceled because your client does not have
843
+ * permission to read this data (or it had permission but has now lost it).
844
+ * This callback will be passed an `Error` object indicating why the failure
845
+ * occurred.
846
+ * @param options - An object that can be used to configure `onlyOnce`, which
847
+ * then removes the listener after its first invocation.
848
+ * @returns A function that can be invoked to remove the listener.
849
+ */
850
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
851
+ export { EventType };
852
+ /**
853
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
854
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
855
+ * the respective `on*` callbacks.
856
+ *
857
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
858
+ * will not automatically remove listeners registered on child nodes, `off()`
859
+ * must also be called on any child listeners to remove the callback.
860
+ *
861
+ * If a callback is not specified, all callbacks for the specified eventType
862
+ * will be removed. Similarly, if no eventType is specified, all callbacks
863
+ * for the `Reference` will be removed.
864
+ *
865
+ * Individual listeners can also be removed by invoking their unsubscribe
866
+ * callbacks.
867
+ *
868
+ * @param query - The query that the listener was registered with.
869
+ * @param eventType - One of the following strings: "value", "child_added",
870
+ * "child_changed", "child_removed", or "child_moved." If omitted, all callbacks
871
+ * for the `Reference` will be removed.
872
+ * @param callback - The callback function that was passed to `on()` or
873
+ * `undefined` to remove all callbacks.
874
+ */
875
+ export declare function off(query: Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
876
+ /** Describes the different query constraints available in this SDK. */
877
+ export type QueryConstraintType = 'endAt' | 'endBefore' | 'startAt' | 'startAfter' | 'limitToFirst' | 'limitToLast' | 'orderByChild' | 'orderByKey' | 'orderByPriority' | 'orderByValue' | 'equalTo';
878
+ /**
879
+ * A `QueryConstraint` is used to narrow the set of documents returned by a
880
+ * Database query. `QueryConstraint`s are created by invoking {@link endAt},
881
+ * {@link endBefore}, {@link startAt}, {@link startAfter}, {@link
882
+ * limitToFirst}, {@link limitToLast}, {@link orderByChild},
883
+ * {@link orderByChild}, {@link orderByKey} , {@link orderByPriority} ,
884
+ * {@link orderByValue} or {@link equalTo} and
885
+ * can then be passed to {@link query} to create a new query instance that
886
+ * also contains this `QueryConstraint`.
887
+ */
888
+ export declare abstract class QueryConstraint {
889
+ /** The type of this query constraints */
890
+ abstract readonly type: QueryConstraintType;
891
+ /**
892
+ * Takes the provided `Query` and returns a copy of the `Query` with this
893
+ * `QueryConstraint` applied.
894
+ */
895
+ abstract _apply<T>(query: QueryImpl): QueryImpl;
896
+ }
897
+ /**
898
+ * Creates a `QueryConstraint` with the specified ending point.
899
+ *
900
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
901
+ * allows you to choose arbitrary starting and ending points for your queries.
902
+ *
903
+ * The ending point is inclusive, so children with exactly the specified value
904
+ * will be included in the query. The optional key argument can be used to
905
+ * further limit the range of the query. If it is specified, then children that
906
+ * have exactly the specified value must also have a key name less than or equal
907
+ * to the specified key.
908
+ *
909
+ * You can read more about `endAt()` in
910
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
911
+ *
912
+ * @param value - The value to end at. The argument type depends on which
913
+ * `orderBy*()` function was used in this query. Specify a value that matches
914
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
915
+ * value must be a string.
916
+ * @param key - The child key to end at, among the children with the previously
917
+ * specified priority. This argument is only allowed if ordering by child,
918
+ * value, or priority.
919
+ */
920
+ export declare function endAt(value: number | string | boolean | null, key?: string): QueryConstraint;
921
+ /**
922
+ * Creates a `QueryConstraint` with the specified ending point (exclusive).
923
+ *
924
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
925
+ * allows you to choose arbitrary starting and ending points for your queries.
926
+ *
927
+ * The ending point is exclusive. If only a value is provided, children
928
+ * with a value less than the specified value will be included in the query.
929
+ * If a key is specified, then children must have a value less than or equal
930
+ * to the specified value and a key name less than the specified key.
931
+ *
932
+ * @param value - The value to end before. The argument type depends on which
933
+ * `orderBy*()` function was used in this query. Specify a value that matches
934
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
935
+ * value must be a string.
936
+ * @param key - The child key to end before, among the children with the
937
+ * previously specified priority. This argument is only allowed if ordering by
938
+ * child, value, or priority.
939
+ */
940
+ export declare function endBefore(value: number | string | boolean | null, key?: string): QueryConstraint;
941
+ /**
942
+ * Creates a `QueryConstraint` with the specified starting point.
943
+ *
944
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
945
+ * allows you to choose arbitrary starting and ending points for your queries.
946
+ *
947
+ * The starting point is inclusive, so children with exactly the specified value
948
+ * will be included in the query. The optional key argument can be used to
949
+ * further limit the range of the query. If it is specified, then children that
950
+ * have exactly the specified value must also have a key name greater than or
951
+ * equal to the specified key.
952
+ *
953
+ * You can read more about `startAt()` in
954
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
955
+ *
956
+ * @param value - The value to start at. The argument type depends on which
957
+ * `orderBy*()` function was used in this query. Specify a value that matches
958
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
959
+ * value must be a string.
960
+ * @param key - The child key to start at. This argument is only allowed if
961
+ * ordering by child, value, or priority.
962
+ */
963
+ export declare function startAt(value?: number | string | boolean | null, key?: string): QueryConstraint;
964
+ /**
965
+ * Creates a `QueryConstraint` with the specified starting point (exclusive).
966
+ *
967
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
968
+ * allows you to choose arbitrary starting and ending points for your queries.
969
+ *
970
+ * The starting point is exclusive. If only a value is provided, children
971
+ * with a value greater than the specified value will be included in the query.
972
+ * If a key is specified, then children must have a value greater than or equal
973
+ * to the specified value and a a key name greater than the specified key.
974
+ *
975
+ * @param value - The value to start after. The argument type depends on which
976
+ * `orderBy*()` function was used in this query. Specify a value that matches
977
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
978
+ * value must be a string.
979
+ * @param key - The child key to start after. This argument is only allowed if
980
+ * ordering by child, value, or priority.
981
+ */
982
+ export declare function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
983
+ /**
984
+ * Creates a new `QueryConstraint` that if limited to the first specific number
985
+ * of children.
986
+ *
987
+ * The `limitToFirst()` method is used to set a maximum number of children to be
988
+ * synced for a given callback. If we set a limit of 100, we will initially only
989
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
990
+ * stored in our Database, a `child_added` event will fire for each message.
991
+ * However, if we have over 100 messages, we will only receive a `child_added`
992
+ * event for the first 100 ordered messages. As items change, we will receive
993
+ * `child_removed` events for each item that drops out of the active list so
994
+ * that the total number stays at 100.
995
+ *
996
+ * You can read more about `limitToFirst()` in
997
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
998
+ *
999
+ * @param limit - The maximum number of nodes to include in this query.
1000
+ */
1001
+ export declare function limitToFirst(limit: number): QueryConstraint;
1002
+ /**
1003
+ * Creates a new `QueryConstraint` that is limited to return only the last
1004
+ * specified number of children.
1005
+ *
1006
+ * The `limitToLast()` method is used to set a maximum number of children to be
1007
+ * synced for a given callback. If we set a limit of 100, we will initially only
1008
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
1009
+ * stored in our Database, a `child_added` event will fire for each message.
1010
+ * However, if we have over 100 messages, we will only receive a `child_added`
1011
+ * event for the last 100 ordered messages. As items change, we will receive
1012
+ * `child_removed` events for each item that drops out of the active list so
1013
+ * that the total number stays at 100.
1014
+ *
1015
+ * You can read more about `limitToLast()` in
1016
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
1017
+ *
1018
+ * @param limit - The maximum number of nodes to include in this query.
1019
+ */
1020
+ export declare function limitToLast(limit: number): QueryConstraint;
1021
+ /**
1022
+ * Creates a new `QueryConstraint` that orders by the specified child key.
1023
+ *
1024
+ * Queries can only order by one key at a time. Calling `orderByChild()`
1025
+ * multiple times on the same query is an error.
1026
+ *
1027
+ * Firebase queries allow you to order your data by any child key on the fly.
1028
+ * However, if you know in advance what your indexes will be, you can define
1029
+ * them via the .indexOn rule in your Security Rules for better performance. See
1030
+ * the{@link https://firebase.google.com/docs/database/security/indexing-data}
1031
+ * rule for more information.
1032
+ *
1033
+ * You can read more about `orderByChild()` in
1034
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1035
+ *
1036
+ * @param path - The path to order by.
1037
+ */
1038
+ export declare function orderByChild(path: string): QueryConstraint;
1039
+ /**
1040
+ * Creates a new `QueryConstraint` that orders by the key.
1041
+ *
1042
+ * Sorts the results of a query by their (ascending) key values.
1043
+ *
1044
+ * You can read more about `orderByKey()` in
1045
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1046
+ */
1047
+ export declare function orderByKey(): QueryConstraint;
1048
+ /**
1049
+ * Creates a new `QueryConstraint` that orders by priority.
1050
+ *
1051
+ * Applications need not use priority but can order collections by
1052
+ * ordinary properties (see
1053
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}
1054
+ * for alternatives to priority.
1055
+ */
1056
+ export declare function orderByPriority(): QueryConstraint;
1057
+ /**
1058
+ * Creates a new `QueryConstraint` that orders by value.
1059
+ *
1060
+ * If the children of a query are all scalar values (string, number, or
1061
+ * boolean), you can order the results by their (ascending) values.
1062
+ *
1063
+ * You can read more about `orderByValue()` in
1064
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1065
+ */
1066
+ export declare function orderByValue(): QueryConstraint;
1067
+ /**
1068
+ * Creates a `QueryConstraint` that includes children that match the specified
1069
+ * value.
1070
+ *
1071
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
1072
+ * allows you to choose arbitrary starting and ending points for your queries.
1073
+ *
1074
+ * The optional key argument can be used to further limit the range of the
1075
+ * query. If it is specified, then children that have exactly the specified
1076
+ * value must also have exactly the specified key as their key name. This can be
1077
+ * used to filter result sets with many matches for the same value.
1078
+ *
1079
+ * You can read more about `equalTo()` in
1080
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
1081
+ *
1082
+ * @param value - The value to match for. The argument type depends on which
1083
+ * `orderBy*()` function was used in this query. Specify a value that matches
1084
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
1085
+ * value must be a string.
1086
+ * @param key - The child key to start at, among the children with the
1087
+ * previously specified priority. This argument is only allowed if ordering by
1088
+ * child, value, or priority.
1089
+ */
1090
+ export declare function equalTo(value: number | string | boolean | null, key?: string): QueryConstraint;
1091
+ /**
1092
+ * Creates a new immutable instance of `Query` that is extended to also include
1093
+ * additional query constraints.
1094
+ *
1095
+ * @param query - The Query instance to use as a base for the new constraints.
1096
+ * @param queryConstraints - The list of `QueryConstraint`s to apply.
1097
+ * @throws if any of the provided query constraints cannot be combined with the
1098
+ * existing or new constraints.
1099
+ */
1100
+ export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;