Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
196b4a0
chore(database): add package tsconfig scaffolding
russellwheatley Apr 13, 2026
111580f
refactor(database): split modular and namespaced entrypoints
russellwheatley Apr 13, 2026
094d4d0
refactor(database): split types for modular and namespaced
russellwheatley Apr 13, 2026
207f89c
refactor(database): type namespaced module bridge
russellwheatley Apr 13, 2026
6f8e963
refactor(database): port leaf reference helpers to typescript
russellwheatley Apr 13, 2026
7ce2059
refactor(database): port DatabaseReference to typescript
russellwheatley Apr 13, 2026
e9c2bbe
refactor(database): port DatabaseQuery to typescript
russellwheatley Apr 13, 2026
f1855a6
refactor(database): wire TypeScript build output for database
russellwheatley Apr 13, 2026
079d9cd
refactor(database): align modular exports with type tests
russellwheatley Apr 13, 2026
a0ebb5e
refactor(database): align modular declarations with shared public ali…
russellwheatley Apr 13, 2026
db5f53b
refactor(database): align modular public types with firebase-js-sdk
russellwheatley Apr 13, 2026
9a13704
refactor(database): compare script using firebase database web types
russellwheatley Apr 13, 2026
a8c2fab
refactor(database): convert remaining package sources to TypeScript
russellwheatley Apr 14, 2026
118a037
refactor(database): split database entrypoints and type surfaces
russellwheatley Apr 14, 2026
8c252e3
refactor(database): type namespaced module and native bridge
russellwheatley Apr 14, 2026
461786b
refactor(database): align modular API with firebase-js-sdk
russellwheatley Apr 17, 2026
6a24143
chore(database): reduce compare-types drift from firebase-js-sdk
russellwheatley Apr 17, 2026
4dd75a4
Merge branch 'main' into database-typescript
russellwheatley Apr 17, 2026
8a5242a
test: ignore expected error
russellwheatley Apr 17, 2026
77d1a6d
fix: should export real type + fix up TS error
russellwheatley Apr 17, 2026
37176de
chore: delete old index.d.ts file
russellwheatley Apr 17, 2026
912f02d
docs: update typedoc.json file
russellwheatley Apr 17, 2026
11228b4
chore: ignore types not exported to consumer
russellwheatley Apr 17, 2026
e1cc452
refactor: align DataSnapshot forEach signatures
russellwheatley Apr 17, 2026
58561de
refactor(pr): address reviewer feedback on query off return handling
russellwheatley Apr 17, 2026
408df32
chore: remove type casting
russellwheatley Apr 17, 2026
a67eb63
fix: reference thennable coming back as undefined due to proxy
russellwheatley Apr 17, 2026
352f44a
refactor: remove ServerValue from modular exports
russellwheatley Apr 17, 2026
c3a7265
fix: internal type was public
russellwheatley Apr 17, 2026
b038be6
refactor: convert DatabaseSyncTree to TS
russellwheatley Apr 17, 2026
9f15d9a
chore: revert word back to library
russellwheatley Apr 17, 2026
e5acebb
fix: databasesynctree divergence from JS implementation
russellwheatley Apr 17, 2026
2e96f33
fix: snapshot handler on web
russellwheatley Apr 17, 2026
e21b8d2
chore: remove unused script
russellwheatley Apr 17, 2026
54e7eaf
Merge branch 'main' into database-typescript
russellwheatley Apr 30, 2026
16636ac
chore: update parse error message in compare script
russellwheatley Apr 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/scripts/compare-types/packages/database/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import type { PackageConfig } from '../../src/types';

const config: PackageConfig = {
nameMapping: {},
missingInRN: [],
extraInRN: [
{
name: 'setPersistenceEnabled',
reason:
'RN Firebase-specific helper for configuring native database ' +
'persistence. The firebase-js-sdk modular API does not expose this ' +
'standalone function.',
},
{
name: 'setLoggingEnabled',
reason:
'RN Firebase-specific helper for toggling native database logging. ' +
'The firebase-js-sdk modular API exposes `enableLogging()` instead.',
},
{
name: 'setPersistenceCacheSizeBytes',
reason:
'RN Firebase-specific helper for configuring the native persistence ' +
'cache size. No equivalent standalone modular helper exists in the ' +
'firebase-js-sdk.',
},
{
name: 'getServerTime',
reason:
'RN Firebase-specific helper that reads native server time offset and ' +
'returns the current server timestamp. No equivalent modular helper ' +
'exists in the firebase-js-sdk.',
},
{
name: 'keepSynced',
reason:
'RN Firebase-specific modular helper mirroring the native/database ' +
'offline sync API. The firebase-js-sdk modular package does not export ' +
'a standalone `keepSynced()` function.',
},
],
differentShape: [
{
name: 'EmulatorMockTokenOptions',
reason:
'RN Firebase reuses the local `FirebaseIdToken` alias in ' +
'`Partial<FirebaseIdToken>`, while the snapshot inlines the token ' +
'shape so compare-types does not treat the helper alias as an extra export. ' +
'The two types are structurally equivalent.',
},
],
};

