Skip to content

Commit a51d9c2

Browse files
authored
feat(ml): Added firebase-admin/machine-learning entry point (#1160)
1 parent 252b640 commit a51d9c2

12 files changed

+403
-351
lines changed

etc/firebase-admin.api.md

Lines changed: 34 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -398,73 +398,46 @@ export namespace instanceId {
398398
}
399399

400400
// @public
401-
export function machineLearning(app?: app.App): machineLearning.MachineLearning;
401+
export function machineLearning(app?: App): machineLearning.MachineLearning;
402402

403403
// @public (undocumented)
404404
export namespace machineLearning {
405+
// Warning: (ae-forgotten-export) The symbol "AutoMLTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
406+
//
405407
// (undocumented)
406-
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
407-
// (undocumented)
408-
tfliteModel: {
409-
automlModel: string;
410-
};
411-
}
408+
export type AutoMLTfliteModelOptions = AutoMLTfliteModelOptions;
409+
// Warning: (ae-forgotten-export) The symbol "GcsTfliteModelOptions" needs to be exported by the entry point default-namespace.d.ts
410+
//
412411
// (undocumented)
413-
export interface GcsTfliteModelOptions extends ModelOptionsBase {
414-
// (undocumented)
415-
tfliteModel: {
416-
gcsTfliteUri: string;
417-
};
418-
}
419-
export interface ListModelsOptions {
420-
filter?: string;
421-
pageSize?: number;
422-
pageToken?: string;
423-
}
424-
export interface ListModelsResult {
425-
readonly models: Model[];
426-
readonly pageToken?: string;
427-
}
428-
export interface MachineLearning {
429-
app: app.App;
430-
createModel(model: ModelOptions): Promise<Model>;
431-
deleteModel(modelId: string): Promise<void>;
432-
getModel(modelId: string): Promise<Model>;
433-
listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
434-
publishModel(modelId: string): Promise<Model>;
435-
unpublishModel(modelId: string): Promise<Model>;
436-
updateModel(modelId: string, model: ModelOptions): Promise<Model>;
437-
}
438-
export interface Model {
439-
readonly createTime: string;
440-
readonly displayName: string;
441-
readonly etag: string;
442-
readonly locked: boolean;
443-
readonly modelHash?: string;
444-
readonly modelId: string;
445-
readonly published: boolean;
446-
readonly tags?: string[];
447-
readonly tfliteModel?: TFLiteModel;
448-
toJSON(): {
449-
[key: string]: any;
450-
};
451-
readonly updateTime: string;
452-
readonly validationError?: string;
453-
waitForUnlocked(maxTimeMillis?: number): Promise<void>;
454-
}
412+
export type GcsTfliteModelOptions = GcsTfliteModelOptions;
413+
// Warning: (ae-forgotten-export) The symbol "ListModelsOptions" needs to be exported by the entry point default-namespace.d.ts
414+
//
455415
// (undocumented)
456-
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
457-
export interface ModelOptionsBase {
458-
// (undocumented)
459-
displayName?: string;
460-
// (undocumented)
461-
tags?: string[];
462-
}
463-
export interface TFLiteModel {
464-
readonly automlModel?: string;
465-
readonly gcsTfliteUri?: string;
466-
readonly sizeBytes: number;
467-
}
416+
export type ListModelsOptions = ListModelsOptions;
417+
// Warning: (ae-forgotten-export) The symbol "ListModelsResult" needs to be exported by the entry point default-namespace.d.ts
418+
//
419+
// (undocumented)
420+
export type ListModelsResult = ListModelsResult;
421+
// Warning: (ae-forgotten-export) The symbol "MachineLearning" needs to be exported by the entry point default-namespace.d.ts
422+
//
423+
// (undocumented)
424+
export type MachineLearning = MachineLearning;
425+
// Warning: (ae-forgotten-export) The symbol "Model" needs to be exported by the entry point default-namespace.d.ts
426+
//
427+
// (undocumented)
428+
export type Model = Model;
429+
// Warning: (ae-forgotten-export) The symbol "ModelOptions" needs to be exported by the entry point default-namespace.d.ts
430+
//
431+
// (undocumented)
432+
export type ModelOptions = ModelOptions;
433+
// Warning: (ae-forgotten-export) The symbol "ModelOptionsBase" needs to be exported by the entry point default-namespace.d.ts
434+
//
435+
// (undocumented)
436+
export type ModelOptionsBase = ModelOptionsBase;
437+
// Warning: (ae-forgotten-export) The symbol "TFLiteModel" needs to be exported by the entry point default-namespace.d.ts
438+
//
439+
// (undocumented)
440+
export type TFLiteModel = TFLiteModel;
468441
}
469442

