Skip to content

Commit 80e04de

Browse files
Exporting all API types
1 parent a175370 commit 80e04de

File tree

3 files changed

+139
-12
lines changed

3 files changed

+139
-12
lines changed

src/index.js

Lines changed: 121 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,17 +1107,18 @@ Firestore.setLogFunction = function(logger) {
11071107
};
11081108

11091109
// Initializing dependencies that require that Firestore class type.
1110-
let reference = require('./reference')(Firestore);
1110+
const reference = require('./reference')(Firestore);
11111111
CollectionReference = reference.CollectionReference;
11121112
DocumentReference = reference.DocumentReference;
1113-
let document = require('./document')(DocumentReference);
1113+
const document = require('./document')(DocumentReference);
11141114
DocumentSnapshot = document.DocumentSnapshot;
11151115
GeoPoint = document.GeoPoint;
11161116
validate = require('./validate')({
11171117
DocumentReference: reference.validateDocumentReference,
11181118
ResourcePath: ResourcePath.validateResourcePath,
11191119
});
1120-
WriteBatch = require('./write-batch')(Firestore, DocumentReference).WriteBatch;
1120+
const batch = require('./write-batch')(Firestore, DocumentReference);
1121+
WriteBatch = batch.WriteBatch;
11211122
Transaction = require('./transaction')(Firestore);
11221123

11231124
/**
@@ -1163,28 +1164,136 @@ module.exports.Firestore = Firestore;
11631164
module.exports.v1beta1 = v1beta1;
11641165

11651166
/**
1166-
* {@link FieldPath} class.
1167+
* {@link GeoPoint} class.
11671168
*
1168-
* @name Firestore.FieldPath
1169-
* @see FieldPath
1169+
* @name Firestore.GeoPoint
1170+
* @see GeoPoint
11701171
* @type {Constructor}
11711172
*/
1172-
module.exports.FieldPath = FieldPath;
1173+
module.exports.GeoPoint = GeoPoint;
1174+
1175+
/**
1176+
* {@link Transaction} class.
1177+
*
1178+
* @name Firestore.Transaction
1179+
* @see Transaction
1180+
* @type Transaction
1181+
*/
1182+
module.exports.Transaction = Transaction;
1183+
1184+
/**
1185+
* {@link WriteBatch} class.
1186+
*
1187+
* @name Firestore.WriteBatch
1188+
* @see WriteBatch
1189+
* @type WriteBatch
1190+
*/
1191+
module.exports.WriteBatch = WriteBatch;
1192+
1193+
/**
1194+
* {@link DocumentReference} class.
1195+
*
1196+
* @name Firestore.DocumentReference
1197+
* @see DocumentReference
1198+
* @type DocumentReference
1199+
*/
1200+
module.exports.DocumentReference = DocumentReference;
1201+
1202+
/**
1203+
* {@link WriteResult} class.
1204+
*
1205+
* @name Firestore.WriteResult
1206+
* @see WriteResult
1207+
* @type WriteResult
1208+
*/
1209+
module.exports.WriteResult = batch.WriteResult;
1210+
1211+
/**
1212+
* {@link DocumentSnapshot} DocumentSnapshot.
1213+
*
1214+
* @name Firestore.DocumentSnapshot
1215+
* @see DocumentSnapshot
1216+
* @type DocumentSnapshot
1217+
*/
1218+
module.exports.DocumentSnapshot = DocumentSnapshot;
1219+
1220+
/**
1221+
* {@link QueryDocumentSnapshot} class.
1222+
*
1223+
* @name Firestore.QueryDocumentSnapshot
1224+
* @see QueryDocumentSnapshot
1225+
* @type QueryDocumentSnapshot
1226+
*/
1227+
module.exports.QueryDocumentSnapshot = document.QueryDocumentSnapshot;
1228+
1229+
/**
1230+
* {@link Query} class.
1231+
*
1232+
* @name Firestore.Query
1233+
* @see Query
1234+
* @type Query
1235+
*/
1236+
module.exports.Query = document.Query;
1237+
1238+
/**
1239+
* {@link CollectionReference} class.
1240+
*
1241+
* @name Firestore.CollectionReference
1242+
* @see CollectionReference
1243+
* @type CollectionReference
1244+
*/
1245+
module.exports.CollectionReference = CollectionReference;
1246+
1247+
/**
1248+
* {@link QuerySnapshot} class.
1249+
*
1250+
* @name Firestore.QuerySnapshot
1251+
* @see QuerySnapshot
1252+
* @type QuerySnapshot
1253+
*/
1254+
module.exports.QuerySnapshot = reference.QuerySnapshot;
1255+
1256+
/**
1257+
* {@link DocumentChange} class.
1258+
*
1259+
* @name Firestore.DocumentChange
1260+
* @see DocumentChange
1261+
* @type DocumentChange
1262+
*/
1263+
module.exports.DocumentChange = document.DocumentChange;
1264+
1265+
/**
1266+
* {@link Query} class.
1267+
*
1268+
* @name Firestore.Query
1269+
* @see Query
1270+
* @type Query
1271+
*/
1272+
module.exports.Query = reference.Query;
1273+
1274+
/**
1275+
* {@link CollectionReference} class.
1276+
*
1277+
* @name Firestore.CollectionReference
1278+
* @see CollectionReference
1279+
* @type CollectionReference
1280+
*/
1281+
module.exports.Query = CollectionReference;
11731282

11741283
/**
11751284
* {@link FieldValue} class.
11761285
*
11771286
* @name Firestore.FieldValue
11781287
* @see FieldValue
1179-
* @type {Constructor}
1288+
* @type FieldValue
11801289
*/
11811290
module.exports.FieldValue = FieldValue;
11821291

11831292
/**
1184-
* {@link GeoPoint} class.
1293+
* {@link FieldPath} class.
11851294
*
1186-
* @name Firestore.GeoPoint
1187-
* @see GeoPoint
1295+
* @name Firestore.FieldPath
1296+
* @see FieldPath
11881297
* @type {Constructor}
11891298
*/
1190-
module.exports.GeoPoint = GeoPoint;
1299+
module.exports.FieldPath = FieldPath;

src/reference.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,6 +2118,7 @@ module.exports = FirestoreType => {
21182118
});
21192119
return {
21202120
CollectionReference,
2121+
DocumentChange,
21212122
DocumentReference,
21222123
Query,
21232124
QuerySnapshot,

test/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,23 @@ describe('instantiation', function() {
296296

297297
assert.equal(calledWith.service, 'firestore');
298298
});
299+
300+
it('exports all types', function() {
301+
// Ordering as per firestore.d.ts
302+
assert.ok(is.defined(Firestore.Firestore));
303+
assert.ok(is.defined(Firestore.GeoPoint));
304+
assert.ok(is.defined(Firestore.Transaction));
305+
assert.ok(is.defined(Firestore.WriteBatch));
306+
assert.ok(is.defined(Firestore.DocumentReference));
307+
assert.ok(is.defined(Firestore.WriteResult));
308+
assert.ok(is.defined(Firestore.DocumentSnapshot));
309+
assert.ok(is.defined(Firestore.QueryDocumentSnapshot));
310+
assert.ok(is.defined(Firestore.Query));
311+
assert.ok(is.defined(Firestore.QuerySnapshot));
312+
assert.ok(is.defined(Firestore.CollectionReference));
313+
assert.ok(is.defined(Firestore.FieldValue));
314+
assert.ok(is.defined(Firestore.FieldPath));
315+
});
299316
});
300317

301318
describe('snapshot_() method', function() {

0 commit comments

Comments
 (0)