Skip to content

Commit 171b55e

Browse files
authored
Firebase ML Node.js SDK Structure (#778)
* Firebase ML Node.js SDK Structure * added tests
1 parent 5457e2b commit 171b55e

File tree

6 files changed

+511
-36
lines changed

6 files changed

+511
-36
lines changed

src/firebase-app.ts

+15
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ import {FirebaseNamespaceInternals} from './firebase-namespace';
2222
import {AppErrorCodes, FirebaseAppError} from './utils/error';
2323

2424
import {Auth} from './auth/auth';
25+
import {MachineLearning} from './machine-learning/machine-learning';
2526
import {Messaging} from './messaging/messaging';
2627
import {Storage} from './storage/storage';
2728
import {Database} from '@firebase/database';
2829
import {DatabaseService} from './database/database';
2930
import {Firestore} from '@google-cloud/firestore';
3031
import {FirestoreService} from './firestore/firestore';
3132
import {InstanceId} from './instance-id/instance-id';
33+
3234
import {ProjectManagement} from './project-management/project-management';
3335
import {SecurityRules} from './security-rules/security-rules';
3436

@@ -354,6 +356,19 @@ export class FirebaseApp {
354356
});
355357
}
356358

359+
/**
360+
* Returns the MachineLearning service instance associated with this app.
361+
*
362+
* @return {MachineLearning} The Machine Learning service instance of this app
363+
*/
364+
public machineLearning(): MachineLearning {
365+
return this.ensureService_('machine-learning', () => {
366+
const machineLearningService: typeof MachineLearning =
367+
require('./machine-learning/machine-learning').MachineLearning;
368+
return new machineLearningService(this);
369+
});
370+
}
371+
357372
/**
358373
* Returns the ProjectManagement service instance associated with this app.
359374
*

src/firebase-namespace.ts

+16
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
} from './auth/credential';
2929

3030
import {Auth} from './auth/auth';
31+
import {MachineLearning} from './machine-learning/machine-learning';
3132
import {Messaging} from './messaging/messaging';
3233
import {Storage} from './storage/storage';
3334
import {Database} from '@firebase/database';
@@ -396,6 +397,21 @@ export class FirebaseNamespace {
396397
return fn;
397398
}
398399

400+
/**
401+
* Gets the `MachineLearning` service namespace. The returned namespace can be
402+
* used to get the `MachineLearning` service for the default app or an
403+
* explicityly specified app.
404+
*/
405+
get machineLearning(): FirebaseServiceNamespace<MachineLearning> {
406+
const fn: FirebaseServiceNamespace<MachineLearning> =
407+
(app?: FirebaseApp) => {
408+
return this.ensureApp(app).machineLearning();
409+
};
410+
const machineLearning =
411+
require('./machine-learning/machine-learning').MachineLearning;
412+
return Object.assign(fn, {MachineLearning: machineLearning});
413+
}
414+
399415
/**
400416
* Gets the `InstanceId` service namespace. The returned namespace can be used to get the
401417
* `Instance` service for the default app or an explicitly specified app.

0 commit comments

Comments
 (0)