1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | import { FirebaseApp } from '@firebase/app-types';
|
19 | import { EmulatorMockTokenOptions } from '@firebase/util';
|
20 |
|
21 | export interface DataSnapshot {
|
22 | child(path: string): DataSnapshot;
|
23 | exists(): boolean;
|
24 | exportVal(): any;
|
25 | forEach(action: (a: DataSnapshot) => boolean | void): boolean;
|
26 | getPriority(): string | number | null;
|
27 | hasChild(path: string): boolean;
|
28 | hasChildren(): boolean;
|
29 | key: string | null;
|
30 | numChildren(): number;
|
31 | ref: Reference;
|
32 | toJSON(): Object | null;
|
33 | val(): any;
|
34 | }
|
35 |
|
36 | export interface Database {
|
37 | app: FirebaseApp;
|
38 | useEmulator(
|
39 | host: string,
|
40 | port: number,
|
41 | options?: {
|
42 | mockUserToken?: EmulatorMockTokenOptions | string;
|
43 | }
|
44 | ): void;
|
45 | goOffline(): void;
|
46 | goOnline(): void;
|
47 | ref(path?: string | Reference): Reference;
|
48 | refFromURL(url: string): Reference;
|
49 | }
|
50 |
|
51 | export class FirebaseDatabase implements Database {
|
52 | private constructor();
|
53 | app: FirebaseApp;
|
54 | useEmulator(
|
55 | host: string,
|
56 | port: number,
|
57 | options?: {
|
58 | mockUserToken?: EmulatorMockTokenOptions | string;
|
59 | }
|
60 | ): void;
|
61 | goOffline(): void;
|
62 | goOnline(): void;
|
63 | ref(path?: string | Reference): Reference;
|
64 | refFromURL(url: string): Reference;
|
65 | }
|
66 |
|
67 | export interface OnDisconnect {
|
68 | cancel(onComplete?: (a: Error | null) => any): Promise<void>;
|
69 | remove(onComplete?: (a: Error | null) => any): Promise<void>;
|
70 | set(value: any, onComplete?: (a: Error | null) => any): Promise<void>;
|
71 | setWithPriority(
|
72 | value: any,
|
73 | priority: number | string | null,
|
74 | onComplete?: (a: Error | null) => any
|
75 | ): Promise<any>;
|
76 | update(values: Object, onComplete?: (a: Error | null) => any): Promise<any>;
|
77 | }
|
78 |
|
79 | type EventType =
|
80 | | 'value'
|
81 | | 'child_added'
|
82 | | 'child_changed'
|
83 | | 'child_moved'
|
84 | | 'child_removed';
|
85 |
|
86 | export interface Query {
|
87 | endBefore(value: number | string | boolean | null, key?: string): Query;
|
88 | endAt(value: number | string | boolean | null, key?: string): Query;
|
89 | equalTo(value: number | string | boolean | null, key?: string): Query;
|
90 | isEqual(other: Query | null): boolean;
|
91 | limitToFirst(limit: number): Query;
|
92 | limitToLast(limit: number): Query;
|
93 | off(
|
94 | eventType?: EventType,
|
95 | callback?: (a: DataSnapshot, b?: string | null) => any,
|
96 | context?: Object | null
|
97 | ): void;
|
98 | get(): Promise<DataSnapshot>;
|
99 | on(
|
100 | eventType: EventType,
|
101 | callback: (a: DataSnapshot, b?: string | null) => any,
|
102 | cancelCallbackOrContext?: ((a: Error) => any) | Object | null,
|
103 | context?: Object | null
|
104 | ): (a: DataSnapshot | null, b?: string | null) => any;
|
105 | once(
|
106 | eventType: EventType,
|
107 | successCallback?: (a: DataSnapshot, b?: string | null) => any,
|
108 | failureCallbackOrContext?: ((a: Error) => void) | Object | null,
|
109 | context?: Object | null
|
110 | ): Promise<DataSnapshot>;
|
111 | orderByChild(path: string): Query;
|
112 | orderByKey(): Query;
|
113 | orderByPriority(): Query;
|
114 | orderByValue(): Query;
|
115 | ref: Reference;
|
116 | startAt(value: number | string | boolean | null, key?: string): Query;
|
117 | startAfter(value: number | string | boolean | null, key?: string): Query;
|
118 | toJSON(): Object;
|
119 | toString(): string;
|
120 | }
|
121 |
|
122 | export interface Reference extends Query {
|
123 | child(path: string): Reference;
|
124 | key: string | null;
|
125 | onDisconnect(): OnDisconnect;
|
126 | parent: Reference | null;
|
127 | push(value?: any, onComplete?: (a: Error | null) => any): ThenableReference;
|
128 | remove(onComplete?: (a: Error | null) => void): Promise<void>;
|
129 | root: Reference;
|
130 | set(value: any, onComplete?: (a: Error | null) => void): Promise<void>;
|
131 | setPriority(
|
132 | priority: string | number | null,
|
133 | onComplete: (a: Error | null) => void
|
134 | ): Promise<void>;
|
135 | setWithPriority(
|
136 | newVal: any,
|
137 | newPriority: string | number | null,
|
138 | onComplete?: (a: Error | null) => void
|
139 | ): Promise<void>;
|
140 | transaction(
|
141 | transactionUpdate: (a: any) => any,
|
142 | onComplete?: (a: Error | null, b: boolean, c: DataSnapshot | null) => void,
|
143 | applyLocally?: boolean
|
144 | ): Promise<TransactionResult>;
|
145 | update(values: Object, onComplete?: (a: Error | null) => void): Promise<void>;
|
146 | }
|
147 |
|
148 | export interface ServerValue {
|
149 | TIMESTAMP: Object;
|
150 | increment(delta: number): Object;
|
151 | }
|
152 |
|
153 | export interface TransactionResult {
|
154 | committed: boolean;
|
155 | snapshot: DataSnapshot;
|
156 | }
|
157 |
|
158 | export interface ThenableReference
|
159 | extends Reference,
|
160 | Pick<Promise<Reference>, 'then' | 'catch'> {}
|
161 |
|
162 | export function enableLogging(
|
163 | logger?: boolean | ((a: string) => any),
|
164 | persistent?: boolean
|
165 | ): any;
|
166 |
|
167 | declare module '@firebase/component' {
|
168 | interface NameServiceMapping {
|
169 | 'database-compat': FirebaseDatabase;
|
170 | }
|
171 | }
|
172 |
|
\ | No newline at end of file |