Skip to content

Commit f919db6

Browse files
authored
Fix a typings issue in database exp (#4333)
* enable api extractor for database * generate doc for database
1 parent 94681d9 commit f919db6

File tree

5 files changed

+238
-5
lines changed

5 files changed

+238
-5
lines changed

common/api-review/database.api.md

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
## API Report File for "@firebase/database"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
import { FirebaseApp } from '@firebase/app-types';
8+
9+
// @public (undocumented)
10+
export interface Database {
11+
// (undocumented)
12+
app: FirebaseApp;
13+
// (undocumented)
14+
goOffline(): void;
15+
// (undocumented)
16+
goOnline(): void;
17+
// (undocumented)
18+
ref(path?: string | Reference): Reference;
19+
// (undocumented)
20+
refFromURL(url: string): Reference;
21+
// (undocumented)
22+
useEmulator(host: string, port: number): void;
23+
}
24+
25+
// @public (undocumented)
26+
export interface DataSnapshot {
27+
// (undocumented)
28+
child(path: string): DataSnapshot;
29+
// (undocumented)
30+
exists(): boolean;
31+
// (undocumented)
32+
exportVal(): any;
33+
// (undocumented)
34+
forEach(action: (a: DataSnapshot) => boolean | void): boolean;
35+
// (undocumented)
36+
getPriority(): string | number | null;
37+
// (undocumented)
38+
hasChild(path: string): boolean;
39+
// (undocumented)
40+
hasChildren(): boolean;
41+
// (undocumented)
42+
key: string | null;
43+
// (undocumented)
44+
numChildren(): number;
45+
// (undocumented)
46+
ref: Reference;
47+
// (undocumented)
48+
toJSON(): object | null;
49+
// (undocumented)
50+
val(): any;
51+
}
52+
53+
// @public (undocumented)
54+
export function enableLogging(
55+
logger?: boolean | ((a: string) => any),
56+
persistent?: boolean
57+
): any;
58+
59+
// @public (undocumented)
60+
export type EventType =
61+
| 'value'
62+
| 'child_added'
63+
| 'child_changed'
64+
| 'child_moved'
65+
| 'child_removed';
66+
67+
// @public (undocumented)
68+
export function getDatabase(app: FirebaseApp, url?: string): Database;
69+
70+
// @public (undocumented)
71+
export interface OnDisconnect {
72+
// (undocumented)
73+
cancel(onComplete?: (a: Error | null) => any): Promise<void>;
74+
// (undocumented)
75+
remove(onComplete?: (a: Error | null) => any): Promise<void>;
76+
// (undocumented)
77+
set(value: any, onComplete?: (a: Error | null) => any): Promise<void>;
78+
// (undocumented)
79+
setWithPriority(
80+
value: any,
81+
priority: number | string | null,
82+
onComplete?: (a: Error | null) => any
83+
): Promise<any>;
84+
// (undocumented)
85+
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
86+
}
87+
88+
// @public (undocumented)
89+
export interface Query {
90+
// (undocumented)
91+
endAt(value: number | string | boolean | null, key?: string): Query;
92+
// (undocumented)
93+
equalTo(value: number | string | boolean | null, key?: string): Query;
94+
// (undocumented)
95+
get(): Promise<DataSnapshot>;
96+
// (undocumented)
97+
isEqual(other: Query | null): boolean;
98+
// (undocumented)
99+
limitToFirst(limit: number): Query;
100+
// (undocumented)
101+
limitToLast(limit: number): Query;
102+
// (undocumented)
103+
off(
104+
eventType?: EventType,
105+
callback?: (a: DataSnapshot, b?: string | null) => any,
106+
context?: object | null
107+
): void;
108+
// (undocumented)
109+
on(
110+
eventType: EventType,
111+
callback: (a: DataSnapshot, b?: string | null) => any,
112+
cancelCallbackOrContext?: ((a: Error) => any) | object | null,
113+
context?: object | null
114+
): (a: DataSnapshot, b?: string | null) => any;
115+
// (undocumented)
116+
once(
117+
eventType: EventType,
118+
successCallback?: (a: DataSnapshot, b?: string | null) => any,
119+
failureCallbackOrContext?: ((a: Error) => void) | object | null,
120+
context?: object | null
121+
): Promise<DataSnapshot>;
122+
// (undocumented)
123+
orderByChild(path: string): Query;
124+
// (undocumented)
125+
orderByKey(): Query;
126+
// (undocumented)
127+
orderByPriority(): Query;
128+
// (undocumented)
129+
orderByValue(): Query;
130+
// (undocumented)
131+
ref: Reference;
132+
// (undocumented)
133+
startAt(value: number | string | boolean | null, key?: string): Query;
134+
// (undocumented)
135+
toJSON(): object;
136+
// (undocumented)
137+
toString(): string;
138+
}
139+
140+
// @public (undocumented)
141+
export interface Reference extends Query {
142+
// (undocumented)
143+
child(path: string): Reference;
144+
// (undocumented)
145+
key: string | null;
146+
// (undocumented)
147+
onDisconnect(): OnDisconnect;
148+
// (undocumented)
149+
parent: Reference | null;
150+
// (undocumented)
151+
push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
152+
// (undocumented)
153+
remove(onComplete?: (a: Error | null) => any): Promise<any>;
154+
// (undocumented)
155+
root: Reference;
156+
// (undocumented)
157+
set(value: any, onComplete?: (a: Error | null) => any): Promise<any>;
158+
// (undocumented)
159+
setPriority(
160+
priority: string | number | null,
161+
onComplete: (a: Error | null) => any
162+
): Promise<any>;
163+
// (undocumented)
164+
setWithPriority(
165+
newVal: any,
166+
newPriority: string | number | null,
167+
onComplete?: (a: Error | null) => any
168+
): Promise<any>;
169+
// (undocumented)
170+
transaction(
171+
transactionUpdate: (a: any) => any,
172+
onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => any,
173+
applyLocally?: boolean
174+
): Promise<any>;
175+
// (undocumented)
176+
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
177+
}
178+
179+
// @public (undocumented)
180+
export interface ServerValue {
181+
// (undocumented)
182+
increment(delta: number): object;
183+
// (undocumented)
184+
TIMESTAMP: object;
185+
}
186+
187+
// @public (undocumented)
188+
export interface ThenableReference
189+
extends Reference,
190+
Pick<Promise<Reference>, 'then' | 'catch'> { }
191+
192+
193+
// (No @packageDocumentation comment for this package)
194+
195+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"lint:fix": "lerna run --scope @firebase/* --scope rxfire lint:fix",
5151
"size-report": "ts-node-script scripts/size_report/report_binary_size.ts",
5252
"modular-export-size-report": "ts-node-script scripts/size_report/report_modular_export_binary_size.ts",
53-
"api-report": "lerna run --scope @firebase/*-exp --scope @firebase/firestore --scope @firebase/storage --scope @firebase/storage-types-exp api-report",
53+
"api-report": "lerna run --scope @firebase/*-exp --scope @firebase/firestore --scope @firebase/storage --scope @firebase/storage-types --scope @firebase/database api-report",
5454
"docgen:exp": "ts-node-script scripts/exp/docgen.ts",
5555
"postinstall": "yarn --cwd repo-scripts/changelog-generator build",
5656
"sa": "ts-node-script repo-scripts/size-analysis/cli.ts"

packages/database/api-extractor.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "../../config/api-extractor.json",
3+
// Point it to your entry point d.ts file.
4+
"mainEntryPointFilePath": "<projectFolder>/exp-types/index.d.ts"
5+
}

