Skip to content

Commit b79a7e2

Browse files
committed
Update doc comments
1 parent f679066 commit b79a7e2

File tree

4 files changed

+109
-25
lines changed

4 files changed

+109
-25
lines changed

common/api-review/vertexai-preview.api.md

Lines changed: 63 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@ import { FirebaseApp } from '@firebase/app';
99
import { FirebaseAuthTokenData } from '@firebase/auth-interop-types';
1010
import { FirebaseError } from '@firebase/util';
1111

12-
// @public (undocumented)
12+
// @public
1313
export class ArraySchema extends Schema {
14-
// Warning: (ae-forgotten-export) The symbol "SchemaParams" needs to be exported by the entry point index.d.ts
1514
constructor(schemaParams: SchemaParams, items: TypedSchema);
1615
// (undocumented)
1716
items: TypedSchema;
18-
// Warning: (ae-forgotten-export) The symbol "_SchemaRequest" needs to be exported by the entry point index.d.ts
17+
// Warning: (ae-incompatible-release-tags) The symbol "toRequest" is marked as @public, but its signature references "_SchemaRequest" which is marked as @internal
1918
//
2019
// (undocumented)
21-
toJSON(): _SchemaRequest;
20+
toRequest(): _SchemaRequest;
2221
}
2322

2423
// @public
@@ -39,7 +38,7 @@ export enum BlockReason {
3938
SAFETY = "SAFETY"
4039
}
4140

42-
// @public (undocumented)
41+
// @public
4342
export class BooleanSchema extends Schema {
4443
constructor(schemaParams?: SchemaParams);
4544
}
@@ -220,7 +219,7 @@ export interface FunctionCallPart {
220219
export interface FunctionDeclaration {
221220
description?: string;
222221
name: string;
223-
parameters?: ObjectSchema;
222+
parameters?: ObjectSchemaInterface;
224223
}
225224

226225
// @public
@@ -313,7 +312,6 @@ export interface GenerationConfig {
313312
// (undocumented)
314313
presencePenalty?: number;
315314
responseMimeType?: string;
316-
// (undocumented)
317315
responseSchema?: TypedSchema;
318316
// (undocumented)
319317
stopSequences?: string[];
@@ -462,7 +460,7 @@ export interface InlineDataPart {
462460
videoMetadata?: VideoMetadata;
463461
}
464462

465-
// @public (undocumented)
463+
// @public
466464
export class IntegerSchema extends Schema {
467465
constructor(schemaParams?: SchemaParams);
468466
}
@@ -479,22 +477,34 @@ export interface ModelParams extends BaseParams {
479477
tools?: Tool[];
480478
}
481479

482-
// @public (undocumented)
480+
// @public
483481
export class NumberSchema extends Schema {
484482
constructor(schemaParams?: SchemaParams);
485483
}
486484

487-
// @public (undocumented)
485+
// @public
488486
export class ObjectSchema extends Schema {
489487
constructor(schemaParams: SchemaParams, properties: {
490488
[k: string]: TypedSchema;
491-
});
489+
}, optionalProperties?: string[]);
490+
// (undocumented)
491+
optionalProperties: string[];
492492
// (undocumented)
493493
properties: {
494494
[k: string]: TypedSchema;
495495
};
496+
// Warning: (ae-incompatible-release-tags) The symbol "toRequest" is marked as @public, but its signature references "_SchemaRequest" which is marked as @internal
497+
//
496498
// (undocumented)
497-
toJSON(): _SchemaRequest;
499+
toRequest(): _SchemaRequest;
500+
}
501+
502+
// @public
503+
export interface ObjectSchemaInterface extends SchemaInterface {
504+
// (undocumented)
505+
optionalProperties?: string[];
506+
// (undocumented)
507+
type: SchemaType.OBJECT;
498508
}
499509

500510
// @public
@@ -556,11 +566,10 @@ export interface SafetySetting {
556566
threshold: HarmBlockThreshold;
557567
}
558568

