Skip to content

Fix a typings issue in database exp #4333

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

Merged
merged 2 commits into from
Jan 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
195 changes: 195 additions & 0 deletions common/api-review/database.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
## API Report File for "@firebase/database"

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

```ts

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

// @public (undocumented)
export interface Database {
// (undocumented)
app: FirebaseApp;
// (undocumented)
goOffline(): void;
// (undocumented)
goOnline(): void;
// (undocumented)
ref(path?: string | Reference): Reference;
// (undocumented)
refFromURL(url: string): Reference;
// (undocumented)
useEmulator(host: string, port: number): void;
}

// @public (undocumented)
export interface DataSnapshot {
// (undocumented)
child(path: string): DataSnapshot;
// (undocumented)
exists(): boolean;
// (undocumented)
exportVal(): any;
// (undocumented)
forEach(action: (a: DataSnapshot) => boolean | void): boolean;
// (undocumented)
getPriority(): string | number | null;
// (undocumented)
hasChild(path: string): boolean;
// (undocumented)
hasChildren(): boolean;
// (undocumented)
key: string | null;
// (undocumented)
numChildren(): number;
// (undocumented)
ref: Reference;
// (undocumented)
toJSON(): object | null;
// (undocumented)
val(): any;
}

// @public (undocumented)
export function enableLogging(
logger?: boolean | ((a: string) => any),
persistent?: boolean
): any;

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

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

// @public (undocumented)
export interface OnDisconnect {
// (undocumented)
cancel(onComplete?: (a: Error | null) => any): Promise<void>;
// (undocumented)
remove(onComplete?: (a: Error | null) => any): Promise<void>;
// (undocumented)
set(value: any, onComplete?: (a: Error | null) => any): Promise<void>;
// (undocumented)
setWithPriority(
value: any,
priority: number | string | null,
onComplete?: (a: Error | null) => any
): Promise<any>;
// (undocumented)
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
}

// @public (undocumented)
export interface Query {
// (undocumented)
endAt(value: number | string | boolean | null, key?: string): Query;
// (undocumented)
equalTo(value: number | string | boolean | null, key?: string): Query;
// (undocumented)
get(): Promise<DataSnapshot>;
// (undocumented)
isEqual(other: Query | null): boolean;
// (undocumented)
limitToFirst(limit: number): Query;
// (undocumented)
limitToLast(limit: number): Query;
// (undocumented)
off(
eventType?: EventType,
callback?: (a: DataSnapshot, b?: string | null) => any,
context?: object | null
): void;
// (undocumented)
on(
eventType: EventType,
callback: (a: DataSnapshot, b?: string | null) => any,
cancelCallbackOrContext?: ((a: Error) => any) | object | null,
context?: object | null
): (a: DataSnapshot, b?: string | null) => any;
// (undocumented)
once(
eventType: EventType,
successCallback?: (a: DataSnapshot, b?: string | null) => any,
failureCallbackOrContext?: ((a: Error) => void) | object | null,
context?: object | null
): Promise<DataSnapshot>;
// (undocumented)
orderByChild(path: string): Query;
// (undocumented)
orderByKey(): Query;
// (undocumented)
orderByPriority(): Query;
// (undocumented)
orderByValue(): Query;
// (undocumented)
ref: Reference;
// (undocumented)
startAt(value: number | string | boolean | null, key?: string): Query;
// (undocumented)
toJSON(): object;
// (undocumented)
toString(): string;
}

// @public (undocumented)
export interface Reference extends Query {
// (undocumented)
child(path: string): Reference;
// (undocumented)
key: string | null;
// (undocumented)
onDisconnect(): OnDisconnect;
// (undocumented)
parent: Reference | null;
// (undocumented)
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
// (undocumented)
remove(onComplete?: (a: Error | null) => any): Promise<any>;
// (undocumented)
root: Reference;
// (undocumented)
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
// (undocumented)
setPriority(
priority: string | number | null,
onComplete: (a: Error | null) => any
): Promise<any>;
// (undocumented)
setWithPriority(
newVal: any,
newPriority: string | number | null,
onComplete?: (a: Error | null) => any
): Promise<any>;
// (undocumented)
transaction(
transactionUpdate: (a: any) => any,
onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => any,
applyLocally?: boolean
): Promise<any>;
// (undocumented)
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
}

// @public (undocumented)
export interface ServerValue {
// (undocumented)
increment(delta: number): object;
// (undocumented)
TIMESTAMP: object;
}

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


// (No @packageDocumentation comment for this package)

```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"lint:fix": "lerna run --scope @firebase/* --scope rxfire lint:fix",
"size-report": "ts-node-script scripts/size_report/report_binary_size.ts",
"modular-export-size-report": "ts-node-script scripts/size_report/report_modular_export_binary_size.ts",
"api-report": "lerna run --scope @firebase/*-exp --scope @firebase/firestore --scope @firebase/storage --scope @firebase/storage-types-exp api-report",
"api-report": "lerna run --scope @firebase/*-exp --scope @firebase/firestore --scope @firebase/storage --scope @firebase/storage-types --scope @firebase/database api-report",
"docgen:exp": "ts-node-script scripts/exp/docgen.ts",
"postinstall": "yarn --cwd repo-scripts/changelog-generator build",
"sa": "ts-node-script repo-scripts/size-analysis/cli.ts"
Expand Down
5 changes: 5 additions & 0 deletions packages/database/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../../config/api-extractor.json",
// Point it to your entry point d.ts file.
"mainEntryPointFilePath": "<projectFolder>/exp-types/index.d.ts"
}
32 changes: 31 additions & 1 deletion packages/database/exp-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@

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

