Skip to content

Commit d6ec133

Browse files
committed
Merge remote-tracking branch 'origin/main' into mtewani/add-more-integration-tests
2 parents 8e3ab83 + af9f8b5 commit d6ec133

30 files changed

+759
-472
lines changed

.changeset/angry-scissors-sit.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/ai': minor
4+
---
5+
6+
Add support for `minItems` and `maxItems` to `Schema`.

.changeset/tricky-years-pump.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'firebase': minor
3+
'@firebase/ai': minor
4+
---
5+
6+
Add `title`, `maximum`, `minimum`, `propertyOrdering` to Schema builder

.github/workflows/e2e-test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ jobs:
3030

3131
defaults:
3232
run:
33-
# Run any command steps in the /e2e subdir
34-
working-directory: './e2e'
33+
# Run any command steps in the /e2e/smoke-tests subdir
34+
working-directory: './e2e/smoke-tests'
3535

3636
steps:
3737
- name: Checkout Repo
@@ -53,7 +53,9 @@ jobs:
5353
- name: Poll npm until version to test is available for install
5454
run: |
5555
echo "Polling npm for firebase@${{ github.event.client_payload.versionOrTag }}"
56-
node ../scripts/release/poll-npm-publish.js
56+
node ./scripts/release/poll-npm-publish.js
57+
# run in root
58+
working-directory: '.'
5759
env:
5860
VERSION: ${{ github.event.client_payload.versionOrTag }}
5961
- name: Yarn install

common/api-review/ai.api.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,8 @@ export enum HarmBlockThreshold {
518518
BLOCK_LOW_AND_ABOVE = "BLOCK_LOW_AND_ABOVE",
519519
BLOCK_MEDIUM_AND_ABOVE = "BLOCK_MEDIUM_AND_ABOVE",
520520
BLOCK_NONE = "BLOCK_NONE",
521-
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH"
521+
BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH",
522+
OFF = "OFF"
522523
}
523524

