@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,2991 @@
1
+ /**
2
+ * Firebase Realtime Database
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
8
+ import { AppCheckTokenListener } from '@firebase/app-check-interop-types';
9
+ import { AppCheckTokenResult } from '@firebase/app-check-interop-types';
10
+ import { EmulatorMockTokenOptions } from '@firebase/util';
11
+ import { FirebaseApp } from '@firebase/app';
12
+ import { FirebaseApp as FirebaseApp_2 } from '@firebase/app-types';
13
+ import { FirebaseAppCheckInternal } from '@firebase/app-check-interop-types';
14
+ import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
15
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
16
+ import { FirebaseAuthTokenData } from '@firebase/app-types/private';
17
+ import { _FirebaseService } from '@firebase/app';
18
+ import { Provider } from '@firebase/component';
19
+
20
+ /**
21
+ * Abstraction around AppCheck's token fetching capabilities.
22
+ */
23
+ declare class AppCheckTokenProvider {
24
+ private appCheckProvider?;
25
+ private appCheck?;
26
+ private serverAppAppCheckToken?;
27
+ private appName;
28
+ constructor(app: FirebaseApp, appCheckProvider?: Provider<AppCheckInternalComponentName>);
29
+ getToken(forceRefresh?: boolean): Promise<AppCheckTokenResult>;
30
+ addTokenChangeListener(listener: AppCheckTokenListener): void;
31
+ notifyForInvalidToken(): void;
32
+ }
33
+
34
+ declare interface AuthTokenProvider {
35
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
36
+ addTokenChangeListener(listener: (token: string | null) => void): void;
37
+ removeTokenChangeListener(listener: (token: string | null) => void): void;
38
+ notifyForInvalidToken(): void;
39
+ }
40
+
41
+ /**
42
+ * A cache node only stores complete children. Additionally it holds a flag whether the node can be considered fully
43
+ * initialized in the sense that we know at one point in time this represented a valid state of the world, e.g.
44
+ * initialized with data from the server, or a complete overwrite by the client. The filtered flag also tracks
45
+ * whether a node potentially had children removed due to a filter.
46
+ */
47
+ declare class CacheNode {
48
+ private node_;
49
+ private fullyInitialized_;
50
+ private filtered_;
51
+ constructor(node_: Node_2, fullyInitialized_: boolean, filtered_: boolean);
52
+ /**
53
+ * Returns whether this node was fully initialized with either server data or a complete overwrite by the client
54
+ */
55
+ isFullyInitialized(): boolean;
56
+ /**
57
+ * Returns whether this node is potentially missing children due to a filter applied to the node
58
+ */
59
+ isFiltered(): boolean;
60
+ isCompleteForPath(path: Path): boolean;
61
+ isCompleteForChild(key: string): boolean;
62
+ getNode(): Node_2;
63
+ }
64
+
65
+ declare class CancelEvent implements Event_2 {
66
+ eventRegistration: EventRegistration;
67
+ error: Error;
68
+ path: Path;
69
+ constructor(eventRegistration: EventRegistration, error: Error, path: Path);
70
+ getPath(): Path;
71
+ getEventType(): string;
72
+ getEventRunner(): () => void;
73
+ toString(): string;
74
+ }
75
+
76
+ declare interface Change {
77
+ /** @param type - The event type */
78
+ type: ChangeType;
79
+ /** @param snapshotNode - The data */
80
+ snapshotNode: Node_2;
81
+ /** @param childName - The name for this child, if it's a child even */
82
+ childName?: string;
83
+ /** @param oldSnap - Used for intermediate processing of child changed events */
84
+ oldSnap?: Node_2;
85
+ /** * @param prevName - The name for the previous child, if applicable */
86
+ prevName?: string | null;
87
+ }
88
+
89
+ declare const enum ChangeType {
90
+ /** Event type for a child added */
91
+ CHILD_ADDED = "child_added",
92
+ /** Event type for a child removed */
93
+ CHILD_REMOVED = "child_removed",
94
+ /** Event type for a child changed */
95
+ CHILD_CHANGED = "child_changed",
96
+ /** Event type for a child moved */
97
+ CHILD_MOVED = "child_moved",
98
+ /** Event type for a value change */
99
+ VALUE = "value"
100
+ }
101
+
102
+ /**
103
+ * Gets a `Reference` for the location at the specified relative path.
104
+ *
105
+ * The relative path can either be a simple child name (for example, "ada") or
106
+ * a deeper slash-separated path (for example, "ada/name/first").
107
+ *
108
+ * @param parent - The parent location.
109
+ * @param path - A relative path from this location to the desired child
110
+ * location.
111
+ * @returns The specified child location.
112
+ */
113
+ export declare function child(parent: DatabaseReference, path: string): DatabaseReference;
114
+
115
+ declare class ChildChangeAccumulator {
116
+ private readonly changeMap;
117
+ trackChildChange(change: Change): void;
118
+ getChanges(): Change[];
119
+ }
120
+
121
+ /**
122
+ * @license
123
+ * Copyright 2017 Google LLC
124
+ *
125
+ * Licensed under the Apache License, Version 2.0 (the "License");
126
+ * you may not use this file except in compliance with the License.
127
+ * You may obtain a copy of the License at
128
+ *
129
+ * http://www.apache.org/licenses/LICENSE-2.0
130
+ *
131
+ * Unless required by applicable law or agreed to in writing, software
132
+ * distributed under the License is distributed on an "AS IS" BASIS,
133
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
134
+ * See the License for the specific language governing permissions and
135
+ * limitations under the License.
136
+ */
137
+ /**
138
+ * @fileoverview Implementation of an immutable SortedMap using a Left-leaning
139
+ * Red-Black Tree, adapted from the implementation in Mugs
140
+ * (http://mads379.github.com/mugs/) by Mads Hartmann Jensen
141
+ * (mads379\@gmail.com).
142
+ *
143
+ * Original paper on Left-leaning Red-Black Trees:
144
+ * http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
145
+ *
146
+ * Invariant 1: No red node has a red child
147
+ * Invariant 2: Every leaf path has the same number of black nodes
148
+ * Invariant 3: Only the left child can be red (left leaning)
149
+ */
150
+ declare type Comparator<K> = (key1: K, key2: K) => number;
151
+
152
+ /**
153
+ * Since updates to filtered nodes might require nodes to be pulled in from "outside" the node, this interface
154
+ * can help to get complete children that can be pulled in.
155
+ * A class implementing this interface takes potentially multiple sources (e.g. user writes, server data from
156
+ * other views etc.) to try it's best to get a complete child that might be useful in pulling into the view.
157
+ *
158
+ * @interface
159
+ */
160
+ declare interface CompleteChildSource {
161
+ getCompleteChild(childKey: string): Node_2 | null;
162
+ getChildAfterChild(index: Index, child: NamedNode, reverse: boolean): NamedNode | null;
163
+ }
164
+
165
+ /**
166
+ * This class holds a collection of writes that can be applied to nodes in unison. It abstracts away the logic with
167
+ * dealing with priority writes and multiple nested writes. At any given path there is only allowed to be one write
168
+ * modifying that path. Any write to an existing path or shadowing an existing path will modify that existing write
169
+ * to reflect the write added.
170
+ */
171
+ declare class CompoundWrite {
172
+ writeTree_: ImmutableTree<Node_2>;
173
+ constructor(writeTree_: ImmutableTree<Node_2>);
174
+ static empty(): CompoundWrite;
175
+ }
176
+
177
+ /**
178
+ * Modify the provided instance to communicate with the Realtime Database
179
+ * emulator.
180
+ *
181
+ * <p>Note: This method must be called before performing any other operation.
182
+ *
183
+ * @param db - The instance to modify.
184
+ * @param host - The emulator host (ex: localhost)
185
+ * @param port - The emulator port (ex: 8080)
186
+ * @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
187
+ */
188
+ export declare function connectDatabaseEmulator(db: Database, host: string, port: number, options?: {
189
+ mockUserToken?: EmulatorMockTokenOptions | string;
190
+ }): void;
191
+
192
+ /**
193
+ * Class representing a Firebase Realtime Database.
194
+ */
195
+ export declare class Database implements _FirebaseService {
196
+ _repoInternal: Repo;
197
+ /** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
198
+ readonly app: FirebaseApp;
199
+ /** Represents a `Database` instance. */
200
+ readonly 'type' = "database";
201
+ /** Track if the instance has been used (root or repo accessed) */
202
+ _instanceStarted: boolean;
203
+ /** Backing state for root_ */
204
+ private _rootInternal?;
205
+ /** @hideconstructor */
206
+ constructor(_repoInternal: Repo,
207
+ /** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
208
+ app: FirebaseApp);
209
+ get _repo(): Repo;
210
+ get _root(): _ReferenceImpl;
211
+ _delete(): Promise<void>;
212
+ _checkNotDeleted(apiName: string): void;
213
+ }
214
+
215
+ /**
216
+ * A `DatabaseReference` represents a specific location in your Database and can be used
217
+ * for reading or writing data to that Database location.
218
+ *
219
+ * You can reference the root or child location in your Database by calling
220
+ * `ref()` or `ref("child/path")`.
221
+ *
222
+ * Writing is done with the `set()` method and reading can be done with the
223
+ * `on*()` method. See {@link
224
+ * https://firebase.google.com/docs/database/web/read-and-write}
225
+ */
226
+ export declare interface DatabaseReference extends Query {
227
+ /**
228
+ * The last part of the `DatabaseReference`'s path.
229
+ *
230
+ * For example, `"ada"` is the key for
231
+ * `https://<DATABASE_NAME>.firebaseio.com/users/ada`.
232
+ *
233
+ * The key of a root `DatabaseReference` is `null`.
234
+ */
235
+ readonly key: string | null;
236
+ /**
237
+ * The parent location of a `DatabaseReference`.
238
+ *
239
+ * The parent of a root `DatabaseReference` is `null`.
240
+ */
241
+ readonly parent: DatabaseReference | null;
242
+ /** The root `DatabaseReference` of the Database. */
243
+ readonly root: DatabaseReference;
244
+ }
245
+
246
+ /**
247
+ * A `DataSnapshot` contains data from a Database location.
248
+ *
249
+ * Any time you read data from the Database, you receive the data as a
250
+ * `DataSnapshot`. A `DataSnapshot` is passed to the event callbacks you attach
251
+ * with `on()` or `once()`. You can extract the contents of the snapshot as a
252
+ * JavaScript object by calling the `val()` method. Alternatively, you can
253
+ * traverse into the snapshot by calling `child()` to return child snapshots
254
+ * (which you could then call `val()` on).
255
+ *
256
+ * A `DataSnapshot` is an efficiently generated, immutable copy of the data at
257
+ * a Database location. It cannot be modified and will never change (to modify
258
+ * data, you always call the `set()` method on a `Reference` directly).
259
+ */
260
+ export declare class DataSnapshot {
261
+ readonly _node: Node_2;
262
+ /**
263
+ * The location of this DataSnapshot.
264
+ */
265
+ readonly ref: DatabaseReference;
266
+ readonly _index: Index;
267
+ /**
268
+ * @param _node - A SnapshotNode to wrap.
269
+ * @param ref - The location this snapshot came from.
270
+ * @param _index - The iteration order for this snapshot
271
+ * @hideconstructor
272
+ */
273
+ constructor(_node: Node_2,
274
+ /**
275
+ * The location of this DataSnapshot.
276
+ */
277
+ ref: DatabaseReference, _index: Index);
278
+ /**
279
+ * Gets the priority value of the data in this `DataSnapshot`.
280
+ *
281
+ * Applications need not use priority but can order collections by
282
+ * ordinary properties (see
283
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data |Sorting and filtering data}
284
+ * ).
285
+ */
286
+ get priority(): string | number | null;
287
+ /**
288
+ * The key (last part of the path) of the location of this `DataSnapshot`.
289
+ *
290
+ * The last token in a Database location is considered its key. For example,
291
+ * "ada" is the key for the /users/ada/ node. Accessing the key on any
292
+ * `DataSnapshot` will return the key for the location that generated it.
293
+ * However, accessing the key on the root URL of a Database will return
294
+ * `null`.
295
+ */
296
+ get key(): string | null;
297
+ /** Returns the number of child properties of this `DataSnapshot`. */
298
+ get size(): number;
299
+ /**
300
+ * Gets another `DataSnapshot` for the location at the specified relative path.
301
+ *
302
+ * Passing a relative path to the `child()` method of a DataSnapshot returns
303
+ * another `DataSnapshot` for the location at the specified relative path. The
304
+ * relative path can either be a simple child name (for example, "ada") or a
305
+ * deeper, slash-separated path (for example, "ada/name/first"). If the child
306
+ * location has no data, an empty `DataSnapshot` (that is, a `DataSnapshot`
307
+ * whose value is `null`) is returned.
308
+ *
309
+ * @param path - A relative path to the location of child data.
310
+ */
311
+ child(path: string): DataSnapshot;
312
+ /**
313
+ * Returns true if this `DataSnapshot` contains any data. It is slightly more
314
+ * efficient than using `snapshot.val() !== null`.
315
+ */
316
+ exists(): boolean;
317
+ /**
318
+ * Exports the entire contents of the DataSnapshot as a JavaScript object.
319
+ *
320
+ * The `exportVal()` method is similar to `val()`, except priority information
321
+ * is included (if available), making it suitable for backing up your data.
322
+ *
323
+ * @returns The DataSnapshot's contents as a JavaScript value (Object,
324
+ * Array, string, number, boolean, or `null`).
325
+ */
326
+ exportVal(): any;
327
+ /**
328
+ * Enumerates the top-level children in the `IteratedDataSnapshot`.
329
+ *
330
+ * Because of the way JavaScript objects work, the ordering of data in the
331
+ * JavaScript object returned by `val()` is not guaranteed to match the
332
+ * ordering on the server nor the ordering of `onChildAdded()` events. That is
333
+ * where `forEach()` comes in handy. It guarantees the children of a
334
+ * `DataSnapshot` will be iterated in their query order.
335
+ *
336
+ * If no explicit `orderBy*()` method is used, results are returned
337
+ * ordered by key (unless priorities are used, in which case, results are
338
+ * returned by priority).
339
+ *
340
+ * @param action - A function that will be called for each child DataSnapshot.
341
+ * The callback can return true to cancel further enumeration.
342
+ * @returns true if enumeration was canceled due to your callback returning
343
+ * true.
344
+ */
345
+ forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean;
346
+ /**
347
+ * Returns true if the specified child path has (non-null) data.
348
+ *
349
+ * @param path - A relative path to the location of a potential child.
350
+ * @returns `true` if data exists at the specified child path; else
351
+ * `false`.
352
+ */
353
+ hasChild(path: string): boolean;
354
+ /**
355
+ * Returns whether or not the `DataSnapshot` has any non-`null` child
356
+ * properties.
357
+ *
358
+ * You can use `hasChildren()` to determine if a `DataSnapshot` has any
359
+ * children. If it does, you can enumerate them using `forEach()`. If it
360
+ * doesn't, then either this snapshot contains a primitive value (which can be
361
+ * retrieved with `val()`) or it is empty (in which case, `val()` will return
362
+ * `null`).
363
+ *
364
+ * @returns true if this snapshot has any children; else false.
365
+ */
366
+ hasChildren(): boolean;
367
+ /**
368
+ * Returns a JSON-serializable representation of this object.
369
+ */
370
+ toJSON(): object | null;
371
+ /**
372
+ * Extracts a JavaScript value from a `DataSnapshot`.
373
+ *
374
+ * Depending on the data in a `DataSnapshot`, the `val()` method may return a
375
+ * scalar type (string, number, or boolean), an array, or an object. It may
376
+ * also return null, indicating that the `DataSnapshot` is empty (contains no
377
+ * data).
378
+ *
379
+ * @returns The DataSnapshot's contents as a JavaScript value (Object,
380
+ * Array, string, number, boolean, or `null`).
381
+ */
382
+ val(): any;
383
+ }
384
+ export { EmulatorMockTokenOptions }
385
+
386
+ /**
387
+ * Logs debugging information to the console.
388
+ *
389
+ * @param enabled - Enables logging if `true`, disables logging if `false`.
390
+ * @param persistent - Remembers the logging state between page refreshes if
391
+ * `true`.
392
+ */
393
+ export declare function enableLogging(enabled: boolean, persistent?: boolean): any;
394
+
395
+ /**
396
+ * Logs debugging information to the console.
397
+ *
398
+ * @param logger - A custom logger function to control how things get logged.
399
+ */
400
+ export declare function enableLogging(logger: (message: string) => unknown): any;
401
+
402
+ /**
403
+ * Creates a `QueryConstraint` with the specified ending point.
404
+ *
405
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
406
+ * allows you to choose arbitrary starting and ending points for your queries.
407
+ *
408
+ * The ending point is inclusive, so children with exactly the specified value
409
+ * will be included in the query. The optional key argument can be used to
410
+ * further limit the range of the query. If it is specified, then children that
411
+ * have exactly the specified value must also have a key name less than or equal
412
+ * to the specified key.
413
+ *
414
+ * You can read more about `endAt()` in
415
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
416
+ *
417
+ * @param value - The value to end at. The argument type depends on which
418
+ * `orderBy*()` function was used in this query. Specify a value that matches
419
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
420
+ * value must be a string.
421
+ * @param key - The child key to end at, among the children with the previously
422
+ * specified priority. This argument is only allowed if ordering by child,
423
+ * value, or priority.
424
+ */
425
+ export declare function endAt(value: number | string | boolean | null, key?: string): QueryConstraint;
426
+
427
+ /**
428
+ * Creates a `QueryConstraint` with the specified ending point (exclusive).
429
+ *
430
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
431
+ * allows you to choose arbitrary starting and ending points for your queries.
432
+ *
433
+ * The ending point is exclusive. If only a value is provided, children
434
+ * with a value less than the specified value will be included in the query.
435
+ * If a key is specified, then children must have a value less than or equal
436
+ * to the specified value and a key name less than the specified key.
437
+ *
438
+ * @param value - The value to end before. The argument type depends on which
439
+ * `orderBy*()` function was used in this query. Specify a value that matches
440
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
441
+ * value must be a string.
442
+ * @param key - The child key to end before, among the children with the
443
+ * previously specified priority. This argument is only allowed if ordering by
444
+ * child, value, or priority.
445
+ */
446
+ export declare function endBefore(value: number | string | boolean | null, key?: string): QueryConstraint;
447
+
448
+ /**
449
+ * Creates a `QueryConstraint` that includes children that match the specified
450
+ * value.
451
+ *
452
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
453
+ * allows you to choose arbitrary starting and ending points for your queries.
454
+ *
455
+ * The optional key argument can be used to further limit the range of the
456
+ * query. If it is specified, then children that have exactly the specified
457
+ * value must also have exactly the specified key as their key name. This can be
458
+ * used to filter result sets with many matches for the same value.
459
+ *
460
+ * You can read more about `equalTo()` in
461
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
462
+ *
463
+ * @param value - The value to match for. The argument type depends on which
464
+ * `orderBy*()` function was used in this query. Specify a value that matches
465
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
466
+ * value must be a string.
467
+ * @param key - The child key to start at, among the children with the
468
+ * previously specified priority. This argument is only allowed if ordering by
469
+ * child, value, or priority.
470
+ */
471
+ export declare function equalTo(value: number | string | boolean | null, key?: string): QueryConstraint;
472
+
473
+ /**
474
+ * Encapsulates the data needed to raise an event
475
+ * @interface
476
+ */
477
+ declare interface Event_2 {
478
+ getPath(): Path;
479
+ getEventType(): string;
480
+ getEventRunner(): () => void;
481
+ toString(): string;
482
+ }
483
+
484
+ /**
485
+ * An EventGenerator is used to convert "raw" changes (Change) as computed by the
486
+ * CacheDiffer into actual events (Event) that can be raised. See generateEventsForChanges()
487
+ * for details.
488
+ *
489
+ */
490
+ declare class EventGenerator {
491
+ query_: QueryContext;
492
+ index_: Index;
493
+ constructor(query_: QueryContext);
494
+ }
495
+
496
+ declare interface EventList {
497
+ events: Event_2[];
498
+ path: Path;
499
+ }
500
+
501
+ /**
502
+ * The event queue serves a few purposes:
503
+ * 1. It ensures we maintain event order in the face of event callbacks doing operations that result in more
504
+ * events being queued.
505
+ * 2. raiseQueuedEvents() handles being called reentrantly nicely. That is, if in the course of raising events,
506
+ * raiseQueuedEvents() is called again, the "inner" call will pick up raising events where the "outer" call
507
+ * left off, ensuring that the events are still raised synchronously and in order.
508
+ * 3. You can use raiseEventsAtPath and raiseEventsForChangedPath to ensure only relevant previously-queued
509
+ * events are raised synchronously.
510
+ *
511
+ * NOTE: This can all go away if/when we move to async events.
512
+ *
513
+ */
514
+ declare class EventQueue {
515
+ eventLists_: EventList[];
516
+ /**
517
+ * Tracks recursion depth of raiseQueuedEvents_, for debugging purposes.
518
+ */
519
+ recursionDepth_: number;
520
+ }
521
+
522
+ /**
523
+ * An EventRegistration is basically an event type ('value', 'child_added', etc.) and a callback
524
+ * to be notified of that type of event.
525
+ *
526
+ * That said, it can also contain a cancel callback to be notified if the event is canceled. And
527
+ * currently, this code is organized around the idea that you would register multiple child_ callbacks
528
+ * together, as a single EventRegistration. Though currently we don't do that.
529
+ */
530
+ declare interface EventRegistration {
531
+ /**
532
+ * True if this container has a callback to trigger for this event type
533
+ */
534
+ respondsTo(eventType: string): boolean;
535
+ createEvent(change: Change, query: QueryContext): Event_2;
536
+ /**
537
+ * Given event data, return a function to trigger the user's callback
538
+ */
539
+ getEventRunner(eventData: Event_2): () => void;
540
+ createCancelEvent(error: Error, path: Path): CancelEvent | null;
541
+ matches(other: EventRegistration): boolean;
542
+ /**
543
+ * False basically means this is a "dummy" callback container being used as a sentinel
544
+ * to remove all callback containers of a particular type. (e.g. if the user does
545
+ * ref.off('value') without specifying a specific callback).
546
+ *
547
+ * (TODO: Rework this, since it's hacky)
548
+ *
549
+ */
550
+ hasAnyCallback(): boolean;
551
+ }
552
+
553
+ /**
554
+ * One of the following strings: "value", "child_added", "child_changed",
555
+ * "child_removed", or "child_moved."
556
+ */
557
+ export declare type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
558
+
559
+ /**
560
+ * Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
561
+ */
562
+ export declare function forceLongPolling(): void;
563
+
564
+ /**
565
+ * Force the use of websockets instead of longPolling.
566
+ */
567
+ export declare function forceWebSockets(): void;
568
+
569
+ /**
570
+ * Gets the most up-to-date result for this query.
571
+ *
572
+ * @param query - The query to run.
573
+ * @returns A `Promise` which resolves to the resulting DataSnapshot if a value is
574
+ * available, or rejects if the client is unable to return a value (e.g., if the
575
+ * server is unreachable and there is nothing cached).
576
+ */
577
+ export declare function get(query: Query): Promise<DataSnapshot>;
578
+
579
+ /**
580
+ * Returns the instance of the Realtime Database SDK that is associated with the provided
581
+ * {@link @firebase/app#FirebaseApp}. Initializes a new instance with default settings if
582
+ * no instance exists or if the existing instance uses a custom database URL.
583
+ *
584
+ * @param app - The {@link @firebase/app#FirebaseApp} instance that the returned Realtime
585
+ * Database instance is associated with.
586
+ * @param url - The URL of the Realtime Database instance to connect to. If not
587
+ * provided, the SDK connects to the default instance of the Firebase App.
588
+ * @returns The `Database` instance of the provided app.
589
+ */
590
+ export declare function getDatabase(app?: FirebaseApp, url?: string): Database;
591
+
592
+ /**
593
+ * Disconnects from the server (all Database operations will be completed
594
+ * offline).
595
+ *
596
+ * The client automatically maintains a persistent connection to the Database
597
+ * server, which will remain active indefinitely and reconnect when
598
+ * disconnected. However, the `goOffline()` and `goOnline()` methods may be used
599
+ * to control the client connection in cases where a persistent connection is
600
+ * undesirable.
601
+ *
602
+ * While offline, the client will no longer receive data updates from the
603
+ * Database. However, all Database operations performed locally will continue to
604
+ * immediately fire events, allowing your application to continue behaving
605
+ * normally. Additionally, each operation performed locally will automatically
606
+ * be queued and retried upon reconnection to the Database server.
607
+ *
608
+ * To reconnect to the Database and begin receiving remote events, see
609
+ * `goOnline()`.
610
+ *
611
+ * @param db - The instance to disconnect.
612
+ */
613
+ export declare function goOffline(db: Database): void;
614
+
615
+ /**
616
+ * Reconnects to the server and synchronizes the offline Database state
617
+ * with the server state.
618
+ *
619
+ * This method should be used after disabling the active connection with
620
+ * `goOffline()`. Once reconnected, the client will transmit the proper data
621
+ * and fire the appropriate events so that your client "catches up"
622
+ * automatically.
623
+ *
624
+ * @param db - The instance to reconnect.
625
+ */
626
+ export declare function goOnline(db: Database): void;
627
+
628
+ /**
629
+ * A tree with immutable elements.
630
+ */
631
+ declare class ImmutableTree<T> {
632
+ readonly value: T | null;
633
+ readonly children: SortedMap<string, ImmutableTree<T>>;
634
+ static fromObject<T>(obj: {
635
+ [k: string]: T;
636
+ }): ImmutableTree<T>;
637
+ constructor(value: T | null, children?: SortedMap<string, ImmutableTree<T>>);
638
+ /**
639
+ * True if the value is empty and there are no children
640
+ */
641
+ isEmpty(): boolean;
642
+ /**
643
+ * Given a path and predicate, return the first node and the path to that node
644
+ * where the predicate returns true.
645
+ *
646
+ * TODO Do a perf test -- If we're creating a bunch of `{path: value:}`
647
+ * objects on the way back out, it may be better to pass down a pathSoFar obj.
648
+ *
649
+ * @param relativePath - The remainder of the path
650
+ * @param predicate - The predicate to satisfy to return a node
651
+ */
652
+ findRootMostMatchingPathAndValue(relativePath: Path, predicate: (a: T) => boolean): {
653
+ path: Path;
654
+ value: T;
655
+ } | null;
656
+ /**
657
+ * Find, if it exists, the shortest subpath of the given path that points a defined
658
+ * value in the tree
659
+ */
660
+ findRootMostValueAndPath(relativePath: Path): {
661
+ path: Path;
662
+ value: T;
663
+ } | null;
664
+ /**
665
+ * @returns The subtree at the given path
666
+ */
667
+ subtree(relativePath: Path): ImmutableTree<T>;
668
+ /**
669
+ * Sets a value at the specified path.
670
+ *
671
+ * @param relativePath - Path to set value at.
672
+ * @param toSet - Value to set.
673
+ * @returns Resulting tree.
674
+ */
675
+ set(relativePath: Path, toSet: T | null): ImmutableTree<T>;
676
+ /**
677
+ * Removes the value at the specified path.
678
+ *
679
+ * @param relativePath - Path to value to remove.
680
+ * @returns Resulting tree.
681
+ */
682
+ remove(relativePath: Path): ImmutableTree<T>;
683
+ /**
684
+ * Gets a value from the tree.
685
+ *
686
+ * @param relativePath - Path to get value for.
687
+ * @returns Value at path, or null.
688
+ */
689
+ get(relativePath: Path): T | null;
690
+ /**
691
+ * Replace the subtree at the specified path with the given new tree.
692
+ *
693
+ * @param relativePath - Path to replace subtree for.
694
+ * @param newTree - New tree.
695
+ * @returns Resulting tree.
696
+ */
697
+ setTree(relativePath: Path, newTree: ImmutableTree<T>): ImmutableTree<T>;
698
+ /**
699
+ * Performs a depth first fold on this tree. Transforms a tree into a single
700
+ * value, given a function that operates on the path to a node, an optional
701
+ * current value, and a map of child names to folded subtrees
702
+ */
703
+ fold<V>(fn: (path: Path, value: T, children: {
704
+ [k: string]: V;
705
+ }) => V): V;
706
+ /**
707
+ * Recursive helper for public-facing fold() method
708
+ */
709
+ private fold_;
710
+ /**
711
+ * Find the first matching value on the given path. Return the result of applying f to it.
712
+ */
713
+ findOnPath<V>(path: Path, f: (path: Path, value: T) => V | null): V | null;
714
+ private findOnPath_;
715
+ foreachOnPath(path: Path, f: (path: Path, value: T) => void): ImmutableTree<T>;
716
+ private foreachOnPath_;
717
+ /**
718
+ * Calls the given function for each node in the tree that has a value.
719
+ *
720
+ * @param f - A function to be called with the path from the root of the tree to
721
+ * a node, and the value at that node. Called in depth-first order.
722
+ */
723
+ foreach(f: (path: Path, value: T) => void): void;
724
+ private foreach_;
725
+ foreachChild(f: (name: string, value: T) => void): void;
726
+ }
727
+
728
+ /**
729
+ * Returns a placeholder value that can be used to atomically increment the
730
+ * current database value by the provided delta.
731
+ *
732
+ * @param delta - the amount to modify the current value atomically.
733
+ * @returns A placeholder value for modifying data atomically server-side.
734
+ */
735
+ export declare function increment(delta: number): object;
736
+
737
+ declare abstract class Index {
738
+ abstract compare(a: NamedNode, b: NamedNode): number;
739
+ abstract isDefinedOn(node: Node_2): boolean;
740
+ /**
741
+ * @returns A standalone comparison function for
742
+ * this index
743
+ */
744
+ getCompare(): Comparator<NamedNode>;
745
+ /**
746
+ * Given a before and after value for a node, determine if the indexed value has changed. Even if they are different,
747
+ * it's possible that the changes are isolated to parts of the snapshot that are not indexed.
748
+ *
749
+ *
750
+ * @returns True if the portion of the snapshot being indexed changed between oldNode and newNode
751
+ */
752
+ indexedValueChanged(oldNode: Node_2, newNode: Node_2): boolean;
753
+ /**
754
+ * @returns a node wrapper that will sort equal to or less than
755
+ * any other node wrapper, using this index
756
+ */
757
+ minPost(): NamedNode;
758
+ /**
759
+ * @returns a node wrapper that will sort greater than or equal to
760
+ * any other node wrapper, using this index
761
+ */
762
+ abstract maxPost(): NamedNode;
763
+ abstract makePost(indexValue: unknown, name: string): NamedNode;
764
+ /**
765
+ * @returns String representation for inclusion in a query spec
766
+ */
767
+ abstract toString(): string;
768
+ }
769
+
770
+ /**
771
+ * Used by console to create a database based on the app,
772
+ * passed database URL and a custom auth implementation.
773
+ * @internal
774
+ * @param app - A valid FirebaseApp-like object
775
+ * @param url - A valid Firebase databaseURL
776
+ * @param version - custom version e.g. firebase-admin version
777
+ * @param customAppCheckImpl - custom app check implementation
778
+ * @param customAuthImpl - custom auth implementation
779
+ */
780
+ export declare function _initStandalone({ app, url, version, customAuthImpl, customAppCheckImpl, nodeAdmin }: {
781
+ app: FirebaseApp_2;
782
+ url: string;
783
+ version: string;
784
+ customAuthImpl: FirebaseAuthInternal;
785
+ customAppCheckImpl?: FirebaseAppCheckInternal;
786
+ nodeAdmin?: boolean;
787
+ }): Database;
788
+
789
+ /**
790
+ * Represents a child snapshot of a `Reference` that is being iterated over. The key will never be undefined.
791
+ */
792
+ export declare interface IteratedDataSnapshot extends DataSnapshot {
793
+ key: string;
794
+ }
795
+
796
+ /**
797
+ * Creates a new `QueryConstraint` that if limited to the first specific number
798
+ * of children.
799
+ *
800
+ * The `limitToFirst()` method is used to set a maximum number of children to be
801
+ * synced for a given callback. If we set a limit of 100, we will initially only
802
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
803
+ * stored in our Database, a `child_added` event will fire for each message.
804
+ * However, if we have over 100 messages, we will only receive a `child_added`
805
+ * event for the first 100 ordered messages. As items change, we will receive
806
+ * `child_removed` events for each item that drops out of the active list so
807
+ * that the total number stays at 100.
808
+ *
809
+ * You can read more about `limitToFirst()` in
810
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
811
+ *
812
+ * @param limit - The maximum number of nodes to include in this query.
813
+ */
814
+ export declare function limitToFirst(limit: number): QueryConstraint;
815
+
816
+ /**
817
+ * Creates a new `QueryConstraint` that is limited to return only the last
818
+ * specified number of children.
819
+ *
820
+ * The `limitToLast()` method is used to set a maximum number of children to be
821
+ * synced for a given callback. If we set a limit of 100, we will initially only
822
+ * receive up to 100 `child_added` events. If we have fewer than 100 messages
823
+ * stored in our Database, a `child_added` event will fire for each message.
824
+ * However, if we have over 100 messages, we will only receive a `child_added`
825
+ * event for the last 100 ordered messages. As items change, we will receive
826
+ * `child_removed` events for each item that drops out of the active list so
827
+ * that the total number stays at 100.
828
+ *
829
+ * You can read more about `limitToLast()` in
830
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
831
+ *
832
+ * @param limit - The maximum number of nodes to include in this query.
833
+ */
834
+ export declare function limitToLast(limit: number): QueryConstraint;
835
+
836
+ /** An options objects that can be used to customize a listener. */
837
+ export declare interface ListenOptions {
838
+ /** Whether to remove the listener after its first invocation. */
839
+ readonly onlyOnce?: boolean;
840
+ }
841
+
842
+ declare interface ListenProvider {
843
+ startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event_2[]): Event_2[];
844
+ stopListening(a: QueryContext, b: number | null): void;
845
+ }
846
+
847
+ /**
848
+ * Represents an empty node (a leaf node in the Red-Black Tree).
849
+ */
850
+ declare class LLRBEmptyNode<K, V> {
851
+ key: K;
852
+ value: V;
853
+ left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
854
+ right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
855
+ color: boolean;
856
+ /**
857
+ * Returns a copy of the current node.
858
+ *
859
+ * @returns The node copy.
860
+ */
861
+ copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBEmptyNode<K, V>;
862
+ /**
863
+ * Returns a copy of the tree, with the specified key/value added.
864
+ *
865
+ * @param key - Key to be added.
866
+ * @param value - Value to be added.
867
+ * @param comparator - Comparator.
868
+ * @returns New tree, with item added.
869
+ */
870
+ insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
871
+ /**
872
+ * Returns a copy of the tree, with the specified key removed.
873
+ *
874
+ * @param key - The key to remove.
875
+ * @param comparator - Comparator.
876
+ * @returns New tree, with item removed.
877
+ */
878
+ remove(key: K, comparator: Comparator<K>): LLRBEmptyNode<K, V>;
879
+ /**
880
+ * @returns The total number of nodes in the tree.
881
+ */
882
+ count(): number;
883
+ /**
884
+ * @returns True if the tree is empty.
885
+ */
886
+ isEmpty(): boolean;
887
+ /**
888
+ * Traverses the tree in key order and calls the specified action function
889
+ * for each node.
890
+ *
891
+ * @param action - Callback function to be called for each
892
+ * node. If it returns true, traversal is aborted.
893
+ * @returns True if traversal was aborted.
894
+ */
895
+ inorderTraversal(action: (k: K, v: V) => unknown): boolean;
896
+ /**
897
+ * Traverses the tree in reverse key order and calls the specified action function
898
+ * for each node.
899
+ *
900
+ * @param action - Callback function to be called for each
901
+ * node. If it returns true, traversal is aborted.
902
+ * @returns True if traversal was aborted.
903
+ */
904
+ reverseTraversal(action: (k: K, v: V) => void): boolean;
905
+ minKey(): null;
906
+ maxKey(): null;
907
+ check_(): number;
908
+ /**
909
+ * @returns Whether this node is red.
910
+ */
911
+ isRed_(): boolean;
912
+ }
913
+
914
+ /**
915
+ * Represents a node in a Left-leaning Red-Black tree.
916
+ */
917
+ declare class LLRBNode<K, V> {
918
+ key: K;
919
+ value: V;
920
+ color: boolean;
921
+ left: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
922
+ right: LLRBNode<K, V> | LLRBEmptyNode<K, V>;
923
+ /**
924
+ * @param key - Key associated with this node.
925
+ * @param value - Value associated with this node.
926
+ * @param color - Whether this node is red.
927
+ * @param left - Left child.
928
+ * @param right - Right child.
929
+ */
930
+ constructor(key: K, value: V, color: boolean | null, left?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right?: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null);
931
+ static RED: boolean;
932
+ static BLACK: boolean;
933
+ /**
934
+ * Returns a copy of the current node, optionally replacing pieces of it.
935
+ *
936
+ * @param key - New key for the node, or null.
937
+ * @param value - New value for the node, or null.
938
+ * @param color - New color for the node, or null.
939
+ * @param left - New left child for the node, or null.
940
+ * @param right - New right child for the node, or null.
941
+ * @returns The node copy.
942
+ */
943
+ copy(key: K | null, value: V | null, color: boolean | null, left: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null, right: LLRBNode<K, V> | LLRBEmptyNode<K, V> | null): LLRBNode<K, V>;
944
+ /**
945
+ * @returns The total number of nodes in the tree.
946
+ */
947
+ count(): number;
948
+ /**
949
+ * @returns True if the tree is empty.
950
+ */
951
+ isEmpty(): boolean;
952
+ /**
953
+ * Traverses the tree in key order and calls the specified action function
954
+ * for each node.
955
+ *
956
+ * @param action - Callback function to be called for each
957
+ * node. If it returns true, traversal is aborted.
958
+ * @returns The first truthy value returned by action, or the last falsey
959
+ * value returned by action
960
+ */
961
+ inorderTraversal(action: (k: K, v: V) => unknown): boolean;
962
+ /**
963
+ * Traverses the tree in reverse key order and calls the specified action function
964
+ * for each node.
965
+ *
966
+ * @param action - Callback function to be called for each
967
+ * node. If it returns true, traversal is aborted.
968
+ * @returns True if traversal was aborted.
969
+ */
970
+ reverseTraversal(action: (k: K, v: V) => void): boolean;
971
+ /**
972
+ * @returns The minimum node in the tree.
973
+ */
974
+ private min_;
975
+ /**
976
+ * @returns The maximum key in the tree.
977
+ */
978
+ minKey(): K;
979
+ /**
980
+ * @returns The maximum key in the tree.
981
+ */
982
+ maxKey(): K;
983
+ /**
984
+ * @param key - Key to insert.
985
+ * @param value - Value to insert.
986
+ * @param comparator - Comparator.
987
+ * @returns New tree, with the key/value added.
988
+ */
989
+ insert(key: K, value: V, comparator: Comparator<K>): LLRBNode<K, V>;
990
+ /**
991
+ * @returns New tree, with the minimum key removed.
992
+ */
993
+ private removeMin_;
994
+ /**
995
+ * @param key - The key of the item to remove.
996
+ * @param comparator - Comparator.
997
+ * @returns New tree, with the specified item removed.
998
+ */
999
+ remove(key: K, comparator: Comparator<K>): LLRBNode<K, V> | LLRBEmptyNode<K, V>;
1000
+ /**
1001
+ * @returns Whether this is a RED node.
1002
+ */
1003
+ isRed_(): boolean;
1004
+ /**
1005
+ * @returns New tree after performing any needed rotations.
1006
+ */
1007
+ private fixUp_;
1008
+ /**
1009
+ * @returns New tree, after moveRedLeft.
1010
+ */
1011
+ private moveRedLeft_;
1012
+ /**
1013
+ * @returns New tree, after moveRedRight.
1014
+ */
1015
+ private moveRedRight_;
1016
+ /**
1017
+ * @returns New tree, after rotateLeft.
1018
+ */
1019
+ private rotateLeft_;
1020
+ /**
1021
+ * @returns New tree, after rotateRight.
1022
+ */
1023
+ private rotateRight_;
1024
+ /**
1025
+ * @returns Newt ree, after colorFlip.
1026
+ */
1027
+ private colorFlip_;
1028
+ /**
1029
+ * For testing.
1030
+ *
1031
+ * @returns True if all is well.
1032
+ */
1033
+ private checkMaxDepth_;
1034
+ check_(): number;
1035
+ }
1036
+
1037
+ declare class NamedNode {
1038
+ name: string;
1039
+ node: Node_2;
1040
+ constructor(name: string, node: Node_2);
1041
+ static Wrap(name: string, node: Node_2): NamedNode;
1042
+ }
1043
+
1044
+ /**
1045
+ * Node is an interface defining the common functionality for nodes in
1046
+ * a DataSnapshot.
1047
+ *
1048
+ * @interface
1049
+ */
1050
+ declare interface Node_2 {
1051
+ /**
1052
+ * Whether this node is a leaf node.
1053
+ * @returns Whether this is a leaf node.
1054
+ */
1055
+ isLeafNode(): boolean;
1056
+ /**
1057
+ * Gets the priority of the node.
1058
+ * @returns The priority of the node.
1059
+ */
1060
+ getPriority(): Node_2;
1061
+ /**
1062
+ * Returns a duplicate node with the new priority.
1063
+ * @param newPriorityNode - New priority to set for the node.
1064
+ * @returns Node with new priority.
1065
+ */
1066
+ updatePriority(newPriorityNode: Node_2): Node_2;
1067
+ /**
1068
+ * Returns the specified immediate child, or null if it doesn't exist.
1069
+ * @param childName - The name of the child to retrieve.
1070
+ * @returns The retrieved child, or an empty node.
1071
+ */
1072
+ getImmediateChild(childName: string): Node_2;
1073
+ /**
1074
+ * Returns a child by path, or null if it doesn't exist.
1075
+ * @param path - The path of the child to retrieve.
1076
+ * @returns The retrieved child or an empty node.
1077
+ */
1078
+ getChild(path: Path): Node_2;
1079
+ /**
1080
+ * Returns the name of the child immediately prior to the specified childNode, or null.
1081
+ * @param childName - The name of the child to find the predecessor of.
1082
+ * @param childNode - The node to find the predecessor of.
1083
+ * @param index - The index to use to determine the predecessor
1084
+ * @returns The name of the predecessor child, or null if childNode is the first child.
1085
+ */
1086
+ getPredecessorChildName(childName: string, childNode: Node_2, index: Index): string | null;
1087
+ /**
1088
+ * Returns a duplicate node, with the specified immediate child updated.
1089
+ * Any value in the node will be removed.
1090
+ * @param childName - The name of the child to update.
1091
+ * @param newChildNode - The new child node
1092
+ * @returns The updated node.
1093
+ */
1094
+ updateImmediateChild(childName: string, newChildNode: Node_2): Node_2;
1095
+ /**
1096
+ * Returns a duplicate node, with the specified child updated. Any value will
1097
+ * be removed.
1098
+ * @param path - The path of the child to update.
1099
+ * @param newChildNode - The new child node, which may be an empty node
1100
+ * @returns The updated node.
1101
+ */
1102
+ updateChild(path: Path, newChildNode: Node_2): Node_2;
1103
+ /**
1104
+ * True if the immediate child specified exists
1105
+ */
1106
+ hasChild(childName: string): boolean;
1107
+ /**
1108
+ * @returns True if this node has no value or children.
1109
+ */
1110
+ isEmpty(): boolean;
1111
+ /**
1112
+ * @returns The number of children of this node.
1113
+ */
1114
+ numChildren(): number;
1115
+ /**
1116
+ * Calls action for each child.
1117
+ * @param action - Action to be called for
1118
+ * each child. It's passed the child name and the child node.
1119
+ * @returns The first truthy value return by action, or the last falsey one
1120
+ */
1121
+ forEachChild(index: Index, action: (a: string, b: Node_2) => void): unknown;
1122
+ /**
1123
+ * @param exportFormat - True for export format (also wire protocol format).
1124
+ * @returns Value of this node as JSON.
1125
+ */
1126
+ val(exportFormat?: boolean): unknown;
1127
+ /**
1128
+ * @returns hash representing the node contents.
1129
+ */
1130
+ hash(): string;
1131
+ /**
1132
+ * @param other - Another node
1133
+ * @returns -1 for less than, 0 for equal, 1 for greater than other
1134
+ */
1135
+ compareTo(other: Node_2): number;
1136
+ /**
1137
+ * @returns Whether or not this snapshot equals other
1138
+ */
1139
+ equals(other: Node_2): boolean;
1140
+ /**
1141
+ * @returns This node, with the specified index now available
1142
+ */
1143
+ withIndex(indexDefinition: Index): Node_2;
1144
+ isIndexed(indexDefinition: Index): boolean;
1145
+ }
1146
+
1147
+ /**
1148
+ * NodeFilter is used to update nodes and complete children of nodes while applying queries on the fly and keeping
1149
+ * track of any child changes. This class does not track value changes as value changes depend on more
1150
+ * than just the node itself. Different kind of queries require different kind of implementations of this interface.
1151
+ * @interface
1152
+ */
1153
+ declare interface NodeFilter_2 {
1154
+ /**
1155
+ * Update a single complete child in the snap. If the child equals the old child in the snap, this is a no-op.
1156
+ * The method expects an indexed snap.
1157
+ */
1158
+ updateChild(snap: Node_2, key: string, newChild: Node_2, affectedPath: Path, source: CompleteChildSource, optChangeAccumulator: ChildChangeAccumulator | null): Node_2;
1159
+ /**
1160
+ * Update a node in full and output any resulting change from this complete update.
1161
+ */
1162
+ updateFullNode(oldSnap: Node_2, newSnap: Node_2, optChangeAccumulator: ChildChangeAccumulator | null): Node_2;
1163
+ /**
1164
+ * Update the priority of the root node
1165
+ */
1166
+ updatePriority(oldSnap: Node_2, newPriority: Node_2): Node_2;
1167
+ /**
1168
+ * Returns true if children might be filtered due to query criteria
1169
+ */
1170
+ filtersNodes(): boolean;
1171
+ /**
1172
+ * Returns the index filter that this filter uses to get a NodeFilter that doesn't filter any children.
1173
+ */
1174
+ getIndexedFilter(): NodeFilter_2;
1175
+ /**
1176
+ * Returns the index that this filter uses
1177
+ */
1178
+ getIndex(): Index;
1179
+ }
1180
+
1181
+ /**
1182
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
1183
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
1184
+ * the respective `on*` callbacks.
1185
+ *
1186
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
1187
+ * will not automatically remove listeners registered on child nodes, `off()`
1188
+ * must also be called on any child listeners to remove the callback.
1189
+ *
1190
+ * If a callback is not specified, all callbacks for the specified eventType
1191
+ * will be removed. Similarly, if no eventType is specified, all callbacks
1192
+ * for the `Reference` will be removed.
1193
+ *
1194
+ * Individual listeners can also be removed by invoking their unsubscribe
1195
+ * callbacks.
1196
+ *
1197
+ * @param query - The query that the listener was registered with.
1198
+ * @param eventType - One of the following strings: "value", "child_added",
1199
+ * "child_changed", "child_removed", or "child_moved." If omitted, all callbacks
1200
+ * for the `Reference` will be removed.
1201
+ * @param callback - The callback function that was passed to `on()` or
1202
+ * `undefined` to remove all callbacks.
1203
+ */
1204
+ export declare function off(query: Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
1205
+
1206
+ /**
1207
+ * Listens for data changes at a particular location.
1208
+ *
1209
+ * This is the primary way to read data from a Database. Your callback
1210
+ * will be triggered for the initial data and again whenever the data changes.
1211
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1212
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1213
+ * for more details.
1214
+ *
1215
+ * An `onChildAdded` event will be triggered once for each initial child at this
1216
+ * location, and it will be triggered again every time a new child is added. The
1217
+ * `DataSnapshot` passed into the callback will reflect the data for the
1218
+ * relevant child. For ordering purposes, it is passed a second argument which
1219
+ * is a string containing the key of the previous sibling child by sort order,
1220
+ * or `null` if it is the first child.
1221
+ *
1222
+ * @param query - The query to run.
1223
+ * @param callback - A callback that fires when the specified event occurs.
1224
+ * The callback will be passed a DataSnapshot and a string containing the key of
1225
+ * the previous child, by sort order, or `null` if it is the first child.
1226
+ * @param cancelCallback - An optional callback that will be notified if your
1227
+ * event subscription is ever canceled because your client does not have
1228
+ * permission to read this data (or it had permission but has now lost it).
1229
+ * This callback will be passed an `Error` object indicating why the failure
1230
+ * occurred.
1231
+ * @returns A function that can be invoked to remove the listener.
1232
+ */
1233
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
1234
+
1235
+ /**
1236
+ * Listens for data changes at a particular location.
1237
+ *
1238
+ * This is the primary way to read data from a Database. Your callback
1239
+ * will be triggered for the initial data and again whenever the data changes.
1240
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1241
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1242
+ * for more details.
1243
+ *
1244
+ * An `onChildAdded` event will be triggered once for each initial child at this
1245
+ * location, and it will be triggered again every time a new child is added. The
1246
+ * `DataSnapshot` passed into the callback will reflect the data for the
1247
+ * relevant child. For ordering purposes, it is passed a second argument which
1248
+ * is a string containing the key of the previous sibling child by sort order,
1249
+ * or `null` if it is the first child.
1250
+ *
1251
+ * @param query - The query to run.
1252
+ * @param callback - A callback that fires when the specified event occurs.
1253
+ * The callback will be passed a DataSnapshot and a string containing the key of
1254
+ * the previous child, by sort order, or `null` if it is the first child.
1255
+ * @param options - An object that can be used to configure `onlyOnce`, which
1256
+ * then removes the listener after its first invocation.
1257
+ * @returns A function that can be invoked to remove the listener.
1258
+ */
1259
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
1260
+
1261
+ /**
1262
+ * Listens for data changes at a particular location.
1263
+ *
1264
+ * This is the primary way to read data from a Database. Your callback
1265
+ * will be triggered for the initial data and again whenever the data changes.
1266
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1267
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1268
+ * for more details.
1269
+ *
1270
+ * An `onChildAdded` event will be triggered once for each initial child at this
1271
+ * location, and it will be triggered again every time a new child is added. The
1272
+ * `DataSnapshot` passed into the callback will reflect the data for the
1273
+ * relevant child. For ordering purposes, it is passed a second argument which
1274
+ * is a string containing the key of the previous sibling child by sort order,
1275
+ * or `null` if it is the first child.
1276
+ *
1277
+ * @param query - The query to run.
1278
+ * @param callback - A callback that fires when the specified event occurs.
1279
+ * The callback will be passed a DataSnapshot and a string containing the key of
1280
+ * the previous child, by sort order, or `null` if it is the first child.
1281
+ * @param cancelCallback - An optional callback that will be notified if your
1282
+ * event subscription is ever canceled because your client does not have
1283
+ * permission to read this data (or it had permission but has now lost it).
1284
+ * This callback will be passed an `Error` object indicating why the failure
1285
+ * occurred.
1286
+ * @param options - An object that can be used to configure `onlyOnce`, which
1287
+ * then removes the listener after its first invocation.
1288
+ * @returns A function that can be invoked to remove the listener.
1289
+ */
1290
+ export declare function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
1291
+
1292
+ /**
1293
+ * Listens for data changes at a particular location.
1294
+ *
1295
+ * This is the primary way to read data from a Database. Your callback
1296
+ * will be triggered for the initial data and again whenever the data changes.
1297
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1298
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1299
+ * for more details.
1300
+ *
1301
+ * An `onChildChanged` event will be triggered when the data stored in a child
1302
+ * (or any of its descendants) changes. Note that a single `child_changed` event
1303
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
1304
+ * callback will contain the new child contents. For ordering purposes, the
1305
+ * callback is also passed a second argument which is a string containing the
1306
+ * key of the previous sibling child by sort order, or `null` if it is the first
1307
+ * child.
1308
+ *
1309
+ * @param query - The query to run.
1310
+ * @param callback - A callback that fires when the specified event occurs.
1311
+ * The callback will be passed a DataSnapshot and a string containing the key of
1312
+ * the previous child, by sort order, or `null` if it is the first child.
1313
+ * @param cancelCallback - An optional callback that will be notified if your
1314
+ * event subscription is ever canceled because your client does not have
1315
+ * permission to read this data (or it had permission but has now lost it).
1316
+ * This callback will be passed an `Error` object indicating why the failure
1317
+ * occurred.
1318
+ * @returns A function that can be invoked to remove the listener.
1319
+ */
1320
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
1321
+
1322
+ /**
1323
+ * Listens for data changes at a particular location.
1324
+ *
1325
+ * This is the primary way to read data from a Database. Your callback
1326
+ * will be triggered for the initial data and again whenever the data changes.
1327
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1328
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1329
+ * for more details.
1330
+ *
1331
+ * An `onChildChanged` event will be triggered when the data stored in a child
1332
+ * (or any of its descendants) changes. Note that a single `child_changed` event
1333
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
1334
+ * callback will contain the new child contents. For ordering purposes, the
1335
+ * callback is also passed a second argument which is a string containing the
1336
+ * key of the previous sibling child by sort order, or `null` if it is the first
1337
+ * child.
1338
+ *
1339
+ * @param query - The query to run.
1340
+ * @param callback - A callback that fires when the specified event occurs.
1341
+ * The callback will be passed a DataSnapshot and a string containing the key of
1342
+ * the previous child, by sort order, or `null` if it is the first child.
1343
+ * @param options - An object that can be used to configure `onlyOnce`, which
1344
+ * then removes the listener after its first invocation.
1345
+ * @returns A function that can be invoked to remove the listener.
1346
+ */
1347
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
1348
+
1349
+ /**
1350
+ * Listens for data changes at a particular location.
1351
+ *
1352
+ * This is the primary way to read data from a Database. Your callback
1353
+ * will be triggered for the initial data and again whenever the data changes.
1354
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1355
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1356
+ * for more details.
1357
+ *
1358
+ * An `onChildChanged` event will be triggered when the data stored in a child
1359
+ * (or any of its descendants) changes. Note that a single `child_changed` event
1360
+ * may represent multiple changes to the child. The `DataSnapshot` passed to the
1361
+ * callback will contain the new child contents. For ordering purposes, the
1362
+ * callback is also passed a second argument which is a string containing the
1363
+ * key of the previous sibling child by sort order, or `null` if it is the first
1364
+ * child.
1365
+ *
1366
+ * @param query - The query to run.
1367
+ * @param callback - A callback that fires when the specified event occurs.
1368
+ * The callback will be passed a DataSnapshot and a string containing the key of
1369
+ * the previous child, by sort order, or `null` if it is the first child.
1370
+ * @param cancelCallback - An optional callback that will be notified if your
1371
+ * event subscription is ever canceled because your client does not have
1372
+ * permission to read this data (or it had permission but has now lost it).
1373
+ * This callback will be passed an `Error` object indicating why the failure
1374
+ * occurred.
1375
+ * @param options - An object that can be used to configure `onlyOnce`, which
1376
+ * then removes the listener after its first invocation.
1377
+ * @returns A function that can be invoked to remove the listener.
1378
+ */
1379
+ export declare function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
1380
+
1381
+ /**
1382
+ * Listens for data changes at a particular location.
1383
+ *
1384
+ * This is the primary way to read data from a Database. Your callback
1385
+ * will be triggered for the initial data and again whenever the data changes.
1386
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1387
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1388
+ * for more details.
1389
+ *
1390
+ * An `onChildMoved` event will be triggered when a child's sort order changes
1391
+ * such that its position relative to its siblings changes. The `DataSnapshot`
1392
+ * passed to the callback will be for the data of the child that has moved. It
1393
+ * is also passed a second argument which is a string containing the key of the
1394
+ * previous sibling child by sort order, or `null` if it is the first child.
1395
+ *
1396
+ * @param query - The query to run.
1397
+ * @param callback - A callback that fires when the specified event occurs.
1398
+ * The callback will be passed a DataSnapshot and a string containing the key of
1399
+ * the previous child, by sort order, or `null` if it is the first child.
1400
+ * @param cancelCallback - An optional callback that will be notified if your
1401
+ * event subscription is ever canceled because your client does not have
1402
+ * permission to read this data (or it had permission but has now lost it).
1403
+ * This callback will be passed an `Error` object indicating why the failure
1404
+ * occurred.
1405
+ * @returns A function that can be invoked to remove the listener.
1406
+ */
1407
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
1408
+
1409
+ /**
1410
+ * Listens for data changes at a particular location.
1411
+ *
1412
+ * This is the primary way to read data from a Database. Your callback
1413
+ * will be triggered for the initial data and again whenever the data changes.
1414
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1415
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1416
+ * for more details.
1417
+ *
1418
+ * An `onChildMoved` event will be triggered when a child's sort order changes
1419
+ * such that its position relative to its siblings changes. The `DataSnapshot`
1420
+ * passed to the callback will be for the data of the child that has moved. It
1421
+ * is also passed a second argument which is a string containing the key of the
1422
+ * previous sibling child by sort order, or `null` if it is the first child.
1423
+ *
1424
+ * @param query - The query to run.
1425
+ * @param callback - A callback that fires when the specified event occurs.
1426
+ * The callback will be passed a DataSnapshot and a string containing the key of
1427
+ * the previous child, by sort order, or `null` if it is the first child.
1428
+ * @param options - An object that can be used to configure `onlyOnce`, which
1429
+ * then removes the listener after its first invocation.
1430
+ * @returns A function that can be invoked to remove the listener.
1431
+ */
1432
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
1433
+
1434
+ /**
1435
+ * Listens for data changes at a particular location.
1436
+ *
1437
+ * This is the primary way to read data from a Database. Your callback
1438
+ * will be triggered for the initial data and again whenever the data changes.
1439
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1440
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1441
+ * for more details.
1442
+ *
1443
+ * An `onChildMoved` event will be triggered when a child's sort order changes
1444
+ * such that its position relative to its siblings changes. The `DataSnapshot`
1445
+ * passed to the callback will be for the data of the child that has moved. It
1446
+ * is also passed a second argument which is a string containing the key of the
1447
+ * previous sibling child by sort order, or `null` if it is the first child.
1448
+ *
1449
+ * @param query - The query to run.
1450
+ * @param callback - A callback that fires when the specified event occurs.
1451
+ * The callback will be passed a DataSnapshot and a string containing the key of
1452
+ * the previous child, by sort order, or `null` if it is the first child.
1453
+ * @param cancelCallback - An optional callback that will be notified if your
1454
+ * event subscription is ever canceled because your client does not have
1455
+ * permission to read this data (or it had permission but has now lost it).
1456
+ * This callback will be passed an `Error` object indicating why the failure
1457
+ * occurred.
1458
+ * @param options - An object that can be used to configure `onlyOnce`, which
1459
+ * then removes the listener after its first invocation.
1460
+ * @returns A function that can be invoked to remove the listener.
1461
+ */
1462
+ export declare function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
1463
+
1464
+ /**
1465
+ * Listens for data changes at a particular location.
1466
+ *
1467
+ * This is the primary way to read data from a Database. Your callback
1468
+ * will be triggered for the initial data and again whenever the data changes.
1469
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1470
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1471
+ * for more details.
1472
+ *
1473
+ * An `onChildRemoved` event will be triggered once every time a child is
1474
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
1475
+ * the child that was removed. A child will get removed when either:
1476
+ *
1477
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
1478
+ * - a client calls `set(null)` on that child or one of its ancestors
1479
+ * - that child has all of its children removed
1480
+ * - there is a query in effect which now filters out the child (because it's
1481
+ * sort order changed or the max limit was hit)
1482
+ *
1483
+ * @param query - The query to run.
1484
+ * @param callback - A callback that fires when the specified event occurs.
1485
+ * The callback will be passed a DataSnapshot and a string containing the key of
1486
+ * the previous child, by sort order, or `null` if it is the first child.
1487
+ * @param cancelCallback - An optional callback that will be notified if your
1488
+ * event subscription is ever canceled because your client does not have
1489
+ * permission to read this data (or it had permission but has now lost it).
1490
+ * This callback will be passed an `Error` object indicating why the failure
1491
+ * occurred.
1492
+ * @returns A function that can be invoked to remove the listener.
1493
+ */
1494
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
1495
+
1496
+ /**
1497
+ * Listens for data changes at a particular location.
1498
+ *
1499
+ * This is the primary way to read data from a Database. Your callback
1500
+ * will be triggered for the initial data and again whenever the data changes.
1501
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1502
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1503
+ * for more details.
1504
+ *
1505
+ * An `onChildRemoved` event will be triggered once every time a child is
1506
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
1507
+ * the child that was removed. A child will get removed when either:
1508
+ *
1509
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
1510
+ * - a client calls `set(null)` on that child or one of its ancestors
1511
+ * - that child has all of its children removed
1512
+ * - there is a query in effect which now filters out the child (because it's
1513
+ * sort order changed or the max limit was hit)
1514
+ *
1515
+ * @param query - The query to run.
1516
+ * @param callback - A callback that fires when the specified event occurs.
1517
+ * The callback will be passed a DataSnapshot and a string containing the key of
1518
+ * the previous child, by sort order, or `null` if it is the first child.
1519
+ * @param options - An object that can be used to configure `onlyOnce`, which
1520
+ * then removes the listener after its first invocation.
1521
+ * @returns A function that can be invoked to remove the listener.
1522
+ */
1523
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
1524
+
1525
+ /**
1526
+ * Listens for data changes at a particular location.
1527
+ *
1528
+ * This is the primary way to read data from a Database. Your callback
1529
+ * will be triggered for the initial data and again whenever the data changes.
1530
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1531
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1532
+ * for more details.
1533
+ *
1534
+ * An `onChildRemoved` event will be triggered once every time a child is
1535
+ * removed. The `DataSnapshot` passed into the callback will be the old data for
1536
+ * the child that was removed. A child will get removed when either:
1537
+ *
1538
+ * - a client explicitly calls `remove()` on that child or one of its ancestors
1539
+ * - a client calls `set(null)` on that child or one of its ancestors
1540
+ * - that child has all of its children removed
1541
+ * - there is a query in effect which now filters out the child (because it's
1542
+ * sort order changed or the max limit was hit)
1543
+ *
1544
+ * @param query - The query to run.
1545
+ * @param callback - A callback that fires when the specified event occurs.
1546
+ * The callback will be passed a DataSnapshot and a string containing the key of
1547
+ * the previous child, by sort order, or `null` if it is the first child.
1548
+ * @param cancelCallback - An optional callback that will be notified if your
1549
+ * event subscription is ever canceled because your client does not have
1550
+ * permission to read this data (or it had permission but has now lost it).
1551
+ * This callback will be passed an `Error` object indicating why the failure
1552
+ * occurred.
1553
+ * @param options - An object that can be used to configure `onlyOnce`, which
1554
+ * then removes the listener after its first invocation.
1555
+ * @returns A function that can be invoked to remove the listener.
1556
+ */
1557
+ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
1558
+
1559
+ /**
1560
+ * The `onDisconnect` class allows you to write or clear data when your client
1561
+ * disconnects from the Database server. These updates occur whether your
1562
+ * client disconnects cleanly or not, so you can rely on them to clean up data
1563
+ * even if a connection is dropped or a client crashes.
1564
+ *
1565
+ * The `onDisconnect` class is most commonly used to manage presence in
1566
+ * applications where it is useful to detect how many clients are connected and
1567
+ * when other clients disconnect. See
1568
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
1569
+ * for more information.
1570
+ *
1571
+ * To avoid problems when a connection is dropped before the requests can be
1572
+ * transferred to the Database server, these functions should be called before
1573
+ * writing any data.
1574
+ *
1575
+ * Note that `onDisconnect` operations are only triggered once. If you want an
1576
+ * operation to occur each time a disconnect occurs, you'll need to re-establish
1577
+ * the `onDisconnect` operations each time you reconnect.
1578
+ */
1579
+ export declare class OnDisconnect {
1580
+ private _repo;
1581
+ private _path;
1582
+ /** @hideconstructor */
1583
+ constructor(_repo: Repo, _path: Path);
1584
+ /**
1585
+ * Cancels all previously queued `onDisconnect()` set or update events for this
1586
+ * location and all children.
1587
+ *
1588
+ * If a write has been queued for this location via a `set()` or `update()` at a
1589
+ * parent location, the write at this location will be canceled, though writes
1590
+ * to sibling locations will still occur.
1591
+ *
1592
+ * @returns Resolves when synchronization to the server is complete.
1593
+ */
1594
+ cancel(): Promise<void>;
1595
+ /**
1596
+ * Ensures the data at this location is deleted when the client is disconnected
1597
+ * (due to closing the browser, navigating to a new page, or network issues).
1598
+ *
1599
+ * @returns Resolves when synchronization to the server is complete.
1600
+ */
1601
+ remove(): Promise<void>;
1602
+ /**
1603
+ * Ensures the data at this location is set to the specified value when the
1604
+ * client is disconnected (due to closing the browser, navigating to a new page,
1605
+ * or network issues).
1606
+ *
1607
+ * `set()` is especially useful for implementing "presence" systems, where a
1608
+ * value should be changed or cleared when a user disconnects so that they
1609
+ * appear "offline" to other users. See
1610
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
1611
+ * for more information.
1612
+ *
1613
+ * Note that `onDisconnect` operations are only triggered once. If you want an
1614
+ * operation to occur each time a disconnect occurs, you'll need to re-establish
1615
+ * the `onDisconnect` operations each time.
1616
+ *
1617
+ * @param value - The value to be written to this location on disconnect (can
1618
+ * be an object, array, string, number, boolean, or null).
1619
+ * @returns Resolves when synchronization to the Database is complete.
1620
+ */
1621
+ set(value: unknown): Promise<void>;
1622
+ /**
1623
+ * Ensures the data at this location is set to the specified value and priority
1624
+ * when the client is disconnected (due to closing the browser, navigating to a
1625
+ * new page, or network issues).
1626
+ *
1627
+ * @param value - The value to be written to this location on disconnect (can
1628
+ * be an object, array, string, number, boolean, or null).
1629
+ * @param priority - The priority to be written (string, number, or null).
1630
+ * @returns Resolves when synchronization to the Database is complete.
1631
+ */
1632
+ setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
1633
+ /**
1634
+ * Writes multiple values at this location when the client is disconnected (due
1635
+ * to closing the browser, navigating to a new page, or network issues).
1636
+ *
1637
+ * The `values` argument contains multiple property-value pairs that will be
1638
+ * written to the Database together. Each child property can either be a simple
1639
+ * property (for example, "name") or a relative path (for example, "name/first")
1640
+ * from the current location to the data to update.
1641
+ *
1642
+ * As opposed to the `set()` method, `update()` can be use to selectively update
1643
+ * only the referenced properties at the current location (instead of replacing
1644
+ * all the child properties at the current location).
1645
+ *
1646
+ * @param values - Object containing multiple values.
1647
+ * @returns Resolves when synchronization to the Database is complete.
1648
+ */
1649
+ update(values: object): Promise<void>;
1650
+ }
1651
+
1652
+ /**
1653
+ * Returns an `OnDisconnect` object - see
1654
+ * {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
1655
+ * for more information on how to use it.
1656
+ *
1657
+ * @param ref - The reference to add OnDisconnect triggers for.
1658
+ */
1659
+ export declare function onDisconnect(ref: DatabaseReference): OnDisconnect;
1660
+
1661
+ /**
1662
+ * Listens for data changes at a particular location.
1663
+ *
1664
+ * This is the primary way to read data from a Database. Your callback
1665
+ * will be triggered for the initial data and again whenever the data changes.
1666
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1667
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1668
+ * for more details.
1669
+ *
1670
+ * An `onValue` event will trigger once with the initial data stored at this
1671
+ * location, and then trigger again each time the data changes. The
1672
+ * `DataSnapshot` passed to the callback will be for the location at which
1673
+ * `on()` was called. It won't trigger until the entire contents has been
1674
+ * synchronized. If the location has no data, it will be triggered with an empty
1675
+ * `DataSnapshot` (`val()` will return `null`).
1676
+ *
1677
+ * @param query - The query to run.
1678
+ * @param callback - A callback that fires when the specified event occurs. The
1679
+ * callback will be passed a DataSnapshot.
1680
+ * @param cancelCallback - An optional callback that will be notified if your
1681
+ * event subscription is ever canceled because your client does not have
1682
+ * permission to read this data (or it had permission but has now lost it).
1683
+ * This callback will be passed an `Error` object indicating why the failure
1684
+ * occurred.
1685
+ * @returns A function that can be invoked to remove the listener.
1686
+ */
1687
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
1688
+
1689
+ /**
1690
+ * Listens for data changes at a particular location.
1691
+ *
1692
+ * This is the primary way to read data from a Database. Your callback
1693
+ * will be triggered for the initial data and again whenever the data changes.
1694
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1695
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1696
+ * for more details.
1697
+ *
1698
+ * An `onValue` event will trigger once with the initial data stored at this
1699
+ * location, and then trigger again each time the data changes. The
1700
+ * `DataSnapshot` passed to the callback will be for the location at which
1701
+ * `on()` was called. It won't trigger until the entire contents has been
1702
+ * synchronized. If the location has no data, it will be triggered with an empty
1703
+ * `DataSnapshot` (`val()` will return `null`).
1704
+ *
1705
+ * @param query - The query to run.
1706
+ * @param callback - A callback that fires when the specified event occurs. The
1707
+ * callback will be passed a DataSnapshot.
1708
+ * @param options - An object that can be used to configure `onlyOnce`, which
1709
+ * then removes the listener after its first invocation.
1710
+ * @returns A function that can be invoked to remove the listener.
1711
+ */
1712
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
1713
+
1714
+ /**
1715
+ * Listens for data changes at a particular location.
1716
+ *
1717
+ * This is the primary way to read data from a Database. Your callback
1718
+ * will be triggered for the initial data and again whenever the data changes.
1719
+ * Invoke the returned unsubscribe callback to stop receiving updates. See
1720
+ * {@link https://firebase.google.com/docs/database/web/retrieve-data | Retrieve Data on the Web}
1721
+ * for more details.
1722
+ *
1723
+ * An `onValue` event will trigger once with the initial data stored at this
1724
+ * location, and then trigger again each time the data changes. The
1725
+ * `DataSnapshot` passed to the callback will be for the location at which
1726
+ * `on()` was called. It won't trigger until the entire contents has been
1727
+ * synchronized. If the location has no data, it will be triggered with an empty
1728
+ * `DataSnapshot` (`val()` will return `null`).
1729
+ *
1730
+ * @param query - The query to run.
1731
+ * @param callback - A callback that fires when the specified event occurs. The
1732
+ * callback will be passed a DataSnapshot.
1733
+ * @param cancelCallback - An optional callback that will be notified if your
1734
+ * event subscription is ever canceled because your client does not have
1735
+ * permission to read this data (or it had permission but has now lost it).
1736
+ * This callback will be passed an `Error` object indicating why the failure
1737
+ * occurred.
1738
+ * @param options - An object that can be used to configure `onlyOnce`, which
1739
+ * then removes the listener after its first invocation.
1740
+ * @returns A function that can be invoked to remove the listener.
1741
+ */
1742
+ export declare function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
1743
+
1744
+ /**
1745
+ * Creates a new `QueryConstraint` that orders by the specified child key.
1746
+ *
1747
+ * Queries can only order by one key at a time. Calling `orderByChild()`
1748
+ * multiple times on the same query is an error.
1749
+ *
1750
+ * Firebase queries allow you to order your data by any child key on the fly.
1751
+ * However, if you know in advance what your indexes will be, you can define
1752
+ * them via the .indexOn rule in your Security Rules for better performance. See
1753
+ * the{@link https://firebase.google.com/docs/database/security/indexing-data}
1754
+ * rule for more information.
1755
+ *
1756
+ * You can read more about `orderByChild()` in
1757
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1758
+ *
1759
+ * @param path - The path to order by.
1760
+ */
1761
+ export declare function orderByChild(path: string): QueryConstraint;
1762
+
1763
+ /**
1764
+ * Creates a new `QueryConstraint` that orders by the key.
1765
+ *
1766
+ * Sorts the results of a query by their (ascending) key values.
1767
+ *
1768
+ * You can read more about `orderByKey()` in
1769
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1770
+ */
1771
+ export declare function orderByKey(): QueryConstraint;
1772
+
1773
+ /**
1774
+ * Creates a new `QueryConstraint` that orders by priority.
1775
+ *
1776
+ * Applications need not use priority but can order collections by
1777
+ * ordinary properties (see
1778
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}
1779
+ * for alternatives to priority.
1780
+ */
1781
+ export declare function orderByPriority(): QueryConstraint;
1782
+
1783
+ /**
1784
+ * Creates a new `QueryConstraint` that orders by value.
1785
+ *
1786
+ * If the children of a query are all scalar values (string, number, or
1787
+ * boolean), you can order the results by their (ascending) values.
1788
+ *
1789
+ * You can read more about `orderByValue()` in
1790
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sort_data | Sort data}.
1791
+ */
1792
+ export declare function orderByValue(): QueryConstraint;
1793
+
1794
+ /**
1795
+ * @license
1796
+ * Copyright 2017 Google LLC
1797
+ *
1798
+ * Licensed under the Apache License, Version 2.0 (the "License");
1799
+ * you may not use this file except in compliance with the License.
1800
+ * You may obtain a copy of the License at
1801
+ *
1802
+ * http://www.apache.org/licenses/LICENSE-2.0
1803
+ *
1804
+ * Unless required by applicable law or agreed to in writing, software
1805
+ * distributed under the License is distributed on an "AS IS" BASIS,
1806
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1807
+ * See the License for the specific language governing permissions and
1808
+ * limitations under the License.
1809
+ */
1810
+ /**
1811
+ * An immutable object representing a parsed path. It's immutable so that you
1812
+ * can pass them around to other functions without worrying about them changing
1813
+ * it.
1814
+ */
1815
+ declare class Path {
1816
+ pieces_: string[];
1817
+ pieceNum_: number;
1818
+ /**
1819
+ * @param pathOrString - Path string to parse, or another path, or the raw
1820
+ * tokens array
1821
+ */
1822
+ constructor(pathOrString: string | string[], pieceNum?: number);
1823
+ toString(): string;
1824
+ }
1825
+
1826
+ /**
1827
+ * Firebase connection. Abstracts wire protocol and handles reconnecting.
1828
+ *
1829
+ * NOTE: All JSON objects sent to the realtime connection must have property names enclosed
1830
+ * in quotes to make sure the closure compiler does not minify them.
1831
+ */
1832
+ declare class PersistentConnection extends ServerActions {
1833
+ private repoInfo_;
1834
+ private applicationId_;
1835
+ private onDataUpdate_;
1836
+ private onConnectStatus_;
1837
+ private onServerInfoUpdate_;
1838
+ private authTokenProvider_;
1839
+ private appCheckTokenProvider_;
1840
+ private authOverride_?;
1841
+ id: number;
1842
+ private log_;
1843
+ private interruptReasons_;
1844
+ private readonly listens;
1845
+ private outstandingPuts_;
1846
+ private outstandingGets_;
1847
+ private outstandingPutCount_;
1848
+ private outstandingGetCount_;
1849
+ private onDisconnectRequestQueue_;
1850
+ private connected_;
1851
+ private reconnectDelay_;
1852
+ private maxReconnectDelay_;
1853
+ private securityDebugCallback_;
1854
+ lastSessionId: string | null;
1855
+ private establishConnectionTimer_;
1856
+ private visible_;
1857
+ private requestCBHash_;
1858
+ private requestNumber_;
1859
+ private realtime_;
1860
+ private authToken_;
1861
+ private appCheckToken_;
1862
+ private forceTokenRefresh_;
1863
+ private invalidAuthTokenCount_;
1864
+ private invalidAppCheckTokenCount_;
1865
+ private firstConnection_;
1866
+ private lastConnectionAttemptTime_;
1867
+ private lastConnectionEstablishedTime_;
1868
+ private static nextPersistentConnectionId_;
1869
+ /**
1870
+ * Counter for number of connections created. Mainly used for tagging in the logs
1871
+ */
1872
+ private static nextConnectionId_;
1873
+ /**
1874
+ * @param repoInfo_ - Data about the namespace we are connecting to
1875
+ * @param applicationId_ - The Firebase App ID for this project
1876
+ * @param onDataUpdate_ - A callback for new data from the server
1877
+ */
1878
+ constructor(repoInfo_: RepoInfo, applicationId_: string, onDataUpdate_: (a: string, b: unknown, c: boolean, d: number | null) => void, onConnectStatus_: (a: boolean) => void, onServerInfoUpdate_: (a: unknown) => void, authTokenProvider_: AuthTokenProvider, appCheckTokenProvider_: AppCheckTokenProvider, authOverride_?: object | null);
1879
+ protected sendRequest(action: string, body: unknown, onResponse?: (a: unknown) => void): void;
1880
+ get(query: QueryContext): Promise<string>;
1881
+ listen(query: QueryContext, currentHashFn: () => string, tag: number | null, onComplete: (a: string, b: unknown) => void): void;
1882
+ private sendGet_;
1883
+ private sendListen_;
1884
+ private static warnOnListenWarnings_;
1885
+ refreshAuthToken(token: string): void;
1886
+ private reduceReconnectDelayIfAdminCredential_;
1887
+ refreshAppCheckToken(token: string | null): void;
1888
+ /**
1889
+ * Attempts to authenticate with the given credentials. If the authentication attempt fails, it's triggered like
1890
+ * a auth revoked (the connection is closed).
1891
+ */
1892
+ tryAuth(): void;
1893
+ /**
1894
+ * Attempts to authenticate with the given token. If the authentication
1895
+ * attempt fails, it's triggered like the token was revoked (the connection is
1896
+ * closed).
1897
+ */
1898
+ tryAppCheck(): void;
1899
+ /**
1900
+ * @inheritDoc
1901
+ */
1902
+ unlisten(query: QueryContext, tag: number | null): void;
1903
+ private sendUnlisten_;
1904
+ onDisconnectPut(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
1905
+ onDisconnectMerge(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
1906
+ onDisconnectCancel(pathString: string, onComplete?: (a: string, b: string) => void): void;
1907
+ private sendOnDisconnect_;
1908
+ put(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void, hash?: string): void;
1909
+ merge(pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
1910
+ putInternal(action: string, pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
1911
+ private sendPut_;
1912
+ reportStats(stats: {
1913
+ [k: string]: unknown;
1914
+ }): void;
1915
+ private onDataMessage_;
1916
+ private onDataPush_;
1917
+ private onReady_;
1918
+ private scheduleConnect_;
1919
+ private initConnection_;
1920
+ private onVisible_;
1921
+ private onOnline_;
1922
+ private onRealtimeDisconnect_;
1923
+ private establishConnection_;
1924
+ interrupt(reason: string): void;
1925
+ resume(reason: string): void;
1926
+ private handleTimestamp_;
1927
+ private cancelSentTransactions_;
1928
+ private onListenRevoked_;
1929
+ private removeListen_;
1930
+ private onAuthRevoked_;
1931
+ private onAppCheckRevoked_;
1932
+ private onSecurityDebugPacket_;
1933
+ private restoreState_;
1934
+ /**
1935
+ * Sends client stats for first connection
1936
+ */
1937
+ private sendConnectStats_;
1938
+ private shouldReconnect_;
1939
+ }
1940
+
1941
+ declare class PriorityIndex extends Index {
1942
+ compare(a: NamedNode, b: NamedNode): number;
1943
+ isDefinedOn(node: Node_2): boolean;
1944
+ indexedValueChanged(oldNode: Node_2, newNode: Node_2): boolean;
1945
+ minPost(): NamedNode;
1946
+ maxPost(): NamedNode;
1947
+ makePost(indexValue: unknown, name: string): NamedNode;
1948
+ /**
1949
+ * @returns String representation for inclusion in a query spec
1950
+ */
1951
+ toString(): string;
1952
+ }
1953
+
1954
+ /**
1955
+ * Generates a new child location using a unique key and returns its
1956
+ * `Reference`.
1957
+ *
1958
+ * This is the most common pattern for adding data to a collection of items.
1959
+ *
1960
+ * If you provide a value to `push()`, the value is written to the
1961
+ * generated location. If you don't pass a value, nothing is written to the
1962
+ * database and the child remains empty (but you can use the `Reference`
1963
+ * elsewhere).
1964
+ *
1965
+ * The unique keys generated by `push()` are ordered by the current time, so the
1966
+ * resulting list of items is chronologically sorted. The keys are also
1967
+ * designed to be unguessable (they contain 72 random bits of entropy).
1968
+ *
1969
+ * See {@link https://firebase.google.com/docs/database/web/lists-of-data#append_to_a_list_of_data | Append to a list of data}.
1970
+ * See {@link https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html | The 2^120 Ways to Ensure Unique Identifiers}.
1971
+ *
1972
+ * @param parent - The parent location.
1973
+ * @param value - Optional value to be written at the generated location.
1974
+ * @returns Combined `Promise` and `Reference`; resolves when write is complete,
1975
+ * but can be used immediately as the `Reference` to the child location.
1976
+ */
1977
+ export declare function push(parent: DatabaseReference, value?: unknown): ThenableReference;
1978
+
1979
+ /**
1980
+ * @license
1981
+ * Copyright 2021 Google LLC
1982
+ *
1983
+ * Licensed under the Apache License, Version 2.0 (the "License");
1984
+ * you may not use this file except in compliance with the License.
1985
+ * You may obtain a copy of the License at
1986
+ *
1987
+ * http://www.apache.org/licenses/LICENSE-2.0
1988
+ *
1989
+ * Unless required by applicable law or agreed to in writing, software
1990
+ * distributed under the License is distributed on an "AS IS" BASIS,
1991
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1992
+ * See the License for the specific language governing permissions and
1993
+ * limitations under the License.
1994
+ */
1995
+ /**
1996
+ * A `Query` sorts and filters the data at a Database location so only a subset
1997
+ * of the child data is included. This can be used to order a collection of
1998
+ * data by some attribute (for example, height of dinosaurs) as well as to
1999
+ * restrict a large list of items (for example, chat messages) down to a number
2000
+ * suitable for synchronizing to the client. Queries are created by chaining
2001
+ * together one or more of the filter methods defined here.
2002
+ *
2003
+ * Just as with a `DatabaseReference`, you can receive data from a `Query` by using the
2004
+ * `on*()` methods. You will only receive events and `DataSnapshot`s for the
2005
+ * subset of the data that matches your query.
2006
+ *
2007
+ * See {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data}
2008
+ * for more information.
2009
+ */
2010
+ export declare interface Query extends QueryContext {
2011
+ /** The `DatabaseReference` for the `Query`'s location. */
2012
+ readonly ref: DatabaseReference;
2013
+ /**
2014
+ * Returns whether or not the current and provided queries represent the same
2015
+ * location, have the same query parameters, and are from the same instance of
2016
+ * `FirebaseApp`.
2017
+ *
2018
+ * Two `DatabaseReference` objects are equivalent if they represent the same location
2019
+ * and are from the same instance of `FirebaseApp`.
2020
+ *
2021
+ * Two `Query` objects are equivalent if they represent the same location,
2022
+ * have the same query parameters, and are from the same instance of
2023
+ * `FirebaseApp`. Equivalent queries share the same sort order, limits, and
2024
+ * starting and ending points.
2025
+ *
2026
+ * @param other - The query to compare against.
2027
+ * @returns Whether or not the current and provided queries are equivalent.
2028
+ */
2029
+ isEqual(other: Query | null): boolean;
2030
+ /**
2031
+ * Returns a JSON-serializable representation of this object.
2032
+ *
2033
+ * @returns A JSON-serializable representation of this object.
2034
+ */
2035
+ toJSON(): string;
2036
+ /**
2037
+ * Gets the absolute URL for this location.
2038
+ *
2039
+ * The `toString()` method returns a URL that is ready to be put into a
2040
+ * browser, curl command, or a `refFromURL()` call. Since all of those expect
2041
+ * the URL to be url-encoded, `toString()` returns an encoded URL.
2042
+ *
2043
+ * Append '.json' to the returned URL when typed into a browser to download
2044
+ * JSON-formatted data. If the location is secured (that is, not publicly
2045
+ * readable), you will get a permission-denied error.
2046
+ *
2047
+ * @returns The absolute URL for this location.
2048
+ */
2049
+ toString(): string;
2050
+ }
2051
+
2052
+ /**
2053
+ * Creates a new immutable instance of `Query` that is extended to also include
2054
+ * additional query constraints.
2055
+ *
2056
+ * @param query - The Query instance to use as a base for the new constraints.
2057
+ * @param queryConstraints - The list of `QueryConstraint`s to apply.
2058
+ * @throws if any of the provided query constraints cannot be combined with the
2059
+ * existing or new constraints.
2060
+ */
2061
+ export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;
2062
+
2063
+ /**
2064
+ * A `QueryConstraint` is used to narrow the set of documents returned by a
2065
+ * Database query. `QueryConstraint`s are created by invoking {@link endAt},
2066
+ * {@link endBefore}, {@link startAt}, {@link startAfter}, {@link
2067
+ * limitToFirst}, {@link limitToLast}, {@link orderByChild},
2068
+ * {@link orderByChild}, {@link orderByKey} , {@link orderByPriority} ,
2069
+ * {@link orderByValue} or {@link equalTo} and
2070
+ * can then be passed to {@link query} to create a new query instance that
2071
+ * also contains this `QueryConstraint`.
2072
+ */
2073
+ export declare abstract class QueryConstraint {
2074
+ /** The type of this query constraints */
2075
+ abstract readonly type: QueryConstraintType;
2076
+ /**
2077
+ * Takes the provided `Query` and returns a copy of the `Query` with this
2078
+ * `QueryConstraint` applied.
2079
+ */
2080
+ abstract _apply<T>(query: _QueryImpl): _QueryImpl;
2081
+ }
2082
+
2083
+ /** Describes the different query constraints available in this SDK. */
2084
+ export declare type QueryConstraintType = 'endAt' | 'endBefore' | 'startAt' | 'startAfter' | 'limitToFirst' | 'limitToLast' | 'orderByChild' | 'orderByKey' | 'orderByPriority' | 'orderByValue' | 'equalTo';
2085
+
2086
+ declare interface QueryContext {
2087
+ readonly _queryIdentifier: string;
2088
+ readonly _queryObject: object;
2089
+ readonly _repo: Repo;
2090
+ readonly _path: Path;
2091
+ readonly _queryParams: _QueryParams;
2092
+ }
2093
+
2094
+ /**
2095
+ * @internal
2096
+ */
2097
+ export declare class _QueryImpl implements Query, QueryContext {
2098
+ readonly _repo: Repo;
2099
+ readonly _path: Path;
2100
+ readonly _queryParams: _QueryParams;
2101
+ readonly _orderByCalled: boolean;
2102
+ /**
2103
+ * @hideconstructor
2104
+ */
2105
+ constructor(_repo: Repo, _path: Path, _queryParams: _QueryParams, _orderByCalled: boolean);
2106
+ get key(): string | null;
2107
+ get ref(): DatabaseReference;
2108
+ get _queryIdentifier(): string;
2109
+ /**
2110
+ * An object representation of the query parameters used by this Query.
2111
+ */
2112
+ get _queryObject(): object;
2113
+ isEqual(other: _QueryImpl | null): boolean;
2114
+ toJSON(): string;
2115
+ toString(): string;
2116
+ }
2117
+
2118
+ /**
2119
+ * This class is an immutable-from-the-public-api struct containing a set of query parameters defining a
2120
+ * range to be returned for a particular location. It is assumed that validation of parameters is done at the
2121
+ * user-facing API level, so it is not done here.
2122
+ *
2123
+ * @internal
2124
+ */
2125
+ export declare class _QueryParams {
2126
+ limitSet_: boolean;
2127
+ startSet_: boolean;
2128
+ startNameSet_: boolean;
2129
+ startAfterSet_: boolean;
2130
+ endSet_: boolean;
2131
+ endNameSet_: boolean;
2132
+ endBeforeSet_: boolean;
2133
+ limit_: number;
2134
+ viewFrom_: string;
2135
+ indexStartValue_: unknown | null;
2136
+ indexStartName_: string;
2137
+ indexEndValue_: unknown | null;
2138
+ indexEndName_: string;
2139
+ index_: PriorityIndex;
2140
+ hasStart(): boolean;
2141
+ /**
2142
+ * @returns True if it would return from left.
2143
+ */
2144
+ isViewFromLeft(): boolean;
2145
+ /**
2146
+ * Only valid to call if hasStart() returns true
2147
+ */
2148
+ getIndexStartValue(): unknown;
2149
+ /**
2150
+ * Only valid to call if hasStart() returns true.
2151
+ * Returns the starting key name for the range defined by these query parameters
2152
+ */
2153
+ getIndexStartName(): string;
2154
+ hasEnd(): boolean;
2155
+ /**
2156
+ * Only valid to call if hasEnd() returns true.
2157
+ */
2158
+ getIndexEndValue(): unknown;
2159
+ /**
2160
+ * Only valid to call if hasEnd() returns true.
2161
+ * Returns the end key name for the range defined by these query parameters
2162
+ */
2163
+ getIndexEndName(): string;
2164
+ hasLimit(): boolean;
2165
+ /**
2166
+ * @returns True if a limit has been set and it has been explicitly anchored
2167
+ */
2168
+ hasAnchoredLimit(): boolean;
2169
+ /**
2170
+ * Only valid to call if hasLimit() returns true
2171
+ */
2172
+ getLimit(): number;
2173
+ getIndex(): Index;
2174
+ loadsAllData(): boolean;
2175
+ isDefault(): boolean;
2176
+ copy(): _QueryParams;
2177
+ }
2178
+
2179
+ /**
2180
+ *
2181
+ * Returns a `Reference` representing the location in the Database
2182
+ * corresponding to the provided path. If no path is provided, the `Reference`
2183
+ * will point to the root of the Database.
2184
+ *
2185
+ * @param db - The database instance to obtain a reference for.
2186
+ * @param path - Optional path representing the location the returned
2187
+ * `Reference` will point. If not provided, the returned `Reference` will
2188
+ * point to the root of the Database.
2189
+ * @returns If a path is provided, a `Reference`
2190
+ * pointing to the provided path. Otherwise, a `Reference` pointing to the
2191
+ * root of the Database.
2192
+ */
2193
+ export declare function ref(db: Database, path?: string): DatabaseReference;
2194
+
2195
+ /**
2196
+ * @internal
2197
+ */
2198
+ export declare class _ReferenceImpl extends _QueryImpl implements DatabaseReference {
2199
+ /** @hideconstructor */
2200
+ constructor(repo: Repo, path: Path);
2201
+ get parent(): _ReferenceImpl | null;
2202
+ get root(): _ReferenceImpl;
2203
+ }
2204
+
2205
+ /**
2206
+ * Returns a `Reference` representing the location in the Database
2207
+ * corresponding to the provided Firebase URL.
2208
+ *
2209
+ * An exception is thrown if the URL is not a valid Firebase Database URL or it
2210
+ * has a different domain than the current `Database` instance.
2211
+ *
2212
+ * Note that all query parameters (`orderBy`, `limitToLast`, etc.) are ignored
2213
+ * and are not applied to the returned `Reference`.
2214
+ *
2215
+ * @param db - The database instance to obtain a reference for.
2216
+ * @param url - The Firebase URL at which the returned `Reference` will
2217
+ * point.
2218
+ * @returns A `Reference` pointing to the provided
2219
+ * Firebase URL.
2220
+ */
2221
+ export declare function refFromURL(db: Database, url: string): DatabaseReference;
2222
+
2223
+ /**
2224
+ * Removes the data at this Database location.
2225
+ *
2226
+ * Any data at child locations will also be deleted.
2227
+ *
2228
+ * The effect of the remove will be visible immediately and the corresponding
2229
+ * event 'value' will be triggered. Synchronization of the remove to the
2230
+ * Firebase servers will also be started, and the returned Promise will resolve
2231
+ * when complete. If provided, the onComplete callback will be called
2232
+ * asynchronously after synchronization has finished.
2233
+ *
2234
+ * @param ref - The location to remove.
2235
+ * @returns Resolves when remove on server is complete.
2236
+ */
2237
+ export declare function remove(ref: DatabaseReference): Promise<void>;
2238
+
2239
+ /**
2240
+ * A connection to a single data repository.
2241
+ */
2242
+ declare class Repo {
2243
+ repoInfo_: RepoInfo;
2244
+ forceRestClient_: boolean;
2245
+ authTokenProvider_: AuthTokenProvider;
2246
+ appCheckProvider_: AppCheckTokenProvider;
2247
+ /** Key for uniquely identifying this repo, used in RepoManager */
2248
+ readonly key: string;
2249
+ dataUpdateCount: number;
2250
+ infoSyncTree_: SyncTree;
2251
+ serverSyncTree_: SyncTree;
2252
+ stats_: StatsCollection;
2253
+ statsListener_: StatsListener | null;
2254
+ eventQueue_: EventQueue;
2255
+ nextWriteId_: number;
2256
+ server_: ServerActions;
2257
+ statsReporter_: StatsReporter;
2258
+ infoData_: SnapshotHolder;
2259
+ interceptServerDataCallback_: ((a: string, b: unknown) => void) | null;
2260
+ /** A list of data pieces and paths to be set when this client disconnects. */
2261
+ onDisconnect_: SparseSnapshotTree;
2262
+ /** Stores queues of outstanding transactions for Firebase locations. */
2263
+ transactionQueueTree_: Tree<Transaction[]>;
2264
+ persistentConnection_: PersistentConnection | null;
2265
+ constructor(repoInfo_: RepoInfo, forceRestClient_: boolean, authTokenProvider_: AuthTokenProvider, appCheckProvider_: AppCheckTokenProvider);
2266
+ /**
2267
+ * @returns The URL corresponding to the root of this Firebase.
2268
+ */
2269
+ toString(): string;
2270
+ }
2271
+
2272
+ /**
2273
+ * A class that holds metadata about a Repo object
2274
+ */
2275
+ declare class RepoInfo {
2276
+ readonly secure: boolean;
2277
+ readonly namespace: string;
2278
+ readonly webSocketOnly: boolean;
2279
+ readonly nodeAdmin: boolean;
2280
+ readonly persistenceKey: string;
2281
+ readonly includeNamespaceInQueryParams: boolean;
2282
+ readonly isUsingEmulator: boolean;
2283
+ readonly emulatorOptions: RepoInfoEmulatorOptions | null;
2284
+ private _host;
2285
+ private _domain;
2286
+ internalHost: string;
2287
+ /**
2288
+ * @param host - Hostname portion of the url for the repo
2289
+ * @param secure - Whether or not this repo is accessed over ssl
2290
+ * @param namespace - The namespace represented by the repo
2291
+ * @param webSocketOnly - Whether to prefer websockets over all other transports (used by Nest).
2292
+ * @param nodeAdmin - Whether this instance uses Admin SDK credentials
2293
+ * @param persistenceKey - Override the default session persistence storage key
2294
+ */
2295
+ constructor(host: string, secure: boolean, namespace: string, webSocketOnly: boolean, nodeAdmin?: boolean, persistenceKey?: string, includeNamespaceInQueryParams?: boolean, isUsingEmulator?: boolean, emulatorOptions?: RepoInfoEmulatorOptions | null);
2296
+ isCacheableHost(): boolean;
2297
+ isCustomHost(): boolean;
2298
+ get host(): string;
2299
+ set host(newHost: string);
2300
+ toString(): string;
2301
+ toURLString(): string;
2302
+ }
2303
+
2304
+ declare interface RepoInfoEmulatorOptions {
2305
+ mockUserToken?: string | EmulatorMockTokenOptions;
2306
+ }
2307
+
2308
+ /**
2309
+ * This function should only ever be called to CREATE a new database instance.
2310
+ * @internal
2311
+ */
2312
+ export declare function _repoManagerDatabaseFromApp(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>, url?: string, nodeAdmin?: boolean): Database;
2313
+
2314
+ /**
2315
+ * Atomically modifies the data at this location.
2316
+ *
2317
+ * Atomically modify the data at this location. Unlike a normal `set()`, which
2318
+ * just overwrites the data regardless of its previous value, `runTransaction()` is
2319
+ * used to modify the existing value to a new value, ensuring there are no
2320
+ * conflicts with other clients writing to the same location at the same time.
2321
+ *
2322
+ * To accomplish this, you pass `runTransaction()` an update function which is
2323
+ * used to transform the current value into a new value. If another client
2324
+ * writes to the location before your new value is successfully written, your
2325
+ * update function will be called again with the new current value, and the
2326
+ * write will be retried. This will happen repeatedly until your write succeeds
2327
+ * without conflict or you abort the transaction by not returning a value from
2328
+ * your update function.
2329
+ *
2330
+ * Note: Modifying data with `set()` will cancel any pending transactions at
2331
+ * that location, so extreme care should be taken if mixing `set()` and
2332
+ * `runTransaction()` to update the same data.
2333
+ *
2334
+ * Note: When using transactions with Security and Firebase Rules in place, be
2335
+ * aware that a client needs `.read` access in addition to `.write` access in
2336
+ * order to perform a transaction. This is because the client-side nature of
2337
+ * transactions requires the client to read the data in order to transactionally
2338
+ * update it.
2339
+ *
2340
+ * @param ref - The location to atomically modify.
2341
+ * @param transactionUpdate - A developer-supplied function which will be passed
2342
+ * the current data stored at this location (as a JavaScript object). The
2343
+ * function should return the new value it would like written (as a JavaScript
2344
+ * object). If `undefined` is returned (i.e. you return with no arguments) the
2345
+ * transaction will be aborted and the data at this location will not be
2346
+ * modified.
2347
+ * @param options - An options object to configure transactions.
2348
+ * @returns A `Promise` that can optionally be used instead of the `onComplete`
2349
+ * callback to handle success and failure.
2350
+ */
2351
+ export declare function runTransaction(ref: DatabaseReference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
2352
+
2353
+ /**
2354
+ * Interface defining the set of actions that can be performed against the Firebase server
2355
+ * (basically corresponds to our wire protocol).
2356
+ *
2357
+ * @interface
2358
+ */
2359
+ declare abstract class ServerActions {
2360
+ abstract listen(query: QueryContext, currentHashFn: () => string, tag: number | null, onComplete: (a: string, b: unknown) => void): void;
2361
+ /**
2362
+ * Remove a listen.
2363
+ */
2364
+ abstract unlisten(query: QueryContext, tag: number | null): void;
2365
+ /**
2366
+ * Get the server value satisfying this query.
2367
+ */
2368
+ abstract get(query: QueryContext): Promise<string>;
2369
+ put(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void, hash?: string): void;
2370
+ merge(pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
2371
+ /**
2372
+ * Refreshes the auth token for the current connection.
2373
+ * @param token - The authentication token
2374
+ */
2375
+ refreshAuthToken(token: string): void;
2376
+ /**
2377
+ * Refreshes the app check token for the current connection.
2378
+ * @param token The app check token
2379
+ */
2380
+ refreshAppCheckToken(token: string): void;
2381
+ onDisconnectPut(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
2382
+ onDisconnectMerge(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
2383
+ onDisconnectCancel(pathString: string, onComplete?: (a: string, b: string) => void): void;
2384
+ reportStats(stats: {
2385
+ [k: string]: unknown;
2386
+ }): void;
2387
+ }
2388
+
2389
+ /**
2390
+ * @license
2391
+ * Copyright 2020 Google LLC
2392
+ *
2393
+ * Licensed under the Apache License, Version 2.0 (the "License");
2394
+ * you may not use this file except in compliance with the License.
2395
+ * You may obtain a copy of the License at
2396
+ *
2397
+ * http://www.apache.org/licenses/LICENSE-2.0
2398
+ *
2399
+ * Unless required by applicable law or agreed to in writing, software
2400
+ * distributed under the License is distributed on an "AS IS" BASIS,
2401
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2402
+ * See the License for the specific language governing permissions and
2403
+ * limitations under the License.
2404
+ */
2405
+ /**
2406
+ * Returns a placeholder value for auto-populating the current timestamp (time
2407
+ * since the Unix epoch, in milliseconds) as determined by the Firebase
2408
+ * servers.
2409
+ */
2410
+ export declare function serverTimestamp(): object;
2411
+
2412
+ /**
2413
+ * Writes data to this Database location.
2414
+ *
2415
+ * This will overwrite any data at this location and all child locations.
2416
+ *
2417
+ * The effect of the write will be visible immediately, and the corresponding
2418
+ * events ("value", "child_added", etc.) will be triggered. Synchronization of
2419
+ * the data to the Firebase servers will also be started, and the returned
2420
+ * Promise will resolve when complete. If provided, the `onComplete` callback
2421
+ * will be called asynchronously after synchronization has finished.
2422
+ *
2423
+ * Passing `null` for the new value is equivalent to calling `remove()`; namely,
2424
+ * all data at this location and all child locations will be deleted.
2425
+ *
2426
+ * `set()` will remove any priority stored at this location, so if priority is
2427
+ * meant to be preserved, you need to use `setWithPriority()` instead.
2428
+ *
2429
+ * Note that modifying data with `set()` will cancel any pending transactions
2430
+ * at that location, so extreme care should be taken if mixing `set()` and
2431
+ * `transaction()` to modify the same data.
2432
+ *
2433
+ * A single `set()` will generate a single "value" event at the location where
2434
+ * the `set()` was performed.
2435
+ *
2436
+ * @param ref - The location to write to.
2437
+ * @param value - The value to be written (string, number, boolean, object,
2438
+ * array, or null).
2439
+ * @returns Resolves when write to server is complete.
2440
+ */
2441
+ export declare function set(ref: DatabaseReference, value: unknown): Promise<void>;
2442
+
2443
+ /**
2444
+ * Sets a priority for the data at this Database location.
2445
+ *
2446
+ * Applications need not use priority but can order collections by
2447
+ * ordinary properties (see
2448
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
2449
+ * ).
2450
+ *
2451
+ * @param ref - The location to write to.
2452
+ * @param priority - The priority to be written (string, number, or null).
2453
+ * @returns Resolves when write to server is complete.
2454
+ */
2455
+ export declare function setPriority(ref: DatabaseReference, priority: string | number | null): Promise<void>;
2456
+
2457
+ /**
2458
+ * SDK_VERSION should be set before any database instance is created
2459
+ * @internal
2460
+ */
2461
+ export declare function _setSDKVersion(version: string): void;
2462
+
2463
+ /**
2464
+ * Writes data the Database location. Like `set()` but also specifies the
2465
+ * priority for that data.
2466
+ *
2467
+ * Applications need not use priority but can order collections by
2468
+ * ordinary properties (see
2469
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#sorting_and_filtering_data | Sorting and filtering data}
2470
+ * ).
2471
+ *
2472
+ * @param ref - The location to write to.
2473
+ * @param value - The value to be written (string, number, boolean, object,
2474
+ * array, or null).
2475
+ * @param priority - The priority to be written (string, number, or null).
2476
+ * @returns Resolves when write to server is complete.
2477
+ */
2478
+ export declare function setWithPriority(ref: DatabaseReference, value: unknown, priority: string | number | null): Promise<void>;
2479
+
2480
+ /**
2481
+ * Mutable object which basically just stores a reference to the "latest" immutable snapshot.
2482
+ */
2483
+ declare class SnapshotHolder {
2484
+ private rootNode_;
2485
+ getNode(path: Path): Node_2;
2486
+ updateSnapshot(path: Path, newSnapshotNode: Node_2): void;
2487
+ }
2488
+
2489
+ /**
2490
+ * An immutable sorted map implementation, based on a Left-leaning Red-Black
2491
+ * tree.
2492
+ */
2493
+ declare class SortedMap<K, V> {
2494
+ private comparator_;
2495
+ private root_;
2496
+ /**
2497
+ * Always use the same empty node, to reduce memory.
2498
+ */
2499
+ static EMPTY_NODE: LLRBEmptyNode<unknown, unknown>;
2500
+ /**
2501
+ * @param comparator_ - Key comparator.
2502
+ * @param root_ - Optional root node for the map.
2503
+ */
2504
+ constructor(comparator_: Comparator<K>, root_?: LLRBNode<K, V> | LLRBEmptyNode<K, V>);
2505
+ /**
2506
+ * Returns a copy of the map, with the specified key/value added or replaced.
2507
+ * (TODO: We should perhaps rename this method to 'put')
2508
+ *
2509
+ * @param key - Key to be added.
2510
+ * @param value - Value to be added.
2511
+ * @returns New map, with item added.
2512
+ */
2513
+ insert(key: K, value: V): SortedMap<K, V>;
2514
+ /**
2515
+ * Returns a copy of the map, with the specified key removed.
2516
+ *
2517
+ * @param key - The key to remove.
2518
+ * @returns New map, with item removed.
2519
+ */
2520
+ remove(key: K): SortedMap<K, V>;
2521
+ /**
2522
+ * Returns the value of the node with the given key, or null.
2523
+ *
2524
+ * @param key - The key to look up.
2525
+ * @returns The value of the node with the given key, or null if the
2526
+ * key doesn't exist.
2527
+ */
2528
+ get(key: K): V | null;
2529
+ /**
2530
+ * Returns the key of the item *before* the specified key, or null if key is the first item.
2531
+ * @param key - The key to find the predecessor of
2532
+ * @returns The predecessor key.
2533
+ */
2534
+ getPredecessorKey(key: K): K | null;
2535
+ /**
2536
+ * @returns True if the map is empty.
2537
+ */
2538
+ isEmpty(): boolean;
2539
+ /**
2540
+ * @returns The total number of nodes in the map.
2541
+ */
2542
+ count(): number;
2543
+ /**
2544
+ * @returns The minimum key in the map.
2545
+ */
2546
+ minKey(): K | null;
2547
+ /**
2548
+ * @returns The maximum key in the map.
2549
+ */
2550
+ maxKey(): K | null;
2551
+ /**
2552
+ * Traverses the map in key order and calls the specified action function
2553
+ * for each key/value pair.
2554
+ *
2555
+ * @param action - Callback function to be called
2556
+ * for each key/value pair. If action returns true, traversal is aborted.
2557
+ * @returns The first truthy value returned by action, or the last falsey
2558
+ * value returned by action
2559
+ */
2560
+ inorderTraversal(action: (k: K, v: V) => unknown): boolean;
2561
+ /**
2562
+ * Traverses the map in reverse key order and calls the specified action function
2563
+ * for each key/value pair.
2564
+ *
2565
+ * @param action - Callback function to be called
2566
+ * for each key/value pair. If action returns true, traversal is aborted.
2567
+ * @returns True if the traversal was aborted.
2568
+ */
2569
+ reverseTraversal(action: (k: K, v: V) => void): boolean;
2570
+ /**
2571
+ * Returns an iterator over the SortedMap.
2572
+ * @returns The iterator.
2573
+ */
2574
+ getIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
2575
+ getIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
2576
+ getReverseIteratorFrom<T>(key: K, resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
2577
+ getReverseIterator<T>(resultGenerator?: (k: K, v: V) => T): SortedMapIterator<K, V, T>;
2578
+ }
2579
+
2580
+ /**
2581
+ * An iterator over an LLRBNode.
2582
+ */
2583
+ declare class SortedMapIterator<K, V, T> {
2584
+ private isReverse_;
2585
+ private resultGenerator_;
2586
+ private nodeStack_;
2587
+ /**
2588
+ * @param node - Node to iterate.
2589
+ * @param isReverse_ - Whether or not to iterate in reverse
2590
+ */
2591
+ constructor(node: LLRBNode<K, V> | LLRBEmptyNode<K, V>, startKey: K | null, comparator: Comparator<K>, isReverse_: boolean, resultGenerator_?: ((k: K, v: V) => T) | null);
2592
+ getNext(): T;
2593
+ hasNext(): boolean;
2594
+ peek(): T;
2595
+ }
2596
+
2597
+ /**
2598
+ * Helper class to store a sparse set of snapshots.
2599
+ */
2600
+ declare interface SparseSnapshotTree {
2601
+ value: Node_2 | null;
2602
+ readonly children: Map<string, SparseSnapshotTree>;
2603
+ }
2604
+
2605
+ /**
2606
+ * Creates a `QueryConstraint` with the specified starting point (exclusive).
2607
+ *
2608
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
2609
+ * allows you to choose arbitrary starting and ending points for your queries.
2610
+ *
2611
+ * The starting point is exclusive. If only a value is provided, children
2612
+ * with a value greater than the specified value will be included in the query.
2613
+ * If a key is specified, then children must have a value greater than or equal
2614
+ * to the specified value and a a key name greater than the specified key.
2615
+ *
2616
+ * @param value - The value to start after. The argument type depends on which
2617
+ * `orderBy*()` function was used in this query. Specify a value that matches
2618
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
2619
+ * value must be a string.
2620
+ * @param key - The child key to start after. This argument is only allowed if
2621
+ * ordering by child, value, or priority.
2622
+ */
2623
+ export declare function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
2624
+
2625
+ /**
2626
+ * Creates a `QueryConstraint` with the specified starting point.
2627
+ *
2628
+ * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()`
2629
+ * allows you to choose arbitrary starting and ending points for your queries.
2630
+ *
2631
+ * The starting point is inclusive, so children with exactly the specified value
2632
+ * will be included in the query. The optional key argument can be used to
2633
+ * further limit the range of the query. If it is specified, then children that
2634
+ * have exactly the specified value must also have a key name greater than or
2635
+ * equal to the specified key.
2636
+ *
2637
+ * You can read more about `startAt()` in
2638
+ * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}.
2639
+ *
2640
+ * @param value - The value to start at. The argument type depends on which
2641
+ * `orderBy*()` function was used in this query. Specify a value that matches
2642
+ * the `orderBy*()` type. When used in combination with `orderByKey()`, the
2643
+ * value must be a string.
2644
+ * @param key - The child key to start at. This argument is only allowed if
2645
+ * ordering by child, value, or priority.
2646
+ */
2647
+ export declare function startAt(value?: number | string | boolean | null, key?: string): QueryConstraint;
2648
+
2649
+ /**
2650
+ * @license
2651
+ * Copyright 2017 Google LLC
2652
+ *
2653
+ * Licensed under the Apache License, Version 2.0 (the "License");
2654
+ * you may not use this file except in compliance with the License.
2655
+ * You may obtain a copy of the License at
2656
+ *
2657
+ * http://www.apache.org/licenses/LICENSE-2.0
2658
+ *
2659
+ * Unless required by applicable law or agreed to in writing, software
2660
+ * distributed under the License is distributed on an "AS IS" BASIS,
2661
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2662
+ * See the License for the specific language governing permissions and
2663
+ * limitations under the License.
2664
+ */
2665
+ /**
2666
+ * Tracks a collection of stats.
2667
+ */
2668
+ declare class StatsCollection {
2669
+ private counters_;
2670
+ incrementCounter(name: string, amount?: number): void;
2671
+ get(): {
2672
+ [k: string]: number;
2673
+ };
2674
+ }
2675
+
2676
+ /**
2677
+ * Returns the delta from the previous call to get stats.
2678
+ *
2679
+ * @param collection_ - The collection to "listen" to.
2680
+ */
2681
+ declare class StatsListener {
2682
+ private collection_;
2683
+ private last_;
2684
+ constructor(collection_: StatsCollection);
2685
+ get(): {
2686
+ [k: string]: number;
2687
+ };
2688
+ }
2689
+
2690
+ declare class StatsReporter {
2691
+ private server_;
2692
+ private statsListener_;
2693
+ statsToReport_: {
2694
+ [k: string]: boolean;
2695
+ };
2696
+ constructor(collection: StatsCollection, server_: ServerActions);
2697
+ private reportStats_;
2698
+ }
2699
+
2700
+ /**
2701
+ * SyncPoint represents a single location in a SyncTree with 1 or more event registrations, meaning we need to
2702
+ * maintain 1 or more Views at this location to cache server data and raise appropriate events for server changes
2703
+ * and user writes (set, transaction, update).
2704
+ *
2705
+ * It's responsible for:
2706
+ * - Maintaining the set of 1 or more views necessary at this location (a SyncPoint with 0 views should be removed).
2707
+ * - Proxying user / server operations to the views as appropriate (i.e. applyServerOverwrite,
2708
+ * applyUserOverwrite, etc.)
2709
+ */
2710
+ declare class SyncPoint {
2711
+ /**
2712
+ * The Views being tracked at this location in the tree, stored as a map where the key is a
2713
+ * queryId and the value is the View for that query.
2714
+ *
2715
+ * NOTE: This list will be quite small (usually 1, but perhaps 2 or 3; any more is an odd use case).
2716
+ */
2717
+ readonly views: Map<string, View>;
2718
+ }
2719
+
2720
+ /**
2721
+ * SyncTree is the central class for managing event callback registration, data caching, views
2722
+ * (query processing), and event generation. There are typically two SyncTree instances for
2723
+ * each Repo, one for the normal Firebase data, and one for the .info data.
2724
+ *
2725
+ * It has a number of responsibilities, including:
2726
+ * - Tracking all user event callbacks (registered via addEventRegistration() and removeEventRegistration()).
2727
+ * - Applying and caching data changes for user set(), transaction(), and update() calls
2728
+ * (applyUserOverwrite(), applyUserMerge()).
2729
+ * - Applying and caching data changes for server data changes (applyServerOverwrite(),
2730
+ * applyServerMerge()).
2731
+ * - Generating user-facing events for server and user changes (all of the apply* methods
2732
+ * return the set of events that need to be raised as a result).
2733
+ * - Maintaining the appropriate set of server listens to ensure we are always subscribed
2734
+ * to the correct set of paths and queries to satisfy the current set of user event
2735
+ * callbacks (listens are started/stopped using the provided listenProvider).
2736
+ *
2737
+ * NOTE: Although SyncTree tracks event callbacks and calculates events to raise, the actual
2738
+ * events are returned to the caller rather than raised synchronously.
2739
+ *
2740
+ */
2741
+ declare class SyncTree {
2742
+ listenProvider_: ListenProvider;
2743
+ /**
2744
+ * Tree of SyncPoints. There's a SyncPoint at any location that has 1 or more views.
2745
+ */
2746
+ syncPointTree_: ImmutableTree<SyncPoint>;
2747
+ /**
2748
+ * A tree of all pending user writes (user-initiated set()'s, transaction()'s, update()'s, etc.).
2749
+ */
2750
+ pendingWriteTree_: WriteTree;
2751
+ readonly tagToQueryMap: Map<number, string>;
2752
+ readonly queryToTagMap: Map<string, number>;
2753
+ /**
2754
+ * @param listenProvider_ - Used by SyncTree to start / stop listening
2755
+ * to server data.
2756
+ */
2757
+ constructor(listenProvider_: ListenProvider);
2758
+ }
2759
+
2760
+ /**
2761
+ * Forces the RepoManager to create Repos that use ReadonlyRestClient instead of PersistentConnection.
2762
+ * @internal
2763
+ */
2764
+ export declare const _TEST_ACCESS_forceRestClient: (forceRestClient: boolean) => void;
2765
+
2766
+ /**
2767
+ * @internal
2768
+ */
2769
+ export declare const _TEST_ACCESS_hijackHash: (newHash: () => string) => () => void;
2770
+
2771
+ /**
2772
+ * A `Promise` that can also act as a `DatabaseReference` when returned by
2773
+ * {@link push}. The reference is available immediately and the `Promise` resolves
2774
+ * as the write to the backend completes.
2775
+ */
2776
+ export declare interface ThenableReference extends DatabaseReference, Pick<Promise<DatabaseReference>, 'then' | 'catch'> {
2777
+ key: string;
2778
+ parent: DatabaseReference;
2779
+ }
2780
+
2781
+ declare interface Transaction {
2782
+ path: Path;
2783
+ update: (a: unknown) => unknown;
2784
+ onComplete: (error: Error | null, committed: boolean, node: Node_2 | null) => void;
2785
+ status: TransactionStatus;
2786
+ order: number;
2787
+ applyLocally: boolean;
2788
+ retryCount: number;
2789
+ unwatcher: () => void;
2790
+ abortReason: string | null;
2791
+ currentWriteId: number;
2792
+ currentInputSnapshot: Node_2 | null;
2793
+ currentOutputSnapshotRaw: Node_2 | null;
2794
+ currentOutputSnapshotResolved: Node_2 | null;
2795
+ }
2796
+
2797
+ /** An options object to configure transactions. */
2798
+ export declare interface TransactionOptions {
2799
+ /**
2800
+ * By default, events are raised each time the transaction update function
2801
+ * runs. So if it is run multiple times, you may see intermediate states. You
2802
+ * can set this to false to suppress these intermediate states and instead
2803
+ * wait until the transaction has completed before events are raised.
2804
+ */
2805
+ readonly applyLocally?: boolean;
2806
+ }
2807
+
2808
+ /**
2809
+ * A type for the resolve value of {@link runTransaction}.
2810
+ */
2811
+ export declare class TransactionResult {
2812
+ /** Whether the transaction was successfully committed. */
2813
+ readonly committed: boolean;
2814
+ /** The resulting data snapshot. */
2815
+ readonly snapshot: DataSnapshot;
2816
+ /** @hideconstructor */
2817
+ constructor(
2818
+ /** Whether the transaction was successfully committed. */
2819
+ committed: boolean,
2820
+ /** The resulting data snapshot. */
2821
+ snapshot: DataSnapshot);
2822
+ /** Returns a JSON-serializable representation of this object. */
2823
+ toJSON(): object;
2824
+ }
2825
+
2826
+ declare const enum TransactionStatus {
2827
+ RUN = 0,
2828
+ SENT = 1,
2829
+ COMPLETED = 2,
2830
+ SENT_NEEDS_ABORT = 3,
2831
+ NEEDS_ABORT = 4
2832
+ }
2833
+
2834
+ /**
2835
+ * A light-weight tree, traversable by path. Nodes can have both values and children.
2836
+ * Nodes are not enumerated (by forEachChild) unless they have a value or non-empty
2837
+ * children.
2838
+ */
2839
+ declare class Tree<T> {
2840
+ readonly name: string;
2841
+ readonly parent: Tree<T> | null;
2842
+ node: TreeNode<T>;
2843
+ /**
2844
+ * @param name - Optional name of the node.
2845
+ * @param parent - Optional parent node.
2846
+ * @param node - Optional node to wrap.
2847
+ */
2848
+ constructor(name?: string, parent?: Tree<T> | null, node?: TreeNode<T>);
2849
+ }
2850
+
2851
+ /**
2852
+ * Node in a Tree.
2853
+ */
2854
+ declare interface TreeNode<T> {
2855
+ children: Record<string, TreeNode<T>>;
2856
+ childCount: number;
2857
+ value?: T;
2858
+ }
2859
+
2860
+ /** A callback that can invoked to remove a listener. */
2861
+ export declare type Unsubscribe = () => void;
2862
+
2863
+ /**
2864
+ * Writes multiple values to the Database at once.
2865
+ *
2866
+ * The `values` argument contains multiple property-value pairs that will be
2867
+ * written to the Database together. Each child property can either be a simple
2868
+ * property (for example, "name") or a relative path (for example,
2869
+ * "name/first") from the current location to the data to update.
2870
+ *
2871
+ * As opposed to the `set()` method, `update()` can be use to selectively update
2872
+ * only the referenced properties at the current location (instead of replacing
2873
+ * all the child properties at the current location).
2874
+ *
2875
+ * The effect of the write will be visible immediately, and the corresponding
2876
+ * events ('value', 'child_added', etc.) will be triggered. Synchronization of
2877
+ * the data to the Firebase servers will also be started, and the returned
2878
+ * Promise will resolve when complete. If provided, the `onComplete` callback
2879
+ * will be called asynchronously after synchronization has finished.
2880
+ *
2881
+ * A single `update()` will generate a single "value" event at the location
2882
+ * where the `update()` was performed, regardless of how many children were
2883
+ * modified.
2884
+ *
2885
+ * Note that modifying data with `update()` will cancel any pending
2886
+ * transactions at that location, so extreme care should be taken if mixing
2887
+ * `update()` and `transaction()` to modify the same data.
2888
+ *
2889
+ * Passing `null` to `update()` will remove the data at this location.
2890
+ *
2891
+ * See
2892
+ * {@link https://firebase.googleblog.com/2015/09/introducing-multi-location-updates-and_86.html | Introducing multi-location updates and more}.
2893
+ *
2894
+ * @param ref - The location to write to.
2895
+ * @param values - Object containing multiple values.
2896
+ * @returns Resolves when update on server is complete.
2897
+ */
2898
+ export declare function update(ref: DatabaseReference, values: object): Promise<void>;
2899
+
2900
+ /**
2901
+ * A user callback. Callbacks issues from the Legacy SDK maintain references
2902
+ * to the original user-issued callbacks, which allows equality
2903
+ * comparison by reference even though this callbacks are wrapped before
2904
+ * they can be passed to the firebase@exp SDK.
2905
+ *
2906
+ * @internal
2907
+ */
2908
+ export declare interface _UserCallback {
2909
+ (dataSnapshot: DataSnapshot, previousChildName?: string | null): unknown;
2910
+ userCallback?: unknown;
2911
+ context?: object | null;
2912
+ }
2913
+
2914
+ /**
2915
+ * @internal
2916
+ */
2917
+ export declare const _validatePathString: (fnName: string, argumentName: string, pathString: string, optional: boolean) => void;
2918
+
2919
+ /**
2920
+ * @internal
2921
+ */
2922
+ export declare const _validateWritablePath: (fnName: string, path: Path) => void;
2923
+
2924
+ /**
2925
+ * A view represents a specific location and query that has 1 or more event registrations.
2926
+ *
2927
+ * It does several things:
2928
+ * - Maintains the list of event registrations for this location/query.
2929
+ * - Maintains a cache of the data visible for this location/query.
2930
+ * - Applies new operations (via applyOperation), updates the cache, and based on the event
2931
+ * registrations returns the set of events to be raised.
2932
+ */
2933
+ declare class View {
2934
+ private query_;
2935
+ processor_: ViewProcessor;
2936
+ viewCache_: ViewCache;
2937
+ eventRegistrations_: EventRegistration[];
2938
+ eventGenerator_: EventGenerator;
2939
+ constructor(query_: QueryContext, initialViewCache: ViewCache);
2940
+ get query(): QueryContext;
2941
+ }
2942
+
2943
+ /**
2944
+ * Stores the data we have cached for a view.
2945
+ *
2946
+ * serverSnap is the cached server data, eventSnap is the cached event data (server data plus any local writes).
2947
+ */
2948
+ declare interface ViewCache {
2949
+ readonly eventCache: CacheNode;
2950
+ readonly serverCache: CacheNode;
2951
+ }
2952
+
2953
+ declare interface ViewProcessor {
2954
+ readonly filter: NodeFilter_2;
2955
+ }
2956
+
2957
+ /**
2958
+ * Defines a single user-initiated write operation. May be the result of a set(), transaction(), or update() call. In
2959
+ * the case of a set() or transaction, snap will be non-null. In the case of an update(), children will be non-null.
2960
+ */
2961
+ declare interface WriteRecord {
2962
+ writeId: number;
2963
+ path: Path;
2964
+ snap?: Node_2 | null;
2965
+ children?: {
2966
+ [k: string]: Node_2;
2967
+ } | null;
2968
+ visible: boolean;
2969
+ }
2970
+
2971
+ /**
2972
+ * WriteTree tracks all pending user-initiated writes and has methods to calculate the result of merging them
2973
+ * with underlying server data (to create "event cache" data). Pending writes are added with addOverwrite()
2974
+ * and addMerge(), and removed with removeWrite().
2975
+ */
2976
+ declare interface WriteTree {
2977
+ /**
2978
+ * A tree tracking the result of applying all visible writes. This does not include transactions with
2979
+ * applyLocally=false or writes that are completely shadowed by other writes.
2980
+ */
2981
+ visibleWrites: CompoundWrite;
2982
+ /**
2983
+ * A list of all pending writes, regardless of visibility and shadowed-ness. Used to calculate arbitrary
2984
+ * sets of the changed data, such as hidden writes (from transactions) or changes with certain writes excluded (also
2985
+ * used by transactions).
2986
+ */
2987
+ allWrites: WriteRecord[];
2988
+ lastWriteId: number;
2989
+ }
2990
+
2991
+ export { }