Skip to content

feat(ml): Added firebase-admin/machine-learning entry point #1160

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 1 commit into from
Feb 9, 2021
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
95 changes: 34 additions & 61 deletions etc/firebase-admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,73 +398,46 @@ export namespace instanceId {
}

// @public
export function machineLearning(app?: app.App): machineLearning.MachineLearning;
export function machineLearning(app?: App): machineLearning.MachineLearning;

// @public (undocumented)
export namespace machineLearning {
// Warning: (ae-forgotten-export) The symbol "AutoMLTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
// (undocumented)
tfliteModel: {
automlModel: string;
};
}
export type AutoMLTfliteModelOptions = AutoMLTfliteModelOptions;
// Warning: (ae-forgotten-export) The symbol "GcsTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export interface GcsTfliteModelOptions extends ModelOptionsBase {
// (undocumented)
tfliteModel: {
gcsTfliteUri: string;
};
}
export interface ListModelsOptions {
filter?: string;
pageSize?: number;
pageToken?: string;
}
export interface ListModelsResult {
readonly models: Model[];
readonly pageToken?: string;
}
export interface MachineLearning {
app: app.App;
createModel(model: ModelOptions): Promise<Model>;
deleteModel(modelId: string): Promise<void>;
getModel(modelId: string): Promise<Model>;
listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
publishModel(modelId: string): Promise<Model>;
unpublishModel(modelId: string): Promise<Model>;
updateModel(modelId: string, model: ModelOptions): Promise<Model>;
}
export interface Model {
readonly createTime: string;
readonly displayName: string;
readonly etag: string;
readonly locked: boolean;
readonly modelHash?: string;
readonly modelId: string;
readonly published: boolean;
readonly tags?: string[];
readonly tfliteModel?: TFLiteModel;
toJSON(): {
[key: string]: any;
};
readonly updateTime: string;
readonly validationError?: string;
waitForUnlocked(maxTimeMillis?: number): Promise<void>;
}
export type GcsTfliteModelOptions = GcsTfliteModelOptions;
// Warning: (ae-forgotten-export) The symbol "ListModelsOptions" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
export interface ModelOptionsBase {
// (undocumented)
displayName?: string;
// (undocumented)
tags?: string[];
}
export interface TFLiteModel {
readonly automlModel?: string;
readonly gcsTfliteUri?: string;
readonly sizeBytes: number;
}
export type ListModelsOptions = ListModelsOptions;
// Warning: (ae-forgotten-export) The symbol "ListModelsResult" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ListModelsResult = ListModelsResult;
// Warning: (ae-forgotten-export) The symbol "MachineLearning" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type MachineLearning = MachineLearning;
// Warning: (ae-forgotten-export) The symbol "Model" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type Model = Model;
// Warning: (ae-forgotten-export) The symbol "ModelOptions" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ModelOptions = ModelOptions;
// Warning: (ae-forgotten-export) The symbol "ModelOptionsBase" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type ModelOptionsBase = ModelOptionsBase;
// Warning: (ae-forgotten-export) The symbol "TFLiteModel" needs to be exported by the entry point default-namespace.d.ts
//
// (undocumented)
export type TFLiteModel = TFLiteModel;
}

// @public
Expand Down
131 changes: 131 additions & 0 deletions etc/firebase-admin.machine-learning.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
## API Report File for "firebase-admin.machine-learning"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

import { Agent } from 'http';

// @public (undocumented)
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
// (undocumented)
tfliteModel: {
automlModel: string;
};
}

// @public (undocumented)
export interface GcsTfliteModelOptions extends ModelOptionsBase {
// (undocumented)
tfliteModel: {
gcsTfliteUri: string;
};
}

// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
//
// @public (undocumented)
export function getMachineLearning(app?: App): MachineLearning;

// @public
export interface ListModelsOptions {
filter?: string;
pageSize?: number;
pageToken?: string;
}

// @public
export interface ListModelsResult {
readonly models: Model[];
readonly pageToken?: string;
}

