Skip to content

Commit 739f13d

Browse files
committed
fix mangling of the property names of the argument to 'onExistenceFilterMismatch()' callbacks
1 parent 15d47bc commit 739f13d

File tree

3 files changed

+41
-37
lines changed

3 files changed

+41
-37
lines changed

packages/firestore/src/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,4 +196,7 @@ export type { ByteString as _ByteString } from './util/byte_string';
196196
export { logWarn as _logWarn } from './util/log';
197197
export { EmptyAuthCredentialsProvider as _EmptyAuthCredentialsProvider } from './api/credentials';
198198
export { EmptyAppCheckTokenProvider as _EmptyAppCheckTokenProvider } from './api/credentials';
199-
export { TestingHooks as _TestingHooks } from './util/testing_hooks';
199+
export {
200+
TestingHooks as _TestingHooks,
201+
ExistenceFilterMismatchInfo as _TestingUtilsExistenceFilterMismatchInfo
202+
} from './util/testing_hooks';

packages/firestore/src/util/testing_hooks.ts

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
export class TestingHooks {
3535
private readonly onExistenceFilterMismatchCallbacks = new Map<
3636
Symbol,
37-
(arg: unknown) => void
37+
(info: ExistenceFilterMismatchInfo) => void
3838
>();
3939

4040
private constructor() {}
@@ -65,31 +65,50 @@ export class TestingHooks {
6565
* The relative order in which callbacks are notified is unspecified; do not
6666
* rely on any particular ordering.
6767
*
68-
* @param callback the callback to invoke upon existence filter mismatch. The
69-
* type of the argument to this callback is intentionally declared as
70-
* `unknown`, rather than something more specific, to discourage its use
71-
* unless you really, really know what you are doing. If you know what you are
72-
* doing then you know the type and how to interpret it.
68+
* @param callback the callback to invoke upon existence filter mismatch.
7369
*
7470
* @return a function that, when called, unregisters the given callback; only
7571
* the first invocation of the returned function does anything; all subsequent
7672
* invocations do nothing.
7773
*/
78-
onExistenceFilterMismatch(callback: (arg: unknown) => void): () => void {
74+
onExistenceFilterMismatch(
75+
callback: (info: ExistenceFilterMismatchInfo) => void
76+
): () => void {
7977
const key = Symbol();
8078
this.onExistenceFilterMismatchCallbacks.set(key, callback);
8179
return () => this.onExistenceFilterMismatchCallbacks.delete(key);
8280
}
8381

8482
/**
8583
* Invokes all currently-registered `onExistenceFilterMismatch` callbacks.
86-
* @param arg the argument to specify to the callbacks; see the documentation
87-
* for `onExistenceFilterMismatch()` for details.
84+
* @param info the argument to specify to the callbacks.
8885
*/
89-
notifyOnExistenceFilterMismatch(arg: unknown): void {
90-
this.onExistenceFilterMismatchCallbacks.forEach(callback => callback(arg));
86+
notifyOnExistenceFilterMismatch(info: ExistenceFilterMismatchInfo): void {
87+
this.onExistenceFilterMismatchCallbacks.forEach(callback => callback(info));
9188
}
9289
}
9390

91+
/**
92+
* The shape of the object specified to
93+
* `TestingUtils.onExistenceFilterMismatch()` callbacks.
94+
*/
95+
export interface ExistenceFilterMismatchInfo {
96+
actualCount: number;
97+
bloomFilterApplied: boolean;
98+
change: {
99+
targetId: number;
100+
existenceFilter: {
101+
count: number;
102+
unchangedNames?: {
103+
bits?: {
104+
bitmap?: string | Uint8Array;
105+
padding?: number;
106+
};
107+
hashCount?: number;
108+
};
109+
};
110+
};
111+
}
112+
94113
/** The global singleton instance of `TestingHooks`. */
95114
let gTestingHooksSingletonInstance: TestingHooks | null = null;

packages/firestore/test/integration/util/testing_hooks_util.ts

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { _TestingHooks as TestingHooks, _logWarn } from './firebase_export';
18+
import {
19+
_TestingHooks as TestingHooks,
20+
_TestingUtilsExistenceFilterMismatchInfo as RawExistenceFilterMismatchInfo,
21+
_logWarn
22+
} from './firebase_export';
1923

2024
/**
2125
* Captures all existence filter mismatches in the Watch 'Listen' stream that
@@ -49,28 +53,6 @@ export async function captureExistenceFilterMismatches(
4953
return results;
5054
}
5155

52-
/**
53-
* The shape of the object specified to
54-
* `TestingUtils.onExistenceFilterMismatch()` callbacks.
55-
*/
56-
interface RawExistenceFilterMismatchInfo {
57-
actualCount: number;
58-
bloomFilterApplied: boolean;
59-
change: {
60-
targetId: number;
61-
existenceFilter: {
62-
count: number;
63-
unchangedNames?: {
64-
bits?: {
65-
bitmap?: string | Uint8Array;
66-
padding?: number;
67-
};
68-
hashCount?: number;
69-
};
70-
};
71-
};
72-
}
73-
7456
/**
7557
* Information about an existence filter mismatch, capturing during an
7658
* invocation of `captureExistenceFilterMismatches()`.
@@ -88,7 +70,7 @@ export interface ExistenceFilterMismatchInfo {
8870
* Information about a bloom filter in an existence filter.
8971
*/
9072
export interface ExistenceFilterBloomFilter {
91-
/** Whether the bloom filter was able to be used to avert a full requery. */
73+
/** Whether the bloom filter was used to avert a full requery. */
9274
applied: boolean;
9375
/** The number of hash functions used in the bloom filter. */
9476
hashCount: number;
@@ -118,7 +100,7 @@ function existenceFilterMismatchInfoFromRaw(
118100

119101
/**
120102
* Creates an `ExistenceFilterBloomFilter` object from the raw object given
121-
* by `TestingUtils`, returning null if the given object does not defined a
103+
* by `TestingUtils`, returning null if the given object does not define a
122104
* bloom filter.
123105
*/
124106
function bloomFilterFromRawExistenceFilterMismatchInfo(

0 commit comments

Comments
 (0)