559-
// Warning: (ae-forgotten-export) The symbol "SchemaInterface" needs to be exported by the entry point index.d.ts
560-
//
561-
// @public (undocumented)
569+
// @public
562570
export abstract class Schema implements SchemaInterface {
563571
constructor(schemaParams: SchemaInterface);
572+
[key: string]: unknown;
564573
// (undocumented)
565574
static array(arrayParams: SchemaParams & {
566575
items: Schema;
@@ -579,6 +588,7 @@ export abstract class Schema implements SchemaInterface {
579588
properties: {
580589
[k: string]: Schema;
581590
};
591+
optionalProperties?: string[];
582592
}): ObjectSchema;
583593
// (undocumented)
584594
static integer(integerParams?: SchemaParams): IntegerSchema;
@@ -590,15 +600,44 @@ export abstract class Schema implements SchemaInterface {
590600
properties: {
591601
[k: string]: Schema;
592602
};
603+
optionalProperties?: string[];
593604
}): ObjectSchema;
594-
required: boolean;
595605
// (undocumented)
596606
static string(stringParams?: SchemaParams): StringSchema;
597-
toJSON(): _SchemaRequest;
598-
// Warning: (ae-forgotten-export) The symbol "SchemaType" needs to be exported by the entry point index.d.ts
607+
// (undocumented)
608+
toJSON(): string;
609+
// Warning: (ae-incompatible-release-tags) The symbol "toRequest" is marked as @public, but its signature references "_SchemaRequest" which is marked as @internal
610+
toRequest(): _SchemaRequest;
611+
type: SchemaType;
612+
}
613+
614+
// Warning: (ae-forgotten-export) The symbol "SchemaShared" needs to be exported by the entry point index.d.ts
615+
//
616+
// @public
617+
export interface SchemaInterface extends SchemaShared<SchemaInterface> {
618+
type: SchemaType;
619+
}
620+
621+
// @public
622+
export interface SchemaParams extends SchemaShared<SchemaInterface> {
623+
}
624+
625+
// @internal
626+
export interface _SchemaRequest extends SchemaShared<_SchemaRequest> {
627+
required?: string[];
599628
type: SchemaType;
600629
}
601630