packages/database/exp-types/index.d.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717

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

20-
export { getDatabase } from '../src/exp/Database';
20+
/**
21+
* @public
22+
*/
23+
export declare function getDatabase(app: FirebaseApp, url?: string): Database;
2124

25+
/**
26+
* @public
27+
*/
2228
export interface DataSnapshot {
2329
child(path: string): DataSnapshot;
2430
exists(): boolean;
@@ -34,6 +40,9 @@ export interface DataSnapshot {
3440
val(): any;
3541
}
3642

43+
/**
44+
* @public
45+
*/
3746
export interface Database {
3847
app: FirebaseApp;
3948
useEmulator(host: string, port: number): void;
@@ -43,6 +52,9 @@ export interface Database {
4352
refFromURL(url: string): Reference;
4453
}
4554

55+
/**
56+
* @public
57+
*/
4658
export interface OnDisconnect {
4759
cancel(onComplete?: (a: Error | null) => any): Promise<void>;
4860
remove(onComplete?: (a: Error | null) => any): Promise<void>;
@@ -55,13 +67,19 @@ export interface OnDisconnect {
5567
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
5668
}
5769

70+
/**
71+
* @public
72+
*/
5873
type EventType =
5974
| 'value'
6075
| 'child_added'
6176
| 'child_changed'
6277
| 'child_moved'
6378
| 'child_removed';
6479

80+
/**
81+
* @public
82+
*/
6583
export interface Query {
6684
endAt(value: number | string | boolean | null, key?: string): Query;
6785
equalTo(value: number | string | boolean | null, key?: string): Query;
@@ -96,6 +114,9 @@ export interface Query {
96114
toString(): string;
97115
}
98116

117+
/**
118+
* @public
119+
*/
99120
export interface Reference extends Query {
100121
child(path: string): Reference;
101122
key: string | null;
@@ -122,15 +143,24 @@ export interface Reference extends Query {
122143
update(values: object, onComplete?: (a: Error | null) => any): Promise<any>;
123144
}
124145

146+
/**
147+
* @public
148+
*/
125149
export interface ServerValue {
126150
TIMESTAMP: object;
127151
increment(delta: number): object;
128152
}
129153

154+
/**
155+
* @public
156+
*/
130157
export interface ThenableReference
131158
extends Reference,
132159
Pick<Promise<Reference>, 'then' | 'catch'> {}
133160

161+
/**
162+
* @public
163+
*/
134164
export function enableLogging(
135165
logger?: boolean | ((a: string) => any),
136166
persistent?: boolean

packages/database/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@
1313
"scripts": {
1414
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1515
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
16-
"build": "run-p build:classic build:exp",
16+
"build": "run-p build:classic build:exp && yarn api-report",
1717
"build:classic": "rollup -c rollup.config.js",
18-
"build:exp": "rollup -c rollup.config.exp.js",
18+
"build:exp": "rollup -c rollup.config.exp.js && yarn api-report",
1919
"build:deps": "lerna run --scope @firebase/'{app,database}' --include-dependencies build",
2020
"dev": "rollup -c -w",
2121
"test": "run-p lint test:emulator",
2222
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:emulator",
2323
"test:all": "run-p lint test:browser test:node",
2424
"test:browser": "karma start --single-run",
2525
"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",
26-
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts"
26+
"test:emulator": "ts-node --compiler-options='{\"module\":\"commonjs\"}' ../../scripts/emulator-testing/database-test-runner.ts",
27+
"api-report": "api-extractor run --local --verbose",
28+
"predoc": "node ../../scripts/exp/remove-exp.js temp",
29+
"doc": "api-documenter markdown --input temp --output docs"
2730
},
2831
"license": "Apache-2.0",
2932
"peerDependencies": {},

0 commit comments

Comments
 (0)