1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { SchemaInterface, SchemaType, SchemaParams, SchemaRequest } from '../types/schema';
/**
* Parent class encompassing all Schema types, with static methods that
* allow building specific Schema types. This class can be converted with
* `JSON.stringify()` into a JSON string accepted by Vertex AI REST endpoints.
* (This string conversion is automatically done when calling SDK methods.)
* @public
*/
export declare abstract class Schema implements SchemaInterface {
/**
* Optional. The type of the property.
* This can only be undefined when using `anyOf` schemas, which do not have an
* explicit type in the {@link https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type | OpenAPI specification}.
*/
type?: SchemaType;
/** Optional. The format of the property.
* Supported formats:<br/>
* <ul>
* <li>for NUMBER type: "float", "double"</li>
* <li>for INTEGER type: "int32", "int64"</li>
* <li>for STRING type: "email", "byte", etc</li>
* </ul>
*/
format?: string;
/** Optional. The description of the property. */
description?: string;
/** Optional. The items of the property. */
items?: SchemaInterface;
/** The minimum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
minItems?: number;
/** The maximum number of items (elements) in a schema of {@link (SchemaType:type)} `array`. */
maxItems?: number;
/** Optional. Whether the property is nullable. Defaults to false. */
nullable: boolean;
/** Optional. The example of the property. */
example?: unknown;
/**
* Allows user to add other schema properties that have not yet
* been officially added to the SDK.
*/
[key: string]: unknown;
constructor(schemaParams: SchemaInterface);
/**
* Defines how this Schema should be serialized as JSON.
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#tojson_behavior
* @internal
*/
toJSON(): SchemaRequest;
static array(arrayParams: SchemaParams & {
items: Schema;
}): ArraySchema;
static object(objectParams: SchemaParams & {
properties: {
[k: string]: Schema;
};
optionalProperties?: string[];
}): ObjectSchema;
static string(stringParams?: SchemaParams): StringSchema;
static enumString(stringParams: SchemaParams & {
enum: string[];
}): StringSchema;
static integer(integerParams?: SchemaParams): IntegerSchema;
static number(numberParams?: SchemaParams): NumberSchema;
static boolean(booleanParams?: SchemaParams): BooleanSchema;
static anyOf(anyOfParams: SchemaParams & {
anyOf: TypedSchema[];
}): AnyOfSchema;
}
/**
* A type that includes all specific Schema types.
* @public
*/
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema | AnyOfSchema;
/**
* Schema class for "integer" types.
* @public
*/
export declare class IntegerSchema extends Schema {
constructor(schemaParams?: SchemaParams);
}
/**
* Schema class for "number" types.
* @public
*/
export declare class NumberSchema extends Schema {
constructor(schemaParams?: SchemaParams);
}
/**
* Schema class for "boolean" types.
* @public
*/
export declare class BooleanSchema extends Schema {
constructor(schemaParams?: SchemaParams);
}
/**
* Schema class for "string" types. Can be used with or without
* enum values.
* @public
*/
export declare class StringSchema extends Schema {
enum?: string[];
constructor(schemaParams?: SchemaParams, enumValues?: string[]);
/**
* @internal
*/
toJSON(): SchemaRequest;
}
/**
* Schema class for "array" types.
* The `items` param should refer to the type of item that can be a member
* of the array.
* @public
*/
export declare class ArraySchema extends Schema {
items: TypedSchema;
constructor(schemaParams: SchemaParams, items: TypedSchema);
/**
* @internal
*/
toJSON(): SchemaRequest;
}
/**
* Schema class for "object" types.
* The `properties` param must be a map of `Schema` objects.
* @public
*/
export declare class ObjectSchema extends Schema {
properties: {
[k: string]: TypedSchema;
};
optionalProperties: string[];
constructor(schemaParams: SchemaParams, properties: {
[k: string]: TypedSchema;
}, optionalProperties?: string[]);
/**
* @internal
*/
toJSON(): SchemaRequest;
}
/**
* Schema class representing a value that can conform to any of the provided sub-schemas. This is
* useful when a field can accept multiple distinct types or structures.
* @public
*/
export declare class AnyOfSchema extends Schema {
anyOf: TypedSchema[];
constructor(schemaParams: SchemaParams & {
anyOf: TypedSchema[];
});
/**
* @internal
*/
toJSON(): SchemaRequest;
}
|