Skip to content

Commit 8896370

Browse files
committed
update database types
1 parent 1e6acf1 commit 8896370

File tree

8 files changed

+22
-13
lines changed

8 files changed

+22
-13
lines changed

packages/database-types/index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export interface Reference extends Query {
9999
key: string | null;
100100
onDisconnect(): OnDisconnect;
101101
parent: Reference | null;
102-
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
102+
push(value?: any, onComplete?: (a: Error | null) => any): Reference;
103103
remove(onComplete?: (a: Error | null) => any): Promise<any>;
104104
root: Reference;
105105
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
@@ -132,3 +132,9 @@ export function enableLogging(
132132
logger?: boolean | ((a: string) => any),
133133
persistent?: boolean
134134
): any;
135+
136+
declare module '@firebase/component' {
137+
interface NameServiceMapping {
138+
'database': FirebaseDatabase;
139+
}
140+
}

packages/database/index.node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
Provider,
3737
ComponentContainer
3838
} from '@firebase/component';
39-
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
39+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
4040

4141
setWebSocketImpl(Client);
4242

@@ -64,7 +64,7 @@ export function initStandalone(app: FirebaseApp, url: string, version: string) {
6464
* ComponentContainer('database-admin') is just a placeholder that doesn't perform
6565
* any actual function.
6666
*/
67-
const authProvider = new Provider<FirebaseAuthInternal>(
67+
const authProvider = new Provider<FirebaseAuthInternalName>(
6868
'auth-internal',
6969
new ComponentContainer('database-admin')
7070
);

packages/database/src/api/Database.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import { validateUrl } from '../core/util/validation';
2626
import { FirebaseApp } from '@firebase/app-types';
2727
import { FirebaseService } from '@firebase/app-types/private';
2828
import { RepoInfo } from '../core/RepoInfo';
29+
import { FirebaseDatabase } from '@firebase/database-types';
2930

3031
/**
3132
* Class representing a firebase database.
3233
* @implements {FirebaseService}
3334
*/
34-
export class Database implements FirebaseService {
35+
export class Database implements FirebaseService, FirebaseDatabase {
3536
INTERNAL: DatabaseInternals;
3637
private root_: Reference;
3738

packages/database/src/api/Reference.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ import { Deferred } from '@firebase/util';
3737
import { SyncPoint } from '../core/SyncPoint';
3838
import { Database } from './Database';
3939
import { DataSnapshot } from './DataSnapshot';
40+
import * as types from '@firebase/database-types';
4041

4142
export interface ReferenceConstructor {
4243
new (repo: Repo, path: Path): Reference;
4344
}
4445

45-
export class Reference extends Query {
46+
export class Reference extends Query implements types.Reference {
4647
public then: (a?: any) => Promise<any>;
4748
public catch: (a?: Error) => Promise<any>;
4849

packages/database/src/core/AuthTokenProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import { FirebaseAuthTokenData } from '@firebase/app-types/private';
19-
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
19+
import { FirebaseAuthInternal, FirebaseAuthInternalName } from '@firebase/auth-interop-types';
2020
import { Provider } from '@firebase/component';
2121
import { log, warn } from './util/util';
2222
import { FirebaseApp } from '@firebase/app-types';
@@ -28,7 +28,7 @@ export class AuthTokenProvider {
2828
private auth_: FirebaseAuthInternal | null = null;
2929
constructor(
3030
private app_: FirebaseApp,
31-
private authProvider_: Provider<FirebaseAuthInternal>
31+
private authProvider_: Provider<FirebaseAuthInternalName>
3232
) {
3333
this.auth_ = authProvider_.getImmediate({ optional: true });
3434
if (!this.auth_) {

packages/database/src/core/Repo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { EventRegistration } from './view/EventRegistration';
4444
import { StatsCollection } from './stats/StatsCollection';
4545
import { Event } from './view/Event';
4646
import { Node } from './snap/Node';
47-
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
47+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
4848
import { Provider } from '@firebase/component';
4949

5050
const INTERRUPT_REASON = 'repo_interrupt';
@@ -82,7 +82,7 @@ export class Repo {
8282
public repoInfo_: RepoInfo,
8383
forceRestClient: boolean,
8484
public app: FirebaseApp,
85-
authProvider: Provider<FirebaseAuthInternal>
85+
authProvider: Provider<FirebaseAuthInternalName>
8686
) {
8787
const authTokenProvider = new AuthTokenProvider(app, authProvider);
8888

packages/database/src/core/RepoManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { validateUrl } from './util/validation';
2424
import './Repo_transaction';
2525
import { Database } from '../api/Database';
2626
import { RepoInfo } from './RepoInfo';
27-
import { FirebaseAuthInternal } from '@firebase/auth-interop-types';
27+
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
2828
import { Provider } from '@firebase/component';
2929

3030
/** @const {string} */
@@ -93,7 +93,7 @@ export class RepoManager {
9393
*/
9494
databaseFromApp(
9595
app: FirebaseApp,
96-
authProvider: Provider<FirebaseAuthInternal>,
96+
authProvider: Provider<FirebaseAuthInternalName>,
9797
url?: string
9898
): Database {
9999
let dbUrl: string | undefined = url || app.options[DATABASE_URL_OPTION];
@@ -159,7 +159,7 @@ export class RepoManager {
159159
createRepo(
160160
repoInfo: RepoInfo,
161161
app: FirebaseApp,
162-
authProvider: Provider<FirebaseAuthInternal>
162+
authProvider: Provider<FirebaseAuthInternalName>
163163
): Repo {
164164
let appRepos = safeGet(this.repos_, app.name);
165165

packages/database/test/helpers/util.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ let numDatabases = 0;
5959
() => ({
6060
getToken: () => Promise.resolve(null),
6161
addAuthTokenListener: () => {},
62-
removeAuthTokenListener: () => {}
62+
removeAuthTokenListener: () => {},
63+
getUid: () => null
6364
}),
6465
ComponentType.PRIVATE
6566
)

0 commit comments

Comments
 (0)