524525
// @public
@@ -790,6 +791,9 @@ export abstract class Schema implements SchemaInterface {
790791
format?: string;
791792
// (undocumented)
792793
static integer(integerParams?: SchemaParams): IntegerSchema;
794+
items?: SchemaInterface;
795+
maxItems?: number;
796+
minItems?: number;
793797
nullable: boolean;
794798
// (undocumented)
795799
static number(numberParams?: SchemaParams): NumberSchema;
@@ -831,10 +835,16 @@ export interface SchemaShared<T> {
831835
example?: unknown;
832836
format?: string;
833837
items?: T;
838+
maximum?: number;
839+
maxItems?: number;
840+
minimum?: number;
841+
minItems?: number;
834842
nullable?: boolean;
835843
properties?: {
836844
[k: string]: T;
837845
};
846+
propertyOrdering?: string[];
847+
title?: string;
838848
}
839849

840850
// @public

docs-devsite/ai.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ export declare const enum AIErrorCode
448448
| INVALID\_CONTENT | <code>&quot;invalid-content&quot;</code> | An error associated with a Content object. |
449449
| INVALID\_SCHEMA | <code>&quot;invalid-schema&quot;</code> | An error due to invalid Schema input. |
450450
| NO\_API\_KEY | <code>&quot;no-api-key&quot;</code> | An error occurred due to a missing Firebase API key. |
451-
| NO\_APP\_ID | <code>&quot;no-app-id&quot;</code> | An error occured due to a missing Firebase app ID. |
451+
| NO\_APP\_ID | <code>&quot;no-app-id&quot;</code> | An error occurred due to a missing Firebase app ID. |
452452
| NO\_MODEL | <code>&quot;no-model&quot;</code> | An error occurred due to a model name not being specified during initialization. |
453453
| NO\_PROJECT\_ID | <code>&quot;no-project-id&quot;</code> | An error occurred due to a missing project ID. |
454454
| PARSE\_FAILED | <code>&quot;parse-failed&quot;</code> | An error occurred while parsing. |
455455
| REQUEST\_ERROR | <code>&quot;request-error&quot;</code> | An error occurred in a request. |
456456
| RESPONSE\_ERROR | <code>&quot;response-error&quot;</code> | An error occurred in a response. |
457-
| UNSUPPORTED | <code>&quot;unsupported&quot;</code> | An error occured due an attempt to use an unsupported feature. |
457+
| UNSUPPORTED | <code>&quot;unsupported&quot;</code> | An error occurred due an attempt to use an unsupported feature. |
458458

459459
## BlockReason
460460

@@ -551,6 +551,7 @@ export declare enum HarmBlockThreshold
551551
| BLOCK\_MEDIUM\_AND\_ABOVE | <code>&quot;BLOCK_MEDIUM_AND_ABOVE&quot;</code> | Content with <code>NEGLIGIBLE</code> and <code>LOW</code> will be allowed. |
552552
| BLOCK\_NONE | <code>&quot;BLOCK_NONE&quot;</code> | All content will be allowed. |
553553
| BLOCK\_ONLY\_HIGH | <code>&quot;BLOCK_ONLY_HIGH&quot;</code> | Content with <code>NEGLIGIBLE</code>, <code>LOW</code>, and <code>MEDIUM</code> will be allowed. |
554+
| OFF | <code>&quot;OFF&quot;</code> | All content will be allowed. This is the same as <code>BLOCK_NONE</code>, but the metadata corresponding to the [HarmCategory](./ai.md#harmcategory) will not be present in the response. |
554555

555556
## HarmCategory
556557

docs-devsite/ai.schema.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export declare abstract class Schema implements SchemaInterface
3232
| [description](./ai.schema.md#schemadescription) | | string | Optional. The description of the property. |
3333
| [example](./ai.schema.md#schemaexample) | | unknown | Optional. The example of the property. |
3434
| [format](./ai.schema.md#schemaformat) | | string | 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> |
35+
| [items](./ai.schema.md#schemaitems) | | [SchemaInterface](./ai.schemainterface.md#schemainterface_interface) | Optional. The items of the property. |
36+
| [maxItems](./ai.schema.md#schemamaxitems) | | number | The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->. |
37+
| [minItems](./ai.schema.md#schemaminitems) | | number | The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->. |
3538
| [nullable](./ai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. |
3639
| [type](./ai.schema.md#schematype) | | [SchemaType](./ai.md#schematype) | Optional. The type of the property. [SchemaType](./ai.md#schematype)<!-- -->. |
3740
@@ -93,6 +96,36 @@ Optional. The format of the property. Supported formats:<br/> <ul> <li>for NUMBE
9396
format?: string;
9497
```
9598
99+
## Schema.items
100+
101+
Optional. The items of the property.
102+
103+
<b>Signature:</b>
104+
105+
```typescript
106+
items?: SchemaInterface;
107+
```
108+
109+
## Schema.maxItems
110+
111+
The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->.
112+
113+
<b>Signature:</b>
114+
115+
```typescript
116+
maxItems?: number;
117+
```
118+
119+
## Schema.minItems
120+
121+
The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->.
122+
123+
<b>Signature:</b>
124+
125+
```typescript
126+
minItems?: number;
127+
```
128+
96129
## Schema.nullable
97130
98131
Optional. Whether the property is nullable. Defaults to false.

docs-devsite/ai.schemashared.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@ export interface SchemaShared<T>
2727
| [example](./ai.schemashared.md#schemasharedexample) | unknown | Optional. The example of the property. |
2828
| [format](./ai.schemashared.md#schemasharedformat) | string | Optional. The format of the property. When using the Gemini Developer API ([GoogleAIBackend](./ai.googleaibackend.md#googleaibackend_class)<!-- -->), this must be either <code>'enum'</code> or <code>'date-time'</code>, otherwise requests will fail. |
2929
| [items](./ai.schemashared.md#schemashareditems) | T | Optional. The items of the property. |
30+
| [maximum](./ai.schemashared.md#schemasharedmaximum) | number | The maximum value of a numeric type. |
31+
| [maxItems](./ai.schemashared.md#schemasharedmaxitems) | number | The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->. |
32+
| [minimum](./ai.schemashared.md#schemasharedminimum) | number | The minimum value of a numeric type. |
33+
| [minItems](./ai.schemashared.md#schemasharedminitems) | number | The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->. |
3034
| [nullable](./ai.schemashared.md#schemasharednullable) | boolean | Optional. Whether the property is nullable. |
3135
| [properties](./ai.schemashared.md#schemasharedproperties) | { \[k: string\]: T; } | Optional. Map of <code>Schema</code> objects. |
36+
| [propertyOrdering](./ai.schemashared.md#schemasharedpropertyordering) | string\[\] | A hint suggesting the order in which the keys should appear in the generated JSON string. |
37+
| [title](./ai.schemashared.md#schemasharedtitle) | string | The title of the property. This helps document the schema's purpose but does not typically constrain the generated value. It can subtly guide the model by clarifying the intent of a field. |
3238

3339
## SchemaShared.description
3440

@@ -80,6 +86,46 @@ Optional. The items of the property.
8086
items?: T;
8187
```
8288

89+
## SchemaShared.maximum
90+
91+
The maximum value of a numeric type.
92+
93+
<b>Signature:</b>
94+
95+
```typescript
96+
maximum?: number;
97+
```
98+
99+
## SchemaShared.maxItems
100+
101+
The maximum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->.
102+
103+
<b>Signature:</b>
104+
105+
```typescript
106+
maxItems?: number;
107+
```
108+
109+
## SchemaShared.minimum
110+
111+
The minimum value of a numeric type.
112+
113+
<b>Signature:</b>
114+
115+
```typescript
116+
minimum?: number;
117+
```
118+
119+
## SchemaShared.minItems
120+
121+
The minimum number of items (elements) in a schema of type [SchemaType.ARRAY](./ai.md#schematypearray_enummember)<!-- -->.
122+
123+
<b>Signature:</b>
124+
125+
```typescript
126+
minItems?: number;
127+
```
128+
83129
## SchemaShared.nullable
84130

85131
Optional. Whether the property is nullable.
@@ -101,3 +147,23 @@ properties?: {
101147
[k: string]: T;
102148
};
103149
```
150+
151+
## SchemaShared.propertyOrdering
152+
153+
A hint suggesting the order in which the keys should appear in the generated JSON string.
154+
155+
<b>Signature:</b>
156+
157+
```typescript
158+
propertyOrdering?: string[];
159+
```
160+
161+
## SchemaShared.title
162+
163+
The title of the property. This helps document the schema's purpose but does not typically constrain the generated value. It can subtly guide the model by clarifying the intent of a field.
164+
165+
<b>Signature:</b>
166+
167+
```typescript
168+
title?: string;
169+
```

e2e/README.md

Lines changed: 7 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,11 @@
1-
# Firebase JS SDK E2E Tests
1+
# E2E Tests
22

3-
This directory contains end-to-end tests for the Firebase JS SDK package as well as minimal quick start sample apps for debugging and development.
3+
This directory is for Firebase E2E tests that are completely independent of the main SDK workspaces. Packages in here should:
44

5-
## E2E Tests
5+
* Have a start trigger independent of the main CI PR/push triggers (e.g., manual trigger, repository_dispatch, from an external runner like Kokoro, etc.)
6+
7+
A common use case might be to clone this repo, cd into the chosen directory under e2e, npm install, and run npm scripts.
68

7-
### Setup
9+
* Have a self-contained set of NPM dependencies. They should not depend on the local version of Firebase in the SDK nor assume inherited availability of any packages in the top level package.json of this repo (typescript, firebase, karma, etc.).
810

9-
Before running the tests, you will need:
10-
11-
- a project config
12-
- a test user with an email/password login which has read/write privileges for Storage, Realtime Database, and Firestore
13-
- an App Check debug token
14-
- to deploy the `callTest` Cloud Function
15-
16-
#### Project Config and Test User
17-
18-
Create a file named `firebase-config.js` in the top level of this `e2e/` directory. The contents of the file should be:
19-
20-
```javascript
21-
// A config for a project
22-
export const config = {
23-
apiKey: ************,
24-
authDomain: ************,
25-
databaseURL: ************,
26-
projectId: ************,
27-
storageBucket: ************,
28-
messagingSenderId: ************,
29-
appId: ************,
30-
measurementId: ************
31-
};
32-
*
33-
// A user account with read/write privileges in that project
34-
// for storage, database, firestore
35-
export const testAccount = {
36-
email: ************,
37-
password: ************
38-
}
39-
```
40-
41-
#### App Check Debug Token
42-
43-
Create an App Check debug token in the Firebase Console. Assign it to an environment variable in your shell named `APP_CHECK_DEBUG_TOKEN`.
44-
45-
#### Deploy `callTest` Cloud Function
46-
47-
From the top level of the firebase repo, ensure you have the Firebase CLI (`firebase-tools`) installed (if not, `npm install -g firebase-tools`).
48-
49-
Ensure you are logged in using the CLI (`firebase login`);
50-
51-
Then deploy the function with:
52-
`firebase deploy --only functions:callTest --project YOUR_PROJECT_ID`
53-
54-
### Running the Tests
55-
56-
To run the tests on the default modular API:
57-
58-
```
59-
yarn test:modular
60-
```
61-
62-
To run the tests on the compat API:
63-
64-
```
65-
yarn test:compat
66-
```
67-
68-
## Sample Apps
69-
70-
Two minimal sample apps are provided for quick debugging and development. These apps import and initialize every product in the SDK and call some basic methods. Products can easily be commented out to focus on one or more products you are interested in looking at.
71-
72-
### Setup
73-
74-
The setup is the same as for the E2E tests above. Certain tests can be skipped if you are commenting out that product (e.g, no need to deploy the Cloud Function if you are commenting out the `callFunctions()` line in the sample app, and no need to set the App Check debug token env variable if not using App Check).
75-
76-
### Running Sample Apps
77-
78-
To run the modular sample app (uses current default version of the API):
79-
80-
```
81-
yarn start:modular
82-
```
83-
84-
Then open `localhost:8080` in a browser.
85-
86-
To run the compat sample app (uses current compat version of the API):
87-
88-
```
89-
yarn start:compat
90-
```
91-
92-
Then open `localhost:8080` in a browser.
11+
See the `template/` directory for an example.
File renamed without changes.

0 commit comments

Comments
 (0)