@firebase/ai 1.4.1-canary.5200f7bb7 → 1.4.1-canary.cb19688bf
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-public.d.ts +11 -34
- package/dist/ai.d.ts +11 -37
- package/dist/esm/index.esm.js +2 -40
- package/dist/esm/index.esm.js.map +1 -1
- package/dist/esm/src/requests/schema-builder.d.ts +4 -23
- package/dist/esm/src/types/requests.d.ts +1 -1
- package/dist/esm/src/types/schema.d.ts +6 -12
- package/dist/index.cjs.js +1 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.node.cjs.js +1 -40
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.mjs +2 -40
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/requests/schema-builder.d.ts +4 -23
- package/dist/src/types/requests.d.ts +1 -1
- package/dist/src/types/schema.d.ts +6 -12
- package/package.json +8 -8
|
@@ -24,11 +24,10 @@ import { SchemaInterface, SchemaType, SchemaParams, SchemaRequest } from '../typ
|
|
|
24
24
|
*/
|
|
25
25
|
export declare abstract class Schema implements SchemaInterface {
|
|
26
26
|
/**
|
|
27
|
-
* Optional. The type of the property.
|
|
28
|
-
*
|
|
29
|
-
* explicit type in the {@link https://swagger.io/docs/specification/v3_0/data-models/data-types/#any-type | OpenAPI specification}.
|
|
27
|
+
* Optional. The type of the property. {@link
|
|
28
|
+
* (SchemaType:type)}.
|
|
30
29
|
*/
|
|
31
|
-
type
|
|
30
|
+
type: SchemaType;
|
|
32
31
|
/** Optional. The format of the property.
|
|
33
32
|
* Supported formats:<br/>
|
|
34
33
|
* <ul>
|
|
@@ -78,15 +77,12 @@ export declare abstract class Schema implements SchemaInterface {
|
|
|
78
77
|
static integer(integerParams?: SchemaParams): IntegerSchema;
|
|
79
78
|
static number(numberParams?: SchemaParams): NumberSchema;
|
|
80
79
|
static boolean(booleanParams?: SchemaParams): BooleanSchema;
|
|
81
|
-
static anyOf(anyOfParams: SchemaParams & {
|
|
82
|
-
anyOf: TypedSchema[];
|
|
83
|
-
}): AnyOfSchema;
|
|
84
80
|
}
|
|
85
81
|
/**
|
|
86
82
|
* A type that includes all specific Schema types.
|
|
87
83
|
* @public
|
|
88
84
|
*/
|
|
89
|
-
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema
|
|
85
|
+
export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema;
|
|
90
86
|
/**
|
|
91
87
|
* Schema class for "integer" types.
|
|
92
88
|
* @public
|
|
@@ -153,18 +149,3 @@ export declare class ObjectSchema extends Schema {
|
|
|
153
149
|
*/
|
|
154
150
|
toJSON(): SchemaRequest;
|
|
155
151
|
}
|
|
156
|
-
/**
|
|
157
|
-
* Schema class representing a value that can conform to any of the provided sub-schemas. This is
|
|
158
|
-
* useful when a field can accept multiple distinct types or structures.
|
|
159
|
-
* @public
|
|
160
|
-
*/
|
|
161
|
-
export declare class AnyOfSchema extends Schema {
|
|
162
|
-
anyOf: TypedSchema[];
|
|
163
|
-
constructor(schemaParams: SchemaParams & {
|
|
164
|
-
anyOf: TypedSchema[];
|
|
165
|
-
});
|
|
166
|
-
/**
|
|
167
|
-
* @internal
|
|
168
|
-
*/
|
|
169
|
-
toJSON(): SchemaRequest;
|
|
170
|
-
}
|
|
@@ -87,7 +87,7 @@ export interface GenerationConfig {
|
|
|
87
87
|
* value can be a class generated with a {@link Schema} static method
|
|
88
88
|
* like `Schema.string()` or `Schema.object()` or it can be a plain
|
|
89
89
|
* JS object matching the {@link SchemaRequest} interface.
|
|
90
|
-
* <br/>Note: This only applies when the specified `
|
|
90
|
+
* <br/>Note: This only applies when the specified `responseMIMEType` supports a schema; currently
|
|
91
91
|
* this is limited to `application/json` and `text/x.enum`.
|
|
92
92
|
*/
|
|
93
93
|
responseSchema?: TypedSchema | SchemaRequest;
|
|
@@ -47,12 +47,6 @@ export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
|
47
47
|
* @public
|
|
48
48
|
*/
|
|
49
49
|
export interface SchemaShared<T> {
|
|
50
|
-
/**
|
|
51
|
-
* An array of {@link Schema}. The generated data must be valid against any of the schemas
|
|
52
|
-
* listed in this array. This allows specifying multiple possible structures or types for a
|
|
53
|
-
* single field.
|
|
54
|
-
*/
|
|
55
|
-
anyOf?: T[];
|
|
56
50
|
/** Optional. The format of the property.
|
|
57
51
|
* When using the Gemini Developer API ({@link GoogleAIBackend}), this must be either `'enum'` or
|
|
58
52
|
* `'date-time'`, otherwise requests will fail.
|
|
@@ -103,10 +97,10 @@ export interface SchemaParams extends SchemaShared<SchemaInterface> {
|
|
|
103
97
|
*/
|
|
104
98
|
export interface SchemaRequest extends SchemaShared<SchemaRequest> {
|
|
105
99
|
/**
|
|
106
|
-
* The type of the property.
|
|
107
|
-
*
|
|
100
|
+
* The type of the property. {@link
|
|
101
|
+
* (SchemaType:type)}.
|
|
108
102
|
*/
|
|
109
|
-
type
|
|
103
|
+
type: SchemaType;
|
|
110
104
|
/** Optional. Array of required property. */
|
|
111
105
|
required?: string[];
|
|
112
106
|
}
|
|
@@ -116,10 +110,10 @@ export interface SchemaRequest extends SchemaShared<SchemaRequest> {
|
|
|
116
110
|
*/
|
|
117
111
|
export interface SchemaInterface extends SchemaShared<SchemaInterface> {
|
|
118
112
|
/**
|
|
119
|
-
* The type of the property.
|
|
120
|
-
*
|
|
113
|
+
* The type of the property. {@link
|
|
114
|
+
* (SchemaType:type)}.
|
|
121
115
|
*/
|
|
122
|
-
type
|
|
116
|
+
type: SchemaType;
|
|
123
117
|
}
|
|
124
118
|
/**
|
|
125
119
|
* Interface for JSON parameters in a schema of {@link SchemaType}
|
package/dist/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var util = require('@firebase/util');
|
|
|
8
8
|
var logger$1 = require('@firebase/logger');
|
|
9
9
|
|
|
10
10
|
var name = "@firebase/ai";
|
|
11
|
-
var version = "1.4.1-canary.
|
|
11
|
+
var version = "1.4.1-canary.cb19688bf";
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @license
|
|
@@ -2311,19 +2311,12 @@ class ImagenModel extends AIModel {
|
|
|
2311
2311
|
*/
|
|
2312
2312
|
class Schema {
|
|
2313
2313
|
constructor(schemaParams) {
|
|
2314
|
-
// TODO(dlarocque): Enforce this with union types
|
|
2315
|
-
if (!schemaParams.type && !schemaParams.anyOf) {
|
|
2316
|
-
throw new AIError(AIErrorCode.INVALID_SCHEMA, "A schema must have either a 'type' or an 'anyOf' array of sub-schemas.");
|
|
2317
|
-
}
|
|
2318
2314
|
// eslint-disable-next-line guard-for-in
|
|
2319
2315
|
for (const paramKey in schemaParams) {
|
|
2320
2316
|
this[paramKey] = schemaParams[paramKey];
|
|
2321
2317
|
}
|
|
2322
2318
|
// Ensure these are explicitly set to avoid TS errors.
|
|
2323
2319
|
this.type = schemaParams.type;
|
|
2324
|
-
this.format = schemaParams.hasOwnProperty('format')
|
|
2325
|
-
? schemaParams.format
|
|
2326
|
-
: undefined;
|
|
2327
2320
|
this.nullable = schemaParams.hasOwnProperty('nullable')
|
|
2328
2321
|
? !!schemaParams.nullable
|
|
2329
2322
|
: false;
|
|
@@ -2370,9 +2363,6 @@ class Schema {
|
|
|
2370
2363
|
static boolean(booleanParams) {
|
|
2371
2364
|
return new BooleanSchema(booleanParams);
|
|
2372
2365
|
}
|
|
2373
|
-
static anyOf(anyOfParams) {
|
|
2374
|
-
return new AnyOfSchema(anyOfParams);
|
|
2375
|
-
}
|
|
2376
2366
|
}
|
|
2377
2367
|
/**
|
|
2378
2368
|
* Schema class for "integer" types.
|
|
@@ -2500,34 +2490,6 @@ class ObjectSchema extends Schema {
|
|
|
2500
2490
|
return obj;
|
|
2501
2491
|
}
|
|
2502
2492
|
}
|
|
2503
|
-
/**
|
|
2504
|
-
* Schema class representing a value that can conform to any of the provided sub-schemas. This is
|
|
2505
|
-
* useful when a field can accept multiple distinct types or structures.
|
|
2506
|
-
* @public
|
|
2507
|
-
*/
|
|
2508
|
-
class AnyOfSchema extends Schema {
|
|
2509
|
-
constructor(schemaParams) {
|
|
2510
|
-
if (schemaParams.anyOf.length === 0) {
|
|
2511
|
-
throw new AIError(AIErrorCode.INVALID_SCHEMA, "The 'anyOf' array must not be empty.");
|
|
2512
|
-
}
|
|
2513
|
-
super({
|
|
2514
|
-
...schemaParams,
|
|
2515
|
-
type: undefined // anyOf schemas do not have an explicit type
|
|
2516
|
-
});
|
|
2517
|
-
this.anyOf = schemaParams.anyOf;
|
|
2518
|
-
}
|
|
2519
|
-
/**
|
|
2520
|
-
* @internal
|
|
2521
|
-
*/
|
|
2522
|
-
toJSON() {
|
|
2523
|
-
const obj = super.toJSON();
|
|
2524
|
-
// Ensure the 'anyOf' property contains serialized SchemaRequest objects.
|
|
2525
|
-
if (this.anyOf && Array.isArray(this.anyOf)) {
|
|
2526
|
-
obj.anyOf = this.anyOf.map(s => s.toJSON());
|
|
2527
|
-
}
|
|
2528
|
-
return obj;
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
2493
|
|
|
2532
2494
|
/**
|
|
2533
2495
|
* @license
|
|
@@ -2705,7 +2667,6 @@ registerAI();
|
|
|
2705
2667
|
exports.AIError = AIError;
|
|
2706
2668
|
exports.AIErrorCode = AIErrorCode;
|
|
2707
2669
|
exports.AIModel = AIModel;
|
|
2708
|
-
exports.AnyOfSchema = AnyOfSchema;
|
|
2709
2670
|
exports.ArraySchema = ArraySchema;
|
|
2710
2671
|
exports.Backend = Backend;
|
|
2711
2672
|
exports.BackendType = BackendType;
|