@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,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Returns a placeholder value for auto-populating the current timestamp (time
19
+ * since the Unix epoch, in milliseconds) as determined by the Firebase
20
+ * servers.
21
+ */
22
+ export declare function serverTimestamp(): object;
23
+ /**
24
+ * Returns a placeholder value that can be used to atomically increment the
25
+ * current database value by the provided delta.
26
+ *
27
+ * @param delta - the amount to modify the current value atomically.
28
+ * @returns A placeholder value for modifying data atomically server-side.
29
+ */
30
+ export declare function increment(delta: number): object;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { DatabaseReference } from './Reference';
18
+ import { DataSnapshot } from './Reference_impl';
19
+ /** An options object to configure transactions. */
20
+ export interface TransactionOptions {
21
+ /**
22
+ * By default, events are raised each time the transaction update function
23
+ * runs. So if it is run multiple times, you may see intermediate states. You
24
+ * can set this to false to suppress these intermediate states and instead
25
+ * wait until the transaction has completed before events are raised.
26
+ */
27
+ readonly applyLocally?: boolean;
28
+ }
29
+ /**
30
+ * A type for the resolve value of {@link runTransaction}.
31
+ */
32
+ export declare class TransactionResult {
33
+ /** Whether the transaction was successfully committed. */
34
+ readonly committed: boolean;
35
+ /** The resulting data snapshot. */
36
+ readonly snapshot: DataSnapshot;
37
+ /** @hideconstructor */
38
+ constructor(
39
+ /** Whether the transaction was successfully committed. */
40
+ committed: boolean,
41
+ /** The resulting data snapshot. */
42
+ snapshot: DataSnapshot);
43
+ /** Returns a JSON-serializable representation of this object. */
44
+ toJSON(): object;
45
+ }
46
+ /**
47
+ * Atomically modifies the data at this location.
48
+ *
49
+ * Atomically modify the data at this location. Unlike a normal `set()`, which
50
+ * just overwrites the data regardless of its previous value, `runTransaction()` is
51
+ * used to modify the existing value to a new value, ensuring there are no
52
+ * conflicts with other clients writing to the same location at the same time.
53
+ *
54
+ * To accomplish this, you pass `runTransaction()` an update function which is
55
+ * used to transform the current value into a new value. If another client
56
+ * writes to the location before your new value is successfully written, your
57
+ * update function will be called again with the new current value, and the
58
+ * write will be retried. This will happen repeatedly until your write succeeds
59
+ * without conflict or you abort the transaction by not returning a value from
60
+ * your update function.
61
+ *
62
+ * Note: Modifying data with `set()` will cancel any pending transactions at
63
+ * that location, so extreme care should be taken if mixing `set()` and
64
+ * `runTransaction()` to update the same data.
65
+ *
66
+ * Note: When using transactions with Security and Firebase Rules in place, be
67
+ * aware that a client needs `.read` access in addition to `.write` access in
68
+ * order to perform a transaction. This is because the client-side nature of
69
+ * transactions requires the client to read the data in order to transactionally
70
+ * update it.
71
+ *
72
+ * @param ref - The location to atomically modify.
73
+ * @param transactionUpdate - A developer-supplied function which will be passed
74
+ * the current data stored at this location (as a JavaScript object). The
75
+ * function should return the new value it would like written (as a JavaScript
76
+ * object). If `undefined` is returned (i.e. you return with no arguments) the
77
+ * transaction will be aborted and the data at this location will not be
78
+ * modified.
79
+ * @param options - An options object to configure transactions.
80
+ * @returns A `Promise` that can optionally be used instead of the `onComplete`
81
+ * callback to handle success and failure.
82
+ */
83
+ export declare function runTransaction(ref: DatabaseReference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
@@ -0,0 +1,31 @@
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 { PersistentConnection } from '../core/PersistentConnection';
18
+ import { RepoInfo } from '../core/RepoInfo';
19
+ import { Connection } from '../realtime/Connection';
20
+ export declare const DataConnection: typeof PersistentConnection;
21
+ export declare const RealTimeConnection: typeof Connection;
22
+ /**
23
+ * @internal
24
+ */
25
+ export declare const hijackHash: (newHash: () => string) => () => void;
26
+ export declare const ConnectionTarget: typeof RepoInfo;
27
+ /**
28
+ * Forces the RepoManager to create Repos that use ReadonlyRestClient instead of PersistentConnection.
29
+ * @internal
30
+ */
31
+ export declare const forceRestClient: (forceRestClient: boolean) => void;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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
+ export * from './api.standalone';
18
+ export { getDatabase } from './api/Database';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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
+ export { Database, EmulatorMockTokenOptions, enableLogging, goOffline, goOnline, forceWebSockets, forceLongPolling, connectDatabaseEmulator } from './api/Database';
18
+ export { Query, DatabaseReference, ListenOptions, Unsubscribe, ThenableReference } from './api/Reference';
19
+ export { OnDisconnect } from './api/OnDisconnect';
20
+ export { DataSnapshot, EventType, IteratedDataSnapshot, QueryConstraint, QueryConstraintType, endAt, endBefore, equalTo, get, limitToFirst, limitToLast, off, onChildAdded, onChildChanged, onChildMoved, onChildRemoved, onDisconnect, onValue, orderByChild, orderByKey, orderByPriority, orderByValue, push, query, ref, refFromURL, remove, set, setPriority, setWithPriority, startAfter, startAt, update, child } from './api/Reference_impl';
21
+ export { increment, serverTimestamp } from './api/ServerValue';
22
+ export { runTransaction, TransactionOptions, TransactionResult } from './api/Transaction';
23
+ export { setSDKVersion as _setSDKVersion } from './core/version';
24
+ export { ReferenceImpl as _ReferenceImpl, QueryImpl as _QueryImpl } from './api/Reference_impl';
25
+ export { repoManagerDatabaseFromApp as _repoManagerDatabaseFromApp } from './api/Database';
26
+ export { validatePathString as _validatePathString, validateWritablePath as _validateWritablePath } from './core/util/validation';
27
+ export { UserCallback as _UserCallback } from './core/view/EventRegistration';
28
+ export { QueryParams as _QueryParams } from './core/view/QueryParams';
29
+ export { hijackHash as _TEST_ACCESS_hijackHash, forceRestClient as _TEST_ACCESS_forceRestClient } from './api/test_access';
30
+ export * from './internal/index';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2021 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 { FirebaseApp } from '@firebase/app';
18
+ import { AppCheckInternalComponentName, AppCheckTokenListener, AppCheckTokenResult } from '@firebase/app-check-interop-types';
19
+ import { Provider } from '@firebase/component';
20
+ /**
21
+ * Abstraction around AppCheck's token fetching capabilities.
22
+ */
23
+ export 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
+ }
@@ -0,0 +1,49 @@
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 { FirebaseAuthTokenData } from '@firebase/app-types/private';
18
+ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
19
+ import { Provider } from '@firebase/component';
20
+ export interface AuthTokenProvider {
21
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
22
+ addTokenChangeListener(listener: (token: string | null) => void): void;
23
+ removeTokenChangeListener(listener: (token: string | null) => void): void;
24
+ notifyForInvalidToken(): void;
25
+ }
26
+ /**
27
+ * Abstraction around FirebaseApp's token fetching capabilities.
28
+ */
29
+ export declare class FirebaseAuthTokenProvider implements AuthTokenProvider {
30
+ private appName_;
31
+ private firebaseOptions_;
32
+ private authProvider_;
33
+ private auth_;
34
+ constructor(appName_: string, firebaseOptions_: object, authProvider_: Provider<FirebaseAuthInternalName>);
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
+ export declare class EmulatorTokenProvider implements AuthTokenProvider {
41
+ private accessToken;
42
+ /** A string that is treated as an admin access token by the RTDB emulator. Used by Admin SDK. */
43
+ static OWNER: string;
44
+ constructor(accessToken: string);
45
+ getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData>;
46
+ addTokenChangeListener(listener: (token: string | null) => void): void;
47
+ removeTokenChangeListener(listener: (token: string | null) => void): void;
48
+ notifyForInvalidToken(): void;
49
+ }
@@ -0,0 +1,81 @@
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 { NamedNode, Node } from './snap/Node';
18
+ import { ImmutableTree } from './util/ImmutableTree';
19
+ import { Path } from './util/Path';
20
+ /**
21
+ * This class holds a collection of writes that can be applied to nodes in unison. It abstracts away the logic with
22
+ * dealing with priority writes and multiple nested writes. At any given path there is only allowed to be one write
23
+ * modifying that path. Any write to an existing path or shadowing an existing path will modify that existing write
24
+ * to reflect the write added.
25
+ */
26
+ export declare class CompoundWrite {
27
+ writeTree_: ImmutableTree<Node>;
28
+ constructor(writeTree_: ImmutableTree<Node>);
29
+ static empty(): CompoundWrite;
30
+ }
31
+ export declare function compoundWriteAddWrite(compoundWrite: CompoundWrite, path: Path, node: Node): CompoundWrite;
32
+ export declare function compoundWriteAddWrites(compoundWrite: CompoundWrite, path: Path, updates: {
33
+ [name: string]: Node;
34
+ }): CompoundWrite;
35
+ /**
36
+ * Will remove a write at the given path and deeper paths. This will <em>not</em> modify a write at a higher
37
+ * location, which must be removed by calling this method with that path.
38
+ *
39
+ * @param compoundWrite - The CompoundWrite to remove.
40
+ * @param path - The path at which a write and all deeper writes should be removed
41
+ * @returns The new CompoundWrite with the removed path
42
+ */
43
+ export declare function compoundWriteRemoveWrite(compoundWrite: CompoundWrite, path: Path): CompoundWrite;
44
+ /**
45
+ * Returns whether this CompoundWrite will fully overwrite a node at a given location and can therefore be
46
+ * considered "complete".
47
+ *
48
+ * @param compoundWrite - The CompoundWrite to check.
49
+ * @param path - The path to check for
50
+ * @returns Whether there is a complete write at that path
51
+ */
52
+ export declare function compoundWriteHasCompleteWrite(compoundWrite: CompoundWrite, path: Path): boolean;
53
+ /**
54
+ * Returns a node for a path if and only if the node is a "complete" overwrite at that path. This will not aggregate
55
+ * writes from deeper paths, but will return child nodes from a more shallow path.
56
+ *
57
+ * @param compoundWrite - The CompoundWrite to get the node from.
58
+ * @param path - The path to get a complete write
59
+ * @returns The node if complete at that path, or null otherwise.
60
+ */
61
+ export declare function compoundWriteGetCompleteNode(compoundWrite: CompoundWrite, path: Path): Node | null;
62
+ /**
63
+ * Returns all children that are guaranteed to be a complete overwrite.
64
+ *
65
+ * @param compoundWrite - The CompoundWrite to get children from.
66
+ * @returns A list of all complete children.
67
+ */
68
+ export declare function compoundWriteGetCompleteChildren(compoundWrite: CompoundWrite): NamedNode[];
69
+ export declare function compoundWriteChildCompoundWrite(compoundWrite: CompoundWrite, path: Path): CompoundWrite;
70
+ /**
71
+ * Returns true if this CompoundWrite is empty and therefore does not modify any nodes.
72
+ * @returns Whether this CompoundWrite is empty
73
+ */
74
+ export declare function compoundWriteIsEmpty(compoundWrite: CompoundWrite): boolean;
75
+ /**
76
+ * Applies this CompoundWrite to a node. The node is returned with all writes from this CompoundWrite applied to the
77
+ * node
78
+ * @param node - The node to apply this CompoundWrite to
79
+ * @returns The node with all writes applied
80
+ */
81
+ export declare function compoundWriteApply(compoundWrite: CompoundWrite, node: Node): Node;
@@ -0,0 +1,135 @@
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 { AppCheckTokenProvider } from './AppCheckTokenProvider';
18
+ import { AuthTokenProvider } from './AuthTokenProvider';
19
+ import { RepoInfo } from './RepoInfo';
20
+ import { ServerActions } from './ServerActions';
21
+ import { QueryContext } from './view/EventRegistration';
22
+ /**
23
+ * Firebase connection. Abstracts wire protocol and handles reconnecting.
24
+ *
25
+ * NOTE: All JSON objects sent to the realtime connection must have property names enclosed
26
+ * in quotes to make sure the closure compiler does not minify them.
27
+ */
28
+ export declare class PersistentConnection extends ServerActions {
29
+ private repoInfo_;
30
+ private applicationId_;
31
+ private onDataUpdate_;
32
+ private onConnectStatus_;
33
+ private onServerInfoUpdate_;
34
+ private authTokenProvider_;
35
+ private appCheckTokenProvider_;
36
+ private authOverride_?;
37
+ id: number;
38
+ private log_;
39
+ private interruptReasons_;
40
+ private readonly listens;
41
+ private outstandingPuts_;
42
+ private outstandingGets_;
43
+ private outstandingPutCount_;
44
+ private outstandingGetCount_;
45
+ private onDisconnectRequestQueue_;
46
+ private connected_;
47
+ private reconnectDelay_;
48
+ private maxReconnectDelay_;
49
+ private securityDebugCallback_;
50
+ lastSessionId: string | null;
51
+ private establishConnectionTimer_;
52
+ private visible_;
53
+ private requestCBHash_;
54
+ private requestNumber_;
55
+ private realtime_;
56
+ private authToken_;
57
+ private appCheckToken_;
58
+ private forceTokenRefresh_;
59
+ private invalidAuthTokenCount_;
60
+ private invalidAppCheckTokenCount_;
61
+ private firstConnection_;
62
+ private lastConnectionAttemptTime_;
63
+ private lastConnectionEstablishedTime_;
64
+ private static nextPersistentConnectionId_;
65
+ /**
66
+ * Counter for number of connections created. Mainly used for tagging in the logs
67
+ */
68
+ private static nextConnectionId_;
69
+ /**
70
+ * @param repoInfo_ - Data about the namespace we are connecting to
71
+ * @param applicationId_ - The Firebase App ID for this project
72
+ * @param onDataUpdate_ - A callback for new data from the server
73
+ */
74
+ 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);
75
+ protected sendRequest(action: string, body: unknown, onResponse?: (a: unknown) => void): void;
76
+ get(query: QueryContext): Promise<string>;
77
+ listen(query: QueryContext, currentHashFn: () => string, tag: number | null, onComplete: (a: string, b: unknown) => void): void;
78
+ private sendGet_;
79
+ private sendListen_;
80
+ private static warnOnListenWarnings_;
81
+ refreshAuthToken(token: string): void;
82
+ private reduceReconnectDelayIfAdminCredential_;
83
+ refreshAppCheckToken(token: string | null): void;
84
+ /**
85
+ * Attempts to authenticate with the given credentials. If the authentication attempt fails, it's triggered like
86
+ * a auth revoked (the connection is closed).
87
+ */
88
+ tryAuth(): void;
89
+ /**
90
+ * Attempts to authenticate with the given token. If the authentication
91
+ * attempt fails, it's triggered like the token was revoked (the connection is
92
+ * closed).
93
+ */
94
+ tryAppCheck(): void;
95
+ /**
96
+ * @inheritDoc
97
+ */
98
+ unlisten(query: QueryContext, tag: number | null): void;
99
+ private sendUnlisten_;
100
+ onDisconnectPut(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
101
+ onDisconnectMerge(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
102
+ onDisconnectCancel(pathString: string, onComplete?: (a: string, b: string) => void): void;
103
+ private sendOnDisconnect_;
104
+ put(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void, hash?: string): void;
105
+ merge(pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
106
+ putInternal(action: string, pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
107
+ private sendPut_;
108
+ reportStats(stats: {
109
+ [k: string]: unknown;
110
+ }): void;
111
+ private onDataMessage_;
112
+ private onDataPush_;
113
+ private onReady_;
114
+ private scheduleConnect_;
115
+ private initConnection_;
116
+ private onVisible_;
117
+ private onOnline_;
118
+ private onRealtimeDisconnect_;
119
+ private establishConnection_;
120
+ interrupt(reason: string): void;
121
+ resume(reason: string): void;
122
+ private handleTimestamp_;
123
+ private cancelSentTransactions_;
124
+ private onListenRevoked_;
125
+ private removeListen_;
126
+ private onAuthRevoked_;
127
+ private onAppCheckRevoked_;
128
+ private onSecurityDebugPacket_;
129
+ private restoreState_;
130
+ /**
131
+ * Sends client stats for first connection
132
+ */
133
+ private sendConnectStats_;
134
+ private shouldReconnect_;
135
+ }
@@ -0,0 +1,60 @@
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 { AppCheckTokenProvider } from './AppCheckTokenProvider';
18
+ import { AuthTokenProvider } from './AuthTokenProvider';
19
+ import { RepoInfo } from './RepoInfo';
20
+ import { ServerActions } from './ServerActions';
21
+ import { QueryContext } from './view/EventRegistration';
22
+ /**
23
+ * An implementation of ServerActions that communicates with the server via REST requests.
24
+ * This is mostly useful for compatibility with crawlers, where we don't want to spin up a full
25
+ * persistent connection (using WebSockets or long-polling)
26
+ */
27
+ export declare class ReadonlyRestClient extends ServerActions {
28
+ private repoInfo_;
29
+ private onDataUpdate_;
30
+ private authTokenProvider_;
31
+ private appCheckTokenProvider_;
32
+ reportStats(stats: {
33
+ [k: string]: unknown;
34
+ }): void;
35
+ /** @private {function(...[*])} */
36
+ private log_;
37
+ /**
38
+ * We don't actually need to track listens, except to prevent us calling an onComplete for a listen
39
+ * that's been removed. :-/
40
+ */
41
+ private listens_;
42
+ static getListenId_(query: QueryContext, tag?: number | null): string;
43
+ /**
44
+ * @param repoInfo_ - Data about the namespace we are connecting to
45
+ * @param onDataUpdate_ - A callback for new data from the server
46
+ */
47
+ constructor(repoInfo_: RepoInfo, onDataUpdate_: (a: string, b: unknown, c: boolean, d: number | null) => void, authTokenProvider_: AuthTokenProvider, appCheckTokenProvider_: AppCheckTokenProvider);
48
+ /** @inheritDoc */
49
+ listen(query: QueryContext, currentHashFn: () => string, tag: number | null, onComplete: (a: string, b: unknown) => void): void;
50
+ /** @inheritDoc */
51
+ unlisten(query: QueryContext, tag: number | null): void;
52
+ get(query: QueryContext): Promise<string>;
53
+ /** @inheritDoc */
54
+ refreshAuthToken(token: string): void;
55
+ /**
56
+ * Performs a REST request to the given path, with the provided query string parameters,
57
+ * and any auth credentials we have.
58
+ */
59
+ private restRequest_;
60
+ }