@firebase/database 0.8.3-canary.fb90580e5 → 0.8.3

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 (134) hide show
  1. package/dist/index.d.ts +0 -16
  2. package/dist/index.esm.js +34 -163
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm2017.js +34 -161
  5. package/dist/index.esm2017.js.map +1 -1
  6. package/dist/index.node.cjs.js +34 -163
  7. package/dist/index.node.cjs.js.map +1 -1
  8. package/dist/src/api/Query.d.ts +0 -2
  9. package/dist/src/core/AuthTokenProvider.d.ts +2 -2
  10. package/dist/src/core/Repo.d.ts +21 -10
  11. package/dist/src/core/RepoManager.d.ts +2 -8
  12. package/dist/src/core/util/NextPushId.d.ts +0 -2
  13. package/dist/src/core/util/util.d.ts +0 -8
  14. package/dist/src/core/view/QueryParams.d.ts +0 -6
  15. package/package.json +13 -16
  16. package/dist/exp/exp/index.d.ts +0 -29
  17. package/dist/exp/index.d.ts +0 -49
  18. package/dist/exp/index.esm.js +0 -15735
  19. package/dist/exp/index.esm.js.map +0 -1
  20. package/dist/exp/index.esm2017.js +0 -15139
  21. package/dist/exp/index.esm2017.js.map +0 -1
  22. package/dist/exp/index.node.cjs.js +0 -15746
  23. package/dist/exp/index.node.cjs.js.map +0 -1
  24. package/dist/exp/index.node.d.ts +0 -83
  25. package/dist/exp/src/api/DataSnapshot.d.ts +0 -99
  26. package/dist/exp/src/api/Database.d.ts +0 -87
  27. package/dist/exp/src/api/Query.d.ts +0 -193
  28. package/dist/exp/src/api/Reference.d.ts +0 -106
  29. package/dist/exp/src/api/TransactionResult.d.ts +0 -30
  30. package/dist/exp/src/api/internal.d.ts +0 -55
  31. package/dist/exp/src/api/onDisconnect.d.ts +0 -60
  32. package/dist/exp/src/api/test_access.d.ts +0 -42
  33. package/dist/exp/src/core/AuthTokenProvider.d.ts +0 -50
  34. package/dist/exp/src/core/CompoundWrite.d.ts +0 -77
  35. package/dist/exp/src/core/PersistentConnection.d.ts +0 -148
  36. package/dist/exp/src/core/ReadonlyRestClient.d.ts +0 -73
  37. package/dist/exp/src/core/Repo.d.ts +0 -121
  38. package/dist/exp/src/core/RepoInfo.d.ts +0 -59
  39. package/dist/exp/src/core/RepoManager.d.ts +0 -78
  40. package/dist/exp/src/core/Repo_transaction.d.ts +0 -33
  41. package/dist/exp/src/core/ServerActions.d.ts +0 -85
  42. package/dist/exp/src/core/SnapshotHolder.d.ts +0 -28
  43. package/dist/exp/src/core/SparseSnapshotTree.d.ts +0 -61
  44. package/dist/exp/src/core/SyncPoint.d.ts +0 -84
  45. package/dist/exp/src/core/SyncTree.d.ts +0 -236
  46. package/dist/exp/src/core/WriteTree.d.ts +0 -295
  47. package/dist/exp/src/core/operation/AckUserWrite.d.ts +0 -42
  48. package/dist/exp/src/core/operation/ListenComplete.d.ts +0 -32
  49. package/dist/exp/src/core/operation/Merge.d.ts +0 -46
  50. package/dist/exp/src/core/operation/Operation.d.ts +0 -78
  51. package/dist/exp/src/core/operation/Overwrite.d.ts +0 -35
  52. package/dist/exp/src/core/snap/ChildrenNode.d.ts +0 -180
  53. package/dist/exp/src/core/snap/IndexMap.d.ts +0 -43
  54. package/dist/exp/src/core/snap/LeafNode.d.ts +0 -107
  55. package/dist/exp/src/core/snap/Node.d.ts +0 -148
  56. package/dist/exp/src/core/snap/childSet.d.ts +0 -34
  57. package/dist/exp/src/core/snap/comparators.d.ts +0 -19
  58. package/dist/exp/src/core/snap/indexes/Index.d.ts +0 -69
  59. package/dist/exp/src/core/snap/indexes/KeyIndex.d.ts +0 -54
  60. package/dist/exp/src/core/snap/indexes/PathIndex.d.ts +0 -54
  61. package/dist/exp/src/core/snap/indexes/PriorityIndex.d.ts +0 -58
  62. package/dist/exp/src/core/snap/indexes/ValueIndex.d.ts +0 -56
  63. package/dist/exp/src/core/snap/nodeFromJSON.d.ts +0 -25
  64. package/dist/exp/src/core/snap/snap.d.ts +0 -29
  65. package/dist/exp/src/core/stats/StatsCollection.d.ts +0 -28
  66. package/dist/exp/src/core/stats/StatsListener.d.ts +0 -31
  67. package/dist/exp/src/core/stats/StatsManager.d.ts +0 -24
  68. package/dist/exp/src/core/stats/StatsReporter.d.ts +0 -33
  69. package/dist/exp/src/core/storage/DOMStorageWrapper.d.ts +0 -55
  70. package/dist/exp/src/core/storage/MemoryStorage.d.ts +0 -29
  71. package/dist/exp/src/core/storage/storage.d.ts +0 -22
  72. package/dist/exp/src/core/util/EventEmitter.d.ts +0 -45
  73. package/dist/exp/src/core/util/ImmutableTree.d.ts +0 -157
  74. package/dist/exp/src/core/util/NextPushId.d.ts +0 -33
  75. package/dist/exp/src/core/util/OnlineMonitor.d.ts +0 -40
  76. package/dist/exp/src/core/util/Path.d.ts +0 -132
  77. package/dist/exp/src/core/util/ServerValues.d.ts +0 -66
  78. package/dist/exp/src/core/util/SortedMap.d.ts +0 -362
  79. package/dist/exp/src/core/util/Tree.d.ts +0 -134
  80. package/dist/exp/src/core/util/VisibilityMonitor.d.ts +0 -30
  81. package/dist/exp/src/core/util/libs/parser.d.ts +0 -37
  82. package/dist/exp/src/core/util/misc.d.ts +0 -19
  83. package/dist/exp/src/core/util/util.d.ts +0 -232
  84. package/dist/exp/src/core/util/validation.d.ts +0 -108
  85. package/dist/exp/src/core/version.d.ts +0 -19
  86. package/dist/exp/src/core/view/CacheNode.d.ts +0 -59
  87. package/dist/exp/src/core/view/Change.d.ts +0 -74
  88. package/dist/exp/src/core/view/ChildChangeAccumulator.d.ts +0 -22
  89. package/dist/exp/src/core/view/CompleteChildSource.d.ts +0 -91
  90. package/dist/exp/src/core/view/Event.d.ts +0 -102
  91. package/dist/exp/src/core/view/EventGenerator.d.ts +0 -77
  92. package/dist/exp/src/core/view/EventQueue.d.ts +0 -99
  93. package/dist/exp/src/core/view/EventRegistration.d.ts +0 -154
  94. package/dist/exp/src/core/view/QueryParams.d.ts +0 -176
  95. package/dist/exp/src/core/view/View.d.ts +0 -97
  96. package/dist/exp/src/core/view/ViewCache.d.ts +0 -70
  97. package/dist/exp/src/core/view/ViewProcessor.d.ts +0 -166
  98. package/dist/exp/src/core/view/filter/IndexedFilter.d.ts +0 -54
  99. package/dist/exp/src/core/view/filter/LimitedFilter.d.ts +0 -94
  100. package/dist/exp/src/core/view/filter/NodeFilter.d.ts +0 -75
  101. package/dist/exp/src/core/view/filter/RangedFilter.d.ts +0 -109
  102. package/dist/exp/src/exp/Database.d.ts +0 -95
  103. package/dist/exp/src/realtime/BrowserPollConnection.d.ts +0 -208
  104. package/dist/exp/src/realtime/Connection.d.ts +0 -119
  105. package/dist/exp/src/realtime/Constants.d.ts +0 -26
  106. package/dist/exp/src/realtime/Transport.d.ts +0 -62
  107. package/dist/exp/src/realtime/TransportManager.d.ts +0 -55
  108. package/dist/exp/src/realtime/WebSocketConnection.d.ts +0 -133
  109. package/dist/exp/src/realtime/polling/PacketReceiver.d.ts +0 -41
  110. package/dist/exp/test/browser/crawler_support.test.d.ts +0 -17
  111. package/dist/exp/test/compound_write.test.d.ts +0 -17
  112. package/dist/exp/test/connection.test.d.ts +0 -17
  113. package/dist/exp/test/database.test.d.ts +0 -17
  114. package/dist/exp/test/datasnapshot.test.d.ts +0 -17
  115. package/dist/exp/test/exp/integration.test.d.ts +0 -17
  116. package/dist/exp/test/helpers/EventAccumulator.d.ts +0 -34
  117. package/dist/exp/test/helpers/events.d.ts +0 -37
  118. package/dist/exp/test/helpers/util.d.ts +0 -50
  119. package/dist/exp/test/info.test.d.ts +0 -17
  120. package/dist/exp/test/node.test.d.ts +0 -17
  121. package/dist/exp/test/order.test.d.ts +0 -17
  122. package/dist/exp/test/order_by.test.d.ts +0 -17
  123. package/dist/exp/test/path.test.d.ts +0 -17
  124. package/dist/exp/test/promise.test.d.ts +0 -17
  125. package/dist/exp/test/pushid.test.d.ts +0 -17
  126. package/dist/exp/test/query.test.d.ts +0 -17
  127. package/dist/exp/test/repoinfo.test.d.ts +0 -17
  128. package/dist/exp/test/servervalues.test.d.ts +0 -17
  129. package/dist/exp/test/sortedmap.test.d.ts +0 -17
  130. package/dist/exp/test/sparsesnapshottree.test.d.ts +0 -17
  131. package/dist/exp/test/transaction.test.d.ts +0 -17
  132. package/dist/src/exp/Database.d.ts +0 -95
  133. package/dist/test/exp/integration.test.d.ts +0 -17
  134. package/dist/test/pushid.test.d.ts +0 -17