631+
// @public
632+
export enum SchemaType {
633+
ARRAY = "array",
634+
BOOLEAN = "boolean",
635+
INTEGER = "integer",
636+
NUMBER = "number",
637+
OBJECT = "object",
638+
STRING = "string"
639+
}
640+
602641
// @public (undocumented)
603642
export interface Segment {
604643
// (undocumented)
@@ -621,13 +660,15 @@ export interface StartChatParams extends BaseParams {
621660
tools?: Tool[];
622661
}
623662

624-
// @public (undocumented)
663+
// @public
625664
export class StringSchema extends Schema {
626665
constructor(schemaParams?: SchemaParams, enumValues?: string[]);
627666
// (undocumented)
628667
enum?: string[];
668+
// Warning: (ae-incompatible-release-tags) The symbol "toRequest" is marked as @public, but its signature references "_SchemaRequest" which is marked as @internal
669+
//
629670
// (undocumented)
630-
toJSON(): _SchemaRequest;
671+
toRequest(): _SchemaRequest;
631672
}
632673

633674
// @public
@@ -651,7 +692,7 @@ export interface ToolConfig {
651692
functionCallingConfig: FunctionCallingConfig;
652693
}
653694

654-
// @public (undocumented)
695+
// @public
655696
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema;
656697

657698
// @public
@@ -675,18 +716,15 @@ export interface VertexAI {
675716
export class VertexAIError extends FirebaseError {
676717
constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomErrorData | undefined);
677718
// (undocumented)
678-
readonly code: VertexAIErrorCode;
679-
// (undocumented)
680719
readonly customErrorData?: CustomErrorData | undefined;
681-
// (undocumented)
682-
readonly message: string;
683720
}
684721

685722
// @public
686723
export const enum VertexAIErrorCode {
687724
ERROR = "error",
688725
FETCH_ERROR = "fetch-error",
689726
INVALID_CONTENT = "invalid-content",
727+
INVALID_SCHEMA = "invalid-schema",
690728
NO_API_KEY = "no-api-key",
691729
NO_MODEL = "no-model",
692730
NO_PROJECT_ID = "no-project-id",

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ import {
88
ObjectSchemaInterface
99
} from '../types/schema';
1010

11+
/**
12+
* Parent class encompassing all Schema types, with static methods that
13+
* allow building specific Schema types. This class can be converted with
14+
* JSON.stringify() into a JSON string accepted by Vertex REST endpoints.
15+
* (This string conversion is automatically done when calling SDK methods.)
16+
* @public
17+
*/
1118
export abstract class Schema implements SchemaInterface {
1219
/**
1320
* Optional. The type of the property. {@link
@@ -120,6 +127,10 @@ export abstract class Schema implements SchemaInterface {
120127
}
121128
}
122129

130+
/**
131+
* A type that includes all specific Schema types.
132+
* @public
133+
*/
123134
export type TypedSchema =
124135
| IntegerSchema
125136
| NumberSchema
@@ -128,6 +139,10 @@ export type TypedSchema =
128139
| ObjectSchema
129140
| ArraySchema;
130141

142+
/**
143+
* Schema class for "integer" types.
144+
* @public
145+
*/
131146
export class IntegerSchema extends Schema {
132147
constructor(schemaParams?: SchemaParams) {
133148
super({
@@ -137,6 +152,10 @@ export class IntegerSchema extends Schema {
137152
}
138153
}
139154

155+
/**
156+
* Schema class for "number" types.
157+
* @public
158+
*/
140159
export class NumberSchema extends Schema {
141160
constructor(schemaParams?: SchemaParams) {
142161
super({
@@ -146,6 +165,10 @@ export class NumberSchema extends Schema {
146165
}
147166
}
148167

168+
/**
169+
* Schema class for "boolean" types.
170+
* @public
171+
*/
149172
export class BooleanSchema extends Schema {
150173
constructor(schemaParams?: SchemaParams) {
151174
super({
@@ -155,6 +178,11 @@ export class BooleanSchema extends Schema {
155178
}
156179
}
157180

181+
/**
182+
* Schema class for "string" types. Can be used with or without
183+
* enum values.
184+
* @public
185+
*/
158186
export class StringSchema extends Schema {
159187
enum?: string[];
160188
constructor(schemaParams?: SchemaParams, enumValues?: string[]) {
@@ -174,6 +202,12 @@ export class StringSchema extends Schema {
174202
}
175203
}
176204

205+
/**
206+
* Schema class for "array" types.
207+
* The `items` param should refer to the type of item that can be a member
208+
* of the array.
209+
* @public
210+
*/
177211
export class ArraySchema extends Schema {
178212
constructor(schemaParams: SchemaParams, public items: TypedSchema) {
179213
super({
@@ -189,6 +223,11 @@ export class ArraySchema extends Schema {
189223
}
190224
}
191225

226+
/**
227+
* Schema class for "object" types.
228+
* The `properties` param must be a map of Schema.
229+
* @public
230+
*/
192231
export class ObjectSchema extends Schema {
193232
constructor(
194233
schemaParams: SchemaParams,

packages/vertexai/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export * from './enums';
2020
export * from './requests';
2121
export * from './responses';
2222
export * from './error';
23+
export * from './schema';

packages/vertexai/src/types/schema.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ interface SchemaShared<T> {
4040

4141
/**
4242
* User-facing params passed to specific Schema static methods.
43+
* @public
4344
*/
4445
export interface SchemaParams extends SchemaShared<SchemaInterface> {}
4546

@@ -60,6 +61,7 @@ export interface _SchemaRequest extends SchemaShared<_SchemaRequest> {
6061

6162
/**
6263
* Interface for Schema class.
64+
* @public
6365
*/
6466
export interface SchemaInterface extends SchemaShared<SchemaInterface> {
6567
/**
@@ -69,6 +71,10 @@ export interface SchemaInterface extends SchemaShared<SchemaInterface> {
6971
type: SchemaType;
7072
}
7173

74+
/**
75+
* Interface for ObjectSchema class.
76+
* @public
77+
*/
7278
export interface ObjectSchemaInterface extends SchemaInterface {
7379
type: SchemaType.OBJECT;
7480
optionalProperties?: string[];

0 commit comments

Comments
 (0)