1 | /*! firebase-admin v12.0.0 */
|
2 | /*!
|
3 | * Copyright 2020 Google Inc.
|
4 | *
|
5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
6 | * you may not use this file except in compliance with the License.
|
7 | * You may obtain a copy of the License at
|
8 | *
|
9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 | *
|
11 | * Unless required by applicable law or agreed to in writing, software
|
12 | * distributed under the License is distributed on an "AS IS" BASIS,
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14 | * See the License for the specific language governing permissions and
|
15 | * limitations under the License.
|
16 | */
|
17 | import { App } from '../app';
|
18 | import { ListModelsOptions, ModelOptions } from './machine-learning-api-client';
|
19 | /** Response object for a listModels operation. */
|
20 | export interface ListModelsResult {
|
21 | /** A list of models in your project. */
|
22 | readonly models: Model[];
|
23 | /**
|
24 | * A token you can use to retrieve the next page of results. If null, the
|
25 | * current page is the final page.
|
26 | */
|
27 | readonly pageToken?: string;
|
28 | }
|
29 | /**
|
30 | * A TensorFlow Lite Model output object
|
31 | */
|
32 | export interface TFLiteModel {
|
33 | /** The size of the model. */
|
34 | readonly sizeBytes: number;
|
35 | /** The URI from which the model was originally provided to Firebase. */
|
36 | readonly gcsTfliteUri?: string;
|
37 | }
|
38 | /**
|
39 | * The Firebase `MachineLearning` service interface.
|
40 | */
|
41 | export declare class MachineLearning {
|
42 | private readonly client;
|
43 | private readonly appInternal;
|
44 | /**
|
45 | * The {@link firebase-admin.app#App} associated with the current `MachineLearning`
|
46 | * service instance.
|
47 | */
|
48 | get app(): App;
|
49 | /**
|
50 | * Creates a model in the current Firebase project.
|
51 | *
|
52 | * @param model - The model to create.
|
53 | *
|
54 | * @returns A Promise fulfilled with the created model.
|
55 | */
|
56 | createModel(model: ModelOptions): Promise<Model>;
|
57 | /**
|
58 | * Updates a model's metadata or model file.
|
59 | *
|
60 | * @param modelId - The ID of the model to update.
|
61 | * @param model - The model fields to update.
|
62 | *
|
63 | * @returns A Promise fulfilled with the updated model.
|
64 | */
|
65 | updateModel(modelId: string, model: ModelOptions): Promise<Model>;
|
66 | /**
|
67 | * Publishes a Firebase ML model.
|
68 | *
|
69 | * A published model can be downloaded to client apps.
|
70 | *
|
71 | * @param modelId - The ID of the model to publish.
|
72 | *
|
73 | * @returns A Promise fulfilled with the published model.
|
74 | */
|
75 | publishModel(modelId: string): Promise<Model>;
|
76 | /**
|
77 | * Unpublishes a Firebase ML model.
|
78 | *
|
79 | * @param modelId - The ID of the model to unpublish.
|
80 | *
|
81 | * @returns A Promise fulfilled with the unpublished model.
|
82 | */
|
83 | unpublishModel(modelId: string): Promise<Model>;
|
84 | /**
|
85 | * Gets the model specified by the given ID.
|
86 | *
|
87 | * @param modelId - The ID of the model to get.
|
88 | *
|
89 | * @returns A Promise fulfilled with the model object.
|
90 | */
|
91 | getModel(modelId: string): Promise<Model>;
|
92 | /**
|
93 | * Lists the current project's models.
|
94 | *
|
95 | * @param options - The listing options.
|
96 | *
|
97 | * @returns A promise that
|
98 | * resolves with the current (filtered) list of models and the next page
|
99 | * token. For the last page, an empty list of models and no page token
|
100 | * are returned.
|
101 | */
|
102 | listModels(options?: ListModelsOptions): Promise<ListModelsResult>;
|
103 | /**
|
104 | * Deletes a model from the current project.
|
105 | *
|
106 | * @param modelId - The ID of the model to delete.
|
107 | */
|
108 | deleteModel(modelId: string): Promise<void>;
|
109 | private setPublishStatus;
|
110 | private signUrlIfPresent;
|
111 | private signUrl;
|
112 | }
|
113 | /**
|
114 | * A Firebase ML Model output object.
|
115 | */
|
116 | export declare class Model {
|
117 | private model;
|
118 | private readonly client?;
|
119 | /** The ID of the model. */
|
120 | get modelId(): string;
|
121 | /**
|
122 | * The model's name. This is the name you use from your app to load the
|
123 | * model.
|
124 | */
|
125 | get displayName(): string;
|
126 | /**
|
127 | * The model's tags, which can be used to group or filter models in list
|
128 | * operations.
|
129 | */
|
130 | get tags(): string[];
|
131 | /** The timestamp of the model's creation. */
|
132 | get createTime(): string;
|
133 | /** The timestamp of the model's most recent update. */
|
134 | get updateTime(): string;
|
135 | /** Error message when model validation fails. */
|
136 | get validationError(): string | undefined;
|
137 | /** True if the model is published. */
|
138 | get published(): boolean;
|
139 | /**
|
140 | * The ETag identifier of the current version of the model. This value
|
141 | * changes whenever you update any of the model's properties.
|
142 | */
|
143 | get etag(): string;
|
144 | /**
|
145 | * The hash of the model's `tflite` file. This value changes only when
|
146 | * you upload a new TensorFlow Lite model.
|
147 | */
|
148 | get modelHash(): string | undefined;
|
149 | /** Metadata about the model's TensorFlow Lite model file. */
|
150 | get tfliteModel(): TFLiteModel | undefined;
|
151 | /**
|
152 | * True if the model is locked by a server-side operation. You can't make
|
153 | * changes to a locked model. See {@link Model.waitForUnlocked}.
|
154 | */
|
155 | get locked(): boolean;
|
156 | /**
|
157 | * Return the model as a JSON object.
|
158 | */
|
159 | toJSON(): {
|
160 | [key: string]: any;
|
161 | };
|
162 | /**
|
163 | * Wait for the model to be unlocked.
|
164 | *
|
165 | * @param maxTimeMillis - The maximum time in milliseconds to wait.
|
166 | * If not specified, a default maximum of 2 minutes is used.
|
167 | *
|
168 | * @returns A promise that resolves when the model is unlocked
|
169 | * or the maximum wait time has passed.
|
170 | */
|
171 | waitForUnlocked(maxTimeMillis?: number): Promise<void>;
|
172 | private static validateAndClone;
|
173 | }
|