Skip to content

Commit 9f75fd5

Browse files
committed
Fix typings for functionDeclaration.parameters.
1 parent 1363ecc commit 9f75fd5

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.changeset/rotten-taxis-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@firebase/vertexai': patch
3+
---
4+
5+
Fix typings for functionDeclaration.parameters.

common/api-review/vertexai.api.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export interface FunctionCallPart {
211211
export interface FunctionDeclaration {
212212
description: string;
213213
name: string;
214-
parameters?: ObjectSchemaInterface;
214+
parameters?: ObjectSchema | ObjectSchemaRequest;
215215
}
216216

217217
// @public
@@ -567,9 +567,8 @@ export class ObjectSchema extends Schema {
567567
}
568568

569569
// @public
570-
export interface ObjectSchemaInterface extends SchemaInterface {
571-
// (undocumented)
572-
optionalProperties?: string[];
570+
export interface ObjectSchemaRequest extends SchemaRequest {
571+
optionalProperties?: never;
573572
// (undocumented)
574573
type: SchemaType.OBJECT;
575574
}

packages/vertexai/src/requests/schema-builder.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ import {
2121
SchemaInterface,
2222
SchemaType,
2323
SchemaParams,
24-
SchemaRequest,
25-
ObjectSchemaInterface
24+
SchemaRequest
2625
} from '../types/schema';
2726

2827
/**
@@ -286,7 +285,7 @@ export class ObjectSchema extends Schema {
286285
if (required.length > 0) {
287286
obj.required = required;
288287
}
289-
delete (obj as ObjectSchemaInterface).optionalProperties;
288+
delete obj.optionalProperties;
290289
return obj as SchemaRequest;
291290
}
292291
}

packages/vertexai/src/types/requests.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { TypedSchema } from '../requests/schema-builder';
18+
import { ObjectSchema, TypedSchema } from '../requests/schema-builder';
1919
import { Content, Part } from './content';
2020
import {
2121
FunctionCallingMode,
2222
HarmBlockMethod,
2323
HarmBlockThreshold,
2424
HarmCategory
2525
} from './enums';
26-
import { ObjectSchemaInterface, SchemaRequest } from './schema';
26+
import { ObjectSchemaRequest, SchemaRequest } from './schema';
2727

2828
/**
2929
* Base parameters for a number of methods.
@@ -175,7 +175,7 @@ export declare interface FunctionDeclaration {
175175
* format. Reflects the Open API 3.03 Parameter Object. Parameter names are
176176
* case-sensitive. For a function with no parameters, this can be left unset.
177177
*/
178-
parameters?: ObjectSchemaInterface;
178+
parameters?: ObjectSchema | ObjectSchemaRequest;
179179
}
180180

181181
/**

packages/vertexai/src/types/schema.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,16 @@ export interface SchemaInterface extends SchemaShared<SchemaInterface> {
9595
}
9696

9797
/**
98-
* Interface for {@link ObjectSchema} class.
98+
* Interface for JSON parameters in {@link SchemaType.OBJECT} format when
99+
* not using the {@link ObjectSchema} helper.
99100
* @public
100101
*/
101-
export interface ObjectSchemaInterface extends SchemaInterface {
102+
export interface ObjectSchemaRequest extends SchemaRequest {
102103
type: SchemaType.OBJECT;
103-
optionalProperties?: string[];
104+
/**
105+
* This is not a property accepted in the final request to the backend, but is
106+
* a client-side convenience property that is only usable by constructing
107+
* a schema through the `Schema.object()` helper method.
108+
*/
109+
optionalProperties?: never;
104110
}

0 commit comments

Comments
 (0)