// @public
export class MachineLearning {
get app(): App;
createModel(model: ModelOptions): Promise<Model>;
deleteModel(modelId: string): Promise<void>;
getModel(modelId: string): Promise<Model>;
listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
publishModel(modelId: string): Promise<Model>;
unpublishModel(modelId: string): Promise<Model>;
updateModel(modelId: string, model: ModelOptions): Promise<Model>;
}

// @public
export function machineLearning(app?: App): machineLearning.MachineLearning;

// @public (undocumented)
export namespace machineLearning {
// (undocumented)
export type AutoMLTfliteModelOptions = AutoMLTfliteModelOptions;
// (undocumented)
export type GcsTfliteModelOptions = GcsTfliteModelOptions;
// (undocumented)
export type ListModelsOptions = ListModelsOptions;
// (undocumented)
export type ListModelsResult = ListModelsResult;
// (undocumented)
export type MachineLearning = MachineLearning;
// (undocumented)
export type Model = Model;
// (undocumented)
export type ModelOptions = ModelOptions;
// (undocumented)
export type ModelOptionsBase = ModelOptionsBase;
// (undocumented)
export type TFLiteModel = TFLiteModel;
}

// @public
export class Model {
// (undocumented)
get createTime(): string;
// (undocumented)
get displayName(): string;
// (undocumented)
get etag(): string;
get locked(): boolean;
// (undocumented)
get modelHash(): string | undefined;
// (undocumented)
get modelId(): string;
// (undocumented)
get published(): boolean;
// (undocumented)
get tags(): string[];
// (undocumented)
get tfliteModel(): TFLiteModel | undefined;
// (undocumented)
toJSON(): {
[key: string]: any;
};
// (undocumented)
get updateTime(): string;
// (undocumented)
get validationError(): string | undefined;
waitForUnlocked(maxTimeMillis?: number): Promise<void>;
}

// @public (undocumented)
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;

// @public
export interface ModelOptionsBase {
// (undocumented)
displayName?: string;
// (undocumented)
tags?: string[];
}

// @public
export interface TFLiteModel {
readonly automlModel?: string;
readonly gcsTfliteUri?: string;
readonly sizeBytes: number;
}


// (No @packageDocumentation comment for this package)

```
1 change: 1 addition & 0 deletions generate-reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const entryPoints = {
'firebase-admin/firestore': './lib/firestore/index.d.ts',
'firebase-admin/instance-id': './lib/instance-id/index.d.ts',
'firebase-admin/messaging': './lib/messaging/index.d.ts',
'firebase-admin/machine-learning': './lib/machine-learning/index.d.ts',
'firebase-admin/project-management': './lib/project-management/index.d.ts',
'firebase-admin/security-rules': './lib/security-rules/index.d.ts',
'firebase-admin/storage': './lib/storage/index.d.ts',
Expand Down
15 changes: 1 addition & 14 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,7 @@ gulp.task('compile', function() {

const configuration = [
'lib/**/*.js',
'lib/**/index.d.ts',
'lib/firebase-namespace-api.d.ts',
'lib/core.d.ts',
'lib/app/*.d.ts',
'lib/auth/*.d.ts',
'lib/database/*.d.ts',
'lib/firestore/*.d.ts',
'lib/instance-id/*.d.ts',
'lib/messaging/*.d.ts',
'lib/project-management/*.d.ts',
'lib/security-rules/*.d.ts',
'lib/storage/*.d.ts',
'lib/remote-config/*.d.ts',
'!lib/utils/index.d.ts',
'lib/**/*.d.ts',
];

workflow = workflow.pipe(filter(configuration));
Expand Down
9 changes: 3 additions & 6 deletions src/app/firebase-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FirebaseNamespaceInternals } from './firebase-namespace';
import { AppErrorCodes, FirebaseAppError } from '../utils/error';

import { Auth } from '../auth/index';
import { MachineLearning } from '../machine-learning/machine-learning';
import { MachineLearning } from '../machine-learning/index';
import { Messaging } from '../messaging/index';
import { Storage } from '../storage/index';
import { Database } from '../database/index';
Expand Down Expand Up @@ -328,11 +328,8 @@ export class FirebaseApp implements app.App {
* @return 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);
});
const fn = require('../machine-learning/index').getMachineLearning;
return fn(this);
}

/**
Expand Down
Loading