@@ -1,78 +0,0 @@
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 { FirebaseApp } from '@firebase/app-types';
18
- import { FirebaseApp as FirebaseAppExp } from "@firebase/app-types";
19
- import { Repo } from './Repo';
20
- import './Repo_transaction';
21
- import { Database } from '../api/Database';
22
- import { RepoInfo } from './RepoInfo';
23
- import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
24
- import { Provider } from '@firebase/component';
25
- import { AuthTokenProvider } from './AuthTokenProvider';
26
- /**
27
- * Intersection type that allows the SDK to be used from firebase-exp and
28
- * firebase v8.
29
- */
30
- export declare type FirebaseAppLike = FirebaseApp | FirebaseAppExp;
31
- /**
32
- * Creates and caches Repo instances.
33
- */
34
- export declare class RepoManager {
35
- /**
36
- * @private {!Object.<string, Object<string, !fb.core.Repo>>}
37
- */
38
- private repos_;
39
- /**
40
- * If true, new Repos will be created to use ReadonlyRestClient (for testing purposes).
41
- * @private {boolean}
42
- */
43
- private useRestClient_;
44
- static getInstance(): RepoManager;
45
- interrupt(): void;
46
- resume(): void;
47
- /**
48
- * Update an existing repo in place to point to a new host/port.
49
- */
50
- applyEmulatorSettings(repo: Repo, host: string, port: number): void;
51
- /**
52
- * This function should only ever be called to CREATE a new database instance.
53
- *
54
- * @param {!FirebaseApp} app
55
- * @return {!Database}
56
- */
57
- databaseFromApp(app: FirebaseAppLike, authProvider: Provider<FirebaseAuthInternalName>, url?: string, nodeAdmin?: boolean): Database;
58
- /**
59
- * Remove the repo and make sure it is disconnected.
60
- *
61
- * @param {!Repo} repo
62
- */
63
- deleteRepo(repo: Repo): void;
64
- /**
65
- * Ensures a repo doesn't already exist and then creates one using the
66
- * provided app.
67
- *
68
- * @param {!RepoInfo} repoInfo The metadata about the Repo
69
- * @param {!FirebaseApp} app
70
- * @return {!Repo} The Repo object for the specified server / repoName.
71
- */
72
- createRepo(repoInfo: RepoInfo, app: FirebaseAppLike, authTokenProvider: AuthTokenProvider): Repo;
73
- /**
74
- * Forces us to use ReadonlyRestClient instead of PersistentConnection for new Repos.
75
- * @param {boolean} forceRestClient
76
- */
77
- forceRestClient(forceRestClient: boolean): void;
78
- }
@@ -1,33 +0,0 @@
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 { DataSnapshot } from '../api/DataSnapshot';
18
- import { Path } from './util/Path';
19
- /**
20
- * @enum {number}
21
- */
22
- export declare enum TransactionStatus {
23
- RUN = 0,
24
- SENT = 1,
25
- COMPLETED = 2,
26
- SENT_NEEDS_ABORT = 3,
27
- NEEDS_ABORT = 4
28
- }
29
- declare module './Repo' {
30
- interface Repo {
31
- startTransaction(path: Path, transactionUpdate: (a: unknown) => void, onComplete: ((a: Error, b: boolean, c: DataSnapshot) => void) | null, applyLocally: boolean): void;
32
- }
33
- }
@@ -1,85 +0,0 @@
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 { Query } from '../api/Query';
18
- /**
19
- * Interface defining the set of actions that can be performed against the Firebase server
20
- * (basically corresponds to our wire protocol).
21
- *
22
- * @interface
23
- */
24
- export declare abstract class ServerActions {
25
- /**
26
- * @param {!Query} query
27
- * @param {function():string} currentHashFn
28
- * @param {?number} tag
29
- * @param {function(string, *)} onComplete
30
- */
31
- abstract listen(query: Query, currentHashFn: () => string, tag: number | null, onComplete: (a: string, b: unknown) => void): void;
32
- /**
33
- * Remove a listen.
34
- *
35
- * @param {!Query} query
36
- * @param {?number} tag
37
- */
38
- abstract unlisten(query: Query, tag: number | null): void;
39
- /**
40
- * Get the server value satisfying this query.
41
- */
42
- abstract get(query: Query): Promise<string>;
43
- /**
44
- * @param {string} pathString
45
- * @param {*} data
46
- * @param {function(string, string)=} onComplete
47
- * @param {string=} hash
48
- */
49
- put(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void, hash?: string): void;
50
- /**
51
- * @param {string} pathString
52
- * @param {*} data
53
- * @param {function(string, ?string)} onComplete
54
- * @param {string=} hash
55
- */
56
- merge(pathString: string, data: unknown, onComplete: (a: string, b: string | null) => void, hash?: string): void;
57
- /**
58
- * Refreshes the auth token for the current connection.
59
- * @param {string} token The authentication token
60
- */
61
- refreshAuthToken(token: string): void;
62
- /**
63
- * @param {string} pathString
64
- * @param {*} data
65
- * @param {function(string, string)=} onComplete
66
- */
67
- onDisconnectPut(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
68
- /**
69
- * @param {string} pathString
70
- * @param {*} data
71
- * @param {function(string, string)=} onComplete
72
- */
73
- onDisconnectMerge(pathString: string, data: unknown, onComplete?: (a: string, b: string) => void): void;
74
- /**
75
- * @param {string} pathString
76
- * @param {function(string, string)=} onComplete
77
- */
78
- onDisconnectCancel(pathString: string, onComplete?: (a: string, b: string) => void): void;
79
- /**
80
- * @param {Object.<string, *>} stats
81
- */
82
- reportStats(stats: {
83
- [k: string]: unknown;
84
- }): void;
85
- }
@@ -1,28 +0,0 @@
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 { Node } from './snap/Node';
19
- /**
20
- * Mutable object which basically just stores a reference to the "latest" immutable snapshot.
21
- *
22
- * @constructor
23
- */
24
- export declare class SnapshotHolder {
25
- private rootNode_;
26
- getNode(path: Path): Node;
27
- updateSnapshot(path: Path, newSnapshotNode: Node): void;
28
- }
@@ -1,61 +0,0 @@
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 { Node } from './snap/Node';
19
- /**
20
- * Helper class to store a sparse set of snapshots.
21
- */
22
- export declare class SparseSnapshotTree {
23
- private value;
24
- private readonly children;
25
- /**
26
- * Gets the node stored at the given path if one exists.
27
- *
28
- * @param path Path to look up snapshot for.
29
- * @return The retrieved node, or null.
30
- */
31
- find(path: Path): Node | null;
32
- /**
33
- * Stores the given node at the specified path. If there is already a node
34
- * at a shallower path, it merges the new data into that snapshot node.
35
- *
36
- * @param path Path to look up snapshot for.
37
- * @param data The new data, or null.
38
- */
39
- remember(path: Path, data: Node): void;
40
- /**
41
- * Purge the data at path from the cache.
42
- *
43
- * @param path Path to look up snapshot for.
44
- * @return True if this node should now be removed.
45
- */
46
- forget(path: Path): boolean;
47
- /**
48
- * Recursively iterates through all of the stored tree and calls the
49
- * callback on each one.
50
- *
51
- * @param prefixPath Path to look up node for.
52
- * @param func The function to invoke for each tree.
53
- */
54
- forEachTree(prefixPath: Path, func: (a: Path, b: Node) => unknown): void;
55
- /**
56
- * Iterates through each immediate child and triggers the callback.
57
- *
58
- * @param func The function to invoke for each child.
59
- */
60
- forEachChild(func: (a: string, b: SparseSnapshotTree) => void): void;
61
- }
@@ -1,84 +0,0 @@
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 { View } from './view/View';
18
- import { Operation } from './operation/Operation';
19
- import { WriteTreeRef } from './WriteTree';
20
- import { Query } from '../api/Query';
21
- import { EventRegistration } from './view/EventRegistration';
22
- import { Node } from './snap/Node';
23
- import { Path } from './util/Path';
24
- import { Event } from './view/Event';
25
- import { ReferenceConstructor } from '../api/Reference';
26
- /**
27
- * SyncPoint represents a single location in a SyncTree with 1 or more event registrations, meaning we need to
28
- * maintain 1 or more Views at this location to cache server data and raise appropriate events for server changes
29
- * and user writes (set, transaction, update).
30
- *
31
- * It's responsible for:
32
- * - Maintaining the set of 1 or more views necessary at this location (a SyncPoint with 0 views should be removed).
33
- * - Proxying user / server operations to the views as appropriate (i.e. applyServerOverwrite,
34
- * applyUserOverwrite, etc.)
35
- */
36
- export declare class SyncPoint {
37
- static set __referenceConstructor(val: ReferenceConstructor);
38
- static get __referenceConstructor(): ReferenceConstructor;
39
- /**
40
- * The Views being tracked at this location in the tree, stored as a map where the key is a
41
- * queryId and the value is the View for that query.
42
- *
43
- * NOTE: This list will be quite small (usually 1, but perhaps 2 or 3; any more is an odd use case).
44
- */
45
- private readonly views;
46
- isEmpty(): boolean;
47
- applyOperation(operation: Operation, writesCache: WriteTreeRef, optCompleteServerCache: Node | null): Event[];
48
- /**
49
- * Add an event callback for the specified query.
50
- *
51
- * @param {!Query} query
52
- * @param {!EventRegistration} eventRegistration
53
- * @param {!WriteTreeRef} writesCache
54
- * @param {?Node} serverCache Complete server cache, if we have it.
55
- * @param {boolean} serverCacheComplete
56
- * @return {!Array.<!Event>} Events to raise.
57
- */
58
- addEventRegistration(query: Query, eventRegistration: EventRegistration, writesCache: WriteTreeRef, serverCache: Node | null, serverCacheComplete: boolean): Event[];
59
- /**
60
- * Remove event callback(s). Return cancelEvents if a cancelError is specified.
61
- *
62
- * If query is the default query, we'll check all views for the specified eventRegistration.
63
- * If eventRegistration is null, we'll remove all callbacks for the specified view(s).
64
- *
65
- * @param {!Query} query
66
- * @param {?EventRegistration} eventRegistration If null, remove all callbacks.
67
- * @param {Error=} cancelError If a cancelError is provided, appropriate cancel events will be returned.
68
- * @return {{removed:!Array.<!Query>, events:!Array.<!Event>}} removed queries and any cancel events
69
- */
70
- removeEventRegistration(query: Query, eventRegistration: EventRegistration | null, cancelError?: Error): {
71
- removed: Query[];
72
- events: Event[];
73
- };
74
- getQueryViews(): View[];
75
- /**
76
- * @param path The path to the desired complete snapshot
77
- * @return A complete cache, if it exists
78
- */
79
- getCompleteServerCache(path: Path): Node | null;
80
- viewForQuery(query: Query): View | null;
81
- viewExistsForQuery(query: Query): boolean;
82
- hasCompleteView(): boolean;
83
- getCompleteView(): View | null;
84
- }
@@ -1,236 +0,0 @@
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 { Query } from '../api/Query';
19
- import { Node } from './snap/Node';
20
- import { Event } from './view/Event';
21
- import { EventRegistration } from './view/EventRegistration';
22
- /**
23
- * @typedef {{
24
- * startListening: function(
25
- * !Query,
26
- * ?number,
27
- * function():string,
28
- * function(!string, *):!Array.<!Event>
29
- * ):!Array.<!Event>,
30
- *
31
- * stopListening: function(!Query, ?number)
32
- * }}
33
- */
34
- export interface ListenProvider {
35
- startListening(query: Query, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
36
- stopListening(a: Query, b: number | null): void;
37
- }
38
- /**
39
- * SyncTree is the central class for managing event callback registration, data caching, views
40
- * (query processing), and event generation. There are typically two SyncTree instances for
41
- * each Repo, one for the normal Firebase data, and one for the .info data.
42
- *
43
- * It has a number of responsibilities, including:
44
- * - Tracking all user event callbacks (registered via addEventRegistration() and removeEventRegistration()).
45
- * - Applying and caching data changes for user set(), transaction(), and update() calls
46
- * (applyUserOverwrite(), applyUserMerge()).
47
- * - Applying and caching data changes for server data changes (applyServerOverwrite(),
48
- * applyServerMerge()).
49
- * - Generating user-facing events for server and user changes (all of the apply* methods
50
- * return the set of events that need to be raised as a result).
51
- * - Maintaining the appropriate set of server listens to ensure we are always subscribed
52
- * to the correct set of paths and queries to satisfy the current set of user event
53
- * callbacks (listens are started/stopped using the provided listenProvider).
54
- *
55
- * NOTE: Although SyncTree tracks event callbacks and calculates events to raise, the actual
56
- * events are returned to the caller rather than raised synchronously.
57
- *
58
- * @constructor
59
- */
60
- export declare class SyncTree {
61
- private listenProvider_;
62
- /**
63
- * Tree of SyncPoints. There's a SyncPoint at any location that has 1 or more views.
64
- */
65
- private syncPointTree_;
66
- /**
67
- * A tree of all pending user writes (user-initiated set()'s, transaction()'s, update()'s, etc.).
68
- */
69
- private pendingWriteTree_;
70
- private readonly tagToQueryMap;
71
- private readonly queryToTagMap;
72
- /**
73
- * @param {!ListenProvider} listenProvider_ Used by SyncTree to start / stop listening
74
- * to server data.
75
- */
76
- constructor(listenProvider_: ListenProvider);
77
- /**
78
- * Apply the data changes for a user-generated set() or transaction() call.
79
- *
80
- * @return Events to raise.
81
- */
82
- applyUserOverwrite(path: Path, newData: Node, writeId: number, visible?: boolean): Event[];
83
- /**
84
- * Apply the data from a user-generated update() call
85
- *
86
- * @return Events to raise.
87
- */
88
- applyUserMerge(path: Path, changedChildren: {
89
- [k: string]: Node;
90
- }, writeId: number): Event[];
91
- /**
92
- * Acknowledge a pending user write that was previously registered with applyUserOverwrite() or applyUserMerge().
93
- *
94
- * @param revert True if the given write failed and needs to be reverted
95
- * @return Events to raise.
96
- */
97
- ackUserWrite(writeId: number, revert?: boolean): Event[];
98
- /**
99
- * Apply new server data for the specified path..
100
- *
101
- * @return Events to raise.
102
- */
103
- applyServerOverwrite(path: Path, newData: Node): Event[];
104
- /**
105
- * Apply new server data to be merged in at the specified path.
106
- *
107
- * @return Events to raise.
108
- */
109
- applyServerMerge(path: Path, changedChildren: {
110
- [k: string]: Node;
111
- }): Event[];
112
- /**
113
- * Apply a listen complete for a query
114
- *
115
- * @return Events to raise.
116
- */
117
- applyListenComplete(path: Path): Event[];
118
- /**
119
- * Apply new server data for the specified tagged query.
120
- *
121
- * @return Events to raise.
122
- */
123
- applyTaggedQueryOverwrite(path: Path, snap: Node, tag: number): Event[];
124
- /**
125
- * Apply server data to be merged in for the specified tagged query.
126
- *
127
- * @return Events to raise.
128
- */
129
- applyTaggedQueryMerge(path: Path, changedChildren: {
130
- [k: string]: Node;
131
- }, tag: number): Event[];
132
- /**
133
- * Apply a listen complete for a tagged query
134
- *
135
- * @return Events to raise.
136
- */
137
- applyTaggedListenComplete(path: Path, tag: number): Event[];
138
- /**
139
- * Add an event callback for the specified query.
140
- *
141
- * @return Events to raise.
142
- */
143
- addEventRegistration(query: Query, eventRegistration: EventRegistration): Event[];
144
- /**
145
- * Remove event callback(s).
146
- *
147
- * If query is the default query, we'll check all queries for the specified eventRegistration.
148
- * If eventRegistration is null, we'll remove all callbacks for the specified query/queries.
149
- *
150
- * @param eventRegistration If null, all callbacks are removed.
151
- * @param cancelError If a cancelError is provided, appropriate cancel events will be returned.
152
- * @return Cancel events, if cancelError was provided.
153
- */
154
- removeEventRegistration(query: Query, eventRegistration: EventRegistration | null, cancelError?: Error): Event[];
155
- /**
156
- * Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
157
- * listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
158
- * have a listener above, and atomic operations would correctly show a jitter of <increment value> ->
159
- * <incremented total> as the write is applied locally and then acknowledged at the server.
160
- *
161
- * Note: this method will *include* hidden writes from transaction with applyLocally set to false.
162
- *
163
- * @param path The path to the data we want
164
- * @param writeIdsToExclude A specific set to be excluded
165
- */
166
- calcCompleteEventCache(path: Path, writeIdsToExclude?: number[]): Node;
167
- /**
168
- * This collapses multiple unfiltered views into a single view, since we only need a single
169
- * listener for them.
170
- */
171
- private collectDistinctViewsForSubTree_;
172
- private removeTags_;
173
- /**
174
- * Normalizes a query to a query we send the server for listening
175
- *
176
- * @return The normalized query
177
- */
178
- private static queryForListening_;
179
- /**
180
- * For a given new listen, manage the de-duplication of outstanding subscriptions.
181
- *
182
- * @return This method can return events to support synchronous data sources
183
- */
184
- private setupListener_;
185
- private createListenerForView_;
186
- /**
187
- * Given a query, computes a "queryKey" suitable for use in our queryToTagMap_.
188
- */
189
- private static makeQueryKey_;
190
- /**
191
- * Given a queryKey (created by makeQueryKey), parse it back into a path and queryId.
192
- */
193
- private static parseQueryKey_;
194
- /**
195
- * Return the query associated with the given tag, if we have one
196
- */
197
- private queryKeyForTag_;
198
- /**
199
- * Return the tag associated with the given query.
200
- */
201
- private tagForQuery_;
202
- /**
203
- * Static tracker for next query tag.
204
- */
205
- private static nextQueryTag_;
206
- /**
207
- * Static accessor for query tags.
208
- */
209
- private static getNextQueryTag_;
210
- /**
211
- * A helper method to apply tagged operations
212
- */
213
- private applyTaggedOperation_;
214
- /**
215
- * A helper method that visits all descendant and ancestor SyncPoints, applying the operation.
216
- *
217
- * NOTES:
218
- * - Descendant SyncPoints will be visited first (since we raise events depth-first).
219
- *
220
- * - We call applyOperation() on each SyncPoint passing three things:
221
- * 1. A version of the Operation that has been made relative to the SyncPoint location.
222
- * 2. A WriteTreeRef of any writes we have cached at the SyncPoint location.
223
- * 3. A snapshot Node with cached server data, if we have it.
224
- *
225
- * - We concatenate all of the events returned by each SyncPoint and return the result.
226
- */
227
- private applyOperationToSyncPoints_;
228
- /**
229
- * Recursive helper for applyOperationToSyncPoints_
230
- */
231
- private applyOperationHelper_;
232
- /**
233
- * Recursive helper for applyOperationToSyncPoints_
234
- */
235
- private applyOperationDescendantsHelper_;
236
- }