export default config;
321 changes: 321 additions & 0 deletions .github/scripts/compare-types/packages/database/firebase-sdk.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,321 @@
/**
* Public types snapshot from the Firebase JS SDK (@firebase/database).
*
* Source: firebase-js-sdk API report for "@firebase/database"
* Modality: modular (tree-shakeable) API only
*/

import { FirebaseApp } from '@firebase/app';

export declare type EmulatorMockTokenOptions = ({ user_id: string } | { sub: string }) &
Partial<{
iss: string;
aud: string;
sub: string;
iat: number;
exp: number;
user_id: string;
auth_time: number;
provider_id?: 'anonymous';
email?: string;
email_verified?: boolean;
phone_number?: string;
name?: string;
picture?: string;
firebase: {
sign_in_provider:
| 'custom'
| 'email'
| 'password'
| 'phone'
| 'anonymous'
| 'google.com'
| 'facebook.com'
| 'github.com'
| 'twitter.com'
| 'microsoft.com'
| 'apple.com';
identities?: {
custom?: string[];
email?: string[];
password?: string[];
phone?: string[];
anonymous?: string[];
'google.com'?: string[];
'facebook.com'?: string[];
'github.com'?: string[];
'twitter.com'?: string[];
'microsoft.com'?: string[];
'apple.com'?: string[];
};
};
uid?: never;
[claim: string]: unknown;
}>;

export declare function child(parent: DatabaseReference, path: string): DatabaseReference;

export declare function connectDatabaseEmulator(
db: Database,
host: string,
port: number,
options?: {
mockUserToken?: EmulatorMockTokenOptions | string;
},
): void;

export declare class Database {
readonly app: FirebaseApp;
readonly type: 'database';
}

export declare interface DatabaseReference extends Query {
readonly key: string | null;
readonly parent: DatabaseReference | null;
readonly root: DatabaseReference;
}

export declare class DataSnapshot {
readonly key: string | null;
readonly priority: string | number | null;
readonly ref: DatabaseReference;
readonly size: number;
child(path: string): DataSnapshot;
exists(): boolean;
exportVal(): any;
forEach(action: (child: IteratedDataSnapshot) => boolean | void): boolean;
hasChild(path: string): boolean;
hasChildren(): boolean;
toJSON(): object | null;
val(): any;
}

export declare function enableLogging(enabled: boolean, persistent?: boolean): any;
export declare function enableLogging(logger: (message: string) => unknown): any;

export declare function endAt(
value: number | string | boolean | null,
key?: string,
): QueryConstraint;

export declare function endBefore(
value: number | string | boolean | null,
key?: string,
): QueryConstraint;

export declare function equalTo(
value: number | string | boolean | null,
key?: string,
): QueryConstraint;

export declare type EventType =
| 'value'
| 'child_added'
| 'child_changed'
| 'child_moved'
| 'child_removed';

export declare function forceLongPolling(): void;
export declare function forceWebSockets(): void;

export declare function get(query: Query): Promise<DataSnapshot>;
export declare function getDatabase(app?: FirebaseApp, url?: string): Database;
export declare function goOffline(db: Database): void;
export declare function goOnline(db: Database): void;
export declare function increment(delta: number): object;

export declare interface IteratedDataSnapshot extends DataSnapshot {
key: string;
}

export declare function limitToFirst(limit: number): QueryConstraint;
export declare function limitToLast(limit: number): QueryConstraint;

export declare interface ListenOptions {
readonly onlyOnce?: boolean;
}

export declare function off(
query: Query,
eventType?: EventType,
callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
): void;

export declare function onChildAdded(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown,
cancelCallback?: (error: Error) => unknown,
): Unsubscribe;
export declare function onChildAdded(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
options: ListenOptions,
): Unsubscribe;
export declare function onChildAdded(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
cancelCallback: (error: Error) => unknown,
options: ListenOptions,
): Unsubscribe;

