@@ -10,7 +10,7 @@ import { FirebaseError } from '@firebase/util';
10
10
import { LogLevelString as LogLevel } from ' @firebase/logger' ;
11
11
12
12
// @public
13
- export function addDoc<T >(reference : CollectionReference <T >, data : WithFieldValue <T >): Promise <DocumentReference <T >>;
13
+ export function addDoc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : CollectionReference <AppType , DbType >, data : WithFieldValue <AppType >): Promise <DocumentReference <AppType , DbType >>;
14
14
15
15
// @public
16
16
export type AddPrefixToKeys <Prefix extends string , T extends Record <string , unknown >> = {
@@ -26,14 +26,14 @@ export class AggregateField<T> {
26
26
export type AggregateFieldType = AggregateField <number | null >;
27
27
28
28
// @public
29
- export class AggregateQuerySnapshot <T extends AggregateSpec > {
30
- data(): AggregateSpecData <T >;
31
- readonly query: Query <unknown >;
29
+ export class AggregateQuerySnapshot <AggregateSpecType extends AggregateSpec , AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
30
+ data(): AggregateSpecData <AggregateSpecType >;
31
+ readonly query: Query <AppType , DbType >;
32
32
readonly type = " AggregateQuerySnapshot" ;
33
33
}
34
34
35
35
// @public
36
- export function aggregateQuerySnapshotEqual<T extends AggregateSpec >(left : AggregateQuerySnapshot <T >, right : AggregateQuerySnapshot <T >): boolean ;
36
+ export function aggregateQuerySnapshotEqual<AggregateSpecType extends AggregateSpec >(left : AggregateQuerySnapshot <AggregateSpecType >, right : AggregateQuerySnapshot <AggregateSpecType >): boolean ;
37
37
38
38
// @public
39
39
export interface AggregateSpec {
@@ -69,25 +69,25 @@ export class Bytes {
69
69
export type ChildUpdateFields <K extends string , V > = V extends Record <string , unknown > ? AddPrefixToKeys <K , UpdateData <V >> : never ;
70
70
71
71
// @public
72
- export function collection(firestore : Firestore , path : string , ... pathSegments : string []): CollectionReference <DocumentData >;
72
+ export function collection(firestore : Firestore , path : string , ... pathSegments : string []): CollectionReference <DocumentData , DocumentData >;
73
73
74
74
// @public
75
- export function collection(reference : CollectionReference <unknown >, path : string , ... pathSegments : string []): CollectionReference <DocumentData >;
75
+ export function collection< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (reference : CollectionReference <AppType , DbType >, path : string , ... pathSegments : string []): CollectionReference <DocumentData , DocumentData >;
76
76
77
77
// @public
78
- export function collection(reference : DocumentReference , path : string , ... pathSegments : string []): CollectionReference <DocumentData >;
78
+ export function collection< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (reference : DocumentReference < AppType , DbType >, path : string , ... pathSegments : string []): CollectionReference <DocumentData , DocumentData >;
79
79
80
80
// @public
81
- export function collectionGroup(firestore : Firestore , collectionId : string ): Query <DocumentData >;
81
+ export function collectionGroup(firestore : Firestore , collectionId : string ): Query <DocumentData , DocumentData >;
82
82
83
83
// @public
84
- export class CollectionReference <T = DocumentData > extends Query <T > {
84
+ export class CollectionReference <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > extends Query <AppType , DbType > {
85
85
get id(): string ;
86
- get parent(): DocumentReference <DocumentData > | null ;
86
+ get parent(): DocumentReference <DocumentData , DocumentData > | null ;
87
87
get path(): string ;
88
88
readonly type = " collection" ;
89
- withConverter<U >(converter : FirestoreDataConverter <U >): CollectionReference <U >;
90
- withConverter(converter : null ): CollectionReference <DocumentData >;
89
+ withConverter<NewAppType = DocumentData , NewDbType extends DocumentData = NewAppType extends DocumentData ? NewAppType : DocumentData >(converter : FirestoreDataConverter <NewAppType , NewDbType >): CollectionReference <NewAppType , NewDbType >;
90
+ withConverter(converter : null ): CollectionReference <DocumentData , DocumentData >;
91
91
}
92
92
93
93
// @public
@@ -96,48 +96,46 @@ export function connectFirestoreEmulator(firestore: Firestore, host: string, por
96
96
}): void ;
97
97
98
98
// @public
99
- export function deleteDoc(reference : DocumentReference <unknown >): Promise <void >;
99
+ export function deleteDoc< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (reference : DocumentReference <AppType , DbType >): Promise <void >;
100
100
101
101
// @public
102
102
export function deleteField(): FieldValue ;
103
103
104
104
// @public
105
- export function doc(firestore : Firestore , path : string , ... pathSegments : string []): DocumentReference <DocumentData >;
105
+ export function doc(firestore : Firestore , path : string , ... pathSegments : string []): DocumentReference <DocumentData , DocumentData >;
106
106
107
107
// @public
108
- export function doc<T >(reference : CollectionReference <T >, path ? : string , ... pathSegments : string []): DocumentReference <T >;
108
+ export function doc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : CollectionReference <AppType , DbType >, path ? : string , ... pathSegments : string []): DocumentReference <AppType , DbType >;
109
109
110
110
// @public
111
- export function doc(reference : DocumentReference <unknown >, path : string , ... pathSegments : string []): DocumentReference <DocumentData >;
111
+ export function doc< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (reference : DocumentReference <AppType , DbType >, path : string , ... pathSegments : string []): DocumentReference <DocumentData , DocumentData >;
112
112
113
113
// @public
114
- export interface DocumentData {
115
- [field : string ]: any ;
116
- }
114
+ export type DocumentData = Record <string , any >;
117
115
118
116
// @public
119
117
export function documentId(): FieldPath ;
120
118
121
119
// @public
122
- export class DocumentReference <T = DocumentData > {
123
- readonly converter: FirestoreDataConverter <T > | null ;
120
+ export class DocumentReference <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
121
+ readonly converter: FirestoreDataConverter <AppType , DbType > | null ;
124
122
readonly firestore: Firestore ;
125
123
get id(): string ;
126
- get parent(): CollectionReference <T >;
124
+ get parent(): CollectionReference <AppType , DbType >;
127
125
get path(): string ;
128
126
readonly type = " document" ;
129
- withConverter<U >(converter : FirestoreDataConverter <U >): DocumentReference <U >;
130
- withConverter(converter : null ): DocumentReference <DocumentData >;
127
+ withConverter<NewAppType = DocumentData , NewDbType extends DocumentData = NewAppType extends DocumentData ? NewAppType : DocumentData >(converter : FirestoreDataConverter <NewAppType , NewDbType >): DocumentReference <NewAppType , NewDbType >;
128
+ withConverter(converter : null ): DocumentReference <DocumentData , DocumentData >;
131
129
}
132
130
133
131
// @public
134
- export class DocumentSnapshot <T = DocumentData > {
132
+ export class DocumentSnapshot <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
135
133
protected constructor ();
136
- data(): T | undefined ;
137
- exists(): this is QueryDocumentSnapshot <T >;
134
+ data(): AppType | undefined ;
135
+ exists(): this is QueryDocumentSnapshot <AppType , DbType >;
138
136
get(fieldPath : string | FieldPath ): any ;
139
137
get id(): string ;
140
- get ref(): DocumentReference <T >;
138
+ get ref(): DocumentReference <AppType , DbType >;
141
139
}
142
140
143
141
export { EmulatorMockTokenOptions }
@@ -173,10 +171,10 @@ export class Firestore {
173
171
}
174
172
175
173
// @public
176
- export interface FirestoreDataConverter <T > {
177
- fromFirestore(snapshot : QueryDocumentSnapshot <DocumentData >): T ;
178
- toFirestore(modelObject : WithFieldValue <T >): DocumentData ;
179
- toFirestore(modelObject : PartialWithFieldValue <T >, options : SetOptions ): DocumentData ;
174
+ export interface FirestoreDataConverter <AppType , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
175
+ fromFirestore(snapshot : QueryDocumentSnapshot <DbType , DbType >): AppType ;
176
+ toFirestore(modelObject : WithFieldValue <AppType >): WithFieldValue < DbType > ;
177
+ toFirestore(modelObject : PartialWithFieldValue <AppType >, options : SetOptions ): PartialWithFieldValue < DbType > ;
180
178
}
181
179
182
180
// @public
@@ -202,15 +200,15 @@ export class GeoPoint {
202
200
}
203
201
204
202
// @public
205
- export function getCount(query : Query <unknown >): Promise <AggregateQuerySnapshot <{
203
+ export function getCount< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (query : Query <AppType , DbType >): Promise <AggregateQuerySnapshot <{
206
204
count: AggregateField <number >;
207
- }>>;
205
+ }, AppType , DbType >>;
208
206
209
207
// @public
210
- export function getDoc<T >(reference : DocumentReference <T >): Promise <DocumentSnapshot <T >>;
208
+ export function getDoc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : DocumentReference <AppType , DbType >): Promise <DocumentSnapshot <AppType , DbType >>;
211
209
212
210
// @public
213
- export function getDocs<T >(query : Query <T >): Promise <QuerySnapshot <T >>;
211
+ export function getDocs<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(query : Query <AppType , DbType >): Promise <QuerySnapshot <AppType , DbType >>;
214
212
215
213
// @public
216
214
export function getFirestore(): Firestore ;
@@ -255,20 +253,20 @@ export type PartialWithFieldValue<T> = Partial<T> | (T extends Primitive ? T : T
255
253
export type Primitive = string | number | boolean | undefined | null ;
256
254
257
255
// @public
258
- export class Query <T = DocumentData > {
256
+ export class Query <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
259
257
protected constructor ();
260
- readonly converter: FirestoreDataConverter <T > | null ;
258
+ readonly converter: FirestoreDataConverter <AppType , DbType > | null ;
261
259
readonly firestore: Firestore ;
262
260
readonly type: ' query' | ' collection' ;
263
- withConverter(converter : null ): Query <DocumentData >;
264
- withConverter<U >(converter : FirestoreDataConverter <U >): Query <U >;
261
+ withConverter(converter : null ): Query <DocumentData , DocumentData >;
262
+ withConverter<NewAppType = DocumentData , NewDbType extends DocumentData = NewAppType extends DocumentData ? NewAppType : DocumentData >(converter : FirestoreDataConverter <NewAppType , NewDbType >): Query <NewAppType , NewDbType >;
265
263
}
266
264
267
265
// @public
268
- export function query<T >(query : Query <T >, compositeFilter : QueryCompositeFilterConstraint , ... queryConstraints : QueryNonFilterConstraint []): Query <T >;
266
+ export function query<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(query : Query <AppType , DbType >, compositeFilter : QueryCompositeFilterConstraint , ... queryConstraints : QueryNonFilterConstraint []): Query <AppType , DbType >;
269
267
270
268
// @public
271
- export function query<T >(query : Query <T >, ... queryConstraints : QueryConstraint []): Query <T >;
269
+ export function query<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(query : Query <AppType , DbType >, ... queryConstraints : QueryConstraint []): Query <AppType , DbType >;
272
270
273
271
// @public
274
272
export class QueryCompositeFilterConstraint {
@@ -284,9 +282,9 @@ export abstract class QueryConstraint {
284
282
export type QueryConstraintType = ' where' | ' orderBy' | ' limit' | ' limitToLast' | ' startAt' | ' startAfter' | ' endAt' | ' endBefore' ;
285
283
286
284
// @public
287
- export class QueryDocumentSnapshot <T = DocumentData > extends DocumentSnapshot <T > {
285
+ export class QueryDocumentSnapshot <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > extends DocumentSnapshot <AppType , DbType > {
288
286
// @override
289
- data(): T ;
287
+ data(): AppType ;
290
288
}
291
289
292
290
// @public
@@ -295,7 +293,7 @@ export class QueryEndAtConstraint extends QueryConstraint {
295
293
}
296
294
297
295
// @public
298
- export function queryEqual<T >(left : Query <T >, right : Query <T >): boolean ;
296
+ export function queryEqual<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(left : Query <AppType , DbType >, right : Query <AppType , DbType >): boolean ;
299
297
300
298
// @public
301
299
export class QueryFieldFilterConstraint extends QueryConstraint {
@@ -319,11 +317,11 @@ export class QueryOrderByConstraint extends QueryConstraint {
319
317
}
320
318
321
319
// @public
322
- export class QuerySnapshot <T = DocumentData > {
323
- get docs(): Array <QueryDocumentSnapshot <T >>;
320
+ export class QuerySnapshot <AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > {
321
+ get docs(): Array <QueryDocumentSnapshot <AppType , DbType >>;
324
322
get empty(): boolean ;
325
- forEach(callback : (result : QueryDocumentSnapshot <T >) => void , thisArg ? : unknown ): void ;
326
- readonly query: Query <T >;
323
+ forEach(callback : (result : QueryDocumentSnapshot <AppType , DbType >) => void , thisArg ? : unknown ): void ;
324
+ readonly query: Query <AppType , DbType >;
327
325
get size(): number ;
328
326
}
329
327
@@ -333,7 +331,7 @@ export class QueryStartAtConstraint extends QueryConstraint {
333
331
}
334
332
335
333
// @public
336
- export function refEqual<T >(left : DocumentReference <T > | CollectionReference <T >, right : DocumentReference <T > | CollectionReference <T >): boolean ;
334
+ export function refEqual<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(left : DocumentReference <AppType , DbType > | CollectionReference <AppType , DbType >, right : DocumentReference <AppType , DbType > | CollectionReference <AppType , DbType >): boolean ;
337
335
338
336
// @public
339
337
export function runTransaction<T >(firestore : Firestore , updateFunction : (transaction : Transaction ) => Promise <T >, options ? : TransactionOptions ): Promise <T >;
@@ -342,10 +340,10 @@ export function runTransaction<T>(firestore: Firestore, updateFunction: (transac
342
340
export function serverTimestamp(): FieldValue ;
343
341
344
342
// @public
345
- export function setDoc<T >(reference : DocumentReference <T >, data : WithFieldValue <T >): Promise <void >;
343
+ export function setDoc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : DocumentReference <AppType , DbType >, data : WithFieldValue <AppType >): Promise <void >;
346
344
347
345
// @public
348
- export function setDoc<T >(reference : DocumentReference <T >, data : PartialWithFieldValue <T >, options : SetOptions ): Promise <void >;
346
+ export function setDoc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : DocumentReference <AppType , DbType >, data : PartialWithFieldValue <AppType >, options : SetOptions ): Promise <void >;
349
347
350
348
// @public
351
349
export function setLogLevel(logLevel : LogLevel ): void ;
@@ -365,7 +363,7 @@ export interface Settings {
365
363
}
366
364
367
365
// @public
368
- export function snapshotEqual<T >(left : DocumentSnapshot <T > | QuerySnapshot <T >, right : DocumentSnapshot <T > | QuerySnapshot <T >): boolean ;
366
+ export function snapshotEqual<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(left : DocumentSnapshot <AppType , DbType > | QuerySnapshot <AppType , DbType >, right : DocumentSnapshot <AppType , DbType > | QuerySnapshot <AppType , DbType >): boolean ;
369
367
370
368
// @public
371
369
export function startAfter(snapshot : DocumentSnapshot <unknown >): QueryStartAtConstraint ;
@@ -405,12 +403,12 @@ export class Timestamp {
405
403
406
404
// @public
407
405
export class Transaction {
408
- delete(documentRef : DocumentReference <unknown >): this ;
409
- get<T >(documentRef : DocumentReference <T >): Promise <DocumentSnapshot <T >>;
410
- set<T >(documentRef : DocumentReference <T >, data : WithFieldValue <T >): this ;
411
- set<T >(documentRef : DocumentReference <T >, data : PartialWithFieldValue <T >, options : SetOptions ): this ;
412
- update<T >(documentRef : DocumentReference <T >, data : UpdateData <T >): this ;
413
- update(documentRef : DocumentReference <unknown >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): this ;
406
+ delete< AppType , DbType extends DocumentData > (documentRef : DocumentReference <AppType , DbType >): this ;
407
+ get<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >): Promise <DocumentSnapshot <AppType , DbType >>;
408
+ set<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : WithFieldValue <AppType >): this ;
409
+ set<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : PartialWithFieldValue <AppType >, options : SetOptions ): this ;
410
+ update<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : UpdateData <DbType >): this ;
411
+ update< AppType , DbType extends DocumentData > (documentRef : DocumentReference <AppType , DbType >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): this ;
414
412
}
415
413
416
414
// @public
@@ -427,10 +425,10 @@ export type UpdateData<T> = T extends Primitive ? T : T extends {} ? {
427
425
} & NestedUpdateFields <T > : Partial <T >;
428
426
429
427
// @public
430
- export function updateDoc<T >(reference : DocumentReference <T >, data : UpdateData <T >): Promise <void >;
428
+ export function updateDoc<AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData >(reference : DocumentReference <AppType , DbType >, data : UpdateData <DbType >): Promise <void >;
431
429
432
430
// @public
433
- export function updateDoc(reference : DocumentReference <unknown >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): Promise <void >;
431
+ export function updateDoc< AppType = DocumentData , DbType extends DocumentData = AppType extends DocumentData ? AppType : DocumentData > (reference : DocumentReference <AppType , DbType >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): Promise <void >;
434
432
435
433
// @public
436
434
export function where(fieldPath : string | FieldPath , opStr : WhereFilterOp , value : unknown ): QueryFieldFilterConstraint ;
@@ -446,11 +444,11 @@ export type WithFieldValue<T> = T | (T extends Primitive ? T : T extends {} ? {
446
444
// @public
447
445
export class WriteBatch {
448
446
commit(): Promise <void >;
449
- delete(documentRef : DocumentReference <unknown >): WriteBatch ;
450
- set<T >(documentRef : DocumentReference <T >, data : WithFieldValue <T >): WriteBatch ;
451
- set<T >(documentRef : DocumentReference <T >, data : PartialWithFieldValue <T >, options : SetOptions ): WriteBatch ;
452
- update<T >(documentRef : DocumentReference <T >, data : UpdateData <T >): WriteBatch ;
453
- update(documentRef : DocumentReference <unknown >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): WriteBatch ;
447
+ delete< AppType , DbType extends DocumentData > (documentRef : DocumentReference <AppType , DbType >): WriteBatch ;
448
+ set<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : WithFieldValue <AppType >): WriteBatch ;
449
+ set<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : PartialWithFieldValue <AppType >, options : SetOptions ): WriteBatch ;
450
+ update<AppType , DbType extends DocumentData >(documentRef : DocumentReference <AppType , DbType >, data : UpdateData <DbType >): WriteBatch ;
451
+ update< AppType , DbType extends DocumentData > (documentRef : DocumentReference <AppType , DbType >, field : string | FieldPath , value : unknown , ... moreFieldsAndValues : unknown []): WriteBatch ;
454
452
}
455
453
456
454
// @public
0 commit comments