Skip to content

Firebase ML Node.js SDK Structure #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ import {FirebaseNamespaceInternals} from './firebase-namespace';
import {AppErrorCodes, FirebaseAppError} from './utils/error';

import {Auth} from './auth/auth';
import {MachineLearning} from './machine-learning/machine-learning';
import {Messaging} from './messaging/messaging';
import {Storage} from './storage/storage';
import {Database} from '@firebase/database';
import {DatabaseService} from './database/database';
import {Firestore} from '@google-cloud/firestore';
import {FirestoreService} from './firestore/firestore';
import {InstanceId} from './instance-id/instance-id';

import {ProjectManagement} from './project-management/project-management';
import {SecurityRules} from './security-rules/security-rules';

Expand Down Expand Up @@ -354,6 +356,19 @@ export class FirebaseApp {
});
}

/**
* Returns the MachineLearning service instance associated with this app.
*
* @return {MachineLearning} The Machine Learning service instance of this app
*/
public machineLearning(): MachineLearning {
return this.ensureService_('machine-learning', () => {
const machineLearningService: typeof MachineLearning =
require('./machine-learning/machine-learning').MachineLearning;
return new machineLearningService(this);
});
}

/**
* Returns the ProjectManagement service instance associated with this app.
*
Expand Down
16 changes: 16 additions & 0 deletions src/firebase-namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from './auth/credential';

import {Auth} from './auth/auth';
import {MachineLearning} from './machine-learning/machine-learning';
import {Messaging} from './messaging/messaging';
import {Storage} from './storage/storage';
import {Database} from '@firebase/database';
Expand Down Expand Up @@ -396,6 +397,21 @@ export class FirebaseNamespace {
return fn;
}

/**
* Gets the `MachineLearning` service namespace. The returned namespace can be
* used to get the `MachineLearning` service for the default app or an
* explicityly specified app.
*/
get machineLearning(): FirebaseServiceNamespace<MachineLearning> {
const fn: FirebaseServiceNamespace<MachineLearning> =
(app?: FirebaseApp) => {
return this.ensureApp(app).machineLearning();
};
const machineLearning =
require('./machine-learning/machine-learning').MachineLearning;
return Object.assign(fn, {MachineLearning: machineLearning});
}

/**
* Gets the `InstanceId` service namespace. The returned namespace can be used to get the
* `Instance` service for the default app or an explicitly specified app.
Expand Down
Loading