Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database exp #4720

Merged
merged 19 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/lets-go-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"firebase": minor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it minor?

"@firebase/util": major
"@firebase/database": patch
---

Internal changes to Database and Validation APIs.
234 changes: 234 additions & 0 deletions common/api-review/database-exp.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
## API Report File for "@firebase/database-exp"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

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

// @public (undocumented)
export class DataSnapshot {
child(path: string): DataSnapshot;
exists(): boolean;
exportVal(): any;
forEach(action: (child: DataSnapshot) => boolean | void): boolean;
hasChild(path: string): boolean;
hasChildren(): boolean;
get key(): string | null;
get priority(): string | number | null;
readonly ref: Reference;
get size(): number;
toJSON(): object | null;
val(): any;
}

// @public
export function enableLogging(enabled: boolean, persistent?: boolean): any;

// @public
export function enableLogging(logger?: (message: string) => unknown, persistent?: boolean): any;

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

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

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

// @public
export type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';

// @public
export class FirebaseDatabase {
readonly app: FirebaseApp;
readonly 'type' = "database";
}

// @public
export function get(query: Query): Promise<DataSnapshot>;

// @public
export function getDatabase(app: FirebaseApp, url?: string): FirebaseDatabase;

// @public
export function goOffline(db: FirebaseDatabase): void;

// @public
export function goOnline(db: FirebaseDatabase): void;

// @public
export function increment(delta: number): object;

// @public
export function limitToFirst(limit: number): QueryConstraint;

// @public
export function limitToLast(limit: number): QueryConstraint;

// @public
export interface ListenOptions {
readonly onlyOnce?: boolean;
}

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

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

// @public
export function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;

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

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

// @public
export function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;

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

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

// @public
export function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;

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

// @public
export function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;

// @public
export function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;

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

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

// @public
export function onDisconnect(ref: Reference): OnDisconnect;

// @public
export function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;

// @public
export function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;

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

// @public
export function orderByChild(path: string): QueryConstraint;

// @public
export function orderByKey(): QueryConstraint;

// @public
export function orderByPriority(): QueryConstraint;

// @public
export function orderByValue(): QueryConstraint;

// @public
export function push(parent: Reference, value?: unknown): ThenableReference;

// @public
export interface Query {
isEqual(other: Query | null): boolean;
readonly ref: Reference;
toJSON(): string;
toString(): string;
}

// @public
export function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;

// @public
export abstract class QueryConstraint {
abstract readonly type: QueryConstraintType;
}

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

// @public
export function ref(db: FirebaseDatabase, path?: string): Reference;

// @public
export interface Reference extends Query {
readonly key: string | null;
readonly parent: Reference | null;
readonly root: Reference;
}

// @public
export function refFromURL(db: FirebaseDatabase, url: string): Reference;

// @public
export function remove(ref: Reference): Promise<void>;

// @public
export function runTransaction(ref: Reference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;

// @public
export function serverTimestamp(): object;

// @public
export function set(ref: Reference, value: unknown): Promise<void>;

// @public
export function setPriority(ref: Reference, priority: string | number | null): Promise<void>;

// @public
export function setWithPriority(ref: Reference, value: unknown, priority: string | number | null): Promise<void>;

// @public
export function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;

// @public
export function startAt(value?: number | string | boolean | null, key?: string): QueryConstraint;

// @public
export interface ThenableReference extends Reference, Pick<Promise<Reference>, 'then' | 'catch'> {
}

// @public
export interface TransactionOptions {
readonly applyLocally?: boolean;
}

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

// @public
export type Unsubscribe = () => void;

// @public
export function update(ref: Reference, values: object): Promise<void>;

// @public
export function useDatabaseEmulator(db: FirebaseDatabase, host: string, port: number): void;


// (No @packageDocumentation comment for this package)

```
6 changes: 6 additions & 0 deletions packages/database/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ module.exports = {
rules: {
'@typescript-eslint/no-explicit-any': 'off'
}
},
{
files: ['scripts/*.ts'],
rules: {
'import/no-extraneous-dependencies': 'off'
}
}
]
};
4 changes: 3 additions & 1 deletion packages/database/.idea/runConfigurations/All_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 56 additions & 2 deletions packages/database/exp/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,61 @@

import { registerDatabase } from './register';

export { getDatabase, ServerValue } from '../src/exp/Database';
export { enableLogging } from '../src/core/util/util';
export {
FirebaseDatabase,
enableLogging,
getDatabase,
goOffline,
goOnline,
useDatabaseEmulator
} from '../src/exp/Database';
export {
Query,
Reference,
ListenOptions,
Unsubscribe,
ThenableReference
} from '../src/exp/Reference';
export { OnDisconnect } from '../src/exp/OnDisconnect';
export {
DataSnapshot,
EventType,
QueryConstraint,
QueryConstraintType,
endAt,
endBefore,
equalTo,
get,
limitToFirst,
limitToLast,
off,
onChildAdded,
onChildChanged,
onChildMoved,
onChildRemoved,
onDisconnect,
onValue,
orderByChild,
orderByKey,
orderByPriority,
orderByValue,
push,
query,
ref,
refFromURL,
remove,
set,
setPriority,
setWithPriority,
startAfter,
startAt,
update
} from '../src/exp/Reference_impl';
export { increment, serverTimestamp } from '../src/exp/ServerValue';
export {
runTransaction,
TransactionOptions,
TransactionResult
} from '../src/exp/Transaction';

registerDatabase('node');
58 changes: 56 additions & 2 deletions packages/database/exp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,61 @@

import { registerDatabase } from './register';

export { getDatabase, ServerValue } from '../src/exp/Database';
export { enableLogging } from '../src/core/util/util';
export {
FirebaseDatabase,
enableLogging,
getDatabase,
goOffline,
goOnline,
useDatabaseEmulator
} from '../src/exp/Database';
export {
Query,
Reference,
ListenOptions,
Unsubscribe,
ThenableReference
} from '../src/exp/Reference';
export { OnDisconnect } from '../src/exp/OnDisconnect';
export {
DataSnapshot,
EventType,
QueryConstraint,
QueryConstraintType,
endAt,
endBefore,
equalTo,
get,
limitToFirst,
limitToLast,
off,
onChildAdded,
onChildChanged,
onChildMoved,
onChildRemoved,
onDisconnect,
onValue,
orderByChild,
orderByKey,
orderByPriority,
orderByValue,
push,
query,
ref,
refFromURL,
remove,
set,
setPriority,
setWithPriority,
startAfter,
startAt,
update
} from '../src/exp/Reference_impl';
export { increment, serverTimestamp } from '../src/exp/ServerValue';
export {
runTransaction,
TransactionOptions,
TransactionResult
} from '../src/exp/Transaction';

registerDatabase();