@firebase/database 0.13.3 → 0.13.4-canary.a5d9e1083

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.
@@ -156,7 +156,9 @@ export declare class DataSnapshot {
156
156
  * @returns true if enumeration was canceled due to your callback returning
157
157
  * true.
158
158
  */
159
- forEach(action: (child: DataSnapshot) => boolean | void): boolean;
159
+ forEach(action: (child: DataSnapshot & {
160
+ key: string;
161
+ }) => boolean | void): boolean;
160
162
  /**
161
163
  * Returns true if the specified child path has (non-null) data.
162
164
  *
@@ -842,12 +844,11 @@ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSn
842
844
  export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
843
845
  export { EventType };
844
846
  /**
845
- * Detaches a callback previously attached with `on()`.
847
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
848
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
849
+ * the respective `on*` callbacks.
846
850
  *
847
- * Detach a callback previously attached with `on()`. Note that if `on()` was
848
- * called multiple times with the same eventType and callback, the callback
849
- * will be called multiple times for each event, and `off()` must be called
850
- * multiple times to remove the callback. Calling `off()` on a parent listener
851
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
851
852
  * will not automatically remove listeners registered on child nodes, `off()`
852
853
  * must also be called on any child listeners to remove the callback.
853
854
  *
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { ValueEventRegistration } from '../api/Reference_impl';
17
18
  import { AppCheckTokenProvider } from './AppCheckTokenProvider';
18
19
  import { AuthTokenProvider } from './AuthTokenProvider';
19
20
  import { PersistentConnection } from './PersistentConnection';
@@ -103,14 +104,14 @@ export declare function repoInterceptServerData(repo: Repo, callback: ((a: strin
103
104
  * belonging to active listeners. If they are found, such values
104
105
  * are considered to be the most up-to-date.
105
106
  *
106
- * If the client is not connected, this method will try to
107
- * establish a connection and request the value for `query`. If
108
- * the client is not able to retrieve the query result, it reports
109
- * an error.
107
+ * If the client is not connected, this method will wait until the
108
+ * repo has established a connection and then request the value for `query`.
109
+ * If the client is not able to retrieve the query result for another reason,
110
+ * it reports an error.
110
111
  *
111
112
  * @param query - The query to surface a value for.
112
113
  */
113
- export declare function repoGetValue(repo: Repo, query: QueryContext): Promise<Node>;
114
+ export declare function repoGetValue(repo: Repo, query: QueryContext, eventRegistration: ValueEventRegistration): Promise<Node>;
114
115
  export declare function repoSetWithPriority(repo: Repo, path: Path, newVal: unknown, newPriority: number | string | null, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
115
116
  export declare function repoUpdate(repo: Repo, path: Path, childrenToMerge: {
116
117
  [k: string]: unknown;
@@ -21,7 +21,7 @@ import { ImmutableTree } from './util/ImmutableTree';
21
21
  import { Path } from './util/Path';
22
22
  import { Event } from './view/Event';
23
23
  import { EventRegistration, QueryContext } from './view/EventRegistration';
24
- import { WriteTree, WriteTreeRef } from './WriteTree';
24
+ import { WriteTree } from './WriteTree';
25
25
  export declare function syncTreeSetReferenceConstructor(val: ReferenceConstructor): void;
26
26
  export interface ListenProvider {
27
27
  startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
@@ -121,23 +121,11 @@ export declare function syncTreeApplyTaggedListenComplete(syncTree: SyncTree, pa
121
121
  *
122
122
  * @param eventRegistration - If null, all callbacks are removed.
123
123
  * @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
124
+ * @param skipListenerDedup - When performing a `get()`, we don't add any new listeners, so no
125
+ * deduping needs to take place. This flag allows toggling of that behavior
124
126
  * @returns Cancel events, if cancelError was provided.
125
127
  */
126
- export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error): Event[];
127
- /**
128
- * This function was added to support non-listener queries,
129
- * specifically for use in repoGetValue. It sets up all the same
130
- * local cache data-structures (SyncPoint + View) that are
131
- * needed for listeners without installing an event registration.
132
- * If `query` is not `loadsAllData`, it will also provision a tag for
133
- * the query so that query results can be merged into the sync
134
- * tree using existing logic for tagged listener queries.
135
- *
136
- * @param syncTree - Synctree to add the query to.
137
- * @param query - Query to register
138
- * @returns tag as a string if query is not a default query, null if query is not.
139
- */
140
- export declare function syncTreeRegisterQuery(syncTree: SyncTree, query: QueryContext): number;
128
+ export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error, skipListenerDedup?: boolean): Event[];
141
129
  /**
142
130
  * Apply new server data for the specified tagged query.
143
131
  *
@@ -152,25 +140,12 @@ export declare function syncTreeApplyTaggedQueryOverwrite(syncTree: SyncTree, pa
152
140
  export declare function syncTreeApplyTaggedQueryMerge(syncTree: SyncTree, path: Path, changedChildren: {
153
141
  [k: string]: Node;
154
142
  }, tag: number): Event[];
155
- /**
156
- * Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
157
- * Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
158
- * without actually listening on a query.
159
- */
160
- export declare function syncTreeRegisterSyncPoint(query: QueryContext, syncTree: SyncTree): {
161
- syncPoint: SyncPoint;
162
- writesCache: WriteTreeRef;
163
- serverCache: Node;
164
- serverCacheComplete: any;
165
- foundAncestorDefaultView: boolean;
166
- viewAlreadyExists: boolean;
167
- };
168
143
  /**
169
144
  * Add an event callback for the specified query.
170
145
  *
171
146
  * @returns Events to raise.
172
147
  */
173
- export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration): Event[];
148
+ export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration, skipSetupListener?: boolean): Event[];
174
149
  /**
175
150
  * Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
176
151
  * listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
@@ -184,3 +159,7 @@ export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query:
184
159
  */
185
160
  export declare function syncTreeCalcCompleteEventCache(syncTree: SyncTree, path: Path, writeIdsToExclude?: number[]): Node;
186
161
  export declare function syncTreeGetServerValue(syncTree: SyncTree, query: QueryContext): Node | null;
162
+ /**
163
+ * Return the tag associated with the given query.
164
+ */
165
+ export declare function syncTreeTagForQuery(syncTree: SyncTree, query: QueryContext): number | null;
@@ -14,15 +14,21 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Database } from '../../src';
17
+ import { Database, DatabaseReference } from '../../src';
18
+ import { Path } from '../../src/core/util/Path';
19
+ import { EventAccumulator } from './EventAccumulator';
18
20
  export declare const TEST_PROJECT: any;
21
+ export declare function getFreshRepo(path: Path): DatabaseReference;
19
22
  export declare const DATABASE_ADDRESS: any;
20
23
  export declare const DATABASE_URL: any;
21
24
  export declare function testRepoInfo(url: any): import("../../src/core/RepoInfo").RepoInfo;
22
25
  export declare function repoInfoForConnectionTest(): import("../../src/core/RepoInfo").RepoInfo;
23
26
  export declare function shuffle(arr: any, randFn?: () => number): void;
24
27
  export declare function waitFor(waitTimeInMS: number): Promise<unknown>;
25
- export declare function getUniqueRef(db: Database): {
26
- ref: import("../../src").DatabaseReference;
27
- path: string;
28
+ export declare function getUniqueRef(db: Database): DatabaseReference;
29
+ export declare function getRWRefs(db: Database): {
30
+ readerRef: DatabaseReference;
31
+ writerRef: DatabaseReference;
28
32
  };
33
+ export declare function writeAndValidate(writerRef: DatabaseReference, readerRef: DatabaseReference, toWrite: unknown, ec: EventAccumulator): Promise<void>;
34
+ export declare function waitUntil(cb: () => boolean, maxRetries?: number): Promise<unknown>;
package/dist/private.d.ts CHANGED
@@ -337,7 +337,9 @@ export declare class DataSnapshot {
337
337
  * @returns true if enumeration was canceled due to your callback returning
338
338
  * true.
339
339
  */
340
- forEach(action: (child: DataSnapshot) => boolean | void): boolean;
340
+ forEach(action: (child: DataSnapshot & {
341
+ key: string;
342
+ }) => boolean | void): boolean;
341
343
  /**
342
344
  * Returns true if the specified child path has (non-null) data.
343
345
  *
@@ -1151,12 +1153,11 @@ declare interface NodeFilter_2 {
1151
1153
  }
1152
1154
 
1153
1155
  /**
1154
- * Detaches a callback previously attached with `on()`.
1156
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
1157
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
1158
+ * the respective `on*` callbacks.
1155
1159
  *
1156
- * Detach a callback previously attached with `on()`. Note that if `on()` was
1157
- * called multiple times with the same eventType and callback, the callback
1158
- * will be called multiple times for each event, and `off()` must be called
1159
- * multiple times to remove the callback. Calling `off()` on a parent listener
1160
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
1160
1161
  * will not automatically remove listeners registered on child nodes, `off()`
1161
1162
  * must also be called on any child listeners to remove the callback.
1162
1163
  *
package/dist/public.d.ts CHANGED
@@ -159,7 +159,9 @@ export declare class DataSnapshot {
159
159
  * @returns true if enumeration was canceled due to your callback returning
160
160
  * true.
161
161
  */
162
- forEach(action: (child: DataSnapshot) => boolean | void): boolean;
162
+ forEach(action: (child: DataSnapshot & {
163
+ key: string;
164
+ }) => boolean | void): boolean;
163
165
  /**
164
166
  * Returns true if the specified child path has (non-null) data.
165
167
  *
@@ -403,12 +405,11 @@ export declare interface ListenOptions {
403
405
  readonly onlyOnce?: boolean;
404
406
  }
405
407
  /**
406
- * Detaches a callback previously attached with `on()`.
408
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
409
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
410
+ * the respective `on*` callbacks.
407
411
  *
408
- * Detach a callback previously attached with `on()`. Note that if `on()` was
409
- * called multiple times with the same eventType and callback, the callback
410
- * will be called multiple times for each event, and `off()` must be called
411
- * multiple times to remove the callback. Calling `off()` on a parent listener
412
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
412
413
  * will not automatically remove listeners registered on child nodes, `off()`
413
414
  * must also be called on any child listeners to remove the callback.
414
415
  *
@@ -156,7 +156,9 @@ export declare class DataSnapshot {
156
156
  * @returns true if enumeration was canceled due to your callback returning
157
157
  * true.
158
158
  */
159
- forEach(action: (child: DataSnapshot) => boolean | void): boolean;
159
+ forEach(action: (child: DataSnapshot & {
160
+ key: string;
161
+ }) => boolean | void): boolean;
160
162
  /**
161
163
  * Returns true if the specified child path has (non-null) data.
162
164
  *
@@ -842,12 +844,11 @@ export declare function onChildRemoved(query: Query, callback: (snapshot: DataSn
842
844
  export declare function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
843
845
  export { EventType };
844
846
  /**
845
- * Detaches a callback previously attached with `on()`.
847
+ * Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
848
+ * Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
849
+ * the respective `on*` callbacks.
846
850
  *
847
- * Detach a callback previously attached with `on()`. Note that if `on()` was
848
- * called multiple times with the same eventType and callback, the callback
849
- * will be called multiple times for each event, and `off()` must be called
850
- * multiple times to remove the callback. Calling `off()` on a parent listener
851
+ * Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
851
852
  * will not automatically remove listeners registered on child nodes, `off()`
852
853
  * must also be called on any child listeners to remove the callback.
853
854
  *
@@ -14,6 +14,7 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
+ import { ValueEventRegistration } from '../api/Reference_impl';
17
18
  import { AppCheckTokenProvider } from './AppCheckTokenProvider';
18
19
  import { AuthTokenProvider } from './AuthTokenProvider';
19
20
  import { PersistentConnection } from './PersistentConnection';
@@ -103,14 +104,14 @@ export declare function repoInterceptServerData(repo: Repo, callback: ((a: strin
103
104
  * belonging to active listeners. If they are found, such values
104
105
  * are considered to be the most up-to-date.
105
106
  *
106
- * If the client is not connected, this method will try to
107
- * establish a connection and request the value for `query`. If
108
- * the client is not able to retrieve the query result, it reports
109
- * an error.
107
+ * If the client is not connected, this method will wait until the
108
+ * repo has established a connection and then request the value for `query`.
109
+ * If the client is not able to retrieve the query result for another reason,
110
+ * it reports an error.
110
111
  *
111
112
  * @param query - The query to surface a value for.
112
113
  */
113
- export declare function repoGetValue(repo: Repo, query: QueryContext): Promise<Node>;
114
+ export declare function repoGetValue(repo: Repo, query: QueryContext, eventRegistration: ValueEventRegistration): Promise<Node>;
114
115
  export declare function repoSetWithPriority(repo: Repo, path: Path, newVal: unknown, newPriority: number | string | null, onComplete: ((status: Error | null, errorReason?: string) => void) | null): void;
115
116
  export declare function repoUpdate(repo: Repo, path: Path, childrenToMerge: {
116
117
  [k: string]: unknown;
@@ -21,7 +21,7 @@ import { ImmutableTree } from './util/ImmutableTree';
21
21
  import { Path } from './util/Path';
22
22
  import { Event } from './view/Event';
23
23
  import { EventRegistration, QueryContext } from './view/EventRegistration';
24
- import { WriteTree, WriteTreeRef } from './WriteTree';
24
+ import { WriteTree } from './WriteTree';
25
25
  export declare function syncTreeSetReferenceConstructor(val: ReferenceConstructor): void;
26
26
  export interface ListenProvider {
27
27
  startListening(query: QueryContext, tag: number | null, hashFn: () => string, onComplete: (a: string, b?: unknown) => Event[]): Event[];
@@ -121,23 +121,11 @@ export declare function syncTreeApplyTaggedListenComplete(syncTree: SyncTree, pa
121
121
  *
122
122
  * @param eventRegistration - If null, all callbacks are removed.
123
123
  * @param cancelError - If a cancelError is provided, appropriate cancel events will be returned.
124
+ * @param skipListenerDedup - When performing a `get()`, we don't add any new listeners, so no
125
+ * deduping needs to take place. This flag allows toggling of that behavior
124
126
  * @returns Cancel events, if cancelError was provided.
125
127
  */
126
- export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error): Event[];
127
- /**
128
- * This function was added to support non-listener queries,
129
- * specifically for use in repoGetValue. It sets up all the same
130
- * local cache data-structures (SyncPoint + View) that are
131
- * needed for listeners without installing an event registration.
132
- * If `query` is not `loadsAllData`, it will also provision a tag for
133
- * the query so that query results can be merged into the sync
134
- * tree using existing logic for tagged listener queries.
135
- *
136
- * @param syncTree - Synctree to add the query to.
137
- * @param query - Query to register
138
- * @returns tag as a string if query is not a default query, null if query is not.
139
- */
140
- export declare function syncTreeRegisterQuery(syncTree: SyncTree, query: QueryContext): number;
128
+ export declare function syncTreeRemoveEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration | null, cancelError?: Error, skipListenerDedup?: boolean): Event[];
141
129
  /**
142
130
  * Apply new server data for the specified tagged query.
143
131
  *
@@ -152,25 +140,12 @@ export declare function syncTreeApplyTaggedQueryOverwrite(syncTree: SyncTree, pa
152
140
  export declare function syncTreeApplyTaggedQueryMerge(syncTree: SyncTree, path: Path, changedChildren: {
153
141
  [k: string]: Node;
154
142
  }, tag: number): Event[];
155
- /**
156
- * Creates a new syncpoint for a query and creates a tag if the view doesn't exist.
157
- * Extracted from addEventRegistration to allow `repoGetValue` to properly set up the SyncTree
158
- * without actually listening on a query.
159
- */
160
- export declare function syncTreeRegisterSyncPoint(query: QueryContext, syncTree: SyncTree): {
161
- syncPoint: SyncPoint;
162
- writesCache: WriteTreeRef;
163
- serverCache: Node;
164
- serverCacheComplete: any;
165
- foundAncestorDefaultView: boolean;
166
- viewAlreadyExists: boolean;
167
- };
168
143
  /**
169
144
  * Add an event callback for the specified query.
170
145
  *
171
146
  * @returns Events to raise.
172
147
  */
173
- export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration): Event[];
148
+ export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query: QueryContext, eventRegistration: EventRegistration, skipSetupListener?: boolean): Event[];
174
149
  /**
175
150
  * Returns a complete cache, if we have one, of the data at a particular path. If the location does not have a
176
151
  * listener above it, we will get a false "null". This shouldn't be a problem because transactions will always
@@ -184,3 +159,7 @@ export declare function syncTreeAddEventRegistration(syncTree: SyncTree, query:
184
159
  */
185
160
  export declare function syncTreeCalcCompleteEventCache(syncTree: SyncTree, path: Path, writeIdsToExclude?: number[]): Node;
186
161
  export declare function syncTreeGetServerValue(syncTree: SyncTree, query: QueryContext): Node | null;
162
+ /**
163
+ * Return the tag associated with the given query.
164
+ */
165
+ export declare function syncTreeTagForQuery(syncTree: SyncTree, query: QueryContext): number | null;
@@ -14,15 +14,21 @@
14
14
  * See the License for the specific language governing permissions and
15
15
  * limitations under the License.
16
16
  */
17
- import { Database } from '../../src';
17
+ import { Database, DatabaseReference } from '../../src';
18
+ import { Path } from '../../src/core/util/Path';
19
+ import { EventAccumulator } from './EventAccumulator';
18
20
  export declare const TEST_PROJECT: any;
21
+ export declare function getFreshRepo(path: Path): DatabaseReference;
19
22
  export declare const DATABASE_ADDRESS: any;
20
23
  export declare const DATABASE_URL: any;
21
24
  export declare function testRepoInfo(url: any): import("../../src/core/RepoInfo").RepoInfo;
22
25
  export declare function repoInfoForConnectionTest(): import("../../src/core/RepoInfo").RepoInfo;
23
26
  export declare function shuffle(arr: any, randFn?: () => number): void;
24
27
  export declare function waitFor(waitTimeInMS: number): Promise<unknown>;
25
- export declare function getUniqueRef(db: Database): {
26
- ref: import("../../src").DatabaseReference;
27
- path: string;
28
+ export declare function getUniqueRef(db: Database): DatabaseReference;
29
+ export declare function getRWRefs(db: Database): {
30
+ readerRef: DatabaseReference;
31
+ writerRef: DatabaseReference;
28
32
  };
33
+ export declare function writeAndValidate(writerRef: DatabaseReference, readerRef: DatabaseReference, toWrite: unknown, ec: EventAccumulator): Promise<void>;
34
+ export declare function waitUntil(cb: () => boolean, maxRetries?: number): Promise<unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase/database",
3
- "version": "0.13.3",
3
+ "version": "0.13.4-canary.a5d9e1083",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",
@@ -45,15 +45,15 @@
45
45
  "license": "Apache-2.0",
46
46
  "peerDependencies": {},
47
47
  "dependencies": {
48
- "@firebase/logger": "0.3.3",
49
- "@firebase/util": "1.6.3",
50
- "@firebase/component": "0.5.17",
51
- "@firebase/auth-interop-types": "0.1.6",
48
+ "@firebase/logger": "0.3.3-canary.a5d9e1083",
49
+ "@firebase/util": "1.6.3-canary.a5d9e1083",
50
+ "@firebase/component": "0.5.17-canary.a5d9e1083",
51
+ "@firebase/auth-interop-types": "0.1.6-canary.a5d9e1083",
52
52
  "faye-websocket": "0.11.4",
53
53
  "tslib": "^2.1.0"
54
54
  },
55
55
  "devDependencies": {
56
- "@firebase/app": "0.7.28",
56
+ "@firebase/app": "0.7.30-canary.a5d9e1083",
57
57
  "rollup": "2.72.1",
58
58
  "rollup-plugin-typescript2": "0.31.2",
59
59
  "typescript": "4.2.2"