@firebase/database 1.0.9 → 1.0.10
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.
- package/dist/index.cjs.js +13834 -13834
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +13834 -13834
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.node.cjs.js +13849 -13849
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.standalone.js +13797 -13797
- package/dist/index.standalone.js.map +1 -1
- package/dist/node-esm/index.node.esm.js +13849 -13849
- package/dist/node-esm/index.node.esm.js.map +1 -1
- package/dist/node-esm/src/api/Database.d.ts +137 -137
- package/dist/node-esm/src/api/OnDisconnect.d.ts +110 -110
- package/dist/node-esm/src/api/Reference.d.ts +122 -122
- package/dist/node-esm/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/node-esm/src/api/ServerValue.d.ts +30 -30
- package/dist/node-esm/src/api/Transaction.d.ts +83 -83
- package/dist/node-esm/src/api/test_access.d.ts +31 -31
- package/dist/node-esm/src/api.d.ts +18 -18
- package/dist/node-esm/src/api.standalone.d.ts +30 -30
- package/dist/node-esm/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/node-esm/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/node-esm/src/core/CompoundWrite.d.ts +81 -81
- package/dist/node-esm/src/core/PersistentConnection.d.ts +135 -135
- package/dist/node-esm/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/node-esm/src/core/Repo.d.ts +144 -144
- package/dist/node-esm/src/core/RepoInfo.d.ts +56 -56
- package/dist/node-esm/src/core/ServerActions.d.ts +52 -52
- package/dist/node-esm/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/node-esm/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/node-esm/src/core/SyncPoint.d.ts +91 -91
- package/dist/node-esm/src/core/SyncTree.d.ts +166 -166
- package/dist/node-esm/src/core/WriteTree.d.ts +205 -205
- package/dist/node-esm/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/node-esm/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/node-esm/src/core/operation/Merge.d.ts +33 -33
- package/dist/node-esm/src/core/operation/Operation.d.ts +45 -45
- package/dist/node-esm/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/node-esm/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/node-esm/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/node-esm/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/node-esm/src/core/snap/Node.d.ts +126 -126
- package/dist/node-esm/src/core/snap/childSet.d.ts +32 -32
- package/dist/node-esm/src/core/snap/comparators.d.ts +19 -19
- package/dist/node-esm/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/node-esm/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/node-esm/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/node-esm/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/node-esm/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/node-esm/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/node-esm/src/core/snap/snap.d.ts +23 -23
- package/dist/node-esm/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/node-esm/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/node-esm/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/node-esm/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/node-esm/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/node-esm/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/node-esm/src/core/storage/storage.d.ts +22 -22
- package/dist/node-esm/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/node-esm/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/node-esm/src/core/util/NextPushId.d.ts +33 -33
- package/dist/node-esm/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/node-esm/src/core/util/Path.d.ts +94 -94
- package/dist/node-esm/src/core/util/ServerValues.d.ts +56 -56
- package/dist/node-esm/src/core/util/SortedMap.d.ts +324 -324
- package/dist/node-esm/src/core/util/Tree.d.ts +105 -105
- package/dist/node-esm/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/node-esm/src/core/util/libs/parser.d.ts +32 -32
- package/dist/node-esm/src/core/util/misc.d.ts +19 -19
- package/dist/node-esm/src/core/util/util.d.ts +176 -176
- package/dist/node-esm/src/core/util/validation.d.ts +70 -70
- package/dist/node-esm/src/core/version.d.ts +23 -23
- package/dist/node-esm/src/core/view/CacheNode.d.ts +41 -41
- package/dist/node-esm/src/core/view/Change.d.ts +46 -46
- package/dist/node-esm/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/node-esm/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/node-esm/src/core/view/Event.d.ts +64 -64
- package/dist/node-esm/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/node-esm/src/core/view/EventQueue.d.ts +67 -67
- package/dist/node-esm/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/node-esm/src/core/view/QueryParams.d.ts +95 -95
- package/dist/node-esm/src/core/view/View.d.ts +59 -59
- package/dist/node-esm/src/core/view/ViewCache.d.ts +32 -32
- package/dist/node-esm/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/node-esm/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/node-esm/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/node-esm/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/node-esm/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/node-esm/src/index.d.ts +28 -28
- package/dist/node-esm/src/index.node.d.ts +17 -17
- package/dist/node-esm/src/index.standalone.d.ts +17 -17
- package/dist/node-esm/src/internal/index.d.ts +38 -38
- package/dist/node-esm/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/node-esm/src/realtime/Connection.d.ts +102 -102
- package/dist/node-esm/src/realtime/Constants.d.ts +27 -27
- package/dist/node-esm/src/realtime/Transport.d.ts +58 -58
- package/dist/node-esm/src/realtime/TransportManager.d.ts +50 -50
- package/dist/node-esm/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/node-esm/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/node-esm/src/register.d.ts +1 -1
- package/dist/node-esm/test/compound_write.test.d.ts +17 -17
- package/dist/node-esm/test/connection.test.d.ts +17 -17
- package/dist/node-esm/test/deno.test.d.ts +17 -17
- package/dist/node-esm/test/exp/integration.test.d.ts +17 -17
- package/dist/node-esm/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/node-esm/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/node-esm/test/helpers/util.d.ts +34 -34
- package/dist/node-esm/test/node.test.d.ts +17 -17
- package/dist/node-esm/test/parser.test.d.ts +17 -17
- package/dist/node-esm/test/path.test.d.ts +17 -17
- package/dist/node-esm/test/pushid.test.d.ts +17 -17
- package/dist/node-esm/test/queryconstraint.test.d.ts +17 -17
- package/dist/node-esm/test/repoinfo.test.d.ts +17 -17
- package/dist/node-esm/test/sortedmap.test.d.ts +17 -17
- package/dist/node-esm/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/node-esm/test/syncpoint.test.d.ts +17 -17
- package/dist/node-esm/test/transport.test.d.ts +17 -17
- package/dist/node-esm/test/websocketconnection.test.d.ts +17 -17
- package/dist/src/api/Database.d.ts +137 -137
- package/dist/src/api/OnDisconnect.d.ts +110 -110
- package/dist/src/api/Reference.d.ts +122 -122
- package/dist/src/api/Reference_impl.d.ts +1098 -1098
- package/dist/src/api/ServerValue.d.ts +30 -30
- package/dist/src/api/Transaction.d.ts +83 -83
- package/dist/src/api/test_access.d.ts +31 -31
- package/dist/src/api.d.ts +18 -18
- package/dist/src/api.standalone.d.ts +30 -30
- package/dist/src/core/AppCheckTokenProvider.d.ts +30 -30
- package/dist/src/core/AuthTokenProvider.d.ts +49 -49
- package/dist/src/core/CompoundWrite.d.ts +81 -81
- package/dist/src/core/PersistentConnection.d.ts +135 -135
- package/dist/src/core/ReadonlyRestClient.d.ts +60 -60
- package/dist/src/core/Repo.d.ts +144 -144
- package/dist/src/core/RepoInfo.d.ts +56 -56
- package/dist/src/core/ServerActions.d.ts +52 -52
- package/dist/src/core/SnapshotHolder.d.ts +26 -26
- package/dist/src/core/SparseSnapshotTree.d.ts +64 -64
- package/dist/src/core/SyncPoint.d.ts +91 -91
- package/dist/src/core/SyncTree.d.ts +166 -166
- package/dist/src/core/WriteTree.d.ts +205 -205
- package/dist/src/core/operation/AckUserWrite.d.ts +36 -36
- package/dist/src/core/operation/ListenComplete.d.ts +26 -26
- package/dist/src/core/operation/Merge.d.ts +33 -33
- package/dist/src/core/operation/Operation.d.ts +45 -45
- package/dist/src/core/operation/Overwrite.d.ts +28 -28
- package/dist/src/core/snap/ChildrenNode.d.ts +112 -112
- package/dist/src/core/snap/IndexMap.d.ts +43 -43
- package/dist/src/core/snap/LeafNode.d.ts +83 -83
- package/dist/src/core/snap/Node.d.ts +126 -126
- package/dist/src/core/snap/childSet.d.ts +32 -32
- package/dist/src/core/snap/comparators.d.ts +19 -19
- package/dist/src/core/snap/indexes/Index.d.ts +50 -50
- package/dist/src/core/snap/indexes/KeyIndex.d.ts +34 -34
- package/dist/src/core/snap/indexes/PathIndex.d.ts +29 -29
- package/dist/src/core/snap/indexes/PriorityIndex.d.ts +33 -33
- package/dist/src/core/snap/indexes/ValueIndex.d.ts +31 -31
- package/dist/src/core/snap/nodeFromJSON.d.ts +24 -24
- package/dist/src/core/snap/snap.d.ts +23 -23
- package/dist/src/core/stats/StatsCollection.d.ts +26 -26
- package/dist/src/core/stats/StatsListener.d.ts +30 -30
- package/dist/src/core/stats/StatsManager.d.ts +20 -20
- package/dist/src/core/stats/StatsReporter.d.ts +28 -28
- package/dist/src/core/storage/DOMStorageWrapper.d.ts +46 -46
- package/dist/src/core/storage/MemoryStorage.d.ts +27 -27
- package/dist/src/core/storage/storage.d.ts +22 -22
- package/dist/src/core/util/EventEmitter.d.ts +39 -39
- package/dist/src/core/util/ImmutableTree.d.ts +117 -117
- package/dist/src/core/util/NextPushId.d.ts +33 -33
- package/dist/src/core/util/OnlineMonitor.d.ts +31 -31
- package/dist/src/core/util/Path.d.ts +94 -94
- package/dist/src/core/util/ServerValues.d.ts +56 -56
- package/dist/src/core/util/SortedMap.d.ts +324 -324
- package/dist/src/core/util/Tree.d.ts +105 -105
- package/dist/src/core/util/VisibilityMonitor.d.ts +23 -23
- package/dist/src/core/util/libs/parser.d.ts +32 -32
- package/dist/src/core/util/misc.d.ts +19 -19
- package/dist/src/core/util/util.d.ts +176 -176
- package/dist/src/core/util/validation.d.ts +70 -70
- package/dist/src/core/version.d.ts +23 -23
- package/dist/src/core/view/CacheNode.d.ts +41 -41
- package/dist/src/core/view/Change.d.ts +46 -46
- package/dist/src/core/view/ChildChangeAccumulator.d.ts +22 -22
- package/dist/src/core/view/CompleteChildSource.d.ts +55 -55
- package/dist/src/core/view/Event.d.ts +64 -64
- package/dist/src/core/view/EventGenerator.d.ts +42 -42
- package/dist/src/core/view/EventQueue.d.ts +67 -67
- package/dist/src/core/view/EventRegistration.d.ts +87 -87
- package/dist/src/core/view/QueryParams.d.ts +95 -95
- package/dist/src/core/view/View.d.ts +59 -59
- package/dist/src/core/view/ViewCache.d.ts +32 -32
- package/dist/src/core/view/ViewProcessor.d.ts +32 -32
- package/dist/src/core/view/filter/IndexedFilter.d.ts +35 -35
- package/dist/src/core/view/filter/LimitedFilter.d.ts +47 -47
- package/dist/src/core/view/filter/NodeFilter.d.ts +54 -54
- package/dist/src/core/view/filter/RangedFilter.d.ts +47 -47
- package/dist/src/index.d.ts +28 -28
- package/dist/src/index.node.d.ts +17 -17
- package/dist/src/index.standalone.d.ts +17 -17
- package/dist/src/internal/index.d.ts +38 -38
- package/dist/src/realtime/BrowserPollConnection.d.ts +198 -198
- package/dist/src/realtime/Connection.d.ts +102 -102
- package/dist/src/realtime/Constants.d.ts +27 -27
- package/dist/src/realtime/Transport.d.ts +58 -58
- package/dist/src/realtime/TransportManager.d.ts +50 -50
- package/dist/src/realtime/WebSocketConnection.d.ts +127 -127
- package/dist/src/realtime/polling/PacketReceiver.d.ts +38 -38
- package/dist/src/register.d.ts +1 -1
- package/dist/test/compound_write.test.d.ts +17 -17
- package/dist/test/connection.test.d.ts +17 -17
- package/dist/test/deno.test.d.ts +17 -17
- package/dist/test/exp/integration.test.d.ts +17 -17
- package/dist/test/helpers/EventAccumulator.d.ts +35 -35
- package/dist/test/helpers/syncpoint-util.d.ts +29 -29
- package/dist/test/helpers/util.d.ts +34 -34
- package/dist/test/node.test.d.ts +17 -17
- package/dist/test/parser.test.d.ts +17 -17
- package/dist/test/path.test.d.ts +17 -17
- package/dist/test/pushid.test.d.ts +17 -17
- package/dist/test/queryconstraint.test.d.ts +17 -17
- package/dist/test/repoinfo.test.d.ts +17 -17
- package/dist/test/sortedmap.test.d.ts +17 -17
- package/dist/test/sparsesnapshottree.test.d.ts +17 -17
- package/dist/test/syncpoint.test.d.ts +17 -17
- package/dist/test/transport.test.d.ts +17 -17
- package/dist/test/websocketconnection.test.d.ts +17 -17
- package/package.json +8 -8
|
@@ -1,137 +1,137 @@
|
|
|
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 { _FirebaseService, FirebaseApp } from '@firebase/app';
|
|
18
|
-
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
19
|
-
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
|
-
import { Provider } from '@firebase/component';
|
|
21
|
-
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
22
|
-
import { Repo } from '../core/Repo';
|
|
23
|
-
import { ReferenceImpl } from './Reference_impl';
|
|
24
|
-
export { EmulatorMockTokenOptions } from '@firebase/util';
|
|
25
|
-
/**
|
|
26
|
-
* This function should only ever be called to CREATE a new database instance.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
export declare function repoManagerDatabaseFromApp(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>, url?: string, nodeAdmin?: boolean): Database;
|
|
30
|
-
/**
|
|
31
|
-
* Forces us to use ReadonlyRestClient instead of PersistentConnection for new Repos.
|
|
32
|
-
*/
|
|
33
|
-
export declare function repoManagerForceRestClient(forceRestClient: boolean): void;
|
|
34
|
-
/**
|
|
35
|
-
* Class representing a Firebase Realtime Database.
|
|
36
|
-
*/
|
|
37
|
-
export declare class Database implements _FirebaseService {
|
|
38
|
-
_repoInternal: Repo;
|
|
39
|
-
/** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
|
|
40
|
-
readonly app: FirebaseApp;
|
|
41
|
-
/** Represents a `Database` instance. */
|
|
42
|
-
readonly 'type' = "database";
|
|
43
|
-
/** Track if the instance has been used (root or repo accessed) */
|
|
44
|
-
_instanceStarted: boolean;
|
|
45
|
-
/** Backing state for root_ */
|
|
46
|
-
private _rootInternal?;
|
|
47
|
-
/** @hideconstructor */
|
|
48
|
-
constructor(_repoInternal: Repo,
|
|
49
|
-
/** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
|
|
50
|
-
app: FirebaseApp);
|
|
51
|
-
get _repo(): Repo;
|
|
52
|
-
get _root(): ReferenceImpl;
|
|
53
|
-
_delete(): Promise<void>;
|
|
54
|
-
_checkNotDeleted(apiName: string): void;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Force the use of websockets instead of longPolling.
|
|
58
|
-
*/
|
|
59
|
-
export declare function forceWebSockets(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
62
|
-
*/
|
|
63
|
-
export declare function forceLongPolling(): void;
|
|
64
|
-
/**
|
|
65
|
-
* Returns the instance of the Realtime Database SDK that is associated with the provided
|
|
66
|
-
* {@link @firebase/app#FirebaseApp}. Initializes a new instance with default settings if
|
|
67
|
-
* no instance exists or if the existing instance uses a custom database URL.
|
|
68
|
-
*
|
|
69
|
-
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned Realtime
|
|
70
|
-
* Database instance is associated with.
|
|
71
|
-
* @param url - The URL of the Realtime Database instance to connect to. If not
|
|
72
|
-
* provided, the SDK connects to the default instance of the Firebase App.
|
|
73
|
-
* @returns The `Database` instance of the provided app.
|
|
74
|
-
*/
|
|
75
|
-
export declare function getDatabase(app?: FirebaseApp, url?: string): Database;
|
|
76
|
-
/**
|
|
77
|
-
* Modify the provided instance to communicate with the Realtime Database
|
|
78
|
-
* emulator.
|
|
79
|
-
*
|
|
80
|
-
* <p>Note: This method must be called before performing any other operation.
|
|
81
|
-
*
|
|
82
|
-
* @param db - The instance to modify.
|
|
83
|
-
* @param host - The emulator host (ex: localhost)
|
|
84
|
-
* @param port - The emulator port (ex: 8080)
|
|
85
|
-
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
|
86
|
-
*/
|
|
87
|
-
export declare function connectDatabaseEmulator(db: Database, host: string, port: number, options?: {
|
|
88
|
-
mockUserToken?: EmulatorMockTokenOptions | string;
|
|
89
|
-
}): void;
|
|
90
|
-
/**
|
|
91
|
-
* Disconnects from the server (all Database operations will be completed
|
|
92
|
-
* offline).
|
|
93
|
-
*
|
|
94
|
-
* The client automatically maintains a persistent connection to the Database
|
|
95
|
-
* server, which will remain active indefinitely and reconnect when
|
|
96
|
-
* disconnected. However, the `goOffline()` and `goOnline()` methods may be used
|
|
97
|
-
* to control the client connection in cases where a persistent connection is
|
|
98
|
-
* undesirable.
|
|
99
|
-
*
|
|
100
|
-
* While offline, the client will no longer receive data updates from the
|
|
101
|
-
* Database. However, all Database operations performed locally will continue to
|
|
102
|
-
* immediately fire events, allowing your application to continue behaving
|
|
103
|
-
* normally. Additionally, each operation performed locally will automatically
|
|
104
|
-
* be queued and retried upon reconnection to the Database server.
|
|
105
|
-
*
|
|
106
|
-
* To reconnect to the Database and begin receiving remote events, see
|
|
107
|
-
* `goOnline()`.
|
|
108
|
-
*
|
|
109
|
-
* @param db - The instance to disconnect.
|
|
110
|
-
*/
|
|
111
|
-
export declare function goOffline(db: Database): void;
|
|
112
|
-
/**
|
|
113
|
-
* Reconnects to the server and synchronizes the offline Database state
|
|
114
|
-
* with the server state.
|
|
115
|
-
*
|
|
116
|
-
* This method should be used after disabling the active connection with
|
|
117
|
-
* `goOffline()`. Once reconnected, the client will transmit the proper data
|
|
118
|
-
* and fire the appropriate events so that your client "catches up"
|
|
119
|
-
* automatically.
|
|
120
|
-
*
|
|
121
|
-
* @param db - The instance to reconnect.
|
|
122
|
-
*/
|
|
123
|
-
export declare function goOnline(db: Database): void;
|
|
124
|
-
/**
|
|
125
|
-
* Logs debugging information to the console.
|
|
126
|
-
*
|
|
127
|
-
* @param enabled - Enables logging if `true`, disables logging if `false`.
|
|
128
|
-
* @param persistent - Remembers the logging state between page refreshes if
|
|
129
|
-
* `true`.
|
|
130
|
-
*/
|
|
131
|
-
export declare function enableLogging(enabled: boolean, persistent?: boolean): any;
|
|
132
|
-
/**
|
|
133
|
-
* Logs debugging information to the console.
|
|
134
|
-
*
|
|
135
|
-
* @param logger - A custom logger function to control how things get logged.
|
|
136
|
-
*/
|
|
137
|
-
export declare function enableLogging(logger: (message: string) => unknown): any;
|
|
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 { _FirebaseService, FirebaseApp } from '@firebase/app';
|
|
18
|
+
import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types';
|
|
19
|
+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
|
|
20
|
+
import { Provider } from '@firebase/component';
|
|
21
|
+
import { EmulatorMockTokenOptions } from '@firebase/util';
|
|
22
|
+
import { Repo } from '../core/Repo';
|
|
23
|
+
import { ReferenceImpl } from './Reference_impl';
|
|
24
|
+
export { EmulatorMockTokenOptions } from '@firebase/util';
|
|
25
|
+
/**
|
|
26
|
+
* This function should only ever be called to CREATE a new database instance.
|
|
27
|
+
* @internal
|
|
28
|
+
*/
|
|
29
|
+
export declare function repoManagerDatabaseFromApp(app: FirebaseApp, authProvider: Provider<FirebaseAuthInternalName>, appCheckProvider?: Provider<AppCheckInternalComponentName>, url?: string, nodeAdmin?: boolean): Database;
|
|
30
|
+
/**
|
|
31
|
+
* Forces us to use ReadonlyRestClient instead of PersistentConnection for new Repos.
|
|
32
|
+
*/
|
|
33
|
+
export declare function repoManagerForceRestClient(forceRestClient: boolean): void;
|
|
34
|
+
/**
|
|
35
|
+
* Class representing a Firebase Realtime Database.
|
|
36
|
+
*/
|
|
37
|
+
export declare class Database implements _FirebaseService {
|
|
38
|
+
_repoInternal: Repo;
|
|
39
|
+
/** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
|
|
40
|
+
readonly app: FirebaseApp;
|
|
41
|
+
/** Represents a `Database` instance. */
|
|
42
|
+
readonly 'type' = "database";
|
|
43
|
+
/** Track if the instance has been used (root or repo accessed) */
|
|
44
|
+
_instanceStarted: boolean;
|
|
45
|
+
/** Backing state for root_ */
|
|
46
|
+
private _rootInternal?;
|
|
47
|
+
/** @hideconstructor */
|
|
48
|
+
constructor(_repoInternal: Repo,
|
|
49
|
+
/** The {@link @firebase/app#FirebaseApp} associated with this Realtime Database instance. */
|
|
50
|
+
app: FirebaseApp);
|
|
51
|
+
get _repo(): Repo;
|
|
52
|
+
get _root(): ReferenceImpl;
|
|
53
|
+
_delete(): Promise<void>;
|
|
54
|
+
_checkNotDeleted(apiName: string): void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Force the use of websockets instead of longPolling.
|
|
58
|
+
*/
|
|
59
|
+
export declare function forceWebSockets(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
|
|
62
|
+
*/
|
|
63
|
+
export declare function forceLongPolling(): void;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the instance of the Realtime Database SDK that is associated with the provided
|
|
66
|
+
* {@link @firebase/app#FirebaseApp}. Initializes a new instance with default settings if
|
|
67
|
+
* no instance exists or if the existing instance uses a custom database URL.
|
|
68
|
+
*
|
|
69
|
+
* @param app - The {@link @firebase/app#FirebaseApp} instance that the returned Realtime
|
|
70
|
+
* Database instance is associated with.
|
|
71
|
+
* @param url - The URL of the Realtime Database instance to connect to. If not
|
|
72
|
+
* provided, the SDK connects to the default instance of the Firebase App.
|
|
73
|
+
* @returns The `Database` instance of the provided app.
|
|
74
|
+
*/
|
|
75
|
+
export declare function getDatabase(app?: FirebaseApp, url?: string): Database;
|
|
76
|
+
/**
|
|
77
|
+
* Modify the provided instance to communicate with the Realtime Database
|
|
78
|
+
* emulator.
|
|
79
|
+
*
|
|
80
|
+
* <p>Note: This method must be called before performing any other operation.
|
|
81
|
+
*
|
|
82
|
+
* @param db - The instance to modify.
|
|
83
|
+
* @param host - The emulator host (ex: localhost)
|
|
84
|
+
* @param port - The emulator port (ex: 8080)
|
|
85
|
+
* @param options.mockUserToken - the mock auth token to use for unit testing Security Rules
|
|
86
|
+
*/
|
|
87
|
+
export declare function connectDatabaseEmulator(db: Database, host: string, port: number, options?: {
|
|
88
|
+
mockUserToken?: EmulatorMockTokenOptions | string;
|
|
89
|
+
}): void;
|
|
90
|
+
/**
|
|
91
|
+
* Disconnects from the server (all Database operations will be completed
|
|
92
|
+
* offline).
|
|
93
|
+
*
|
|
94
|
+
* The client automatically maintains a persistent connection to the Database
|
|
95
|
+
* server, which will remain active indefinitely and reconnect when
|
|
96
|
+
* disconnected. However, the `goOffline()` and `goOnline()` methods may be used
|
|
97
|
+
* to control the client connection in cases where a persistent connection is
|
|
98
|
+
* undesirable.
|
|
99
|
+
*
|
|
100
|
+
* While offline, the client will no longer receive data updates from the
|
|
101
|
+
* Database. However, all Database operations performed locally will continue to
|
|
102
|
+
* immediately fire events, allowing your application to continue behaving
|
|
103
|
+
* normally. Additionally, each operation performed locally will automatically
|
|
104
|
+
* be queued and retried upon reconnection to the Database server.
|
|
105
|
+
*
|
|
106
|
+
* To reconnect to the Database and begin receiving remote events, see
|
|
107
|
+
* `goOnline()`.
|
|
108
|
+
*
|
|
109
|
+
* @param db - The instance to disconnect.
|
|
110
|
+
*/
|
|
111
|
+
export declare function goOffline(db: Database): void;
|
|
112
|
+
/**
|
|
113
|
+
* Reconnects to the server and synchronizes the offline Database state
|
|
114
|
+
* with the server state.
|
|
115
|
+
*
|
|
116
|
+
* This method should be used after disabling the active connection with
|
|
117
|
+
* `goOffline()`. Once reconnected, the client will transmit the proper data
|
|
118
|
+
* and fire the appropriate events so that your client "catches up"
|
|
119
|
+
* automatically.
|
|
120
|
+
*
|
|
121
|
+
* @param db - The instance to reconnect.
|
|
122
|
+
*/
|
|
123
|
+
export declare function goOnline(db: Database): void;
|
|
124
|
+
/**
|
|
125
|
+
* Logs debugging information to the console.
|
|
126
|
+
*
|
|
127
|
+
* @param enabled - Enables logging if `true`, disables logging if `false`.
|
|
128
|
+
* @param persistent - Remembers the logging state between page refreshes if
|
|
129
|
+
* `true`.
|
|
130
|
+
*/
|
|
131
|
+
export declare function enableLogging(enabled: boolean, persistent?: boolean): any;
|
|
132
|
+
/**
|
|
133
|
+
* Logs debugging information to the console.
|
|
134
|
+
*
|
|
135
|
+
* @param logger - A custom logger function to control how things get logged.
|
|
136
|
+
*/
|
|
137
|
+
export declare function enableLogging(logger: (message: string) => unknown): any;
|
|
@@ -1,110 +1,110 @@
|
|
|
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 { Repo } from '../core/Repo';
|
|
18
|
-
import { Path } from '../core/util/Path';
|
|
19
|
-
/**
|
|
20
|
-
* The `onDisconnect` class allows you to write or clear data when your client
|
|
21
|
-
* disconnects from the Database server. These updates occur whether your
|
|
22
|
-
* client disconnects cleanly or not, so you can rely on them to clean up data
|
|
23
|
-
* even if a connection is dropped or a client crashes.
|
|
24
|
-
*
|
|
25
|
-
* The `onDisconnect` class is most commonly used to manage presence in
|
|
26
|
-
* applications where it is useful to detect how many clients are connected and
|
|
27
|
-
* when other clients disconnect. See
|
|
28
|
-
* {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
|
|
29
|
-
* for more information.
|
|
30
|
-
*
|
|
31
|
-
* To avoid problems when a connection is dropped before the requests can be
|
|
32
|
-
* transferred to the Database server, these functions should be called before
|
|
33
|
-
* writing any data.
|
|
34
|
-
*
|
|
35
|
-
* Note that `onDisconnect` operations are only triggered once. If you want an
|
|
36
|
-
* operation to occur each time a disconnect occurs, you'll need to re-establish
|
|
37
|
-
* the `onDisconnect` operations each time you reconnect.
|
|
38
|
-
*/
|
|
39
|
-
export declare class OnDisconnect {
|
|
40
|
-
private _repo;
|
|
41
|
-
private _path;
|
|
42
|
-
/** @hideconstructor */
|
|
43
|
-
constructor(_repo: Repo, _path: Path);
|
|
44
|
-
/**
|
|
45
|
-
* Cancels all previously queued `onDisconnect()` set or update events for this
|
|
46
|
-
* location and all children.
|
|
47
|
-
*
|
|
48
|
-
* If a write has been queued for this location via a `set()` or `update()` at a
|
|
49
|
-
* parent location, the write at this location will be canceled, though writes
|
|
50
|
-
* to sibling locations will still occur.
|
|
51
|
-
*
|
|
52
|
-
* @returns Resolves when synchronization to the server is complete.
|
|
53
|
-
*/
|
|
54
|
-
cancel(): Promise<void>;
|
|
55
|
-
/**
|
|
56
|
-
* Ensures the data at this location is deleted when the client is disconnected
|
|
57
|
-
* (due to closing the browser, navigating to a new page, or network issues).
|
|
58
|
-
*
|
|
59
|
-
* @returns Resolves when synchronization to the server is complete.
|
|
60
|
-
*/
|
|
61
|
-
remove(): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Ensures the data at this location is set to the specified value when the
|
|
64
|
-
* client is disconnected (due to closing the browser, navigating to a new page,
|
|
65
|
-
* or network issues).
|
|
66
|
-
*
|
|
67
|
-
* `set()` is especially useful for implementing "presence" systems, where a
|
|
68
|
-
* value should be changed or cleared when a user disconnects so that they
|
|
69
|
-
* appear "offline" to other users. See
|
|
70
|
-
* {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
|
|
71
|
-
* for more information.
|
|
72
|
-
*
|
|
73
|
-
* Note that `onDisconnect` operations are only triggered once. If you want an
|
|
74
|
-
* operation to occur each time a disconnect occurs, you'll need to re-establish
|
|
75
|
-
* the `onDisconnect` operations each time.
|
|
76
|
-
*
|
|
77
|
-
* @param value - The value to be written to this location on disconnect (can
|
|
78
|
-
* be an object, array, string, number, boolean, or null).
|
|
79
|
-
* @returns Resolves when synchronization to the Database is complete.
|
|
80
|
-
*/
|
|
81
|
-
set(value: unknown): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* Ensures the data at this location is set to the specified value and priority
|
|
84
|
-
* when the client is disconnected (due to closing the browser, navigating to a
|
|
85
|
-
* new page, or network issues).
|
|
86
|
-
*
|
|
87
|
-
* @param value - The value to be written to this location on disconnect (can
|
|
88
|
-
* be an object, array, string, number, boolean, or null).
|
|
89
|
-
* @param priority - The priority to be written (string, number, or null).
|
|
90
|
-
* @returns Resolves when synchronization to the Database is complete.
|
|
91
|
-
*/
|
|
92
|
-
setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
|
|
93
|
-
/**
|
|
94
|
-
* Writes multiple values at this location when the client is disconnected (due
|
|
95
|
-
* to closing the browser, navigating to a new page, or network issues).
|
|
96
|
-
*
|
|
97
|
-
* The `values` argument contains multiple property-value pairs that will be
|
|
98
|
-
* written to the Database together. Each child property can either be a simple
|
|
99
|
-
* property (for example, "name") or a relative path (for example, "name/first")
|
|
100
|
-
* from the current location to the data to update.
|
|
101
|
-
*
|
|
102
|
-
* As opposed to the `set()` method, `update()` can be use to selectively update
|
|
103
|
-
* only the referenced properties at the current location (instead of replacing
|
|
104
|
-
* all the child properties at the current location).
|
|
105
|
-
*
|
|
106
|
-
* @param values - Object containing multiple values.
|
|
107
|
-
* @returns Resolves when synchronization to the Database is complete.
|
|
108
|
-
*/
|
|
109
|
-
update(values: object): Promise<void>;
|
|
110
|
-
}
|
|
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 { Repo } from '../core/Repo';
|
|
18
|
+
import { Path } from '../core/util/Path';
|
|
19
|
+
/**
|
|
20
|
+
* The `onDisconnect` class allows you to write or clear data when your client
|
|
21
|
+
* disconnects from the Database server. These updates occur whether your
|
|
22
|
+
* client disconnects cleanly or not, so you can rely on them to clean up data
|
|
23
|
+
* even if a connection is dropped or a client crashes.
|
|
24
|
+
*
|
|
25
|
+
* The `onDisconnect` class is most commonly used to manage presence in
|
|
26
|
+
* applications where it is useful to detect how many clients are connected and
|
|
27
|
+
* when other clients disconnect. See
|
|
28
|
+
* {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
|
|
29
|
+
* for more information.
|
|
30
|
+
*
|
|
31
|
+
* To avoid problems when a connection is dropped before the requests can be
|
|
32
|
+
* transferred to the Database server, these functions should be called before
|
|
33
|
+
* writing any data.
|
|
34
|
+
*
|
|
35
|
+
* Note that `onDisconnect` operations are only triggered once. If you want an
|
|
36
|
+
* operation to occur each time a disconnect occurs, you'll need to re-establish
|
|
37
|
+
* the `onDisconnect` operations each time you reconnect.
|
|
38
|
+
*/
|
|
39
|
+
export declare class OnDisconnect {
|
|
40
|
+
private _repo;
|
|
41
|
+
private _path;
|
|
42
|
+
/** @hideconstructor */
|
|
43
|
+
constructor(_repo: Repo, _path: Path);
|
|
44
|
+
/**
|
|
45
|
+
* Cancels all previously queued `onDisconnect()` set or update events for this
|
|
46
|
+
* location and all children.
|
|
47
|
+
*
|
|
48
|
+
* If a write has been queued for this location via a `set()` or `update()` at a
|
|
49
|
+
* parent location, the write at this location will be canceled, though writes
|
|
50
|
+
* to sibling locations will still occur.
|
|
51
|
+
*
|
|
52
|
+
* @returns Resolves when synchronization to the server is complete.
|
|
53
|
+
*/
|
|
54
|
+
cancel(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Ensures the data at this location is deleted when the client is disconnected
|
|
57
|
+
* (due to closing the browser, navigating to a new page, or network issues).
|
|
58
|
+
*
|
|
59
|
+
* @returns Resolves when synchronization to the server is complete.
|
|
60
|
+
*/
|
|
61
|
+
remove(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Ensures the data at this location is set to the specified value when the
|
|
64
|
+
* client is disconnected (due to closing the browser, navigating to a new page,
|
|
65
|
+
* or network issues).
|
|
66
|
+
*
|
|
67
|
+
* `set()` is especially useful for implementing "presence" systems, where a
|
|
68
|
+
* value should be changed or cleared when a user disconnects so that they
|
|
69
|
+
* appear "offline" to other users. See
|
|
70
|
+
* {@link https://firebase.google.com/docs/database/web/offline-capabilities | Enabling Offline Capabilities in JavaScript}
|
|
71
|
+
* for more information.
|
|
72
|
+
*
|
|
73
|
+
* Note that `onDisconnect` operations are only triggered once. If you want an
|
|
74
|
+
* operation to occur each time a disconnect occurs, you'll need to re-establish
|
|
75
|
+
* the `onDisconnect` operations each time.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The value to be written to this location on disconnect (can
|
|
78
|
+
* be an object, array, string, number, boolean, or null).
|
|
79
|
+
* @returns Resolves when synchronization to the Database is complete.
|
|
80
|
+
*/
|
|
81
|
+
set(value: unknown): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Ensures the data at this location is set to the specified value and priority
|
|
84
|
+
* when the client is disconnected (due to closing the browser, navigating to a
|
|
85
|
+
* new page, or network issues).
|
|
86
|
+
*
|
|
87
|
+
* @param value - The value to be written to this location on disconnect (can
|
|
88
|
+
* be an object, array, string, number, boolean, or null).
|
|
89
|
+
* @param priority - The priority to be written (string, number, or null).
|
|
90
|
+
* @returns Resolves when synchronization to the Database is complete.
|
|
91
|
+
*/
|
|
92
|
+
setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Writes multiple values at this location when the client is disconnected (due
|
|
95
|
+
* to closing the browser, navigating to a new page, or network issues).
|
|
96
|
+
*
|
|
97
|
+
* The `values` argument contains multiple property-value pairs that will be
|
|
98
|
+
* written to the Database together. Each child property can either be a simple
|
|
99
|
+
* property (for example, "name") or a relative path (for example, "name/first")
|
|
100
|
+
* from the current location to the data to update.
|
|
101
|
+
*
|
|
102
|
+
* As opposed to the `set()` method, `update()` can be use to selectively update
|
|
103
|
+
* only the referenced properties at the current location (instead of replacing
|
|
104
|
+
* all the child properties at the current location).
|
|
105
|
+
*
|
|
106
|
+
* @param values - Object containing multiple values.
|
|
107
|
+
* @returns Resolves when synchronization to the Database is complete.
|
|
108
|
+
*/
|
|
109
|
+
update(values: object): Promise<void>;
|
|
110
|
+
}
|