Skip to content

Commit ad26883

Browse files
docs(ai): add missing JSDoc descriptions for AI provider tables and t… (#1951)
### Description Adds missing JSDoc descriptions for exported interfaces, variables, type aliases, and properties in `firebase-functions/v2/ai` so that all reference overview tables are populated with descriptions. ### Release notes relnote: none
1 parent d309c3b commit ad26883

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

src/v2/providers/ai/index.ts

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ import * as logger from "../../../logger";
4040

4141
export { HttpsError };
4242

43+
/**
44+
* Mapping from `FunctionsErrorCode` strings to numeric RPC status codes.
45+
*/
4346
export const rpcCodeMap: Record<FunctionsErrorCode, number> = {
4447
ok: 0,
4548
cancelled: 1,
@@ -82,32 +85,72 @@ export {
8285
};
8386
type MultipleLocationsIf<Allowed extends boolean> = Allowed extends true ? string[] : never;
8487

88+
/**
89+
* Options for configuring AI webhook triggers.
90+
*/
8591
export interface WebhookOptions<Regional extends boolean = false>
8692
extends Omit<EventHandlerOptions, "location"> {
93+
/**
94+
* Region where functions should be deployed. Deployed to `us-central1` by default.
95+
*/
8796
location?: string | Expression<string> | MultipleLocationsIf<Regional> | ResetValue;
97+
/**
98+
* Whether to handle regional webhooks.
99+
*/
88100
regionalWebhook?: Regional;
89101
}
90102

103+
/**
104+
* Metadata about the server prompt template used, if applicable.
105+
*/
91106
export interface PromptTemplateInfo {
107+
/** The name of the server prompt template. */
92108
templateName?: string;
93109
}
94110

111+
/**
112+
* Authentication state for the caller: `"app_user"`, `"unauthenticated"`, or `"unknown"`.
113+
*/
95114
export type AuthType = "app_user" | "unauthenticated" | "unknown";
96115

116+
/**
117+
* Event type for `beforeGenerate` triggers.
118+
*/
97119
export const beforeGenerateEventType = "google.firebase.ailogic.v1.beforeGenerate";
120+
/**
121+
* Event type for `afterGenerate` triggers.
122+
*/
98123
export const afterGenerateEventType = "google.firebase.ailogic.v1.afterGenerate";
99124

125+
/**
126+
* Union of all valid AI request payloads across supported Gemini API providers.
127+
*/
100128
export type AnyValidAIRequest =
101129
| GeminiV1BetaGenerateContentRequest
102130
| VertexV1Beta1GenerateContentRequest;
131+
/**
132+
* Union of all valid AI response payloads across supported Gemini API providers.
133+
*/
103134
export type AnyValidAIResponse =
104135
| GeminiV1BetaGenerateContentResponse
105136
| VertexV1Beta1GenerateContentResponse;
106137

138+
/**
139+
* Identifier for the Gemini Developer API (`geminiV1Beta`).
140+
*/
107141
export const geminiV1Beta = "google.ai.generativelanguage.v1beta";
142+
/**
143+
* Identifier for the Agent Platform Gemini API (formerly Vertex AI) (`vertexV1Beta1`).
144+
*/
108145
export const vertexV1Beta1 = "google.cloud.aiplatform.v1beta1";
146+
/**
147+
* Supported Gemini API providers: Gemini Developer API or Agent Platform Gemini API (formerly Vertex AI).
148+
*/
109149
export type SupportedAPI = typeof geminiV1Beta | typeof vertexV1Beta1;
110150

151+
/**
152+
* Generic type resolving to the corresponding AI request type based on the API identifier.
153+
*/
111154
export type AIRequest<API> = string extends API
112155
? AnyValidAIRequest
113156
: API extends typeof geminiV1Beta
@@ -116,6 +159,9 @@ export type AIRequest<API> = string extends API
116159
? VertexV1Beta1GenerateContentRequest
117160
: never;
118161

162+
/**
163+
* Generic type resolving to the corresponding AI response type based on the API identifier.
164+
*/
119165
export type AIResponse<API> = string extends API
120166
? AnyValidAIResponse
121167
: API extends typeof geminiV1Beta
@@ -124,31 +170,56 @@ export type AIResponse<API> = string extends API
124170
? VertexV1Beta1GenerateContentResponse
125171
: never;
126172

173+
/**
174+
* Data payload for `beforeGenerateContent` events.
175+
*/
127176
export interface BeforeGenerateContentData<API extends string = string> {
177+
/** The full model resource path (for example, `projects/{PROJECT_ID}/locations/global/publishers/google/models/gemini-3.5-flash`). */
128178
model: string;
179+
/** Metadata about the server prompt template used, if applicable. */
129180
template?: PromptTemplateInfo;
181+
/** The Gemini API provider: `geminiV1Beta` (Gemini Developer API) or `vertexV1Beta1` (Agent Platform Gemini API (formerly Vertex AI)). */
130182
api: SupportedAPI;
183+
/** The outgoing request payload. */
131184
request: AIRequest<API>;
132185
}
133186

187+
/**
188+
* Data payload for `afterGenerateContent` events.
189+
*/
134190
export interface AfterGenerateContentData<API extends string = string>
135191
extends BeforeGenerateContentData<API> {
192+
/** The model's response payload. */
136193
response: AIResponse<API>;
137194
}
138195

196+
/**
197+
* Event context and metadata delivered to AI blocking handlers.
198+
*/
139199
export interface AIBlockingEvent<T = any> extends CloudEvent<T> {
200+
/** Authentication state for the caller: `"app_user"`, `"unauthenticated"`, or `"unknown"`. */
140201
authType: AuthType;
202+
/** The caller's Firebase Authentication UID, if signed in. */
141203
authId?: string;
204+
/** The caller's custom auth claims, if any. */
142205
authClaims?: any;
206+
/** The resource name of the caller or request. */
143207
resourceName?: string;
208+
/** The Firebase App ID that made the request. */
144209
appId?: string;
210+
/** The display name of the calling app, if set. */
145211
displayName?: string;
212+
/** The package name of the calling app (applicable only for apps that target Android platforms). */
146213
androidPackageName?: string;
214+
/** The bundle ID of the calling app (applicable only for apps that target Apple platforms). */
147215
iosBundleId?: string;
148216
}
149217

150218
type MaybeAsync<T> = T | Promise<T>;
151219

220+
/**
221+
* A function that handles AI blocking events.
222+
*/
152223
export type BlockingFunction = HttpsFunction;
153224

154225
/**

src/v2/providers/ai/types/gemini/v1beta/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,13 @@ export declare interface GenerateContentCandidate {
382382
* @public
383383
*/
384384
export declare interface GenerateContentRequest extends BaseParams {
385+
/** Array of conversation turns (Content) that make up the prompt. */
385386
contents: Content[];
387+
/** Optional tools that the model may use to generate content. */
386388
tools?: Tool[];
389+
/** Optional tool configuration. */
387390
toolConfig?: ToolConfig;
391+
/** Optional system instructions for the model. */
388392
systemInstruction?: string | Part | Content;
389393
/**
390394
* This is the name of a `CachedContent` and not the cache object itself.

0 commit comments

Comments
 (0)