470443
// @public
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
## API Report File for "firebase-admin.machine-learning"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
import { Agent } from 'http';
8+
9+
// @public (undocumented)
10+
export interface AutoMLTfliteModelOptions extends ModelOptionsBase {
11+
// (undocumented)
12+
tfliteModel: {
13+
automlModel: string;
14+
};
15+
}
16+
17+
// @public (undocumented)
18+
export interface GcsTfliteModelOptions extends ModelOptionsBase {
19+
// (undocumented)
20+
tfliteModel: {
21+
gcsTfliteUri: string;
22+
};
23+
}
24+
25+
// Warning: (ae-forgotten-export) The symbol "App" needs to be exported by the entry point index.d.ts
26+
//
27+
// @public (undocumented)
28+
export function getMachineLearning(app?: App): MachineLearning;
29+
30+
// @public
31+
export interface ListModelsOptions {
32+
filter?: string;
33+
pageSize?: number;
34+
pageToken?: string;
35+
}
36+
37+
// @public
38+
export interface ListModelsResult {
39+
readonly models: Model[];
40+
readonly pageToken?: string;
41+
}
42+
43+
// @public
44+
export class MachineLearning {
45+
get app(): App;
46+
createModel(model: ModelOptions): Promise<Model>;
47+
deleteModel(modelId: string): Promise<void>;
48+
getModel(modelId: string): Promise<Model>;
49+
listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
50+
publishModel(modelId: string): Promise<Model>;
51+
unpublishModel(modelId: string): Promise<Model>;
52+
updateModel(modelId: string, model: ModelOptions): Promise<Model>;
53+
}
54+
55+
// @public
56+
export function machineLearning(app?: App): machineLearning.MachineLearning;
57+
58+
// @public (undocumented)
59+
export namespace machineLearning {
60+
// (undocumented)
61+
export type AutoMLTfliteModelOptions = AutoMLTfliteModelOptions;
62+
// (undocumented)
63+
export type GcsTfliteModelOptions = GcsTfliteModelOptions;
64+
// (undocumented)
65+
export type ListModelsOptions = ListModelsOptions;
66+
// (undocumented)
67+
export type ListModelsResult = ListModelsResult;
68+
// (undocumented)
69+
export type MachineLearning = MachineLearning;
70+
// (undocumented)
71+
export type Model = Model;
72+
// (undocumented)
73+
export type ModelOptions = ModelOptions;
74+
// (undocumented)
75+
export type ModelOptionsBase = ModelOptionsBase;
76+
// (undocumented)
77+
export type TFLiteModel = TFLiteModel;
78+
}
79+
80+
// @public
81+
export class Model {
82+
// (undocumented)
83+
get createTime(): string;
84+
// (undocumented)
85+
get displayName(): string;
86+
// (undocumented)
87+
get etag(): string;
88+
get locked(): boolean;
89+
// (undocumented)
90+
get modelHash(): string | undefined;
91+
// (undocumented)
92+
get modelId(): string;
93+
// (undocumented)
94+
get published(): boolean;
95+
// (undocumented)
96+
get tags(): string[];
97+
// (undocumented)
98+
get tfliteModel(): TFLiteModel | undefined;
99+
// (undocumented)
100+
toJSON(): {
101+
[key: string]: any;
102+
};
103+
// (undocumented)
104+
get updateTime(): string;
105+
// (undocumented)
106+
get validationError(): string | undefined;
107+
waitForUnlocked(maxTimeMillis?: number): Promise<void>;
108+
}
109+
110+
// @public (undocumented)
111+
export type ModelOptions = ModelOptionsBase | GcsTfliteModelOptions | AutoMLTfliteModelOptions;
112+
113+
// @public
114+
export interface ModelOptionsBase {
115+
// (undocumented)
116+
displayName?: string;
117+
// (undocumented)
118+
tags?: string[];
119+
}
120+
121+
// @public
122+
export interface TFLiteModel {
123+
readonly automlModel?: string;
124+
readonly gcsTfliteUri?: string;
125+
readonly sizeBytes: number;
126+
}
127+
128+
129+
// (No @packageDocumentation comment for this package)
130+
131+
```

generate-reports.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const entryPoints = {
4040
'firebase-admin/firestore': './lib/firestore/index.d.ts',
4141
'firebase-admin/instance-id': './lib/instance-id/index.d.ts',
4242
'firebase-admin/messaging': './lib/messaging/index.d.ts',
43+
'firebase-admin/machine-learning': './lib/machine-learning/index.d.ts',
4344
'firebase-admin/project-management': './lib/project-management/index.d.ts',
4445
'firebase-admin/security-rules': './lib/security-rules/index.d.ts',
4546
'firebase-admin/storage': './lib/storage/index.d.ts',

gulpfile.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,7 @@ gulp.task('compile', function() {
8484

8585
const configuration = [
8686
'lib/**/*.js',
87-
'lib/**/index.d.ts',
88-
'lib/firebase-namespace-api.d.ts',
89-
'lib/core.d.ts',
90-
'lib/app/*.d.ts',
91-
'lib/auth/*.d.ts',
92-
'lib/database/*.d.ts',
93-
'lib/firestore/*.d.ts',
94-
'lib/instance-id/*.d.ts',
95-
'lib/messaging/*.d.ts',
96-
'lib/project-management/*.d.ts',
97-
'lib/security-rules/*.d.ts',
98-
'lib/storage/*.d.ts',
99-
'lib/remote-config/*.d.ts',
100-
'!lib/utils/index.d.ts',
87+
'lib/**/*.d.ts',
10188
];
10289

10390
workflow = workflow.pipe(filter(configuration));

src/app/firebase-app.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { FirebaseNamespaceInternals } from './firebase-namespace';
2424
import { AppErrorCodes, FirebaseAppError } from '../utils/error';
2525

2626
import { Auth } from '../auth/index';
27-
import { MachineLearning } from '../machine-learning/machine-learning';
27+
import { MachineLearning } from '../machine-learning/index';
2828
import { Messaging } from '../messaging/index';
2929
import { Storage } from '../storage/index';
3030
import { Database } from '../database/index';
@@ -328,11 +328,8 @@ export class FirebaseApp implements app.App {
328328
* @return The Machine Learning service instance of this app
329329
*/
330330
public machineLearning(): MachineLearning {
331-
return this.ensureService_('machine-learning', () => {
332-
const machineLearningService: typeof MachineLearning =
333-
require('../machine-learning/machine-learning').MachineLearning;
334-
return new machineLearningService(this);
335-
});
331+
const fn = require('../machine-learning/index').getMachineLearning;
332+
return fn(this);
336333
}
337334

338335
/**

0 commit comments

Comments
 (0)