@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,205 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { CompoundWrite } from './CompoundWrite';
18
+ import { ChildrenNode } from './snap/ChildrenNode';
19
+ import { Index } from './snap/indexes/Index';
20
+ import { NamedNode, Node } from './snap/Node';
21
+ import { Path } from './util/Path';
22
+ import { CacheNode } from './view/CacheNode';
23
+ /**
24
+ * Defines a single user-initiated write operation. May be the result of a set(), transaction(), or update() call. In
25
+ * the case of a set() or transaction, snap will be non-null. In the case of an update(), children will be non-null.
26
+ */
27
+ export interface WriteRecord {
28
+ writeId: number;
29
+ path: Path;
30
+ snap?: Node | null;
31
+ children?: {
32
+ [k: string]: Node;
33
+ } | null;
34
+ visible: boolean;
35
+ }
36
+ /**
37
+ * Create a new WriteTreeRef for the given path. For use with a new sync point at the given path.
38
+ *
39
+ */
40
+ export declare function writeTreeChildWrites(writeTree: WriteTree, path: Path): WriteTreeRef;
41
+ /**
42
+ * Record a new overwrite from user code.
43
+ *
44
+ * @param visible - This is set to false by some transactions. It should be excluded from event caches
45
+ */
46
+ export declare function writeTreeAddOverwrite(writeTree: WriteTree, path: Path, snap: Node, writeId: number, visible?: boolean): void;
47
+ /**
48
+ * Record a new merge from user code.
49
+ */
50
+ export declare function writeTreeAddMerge(writeTree: WriteTree, path: Path, changedChildren: {
51
+ [k: string]: Node;
52
+ }, writeId: number): void;
53
+ export declare function writeTreeGetWrite(writeTree: WriteTree, writeId: number): WriteRecord | null;
54
+ /**
55
+ * Remove a write (either an overwrite or merge) that has been successfully acknowledge by the server. Recalculates
56
+ * the tree if necessary. We return true if it may have been visible, meaning views need to reevaluate.
57
+ *
58
+ * @returns true if the write may have been visible (meaning we'll need to reevaluate / raise
59
+ * events as a result).
60
+ */
61
+ export declare function writeTreeRemoveWrite(writeTree: WriteTree, writeId: number): boolean;
62
+ /**
63
+ * Return a complete snapshot for the given path if there's visible write data at that path, else null.
64
+ * No server data is considered.
65
+ *
66
+ */
67
+ export declare function writeTreeGetCompleteWriteData(writeTree: WriteTree, path: Path): Node | null;
68
+ /**
69
+ * Given optional, underlying server data, and an optional set of constraints (exclude some sets, include hidden
70
+ * writes), attempt to calculate a complete snapshot for the given path
71
+ *
72
+ * @param writeIdsToExclude - An optional set to be excluded
73
+ * @param includeHiddenWrites - Defaults to false, whether or not to layer on writes with visible set to false
74
+ */
75
+ export declare function writeTreeCalcCompleteEventCache(writeTree: WriteTree, treePath: Path, completeServerCache: Node | null, writeIdsToExclude?: number[], includeHiddenWrites?: boolean): Node | null;
76
+ /**
77
+ * With optional, underlying server data, attempt to return a children node of children that we have complete data for.
78
+ * Used when creating new views, to pre-fill their complete event children snapshot.
79
+ */
80
+ export declare function writeTreeCalcCompleteEventChildren(writeTree: WriteTree, treePath: Path, completeServerChildren: ChildrenNode | null): Node;
81
+ /**
82
+ * Given that the underlying server data has updated, determine what, if anything, needs to be
83
+ * applied to the event cache.
84
+ *
85
+ * Possibilities:
86
+ *
87
+ * 1. No writes are shadowing. Events should be raised, the snap to be applied comes from the server data
88
+ *
89
+ * 2. Some write is completely shadowing. No events to be raised
90
+ *
91
+ * 3. Is partially shadowed. Events
92
+ *
93
+ * Either existingEventSnap or existingServerSnap must exist
94
+ */
95
+ export declare function writeTreeCalcEventCacheAfterServerOverwrite(writeTree: WriteTree, treePath: Path, childPath: Path, existingEventSnap: Node | null, existingServerSnap: Node | null): Node | null;
96
+ /**
97
+ * Returns a complete child for a given server snap after applying all user writes or null if there is no
98
+ * complete child for this ChildKey.
99
+ */
100
+ export declare function writeTreeCalcCompleteChild(writeTree: WriteTree, treePath: Path, childKey: string, existingServerSnap: CacheNode): Node | null;
101
+ /**
102
+ * Returns a node if there is a complete overwrite for this path. More specifically, if there is a write at
103
+ * a higher path, this will return the child of that write relative to the write and this path.
104
+ * Returns null if there is no write at this path.
105
+ */
106
+ export declare function writeTreeShadowingWrite(writeTree: WriteTree, path: Path): Node | null;
107
+ /**
108
+ * This method is used when processing child remove events on a query. If we can, we pull in children that were outside
109
+ * the window, but may now be in the window.
110
+ */
111
+ export declare function writeTreeCalcIndexedSlice(writeTree: WriteTree, treePath: Path, completeServerData: Node | null, startPost: NamedNode, count: number, reverse: boolean, index: Index): NamedNode[];
112
+ export declare function newWriteTree(): WriteTree;
113
+ /**
114
+ * WriteTree tracks all pending user-initiated writes and has methods to calculate the result of merging them
115
+ * with underlying server data (to create "event cache" data). Pending writes are added with addOverwrite()
116
+ * and addMerge(), and removed with removeWrite().
117
+ */
118
+ export interface WriteTree {
119
+ /**
120
+ * A tree tracking the result of applying all visible writes. This does not include transactions with
121
+ * applyLocally=false or writes that are completely shadowed by other writes.
122
+ */
123
+ visibleWrites: CompoundWrite;
124
+ /**
125
+ * A list of all pending writes, regardless of visibility and shadowed-ness. Used to calculate arbitrary
126
+ * sets of the changed data, such as hidden writes (from transactions) or changes with certain writes excluded (also
127
+ * used by transactions).
128
+ */
129
+ allWrites: WriteRecord[];
130
+ lastWriteId: number;
131
+ }
132
+ /**
133
+ * If possible, returns a complete event cache, using the underlying server data if possible. In addition, can be used
134
+ * to get a cache that includes hidden writes, and excludes arbitrary writes. Note that customizing the returned node
135
+ * can lead to a more expensive calculation.
136
+ *
137
+ * @param writeIdsToExclude - Optional writes to exclude.
138
+ * @param includeHiddenWrites - Defaults to false, whether or not to layer on writes with visible set to false
139
+ */
140
+ export declare function writeTreeRefCalcCompleteEventCache(writeTreeRef: WriteTreeRef, completeServerCache: Node | null, writeIdsToExclude?: number[], includeHiddenWrites?: boolean): Node | null;
141
+ /**
142
+ * If possible, returns a children node containing all of the complete children we have data for. The returned data is a
143
+ * mix of the given server data and write data.
144
+ *
145
+ */
146
+ export declare function writeTreeRefCalcCompleteEventChildren(writeTreeRef: WriteTreeRef, completeServerChildren: ChildrenNode | null): ChildrenNode;
147
+ /**
148
+ * Given that either the underlying server data has updated or the outstanding writes have updated, determine what,
149
+ * if anything, needs to be applied to the event cache.
150
+ *
151
+ * Possibilities:
152
+ *
153
+ * 1. No writes are shadowing. Events should be raised, the snap to be applied comes from the server data
154
+ *
155
+ * 2. Some write is completely shadowing. No events to be raised
156
+ *
157
+ * 3. Is partially shadowed. Events should be raised
158
+ *
159
+ * Either existingEventSnap or existingServerSnap must exist, this is validated via an assert
160
+ *
161
+ *
162
+ */
163
+ export declare function writeTreeRefCalcEventCacheAfterServerOverwrite(writeTreeRef: WriteTreeRef, path: Path, existingEventSnap: Node | null, existingServerSnap: Node | null): Node | null;
164
+ /**
165
+ * Returns a node if there is a complete overwrite for this path. More specifically, if there is a write at
166
+ * a higher path, this will return the child of that write relative to the write and this path.
167
+ * Returns null if there is no write at this path.
168
+ *
169
+ */
170
+ export declare function writeTreeRefShadowingWrite(writeTreeRef: WriteTreeRef, path: Path): Node | null;
171
+ /**
172
+ * This method is used when processing child remove events on a query. If we can, we pull in children that were outside
173
+ * the window, but may now be in the window
174
+ */
175
+ export declare function writeTreeRefCalcIndexedSlice(writeTreeRef: WriteTreeRef, completeServerData: Node | null, startPost: NamedNode, count: number, reverse: boolean, index: Index): NamedNode[];
176
+ /**
177
+ * Returns a complete child for a given server snap after applying all user writes or null if there is no
178
+ * complete child for this ChildKey.
179
+ */
180
+ export declare function writeTreeRefCalcCompleteChild(writeTreeRef: WriteTreeRef, childKey: string, existingServerCache: CacheNode): Node | null;
181
+ /**
182
+ * Return a WriteTreeRef for a child.
183
+ */
184
+ export declare function writeTreeRefChild(writeTreeRef: WriteTreeRef, childName: string): WriteTreeRef;
185
+ export declare function newWriteTreeRef(path: Path, writeTree: WriteTree): WriteTreeRef;
186
+ /**
187
+ * A WriteTreeRef wraps a WriteTree and a path, for convenient access to a particular subtree. All of the methods
188
+ * just proxy to the underlying WriteTree.
189
+ *
190
+ */
191
+ export interface WriteTreeRef {
192
+ /**
193
+ * The path to this particular write tree ref. Used for calling methods on writeTree_ while exposing a simpler
194
+ * interface to callers.
195
+ */
196
+ readonly treePath: Path;
197
+ /**
198
+ * * A reference to the actual tree of write data. All methods are pass-through to the tree, but with the appropriate
199
+ * path prefixed.
200
+ *
201
+ * This lets us make cheap references to points in the tree for sync points without having to copy and maintain all of
202
+ * the data.
203
+ */
204
+ readonly writeTree: WriteTree;
205
+ }
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { ImmutableTree } from '../util/ImmutableTree';
18
+ import { Path } from '../util/Path';
19
+ import { Operation, OperationType } from './Operation';
20
+ export declare class AckUserWrite implements Operation {
21
+ /** @inheritDoc */ path: Path;
22
+ /** @inheritDoc */ affectedTree: ImmutableTree<boolean>;
23
+ /** @inheritDoc */ revert: boolean;
24
+ /** @inheritDoc */
25
+ type: OperationType;
26
+ /** @inheritDoc */
27
+ source: import("./Operation").OperationSource;
28
+ /**
29
+ * @param affectedTree - A tree containing true for each affected path. Affected paths can't overlap.
30
+ */
31
+ constructor(
32
+ /** @inheritDoc */ path: Path,
33
+ /** @inheritDoc */ affectedTree: ImmutableTree<boolean>,
34
+ /** @inheritDoc */ revert: boolean);
35
+ operationForChild(childName: string): AckUserWrite;
36
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Path } from '../util/Path';
18
+ import { Operation, OperationSource, OperationType } from './Operation';
19
+ export declare class ListenComplete implements Operation {
20
+ source: OperationSource;
21
+ path: Path;
22
+ /** @inheritDoc */
23
+ type: OperationType;
24
+ constructor(source: OperationSource, path: Path);
25
+ operationForChild(childName: string): ListenComplete;
26
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Node } from '../snap/Node';
18
+ import { ImmutableTree } from '../util/ImmutableTree';
19
+ import { Path } from '../util/Path';
20
+ import { Operation, OperationSource, OperationType } from './Operation';
21
+ export declare class Merge implements Operation {
22
+ /** @inheritDoc */ source: OperationSource;
23
+ /** @inheritDoc */ path: Path;
24
+ /** @inheritDoc */ children: ImmutableTree<Node>;
25
+ /** @inheritDoc */
26
+ type: OperationType;
27
+ constructor(
28
+ /** @inheritDoc */ source: OperationSource,
29
+ /** @inheritDoc */ path: Path,
30
+ /** @inheritDoc */ children: ImmutableTree<Node>);
31
+ operationForChild(childName: string): Operation;
32
+ toString(): string;
33
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Path } from '../util/Path';
18
+ /**
19
+ *
20
+ * @enum
21
+ */
22
+ export declare enum OperationType {
23
+ OVERWRITE = 0,
24
+ MERGE = 1,
25
+ ACK_USER_WRITE = 2,
26
+ LISTEN_COMPLETE = 3
27
+ }
28
+ /**
29
+ * @interface
30
+ */
31
+ export interface Operation {
32
+ source: OperationSource;
33
+ type: OperationType;
34
+ path: Path;
35
+ operationForChild(childName: string): Operation | null;
36
+ }
37
+ export interface OperationSource {
38
+ fromUser: boolean;
39
+ fromServer: boolean;
40
+ queryId: string | null;
41
+ tagged: boolean;
42
+ }
43
+ export declare function newOperationSourceUser(): OperationSource;
44
+ export declare function newOperationSourceServer(): OperationSource;
45
+ export declare function newOperationSourceServerTaggedQuery(queryId: string): OperationSource;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Node } from '../snap/Node';
18
+ import { Path } from '../util/Path';
19
+ import { Operation, OperationSource, OperationType } from './Operation';
20
+ export declare class Overwrite implements Operation {
21
+ source: OperationSource;
22
+ path: Path;
23
+ snap: Node;
24
+ /** @inheritDoc */
25
+ type: OperationType;
26
+ constructor(source: OperationSource, path: Path, snap: Node);
27
+ operationForChild(childName: string): Overwrite;
28
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Path } from '../util/Path';
18
+ import { SortedMap, SortedMapIterator } from '../util/SortedMap';
19
+ import { Index } from './indexes/Index';
20
+ import { IndexMap } from './IndexMap';
21
+ import { NamedNode, Node } from './Node';
22
+ export interface ChildrenNodeConstructor {
23
+ new (children_: SortedMap<string, Node>, priorityNode_: Node | null, indexMap_: IndexMap): ChildrenNode;
24
+ EMPTY_NODE: ChildrenNode;
25
+ }
26
+ /**
27
+ * ChildrenNode is a class for storing internal nodes in a DataSnapshot
28
+ * (i.e. nodes with children). It implements Node and stores the
29
+ * list of children in the children property, sorted by child name.
30
+ */
31
+ export declare class ChildrenNode implements Node {
32
+ private readonly children_;
33
+ private readonly priorityNode_;
34
+ private indexMap_;
35
+ private lazyHash_;
36
+ static get EMPTY_NODE(): ChildrenNode;
37
+ /**
38
+ * @param children_ - List of children of this node..
39
+ * @param priorityNode_ - The priority of this node (as a snapshot node).
40
+ */
41
+ constructor(children_: SortedMap<string, Node>, priorityNode_: Node | null, indexMap_: IndexMap);
42
+ /** @inheritDoc */
43
+ isLeafNode(): boolean;
44
+ /** @inheritDoc */
45
+ getPriority(): Node;
46
+ /** @inheritDoc */
47
+ updatePriority(newPriorityNode: Node): Node;
48
+ /** @inheritDoc */
49
+ getImmediateChild(childName: string): Node;
50
+ /** @inheritDoc */
51
+ getChild(path: Path): Node;
52
+ /** @inheritDoc */
53
+ hasChild(childName: string): boolean;
54
+ /** @inheritDoc */
55
+ updateImmediateChild(childName: string, newChildNode: Node): Node;
56
+ /** @inheritDoc */
57
+ updateChild(path: Path, newChildNode: Node): Node;
58
+ /** @inheritDoc */
59
+ isEmpty(): boolean;
60
+ /** @inheritDoc */
61
+ numChildren(): number;
62
+ private static INTEGER_REGEXP_;
63
+ /** @inheritDoc */
64
+ val(exportFormat?: boolean): object;
65
+ /** @inheritDoc */
66
+ hash(): string;
67
+ /** @inheritDoc */
68
+ getPredecessorChildName(childName: string, childNode: Node, index: Index): string;
69
+ getFirstChildName(indexDefinition: Index): string | null;
70
+ getFirstChild(indexDefinition: Index): NamedNode | null;
71
+ /**
72
+ * Given an index, return the key name of the largest value we have, according to that index
73
+ */
74
+ getLastChildName(indexDefinition: Index): string | null;
75
+ getLastChild(indexDefinition: Index): NamedNode | null;
76
+ forEachChild(index: Index, action: (key: string, node: Node) => boolean | void): boolean;
77
+ getIterator(indexDefinition: Index): SortedMapIterator<string | NamedNode, Node, NamedNode>;
78
+ getIteratorFrom(startPost: NamedNode, indexDefinition: Index): SortedMapIterator<string | NamedNode, Node, NamedNode>;
79
+ getReverseIterator(indexDefinition: Index): SortedMapIterator<string | NamedNode, Node, NamedNode>;
80
+ getReverseIteratorFrom(endPost: NamedNode, indexDefinition: Index): SortedMapIterator<string | NamedNode, Node, NamedNode>;
81
+ compareTo(other: ChildrenNode): number;
82
+ withIndex(indexDefinition: Index): Node;
83
+ isIndexed(index: Index): boolean;
84
+ equals(other: Node): boolean;
85
+ /**
86
+ * Returns a SortedMap ordered by index, or null if the default (by-key) ordering can be used
87
+ * instead.
88
+ *
89
+ */
90
+ private resolveIndex_;
91
+ }
92
+ export declare class MaxNode extends ChildrenNode {
93
+ constructor();
94
+ compareTo(other: Node): number;
95
+ equals(other: Node): boolean;
96
+ getPriority(): MaxNode;
97
+ getImmediateChild(childName: string): ChildrenNode;
98
+ isEmpty(): boolean;
99
+ }
100
+ /**
101
+ * Marker that will sort higher than any other snapshot.
102
+ */
103
+ export declare const MAX_NODE: MaxNode;
104
+ /**
105
+ * Document NamedNode extensions
106
+ */
107
+ declare module './Node' {
108
+ interface NamedNode {
109
+ MIN: NamedNode;
110
+ MAX: NamedNode;
111
+ }
112
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { SortedMap } from '../util/SortedMap';
18
+ import { Index } from './indexes/Index';
19
+ import { NamedNode, Node } from './Node';
20
+ export declare class IndexMap {
21
+ private indexes_;
22
+ private indexSet_;
23
+ /**
24
+ * The default IndexMap for nodes without a priority
25
+ */
26
+ static get Default(): IndexMap;
27
+ constructor(indexes_: {
28
+ [k: string]: SortedMap<NamedNode, Node> | /*FallbackType*/ object;
29
+ }, indexSet_: {
30
+ [k: string]: Index;
31
+ });
32
+ get(indexKey: string): SortedMap<NamedNode, Node> | null;
33
+ hasIndex(indexDefinition: Index): boolean;
34
+ addIndex(indexDefinition: Index, existingChildren: SortedMap<string, Node>): IndexMap;
35
+ /**
36
+ * Ensure that this node is properly tracked in any indexes that we're maintaining
37
+ */
38
+ addToIndexes(namedNode: NamedNode, existingChildren: SortedMap<string, Node>): IndexMap;
39
+ /**
40
+ * Create a new IndexMap instance with the given value removed
41
+ */
42
+ removeFromIndexes(namedNode: NamedNode, existingChildren: SortedMap<string, Node>): IndexMap;
43
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2017 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Indexable } from '../util/misc';
18
+ import { Path } from '../util/Path';
19
+ import { ChildrenNodeConstructor } from './ChildrenNode';
20
+ import { Index } from './indexes/Index';
21
+ import { Node } from './Node';
22
+ /**
23
+ * LeafNode is a class for storing leaf nodes in a DataSnapshot. It
24
+ * implements Node and stores the value of the node (a string,
25
+ * number, or boolean) accessible via getValue().
26
+ */
27
+ export declare class LeafNode implements Node {
28
+ private readonly value_;
29
+ private priorityNode_;
30
+ static set __childrenNodeConstructor(val: ChildrenNodeConstructor);
31
+ static get __childrenNodeConstructor(): ChildrenNodeConstructor;
32
+ /**
33
+ * The sort order for comparing leaf nodes of different types. If two leaf nodes have
34
+ * the same type, the comparison falls back to their value
35
+ */
36
+ static VALUE_TYPE_ORDER: string[];
37
+ private lazyHash_;
38
+ /**
39
+ * @param value_ - The value to store in this leaf node. The object type is
40
+ * possible in the event of a deferred value
41
+ * @param priorityNode_ - The priority of this node.
42
+ */
43
+ constructor(value_: string | number | boolean | Indexable, priorityNode_?: Node);
44
+ /** @inheritDoc */
45
+ isLeafNode(): boolean;
46
+ /** @inheritDoc */
47
+ getPriority(): Node;
48
+ /** @inheritDoc */
49
+ updatePriority(newPriorityNode: Node): Node;
50
+ /** @inheritDoc */
51
+ getImmediateChild(childName: string): Node;
52
+ /** @inheritDoc */
53
+ getChild(path: Path): Node;
54
+ hasChild(): boolean;
55
+ /** @inheritDoc */
56
+ getPredecessorChildName(childName: string, childNode: Node): null;
57
+ /** @inheritDoc */
58
+ updateImmediateChild(childName: string, newChildNode: Node): Node;
59
+ /** @inheritDoc */
60
+ updateChild(path: Path, newChildNode: Node): Node;
61
+ /** @inheritDoc */
62
+ isEmpty(): boolean;
63
+ /** @inheritDoc */
64
+ numChildren(): number;
65
+ /** @inheritDoc */
66
+ forEachChild(index: Index, action: (s: string, n: Node) => void): boolean;
67
+ val(exportFormat?: boolean): {};
68
+ /** @inheritDoc */
69
+ hash(): string;
70
+ /**
71
+ * Returns the value of the leaf node.
72
+ * @returns The value of the node.
73
+ */
74
+ getValue(): Indexable | string | number | boolean;
75
+ compareTo(other: Node): number;
76
+ /**
77
+ * Comparison specifically for two leaf nodes
78
+ */
79
+ private compareToLeafNode_;
80
+ withIndex(): Node;
81
+ isIndexed(): boolean;
82
+ equals(other: Node): boolean;
83
+ }