Skip to content

Commit 7354a0e

Browse files
Database exp (#4720)
* Add database@exp API (#4614) * Compat and @exp class for DataSnapshot (#4686) * Add events to database@exp (#4694) * Compat and @exp class for Database (#4705) * Implement Query Compat and query@exp (#4709) * Compat class for Reference (#4719) * OnDisconnect Compat (#4727) * ServerValues compat (#4728) * EnableLogging Compat (#4730) * Remove argument numbers from validation (#4729) * Update changeset * Add database@exp API docs (#4738) * Add Support for API report (#4741) * Update lets-go-travel.md * Update enableLogging
1 parent bc0e713 commit 7354a0e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+5161
-2779
lines changed

.changeset/lets-go-travel.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"firebase": patch
3+
"@firebase/util": major
4+
"@firebase/database": patch
5+
---
6+
7+
Internal changes to Database and Validation APIs.

common/api-review/database-exp.api.md

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
## API Report File for "@firebase/database-exp"
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';
8+
9+
// @public (undocumented)
10+
export class DataSnapshot {
11+
child(path: string): DataSnapshot;
12+
exists(): boolean;
13+
exportVal(): any;
14+
forEach(action: (child: DataSnapshot) => boolean | void): boolean;
15+
hasChild(path: string): boolean;
16+
hasChildren(): boolean;
17+
get key(): string | null;
18+
get priority(): string | number | null;
19+
readonly ref: Reference;
20+
get size(): number;
21+
toJSON(): object | null;
22+
val(): any;
23+
}
24+
25+
// @public
26+
export function enableLogging(enabled: boolean, persistent?: boolean): any;
27+
28+
// @public
29+
export function enableLogging(logger: (message: string) => unknown): any;
30+
31+
// @public
32+
export function endAt(value: number | string | boolean | null, key?: string): QueryConstraint;
33+
34+
// @public
35+
export function endBefore(value: number | string | boolean | null, key?: string): QueryConstraint;
36+
37+
// @public
38+
export function equalTo(value: number | string | boolean | null, key?: string): QueryConstraint;
39+
40+
// @public
41+
export type EventType = 'value' | 'child_added' | 'child_changed' | 'child_moved' | 'child_removed';
42+
43+
// @public
44+
export class FirebaseDatabase {
45+
readonly app: FirebaseApp;
46+
readonly 'type' = "database";
47+
}
48+
49+
// @public
50+
export function get(query: Query): Promise<DataSnapshot>;
51+
52+
// @public
53+
export function getDatabase(app?: FirebaseApp, url?: string): FirebaseDatabase;
54+
55+
// @public
56+
export function goOffline(db: FirebaseDatabase): void;
57+
58+
// @public
59+
export function goOnline(db: FirebaseDatabase): void;
60+
61+
// @public
62+
export function increment(delta: number): object;
63+
64+
// @public
65+
export function limitToFirst(limit: number): QueryConstraint;
66+
67+
// @public
68+
export function limitToLast(limit: number): QueryConstraint;
69+
70+
// @public
71+
export interface ListenOptions {
72+
readonly onlyOnce?: boolean;
73+
}
74+
75+
// @public
76+
export function off(query: Query, eventType?: EventType, callback?: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown): void;
77+
78+
// @public
79+
export function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName?: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
80+
81+
// @public
82+
export function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
83+
84+
// @public
85+
export function onChildAdded(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
86+
87+
// @public
88+
export function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
89+
90+
// @public
91+
export function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
92+
93+
// @public
94+
export function onChildChanged(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
95+
96+
// @public
97+
export function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
98+
99+
// @public
100+
export function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, options: ListenOptions): Unsubscribe;
101+
102+
// @public
103+
export function onChildMoved(query: Query, callback: (snapshot: DataSnapshot, previousChildName: string | null) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
104+
105+
// @public
106+
export function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
107+
108+
// @public
109+
export function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
110+
111+
// @public
112+
export function onChildRemoved(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
113+
114+
// @public
115+
export class OnDisconnect {
116+
cancel(): Promise<void>;
117+
remove(): Promise<void>;
118+
set(value: unknown): Promise<void>;
119+
setWithPriority(value: unknown, priority: number | string | null): Promise<void>;
120+
update(values: object): Promise<void>;
121+
}
122+
123+
// @public
124+
export function onDisconnect(ref: Reference): OnDisconnect;
125+
126+
// @public
127+
export function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback?: (error: Error) => unknown): Unsubscribe;
128+
129+
// @public
130+
export function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, options: ListenOptions): Unsubscribe;
131+
132+
// @public
133+
export function onValue(query: Query, callback: (snapshot: DataSnapshot) => unknown, cancelCallback: (error: Error) => unknown, options: ListenOptions): Unsubscribe;
134+
135+
// @public
136+
export function orderByChild(path: string): QueryConstraint;
137+
138+
// @public
139+
export function orderByKey(): QueryConstraint;
140+
141+
// @public
142+
export function orderByPriority(): QueryConstraint;
143+
144+
// @public
145+
export function orderByValue(): QueryConstraint;
146+
147+
// @public
148+
export function push(parent: Reference, value?: unknown): ThenableReference;
149+
150+
// @public
151+
export interface Query {
152+
isEqual(other: Query | null): boolean;
153+
readonly ref: Reference;
154+
toJSON(): string;
155+
toString(): string;
156+
}
157+
158+
// @public
159+
export function query(query: Query, ...queryConstraints: QueryConstraint[]): Query;
160+
161+
// @public
162+
export abstract class QueryConstraint {
163+
abstract readonly type: QueryConstraintType;
164+
}
165+
166+
// @public
167+
export type QueryConstraintType = 'endAt' | 'endBefore' | 'startAt' | 'startAfter' | 'limitToFirst' | 'limitToLast' | 'orderByChild' | 'orderByKey' | 'orderByPriority' | 'orderByValue' | 'equalTo';
168+
169+
// @public
170+
export function ref(db: FirebaseDatabase, path?: string): Reference;
171+
172+
// @public
173+
export interface Reference extends Query {
174+
readonly key: string | null;
175+
readonly parent: Reference | null;
176+
readonly root: Reference;
177+
}
178+
179+
// @public
180+
export function refFromURL(db: FirebaseDatabase, url: string): Reference;
181+
182+
// @public
183+
export function remove(ref: Reference): Promise<void>;
184+
185+
// @public
186+
export function runTransaction(ref: Reference, transactionUpdate: (currentData: any) => unknown, options?: TransactionOptions): Promise<TransactionResult>;
187+
188+
// @public
189+
export function serverTimestamp(): object;
190+
191+
// @public
192+
export function set(ref: Reference, value: unknown): Promise<void>;
193+
194+
// @public
195+
export function setPriority(ref: Reference, priority: string | number | null): Promise<void>;
196+
197+
// @public
198+
export function setWithPriority(ref: Reference, value: unknown, priority: string | number | null): Promise<void>;
199+
200+
// @public
201+
export function startAfter(value: number | string | boolean | null, key?: string): QueryConstraint;
202+
203+
// @public
204+
export function startAt(value?: number | string | boolean | null, key?: string): QueryConstraint;
205+
206+
// @public
207+
export interface ThenableReference extends Reference, Pick<Promise<Reference>, 'then' | 'catch'> {
208+
}
209+
210+
// @public
211+
export interface TransactionOptions {
212+
readonly applyLocally?: boolean;
213+
}
214+
215+
// @public
216+
export class TransactionResult {
217+
readonly committed: boolean;
218+
readonly snapshot: DataSnapshot;
219+
toJSON(): object;
220+
}
221+
222+
// @public
223+
export type Unsubscribe = () => void;
224+
225+
// @public
226+
export function update(ref: Reference, values: object): Promise<void>;
227+
228+
// @public
229+
export function useDatabaseEmulator(db: FirebaseDatabase, host: string, port: number): void;
230+
231+
232+
// (No @packageDocumentation comment for this package)
233+
234+
```

packages/database/.eslintrc.js

+6
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ module.exports = {
5353
rules: {
5454
'@typescript-eslint/no-explicit-any': 'off'
5555
}
56+
},
57+
{
58+
files: ['scripts/*.ts'],
59+
rules: {
60+
'import/no-extraneous-dependencies': 'off'
61+
}
5662
}
5763
]
5864
};

packages/database/.idea/runConfigurations/All_Tests.xml

+3-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/database/exp/index.node.ts

+56-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,61 @@
1717

1818
import { registerDatabase } from './register';
1919

20-
export { getDatabase, ServerValue } from '../src/exp/Database';
21-
export { enableLogging } from '../src/core/util/util';
20+
export {
21+
FirebaseDatabase,
22+
enableLogging,
23+
getDatabase,
24+
goOffline,
25+
goOnline,
26+
useDatabaseEmulator
27+
} from '../src/exp/Database';
28+
export {
29+
Query,
30+
Reference,
31+
ListenOptions,
32+
Unsubscribe,
33+
ThenableReference
34+
} from '../src/exp/Reference';
35+
export { OnDisconnect } from '../src/exp/OnDisconnect';
36+
export {
37+
DataSnapshot,
38+
EventType,
39+
QueryConstraint,
40+
QueryConstraintType,
41+
endAt,
42+
endBefore,
43+
equalTo,
44+
get,
45+
limitToFirst,
46+
limitToLast,
47+
off,
48+
onChildAdded,
49+
onChildChanged,
50+
onChildMoved,
51+
onChildRemoved,
52+
onDisconnect,
53+
onValue,
54+
orderByChild,
55+
orderByKey,
56+
orderByPriority,
57+
orderByValue,
58+
push,
59+
query,
60+
ref,
61+
refFromURL,
62+
remove,
63+
set,
64+
setPriority,
65+
setWithPriority,
66+
startAfter,
67+
startAt,
68+
update
69+
} from '../src/exp/Reference_impl';
70+
export { increment, serverTimestamp } from '../src/exp/ServerValue';
71+
export {
72+
runTransaction,
73+
TransactionOptions,
74+
TransactionResult
75+
} from '../src/exp/Transaction';
2276

2377
registerDatabase('node');

packages/database/exp/index.ts

+56-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,61 @@
1717

1818
import { registerDatabase } from './register';
1919

20-
export { getDatabase, ServerValue } from '../src/exp/Database';
21-
export { enableLogging } from '../src/core/util/util';
20+
export {
21+
FirebaseDatabase,
22+
enableLogging,
23+
getDatabase,
24+
goOffline,
25+
goOnline,
26+
useDatabaseEmulator
27+
} from '../src/exp/Database';
28+
export {
29+
Query,
30+
Reference,
31+
ListenOptions,
32+
Unsubscribe,
33+
ThenableReference
34+
} from '../src/exp/Reference';
35+
export { OnDisconnect } from '../src/exp/OnDisconnect';
36+
export {
37+
DataSnapshot,
38+
EventType,
39+
QueryConstraint,
40+
QueryConstraintType,
41+
endAt,
42+
endBefore,
43+
equalTo,
44+
get,
45+
limitToFirst,
46+
limitToLast,
47+
off,
48+
onChildAdded,
49+
onChildChanged,
50+
onChildMoved,
51+
onChildRemoved,
52+
onDisconnect,
53+
onValue,
54+
orderByChild,
55+
orderByKey,
56+
orderByPriority,
57+
orderByValue,
58+
push,
59+
query,
60+
ref,
61+
refFromURL,
62+
remove,
63+
set,
64+
setPriority,
65+
setWithPriority,
66+
startAfter,
67+
startAt,
68+
update
69+
} from '../src/exp/Reference_impl';
70+
export { increment, serverTimestamp } from '../src/exp/ServerValue';
71+
export {
72+
runTransaction,
73+
TransactionOptions,
74+
TransactionResult
75+
} from '../src/exp/Transaction';
2276

2377
registerDatabase();

0 commit comments

Comments
 (0)