@firebase/database 0.13.4 → 0.13.5-20220818183912

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,9 +156,7 @@ 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 & {
160
- key: string;
161
- }) => boolean | void): boolean;
159
+ forEach(action: (child: DataSnapshot) => boolean | void): boolean;
162
160
  /**
163
161
  * Returns true if the specified child path has (non-null) data.
164
162
  *
@@ -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,9 +337,7 @@ 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 & {
341
- key: string;
342
- }) => boolean | void): boolean;
340
+ forEach(action: (child: DataSnapshot) => boolean | void): boolean;
343
341
  /**
344
342
  * Returns true if the specified child path has (non-null) data.
345
343
  *
package/dist/public.d.ts CHANGED
@@ -159,9 +159,7 @@ 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 & {
163
- key: string;
164
- }) => boolean | void): boolean;
162
+ forEach(action: (child: DataSnapshot) => boolean | void): boolean;
165
163
  /**
166
164
  * Returns true if the specified child path has (non-null) data.
167
165
  *
@@ -156,9 +156,7 @@ 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 & {
160
- key: string;
161
- }) => boolean | void): boolean;
159
+ forEach(action: (child: DataSnapshot) => boolean | void): boolean;
162
160
  /**
163
161
  * Returns true if the specified child path has (non-null) data.
164
162
  *
@@ -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.4",
3
+ "version": "0.13.5-20220818183912",
4
4
  "description": "",
5
5
  "author": "Firebase <firebase-support@google.com> (https://firebase.google.com/)",
6
6
  "main": "dist/index.node.cjs.js",