export { getDatabase } from '../src/exp/Database';
/**
* @public
*/
export declare function getDatabase(app: FirebaseApp, url?: string): Database;

/**
* @public
*/
export interface DataSnapshot {
child(path: string): DataSnapshot;
exists(): boolean;
Expand All @@ -34,6 +40,9 @@ export interface DataSnapshot {
val(): any;
}

/**
* @public
*/
export interface Database {
app: FirebaseApp;
useEmulator(host: string, port: number): void;
Expand All @@ -43,6 +52,9 @@ export interface Database {
refFromURL(url: string): Reference;
}

/**
* @public
*/
export interface OnDisconnect {
cancel(onComplete?: (a: Error | null) => any): Promise<void>;
remove(onComplete?: (a: Error | null) => any): Promise<void>;
Expand All @@ -55,13 +67,19 @@ export interface OnDisconnect {
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
}

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

/**
* @public
*/
export interface Query {
endAt(value: number | string | boolean | null, key?: string): Query;
equalTo(value: number | string | boolean | null, key?: string): Query;
Expand Down Expand Up @@ -96,6 +114,9 @@ export interface Query {
toString(): string;
}

/**
* @public
*/
export interface Reference extends Query {
child(path: string): Reference;
key: string | null;
Expand All @@ -122,15 +143,24 @@ export interface Reference extends Query {
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
}

/**
* @public
*/
export interface ServerValue {
TIMESTAMP: object;
increment(delta: number): object;
}

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

/**
* @public
*/
export function enableLogging(
logger?: boolean | ((a: string) => any),
persistent?: boolean
Expand Down
9 changes: 6 additions & 3 deletions packages/database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@
"scripts": {
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "run-p build:classic build:exp",
"build": "run-p build:classic build:exp && yarn api-report",
"build:classic": "rollup -c rollup.config.js",
"build:exp": "rollup -c rollup.config.exp.js",
"build:exp": "rollup -c rollup.config.exp.js && yarn api-report",
"build:deps": "lerna run --scope @firebase/'{app,database}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "run-p lint test:emulator",
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
"test:all": "run-p lint test:browser test:node",
"test:browser": "karma start --single-run",
"test:node": "TS_NODE_FILES=true TS_NODE_CACHE=NO TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'test/{,!(browser)/**/}*.test.ts' --file index.node.ts --config ../../config/mocharc.node.js",
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts"
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts",
"api-report": "api-extractor run --local --verbose",
"predoc": "node ../../scripts/exp/remove-exp.js temp",
"doc": "api-documenter markdown --input temp --output docs"
},
"license": "Apache-2.0",
"peerDependencies": {},
Expand Down