export declare function onChildChanged(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
cancelCallback?: (error: Error) => unknown,
): Unsubscribe;
export declare function onChildChanged(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
options: ListenOptions,
): Unsubscribe;
export declare function onChildChanged(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
cancelCallback: (error: Error) => unknown,
options: ListenOptions,
): Unsubscribe;

export declare function onChildMoved(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
cancelCallback?: (error: Error) => unknown,
): Unsubscribe;
export declare function onChildMoved(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
options: ListenOptions,
): Unsubscribe;
export declare function onChildMoved(
query: Query,
callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown,
cancelCallback: (error: Error) => unknown,
options: ListenOptions,
): Unsubscribe;

export declare function onChildRemoved(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
cancelCallback?: (error: Error) => unknown,
): Unsubscribe;
export declare function onChildRemoved(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
options: ListenOptions,
): Unsubscribe;
export declare function onChildRemoved(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
cancelCallback: (error: Error) => unknown,
options: ListenOptions,
): Unsubscribe;

export declare class OnDisconnect {
cancel(): Promise<void>;
remove(): Promise<void>;
set(value: unknown): Promise<void>;
setWithPriority(value: unknown, priority: string | number | null): Promise<void>;
update(values: object): Promise<void>;
}

export declare function onDisconnect(ref: DatabaseReference): OnDisconnect;

export declare function onValue(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
cancelCallback?: (error: Error) => unknown,
): Unsubscribe;
export declare function onValue(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
options: ListenOptions,
): Unsubscribe;
export declare function onValue(
query: Query,
callback: (snapshot: DataSnapshot) => unknown,
cancelCallback: (error: Error) => unknown,
options: ListenOptions,
): Unsubscribe;

export declare function orderByChild(path: string): QueryConstraint;
export declare function orderByKey(): QueryConstraint;
export declare function orderByPriority(): QueryConstraint;
export declare function orderByValue(): QueryConstraint;

export declare function push(parent: DatabaseReference, value?: unknown): ThenableReference;

export declare interface Query {
isEqual(other: Query | null): boolean;
readonly ref: DatabaseReference;
toJSON(): string;
toString(): string;
}

export declare function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;

export declare abstract class QueryConstraint {
abstract readonly type: QueryConstraintType;
}

export declare type QueryConstraintType =
| 'endAt'
| 'endBefore'
| 'startAt'
| 'startAfter'
| 'limitToFirst'
| 'limitToLast'
| 'orderByChild'
| 'orderByKey'
| 'orderByPriority'
| 'orderByValue'
| 'equalTo';

export declare function ref(db: Database, path?: string): DatabaseReference;
export declare function refFromURL(db: Database, url: string): DatabaseReference;
export declare function remove(ref: DatabaseReference): Promise<void>;

export declare function runTransaction(
ref: DatabaseReference,
transactionUpdate: (currentData: any) => unknown,
options?: TransactionOptions,
): Promise<TransactionResult>;

export declare function serverTimestamp(): object;
export declare function set(ref: DatabaseReference, value: unknown): Promise<void>;
export declare function setPriority(
ref: DatabaseReference,
priority: string | number | null,
): Promise<void>;
export declare function setWithPriority(
ref: DatabaseReference,
value: unknown,
priority: string | number | null,
): Promise<void>;

export declare function startAfter(
value: number | string | boolean | null,
key?: string,
): QueryConstraint;
export declare function startAt(
value?: number | string | boolean | null,
key?: string,
): QueryConstraint;

export declare interface ThenableReference
extends DatabaseReference, Pick<Promise<DatabaseReference>, 'then' | 'catch'> {
key: string;
parent: DatabaseReference;
}

export declare interface TransactionOptions {
readonly applyLocally?: boolean;
}

export declare class TransactionResult {
readonly committed: boolean;
readonly snapshot: DataSnapshot;
toJSON(): object;
}

export declare type Unsubscribe = () => void;

export declare function update(ref: DatabaseReference, values: object): Promise<void>;
2 changes: 1 addition & 1 deletion .github/scripts/compare-types/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export function parseModularFiles(
if (!sf) {
throw new Error(
`Could not load source file: ${filePath}\n` +
`Make sure the package has been built (yarn build:all:build).`,
`Make sure the package has been built (run 'yarn' in root of repository).`,
);
}
collectExportsFromSourceFile(sf, result);
Expand Down
Loading
Loading