From c04d9ef0b958586bf6b314bdca3643251891d642 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 3 Sep 2024 14:13:28 -0700 Subject: [PATCH 01/21] Add node engines fields specifying a minimum of 18 (#8457) --- config/functions/package.json | 2 +- e2e/package.json | 3 +++ integration/compat-interop/package.json | 3 +++ integration/compat-typings/package.json | 5 ++++- integration/firebase/package.json | 3 +++ integration/firestore/package.json | 3 +++ integration/messaging/package.json | 3 +++ package.json | 2 +- packages/app-check-compat/package.json | 3 +++ packages/app-check/package.json | 3 +++ packages/app-compat/package.json | 3 +++ packages/app/package.json | 3 +++ packages/auth-compat/package.json | 3 +++ packages/auth/internal/package.json | 5 ++++- packages/auth/package.json | 3 +++ packages/component/package.json | 3 +++ packages/database-compat/package.json | 3 +++ packages/database/package.json | 3 +++ packages/firestore-compat/package.json | 3 +++ packages/firestore/lite/package.json | 5 ++++- packages/firestore/package.json | 2 +- packages/functions-compat/package.json | 3 +++ packages/functions/package.json | 3 +++ packages/logger/package.json | 3 +++ packages/rules-unit-testing/package.json | 2 +- packages/storage-compat/package.json | 3 +++ packages/storage/package.json | 5 ++++- packages/util/package.json | 3 +++ repo-scripts/api-documenter/package.json | 3 +++ repo-scripts/changelog-generator/package.json | 3 +++ repo-scripts/prune-dts/package.json | 2 +- repo-scripts/size-analysis/package.json | 3 +++ 32 files changed, 90 insertions(+), 9 deletions(-) diff --git a/config/functions/package.json b/config/functions/package.json index 08a79673e85..9a032e8bb95 100644 --- a/config/functions/package.json +++ b/config/functions/package.json @@ -8,6 +8,6 @@ }, "private": true, "engines": { - "node": "16" + "node": ">=18.0.0" } } diff --git a/e2e/package.json b/e2e/package.json index 54a4ca3f292..676498d6142 100644 --- a/e2e/package.json +++ b/e2e/package.json @@ -38,5 +38,8 @@ "webpack": "5.76.0", "webpack-cli": "4.10.0", "webpack-dev-server": "4.11.1" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/integration/compat-interop/package.json b/integration/compat-interop/package.json index 51c0fb6dac3..15f1bbc093b 100644 --- a/integration/compat-interop/package.json +++ b/integration/compat-interop/package.json @@ -25,5 +25,8 @@ }, "devDependencies": { "typescript": "4.7.4" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/integration/compat-typings/package.json b/integration/compat-typings/package.json index 11639312c27..9c0802f888d 100644 --- a/integration/compat-typings/package.json +++ b/integration/compat-typings/package.json @@ -11,5 +11,8 @@ }, "devDependencies": { "typescript": "4.7.4" + }, + "engines": { + "node": ">=18.0.0" } -} \ No newline at end of file +} diff --git a/integration/firebase/package.json b/integration/firebase/package.json index 94f1ed92d18..cc366727331 100644 --- a/integration/firebase/package.json +++ b/integration/firebase/package.json @@ -21,5 +21,8 @@ "mocha": "9.2.2", "npm-run-all": "4.1.5", "typescript": "4.7.4" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/integration/firestore/package.json b/integration/firestore/package.json index c33098fadc8..d308054080f 100644 --- a/integration/firestore/package.json +++ b/integration/firestore/package.json @@ -32,5 +32,8 @@ "typescript": "4.2.2", "webpack": "5.76.0", "webpack-stream": "7.0.0" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/integration/messaging/package.json b/integration/messaging/package.json index bd32daa7f21..864faa99987 100644 --- a/integration/messaging/package.json +++ b/integration/messaging/package.json @@ -17,5 +17,8 @@ "mocha": "9.2.2", "undici": "6.19.7", "selenium-assistant": "6.1.1" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/package.json b/package.json index 32d8e78eeb9..18ddbe42bff 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "author": "Firebase (https://firebase.google.com/)", "license": "Apache-2.0", "engines": { - "node": "^8.13.0 || >=10.10.0" + "node": ">=18.0.0" }, "homepage": "https://github.com/firebase/firebase-js-sdk", "keywords": [ diff --git a/packages/app-check-compat/package.json b/packages/app-check-compat/package.json index e543238f178..f611e7c1f8a 100644 --- a/packages/app-check-compat/package.json +++ b/packages/app-check-compat/package.json @@ -67,5 +67,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/app-check/package.json b/packages/app-check/package.json index 0d9150788ca..9a1a3719570 100644 --- a/packages/app-check/package.json +++ b/packages/app-check/package.json @@ -68,5 +68,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/app-compat/package.json b/packages/app-compat/package.json index 711b8a4d745..4bbd3654661 100644 --- a/packages/app-compat/package.json +++ b/packages/app-compat/package.json @@ -68,5 +68,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/app/package.json b/packages/app/package.json index 9c0960e8765..c9260501894 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -68,5 +68,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index 770b0438d63..6db6e7ba89d 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -82,5 +82,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/auth/internal/package.json b/packages/auth/internal/package.json index 8dd06ec9378..41b63d2c841 100644 --- a/packages/auth/internal/package.json +++ b/packages/auth/internal/package.json @@ -6,5 +6,8 @@ "browser": "../dist/esm2017/internal.js", "esm5": "../dist/esm5/internal.js", "typings": "../dist/esm5/internal/index.d.ts", - "private": true + "private": true, + "engines": { + "node": ">=18.0.0" + } } diff --git a/packages/auth/package.json b/packages/auth/package.json index add928154b5..7d41b0c5962 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -161,5 +161,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/component/package.json b/packages/component/package.json index 299dd180bb9..ade6f93a347 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -56,5 +56,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/database-compat/package.json b/packages/database-compat/package.json index 8a6cea9ecca..1c94b81c892 100644 --- a/packages/database-compat/package.json +++ b/packages/database-compat/package.json @@ -69,5 +69,8 @@ }, "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/database/package.json b/packages/database/package.json index a5a85cdfe38..f20c985e4c1 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -78,5 +78,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/firestore-compat/package.json b/packages/firestore-compat/package.json index 1c89fe5f567..1150383985a 100644 --- a/packages/firestore-compat/package.json +++ b/packages/firestore-compat/package.json @@ -74,5 +74,8 @@ }, "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/firestore/lite/package.json b/packages/firestore/lite/package.json index dbef6c78d6c..b36ddf80218 100644 --- a/packages/firestore/lite/package.json +++ b/packages/firestore/lite/package.json @@ -8,5 +8,8 @@ "react-native": "../dist/lite/index.rn.esm2017.js", "esm5": "../dist/lite/index.browser.esm5.js", "typings": "../dist/lite/index.d.ts", - "private": true + "private": true, + "engines": { + "node": ">=18.0.0" + } } diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 5547161658b..1ba59e3a8dd 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -2,7 +2,7 @@ "name": "@firebase/firestore", "version": "4.7.0", "engines": { - "node": ">=10.10.0" + "node": ">=18.0.0" }, "description": "The Cloud Firestore component of the Firebase JS SDK.", "author": "Firebase (https://firebase.google.com/)", diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 3b1f030d7a2..5ff623872f8 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -75,5 +75,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/functions/package.json b/packages/functions/package.json index f69d514b376..3ede8a4c3f9 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -80,5 +80,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/logger/package.json b/packages/logger/package.json index 17e64c678d1..931cdd4b5bb 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -55,5 +55,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/rules-unit-testing/package.json b/packages/rules-unit-testing/package.json index 70e5b522683..4053cca8e17 100644 --- a/packages/rules-unit-testing/package.json +++ b/packages/rules-unit-testing/package.json @@ -20,7 +20,7 @@ "./package.json": "./package.json" }, "engines": { - "node": ">=10.10.0" + "node": ">=18.0.0" }, "files": [ "dist" diff --git a/packages/storage-compat/package.json b/packages/storage-compat/package.json index badc250a141..bcbd3b55f72 100644 --- a/packages/storage-compat/package.json +++ b/packages/storage-compat/package.json @@ -63,5 +63,8 @@ }, "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/packages/storage/package.json b/packages/storage/package.json index cb8fdd48a55..94453f9fce8 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -73,5 +73,8 @@ "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" }, - "typings": "dist/src/index.d.ts" + "typings": "dist/src/index.d.ts", + "engines": { + "node": ">=18.0.0" + } } diff --git a/packages/util/package.json b/packages/util/package.json index 6d97f6e4795..24608ab537e 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -65,5 +65,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/repo-scripts/api-documenter/package.json b/repo-scripts/api-documenter/package.json index 1e6b1a9ac21..b824be66e65 100644 --- a/repo-scripts/api-documenter/package.json +++ b/repo-scripts/api-documenter/package.json @@ -34,5 +34,8 @@ "@types/js-yaml": "4.0.9", "@types/resolve": "1.20.6", "mocha-chai-jest-snapshot": "1.1.3" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/repo-scripts/changelog-generator/package.json b/repo-scripts/changelog-generator/package.json index f4afc131d1f..5d791be54bf 100644 --- a/repo-scripts/changelog-generator/package.json +++ b/repo-scripts/changelog-generator/package.json @@ -39,5 +39,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } diff --git a/repo-scripts/prune-dts/package.json b/repo-scripts/prune-dts/package.json index d8d4ab6391b..8b1128b29b0 100644 --- a/repo-scripts/prune-dts/package.json +++ b/repo-scripts/prune-dts/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "engines": { - "node": "^8.13.0 || >=10.10.0" + "node": ">=18.0.0" }, "description": "A script to prune non-exported types from a d.ts.", "author": "Firebase (https://firebase.google.com/)", diff --git a/repo-scripts/size-analysis/package.json b/repo-scripts/size-analysis/package.json index 25baa22bbce..8dd43345720 100644 --- a/repo-scripts/size-analysis/package.json +++ b/repo-scripts/size-analysis/package.json @@ -57,5 +57,8 @@ ".ts" ], "reportDir": "./coverage/node" + }, + "engines": { + "node": ">=18.0.0" } } From a377fb2fb643e2454f6de4242368b3e12699df1d Mon Sep 17 00:00:00 2001 From: wu-hui <53845758+wu-hui@users.noreply.github.com> Date: Mon, 9 Sep 2024 18:10:41 -0400 Subject: [PATCH 02/21] Make memory lru gc the default (#8110) * Make memory lru gc the default * undo yarn.lock * Make memory lru gc the default * Fix tests --- packages/firestore/src/api/cache_config.ts | 4 +++- packages/firestore/src/core/firestore_client.ts | 3 ++- .../firestore/test/integration/api/database.test.ts | 13 +++++++++++++ packages/firestore/test/integration/util/helpers.ts | 4 +--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/firestore/src/api/cache_config.ts b/packages/firestore/src/api/cache_config.ts index 1007023b2d7..030828b593e 100644 --- a/packages/firestore/src/api/cache_config.ts +++ b/packages/firestore/src/api/cache_config.ts @@ -62,7 +62,9 @@ class MemoryLocalCacheImpl implements MemoryLocalCache { this._offlineComponentProvider = settings.garbageCollector._offlineComponentProvider; } else { - this._offlineComponentProvider = new MemoryOfflineComponentProvider(); + this._offlineComponentProvider = new LruGcMemoryOfflineComponentProvider( + undefined + ); } } diff --git a/packages/firestore/src/core/firestore_client.ts b/packages/firestore/src/core/firestore_client.ts index 6e21737380b..a8a4453123c 100644 --- a/packages/firestore/src/core/firestore_client.ts +++ b/packages/firestore/src/core/firestore_client.ts @@ -64,6 +64,7 @@ import { Aggregate } from './aggregate'; import { NamedQuery } from './bundle'; import { ComponentConfiguration, + LruGcMemoryOfflineComponentProvider, MemoryOfflineComponentProvider, OfflineComponentProvider, OnlineComponentProvider @@ -339,7 +340,7 @@ async function ensureOfflineComponents( logDebug(LOG_TAG, 'Using default OfflineComponentProvider'); await setOfflineComponentProvider( client, - new MemoryOfflineComponentProvider() + new LruGcMemoryOfflineComponentProvider(undefined) ); } } diff --git a/packages/firestore/test/integration/api/database.test.ts b/packages/firestore/test/integration/api/database.test.ts index eda3978dd46..b37e8a911a4 100644 --- a/packages/firestore/test/integration/api/database.test.ts +++ b/packages/firestore/test/integration/api/database.test.ts @@ -2212,4 +2212,17 @@ apiDescribe('Database', persistence => { }); }); }); + + it('Lru GC is enabled by default.', () => { + const initialData = { key: 'value' }; + return withTestDb(persistence, async db => { + const docRef = doc(collection(db, 'test-collection')); + await setDoc(docRef, initialData); + return getDocFromCache(docRef).then(doc => { + expect(doc.exists()).to.be.true; + expect(doc.metadata.fromCache).to.be.true; + expect(doc.data()).to.deep.equal(initialData); + }); + }); + }); }); diff --git a/packages/firestore/test/integration/util/helpers.ts b/packages/firestore/test/integration/util/helpers.ts index 647360db463..465bc8edd61 100644 --- a/packages/firestore/test/integration/util/helpers.ts +++ b/packages/firestore/test/integration/util/helpers.ts @@ -181,9 +181,7 @@ function apiDescribeInternal( message: string, testSuite: (persistence: PersistenceMode) => void ): void { - const persistenceModes: PersistenceMode[] = [ - new MemoryEagerPersistenceMode() - ]; + const persistenceModes: PersistenceMode[] = [new MemoryLruPersistenceMode()]; if (isPersistenceAvailable()) { persistenceModes.push(new IndexedDbPersistenceMode()); } From c8937e72476398ca8223f60ae5a10566df849505 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 15:53:48 -0400 Subject: [PATCH 03/21] V11 release removal of node-fetch and undici dependencies (#8492) Our v11 release will require node 18+. Since fetch has been introduced in these node versions, we can remove our dependency on third party fetch implementations. This change removes our usage of fetch variants undici and node-fetch for our node target builds and our CI tools. --- .changeset/plenty-beers-decide.md | 13 ++++ integration/messaging/package.json | 1 - .../messaging/test/utils/sendMessage.js | 3 +- package.json | 1 - packages/auth-compat/index.node.ts | 11 +-- packages/auth-compat/karma.conf.js | 12 --- packages/auth-compat/package.json | 1 - packages/auth/karma.conf.js | 11 --- packages/auth/package.json | 1 - packages/auth/src/platform_node/index.ts | 11 +-- .../integration/emulator_rest_helpers.ts | 8 +- packages/firestore/package.json | 1 - .../src/platform/browser_lite/connection.ts | 2 +- .../platform/browser_lite/fetch_connection.ts | 14 +--- .../src/platform/node_lite/connection.ts | 7 +- packages/functions/karma.conf.js | 13 +--- packages/functions/package.json | 1 - packages/functions/src/config.ts | 8 +- packages/functions/src/index.node.ts | 5 +- packages/functions/src/index.ts | 2 +- packages/functions/src/service.ts | 10 +-- packages/functions/test/utils.ts | 6 +- packages/rules-unit-testing/package.json | 4 - .../rules-unit-testing/src/impl/discovery.ts | 5 +- packages/rules-unit-testing/src/impl/rules.ts | 1 - .../src/impl/test_environment.ts | 1 - packages/rules-unit-testing/src/util.ts | 1 - .../test/impl/discovery.test.ts | 2 +- packages/rules-unit-testing/test/util.test.ts | 4 +- packages/storage/package.json | 1 - .../storage/src/platform/node/connection.ts | 8 +- packages/storage/test/node/connection.test.ts | 4 +- repo-scripts/changelog-generator/index.ts | 5 +- repo-scripts/changelog-generator/package.json | 3 +- .../emulator-testing/emulators/emulator.ts | 74 ++++++++++++------- yarn.lock | 36 ++------- 36 files changed, 102 insertions(+), 189 deletions(-) create mode 100644 .changeset/plenty-beers-decide.md diff --git a/.changeset/plenty-beers-decide.md b/.changeset/plenty-beers-decide.md new file mode 100644 index 00000000000..87bc58c3589 --- /dev/null +++ b/.changeset/plenty-beers-decide.md @@ -0,0 +1,13 @@ +--- +'@firebase/rules-unit-testing': patch +'@firebase/firestore-compat': patch +'@firebase/functions-compat': patch +'@firebase/storage-compat': patch +'@firebase/auth-compat': patch +'@firebase/firestore': patch +'@firebase/functions': patch +'@firebase/storage': patch +'@firebase/auth': patch +--- + +Removed dependency on undici and node-fetch in our node bundles, replacing them with the native fetch implementation. diff --git a/integration/messaging/package.json b/integration/messaging/package.json index 864faa99987..f34637fba05 100644 --- a/integration/messaging/package.json +++ b/integration/messaging/package.json @@ -15,7 +15,6 @@ "express": "4.19.2", "geckodriver": "2.0.4", "mocha": "9.2.2", - "undici": "6.19.7", "selenium-assistant": "6.1.1" }, "engines": { diff --git a/integration/messaging/test/utils/sendMessage.js b/integration/messaging/test/utils/sendMessage.js index 1d2e95054eb..6393e90364c 100644 --- a/integration/messaging/test/utils/sendMessage.js +++ b/integration/messaging/test/utils/sendMessage.js @@ -15,7 +15,6 @@ * limitations under the License. */ -const undici = require('undici'); const FCM_SEND_ENDPOINT = 'https://fcm.googleapis.com/fcm/send'; // Rotatable fcm server key. It's generally a bad idea to expose server keys. The reason is to // simplify testing process (no need to implement server side decryption of git secret). The @@ -28,7 +27,7 @@ module.exports = async payload => { 'Requesting to send an FCM message with payload: ' + JSON.stringify(payload) ); - const response = await undici.fetch(FCM_SEND_ENDPOINT, { + const response = await fetch(FCM_SEND_ENDPOINT, { method: 'POST', body: JSON.stringify(payload), headers: { diff --git a/package.json b/package.json index 18ddbe42bff..41d92b74fb6 100644 --- a/package.json +++ b/package.json @@ -156,7 +156,6 @@ "tslint": "6.1.3", "typedoc": "0.16.11", "typescript": "4.7.4", - "undici": "6.19.7", "watch": "1.0.2", "webpack": "5.76.0", "yargs": "17.7.2" diff --git a/packages/auth-compat/index.node.ts b/packages/auth-compat/index.node.ts index 6d8dd2c07a5..1513148bea9 100644 --- a/packages/auth-compat/index.node.ts +++ b/packages/auth-compat/index.node.ts @@ -23,15 +23,6 @@ */ export * from './index'; import { FetchProvider } from '@firebase/auth/internal'; -import { - fetch as undiciFetch, - Headers as undiciHeaders, - Response as undiciResponse -} from 'undici'; import './index'; -FetchProvider.initialize( - undiciFetch as unknown as typeof fetch, - undiciHeaders as unknown as typeof Headers, - undiciResponse as unknown as typeof Response -); +FetchProvider.initialize(fetch, Headers, Response); diff --git a/packages/auth-compat/karma.conf.js b/packages/auth-compat/karma.conf.js index f3f14e8d1b1..6283ffbc3f1 100644 --- a/packages/auth-compat/karma.conf.js +++ b/packages/auth-compat/karma.conf.js @@ -30,18 +30,6 @@ module.exports = function (config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - }, - client: Object.assign({}, karmaBase.client, getClientConfig()) }); diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index 6db6e7ba89d..d6d5d9573b8 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -55,7 +55,6 @@ "@firebase/auth-types": "0.12.2", "@firebase/component": "0.6.8", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "license": "Apache-2.0", diff --git a/packages/auth/karma.conf.js b/packages/auth/karma.conf.js index 1d28c329f55..f8dcd5b0341 100644 --- a/packages/auth/karma.conf.js +++ b/packages/auth/karma.conf.js @@ -27,17 +27,6 @@ module.exports = function (config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - }, client: Object.assign({}, karmaBase.client, getClientConfig(argv)) }); diff --git a/packages/auth/package.json b/packages/auth/package.json index 7d41b0c5962..2dff1631c02 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -130,7 +130,6 @@ "@firebase/component": "0.6.8", "@firebase/logger": "0.4.2", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "license": "Apache-2.0", diff --git a/packages/auth/src/platform_node/index.ts b/packages/auth/src/platform_node/index.ts index 41da18ff643..67618b5b773 100644 --- a/packages/auth/src/platform_node/index.ts +++ b/packages/auth/src/platform_node/index.ts @@ -28,18 +28,9 @@ import { AuthImpl } from '../core/auth/auth_impl'; import { FetchProvider } from '../core/util/fetch_provider'; import { getDefaultEmulatorHost } from '@firebase/util'; -import { - fetch as undiciFetch, - Headers as undiciHeaders, - Response as undiciResponse -} from 'undici'; // Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best -FetchProvider.initialize( - undiciFetch as unknown as typeof fetch, - undiciHeaders as unknown as typeof Headers, - undiciResponse as unknown as typeof Response -); +FetchProvider.initialize(fetch, Headers, Response); // First, we set up the various platform-specific features for Node (register // the version and declare the Node getAuth function) diff --git a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts index 32b9aad2129..5a96d193ee1 100644 --- a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts +++ b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -import { fetch as undiciFetch, RequestInit as undiciRequestInit } from 'undici'; import { getAppConfig, getEmulatorUrl } from './settings'; export interface VerificationSession { @@ -88,9 +87,8 @@ function doFetch(url: string, request?: RequestInit): ReturnType { if (typeof document !== 'undefined') { return fetch(url, request); } else { - return undiciFetch( - url, - request as undiciRequestInit - ) as unknown as ReturnType; + return fetch(url, request as RequestInit) as unknown as ReturnType< + typeof fetch + >; } } diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 1ba59e3a8dd..5c630f7837e 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -103,7 +103,6 @@ "@firebase/webchannel-wrapper": "1.0.1", "@grpc/grpc-js": "~1.9.0", "@grpc/proto-loader": "^0.7.8", - "undici": "6.19.7", "tslib": "^2.1.0" }, "peerDependencies": { diff --git a/packages/firestore/src/platform/browser_lite/connection.ts b/packages/firestore/src/platform/browser_lite/connection.ts index a6464245441..573f743a882 100644 --- a/packages/firestore/src/platform/browser_lite/connection.ts +++ b/packages/firestore/src/platform/browser_lite/connection.ts @@ -24,5 +24,5 @@ export { newConnectivityMonitor } from '../browser/connection'; /** Initializes the HTTP connection for the REST API. */ export function newConnection(databaseInfo: DatabaseInfo): Connection { - return new FetchConnection(databaseInfo, fetch.bind(null)); + return new FetchConnection(databaseInfo); } diff --git a/packages/firestore/src/platform/browser_lite/fetch_connection.ts b/packages/firestore/src/platform/browser_lite/fetch_connection.ts index cad3c372ad5..d11247c8019 100644 --- a/packages/firestore/src/platform/browser_lite/fetch_connection.ts +++ b/packages/firestore/src/platform/browser_lite/fetch_connection.ts @@ -16,7 +16,6 @@ */ import { Token } from '../../api/credentials'; -import { DatabaseInfo } from '../../core/database_info'; import { Stream } from '../../remote/connection'; import { RestConnection } from '../../remote/rest_connection'; import { mapCodeFromHttpStatus } from '../../remote/rpc_error'; @@ -28,17 +27,6 @@ import { StringMap } from '../../util/types'; * (e.g. `fetch` or a polyfill). */ export class FetchConnection extends RestConnection { - /** - * @param databaseInfo - The connection info. - * @param fetchImpl - `fetch` or a Polyfill that implements the fetch API. - */ - constructor( - databaseInfo: DatabaseInfo, - private readonly fetchImpl: typeof fetch - ) { - super(databaseInfo); - } - openStream( rpcName: string, token: Token | null @@ -56,7 +44,7 @@ export class FetchConnection extends RestConnection { let response: Response; try { - response = await this.fetchImpl(url, { + response = await fetch(url, { method: 'POST', headers, body: requestJson diff --git a/packages/firestore/src/platform/node_lite/connection.ts b/packages/firestore/src/platform/node_lite/connection.ts index e85bb89bc97..7258661c184 100644 --- a/packages/firestore/src/platform/node_lite/connection.ts +++ b/packages/firestore/src/platform/node_lite/connection.ts @@ -15,8 +15,6 @@ * limitations under the License. */ -import { fetch as undiciFetch } from 'undici'; - import { DatabaseInfo } from '../../core/database_info'; import { Connection } from '../../remote/connection'; import { FetchConnection } from '../browser_lite/fetch_connection'; @@ -25,8 +23,5 @@ export { newConnectivityMonitor } from '../browser/connection'; /** Initializes the HTTP connection for the REST API. */ export function newConnection(databaseInfo: DatabaseInfo): Connection { - // undici is meant to be API compatible with `fetch`, but its type doesn't - // match 100%. - // eslint-disable-next-line @typescript-eslint/no-explicit-any - return new FetchConnection(databaseInfo, undiciFetch as any); + return new FetchConnection(databaseInfo); } diff --git a/packages/functions/karma.conf.js b/packages/functions/karma.conf.js index 3dc9b7d572c..db9bf05bfe0 100644 --- a/packages/functions/karma.conf.js +++ b/packages/functions/karma.conf.js @@ -26,18 +26,7 @@ module.exports = function (config) { files, // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - } + frameworks: ['mocha'] }); config.set(karmaConfig); diff --git a/packages/functions/package.json b/packages/functions/package.json index 3ede8a4c3f9..5be9917b301 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -72,7 +72,6 @@ "@firebase/auth-interop-types": "0.2.3", "@firebase/app-check-interop-types": "0.3.2", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "nyc": { diff --git a/packages/functions/src/config.ts b/packages/functions/src/config.ts index 6c4dac26e6a..656158da10d 100644 --- a/packages/functions/src/config.ts +++ b/packages/functions/src/config.ts @@ -35,10 +35,7 @@ const APP_CHECK_INTERNAL_NAME: AppCheckInternalComponentName = const MESSAGING_INTERNAL_NAME: MessagingInternalComponentName = 'messaging-internal'; -export function registerFunctions( - fetchImpl: typeof fetch, - variant?: string -): void { +export function registerFunctions(variant?: string): void { const factory: InstanceFactory<'functions'> = ( container: ComponentContainer, { instanceIdentifier: regionOrCustomDomain } @@ -55,8 +52,7 @@ export function registerFunctions( authProvider, messagingProvider, appCheckProvider, - regionOrCustomDomain, - fetchImpl + regionOrCustomDomain ); }; diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index 6fb63173957..6b1a2ee2939 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -15,9 +15,8 @@ * limitations under the License. */ import { registerFunctions } from './config'; -import { fetch as undiciFetch } from 'undici'; export * from './api'; +export * from './public-types'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any -registerFunctions(undiciFetch as any, 'node'); +registerFunctions('node'); diff --git a/packages/functions/src/index.ts b/packages/functions/src/index.ts index 7318b3e64b7..6d404cc8245 100644 --- a/packages/functions/src/index.ts +++ b/packages/functions/src/index.ts @@ -25,4 +25,4 @@ import { registerFunctions } from './config'; export * from './api'; export * from './public-types'; -registerFunctions(fetch.bind(self)); +registerFunctions(); diff --git a/packages/functions/src/service.ts b/packages/functions/src/service.ts index c5fe7fa8a85..986dcbc735d 100644 --- a/packages/functions/src/service.ts +++ b/packages/functions/src/service.ts @@ -104,8 +104,7 @@ export class FunctionsService implements _FirebaseService { authProvider: Provider, messagingProvider: Provider, appCheckProvider: Provider, - regionOrCustomDomain: string = DEFAULT_REGION, - readonly fetchImpl: typeof fetch + regionOrCustomDomain: string = DEFAULT_REGION ) { this.contextProvider = new ContextProvider( authProvider, @@ -212,14 +211,13 @@ export function httpsCallableFromURL( async function postJSON( url: string, body: unknown, - headers: { [key: string]: string }, - fetchImpl: typeof fetch + headers: { [key: string]: string } ): Promise { headers['Content-Type'] = 'application/json'; let response: Response; try { - response = await fetchImpl(url, { + response = await fetch(url, { method: 'POST', body: JSON.stringify(body), headers @@ -296,7 +294,7 @@ async function callAtURL( const failAfterHandle = failAfter(timeout); const response = await Promise.race([ - postJSON(url, body, headers, functionsInstance.fetchImpl), + postJSON(url, body, headers), failAfterHandle.promise, functionsInstance.cancelAllRequests ]); diff --git a/packages/functions/test/utils.ts b/packages/functions/test/utils.ts index 0eb0b678c19..bcf0286b49d 100644 --- a/packages/functions/test/utils.ts +++ b/packages/functions/test/utils.ts @@ -21,7 +21,6 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; import { FunctionsService } from '../src/service'; import { connectFunctionsEmulator } from '../src/api'; -import { fetch as undiciFetch } from 'undici'; import { MessagingInternalComponentName } from '../../../packages/messaging-interop-types'; export function makeFakeApp(options: FirebaseOptions = {}): FirebaseApp { @@ -58,15 +57,12 @@ export function createTestService( new ComponentContainer('test') ) ): FunctionsService { - const fetchImpl: typeof fetch = - typeof window !== 'undefined' ? fetch.bind(window) : (undiciFetch as any); const functions = new FunctionsService( app, authProvider, messagingProvider, appCheckProvider, - region, - fetchImpl + region ); const useEmulator = !!process.env.FIREBASE_FUNCTIONS_EMULATOR_ORIGIN; if (useEmulator) { diff --git a/packages/rules-unit-testing/package.json b/packages/rules-unit-testing/package.json index 4053cca8e17..585a0efc5e8 100644 --- a/packages/rules-unit-testing/package.json +++ b/packages/rules-unit-testing/package.json @@ -53,9 +53,5 @@ "typings": "dist/index.d.ts", "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" - }, - "dependencies": { - "node-fetch": "2.6.7", - "@types/node-fetch": "2.6.4" } } diff --git a/packages/rules-unit-testing/src/impl/discovery.ts b/packages/rules-unit-testing/src/impl/discovery.ts index 9798f017241..3c7c20fedad 100644 --- a/packages/rules-unit-testing/src/impl/discovery.ts +++ b/packages/rules-unit-testing/src/impl/discovery.ts @@ -16,7 +16,6 @@ */ import { EmulatorConfig, HostAndPort } from '../public_types'; -import nodeFetch from 'node-fetch'; import { makeUrl, fixHostname } from './url'; /** @@ -27,9 +26,9 @@ import { makeUrl, fixHostname } from './url'; */ export async function discoverEmulators( hub: HostAndPort, - fetch: typeof nodeFetch = nodeFetch + fetchImpl: typeof fetch = fetch ): Promise { - const res = await fetch(makeUrl(hub, '/emulators')); + const res = await fetchImpl(makeUrl(hub, '/emulators')); if (!res.ok) { throw new Error( `HTTP Error ${res.status} when attempting to reach Emulator Hub at ${res.url}, are you sure it is running?` diff --git a/packages/rules-unit-testing/src/impl/rules.ts b/packages/rules-unit-testing/src/impl/rules.ts index 7d4d900367f..fefeb586233 100644 --- a/packages/rules-unit-testing/src/impl/rules.ts +++ b/packages/rules-unit-testing/src/impl/rules.ts @@ -17,7 +17,6 @@ import { HostAndPort } from '../public_types'; import { makeUrl } from './url'; -import fetch from 'node-fetch'; /** * @private diff --git a/packages/rules-unit-testing/src/impl/test_environment.ts b/packages/rules-unit-testing/src/impl/test_environment.ts index cb325912c29..5e0f4c613fe 100644 --- a/packages/rules-unit-testing/src/impl/test_environment.ts +++ b/packages/rules-unit-testing/src/impl/test_environment.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -import fetch from 'node-fetch'; import firebase from 'firebase/compat/app'; import 'firebase/compat/firestore'; import 'firebase/compat/database'; diff --git a/packages/rules-unit-testing/src/util.ts b/packages/rules-unit-testing/src/util.ts index c96b22d8597..abcad41ef9b 100644 --- a/packages/rules-unit-testing/src/util.ts +++ b/packages/rules-unit-testing/src/util.ts @@ -21,7 +21,6 @@ import { } from './impl/discovery'; import { fixHostname, makeUrl } from './impl/url'; import { HostAndPort } from './public_types'; -import fetch from 'node-fetch'; /** * Run a setup function with background Cloud Functions triggers disabled. This can be used to diff --git a/packages/rules-unit-testing/test/impl/discovery.test.ts b/packages/rules-unit-testing/test/impl/discovery.test.ts index a2ac2be767b..39b5628ddc2 100644 --- a/packages/rules-unit-testing/test/impl/discovery.test.ts +++ b/packages/rules-unit-testing/test/impl/discovery.test.ts @@ -71,7 +71,7 @@ describe('discoverEmulators()', () => { // Connect to port:0. Should always fail (although error codes may differ among OSes). await expect( discoverEmulators({ host: '127.0.0.1', port: 0 }) - ).to.be.rejectedWith(/EADDRNOTAVAIL|ECONNREFUSED/); + ).to.be.rejectedWith(/EADDRNOTAVAIL|ECONNREFUSED|fetch failed/); }); it('throws if response status is not 2xx', async () => { diff --git a/packages/rules-unit-testing/test/util.test.ts b/packages/rules-unit-testing/test/util.test.ts index 9dc778fb93e..e3b514d6a10 100644 --- a/packages/rules-unit-testing/test/util.test.ts +++ b/packages/rules-unit-testing/test/util.test.ts @@ -165,7 +165,7 @@ describe('assertFails()', () => { describe('withFunctionTriggersDisabled()', () => { it('disabling function triggers does not throw, returns value', async function () { - const fetchSpy = sinon.spy(require('node-fetch'), 'default'); + const fetchSpy = sinon.spy(globalThis, 'fetch'); const res = await withFunctionTriggersDisabled(() => { return Promise.resolve(1234); @@ -176,7 +176,7 @@ describe('withFunctionTriggersDisabled()', () => { }); it('disabling function triggers always re-enables, event when the function throws', async function () { - const fetchSpy = sinon.spy(require('node-fetch'), 'default'); + const fetchSpy = sinon.spy(globalThis, 'fetch'); const res = withFunctionTriggersDisabled(() => { throw new Error('I throw!'); diff --git a/packages/storage/package.json b/packages/storage/package.json index 94453f9fce8..c588756199f 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -50,7 +50,6 @@ "dependencies": { "@firebase/util": "1.9.7", "@firebase/component": "0.6.8", - "undici": "6.19.7", "tslib": "^2.1.0" }, "peerDependencies": { diff --git a/packages/storage/src/platform/node/connection.ts b/packages/storage/src/platform/node/connection.ts index d7141e6ef68..c90f664c3b2 100644 --- a/packages/storage/src/platform/node/connection.ts +++ b/packages/storage/src/platform/node/connection.ts @@ -21,7 +21,6 @@ import { ErrorCode } from '../../implementation/connection'; import { internalError } from '../../implementation/error'; -import { fetch as undiciFetch, Headers as undiciHeaders } from 'undici'; /** An override for the text-based Connection. Used in tests. */ let textFactoryOverride: (() => Connection) | null = null; @@ -39,9 +38,8 @@ abstract class FetchConnection protected statusCode_: number | undefined; protected body_: ArrayBuffer | undefined; protected errorText_ = ''; - protected headers_: undiciHeaders | undefined; + protected headers_: Headers | undefined; protected sent_: boolean = false; - protected fetch_ = undiciFetch; constructor() { this.errorCode_ = ErrorCode.NO_ERROR; @@ -59,7 +57,7 @@ abstract class FetchConnection this.sent_ = true; try { - const response = await this.fetch_(url, { + const response = await fetch(url, { method, headers: headers || {}, body: body as NodeJS.ArrayBufferView | string @@ -163,7 +161,7 @@ export class FetchStreamConnection extends FetchConnection< this.sent_ = true; try { - const response = await this.fetch_(url, { + const response = await fetch(url, { method, headers: headers || {}, body: body as NodeJS.ArrayBufferView | string diff --git a/packages/storage/test/node/connection.test.ts b/packages/storage/test/node/connection.test.ts index 32c499f0209..925d1f8f7dc 100644 --- a/packages/storage/test/node/connection.test.ts +++ b/packages/storage/test/node/connection.test.ts @@ -24,9 +24,9 @@ describe('Connections', () => { it('FetchConnection.send() should not reject on network errors', async () => { const connection = new FetchBytesConnection(); - // need the casting here because fetch_ is a private member - stub(connection as any, 'fetch_').rejects(); + const fetchStub = stub(globalThis, 'fetch').rejects(); await connection.send('testurl', 'GET'); expect(connection.getErrorCode()).to.equal(ErrorCode.NETWORK_ERROR); + fetchStub.restore(); }); }); diff --git a/repo-scripts/changelog-generator/index.ts b/repo-scripts/changelog-generator/index.ts index 20f3de482f1..3570c8a96a5 100644 --- a/repo-scripts/changelog-generator/index.ts +++ b/repo-scripts/changelog-generator/index.ts @@ -17,7 +17,6 @@ import { ChangelogFunctions } from '@changesets/types'; import { getInfo } from '@changesets/get-github-info'; -import { fetch as undiciFetch, Response as undiciResponse } from 'undici'; const changelogFunctions: ChangelogFunctions = { getDependencyReleaseLine: async ( @@ -95,7 +94,7 @@ async function getFixedIssueLink( prNumber: number, repo: string ): Promise { - const response = await undiciFetch( + const response = await fetch( `https://api.github.com/repos/${repo}/pulls/${prNumber}`, { method: 'GET', @@ -105,7 +104,7 @@ async function getFixedIssueLink( } ).then(data => data.json()); - const body = (response as undiciResponse).body; + const body = (response as Response).body; if (!body) { return ''; } diff --git a/repo-scripts/changelog-generator/package.json b/repo-scripts/changelog-generator/package.json index 5d791be54bf..09313c27ed6 100644 --- a/repo-scripts/changelog-generator/package.json +++ b/repo-scripts/changelog-generator/package.json @@ -19,8 +19,7 @@ "dependencies": { "@changesets/types": "3.3.0", "@changesets/get-github-info": "0.5.2", - "@types/node": "20.8.10", - "undici": "6.19.7" + "@types/node": "20.8.10" }, "license": "Apache-2.0", "devDependencies": { diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 1295d413e4b..ba69e049ad6 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -21,7 +21,6 @@ import { ChildProcess } from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import fetch from 'node-fetch'; // @ts-ignore import * as tmp from 'tmp'; @@ -51,35 +50,60 @@ export abstract class Emulator { return new Promise((resolve, reject) => { tmp.dir((err: Error | null, dir: string) => { if (err) reject(err); - console.log(`Created temporary directory at [${dir}].`); const filepath: string = path.resolve(dir, this.binaryName); - const writeStream: fs.WriteStream = fs.createWriteStream(filepath); - + const writer = fs.createWriteStream(filepath); console.log(`Downloading emulator from [${this.binaryUrl}] ...`); - fetch(this.binaryUrl).then(resp => { - resp.body - .pipe(writeStream) - .on('finish', () => { - console.log(`Saved emulator binary file to [${filepath}].`); - // Change emulator binary file permission to 'rwxr-xr-x'. - // The execute permission is required for it to be able to start - // with 'java -jar'. - fs.chmod(filepath, 0o755, err => { - if (err) reject(err); - console.log( - `Changed emulator file permissions to 'rwxr-xr-x'.` - ); - this.binaryPath = filepath; - - if (this.copyToCache()) { - console.log(`Cached emulator at ${this.cacheBinaryPath}`); + // Map the DOM's fetch Reader to node's streaming file system + // operations. We will need to access class members `binaryPath` and `copyToCache` after the + // download completes. It's a compilation error to pass `this` into the named function + // `readChunk`, so the download operation is wrapped in a promise that we wait upon. + const downloadPromise = new Promise( + (downloadComplete, downloadFailed) => { + fetch(this.binaryUrl) + .then(resp => { + if (resp.status !== 200 || resp.body === null) { + console.log('Download of emulator failed: ', resp.statusText); + downloadFailed(); + } else { + const reader = resp.body.getReader(); + reader.read().then(function readChunk({ done, value }): any { + if (done) { + downloadComplete(); + } else { + writer.write(value); + return reader.read().then(readChunk); + } + }); } - resolve(); + }) + .catch(e => { + console.log(`Download of emulator failed: ${e}`); + downloadFailed(); }); - }) - .on('error', reject); - }); + } + ); + + downloadPromise.then( + () => { + console.log('Download complete'); + // Change emulator binary file permission to 'rwxr-xr-x'. + // The execute permission is required for it to be able to start + // with 'java -jar'. + fs.chmod(filepath, 0o755, err => { + if (err) reject(err); + console.log(`Changed emulator file permissions to 'rwxr-xr-x'.`); + this.binaryPath = filepath; + if (this.copyToCache()) { + console.log(`Cached emulator at ${this.cacheBinaryPath}`); + } + resolve(); + }); + }, + () => { + reject(); + } + ); }); }); } diff --git a/yarn.lock b/yarn.lock index 477e784871e..f3fc015f9ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3480,14 +3480,6 @@ dependencies: "@types/node" "*" -"@types/node-fetch@2.6.4": - version "2.6.4" - resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - "@types/node@*", "@types/node@>=10.0.0", "@types/node@^12.7.1": version "12.20.50" resolved "https://registry.npmjs.org/@types/node/-/node-12.20.50.tgz" @@ -8512,15 +8504,6 @@ form-data@^2.5.0: combined-stream "^1.0.6" mime-types "^2.1.12" -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - form-data@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" @@ -12852,13 +12835,6 @@ node-emoji@^1.11.0: dependencies: lodash "^4.17.21" -node-fetch@2.6.7, node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-fetch@^2.5.0, node-fetch@^2.6.1: version "2.6.5" resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz" @@ -12866,6 +12842,13 @@ node-fetch@^2.5.0, node-fetch@^2.6.1: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + node-forge@^0.10.0: version "0.10.0" resolved "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz" @@ -17388,11 +17371,6 @@ undici-types@~5.26.4: resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@6.19.7: - version "6.19.7" - resolved "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz#7d4cf26dc689838aa8b6753a3c5c4288fc1e0216" - integrity sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A== - unicode-canonical-property-names-ecmascript@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz" From d2534840791fb8b0eeee3192e91d79fed40ec442 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Mon, 23 Sep 2024 15:07:42 -0400 Subject: [PATCH 04/21] V11 - Remove functions node bundle (#8507) With the removal of fetch we no long need to create a node bundle for functions. Instead the sourcebase may become isomorphic, so long as we remove the older node sources. And that's what the PR does! --- .changeset/slimy-cups-promise.md | 6 +++++ packages/functions-compat/package.json | 8 +++---- packages/functions-compat/rollup.config.js | 19 +-------------- packages/functions-compat/src/index.node.ts | 23 ------------------ packages/functions/package.json | 8 +++---- packages/functions/rollup.config.js | 26 +-------------------- packages/functions/src/index.node.ts | 22 ----------------- 7 files changed, 16 insertions(+), 96 deletions(-) create mode 100644 .changeset/slimy-cups-promise.md delete mode 100644 packages/functions-compat/src/index.node.ts delete mode 100644 packages/functions/src/index.node.ts diff --git a/.changeset/slimy-cups-promise.md b/.changeset/slimy-cups-promise.md new file mode 100644 index 00000000000..9456c0d5b04 --- /dev/null +++ b/.changeset/slimy-cups-promise.md @@ -0,0 +1,6 @@ +--- +'@firebase/functions-compat': patch +'@firebase/functions': patch +--- + +Remove node bundle from the functions SDK as the node-specific fetch code has been removed in favor of using native fetch throughout the SDK. diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 584c7126c61..d30a085e30b 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -3,7 +3,7 @@ "version": "0.3.14", "description": "", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.node.cjs.js", + "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", @@ -11,8 +11,8 @@ ".": { "types": "./dist/src/index.d.ts", "node": { - "import": "./dist/node-esm/index.node.esm.js", - "require": "./dist/index.node.cjs.js" + "require": "./dist/index.cjs.js", + "import": "./dist/index.esm2017.js" }, "esm5": "./dist/index.esm5.js", "browser": { @@ -57,7 +57,7 @@ "test:all": "run-p --npm-path npm test:browser test:node", "test:browser": "karma start", "test:browser:debug": "karma start --browsers=Chrome --auto-watch", - "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js", + "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js", "test:emulator": "env FIREBASE_FUNCTIONS_HOST=http://localhost FIREBASE_FUNCTIONS_PORT=5005 run-p --npm-path npm test:node", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "add-compat-overloads": "ts-node-script ../../scripts/build/create-overloads.ts -i ../functions/dist/functions-public.d.ts -o dist/src/index.d.ts -a -r Functions:types.FirebaseFunctions -r FirebaseApp:FirebaseAppCompat --moduleToEnhance @firebase/functions" diff --git a/packages/functions-compat/rollup.config.js b/packages/functions-compat/rollup.config.js index 949aeebd513..53aad50475a 100644 --- a/packages/functions-compat/rollup.config.js +++ b/packages/functions-compat/rollup.config.js @@ -73,21 +73,4 @@ const browserBuilds = [ } ]; -const nodeBuilds = [ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - { - input: 'src/index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -export default [...browserBuilds, ...nodeBuilds]; +export default [...browserBuilds]; diff --git a/packages/functions-compat/src/index.node.ts b/packages/functions-compat/src/index.node.ts deleted file mode 100644 index e7b3c108ac4..00000000000 --- a/packages/functions-compat/src/index.node.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2020 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 firebase from '@firebase/app-compat'; -import { name, version } from '../package.json'; -import { registerFunctions } from './register'; - -registerFunctions(); -firebase.registerVersion(name, version, 'node'); diff --git a/packages/functions/package.json b/packages/functions/package.json index 62146df01c6..084bd1b28db 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -3,7 +3,7 @@ "version": "0.11.8", "description": "", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.node.cjs.js", + "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm.js", @@ -11,8 +11,8 @@ ".": { "types": "./dist/functions-public.d.ts", "node": { - "import": "./dist/esm-node/index.node.esm.js", - "require": "./dist/index.node.cjs.js" + "import": "./dist/index.esm2017.js", + "require": "./dist/index.cjs.js" }, "esm5": "./dist/index.esm.js", "browser": { @@ -38,7 +38,7 @@ "test:all": "run-p --npm-path npm test:browser test:node", "test:browser": "karma start", "test:browser:debug": "karma start --browsers=Chrome --auto-watch", - "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js", + "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.ts --config ../../config/mocharc.node.js", "test:emulator": "env FIREBASE_FUNCTIONS_EMULATOR_ORIGIN=http://localhost:5005 run-p --npm-path npm test:node", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "api-report": "api-extractor run --local --verbose", diff --git a/packages/functions/rollup.config.js b/packages/functions/rollup.config.js index bb5506ea9b5..4bc7f73d869 100644 --- a/packages/functions/rollup.config.js +++ b/packages/functions/rollup.config.js @@ -84,28 +84,4 @@ const browserBuilds = [ } ]; -const nodeBuilds = [ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - }, - { - input: 'src/index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)), - emitModulePackageFile() - ] - } -]; - -export default [...browserBuilds, ...nodeBuilds]; +export default [...browserBuilds]; diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts deleted file mode 100644 index 6b1a2ee2939..00000000000 --- a/packages/functions/src/index.node.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 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 { registerFunctions } from './config'; - -export * from './api'; -export * from './public-types'; - -registerFunctions('node'); From 097bd672367a1ebb9868730db99e859e3ee1b685 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 23 Sep 2024 16:28:39 -0700 Subject: [PATCH 05/21] Initial changes for Vertex GA packaging (#8498) --- .changeset/large-snakes-march.md | 6 ++++++ .github/workflows/canary-deploy.yml | 2 +- .github/workflows/prerelease-manual-deploy.yml | 2 +- .github/workflows/release-prod.yml | 2 +- .github/workflows/release-staging.yml | 2 +- ...vertexai-preview.api.md => vertexai.api.md} | 2 +- packages/firebase/package.json | 18 +++++++++--------- .../{vertexai-preview => vertexai}/index.ts | 2 +- .../package.json | 4 ++-- packages/vertexai/package.json | 8 ++++---- 10 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 .changeset/large-snakes-march.md rename common/api-review/{vertexai-preview.api.md => vertexai.api.md} (99%) rename packages/firebase/{vertexai-preview => vertexai}/index.ts (93%) rename packages/firebase/{vertexai-preview => vertexai}/package.json (55%) diff --git a/.changeset/large-snakes-march.md b/.changeset/large-snakes-march.md new file mode 100644 index 00000000000..947d6e0b278 --- /dev/null +++ b/.changeset/large-snakes-march.md @@ -0,0 +1,6 @@ +--- +'firebase': major +'@firebase/vertexai': major +--- + +Release VertexAI in Firebase for general availability. diff --git a/.github/workflows/canary-deploy.yml b/.github/workflows/canary-deploy.yml index 74364b49cd5..c74bbc78762 100644 --- a/.github/workflows/canary-deploy.yml +++ b/.github/workflows/canary-deploy.yml @@ -70,7 +70,7 @@ jobs: NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}} NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}} NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}} - NPM_TOKEN_VERTEXAI_PREVIEW: ${{secrets.NPM_TOKEN_VERTEXAI_PREVIEW}} + NPM_TOKEN_VERTEXAI: ${{secrets.NPM_TOKEN_VERTEXAI}} NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}} NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}} NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }} diff --git a/.github/workflows/prerelease-manual-deploy.yml b/.github/workflows/prerelease-manual-deploy.yml index a4a96f12e61..a5508db4709 100644 --- a/.github/workflows/prerelease-manual-deploy.yml +++ b/.github/workflows/prerelease-manual-deploy.yml @@ -73,7 +73,7 @@ jobs: NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}} NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}} NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}} - NPM_TOKEN_VERTEXAI_PREVIEW: ${{secrets.NPM_TOKEN_VERTEXAI_PREVIEW}} + NPM_TOKEN_VERTEXAI: ${{secrets.NPM_TOKEN_VERTEXAI}} NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}} NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}} NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }} diff --git a/.github/workflows/release-prod.yml b/.github/workflows/release-prod.yml index 910938c3903..0ff1a0b2185 100644 --- a/.github/workflows/release-prod.yml +++ b/.github/workflows/release-prod.yml @@ -83,7 +83,7 @@ jobs: NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}} NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}} NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}} - NPM_TOKEN_VERTEXAI_PREVIEW: ${{secrets.NPM_TOKEN_VERTEXAI_PREVIEW}} + NPM_TOKEN_VERTEXAI: ${{secrets.NPM_TOKEN_VERTEXAI}} NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}} NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}} NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }} diff --git a/.github/workflows/release-staging.yml b/.github/workflows/release-staging.yml index ee8eee1c0d1..3aa2716b5e2 100644 --- a/.github/workflows/release-staging.yml +++ b/.github/workflows/release-staging.yml @@ -109,7 +109,7 @@ jobs: NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}} NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}} NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}} - NPM_TOKEN_VERTEXAI_PREVIEW: ${{secrets.NPM_TOKEN_VERTEXAI_PREVIEW}} + NPM_TOKEN_VERTEXAI: ${{secrets.NPM_TOKEN_VERTEXAI}} NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}} NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}} NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }} diff --git a/common/api-review/vertexai-preview.api.md b/common/api-review/vertexai.api.md similarity index 99% rename from common/api-review/vertexai-preview.api.md rename to common/api-review/vertexai.api.md index c965bdde432..ff33d56f269 100644 --- a/common/api-review/vertexai-preview.api.md +++ b/common/api-review/vertexai.api.md @@ -1,4 +1,4 @@ -## API Report File for "@firebase/vertexai-preview" +## API Report File for "@firebase/vertexai" > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). diff --git a/packages/firebase/package.json b/packages/firebase/package.json index 6d1e8b618b8..1565ce91337 100644 --- a/packages/firebase/package.json +++ b/packages/firebase/package.json @@ -215,17 +215,17 @@ }, "default": "./storage/dist/esm/index.esm.js" }, - "./vertexai-preview": { - "types": "./vertexai-preview/dist/vertexai-preview/index.d.ts", + "./vertexai": { + "types": "./vertexai/dist/vertexai/index.d.ts", "node": { - "require": "./vertexai-preview/dist/index.cjs.js", - "import": "./vertexai-preview/dist/index.mjs" + "require": "./vertexai/dist/index.cjs.js", + "import": "./vertexai/dist/index.mjs" }, "browser": { - "require": "./vertexai-preview/dist/index.cjs.js", - "import": "./vertexai-preview/dist/esm/index.esm.js" + "require": "./vertexai/dist/index.cjs.js", + "import": "./vertexai/dist/esm/index.esm.js" }, - "default": "./vertexai-preview/dist/esm/index.esm.js" + "default": "./vertexai/dist/esm/index.esm.js" }, "./compat/analytics": { "types": "./compat/analytics/dist/compat/analytics/index.d.ts", @@ -413,7 +413,7 @@ "@firebase/app-check": "0.8.8", "@firebase/app-check-compat": "0.3.15", "@firebase/util": "1.10.0", - "@firebase/vertexai-preview": "0.0.4" + "@firebase/vertexai": "0.0.4" }, "devDependencies": { "rollup": "2.79.1", @@ -446,7 +446,7 @@ "messaging", "messaging/sw", "database", - "vertexai-preview" + "vertexai" ], "typings": "empty.d.ts" } diff --git a/packages/firebase/vertexai-preview/index.ts b/packages/firebase/vertexai/index.ts similarity index 93% rename from packages/firebase/vertexai-preview/index.ts rename to packages/firebase/vertexai/index.ts index 20d7697c1e0..2645fd3004f 100644 --- a/packages/firebase/vertexai-preview/index.ts +++ b/packages/firebase/vertexai/index.ts @@ -15,4 +15,4 @@ * limitations under the License. */ -export * from '@firebase/vertexai-preview'; +export * from '@firebase/vertexai'; diff --git a/packages/firebase/vertexai-preview/package.json b/packages/firebase/vertexai/package.json similarity index 55% rename from packages/firebase/vertexai-preview/package.json rename to packages/firebase/vertexai/package.json index 9dfe8f0c3fa..20e04a3bbb5 100644 --- a/packages/firebase/vertexai-preview/package.json +++ b/packages/firebase/vertexai/package.json @@ -1,7 +1,7 @@ { - "name": "firebase/vertexai-preview", + "name": "firebase/vertexai", "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm.js", "module": "dist/esm/index.esm.js", - "typings": "dist/vertexai-preview/index.d.ts" + "typings": "dist/vertexai/index.d.ts" } \ No newline at end of file diff --git a/packages/vertexai/package.json b/packages/vertexai/package.json index 6023c4dc095..4881ea92381 100644 --- a/packages/vertexai/package.json +++ b/packages/vertexai/package.json @@ -1,7 +1,7 @@ { - "name": "@firebase/vertexai-preview", + "name": "@firebase/vertexai", "version": "0.0.4", - "description": "A Firebase SDK for VertexAI (preview)", + "description": "A Firebase SDK for VertexAI", "author": "Firebase (https://firebase.google.com/)", "engines": { "node": ">=18.0.0" @@ -11,7 +11,7 @@ "module": "dist/esm/index.esm2017.js", "exports": { ".": { - "types": "./dist/vertexai-preview-public.d.ts", + "types": "./dist/vertexai-public.d.ts", "node": { "require": "./dist/index.cjs.js", "import": "./dist/esm/index.esm2017.js" @@ -40,7 +40,7 @@ "test:skip-clone": "karma start", "test:browser": "yarn testsetup && karma start", "api-report": "api-extractor run --local --verbose", - "typings:public": "node ../../scripts/build/use_typings.js ./dist/vertexai-preview-public.d.ts", + "typings:public": "node ../../scripts/build/use_typings.js ./dist/vertexai-public.d.ts", "trusted-type-check": "tsec -p tsconfig.json --noEmit" }, "peerDependencies": { From 09ba48f82d83af7c7699385c875ece80ea1d86aa Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 24 Sep 2024 11:08:02 -0700 Subject: [PATCH 06/21] [Vertex GA] Rewrite Schema (#8479) --- common/api-review/vertexai.api.md | 176 ++++++-- packages/vertexai/src/api.test.ts | 13 +- packages/vertexai/src/api.ts | 1 + packages/vertexai/src/errors.ts | 6 +- .../src/requests/schema-builder.test.ts | 393 ++++++++++++++++++ .../vertexai/src/requests/schema-builder.ts | 292 +++++++++++++ packages/vertexai/src/types/error.ts | 3 + packages/vertexai/src/types/index.ts | 1 + packages/vertexai/src/types/requests.ts | 85 +--- packages/vertexai/src/types/schema.ts | 104 +++++ 10 files changed, 958 insertions(+), 116 deletions(-) create mode 100644 packages/vertexai/src/requests/schema-builder.test.ts create mode 100644 packages/vertexai/src/requests/schema-builder.ts create mode 100644 packages/vertexai/src/types/schema.ts diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index ff33d56f269..0a925cf580c 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -9,6 +9,15 @@ import { FirebaseApp } from '@firebase/app'; import { FirebaseAuthTokenData } from '@firebase/auth-interop-types'; import { FirebaseError } from '@firebase/util'; +// @public +export class ArraySchema extends Schema { + constructor(schemaParams: SchemaParams, items: TypedSchema); + // (undocumented) + items: TypedSchema; + // @internal (undocumented) + toJSON(): SchemaRequest; +} + // @public export interface BaseParams { // (undocumented) @@ -27,6 +36,11 @@ export enum BlockReason { SAFETY = "SAFETY" } +// @public +export class BooleanSchema extends Schema { + constructor(schemaParams?: SchemaParams); +} + // @public export class ChatSession { // Warning: (ae-forgotten-export) The symbol "ApiSettings" needs to be exported by the entry point index.d.ts @@ -203,42 +217,7 @@ export interface FunctionCallPart { export interface FunctionDeclaration { description?: string; name: string; - parameters?: FunctionDeclarationSchema; -} - -// @public -export interface FunctionDeclarationSchema { - description?: string; - properties: { - [k: string]: FunctionDeclarationSchemaProperty; - }; - required?: string[]; - type: FunctionDeclarationSchemaType; -} - -// @public -export interface FunctionDeclarationSchemaProperty { - description?: string; - enum?: string[]; - example?: unknown; - format?: string; - items?: FunctionDeclarationSchema; - nullable?: boolean; - properties?: { - [k: string]: FunctionDeclarationSchema; - }; - required?: string[]; - type?: FunctionDeclarationSchemaType; -} - -// @public -export enum FunctionDeclarationSchemaType { - ARRAY = "ARRAY", - BOOLEAN = "BOOLEAN", - INTEGER = "INTEGER", - NUMBER = "NUMBER", - OBJECT = "OBJECT", - STRING = "STRING" + parameters?: ObjectSchemaInterface; } // @public @@ -331,6 +310,7 @@ export interface GenerationConfig { // (undocumented) presencePenalty?: number; responseMimeType?: string; + responseSchema?: TypedSchema | SchemaRequest; // (undocumented) stopSequences?: string[]; // (undocumented) @@ -478,6 +458,11 @@ export interface InlineDataPart { videoMetadata?: VideoMetadata; } +// @public +export class IntegerSchema extends Schema { + constructor(schemaParams?: SchemaParams); +} + // @public export interface ModelParams extends BaseParams { // (undocumented) @@ -490,6 +475,34 @@ export interface ModelParams extends BaseParams { tools?: Tool[]; } +// @public +export class NumberSchema extends Schema { + constructor(schemaParams?: SchemaParams); +} + +// @public +export class ObjectSchema extends Schema { + constructor(schemaParams: SchemaParams, properties: { + [k: string]: TypedSchema; + }, optionalProperties?: string[]); + // (undocumented) + optionalProperties: string[]; + // (undocumented) + properties: { + [k: string]: TypedSchema; + }; + // @internal (undocumented) + toJSON(): SchemaRequest; +} + +// @public +export interface ObjectSchemaInterface extends SchemaInterface { + // (undocumented) + optionalProperties?: string[]; + // (undocumented) + type: SchemaType.OBJECT; +} + // @public export type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; @@ -549,6 +562,82 @@ export interface SafetySetting { threshold: HarmBlockThreshold; } +// @public +export abstract class Schema implements SchemaInterface { + constructor(schemaParams: SchemaInterface); + [key: string]: unknown; + // (undocumented) + static array(arrayParams: SchemaParams & { + items: Schema; + }): ArraySchema; + // (undocumented) + static boolean(booleanParams?: SchemaParams): BooleanSchema; + description?: string; + // (undocumented) + static enumString(stringParams: SchemaParams & { + enum: string[]; + }): StringSchema; + example?: unknown; + format?: string; + // (undocumented) + static integer(integerParams?: SchemaParams): IntegerSchema; + nullable: boolean; + // (undocumented) + static number(numberParams?: SchemaParams): NumberSchema; + // (undocumented) + static object(objectParams: SchemaParams & { + properties: { + [k: string]: Schema; + }; + optionalProperties?: string[]; + }): ObjectSchema; + // (undocumented) + static string(stringParams?: SchemaParams): StringSchema; + // @internal + toJSON(): SchemaRequest; + type: SchemaType; +} + +// @public +export interface SchemaInterface extends SchemaShared { + type: SchemaType; +} + +// @public +export interface SchemaParams extends SchemaShared { +} + +// @public +export interface SchemaRequest extends SchemaShared { + required?: string[]; + type: SchemaType; +} + +// @public +export interface SchemaShared { + // (undocumented) + [key: string]: unknown; + description?: string; + enum?: string[]; + example?: unknown; + format?: string; + items?: T; + nullable?: boolean; + properties?: { + [k: string]: T; + }; +} + +// @public +export enum SchemaType { + ARRAY = "array", + BOOLEAN = "boolean", + INTEGER = "integer", + NUMBER = "number", + OBJECT = "object", + STRING = "string" +} + // @public (undocumented) export interface Segment { // (undocumented) @@ -571,6 +660,15 @@ export interface StartChatParams extends BaseParams { tools?: Tool[]; } +// @public +export class StringSchema extends Schema { + constructor(schemaParams?: SchemaParams, enumValues?: string[]); + // (undocumented) + enum?: string[]; + // @internal (undocumented) + toJSON(): SchemaRequest; +} + // @public export interface TextPart { // (undocumented) @@ -592,6 +690,9 @@ export interface ToolConfig { functionCallingConfig: FunctionCallingConfig; } +// @public +export type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; + // @public export interface UsageMetadata { // (undocumented) @@ -616,8 +717,6 @@ export class VertexAIError extends FirebaseError { readonly code: VertexAIErrorCode; // (undocumented) readonly customErrorData?: CustomErrorData | undefined; - // (undocumented) - readonly message: string; } // @public @@ -625,6 +724,7 @@ export const enum VertexAIErrorCode { ERROR = "error", FETCH_ERROR = "fetch-error", INVALID_CONTENT = "invalid-content", + INVALID_SCHEMA = "invalid-schema", NO_API_KEY = "no-api-key", NO_MODEL = "no-model", NO_PROJECT_ID = "no-project-id", diff --git a/packages/vertexai/src/api.test.ts b/packages/vertexai/src/api.test.ts index 794c5045012..b6c96923856 100644 --- a/packages/vertexai/src/api.test.ts +++ b/packages/vertexai/src/api.test.ts @@ -39,8 +39,9 @@ describe('Top level API', () => { getGenerativeModel(fakeVertexAI, {} as ModelParams); } catch (e) { expect((e as VertexAIError).code).includes(VertexAIErrorCode.NO_MODEL); - expect((e as VertexAIError).message).equals( - `Must provide a model name. Example: getGenerativeModel({ model: 'my-model-name' })` + expect((e as VertexAIError).message).includes( + `VertexAI: Must provide a model name. Example: ` + + `getGenerativeModel({ model: 'my-model-name' }) (vertexAI/${VertexAIErrorCode.NO_MODEL})` ); } }); @@ -54,7 +55,9 @@ describe('Top level API', () => { } catch (e) { expect((e as VertexAIError).code).includes(VertexAIErrorCode.NO_API_KEY); expect((e as VertexAIError).message).equals( - `The "apiKey" field is empty in the local Firebase config. Firebase VertexAI requires this field to contain a valid API key.` + `VertexAI: The "apiKey" field is empty in the local ` + + `Firebase config. Firebase VertexAI requires this field to` + + ` contain a valid API key. (vertexAI/${VertexAIErrorCode.NO_API_KEY})` ); } }); @@ -70,7 +73,9 @@ describe('Top level API', () => { VertexAIErrorCode.NO_PROJECT_ID ); expect((e as VertexAIError).message).equals( - `The "projectId" field is empty in the local Firebase config. Firebase VertexAI requires this field to contain a valid project ID.` + `VertexAI: The "projectId" field is empty in the local` + + ` Firebase config. Firebase VertexAI requires this field ` + + `to contain a valid project ID. (vertexAI/${VertexAIErrorCode.NO_PROJECT_ID})` ); } }); diff --git a/packages/vertexai/src/api.ts b/packages/vertexai/src/api.ts index 92d5aac7144..23c502895d8 100644 --- a/packages/vertexai/src/api.ts +++ b/packages/vertexai/src/api.ts @@ -26,6 +26,7 @@ import { VertexAIError } from './errors'; import { GenerativeModel } from './models/generative-model'; export { ChatSession } from './methods/chat-session'; +export * from './requests/schema-builder'; export { GenerativeModel }; diff --git a/packages/vertexai/src/errors.ts b/packages/vertexai/src/errors.ts index 46db2fd271f..b0b5d9f25ec 100644 --- a/packages/vertexai/src/errors.ts +++ b/packages/vertexai/src/errors.ts @@ -34,15 +34,15 @@ export class VertexAIError extends FirebaseError { */ constructor( readonly code: VertexAIErrorCode, - readonly message: string, + message: string, readonly customErrorData?: CustomErrorData ) { // Match error format used by FirebaseError from ErrorFactory const service = VERTEX_TYPE; const serviceName = 'VertexAI'; const fullCode = `${service}/${code}`; - const fullMessage = `${serviceName}: ${message} (${fullCode}).`; - super(fullCode, fullMessage); + const fullMessage = `${serviceName}: ${message} (${fullCode})`; + super(code, fullMessage); // FirebaseError initializes a stack trace, but it assumes the error is created from the error // factory. Since we break this assumption, we set the stack trace to be originating from this diff --git a/packages/vertexai/src/requests/schema-builder.test.ts b/packages/vertexai/src/requests/schema-builder.test.ts new file mode 100644 index 00000000000..b95acaae9f1 --- /dev/null +++ b/packages/vertexai/src/requests/schema-builder.test.ts @@ -0,0 +1,393 @@ +/** + * @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 { expect, use } from 'chai'; +import sinonChai from 'sinon-chai'; +import { Schema } from './schema-builder'; +import { VertexAIErrorCode } from '../types'; + +use(sinonChai); + +describe('Schema builder', () => { + it('builds integer schema', () => { + const schema = Schema.integer(); + expect(schema.toJSON()).to.eql({ + type: 'integer', + nullable: false + }); + }); + it('builds integer schema with options and overrides', () => { + const schema = Schema.integer({ nullable: true, format: 'int32' }); + expect(schema.toJSON()).to.eql({ + type: 'integer', + format: 'int32', + nullable: true + }); + }); + it('builds number schema', () => { + const schema = Schema.number(); + expect(schema.toJSON()).to.eql({ + type: 'number', + nullable: false + }); + }); + it('builds number schema with options and unknown options', () => { + const schema = Schema.number({ format: 'float', futureOption: 'test' }); + expect(schema.toJSON()).to.eql({ + type: 'number', + format: 'float', + futureOption: 'test', + nullable: false + }); + }); + it('builds boolean schema', () => { + const schema = Schema.boolean(); + expect(schema.toJSON()).to.eql({ + type: 'boolean', + nullable: false + }); + }); + it('builds string schema', () => { + const schema = Schema.string({ description: 'hey' }); + expect(schema.toJSON()).to.eql({ + type: 'string', + description: 'hey', + nullable: false + }); + }); + it('builds enumString schema', () => { + const schema = Schema.enumString({ + example: 'east', + enum: ['east', 'west'] + }); + expect(schema.toJSON()).to.eql({ + type: 'string', + example: 'east', + enum: ['east', 'west'], + nullable: false + }); + }); + it('builds an object schema', () => { + const schema = Schema.object({ + properties: { + 'someInput': Schema.string() + } + }); + expect(schema.toJSON()).to.eql({ + type: 'object', + nullable: false, + properties: { + 'someInput': { + type: 'string', + nullable: false + } + }, + required: ['someInput'] + }); + }); + it('builds an object schema with optional properties', () => { + const schema = Schema.object({ + properties: { + 'someInput': Schema.string(), + 'someBool': Schema.boolean() + }, + optionalProperties: ['someBool'] + }); + expect(schema.toJSON()).to.eql({ + type: 'object', + nullable: false, + properties: { + 'someInput': { + type: 'string', + nullable: false + }, + 'someBool': { + type: 'boolean', + nullable: false + } + }, + required: ['someInput'] + }); + }); + it('builds layered schema - partially filled out', () => { + const schema = Schema.array({ + items: Schema.object({ + properties: { + country: Schema.string({ + description: 'A country name' + }), + population: Schema.integer(), + coordinates: Schema.object({ + properties: { + latitude: Schema.number({ format: 'float' }), + longitude: Schema.number({ format: 'double' }) + } + }), + hemisphere: Schema.object({ + properties: { + latitudinal: Schema.enumString({ enum: ['N', 'S'] }), + longitudinal: Schema.enumString({ enum: ['E', 'W'] }) + } + }), + isCapital: Schema.boolean() + } + }) + }); + expect(schema.toJSON()).to.eql(layeredSchemaOutputPartial); + }); + it('builds layered schema - fully filled out', () => { + const schema = Schema.array({ + items: Schema.object({ + description: 'A country profile', + nullable: false, + properties: { + country: Schema.string({ + nullable: false, + description: 'Country name', + format: undefined + }), + population: Schema.integer({ + nullable: false, + description: 'Number of people in country', + format: 'int64' + }), + coordinates: Schema.object({ + nullable: false, + description: 'Latitude and longitude', + properties: { + latitude: Schema.number({ + nullable: false, + description: 'Latitude of capital', + format: 'float' + }), + longitude: Schema.number({ + nullable: false, + description: 'Longitude of capital', + format: 'double' + }) + } + }), + hemisphere: Schema.object({ + nullable: false, + description: 'Hemisphere(s) country is in', + properties: { + latitudinal: Schema.enumString({ enum: ['N', 'S'] }), + longitudinal: Schema.enumString({ enum: ['E', 'W'] }) + } + }), + isCapital: Schema.boolean({ + nullable: false, + description: "This doesn't make a lot of sense but it's a demo" + }), + elevation: Schema.integer({ + nullable: false, + description: 'Average elevation', + format: 'float' + }) + }, + optionalProperties: [] + }) + }); + + expect(schema.toJSON()).to.eql(layeredSchemaOutput); + }); + it('can override "nullable" and set optional properties', () => { + const schema = Schema.object({ + properties: { + country: Schema.string(), + elevation: Schema.number(), + population: Schema.integer({ nullable: true }) + }, + optionalProperties: ['elevation'] + }); + expect(schema.toJSON()).to.eql({ + 'type': 'object', + 'nullable': false, + 'properties': { + 'country': { + 'type': 'string', + 'nullable': false + }, + 'elevation': { + 'type': 'number', + 'nullable': false + }, + 'population': { + 'type': 'integer', + 'nullable': true + } + }, + 'required': ['country', 'population'] + }); + }); + it('throws if an optionalProperties item does not exist', () => { + const schema = Schema.object({ + properties: { + country: Schema.string(), + elevation: Schema.number(), + population: Schema.integer({ nullable: true }) + }, + optionalProperties: ['cat'] + }); + expect(() => schema.toJSON()).to.throw(VertexAIErrorCode.INVALID_SCHEMA); + }); +}); + +const layeredSchemaOutputPartial = { + 'type': 'array', + 'nullable': false, + 'items': { + 'type': 'object', + 'nullable': false, + 'properties': { + 'country': { + 'type': 'string', + 'description': 'A country name', + 'nullable': false + }, + 'population': { + 'type': 'integer', + 'nullable': false + }, + 'coordinates': { + 'type': 'object', + 'nullable': false, + 'properties': { + 'latitude': { + 'type': 'number', + 'format': 'float', + 'nullable': false + }, + 'longitude': { + 'type': 'number', + 'format': 'double', + 'nullable': false + } + }, + 'required': ['latitude', 'longitude'] + }, + 'hemisphere': { + 'type': 'object', + 'nullable': false, + 'properties': { + 'latitudinal': { + 'type': 'string', + 'nullable': false, + 'enum': ['N', 'S'] + }, + 'longitudinal': { + 'type': 'string', + 'nullable': false, + 'enum': ['E', 'W'] + } + }, + 'required': ['latitudinal', 'longitudinal'] + }, + 'isCapital': { + 'type': 'boolean', + 'nullable': false + } + }, + 'required': [ + 'country', + 'population', + 'coordinates', + 'hemisphere', + 'isCapital' + ] + } +}; + +const layeredSchemaOutput = { + 'type': 'array', + 'nullable': false, + 'items': { + 'type': 'object', + 'description': 'A country profile', + 'nullable': false, + 'required': [ + 'country', + 'population', + 'coordinates', + 'hemisphere', + 'isCapital', + 'elevation' + ], + 'properties': { + 'country': { + 'type': 'string', + 'description': 'Country name', + 'nullable': false + }, + 'population': { + 'type': 'integer', + 'format': 'int64', + 'description': 'Number of people in country', + 'nullable': false + }, + 'coordinates': { + 'type': 'object', + 'description': 'Latitude and longitude', + 'nullable': false, + 'required': ['latitude', 'longitude'], + 'properties': { + 'latitude': { + 'type': 'number', + 'format': 'float', + 'description': 'Latitude of capital', + 'nullable': false + }, + 'longitude': { + 'type': 'number', + 'format': 'double', + 'description': 'Longitude of capital', + 'nullable': false + } + } + }, + 'hemisphere': { + 'type': 'object', + 'description': 'Hemisphere(s) country is in', + 'nullable': false, + 'required': ['latitudinal', 'longitudinal'], + 'properties': { + 'latitudinal': { + 'type': 'string', + 'nullable': false, + 'enum': ['N', 'S'] + }, + 'longitudinal': { + 'type': 'string', + 'nullable': false, + 'enum': ['E', 'W'] + } + } + }, + 'isCapital': { + 'type': 'boolean', + 'description': "This doesn't make a lot of sense but it's a demo", + 'nullable': false + }, + 'elevation': { + 'type': 'integer', + 'format': 'float', + 'description': 'Average elevation', + 'nullable': false + } + } + } +}; diff --git a/packages/vertexai/src/requests/schema-builder.ts b/packages/vertexai/src/requests/schema-builder.ts new file mode 100644 index 00000000000..8a36aaa8997 --- /dev/null +++ b/packages/vertexai/src/requests/schema-builder.ts @@ -0,0 +1,292 @@ +/** + * @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 { VertexAIError } from '../errors'; +import { VertexAIErrorCode } from '../types'; +import { + SchemaInterface, + SchemaType, + SchemaParams, + SchemaRequest, + ObjectSchemaInterface +} 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 abstract class Schema implements SchemaInterface { + /** + * Optional. The type of the property. {@link + * SchemaType}. + */ + type: SchemaType; + /** Optional. The format of the property. + * Supported formats:
+ *
    + *
  • for NUMBER type: "float", "double"
  • + *
  • for INTEGER type: "int32", "int64"
  • + *
  • for STRING type: "email", "byte", etc
  • + *
+ */ + format?: string; + /** Optional. The description of the property. */ + description?: string; + /** 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) { + // eslint-disable-next-line guard-for-in + for (const paramKey in schemaParams) { + this[paramKey] = schemaParams[paramKey]; + } + // Ensure these are explicitly set to avoid TS errors. + this.type = schemaParams.type; + this.nullable = schemaParams.hasOwnProperty('nullable') + ? !!schemaParams.nullable + : false; + } + + /** + * 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 { + const obj: { type: SchemaType; [key: string]: unknown } = { + type: this.type + }; + for (const prop in this) { + if (this.hasOwnProperty(prop) && this[prop] !== undefined) { + if (prop !== 'required' || this.type === SchemaType.OBJECT) { + obj[prop] = this[prop]; + } + } + } + return obj as SchemaRequest; + } + + static array(arrayParams: SchemaParams & { items: Schema }): ArraySchema { + return new ArraySchema(arrayParams, arrayParams.items); + } + + static object( + objectParams: SchemaParams & { + properties: { + [k: string]: Schema; + }; + optionalProperties?: string[]; + } + ): ObjectSchema { + return new ObjectSchema( + objectParams, + objectParams.properties, + objectParams.optionalProperties + ); + } + + // eslint-disable-next-line id-blacklist + static string(stringParams?: SchemaParams): StringSchema { + return new StringSchema(stringParams); + } + + static enumString( + stringParams: SchemaParams & { enum: string[] } + ): StringSchema { + return new StringSchema(stringParams, stringParams.enum); + } + + static integer(integerParams?: SchemaParams): IntegerSchema { + return new IntegerSchema(integerParams); + } + + // eslint-disable-next-line id-blacklist + static number(numberParams?: SchemaParams): NumberSchema { + return new NumberSchema(numberParams); + } + + // eslint-disable-next-line id-blacklist + static boolean(booleanParams?: SchemaParams): BooleanSchema { + return new BooleanSchema(booleanParams); + } +} + +/** + * A type that includes all specific Schema types. + * @public + */ +export type TypedSchema = + | IntegerSchema + | NumberSchema + | StringSchema + | BooleanSchema + | ObjectSchema + | ArraySchema; + +/** + * Schema class for "integer" types. + * @public + */ +export class IntegerSchema extends Schema { + constructor(schemaParams?: SchemaParams) { + super({ + type: SchemaType.INTEGER, + ...schemaParams + }); + } +} + +/** + * Schema class for "number" types. + * @public + */ +export class NumberSchema extends Schema { + constructor(schemaParams?: SchemaParams) { + super({ + type: SchemaType.NUMBER, + ...schemaParams + }); + } +} + +/** + * Schema class for "boolean" types. + * @public + */ +export class BooleanSchema extends Schema { + constructor(schemaParams?: SchemaParams) { + super({ + type: SchemaType.BOOLEAN, + ...schemaParams + }); + } +} + +/** + * Schema class for "string" types. Can be used with or without + * enum values. + * @public + */ +export class StringSchema extends Schema { + enum?: string[]; + constructor(schemaParams?: SchemaParams, enumValues?: string[]) { + super({ + type: SchemaType.STRING, + ...schemaParams + }); + this.enum = enumValues; + } + + /** + * @internal + */ + toJSON(): SchemaRequest { + const obj = super.toJSON(); + if (this.enum) { + obj['enum'] = this.enum; + } + return obj as 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 class ArraySchema extends Schema { + constructor(schemaParams: SchemaParams, public items: TypedSchema) { + super({ + type: SchemaType.ARRAY, + ...schemaParams + }); + } + + /** + * @internal + */ + toJSON(): SchemaRequest { + const obj = super.toJSON(); + obj.items = this.items.toJSON(); + return obj; + } +} + +/** + * Schema class for "object" types. + * The `properties` param must be a map of Schema. + * @public + */ +export class ObjectSchema extends Schema { + constructor( + schemaParams: SchemaParams, + public properties: { + [k: string]: TypedSchema; + }, + public optionalProperties: string[] = [] + ) { + super({ + type: SchemaType.OBJECT, + ...schemaParams + }); + } + + /** + * @internal + */ + toJSON(): SchemaRequest { + const obj = super.toJSON(); + obj.properties = { ...this.properties }; + const required = []; + if (this.optionalProperties) { + for (const propertyKey of this.optionalProperties) { + if (!this.properties.hasOwnProperty(propertyKey)) { + throw new VertexAIError( + VertexAIErrorCode.INVALID_SCHEMA, + `Property "${propertyKey}" specified in "optionalProperties" does not exist.` + ); + } + } + } + for (const propertyKey in this.properties) { + if (this.properties.hasOwnProperty(propertyKey)) { + obj.properties[propertyKey] = this.properties[ + propertyKey + ].toJSON() as SchemaRequest; + if (!this.optionalProperties.includes(propertyKey)) { + required.push(propertyKey); + } + } + } + if (required.length > 0) { + obj.required = required; + } + delete (obj as ObjectSchemaInterface).optionalProperties; + return obj as SchemaRequest; + } +} diff --git a/packages/vertexai/src/types/error.ts b/packages/vertexai/src/types/error.ts index 5ba594013c2..d624e64fa07 100644 --- a/packages/vertexai/src/types/error.ts +++ b/packages/vertexai/src/types/error.ts @@ -78,6 +78,9 @@ export const enum VertexAIErrorCode { /** An error associated with a Content object. */ INVALID_CONTENT = 'invalid-content', + /** An error due to invalid Schema input. */ + INVALID_SCHEMA = 'invalid-schema', + /** An error occurred due to a missing Firebase API key. */ NO_API_KEY = 'no-api-key', diff --git a/packages/vertexai/src/types/index.ts b/packages/vertexai/src/types/index.ts index 45365c39037..85133aa07c5 100644 --- a/packages/vertexai/src/types/index.ts +++ b/packages/vertexai/src/types/index.ts @@ -20,3 +20,4 @@ export * from './enums'; export * from './requests'; export * from './responses'; export * from './error'; +export * from './schema'; diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts index 1e976b386b6..335e7e7dc72 100644 --- a/packages/vertexai/src/types/requests.ts +++ b/packages/vertexai/src/types/requests.ts @@ -15,6 +15,7 @@ * limitations under the License. */ +import { TypedSchema } from '../requests/schema-builder'; import { Content, Part } from './content'; import { FunctionCallingMode, @@ -22,6 +23,7 @@ import { HarmBlockThreshold, HarmCategory } from './enums'; +import { ObjectSchemaInterface, SchemaRequest } from './schema'; /** * Base parameters for a number of methods. @@ -78,14 +80,20 @@ export interface GenerationConfig { presencePenalty?: number; frequencyPenalty?: number; /** - * Output response mimetype of the generated candidate text. - * Supported mimetypes are `text/plain` (default, text output) and `application/json` + * Output response MIME type of the generated candidate text. + * Supported MIME types are `text/plain` (default, text output) and `application/json` * (JSON response in the candidates). - * The model needs to be prompted to output the appropriate response type, - * otherwise the behavior is undefined. - * This is a preview feature. */ responseMimeType?: string; + /** + * Output response schema of the generated candidate text. This + * value can be a class generated with a {@link Schema} static method + * like `Schema.string()` or `Schema.object()` or it can be a plain + * JS object matching the {@link SchemaRequest} interface. + *
Note: This only applies when the specified `responseMIMEType` supports a schema; currently + * this is limited to `application/json`. + */ + responseSchema?: TypedSchema | SchemaRequest; } /** @@ -154,7 +162,7 @@ export declare interface FunctionDeclaration { * format. Reflects the Open API 3.03 Parameter Object. Parameter names are * case-sensitive. For a function with no parameters, this can be left unset. */ - parameters?: FunctionDeclarationSchema; + parameters?: ObjectSchemaInterface; } /** @@ -177,71 +185,6 @@ export declare interface FunctionDeclarationsTool { functionDeclarations?: FunctionDeclaration[]; } -/** - * Contains the list of OpenAPI data types - * as defined by https://swagger.io/docs/specification/data-models/data-types/ - * @public - */ -export enum FunctionDeclarationSchemaType { - /** String type. */ - STRING = 'STRING', - /** Number type. */ - NUMBER = 'NUMBER', - /** Integer type. */ - INTEGER = 'INTEGER', - /** Boolean type. */ - BOOLEAN = 'BOOLEAN', - /** Array type. */ - ARRAY = 'ARRAY', - /** Object type. */ - OBJECT = 'OBJECT' -} - -/** - * Schema for parameters passed to {@link FunctionDeclaration.parameters}. - * @public - */ -export interface FunctionDeclarationSchema { - /** The type of the parameter. */ - type: FunctionDeclarationSchemaType; - /** The format of the parameter. */ - properties: { [k: string]: FunctionDeclarationSchemaProperty }; - /** Optional. Description of the parameter. */ - description?: string; - /** Optional. Array of required parameters. */ - required?: string[]; -} - -/** - * Schema is used to define the format of input/output data. - * Represents a select subset of an OpenAPI 3.0 schema object. - * More fields may be added in the future as needed. - * @public - */ -export interface FunctionDeclarationSchemaProperty { - /** - * Optional. The type of the property. {@link - * FunctionDeclarationSchemaType}. - */ - type?: FunctionDeclarationSchemaType; - /** Optional. The format of the property. */ - format?: string; - /** Optional. The description of the property. */ - description?: string; - /** Optional. Whether the property is nullable. */ - nullable?: boolean; - /** Optional. The items of the property. {@link FunctionDeclarationSchema} */ - items?: FunctionDeclarationSchema; - /** Optional. The enum of the property. */ - enum?: string[]; - /** Optional. Map of {@link FunctionDeclarationSchema}. */ - properties?: { [k: string]: FunctionDeclarationSchema }; - /** Optional. Array of required property. */ - required?: string[]; - /** Optional. The example of the property. */ - example?: unknown; -} - /** * Tool config. This config is shared for all tools provided in the request. * @public diff --git a/packages/vertexai/src/types/schema.ts b/packages/vertexai/src/types/schema.ts new file mode 100644 index 00000000000..7b8f34d89d6 --- /dev/null +++ b/packages/vertexai/src/types/schema.ts @@ -0,0 +1,104 @@ +/** + * @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. + */ + +/** + * Contains the list of OpenAPI data types + * as defined by the + * {@link https://swagger.io/docs/specification/data-models/data-types/ | OpenAPI specification} + * @public + */ +export enum SchemaType { + /** String type. */ + STRING = 'string', + /** Number type. */ + NUMBER = 'number', + /** Integer type. */ + INTEGER = 'integer', + /** Boolean type. */ + BOOLEAN = 'boolean', + /** Array type. */ + ARRAY = 'array', + /** Object type. */ + OBJECT = 'object' +} + +/** + * Basic {@link Schema} properties shared across several Schema-related + * types. + * @public + */ +export interface SchemaShared { + /** Optional. The format of the property. */ + format?: string; + /** Optional. The description of the property. */ + description?: string; + /** Optional. The items of the property. */ + items?: T; + /** Optional. Map of Schemas. */ + properties?: { + [k: string]: T; + }; + /** Optional. The enum of the property. */ + enum?: string[]; + /** Optional. The example of the property. */ + example?: unknown; + /** Optional. Whether the property is nullable. */ + nullable?: boolean; + [key: string]: unknown; +} + +/** + * Params passed to {@link Schema} static methods to create specific + * {@link Schema} classes. + * @public + */ +export interface SchemaParams extends SchemaShared {} + +/** + * Final format for {@link Schema} params passed to backend requests. + * @public + */ +export interface SchemaRequest extends SchemaShared { + /** + * The type of the property. {@link + * SchemaType}. + */ + type: SchemaType; + /** Optional. Array of required property. */ + required?: string[]; +} + +/** + * Interface for {@link Schema} class. + * @public + */ +export interface SchemaInterface extends SchemaShared { + /** + * The type of the property. {@link + * SchemaType}. + */ + type: SchemaType; +} + +/** + * Interface for {@link ObjectSchema} class. + * @public + */ +export interface ObjectSchemaInterface extends SchemaInterface { + type: SchemaType.OBJECT; + optionalProperties?: string[]; +} From 245e65e7fa06cf7cb8ae7756a0a653444bd0548e Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 24 Sep 2024 15:07:11 -0700 Subject: [PATCH 07/21] [Vertex GA] Add new endpoint and error message. (#8497) --- common/api-review/vertexai.api.md | 1 + packages/vertexai/src/constants.ts | 4 +-- .../src/methods/generate-content.test.ts | 14 +++++++++ .../vertexai/src/requests/request.test.ts | 25 +++++++++++++++ packages/vertexai/src/requests/request.ts | 31 ++++++++++++++++++- packages/vertexai/src/types/error.ts | 3 ++ 6 files changed, 75 insertions(+), 3 deletions(-) diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index 0a925cf580c..14177f133f4 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -721,6 +721,7 @@ export class VertexAIError extends FirebaseError { // @public export const enum VertexAIErrorCode { + API_NOT_ENABLED = "api-not-enabled", ERROR = "error", FETCH_ERROR = "fetch-error", INVALID_CONTENT = "invalid-content", diff --git a/packages/vertexai/src/constants.ts b/packages/vertexai/src/constants.ts index 97f6d813abc..3ff894f354b 100644 --- a/packages/vertexai/src/constants.ts +++ b/packages/vertexai/src/constants.ts @@ -21,9 +21,9 @@ export const VERTEX_TYPE = 'vertexAI'; export const DEFAULT_LOCATION = 'us-central1'; -export const DEFAULT_BASE_URL = 'https://firebaseml.googleapis.com'; +export const DEFAULT_BASE_URL = 'https://firebasevertexai.googleapis.com'; -export const DEFAULT_API_VERSION = 'v2beta'; +export const DEFAULT_API_VERSION = 'v1beta'; export const PACKAGE_VERSION = version; diff --git a/packages/vertexai/src/methods/generate-content.test.ts b/packages/vertexai/src/methods/generate-content.test.ts index 51fa82dccc9..fd12964c4bc 100644 --- a/packages/vertexai/src/methods/generate-content.test.ts +++ b/packages/vertexai/src/methods/generate-content.test.ts @@ -220,4 +220,18 @@ describe('generateContent()', () => { ).to.be.rejectedWith(/400.*invalid argument/); expect(mockFetch).to.be.called; }); + it('api not enabled (403)', async () => { + const mockResponse = getMockResponse( + 'unary-failure-firebasevertexai-api-not-enabled.json' + ); + const mockFetch = stub(globalThis, 'fetch').resolves({ + ok: false, + status: 403, + json: mockResponse.json + } as Response); + await expect( + generateContent(fakeApiSettings, 'model', fakeRequestParams) + ).to.be.rejectedWith(/firebasevertexai\.googleapis.*my-project/); + expect(mockFetch).to.be.called; + }); }); diff --git a/packages/vertexai/src/requests/request.test.ts b/packages/vertexai/src/requests/request.test.ts index 16a1ece2c7e..95e37631472 100644 --- a/packages/vertexai/src/requests/request.test.ts +++ b/packages/vertexai/src/requests/request.test.ts @@ -24,6 +24,7 @@ import { ApiSettings } from '../types/internal'; import { DEFAULT_API_VERSION } from '../constants'; import { VertexAIErrorCode } from '../types'; import { VertexAIError } from '../errors'; +import { getMockResponse } from '../../test-utils/mock-response'; use(sinonChai); use(chaiAsPromised); @@ -357,4 +358,28 @@ describe('request methods', () => { expect(fetchStub).to.be.calledOnce; }); }); + it('Network error, API not enabled', async () => { + const mockResponse = getMockResponse( + 'unary-failure-firebasevertexai-api-not-enabled.json' + ); + const fetchStub = stub(globalThis, 'fetch').resolves( + mockResponse as Response + ); + try { + await makeRequest( + 'models/model-name', + Task.GENERATE_CONTENT, + fakeApiSettings, + false, + '' + ); + } catch (e) { + expect((e as VertexAIError).code).to.equal( + VertexAIErrorCode.API_NOT_ENABLED + ); + expect((e as VertexAIError).message).to.include('my-project'); + expect((e as VertexAIError).message).to.include('googleapis.com'); + } + expect(fetchStub).to.be.calledOnce; + }); }); diff --git a/packages/vertexai/src/requests/request.ts b/packages/vertexai/src/requests/request.ts index eac99a23038..a81e2d32d89 100644 --- a/packages/vertexai/src/requests/request.ts +++ b/packages/vertexai/src/requests/request.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { RequestOptions, VertexAIErrorCode } from '../types'; +import { ErrorDetails, RequestOptions, VertexAIErrorCode } from '../types'; import { VertexAIError } from '../errors'; import { ApiSettings } from '../types/internal'; import { @@ -151,6 +151,34 @@ export async function makeRequest( } catch (e) { // ignored } + if ( + response.status === 403 && + errorDetails.some( + (detail: ErrorDetails) => detail.reason === 'SERVICE_DISABLED' + ) && + errorDetails.some((detail: ErrorDetails) => + ( + detail.links as Array> + )?.[0]?.description.includes( + 'Google developers console API activation' + ) + ) + ) { + throw new VertexAIError( + VertexAIErrorCode.API_NOT_ENABLED, + `The Vertex AI for Firebase SDK requires the Firebase Vertex AI API ` + + `firebasevertexai.googleapis.com to be enabled for your ` + + `project. Get started in the Firebase Console` + + ` (https://console.firebase.google.com/project/${url.apiSettings.project}/genai/vertex)` + + ` or verify that the API is enabled in the Google Cloud` + + ` Console (https://console.developers.google.com/apis/api/firebasevertexai.googleapis.com/overview?project=${url.apiSettings.project}).`, + { + status: response.status, + statusText: response.statusText, + errorDetails + } + ); + } throw new VertexAIError( VertexAIErrorCode.FETCH_ERROR, `Error fetching from ${url}: [${response.status} ${response.statusText}] ${message}`, @@ -165,6 +193,7 @@ export async function makeRequest( let err = e as Error; if ( (e as VertexAIError).code !== VertexAIErrorCode.FETCH_ERROR && + (e as VertexAIError).code !== VertexAIErrorCode.API_NOT_ENABLED && e instanceof Error ) { err = new VertexAIError( diff --git a/packages/vertexai/src/types/error.ts b/packages/vertexai/src/types/error.ts index d624e64fa07..aaaf19f05b3 100644 --- a/packages/vertexai/src/types/error.ts +++ b/packages/vertexai/src/types/error.ts @@ -78,6 +78,9 @@ export const enum VertexAIErrorCode { /** An error associated with a Content object. */ INVALID_CONTENT = 'invalid-content', + /** An error due to the Firebase API not being enabled in the Console. */ + API_NOT_ENABLED = 'api-not-enabled', + /** An error due to invalid Schema input. */ INVALID_SCHEMA = 'invalid-schema', From 3fe4f4fd28840342b18f5c6d42bd72dba5693d09 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 24 Sep 2024 16:03:30 -0700 Subject: [PATCH 08/21] [Vertex GA] Miscellaneous breaking changes for Vertex GA (#8514) --- common/api-review/vertexai.api.md | 28 ++++--------------- .../vertexai/src/requests/request.test.ts | 2 +- packages/vertexai/src/requests/request.ts | 10 ++++--- packages/vertexai/src/types/enums.ts | 15 ---------- packages/vertexai/src/types/requests.ts | 8 +++--- packages/vertexai/src/types/responses.ts | 2 +- 6 files changed, 18 insertions(+), 47 deletions(-) diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index 14177f133f4..a3f7b30b994 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -28,8 +28,6 @@ export interface BaseParams { // @public export enum BlockReason { - // (undocumented) - BLOCKED_REASON_UNSPECIFIED = "BLOCKED_REASON_UNSPECIFIED", // (undocumented) OTHER = "OTHER", // (undocumented) @@ -159,8 +157,6 @@ export interface FileDataPart { // @public export enum FinishReason { - // (undocumented) - FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", // (undocumented) MAX_TOKENS = "MAX_TOKENS", // (undocumented) @@ -196,8 +192,6 @@ export enum FunctionCallingMode { // (undocumented) AUTO = "AUTO", // (undocumented) - MODE_UNSPECIFIED = "MODE_UNSPECIFIED", - // (undocumented) NONE = "NONE" } @@ -215,7 +209,7 @@ export interface FunctionCallPart { // @public export interface FunctionDeclaration { - description?: string; + description: string; name: string; parameters?: ObjectSchemaInterface; } @@ -381,8 +375,6 @@ export interface GroundingMetadata { // @public (undocumented) export enum HarmBlockMethod { - // (undocumented) - HARM_BLOCK_METHOD_UNSPECIFIED = "HARM_BLOCK_METHOD_UNSPECIFIED", // (undocumented) PROBABILITY = "PROBABILITY", // (undocumented) @@ -398,9 +390,7 @@ export enum HarmBlockThreshold { // (undocumented) BLOCK_NONE = "BLOCK_NONE", // (undocumented) - BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH", - // (undocumented) - HARM_BLOCK_THRESHOLD_UNSPECIFIED = "HARM_BLOCK_THRESHOLD_UNSPECIFIED" + BLOCK_ONLY_HIGH = "BLOCK_ONLY_HIGH" } // @public @@ -412,15 +402,11 @@ export enum HarmCategory { // (undocumented) HARM_CATEGORY_HATE_SPEECH = "HARM_CATEGORY_HATE_SPEECH", // (undocumented) - HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT", - // (undocumented) - HARM_CATEGORY_UNSPECIFIED = "HARM_CATEGORY_UNSPECIFIED" + HARM_CATEGORY_SEXUALLY_EXPLICIT = "HARM_CATEGORY_SEXUALLY_EXPLICIT" } // @public export enum HarmProbability { - // (undocumented) - HARM_PROBABILITY_UNSPECIFIED = "HARM_PROBABILITY_UNSPECIFIED", // (undocumented) HIGH = "HIGH", // (undocumented) @@ -440,9 +426,7 @@ export enum HarmSeverity { // (undocumented) HARM_SEVERITY_MEDIUM = "HARM_SEVERITY_MEDIUM", // (undocumented) - HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE", - // (undocumented) - HARM_SEVERITY_UNSPECIFIED = "HARM_SEVERITY_UNSPECIFIED" + HARM_SEVERITY_NEGLIGIBLE = "HARM_SEVERITY_NEGLIGIBLE" } // @public @@ -512,7 +496,7 @@ export const POSSIBLE_ROLES: readonly ["user", "model", "function", "system"]; // @public export interface PromptFeedback { // (undocumented) - blockReason: BlockReason; + blockReason?: BlockReason; // (undocumented) blockReasonMessage?: string; // (undocumented) @@ -687,7 +671,7 @@ export type Tool = FunctionDeclarationsTool; // @public export interface ToolConfig { // (undocumented) - functionCallingConfig: FunctionCallingConfig; + functionCallingConfig?: FunctionCallingConfig; } // @public diff --git a/packages/vertexai/src/requests/request.test.ts b/packages/vertexai/src/requests/request.test.ts index 95e37631472..da32ec7d59c 100644 --- a/packages/vertexai/src/requests/request.test.ts +++ b/packages/vertexai/src/requests/request.test.ts @@ -244,7 +244,7 @@ describe('request methods', () => { false, '', { - timeout: 0 + timeout: 180000 } ); } catch (e) { diff --git a/packages/vertexai/src/requests/request.ts b/packages/vertexai/src/requests/request.ts index a81e2d32d89..8c563d8ccfc 100644 --- a/packages/vertexai/src/requests/request.ts +++ b/packages/vertexai/src/requests/request.ts @@ -215,11 +215,13 @@ export async function makeRequest( */ function buildFetchOptions(requestOptions?: RequestOptions): RequestInit { const fetchOptions = {} as RequestInit; + let timeoutMillis = 180 * 1000; // default: 180 s if (requestOptions?.timeout && requestOptions?.timeout >= 0) { - const abortController = new AbortController(); - const signal = abortController.signal; - setTimeout(() => abortController.abort(), requestOptions.timeout); - fetchOptions.signal = signal; + timeoutMillis = requestOptions.timeout; } + const abortController = new AbortController(); + const signal = abortController.signal; + setTimeout(() => abortController.abort(), timeoutMillis); + fetchOptions.signal = signal; return fetchOptions; } diff --git a/packages/vertexai/src/types/enums.ts b/packages/vertexai/src/types/enums.ts index fd901241250..3e66bacc612 100644 --- a/packages/vertexai/src/types/enums.ts +++ b/packages/vertexai/src/types/enums.ts @@ -32,7 +32,6 @@ export const POSSIBLE_ROLES = ['user', 'model', 'function', 'system'] as const; * @public */ export enum HarmCategory { - HARM_CATEGORY_UNSPECIFIED = 'HARM_CATEGORY_UNSPECIFIED', HARM_CATEGORY_HATE_SPEECH = 'HARM_CATEGORY_HATE_SPEECH', HARM_CATEGORY_SEXUALLY_EXPLICIT = 'HARM_CATEGORY_SEXUALLY_EXPLICIT', HARM_CATEGORY_HARASSMENT = 'HARM_CATEGORY_HARASSMENT', @@ -44,8 +43,6 @@ export enum HarmCategory { * @public */ export enum HarmBlockThreshold { - // Threshold is unspecified. - HARM_BLOCK_THRESHOLD_UNSPECIFIED = 'HARM_BLOCK_THRESHOLD_UNSPECIFIED', // Content with NEGLIGIBLE will be allowed. BLOCK_LOW_AND_ABOVE = 'BLOCK_LOW_AND_ABOVE', // Content with NEGLIGIBLE and LOW will be allowed. @@ -60,8 +57,6 @@ export enum HarmBlockThreshold { * @public */ export enum HarmBlockMethod { - // The harm block method is unspecified. - HARM_BLOCK_METHOD_UNSPECIFIED = 'HARM_BLOCK_METHOD_UNSPECIFIED', // The harm block method uses both probability and severity scores. SEVERITY = 'SEVERITY', // The harm block method uses the probability score. @@ -73,8 +68,6 @@ export enum HarmBlockMethod { * @public */ export enum HarmProbability { - // Probability is unspecified. - HARM_PROBABILITY_UNSPECIFIED = 'HARM_PROBABILITY_UNSPECIFIED', // Content has a negligible chance of being unsafe. NEGLIGIBLE = 'NEGLIGIBLE', // Content has a low chance of being unsafe. @@ -90,8 +83,6 @@ export enum HarmProbability { * @public */ export enum HarmSeverity { - // Harm severity unspecified. - HARM_SEVERITY_UNSPECIFIED = 'HARM_SEVERITY_UNSPECIFIED', // Negligible level of harm severity. HARM_SEVERITY_NEGLIGIBLE = 'HARM_SEVERITY_NEGLIGIBLE', // Low level of harm severity. @@ -107,8 +98,6 @@ export enum HarmSeverity { * @public */ export enum BlockReason { - // A blocked reason was not specified. - BLOCKED_REASON_UNSPECIFIED = 'BLOCKED_REASON_UNSPECIFIED', // Content was blocked by safety settings. SAFETY = 'SAFETY', // Content was blocked, but the reason is uncategorized. @@ -120,8 +109,6 @@ export enum BlockReason { * @public */ export enum FinishReason { - // Default value. This value is unused. - FINISH_REASON_UNSPECIFIED = 'FINISH_REASON_UNSPECIFIED', // Natural stop point of the model or provided stop sequence. STOP = 'STOP', // The maximum number of tokens as specified in the request was reached. @@ -138,8 +125,6 @@ export enum FinishReason { * @public */ export enum FunctionCallingMode { - // Unspecified function calling mode. This value should not be used. - MODE_UNSPECIFIED = 'MODE_UNSPECIFIED', // Default model behavior, model decides to predict either a function call // or a natural language response. AUTO = 'AUTO', diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts index 335e7e7dc72..c844ddfb878 100644 --- a/packages/vertexai/src/types/requests.ts +++ b/packages/vertexai/src/types/requests.ts @@ -121,7 +121,7 @@ export interface CountTokensRequest { */ export interface RequestOptions { /** - * Request timeout in milliseconds. + * Request timeout in milliseconds. Defaults to 180 seconds (180000ms). */ timeout?: number; /** @@ -153,10 +153,10 @@ export declare interface FunctionDeclaration { */ name: string; /** - * Optional. Description and purpose of the function. Model uses it to decide + * Description and purpose of the function. Model uses it to decide * how and whether to call the function. */ - description?: string; + description: string; /** * Optional. Describes the parameters to this function in JSON Schema Object * format. Reflects the Open API 3.03 Parameter Object. Parameter names are @@ -190,7 +190,7 @@ export declare interface FunctionDeclarationsTool { * @public */ export interface ToolConfig { - functionCallingConfig: FunctionCallingConfig; + functionCallingConfig?: FunctionCallingConfig; } /** diff --git a/packages/vertexai/src/types/responses.ts b/packages/vertexai/src/types/responses.ts index 0a4557fb055..026002a851d 100644 --- a/packages/vertexai/src/types/responses.ts +++ b/packages/vertexai/src/types/responses.ts @@ -91,7 +91,7 @@ export interface UsageMetadata { * @public */ export interface PromptFeedback { - blockReason: BlockReason; + blockReason?: BlockReason; safetyRatings: SafetyRating[]; blockReasonMessage?: string; } From 36cb0178cded40b80024d5bdad6432c7a30a6a89 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 25 Sep 2024 10:55:29 -0400 Subject: [PATCH 09/21] Remove ES5 Support (#8509) --- .changeset/little-cows-tie.md | 36 +++++++ config/tsconfig.base.json | 14 +-- e2e/karma.conf.js | 2 +- integration/compat-interop/tsconfig.json | 2 +- integration/firebase/tsconfig.json | 2 +- packages/analytics-compat/package.json | 2 - packages/analytics-compat/rollup.config.js | 60 ++++-------- packages/analytics/package.json | 2 - packages/analytics/rollup.config.js | 36 ++----- packages/analytics/src/index.ts | 2 +- packages/app-check-compat/package.json | 2 - packages/app-check-compat/rollup.config.js | 30 ++---- packages/app-check/package.json | 2 - packages/app-check/rollup.config.js | 30 ++---- packages/app-compat/package.json | 4 - packages/app-compat/rollup.config.js | 47 ++------- packages/app/package.json | 2 - packages/app/rollup.config.js | 43 ++------- packages/app/src/registerCoreComponents.ts | 2 +- packages/auth-compat/package.json | 2 - packages/auth-compat/rollup.config.js | 49 +++------- packages/auth/api-extractor.json | 2 +- packages/auth/cordova/demo/rollup.config.js | 33 ++----- packages/auth/demo/rollup.config.js | 38 ++++---- packages/auth/demo/src/worker/tsconfig.json | 4 +- packages/auth/internal/package.json | 3 +- packages/auth/package.json | 7 +- packages/auth/rollup.config.js | 75 +++++---------- packages/auth/src/core/auth/register.ts | 2 +- packages/component/package.json | 2 - packages/component/rollup.config.js | 59 ++++-------- packages/database-compat/package.json | 2 - packages/database-compat/rollup.config.js | 41 ++------ packages/database/package.json | 2 - packages/database/rollup.config.js | 52 +++------- packages/database/src/register.ts | 2 +- packages/firebase/compat/rollup.config.js | 31 +----- packages/firestore-compat/package.json | 2 - packages/firestore-compat/rollup.config.js | 20 ---- packages/firestore/lite/package.json | 1 - packages/firestore/package.json | 3 - packages/firestore/rollup.config.js | 95 +++++++------------ packages/firestore/rollup.config.lite.js | 82 +++++----------- packages/firestore/rollup.shared.js | 71 +------------- packages/firestore/src/register.ts | 2 +- .../test/unit/specs/spec_rpc_error.ts | 3 +- packages/functions-compat/package.json | 2 - packages/functions-compat/rollup.config.js | 24 +---- packages/functions/package.json | 2 - packages/functions/rollup.config.js | 27 +----- packages/functions/src/config.ts | 2 +- packages/installations-compat/package.json | 2 - .../installations-compat/rollup.config.js | 56 +++++------ packages/installations/package.json | 2 - packages/installations/rollup.config.js | 75 ++++++--------- packages/installations/src/index.ts | 2 +- .../src/testing/compare-headers.ts | 1 + packages/logger/package.json | 2 - packages/logger/rollup.config.js | 63 ++++-------- packages/messaging-compat/package.json | 2 - packages/messaging-compat/rollup.config.js | 60 ++++-------- packages/messaging/package.json | 2 - packages/messaging/rollup.config.js | 49 ++++------ packages/messaging/src/helpers/register.ts | 2 +- .../messaging/src/testing/compare-headers.ts | 1 + packages/performance-compat/package.json | 2 - packages/performance-compat/rollup.config.js | 55 ++++------- packages/performance/package.json | 2 - packages/performance/rollup.config.js | 68 +++++-------- packages/performance/src/index.ts | 2 +- packages/remote-config-compat/package.json | 2 - .../remote-config-compat/rollup.config.js | 55 ++++------- packages/remote-config/package.json | 2 - packages/remote-config/rollup.config.js | 88 +++++++---------- packages/remote-config/src/register.ts | 2 +- packages/rules-unit-testing/rollup.config.js | 31 +++--- .../src/impl/test_environment.ts | 2 +- packages/storage-compat/package.json | 2 - packages/storage-compat/rollup.config.js | 65 ++++--------- packages/storage/package.json | 2 - packages/storage/rollup.config.js | 41 ++------ packages/storage/src/index.ts | 2 +- packages/template/package.json | 2 - packages/template/rollup.config.js | 45 +++------ packages/util/package.json | 2 - packages/util/rollup.config.js | 45 +++------ packages/util/src/crypt.ts | 1 + packages/util/src/errors.ts | 2 + packages/vertexai/rollup.config.js | 23 ++--- packages/vertexai/src/errors.ts | 2 + packages/vertexai/src/index.ts | 2 +- .../bloom-blob/package.json | 1 - packages/webchannel-wrapper/package.json | 2 - packages/webchannel-wrapper/rollup.config.js | 6 +- .../webchannel-blob/package.json | 1 - .../changelog-generator/tsconfig.json | 2 +- repo-scripts/size-analysis/rollup.config.js | 4 +- scripts/ci-test/check-paths.ts | 1 - scripts/docgen/docgen.ts | 10 +- scripts/size_report/report_binary_size.ts | 5 +- scripts/tsconfig.json | 2 +- 101 files changed, 609 insertions(+), 1353 deletions(-) create mode 100644 .changeset/little-cows-tie.md diff --git a/.changeset/little-cows-tie.md b/.changeset/little-cows-tie.md new file mode 100644 index 00000000000..988329e2f0e --- /dev/null +++ b/.changeset/little-cows-tie.md @@ -0,0 +1,36 @@ +--- +'@firebase/installations-compat': patch +'@firebase/remote-config-compat': patch +'@firebase/performance-compat': patch +'@firebase/rules-unit-testing': patch +'@firebase/webchannel-wrapper': patch +'@firebase/analytics-compat': patch +'@firebase/app-check-compat': patch +'@firebase/firestore-compat': patch +'@firebase/functions-compat': patch +'@firebase/messaging-compat': patch +'@firebase/database-compat': patch +'@firebase/storage-compat': patch +'@firebase/installations': patch +'@firebase/remote-config': patch +'@firebase/auth-compat': patch +'@firebase/performance': patch +'@firebase/app-compat': patch +'@firebase/analytics': patch +'@firebase/app-check': patch +'@firebase/component': patch +'@firebase/firestore': patch +'@firebase/functions': patch +'@firebase/messaging': patch +'@firebase/database': patch +'firebase': patch +'@firebase/template': patch +'@firebase/vertexai-preview': patch +'@firebase/storage': patch +'@firebase/logger': patch +'@firebase/auth': patch +'@firebase/util': patch +'@firebase/app': patch +--- + +Remove ES5 bundles. The minimum required ES version is now ES2017. diff --git a/config/tsconfig.base.json b/config/tsconfig.base.json index 0bfe24208a8..adbd2e44072 100644 --- a/config/tsconfig.base.json +++ b/config/tsconfig.base.json @@ -5,24 +5,16 @@ "importHelpers": true, "strict": true, "lib": [ - "es5", "dom", - "es2015.promise", - "es2015.symbol", - "es2015.iterable", - "es2015.collection", - "es2015.symbol.wellknown", - "es2015.core", - "es2017.object", - "es2017.string", - "ESNext.WeakRef", + "es2017", + "esnext.WeakRef", ], "module": "ES2015", "moduleResolution": "node", "resolveJsonModule": true, "esModuleInterop": true, "sourceMap": true, - "target": "es5", + "target": "es2017", "typeRoots": [ "../node_modules/@types" ], diff --git a/e2e/karma.conf.js b/e2e/karma.conf.js index 80824d6d548..fb2474f3beb 100644 --- a/e2e/karma.conf.js +++ b/e2e/karma.conf.js @@ -82,7 +82,7 @@ module.exports = function (config) { 'resolveJsonModule': true, 'esModuleInterop': true, 'sourceMap': true, - 'target': 'es5', + 'target': 'es2017', 'importHelpers': true, 'noEmitOnError': true } diff --git a/integration/compat-interop/tsconfig.json b/integration/compat-interop/tsconfig.json index 4da78214594..735f3df7fbd 100644 --- a/integration/compat-interop/tsconfig.json +++ b/integration/compat-interop/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "noImplicitAny": true, "outDir": "dist", - "target": "ES5", + "target": "es2017", "sourceMap": true, "esModuleInterop": true }, diff --git a/integration/firebase/tsconfig.json b/integration/firebase/tsconfig.json index 4da78214594..735f3df7fbd 100644 --- a/integration/firebase/tsconfig.json +++ b/integration/firebase/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "noImplicitAny": true, "outDir": "dist", - "target": "ES5", + "target": "es2017", "sourceMap": true, "esModuleInterop": true }, diff --git a/packages/analytics-compat/package.json b/packages/analytics-compat/package.json index 861e5baf519..62fa41c2029 100644 --- a/packages/analytics-compat/package.json +++ b/packages/analytics-compat/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/analytics-compat/rollup.config.js b/packages/analytics-compat/rollup.config.js index 0fccfa7a26c..49b8ac0d21e 100644 --- a/packages/analytics-compat/rollup.config.js +++ b/packages/analytics-compat/rollup.config.js @@ -25,51 +25,33 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...buildPlugins, emitModulePackageFile()] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: buildPlugins +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/analytics/package.json b/packages/analytics/package.json index 590ba9c6640..57b08f0e84a 100644 --- a/packages/analytics/package.json +++ b/packages/analytics/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/analytics-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/analytics/rollup.config.js b/packages/analytics/rollup.config.js index 509b9690c5e..6acafe03b5d 100644 --- a/packages/analytics/rollup.config.js +++ b/packages/analytics/rollup.config.js @@ -27,22 +27,10 @@ const deps = [ ...Object.keys(Object.assign({}, pkg.peerDependencies, pkg.dependencies)) ]; -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; @@ -50,16 +38,6 @@ const es2017BuildPlugins = [ * ESM builds */ const esmBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)), - emitModulePackageFile() - ] - }, { input: 'src/index.ts', output: { @@ -69,7 +47,7 @@ const esmBuilds = [ }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)), emitModulePackageFile() ] @@ -82,11 +60,15 @@ const esmBuilds = [ const cjsBuilds = [ { input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ] } ]; diff --git a/packages/analytics/src/index.ts b/packages/analytics/src/index.ts index ed785fba94b..f79725db7bd 100644 --- a/packages/analytics/src/index.ts +++ b/packages/analytics/src/index.ts @@ -66,7 +66,7 @@ function registerAnalytics(): void { ); registerVersion(name, version); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); function internalFactory( diff --git a/packages/app-check-compat/package.json b/packages/app-check-compat/package.json index bbb8f2f9798..464f9e36c25 100644 --- a/packages/app-check-compat/package.json +++ b/packages/app-check-compat/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/app-check-compat/rollup.config.js b/packages/app-check-compat/rollup.config.js index e3cc4ea55de..137f3a27fad 100644 --- a/packages/app-check-compat/rollup.config.js +++ b/packages/app-check-compat/rollup.config.js @@ -25,32 +25,14 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] - }, { input: 'src/index.ts', output: { @@ -59,16 +41,20 @@ const esmBuilds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] + plugins: [...buildPlugins, emitModulePackageFile()] } ]; const cjsBuilds = [ { input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins + plugins: buildPlugins } ]; diff --git a/packages/app-check/package.json b/packages/app-check/package.json index f107eb81df9..d74ec9843df 100644 --- a/packages/app-check/package.json +++ b/packages/app-check/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/app-check-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/app-check/rollup.config.js b/packages/app-check/rollup.config.js index e3cc4ea55de..137f3a27fad 100644 --- a/packages/app-check/rollup.config.js +++ b/packages/app-check/rollup.config.js @@ -25,32 +25,14 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] - }, { input: 'src/index.ts', output: { @@ -59,16 +41,20 @@ const esmBuilds = [ sourcemap: true }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] + plugins: [...buildPlugins, emitModulePackageFile()] } ]; const cjsBuilds = [ { input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins + plugins: buildPlugins } ]; diff --git a/packages/app-compat/package.json b/packages/app-compat/package.json index e7691b2e66e..8a8b39eca7a 100644 --- a/packages/app-compat/package.json +++ b/packages/app-compat/package.json @@ -6,16 +6,12 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "lite": "dist/index.lite.js", - "liteesm5": "dist/index.lite.esm5.js", "exports": { ".": { "types": "./dist/app-compat-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "lite": "./dist/index.lite.js", - "liteesm5": "./dist/index.lite.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/app-compat/rollup.config.js b/packages/app-compat/rollup.config.js index 055b75f3836..5bc1c799aa2 100644 --- a/packages/app-compat/rollup.config.js +++ b/packages/app-compat/rollup.config.js @@ -25,46 +25,15 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, abortOnError: false }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - abortOnError: false, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), - json({ - preferConst: true - }) + json({ preferConst: true }) ]; const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: [...es5BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - { - input: 'src/index.lite.ts', - output: { - file: pkg['liteesm5'], - format: 'es', - sourcemap: true - }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: 'src/index.ts', output: { @@ -72,7 +41,7 @@ const esmBuilds = [ format: 'es', sourcemap: true }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { @@ -82,7 +51,7 @@ const esmBuilds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; @@ -90,8 +59,12 @@ const esmBuilds = [ const cjsBuilds = [ { input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - plugins: es5BuildPlugins, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; diff --git a/packages/app/package.json b/packages/app/package.json index abb6fad7648..2cb10dbcbeb 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/app-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/app/rollup.config.js b/packages/app/rollup.config.js index 6900b5f0f4a..ec5a279a1c2 100644 --- a/packages/app/rollup.config.js +++ b/packages/app/rollup.config.js @@ -28,44 +28,17 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), - json({ - preferConst: true - }) + json({ preferConst: true }) ]; const esmBuilds = [ /** * Browser Builds */ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace({ - ...generateBuildTargetReplaceConfig('esm', 5), - '__RUNTIME_ENV__': '' - }), - emitModulePackageFile() - ] - }, { input: 'src/index.ts', output: { @@ -75,7 +48,7 @@ const esmBuilds = [ }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': '' @@ -88,12 +61,16 @@ const esmBuilds = [ const cjsBuilds = [ { input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es5BuildPlugins, + ...buildPlugins, replace({ - ...generateBuildTargetReplaceConfig('cjs', 5), + ...generateBuildTargetReplaceConfig('cjs', 2017), '__RUNTIME_ENV__': 'node' }) ] diff --git a/packages/app/src/registerCoreComponents.ts b/packages/app/src/registerCoreComponents.ts index 744b916e4c0..f0141dbf155 100644 --- a/packages/app/src/registerCoreComponents.ts +++ b/packages/app/src/registerCoreComponents.ts @@ -40,7 +40,7 @@ export function registerCoreComponents(variant?: string): void { // Register `app` package. registerVersion(name, version, variant); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); // Register platform SDK identifier (no version). registerVersion('fire-js', ''); diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index dbbaa86f0f1..b6366b2f725 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -6,7 +6,6 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm.js", "exports": { ".": { "types": "./dist/auth-compat/index.d.ts", @@ -15,7 +14,6 @@ "import": "./dist/esm/index.node.esm.js", "require": "./dist/index.node.cjs.js" }, - "esm5": "./dist/index.esm.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/auth-compat/rollup.config.js b/packages/auth-compat/rollup.config.js index cb3491541c4..b2872f977fd 100644 --- a/packages/auth-compat/rollup.config.js +++ b/packages/auth-compat/rollup.config.js @@ -27,40 +27,9 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * Common plugins for all builds - */ -const commonPlugins = [json(), resolve()]; - -const es5BuildPlugins = [ - ...commonPlugins, - typescriptPlugin({ - typescript - }) -]; - -const es2017BuildPlugins = [ - ...commonPlugins, - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; +const buildPlugins = [json(), resolve(), typescriptPlugin({ typescript })]; const browserBuilds = [ - { - input: 'index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - treeshake: { - moduleSideEffects: false - } - }, { input: 'index.ts', output: { @@ -68,7 +37,7 @@ const browserBuilds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), treeshake: { moduleSideEffects: false @@ -81,7 +50,7 @@ const browserBuilds = [ format: 'cjs', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), treeshake: { moduleSideEffects: false @@ -92,8 +61,12 @@ const browserBuilds = [ const nodeBuilds = [ { input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), treeshake: { moduleSideEffects: true @@ -104,7 +77,7 @@ const nodeBuilds = [ output: [ { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), treeshake: { moduleSideEffects: true @@ -144,7 +117,7 @@ const umdBuild = { ); }` }, - plugins: [...es5BuildPlugins, uglify()], + plugins: [...buildPlugins, uglify()], external: ['@firebase/app-compat', '@firebase/app'] }; diff --git a/packages/auth/api-extractor.json b/packages/auth/api-extractor.json index ca7e1ee6983..f7279fcac15 100644 --- a/packages/auth/api-extractor.json +++ b/packages/auth/api-extractor.json @@ -1,6 +1,6 @@ { "extends": "../../config/api-extractor.json", - "mainEntryPointFilePath": "/dist/esm5/index.d.ts", + "mainEntryPointFilePath": "/dist/esm2017/index.d.ts", "dtsRollup": { "enabled": true, "untrimmedFilePath": "/dist/.d.ts", diff --git a/packages/auth/cordova/demo/rollup.config.js b/packages/auth/cordova/demo/rollup.config.js index 252e2e6b622..21654b783d2 100644 --- a/packages/auth/cordova/demo/rollup.config.js +++ b/packages/auth/cordova/demo/rollup.config.js @@ -18,28 +18,15 @@ import resolve from '@rollup/plugin-node-resolve'; import strip from '@rollup/plugin-strip'; /** - * Common plugins for all builds + * Browser Build */ -const commonPlugins = [ - strip({ - functions: ['debugAssert.*'] - }) -]; +const esmBuild = { + input: 'src/index.js', + output: [{ file: 'www/dist/bundle.js', format: 'esm', sourcemap: true }], + plugins: [ + strip({ functions: ['debugAssert.*'] }), + resolve({ mainFields: ['module', 'main'] }) + ] +}; -const es5Builds = [ - /** - * Browser Builds - */ - { - input: 'src/index.js', - output: [{ file: 'www/dist/bundle.js', format: 'esm', sourcemap: true }], - plugins: [ - ...commonPlugins, - resolve({ - mainFields: ['module', 'main'] - }) - ] - } -]; - -export default [...es5Builds]; +export default esmBuild; diff --git a/packages/auth/demo/rollup.config.js b/packages/auth/demo/rollup.config.js index 49aff45b419..ce6a2893210 100644 --- a/packages/auth/demo/rollup.config.js +++ b/packages/auth/demo/rollup.config.js @@ -21,17 +21,8 @@ import typescript from 'typescript'; import pkg from './package.json'; -/** - * Common plugins for all builds - */ -const commonPlugins = [ - strip({ - functions: ['debugAssert.*'] - }) -]; - const workerPlugins = [ - ...commonPlugins, + strip({ functions: ['debugAssert.*'] }), resolve({ mainFields: ['webworker', 'module', 'main'] }), @@ -44,7 +35,7 @@ const workerPlugins = [ lib: [ // TODO: remove this 'dom', - 'es2015', + 'es2017', 'webworker' ] } @@ -52,30 +43,33 @@ const workerPlugins = [ }) ]; -const es5Builds = [ - /** - * Browser Builds - */ +const esmBuilds = [ { input: 'src/index.js', output: [{ file: pkg.browser, format: 'esm', sourcemap: true }], plugins: [ - ...commonPlugins, - resolve({ - mainFields: ['module', 'main'] - }) + strip({ functions: ['debugAssert.*'] }), + resolve({ mainFields: ['module', 'main'] }) ] }, { input: 'src/worker/web-worker.ts', - output: [{ file: pkg.webworker, format: 'esm', sourcemap: true }], + output: { + file: pkg.webworker, + format: 'esm', + sourcemap: true + }, plugins: workerPlugins }, { input: 'src/worker/service-worker.ts', - output: [{ file: pkg.serviceworker, format: 'esm', sourcemap: true }], + output: { + file: pkg.serviceworker, + format: 'esm', + sourcemap: true + }, plugins: workerPlugins } ]; -export default [...es5Builds]; +export default [...esmBuilds]; diff --git a/packages/auth/demo/src/worker/tsconfig.json b/packages/auth/demo/src/worker/tsconfig.json index e160c5c6b47..1081b12233f 100644 --- a/packages/auth/demo/src/worker/tsconfig.json +++ b/packages/auth/demo/src/worker/tsconfig.json @@ -2,9 +2,9 @@ "extends": "../../../config/tsconfig.base.json", "compilerOptions": { "outDir": "dist", - "target": "es2015", + "target": "es2017", "lib": [ - "es2015", + "es2017", "webworker" ] }, diff --git a/packages/auth/internal/package.json b/packages/auth/internal/package.json index 41b63d2c841..4ecfdccbd20 100644 --- a/packages/auth/internal/package.json +++ b/packages/auth/internal/package.json @@ -4,8 +4,7 @@ "main": "../dist/node/internal.js", "module": "../dist/esm2017/internal.js", "browser": "../dist/esm2017/internal.js", - "esm5": "../dist/esm5/internal.js", - "typings": "../dist/esm5/internal/index.d.ts", + "typings": "../dist/esm2017/internal/index.d.ts", "private": true, "engines": { "node": ">=18.0.0" diff --git a/packages/auth/package.json b/packages/auth/package.json index 42616cd4f0f..e30312d4b68 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -9,8 +9,7 @@ "module": "dist/esm2017/index.js", "cordova": "dist/cordova/index.js", "web-extension": "dist/web-extension-esm2017/index.js", - "webworker": "dist/index.webworker.esm5.js", - "esm5": "dist/esm5/index.js", + "webworker": "dist/index.webworker.js", "exports": { ".": { "types": "./dist/auth-public.d.ts", @@ -29,9 +28,8 @@ }, "webworker": { "types": "./dist/index.webworker.d.ts", - "default": "./dist/index.webworker.esm5.js" + "default": "./dist/index.webworker.js" }, - "esm5": "./dist/esm5/index.js", "browser": { "require": "./dist/browser-cjs/index.js", "import": "./dist/esm2017/index.js" @@ -63,7 +61,6 @@ "types": "./dist/cordova/internal/index.d.ts", "default": "./dist/cordova/internal.js" }, - "esm5": "./dist/esm5/internal.js", "browser": { "require": "./dist/browser-cjs/internal.js", "import": "./dist/esm2017/internal.js" diff --git a/packages/auth/rollup.config.js b/packages/auth/rollup.config.js index 46d3ee0380d..6af229962bd 100644 --- a/packages/auth/rollup.config.js +++ b/packages/auth/rollup.config.js @@ -44,44 +44,13 @@ const nodeAliasPlugin = alias({ ] }); -const es5BuildPlugins = [ +const buildPlugins = [ json(), - strip({ - functions: ['debugAssert.*'] - }), - typescriptPlugin({ - typescript - }) -]; - -const es2017BuildPlugins = [ - json(), - strip({ - functions: ['debugAssert.*'] - }), - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) + strip({ functions: ['debugAssert.*'] }), + typescriptPlugin({ typescript }) ]; const browserBuilds = [ - { - input: { - index: 'index.ts', - internal: 'internal/index.ts' - }, - output: [{ dir: 'dist/esm5', format: 'es', sourcemap: true }], - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: { index: 'index.ts', @@ -93,7 +62,7 @@ const browserBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) @@ -105,7 +74,7 @@ const browserBuilds = [ }, output: [{ dir: 'dist/browser-cjs', format: 'cjs', sourcemap: true }], plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) @@ -124,7 +93,7 @@ const browserWebExtensionBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)), emitModulePackageFile() ], @@ -137,7 +106,7 @@ const browserWebExtensionBuilds = [ }, output: [{ dir: 'dist/web-extension-cjs', format: 'cjs', sourcemap: true }], plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) @@ -153,8 +122,8 @@ const nodeBuilds = [ output: [{ dir: 'dist/node', format: 'cjs', sourcemap: true }], plugins: [ nodeAliasPlugin, - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, @@ -166,7 +135,7 @@ const nodeBuilds = [ output: [{ dir: 'dist/node-esm', format: 'es', sourcemap: true }], plugins: [ nodeAliasPlugin, - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)), emitModulePackageFile() ], @@ -179,10 +148,14 @@ const cordovaBuild = { index: 'index.cordova.ts', internal: 'internal/index.ts' }, - output: [{ dir: 'dist/cordova', format: 'es', sourcemap: true }], + output: { + dir: 'dist/cordova', + format: 'es', + sourcemap: true + }, plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)) ], external: id => [...deps, 'cordova'].some(dep => id === dep || id.startsWith(`${dep}/`)) @@ -195,8 +168,8 @@ const rnBuild = { }, output: [{ dir: 'dist/rn', format: 'cjs', sourcemap: true }], plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => [...deps, 'react-native'].some( @@ -206,7 +179,11 @@ const rnBuild = { const webWorkerBuild = { input: 'index.webworker.ts', - output: [{ file: pkg.webworker, format: 'es', sourcemap: true }], + output: { + file: pkg.webworker, + format: 'es', + sourcemap: true + }, plugins: [ json(), strip({ @@ -218,12 +195,12 @@ const webWorkerBuild = { lib: [ // Remove dom after we figure out why navigator stuff doesn't exist 'dom', - 'es2015', + 'es2017', 'webworker' ] } }), - replace(generateBuildTargetReplaceConfig('esm', 5)) + replace(generateBuildTargetReplaceConfig('esm', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }; diff --git a/packages/auth/src/core/auth/register.ts b/packages/auth/src/core/auth/register.ts index 4b891618d3a..9d0d6b4559d 100644 --- a/packages/auth/src/core/auth/register.ts +++ b/packages/auth/src/core/auth/register.ts @@ -130,6 +130,6 @@ export function registerAuth(clientPlatform: ClientPlatform): void { ); registerVersion(name, version, getVersionForPlatform(clientPlatform)); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/component/package.json b/packages/component/package.json index 46f7a83720d..1f3b8ad51a8 100644 --- a/packages/component/package.json +++ b/packages/component/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/component/rollup.config.js b/packages/component/rollup.config.js index f0cc1a84e98..11d18692c8c 100644 --- a/packages/component/rollup.config.js +++ b/packages/component/rollup.config.js @@ -24,49 +24,24 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }) -]; +const buildPlugins = [typescriptPlugin({ typescript })]; -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; +const esmBuild = { + input: 'index.ts', + output: { file: pkg.module, format: 'es', sourcemap: true }, + plugins: [...buildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -const esmBuilds = [ - { - input: 'index.ts', - output: { file: pkg.module, format: 'es', sourcemap: true }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +const cjsBuild = { + input: 'index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true }, - { - input: 'index.ts', - output: { - file: pkg.esm5, - format: 'es', - sourcemap: true - }, - plugins: [...es5BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; + plugins: buildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -const cjsBuilds = [ - { - input: 'index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/database-compat/package.json b/packages/database-compat/package.json index 36769537e9c..be50b28f6fa 100644 --- a/packages/database-compat/package.json +++ b/packages/database-compat/package.json @@ -6,7 +6,6 @@ "main": "dist/index.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "license": "Apache-2.0", "typings": "dist/database-compat/src/index.d.ts", "files": [ @@ -21,7 +20,6 @@ "import": "./dist/node-esm/index.js", "require": "./dist/index.js" }, - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.js", "import": "./dist/index.esm2017.js" diff --git a/packages/database-compat/rollup.config.js b/packages/database-compat/rollup.config.js index bba2fba3c44..57ec9aee2ba 100644 --- a/packages/database-compat/rollup.config.js +++ b/packages/database-compat/rollup.config.js @@ -34,24 +34,11 @@ function onWarn(warning, defaultWarn) { defaultWarn(warning); } -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, abortOnError: false }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), json({ preferConst: true }) ]; @@ -68,7 +55,7 @@ const esmBuilds = [ sourcemap: true } ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + plugins: [...buildPlugins, emitModulePackageFile()], treeshake: { moduleSideEffects: false }, @@ -76,24 +63,8 @@ const esmBuilds = [ onwarn: onWarn }, /** - * Browser Builds + * Browser Build */ - { - input: 'src/index.ts', - output: [ - { - file: pkg.esm5, - format: 'es', - sourcemap: true - } - ], - plugins: es5BuildPlugins, - treeshake: { - moduleSideEffects: false - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - onwarn: onWarn - }, { input: 'src/index.ts', output: [ @@ -103,7 +74,7 @@ const esmBuilds = [ sourcemap: true } ], - plugins: es2017BuildPlugins, + plugins: buildPlugins, treeshake: { moduleSideEffects: false }, @@ -125,7 +96,7 @@ const cjsBuilds = [ sourcemap: true } ], - plugins: es5BuildPlugins, + plugins: buildPlugins, treeshake: { moduleSideEffects: false }, @@ -146,7 +117,7 @@ const cjsBuilds = [ } ], plugins: [ - ...es5BuildPlugins, + ...buildPlugins, resolveModule({ exportConditions: ['standalone'], preferBuiltins: true diff --git a/packages/database/package.json b/packages/database/package.json index 05ff943e675..14f30231f17 100644 --- a/packages/database/package.json +++ b/packages/database/package.json @@ -6,7 +6,6 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "standalone": "dist/index.standalone.js", "exports": { ".": { @@ -15,7 +14,6 @@ "import": "./dist/node-esm/index.node.esm.js", "require": "./dist/index.node.cjs.js" }, - "esm5": "./dist/index.esm5.js", "standalone": "./dist/index.standalone.js", "browser": { "require": "./dist/index.cjs.js", diff --git a/packages/database/rollup.config.js b/packages/database/rollup.config.js index 886a177e4d9..293eaf06811 100644 --- a/packages/database/rollup.config.js +++ b/packages/database/rollup.config.js @@ -35,47 +35,15 @@ function onWarn(warning, defaultWarn) { defaultWarn(warning); } -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, abortOnError: false }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), json({ preferConst: true }) ]; const browserBuilds = [ - { - input: 'src/index.ts', - output: [ - { - file: pkg.esm5, - format: 'es', - sourcemap: true - } - ], - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], - treeshake: { - moduleSideEffects: false - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - onwarn: onWarn - }, { input: 'src/index.ts', output: [ @@ -86,7 +54,7 @@ const browserBuilds = [ } ], plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)) ], treeshake: { @@ -105,7 +73,7 @@ const browserBuilds = [ } ], plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], treeshake: { @@ -119,10 +87,14 @@ const browserBuilds = [ const nodeBuilds = [ { input: 'src/index.node.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], treeshake: { moduleSideEffects: false @@ -138,7 +110,7 @@ const nodeBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)), emitModulePackageFile() ], @@ -154,7 +126,7 @@ const nodeBuilds = [ { input: 'src/index.standalone.ts', output: [{ file: pkg.standalone, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, + plugins: buildPlugins, treeshake: { moduleSideEffects: false }, diff --git a/packages/database/src/register.ts b/packages/database/src/register.ts index cd2be0aaa7e..9322368526b 100644 --- a/packages/database/src/register.ts +++ b/packages/database/src/register.ts @@ -47,6 +47,6 @@ export function registerDatabase(variant?: string): void { ).setMultipleInstances(true) ); registerVersion(name, version, variant); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/firebase/compat/rollup.config.js b/packages/firebase/compat/rollup.config.js index 4b481b93b1f..1f850011b13 100644 --- a/packages/firebase/compat/rollup.config.js +++ b/packages/firebase/compat/rollup.config.js @@ -284,43 +284,16 @@ const completeBuilds = [ }, plugins: [ sourcemaps(), - resolveModule({ - exportConditions: ['liteesm5', 'esm5'] - }), - typescriptPluginCDN, - json(), - commonjs(), - uglify(uglifyOptions) - ] - }, - /** - * Performance script Build in ES2017 - */ - { - input: `${__dirname}/index.perf.ts`, - output: { - file: 'firebase-performance-standalone-compat.es2017.js', - format: 'umd', - sourcemap: true, - name: GLOBAL_NAME - }, - plugins: [ - sourcemaps(), - resolveModule({ - exportConditions: ['lite'] - }), + resolveModule({ exportConditions: ['lite'] }), rollupTypescriptPlugin({ typescript, tsconfigOverride: { compilerOptions: { - target: 'es2017', declaration: false } } }), - json({ - preferConst: true - }), + json({ preferConst: true }), commonjs(), terser() ] diff --git a/packages/firestore-compat/package.json b/packages/firestore-compat/package.json index cef35d62ce4..2994067a633 100644 --- a/packages/firestore-compat/package.json +++ b/packages/firestore-compat/package.json @@ -7,7 +7,6 @@ "react-native": "dist/index.rn.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "exports": { ".": { "types": "./dist/src/index.d.ts", @@ -16,7 +15,6 @@ "require": "./dist/index.node.cjs.js" }, "react-native": "./dist/index.rn.js", - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/firestore-compat/rollup.config.js b/packages/firestore-compat/rollup.config.js index ecf6d42ca91..c85af11225f 100644 --- a/packages/firestore-compat/rollup.config.js +++ b/packages/firestore-compat/rollup.config.js @@ -38,14 +38,6 @@ const es2017Plugins = [ json({ preferConst: true }) ]; -const es5Plugins = [ - typescriptPlugin({ - typescript, - transformers: [util.removeAssertTransformer] - }), - json({ preferConst: true }) -]; - const browserBuilds = [ { input: './src/index.ts', @@ -57,18 +49,6 @@ const browserBuilds = [ plugins: es2017Plugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, - { - input: './src/index.ts', - output: [ - { - file: pkg.esm5, - format: 'es', - sourcemap: true - } - ], - plugins: es5Plugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: './src/index.ts', output: [ diff --git a/packages/firestore/lite/package.json b/packages/firestore/lite/package.json index b36ddf80218..ef362535fdb 100644 --- a/packages/firestore/lite/package.json +++ b/packages/firestore/lite/package.json @@ -6,7 +6,6 @@ "module": "../dist/lite/index.browser.esm2017.js", "browser": "../dist/lite/index.browser.esm2017.js", "react-native": "../dist/lite/index.rn.esm2017.js", - "esm5": "../dist/lite/index.browser.esm5.js", "typings": "../dist/lite/index.d.ts", "private": true, "engines": { diff --git a/packages/firestore/package.json b/packages/firestore/package.json index f15127ae499..5268cad97cb 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -62,7 +62,6 @@ "import": "./dist/index.node.mjs" }, "react-native": "./dist/index.rn.js", - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" @@ -76,7 +75,6 @@ "import": "./dist/lite/index.node.mjs" }, "react-native": "./dist/lite/index.rn.esm2017.js", - "esm5": "./dist/lite/index.browser.esm5.js", "browser": { "require": "./dist/lite/index.cjs.js", "import": "./dist/lite/index.browser.esm2017.js" @@ -90,7 +88,6 @@ "react-native": "dist/index.rn.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "license": "Apache-2.0", "files": [ "dist", diff --git a/packages/firestore/rollup.config.js b/packages/firestore/rollup.config.js index 0f6a42205fd..c9604fee55d 100644 --- a/packages/firestore/rollup.config.js +++ b/packages/firestore/rollup.config.js @@ -32,43 +32,29 @@ import pkg from './package.json'; const sourcemaps = require('rollup-plugin-sourcemaps'); const util = require('./rollup.shared'); -const nodePlugins = function () { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - cacheDir: tmp.dirSync(), - abortOnError: true, - transformers: [util.removeAssertTransformer] - }), - json({ preferConst: true }), - replace({ - '__GRPC_VERSION__': grpcVersion - }) - ]; -}; +const nodePlugins = [ + typescriptPlugin({ + typescript, + cacheDir: tmp.dirSync(), + abortOnError: true, + transformers: [util.removeAssertTransformer] + }), + json({ preferConst: true }), + replace({ + '__GRPC_VERSION__': grpcVersion + }) +]; -const browserPlugins = function () { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - cacheDir: tmp.dirSync(), - abortOnError: true, - transformers: [util.removeAssertAndPrefixInternalTransformer] - }), - json({ preferConst: true }), - terser(util.manglePrivatePropertiesOptions) - ]; -}; +const browserPlugins = [ + typescriptPlugin({ + typescript, + cacheDir: tmp.dirSync(), + abortOnError: true, + transformers: [util.removeAssertAndPrefixInternalTransformer] + }), + json({ preferConst: true }), + terser(util.manglePrivatePropertiesOptions) +]; const allBuilds = [ // Intermediate Node ESM build without build target reporting @@ -81,7 +67,7 @@ const allBuilds = [ format: 'es', sourcemap: true }, - plugins: [alias(util.generateAliasConfig('node')), ...nodePlugins()], + plugins: [alias(util.generateAliasConfig('node')), ...nodePlugins], external: util.resolveNodeExterns, treeshake: { moduleSideEffects: false @@ -97,7 +83,17 @@ const allBuilds = [ sourcemap: true }, plugins: [ - ...util.es2017ToEs5Plugins(/* mangled= */ false), + typescriptPlugin({ + typescript, + tsconfigOverride: { + compilerOptions: { + allowJs: true + } + }, + include: ['dist/**/*.js'], + cacheDir: tmp.dirSync() + }), + sourcemaps(), replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: util.resolveNodeExterns, @@ -132,26 +128,7 @@ const allBuilds = [ format: 'es', sourcemap: true }, - plugins: [alias(util.generateAliasConfig('browser')), ...browserPlugins()], - external: util.resolveBrowserExterns, - treeshake: { - moduleSideEffects: false - } - }, - // Convert es2017 build to ES5 - { - input: pkg['browser'], - output: [ - { - file: pkg['esm5'], - format: 'es', - sourcemap: true - } - ], - plugins: [ - ...util.es2017ToEs5Plugins(/* mangled= */ true), - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], + plugins: [alias(util.generateAliasConfig('browser')), ...browserPlugins], external: util.resolveBrowserExterns, treeshake: { moduleSideEffects: false @@ -205,7 +182,7 @@ const allBuilds = [ }, plugins: [ alias(util.generateAliasConfig('rn')), - ...browserPlugins(), + ...browserPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)) ], external: util.resolveBrowserExterns, diff --git a/packages/firestore/rollup.config.lite.js b/packages/firestore/rollup.config.lite.js index 369a9210262..25209966fe8 100644 --- a/packages/firestore/rollup.config.lite.js +++ b/packages/firestore/rollup.config.lite.js @@ -30,40 +30,26 @@ import { generateBuildTargetReplaceConfig } from '../../scripts/build/rollup_rep const util = require('./rollup.shared'); -const nodePlugins = function () { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - cacheDir: tmp.dirSync(), - abortOnError: true, - transformers: [util.removeAssertTransformer] - }), - json({ preferConst: true }) - ]; -}; +const nodePlugins = [ + typescriptPlugin({ + typescript, + cacheDir: tmp.dirSync(), + abortOnError: true, + transformers: [util.removeAssertTransformer] + }), + json({ preferConst: true }) +]; -const browserPlugins = function () { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - cacheDir: tmp.dirSync(), - abortOnError: true, - transformers: [util.removeAssertAndPrefixInternalTransformer] - }), - json({ preferConst: true }), - terser(util.manglePrivatePropertiesOptions) - ]; -}; +const browserPlugins = [ + typescriptPlugin({ + typescript, + cacheDir: tmp.dirSync(), + abortOnError: true, + transformers: [util.removeAssertAndPrefixInternalTransformer] + }), + json({ preferConst: true }), + terser(util.manglePrivatePropertiesOptions) +]; const allBuilds = [ // Intermediate Node ESM build without build target reporting @@ -78,7 +64,7 @@ const allBuilds = [ }, plugins: [ alias(util.generateAliasConfig('node_lite')), - ...nodePlugins(), + ...nodePlugins, replace({ '__RUNTIME_ENV__': 'node' }) @@ -101,14 +87,13 @@ const allBuilds = [ typescriptPlugin({ typescript, compilerOptions: { - allowJs: true, - target: 'es5' + allowJs: true }, include: ['dist/lite/*.js'] }), json(), sourcemaps(), - replace(generateBuildTargetReplaceConfig('cjs', 5)) + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: util.resolveNodeExterns, treeshake: { @@ -144,7 +129,7 @@ const allBuilds = [ }, plugins: [ alias(util.generateAliasConfig('browser_lite')), - ...browserPlugins(), + ...browserPlugins, // setting it to empty string because browser is the default env replace({ '__RUNTIME_ENV__': '' @@ -155,25 +140,6 @@ const allBuilds = [ moduleSideEffects: false } }, - // Convert es2017 build to ES5 - { - input: path.resolve('./lite', pkg.browser), - output: [ - { - file: path.resolve('./lite', pkg.esm5), - format: 'es', - sourcemap: true - } - ], - plugins: [ - ...util.es2017ToEs5Plugins(/* mangled= */ true), - replace(generateBuildTargetReplaceConfig('esm', 5)) - ], - external: util.resolveBrowserExterns, - treeshake: { - moduleSideEffects: false - } - }, // Convert es2017 build to CJS { input: path.resolve('./lite', pkg.browser), @@ -222,7 +188,7 @@ const allBuilds = [ }, plugins: [ alias(util.generateAliasConfig('rn_lite')), - ...browserPlugins(), + ...browserPlugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': 'rn' diff --git a/packages/firestore/rollup.shared.js b/packages/firestore/rollup.shared.js index 44253d24d38..1b33ddf0b1b 100644 --- a/packages/firestore/rollup.shared.js +++ b/packages/firestore/rollup.shared.js @@ -34,10 +34,9 @@ const pkg = require('./package.json'); // This file contains shared utilities for Firestore's rollup builds. // Firestore is released in a number of different build configurations: -// - Browser builds that support persistence in ES5 CJS and ES5 ESM formats and -// ES2017 in ESM format. -// - In-memory Browser builds that support persistence in ES5 CJS and ES5 ESM -// formats and ES2017 in ESM format. +// - Browser builds that support persistence in ES2017 CJS and ESM formats. +// - In-memory Browser builds that support persistence in ES2017 CJS and ESM +// formats. // - A NodeJS build that supports persistence (to be used with an IndexedDb // shim) // - A in-memory only NodeJS build @@ -248,11 +247,6 @@ exports.es2017Plugins = function (platform, mangled = false) { alias(generateAliasConfig(platform)), typescriptPlugin({ typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, cacheDir: tmp.dirSync(), transformers: [removeAssertAndPrefixInternalTransformer] }), @@ -264,11 +258,6 @@ exports.es2017Plugins = function (platform, mangled = false) { alias(generateAliasConfig(platform)), typescriptPlugin({ typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, cacheDir: tmp.dirSync(), transformers: [removeAssertTransformer] }), @@ -277,50 +266,6 @@ exports.es2017Plugins = function (platform, mangled = false) { } }; -exports.es2017ToEs5Plugins = function (mangled = false) { - if (mangled) { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - allowJs: true - } - }, - include: ['dist/**/*.js'], - cacheDir: tmp.dirSync() - }), - terser({ - output: { - comments: 'all', - beautify: true - }, - // See comment above `manglePrivatePropertiesOptions`. This build did - // not have the identical variable name issue but we should be - // consistent. - mangle: { - reserved: ['_getProvider'] - } - }), - sourcemaps() - ]; - } else { - return [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - allowJs: true - } - }, - include: ['dist/**/*.js'], - cacheDir: tmp.dirSync() - }), - sourcemaps() - ]; - } -}; - exports.es2017PluginsCompat = function ( platform, pathTransformer, @@ -331,11 +276,6 @@ exports.es2017PluginsCompat = function ( alias(generateAliasConfig(platform)), typescriptPlugin({ typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, cacheDir: tmp.dirSync(), abortOnError: true, transformers: [ @@ -351,11 +291,6 @@ exports.es2017PluginsCompat = function ( alias(generateAliasConfig(platform)), typescriptPlugin({ typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, cacheDir: tmp.dirSync(), abortOnError: true, transformers: [removeAssertTransformer, pathTransformer] diff --git a/packages/firestore/src/register.ts b/packages/firestore/src/register.ts index 3abb38c9d86..573ac6f2020 100644 --- a/packages/firestore/src/register.ts +++ b/packages/firestore/src/register.ts @@ -60,6 +60,6 @@ export function registerFirestore( ).setMultipleInstances(true) ); registerVersion(name, version, variant); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/firestore/test/unit/specs/spec_rpc_error.ts b/packages/firestore/test/unit/specs/spec_rpc_error.ts index 8d4a7073861..0560bdd65db 100644 --- a/packages/firestore/test/unit/specs/spec_rpc_error.ts +++ b/packages/firestore/test/unit/specs/spec_rpc_error.ts @@ -33,7 +33,8 @@ export class RpcError extends Error { this.code = mapRpcCodeFromCode(code); } - // TODO(mikelehen): Error is a function not a class in ES5 so extending it + // TODO(dlarocque): Improve this since we no longer target ES5. + // Error is a function not a class in ES5 so extending it // doesn't really work without hackery. Just manually set .message for now. this.message = message; } diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index d30a085e30b..484df1c5a70 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -6,7 +6,6 @@ "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "exports": { ".": { "types": "./dist/src/index.d.ts", @@ -14,7 +13,6 @@ "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" }, - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/functions-compat/rollup.config.js b/packages/functions-compat/rollup.config.js index 53aad50475a..6ac98783eae 100644 --- a/packages/functions-compat/rollup.config.js +++ b/packages/functions-compat/rollup.config.js @@ -25,32 +25,14 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; const browserBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: 'src/index.ts', output: { @@ -58,7 +40,7 @@ const browserBuilds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { @@ -68,7 +50,7 @@ const browserBuilds = [ format: 'cjs', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; diff --git a/packages/functions/package.json b/packages/functions/package.json index 084bd1b28db..33cf52bfbb2 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -6,7 +6,6 @@ "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm.js", "exports": { ".": { "types": "./dist/functions-public.d.ts", @@ -14,7 +13,6 @@ "import": "./dist/index.esm2017.js", "require": "./dist/index.cjs.js" }, - "esm5": "./dist/index.esm.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/functions/rollup.config.js b/packages/functions/rollup.config.js index 4bc7f73d869..bb950655646 100644 --- a/packages/functions/rollup.config.js +++ b/packages/functions/rollup.config.js @@ -27,35 +27,14 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; const browserBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)) - ] - }, { input: 'src/index.ts', output: { @@ -65,7 +44,7 @@ const browserBuilds = [ }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)) ] }, @@ -78,7 +57,7 @@ const browserBuilds = [ }, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('cjs', 2017)) ] } diff --git a/packages/functions/src/config.ts b/packages/functions/src/config.ts index 656158da10d..8dfadb52b54 100644 --- a/packages/functions/src/config.ts +++ b/packages/functions/src/config.ts @@ -65,6 +65,6 @@ export function registerFunctions(variant?: string): void { ); registerVersion(name, version, variant); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/installations-compat/package.json b/packages/installations-compat/package.json index bc663d6f2ce..44115221348 100644 --- a/packages/installations-compat/package.json +++ b/packages/installations-compat/package.json @@ -5,12 +5,10 @@ "main": "dist/index.cjs.js", "module": "dist/esm/index.esm2017.js", "browser": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/installations-compat/rollup.config.js b/packages/installations-compat/rollup.config.js index dff41008688..839c66d4413 100644 --- a/packages/installations-compat/rollup.config.js +++ b/packages/installations-compat/rollup.config.js @@ -23,45 +23,33 @@ import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_pa const deps = Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies }); -const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } + typescript }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...buildPlugins, emitModulePackageFile()] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: buildPlugins +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/installations/package.json b/packages/installations/package.json index ff6c74bd23d..e6093c759d6 100644 --- a/packages/installations/package.json +++ b/packages/installations/package.json @@ -5,12 +5,10 @@ "main": "dist/index.cjs.js", "module": "dist/esm/index.esm2017.js", "browser": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/installations-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/installations/rollup.config.js b/packages/installations/rollup.config.js index 70628504fdb..7d083c63320 100644 --- a/packages/installations/rollup.config.js +++ b/packages/installations/rollup.config.js @@ -25,57 +25,40 @@ import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_pa const deps = [...Object.keys({ ...pkg.peerDependencies, ...pkg.dependencies })]; -const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; - -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } + typescript }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)), - emitModulePackageFile() - ] +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)), - emitModulePackageFile() - ] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) + ] +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/installations/src/index.ts b/packages/installations/src/index.ts index c16abc2b0b1..5a70ef10846 100644 --- a/packages/installations/src/index.ts +++ b/packages/installations/src/index.ts @@ -31,5 +31,5 @@ export * from './interfaces/public-types'; registerInstallations(); registerVersion(name, version); -// BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation +// BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); diff --git a/packages/installations/src/testing/compare-headers.ts b/packages/installations/src/testing/compare-headers.ts index 5b93c14933e..6c3681b3ca0 100644 --- a/packages/installations/src/testing/compare-headers.ts +++ b/packages/installations/src/testing/compare-headers.ts @@ -18,6 +18,7 @@ import { AssertionError, expect } from 'chai'; // Trick TS since it's set to target ES5. +// TODO(dlarocque): Improve this since we no longer target ES5. declare class HeadersWithEntries extends Headers { entries?(): Iterable<[string, string]>; } diff --git a/packages/logger/package.json b/packages/logger/package.json index 36131004285..14131f73258 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -5,12 +5,10 @@ "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/logger/rollup.config.js b/packages/logger/rollup.config.js index e6bfbb4efe5..0089b01c801 100644 --- a/packages/logger/rollup.config.js +++ b/packages/logger/rollup.config.js @@ -20,53 +20,32 @@ import typescript from 'typescript'; import pkg from './package.json'; import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }) -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; +const buildPlugins = [typescriptPlugin({ typescript })]; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const esmBuilds = [ - { - input: 'index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: [...es5BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +const esmBuild = { + input: 'index.ts', + output: { + file: pkg.module, + format: 'es', + sourcemap: true }, - { - input: 'index.ts', - output: { - file: pkg.module, - format: 'es', - sourcemap: true - }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; + plugins: [...buildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -const cjsBuilds = [ - { - input: 'index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; +const cjsBuild = { + input: 'index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/messaging-compat/package.json b/packages/messaging-compat/package.json index 3d529a8eb5b..628d5801668 100644 --- a/packages/messaging-compat/package.json +++ b/packages/messaging-compat/package.json @@ -7,12 +7,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/messaging-compat/rollup.config.js b/packages/messaging-compat/rollup.config.js index 2bc0cecded0..b8a320641fc 100644 --- a/packages/messaging-compat/rollup.config.js +++ b/packages/messaging-compat/rollup.config.js @@ -25,51 +25,33 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: [...es5BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; + plugins: [...buildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/messaging/package.json b/packages/messaging/package.json index 674b2feb246..e191118271f 100644 --- a/packages/messaging/package.json +++ b/packages/messaging/package.json @@ -8,13 +8,11 @@ "module": "dist/esm/index.esm2017.js", "sw": "dist/esm/index.sw.esm2017.js", "sw-main": "dist/index.sw.cjs", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/index-public.d.ts", "require": "./dist/index.cjs.js", "module": "./dist/esm/index.esm2017.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./sw": { diff --git a/packages/messaging/rollup.config.js b/packages/messaging/rollup.config.js index 297dc00c46f..506f0d30261 100644 --- a/packages/messaging/rollup.config.js +++ b/packages/messaging/rollup.config.js @@ -27,36 +27,14 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }), - json() -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }), json({ preferConst: true }) ]; const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)), - emitModulePackageFile() - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: 'src/index.ts', output: { @@ -65,7 +43,7 @@ const esmBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace(generateBuildTargetReplaceConfig('esm', 2017)), emitModulePackageFile() ], @@ -74,8 +52,12 @@ const esmBuilds = [ // sw builds { input: 'src/index.sw.ts', - output: { file: pkg.sw, format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + output: { + file: pkg.sw, + format: 'es', + sourcemap: true + }, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; @@ -83,10 +65,14 @@ const esmBuilds = [ const cjsBuilds = [ { input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, @@ -95,12 +81,13 @@ const cjsBuilds = [ // builds (contingent on updating the `idb` dependency). When we add // ESM Node builds, test with Nuxt and other SSR frameworks to see if // this can then be removed. + // TODO(dlarocque): ask Christina about this { input: 'src/index.sw.ts', output: { file: pkg['sw-main'], format: 'cjs', sourcemap: true }, plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } diff --git a/packages/messaging/src/helpers/register.ts b/packages/messaging/src/helpers/register.ts index 7a9176f96d2..ef28cd2edad 100644 --- a/packages/messaging/src/helpers/register.ts +++ b/packages/messaging/src/helpers/register.ts @@ -104,7 +104,7 @@ export function registerMessagingInWindow(): void { ); registerVersion(name, version); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/messaging/src/testing/compare-headers.ts b/packages/messaging/src/testing/compare-headers.ts index 6f760caf32d..4e6ea3e489d 100644 --- a/packages/messaging/src/testing/compare-headers.ts +++ b/packages/messaging/src/testing/compare-headers.ts @@ -20,6 +20,7 @@ import './setup'; import { expect } from 'chai'; // Trick TS since it's set to target ES5. +// TODO(dlarocque): Improve this since we no longer target ES5. declare class HeadersWithEntries extends Headers { entries?(): Iterable<[string, string]>; } diff --git a/packages/performance-compat/package.json b/packages/performance-compat/package.json index 72a12d37042..0e657021ff6 100644 --- a/packages/performance-compat/package.json +++ b/packages/performance-compat/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/performance-compat/rollup.config.js b/packages/performance-compat/rollup.config.js index d64b7bb89e5..e52495c401e 100644 --- a/packages/performance-compat/rollup.config.js +++ b/packages/performance-compat/rollup.config.js @@ -25,14 +25,7 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }), - json() -]; - -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, tsconfigOverride: { @@ -46,32 +39,26 @@ const es2017BuildPlugins = [ }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...buildPlugins, emitModulePackageFile()] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: buildPlugins +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/performance/package.json b/packages/performance/package.json index de60407f2d4..7748cf3d3aa 100644 --- a/packages/performance/package.json +++ b/packages/performance/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/performance/rollup.config.js b/packages/performance/rollup.config.js index 4816210933d..4752b5cfc02 100644 --- a/packages/performance/rollup.config.js +++ b/packages/performance/rollup.config.js @@ -27,52 +27,36 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [typescriptPlugin({ typescript }), json()]; -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } + typescript }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)), - emitModulePackageFile() - ] - }, - { - input: 'src/index.ts', - output: [{ file: pkg.browser, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)), - emitModulePackageFile() - ] - } -]; +const esmBuild = { + input: 'src/index.ts', + output: [{ file: pkg.browser, format: 'es', sourcemap: true }], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 5)) + ] +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/performance/src/index.ts b/packages/performance/src/index.ts index 4d3713f0614..4ccb499b368 100644 --- a/packages/performance/src/index.ts +++ b/packages/performance/src/index.ts @@ -137,7 +137,7 @@ function registerPerformance(): void { new Component('performance', factory, ComponentType.PUBLIC) ); registerVersion(name, version); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/remote-config-compat/package.json b/packages/remote-config-compat/package.json index 1ea2ed030d5..40c7bd6fc9c 100644 --- a/packages/remote-config-compat/package.json +++ b/packages/remote-config-compat/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/remote-config-compat/rollup.config.js b/packages/remote-config-compat/rollup.config.js index d64b7bb89e5..e52495c401e 100644 --- a/packages/remote-config-compat/rollup.config.js +++ b/packages/remote-config-compat/rollup.config.js @@ -25,14 +25,7 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }), - json() -]; - -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, tsconfigOverride: { @@ -46,32 +39,26 @@ const es2017BuildPlugins = [ }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es5BuildPlugins, emitModulePackageFile()] +const esmBuild = { + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [...es2017BuildPlugins, emitModulePackageFile()] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [...buildPlugins, emitModulePackageFile()] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: { file: pkg.main, format: 'cjs', sourcemap: true }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: es5BuildPlugins - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: buildPlugins +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/remote-config/package.json b/packages/remote-config/package.json index c38dbc0ef26..f089e972b49 100644 --- a/packages/remote-config/package.json +++ b/packages/remote-config/package.json @@ -6,12 +6,10 @@ "main": "dist/index.cjs.js", "browser": "dist/esm/index.esm2017.js", "module": "dist/esm/index.esm2017.js", - "esm5": "dist/esm/index.esm.js", "exports": { ".": { "types": "./dist/remote-config-public.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/remote-config/rollup.config.js b/packages/remote-config/rollup.config.js index dba933fa417..a7209c67e09 100644 --- a/packages/remote-config/rollup.config.js +++ b/packages/remote-config/rollup.config.js @@ -26,68 +26,44 @@ import pkg from './package.json'; const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -/** - * ES5 Builds - */ -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }), - json() -]; -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } + typescript }), json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 5)), - emitModulePackageFile() - ] +const esmBuild = { + /** + * Browser Build + */ + input: 'src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - /** - * Browser Build - */ - input: 'src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)), - emitModulePackageFile() - ] - } -]; + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() + ] +}; -const cjsBuilds = [ - { - input: 'src/index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - } -]; +const cjsBuild = { + input: 'src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), + plugins: [ + ...buildPlugins, + replace(generateBuildTargetReplaceConfig('cjs', 2017)) + ] +}; -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/remote-config/src/register.ts b/packages/remote-config/src/register.ts index ac8a8aae755..ff83e761888 100644 --- a/packages/remote-config/src/register.ts +++ b/packages/remote-config/src/register.ts @@ -52,7 +52,7 @@ export function registerRemoteConfig(): void { ); registerVersion(packageName, version); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(packageName, version, '__BUILD_TARGET__'); function remoteConfigFactory( diff --git a/packages/rules-unit-testing/rollup.config.js b/packages/rules-unit-testing/rollup.config.js index bd56861015b..5811401fb74 100644 --- a/packages/rules-unit-testing/rollup.config.js +++ b/packages/rules-unit-testing/rollup.config.js @@ -20,23 +20,12 @@ import pkg from './package.json'; import typescript from 'typescript'; import { emitModulePackageFile } from '../../scripts/build/rollup_emit_module_package_file'; -const plugins = [ +const buildPlugins = [ typescriptPlugin({ typescript }) ]; -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; - const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); @@ -44,16 +33,22 @@ const deps = Object.keys( export default [ { input: 'index.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: [...plugins], + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: [...buildPlugins], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { input: 'index.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + output: { + file: pkg.exports['.'].node.import, + format: 'es', + sourcemap: true + }, + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; diff --git a/packages/rules-unit-testing/src/impl/test_environment.ts b/packages/rules-unit-testing/src/impl/test_environment.ts index 5e0f4c613fe..eaafee85060 100644 --- a/packages/rules-unit-testing/src/impl/test_environment.ts +++ b/packages/rules-unit-testing/src/impl/test_environment.ts @@ -125,7 +125,7 @@ export class RulesTestEnvironmentImpl implements RulesTestEnvironment { return this.withSecurityRulesDisabled(async context => { const { items } = await context.storage().ref().listAll(); await Promise.all( - items.map(item => { + items.map((item: { delete: () => any }) => { return item.delete(); }) ); diff --git a/packages/storage-compat/package.json b/packages/storage-compat/package.json index 1ebccb8f29d..35bb7d57f9a 100644 --- a/packages/storage-compat/package.json +++ b/packages/storage-compat/package.json @@ -6,12 +6,10 @@ "main": "./dist/index.cjs.js", "browser": "./dist/esm/index.esm2017.js", "module": "./dist/esm/index.esm2017.js", - "esm5": "./dist/esm/index.esm5.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "require": "./dist/index.cjs.js", - "esm5": "./dist/esm/index.esm5.js", "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" diff --git a/packages/storage-compat/rollup.config.js b/packages/storage-compat/rollup.config.js index 5aad0883255..59f6282bf5e 100644 --- a/packages/storage-compat/rollup.config.js +++ b/packages/storage-compat/rollup.config.js @@ -25,15 +25,7 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript, - abortOnError: false - }), - json() -]; - -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, abortOnError: false, @@ -46,41 +38,26 @@ const es2017BuildPlugins = [ json({ preferConst: true }) ]; -const esmBuilds = [ - { - input: './src/index.ts', - output: { - file: pkg.esm5, - format: 'es', - sourcemap: true - }, - plugins: [...es5BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +const esmBuild = { + input: './src/index.ts', + output: { + file: pkg.browser, + format: 'es', + sourcemap: true }, - { - input: './src/index.ts', - output: { - file: pkg.browser, - format: 'es', - sourcemap: true - }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; + plugins: [...buildPlugins, emitModulePackageFile()], + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -const cjsBuilds = [ - { - input: './src/index.ts', - output: { - file: pkg.main, - format: 'cjs', - sourcemap: true - }, - plugins: [...es5BuildPlugins], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; +const cjsBuild = { + input: './src/index.ts', + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, + external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) +}; -// eslint-disable-next-line import/no-default-export -export default [...esmBuilds, ...cjsBuilds]; +export default [esmBuild, cjsBuild]; diff --git a/packages/storage/package.json b/packages/storage/package.json index bf262e820be..2ca5f2fff12 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -6,7 +6,6 @@ "main": "dist/index.node.cjs.js", "module": "dist/index.esm2017.js", "browser": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "exports": { ".": { "types": "./dist/storage-public.d.ts", @@ -14,7 +13,6 @@ "import": "./dist/node-esm/index.node.esm.js", "default": "./dist/index.node.cjs.js" }, - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/storage/rollup.config.js b/packages/storage/rollup.config.js index 73c9d7561aa..21431d1a2a3 100644 --- a/packages/storage/rollup.config.js +++ b/packages/storage/rollup.config.js @@ -41,44 +41,15 @@ const deps = Object.keys( const nodeDeps = [...deps, 'util']; -const es5Plugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, abortOnError: false }), - json() -]; - -const es2017Plugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - }, - abortOnError: false - }), json({ preferConst: true }) ]; const browserBuilds = [ - { - input: './src/index.ts', - output: { file: pkg.esm5, format: 'es', sourcemap: true }, - plugins: [ - alias(generateAliasConfig('browser')), - ...es5Plugins, - replace({ - ...generateBuildTargetReplaceConfig('esm', 5), - '__RUNTIME_ENV__': '' - }) - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - treeshake: { - moduleSideEffects: false - } - }, { input: './src/index.ts', output: { @@ -88,7 +59,7 @@ const browserBuilds = [ }, plugins: [ alias(generateAliasConfig('browser')), - ...es2017Plugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': '' @@ -108,7 +79,7 @@ const browserBuilds = [ }, plugins: [ alias(generateAliasConfig('browser')), - ...es2017Plugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('cjs', 2017), '__RUNTIME_ENV__': '' @@ -127,7 +98,7 @@ const browserBuilds = [ ], plugins: [ alias(generateAliasConfig('browser')), - ...es5Plugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('cjs', 5), '__RUNTIME_ENV__': '' @@ -150,7 +121,7 @@ const nodeBuilds = [ }, plugins: [ alias(generateAliasConfig('node')), - ...es2017Plugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('cjs', 2017), '__RUNTIME_ENV__': 'node' @@ -171,7 +142,7 @@ const nodeBuilds = [ }, plugins: [ alias(generateAliasConfig('node')), - ...es2017Plugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), '__RUNTIME_ENV__': 'node' diff --git a/packages/storage/src/index.ts b/packages/storage/src/index.ts index 1e19f5bf6eb..733a39c9ad8 100644 --- a/packages/storage/src/index.ts +++ b/packages/storage/src/index.ts @@ -70,7 +70,7 @@ function registerStorage(): void { ); //RUNTIME_ENV will be replaced during the compilation to "node" for nodejs and an empty string for browser registerVersion(name, version, '__RUNTIME_ENV__'); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/template/package.json b/packages/template/package.json index 9f797e78984..4c4e0b017ea 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -7,7 +7,6 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "exports": { ".": { "types": "./dist/index.d.ts", @@ -15,7 +14,6 @@ "import": "./dist/node-esm/index.node.esm.js", "require": "./dist/index.node.cjs.js" }, - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/template/rollup.config.js b/packages/template/rollup.config.js index 0417ac2a28d..18ee720efeb 100644 --- a/packages/template/rollup.config.js +++ b/packages/template/rollup.config.js @@ -24,30 +24,9 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }) -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; +const buildPlugins = [typescriptPlugin({ typescript })]; const browserBuilds = [ - { - input: 'index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: 'index.ts', output: { @@ -55,7 +34,7 @@ const browserBuilds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { @@ -65,7 +44,7 @@ const browserBuilds = [ format: 'cjs', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; @@ -73,16 +52,22 @@ const browserBuilds = [ const nodeBuilds = [ { input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es2017BuildPlugins, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { input: 'index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + output: { + file: pkg.exports['.'].node.import, + format: 'es', + sourcemap: true + }, + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; diff --git a/packages/util/package.json b/packages/util/package.json index d9ee2bf3a2e..fa30ebd15d9 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -6,7 +6,6 @@ "main": "dist/index.node.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", - "esm5": "dist/index.esm5.js", "exports": { ".": { "types": "./dist/util-public.d.ts", @@ -14,7 +13,6 @@ "import": "./dist/node-esm/index.node.esm.js", "require": "./dist/index.node.cjs.js" }, - "esm5": "./dist/index.esm5.js", "browser": { "require": "./dist/index.cjs.js", "import": "./dist/index.esm2017.js" diff --git a/packages/util/rollup.config.js b/packages/util/rollup.config.js index 8f0d1312bfa..d428092d8ee 100644 --- a/packages/util/rollup.config.js +++ b/packages/util/rollup.config.js @@ -24,30 +24,9 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }) -]; - -const es2017BuildPlugins = [ - typescriptPlugin({ - typescript, - tsconfigOverride: { - compilerOptions: { - target: 'es2017' - } - } - }) -]; +const buildPlugins = [typescriptPlugin({ typescript })]; const browserBuilds = [ - { - input: 'index.ts', - output: [{ file: pkg.esm5, format: 'es', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, { input: 'index.ts', output: { @@ -55,7 +34,7 @@ const browserBuilds = [ format: 'es', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { @@ -65,7 +44,7 @@ const browserBuilds = [ format: 'cjs', sourcemap: true }, - plugins: es2017BuildPlugins, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; @@ -73,16 +52,22 @@ const browserBuilds = [ const nodeBuilds = [ { input: 'index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, + output: { + file: pkg.main, + format: 'cjs', + sourcemap: true + }, + plugins: buildPlugins, external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { input: 'index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], + output: { + file: pkg.exports['.'].node.import, + format: 'es', + sourcemap: true + }, + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) } ]; diff --git a/packages/util/src/crypt.ts b/packages/util/src/crypt.ts index 7cd32125043..bec79d5304d 100644 --- a/packages/util/src/crypt.ts +++ b/packages/util/src/crypt.ts @@ -104,6 +104,7 @@ interface Base64 { // We define it as an object literal instead of a class because a class compiled down to es5 can't // be treeshaked. https://github.com/rollup/rollup/issues/1691 // Static lookup maps, lazily populated by init_() +// TODO(dlarocque): Define this as a class, since we no longer target ES5. export const base64: Base64 = { /** * Maps bytes to characters. diff --git a/packages/util/src/errors.ts b/packages/util/src/errors.ts index 7946d706ea3..fdf9a71f719 100644 --- a/packages/util/src/errors.ts +++ b/packages/util/src/errors.ts @@ -86,6 +86,8 @@ export class FirebaseError extends Error { // Fix For ES5 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work + // TODO(dlarocque): Replace this with `new.target`: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget + // which we can now use since we no longer target ES5. Object.setPrototypeOf(this, FirebaseError.prototype); // Maintains proper stack trace for where our error was thrown. diff --git a/packages/vertexai/rollup.config.js b/packages/vertexai/rollup.config.js index 6e99c03e913..3a1313a6bff 100644 --- a/packages/vertexai/rollup.config.js +++ b/packages/vertexai/rollup.config.js @@ -27,14 +27,7 @@ const deps = Object.keys( Object.assign({}, pkg.peerDependencies, pkg.dependencies) ); -const es5BuildPlugins = [ - typescriptPlugin({ - typescript - }), - json() -]; - -const es2017BuildPlugins = [ +const buildPlugins = [ typescriptPlugin({ typescript, tsconfigOverride: { @@ -55,7 +48,7 @@ const browserBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('esm', 2017), __PACKAGE_VERSION__: pkg.version @@ -72,7 +65,7 @@ const browserBuilds = [ sourcemap: true }, plugins: [ - ...es2017BuildPlugins, + ...buildPlugins, replace({ ...generateBuildTargetReplaceConfig('cjs', 2017), __PACKAGE_VERSION__: pkg.version @@ -85,8 +78,12 @@ const browserBuilds = [ // const nodeBuilds = [ // { // input: 'index.node.ts', -// output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], -// plugins: es2017BuildPlugins, +// output: { +// file: pkg.main, +// format: 'cjs', +// sourcemap: true +// }, +// plugins: buildPlugins, // external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) // }, // { @@ -94,7 +91,7 @@ const browserBuilds = [ // output: [ // { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } // ], -// plugins: [...es2017BuildPlugins, emitModulePackageFile()], +// plugins: [...buildPlugins, emitModulePackageFile()], // external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) // } // ]; diff --git a/packages/vertexai/src/errors.ts b/packages/vertexai/src/errors.ts index b0b5d9f25ec..ad3f9b72f5a 100644 --- a/packages/vertexai/src/errors.ts +++ b/packages/vertexai/src/errors.ts @@ -56,6 +56,8 @@ export class VertexAIError extends FirebaseError { // Allows instanceof VertexAIError in ES5/ES6 // https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work + // TODO(dlarocque): Replace this with `new.target`: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#support-for-newtarget + // which we can now use since we no longer target ES5. Object.setPrototypeOf(this, VertexAIError.prototype); // Since Error is an interface, we don't inherit toString and so we define it ourselves. diff --git a/packages/vertexai/src/index.ts b/packages/vertexai/src/index.ts index c8f798ff3c5..5d646e8d9d0 100644 --- a/packages/vertexai/src/index.ts +++ b/packages/vertexai/src/index.ts @@ -49,7 +49,7 @@ function registerVertex(): void { ); registerVersion(name, version); - // BUILD_TARGET will be replaced by values like esm5, esm2017, cjs5, etc during the compilation + // BUILD_TARGET will be replaced by values like esm2017, cjs2017, etc during the compilation registerVersion(name, version, '__BUILD_TARGET__'); } diff --git a/packages/webchannel-wrapper/bloom-blob/package.json b/packages/webchannel-wrapper/bloom-blob/package.json index 956333e7cf2..21b0b0e4800 100644 --- a/packages/webchannel-wrapper/bloom-blob/package.json +++ b/packages/webchannel-wrapper/bloom-blob/package.json @@ -4,6 +4,5 @@ "main": "../dist/bloom-blob/bloom_blob_es2018.js", "browser": "../dist/bloom-blob/esm/bloom_blob_es2018.js", "module": "../dist/bloom-blob/esm/bloom_blob_es2018.js", - "esm5": "../dist/bloom-blob/bloom_blob_es5.js", "typings": "../dist/bloom-blob/bloom_blob_types.d.ts" } diff --git a/packages/webchannel-wrapper/package.json b/packages/webchannel-wrapper/package.json index ddc849bcce6..5e483417c95 100644 --- a/packages/webchannel-wrapper/package.json +++ b/packages/webchannel-wrapper/package.json @@ -8,13 +8,11 @@ "./webchannel-blob": { "types": "./dist/webchannel-blob/webchannel_blob_types.d.ts", "require": "./dist/webchannel-blob/webchannel_blob_es2018.js", - "esm5": "./dist/webchannel-blob/webchannel_blob_es5.js", "default": "./dist/webchannel-blob/esm/webchannel_blob_es2018.js" }, "./bloom-blob": { "types": "./dist/bloom-blob/bloom_blob_types.d.ts", "require": "./dist/bloom-blob/bloom_blob_es2018.js", - "esm5": "./dist/bloom-blob/bloom_blob_es5.js", "default": "./dist/bloom-blob/esm/bloom_blob_es2018.js" }, "./package.json": "./package.json" diff --git a/packages/webchannel-wrapper/rollup.config.js b/packages/webchannel-wrapper/rollup.config.js index 77c29ecb4ac..ae80c831396 100644 --- a/packages/webchannel-wrapper/rollup.config.js +++ b/packages/webchannel-wrapper/rollup.config.js @@ -25,7 +25,7 @@ import pkg from './package.json'; const closureBlobsDir = '../../node_modules/closure-net/firebase/'; -const es2017BuildPlugins = [ +const buildPlugins = [ copy({ targets: [ { @@ -57,7 +57,7 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()] + plugins: [...buildPlugins, emitModulePackageFile()] }, { input: join(closureBlobsDir, 'bloom_blob_es2018.js'), @@ -66,7 +66,7 @@ const esm2017Builds = [ format: 'es', sourcemap: true }, - plugins: [...es2017BuildPlugins, emitModulePackageFile()] + plugins: [...buildPlugins, emitModulePackageFile()] } ]; diff --git a/packages/webchannel-wrapper/webchannel-blob/package.json b/packages/webchannel-wrapper/webchannel-blob/package.json index cb339b82557..312b9d9f2a2 100644 --- a/packages/webchannel-wrapper/webchannel-blob/package.json +++ b/packages/webchannel-wrapper/webchannel-blob/package.json @@ -4,6 +4,5 @@ "main": "../dist/webchannel-blob/webchannel_blob_es2018.js", "browser": "../dist/webchannel-blob/esm/webchannel_blob_es2018.js", "module": "../dist/webchannel-blob/esm/webchannel_blob_es2018.js", - "esm5": "../dist/webchannel-blob/webchannel_blob_es5.js", "typings": "../dist/webchannel-blob/webchannel_blob_types.d.ts" } diff --git a/repo-scripts/changelog-generator/tsconfig.json b/repo-scripts/changelog-generator/tsconfig.json index 5c910fcca64..38bdb7035e4 100644 --- a/repo-scripts/changelog-generator/tsconfig.json +++ b/repo-scripts/changelog-generator/tsconfig.json @@ -9,6 +9,6 @@ "moduleResolution": "node", "esModuleInterop": true, "resolveJsonModule": true, - "target": "es5" + "target": "es2017" } } \ No newline at end of file diff --git a/repo-scripts/size-analysis/rollup.config.js b/repo-scripts/size-analysis/rollup.config.js index 505596e3d2e..2796accc3a9 100644 --- a/repo-scripts/size-analysis/rollup.config.js +++ b/repo-scripts/size-analysis/rollup.config.js @@ -42,7 +42,7 @@ export default [ tsconfigOverride: { compilerOptions: { target: 'es2017', - module: 'es2015' + module: 'es2017' } } }), @@ -67,7 +67,7 @@ export default [ tsconfigOverride: { compilerOptions: { target: 'es2017', - module: 'es2015' + module: 'es2017' } } }), diff --git a/scripts/ci-test/check-paths.ts b/scripts/ci-test/check-paths.ts index 236e63d310f..d3af878f286 100644 --- a/scripts/ci-test/check-paths.ts +++ b/scripts/ci-test/check-paths.ts @@ -31,7 +31,6 @@ const TOP_LEVEL_FIELDS = [ 'typings', 'react-native', 'cordova', - 'esm5', 'webworker', 'main-esm' ]; diff --git a/scripts/docgen/docgen.ts b/scripts/docgen/docgen.ts index 8e9dfa87cab..ab335256145 100644 --- a/scripts/docgen/docgen.ts +++ b/scripts/docgen/docgen.ts @@ -58,6 +58,9 @@ const PREFERRED_PARAMS = [ 'vertexAI' ]; +let authApiReportOriginal: string; +let authApiConfigOriginal: string; + yargs .command( '$0', @@ -93,9 +96,6 @@ yargs process.on('exit', cleanup); process.on('SIGINT', cleanup); -let authApiReportOriginal: string; -let authApiConfigOriginal: string; - function cleanup() { try { // Restore original auth api-extractor.json contents. @@ -189,8 +189,8 @@ async function generateDocs( 'utf8' ); const authApiConfigModified = authApiConfigOriginal.replace( - `"mainEntryPointFilePath": "/dist/esm5/index.d.ts"`, - `"mainEntryPointFilePath": "/dist/esm5/index.doc.d.ts"` + `"mainEntryPointFilePath": "/dist/esm2017/index.d.ts"`, + `"mainEntryPointFilePath": "/dist/esm2017/index.doc.d.ts"` ); try { diff --git a/scripts/size_report/report_binary_size.ts b/scripts/size_report/report_binary_size.ts index 444e45dd978..da1ad166702 100644 --- a/scripts/size_report/report_binary_size.ts +++ b/scripts/size_report/report_binary_size.ts @@ -49,7 +49,6 @@ function generateReportForCDNScripts(): Report[] { const compatPkgJson = require(`${firebaseRoot}/compat/package.json`); const special_files = [ - 'firebase-performance-standalone-compat.es2017.js', 'firebase-performance-standalone-compat.js', 'firebase-compat.js' ]; @@ -118,11 +117,9 @@ async function collectBinarySize(pkg: string): Promise { 'main', 'module', 'browser', - 'esm5', 'react-native', 'cordova', - 'lite', - 'lite-esm5' + 'lite' ]; const json = require(pkg); for (const field of fields) { diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 826691796fc..75f1741329a 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "esModuleInterop": true, "resolveJsonModule": true, - "target": "es5", + "target": "es2017", "typeRoots": [ "../node_modules/@types" ], From 6b035b7d362848a85772596b8274f75e3a831dc1 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Thu, 26 Sep 2024 10:33:58 -0400 Subject: [PATCH 10/21] Emit a module package file for functions ESM builds (#8517) --- packages/functions-compat/package.json | 10 +++++----- packages/functions-compat/rollup.config.js | 8 ++++---- packages/functions/package.json | 10 +++++----- packages/functions/rollup.config.js | 9 +++++---- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 484df1c5a70..e51aa90e791 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -4,20 +4,20 @@ "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", "exports": { ".": { "types": "./dist/src/index.d.ts", "node": { "require": "./dist/index.cjs.js", - "import": "./dist/index.esm2017.js" + "import": "./dist/esm/index.esm2017.js" }, "browser": { "require": "./dist/index.cjs.js", - "import": "./dist/index.esm2017.js" + "import": "./dist/esm/index.esm2017.js" }, - "default": "./dist/index.esm2017.js" + "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" }, diff --git a/packages/functions-compat/rollup.config.js b/packages/functions-compat/rollup.config.js index 6ac98783eae..b85c7fa65c3 100644 --- a/packages/functions-compat/rollup.config.js +++ b/packages/functions-compat/rollup.config.js @@ -32,7 +32,7 @@ const buildPlugins = [ json({ preferConst: true }) ]; -const browserBuilds = [ +const builds = [ { input: 'src/index.ts', output: { @@ -40,13 +40,13 @@ const browserBuilds = [ format: 'es', sourcemap: true }, - plugins: buildPlugins, + plugins: [...buildPlugins, emitModulePackageFile()], external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) }, { input: 'src/index.ts', output: { - file: './dist/index.cjs.js', + file: pkg.main, format: 'cjs', sourcemap: true }, @@ -55,4 +55,4 @@ const browserBuilds = [ } ]; -export default [...browserBuilds]; +export default builds; diff --git a/packages/functions/package.json b/packages/functions/package.json index 33cf52bfbb2..c739600b5ed 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -4,20 +4,20 @@ "description": "", "author": "Firebase (https://firebase.google.com/)", "main": "dist/index.cjs.js", - "browser": "dist/index.esm2017.js", - "module": "dist/index.esm2017.js", + "browser": "dist/esm/index.esm2017.js", + "module": "dist/esm/index.esm2017.js", "exports": { ".": { "types": "./dist/functions-public.d.ts", "node": { - "import": "./dist/index.esm2017.js", + "import": "./dist/esm/index.esm2017.js", "require": "./dist/index.cjs.js" }, "browser": { "require": "./dist/index.cjs.js", - "import": "./dist/index.esm2017.js" + "import": "./dist/esm/index.esm2017.js" }, - "default": "./dist/index.esm2017.js" + "default": "./dist/esm/index.esm2017.js" }, "./package.json": "./package.json" }, diff --git a/packages/functions/rollup.config.js b/packages/functions/rollup.config.js index bb950655646..8d00f21d755 100644 --- a/packages/functions/rollup.config.js +++ b/packages/functions/rollup.config.js @@ -34,7 +34,7 @@ const buildPlugins = [ json({ preferConst: true }) ]; -const browserBuilds = [ +const builds = [ { input: 'src/index.ts', output: { @@ -45,13 +45,14 @@ const browserBuilds = [ external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...buildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)) + replace(generateBuildTargetReplaceConfig('esm', 2017)), + emitModulePackageFile() ] }, { input: 'src/index.ts', output: { - file: './dist/index.cjs.js', + file: pkg.main, format: 'cjs', sourcemap: true }, @@ -63,4 +64,4 @@ const browserBuilds = [ } ]; -export default [...browserBuilds]; +export default builds; From 98bbf53de8f2db4fe3ebe542dba02fccf2c59456 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Mon, 30 Sep 2024 11:17:43 -0700 Subject: [PATCH 11/21] Update API_NOT_ENABLED error for Vertex (#8549) --- .../vertexai/src/methods/generate-content.test.ts | 4 +++- packages/vertexai/src/requests/request.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/vertexai/src/methods/generate-content.test.ts b/packages/vertexai/src/methods/generate-content.test.ts index fd12964c4bc..c5a1d9e1e91 100644 --- a/packages/vertexai/src/methods/generate-content.test.ts +++ b/packages/vertexai/src/methods/generate-content.test.ts @@ -231,7 +231,9 @@ describe('generateContent()', () => { } as Response); await expect( generateContent(fakeApiSettings, 'model', fakeRequestParams) - ).to.be.rejectedWith(/firebasevertexai\.googleapis.*my-project/); + ).to.be.rejectedWith( + /firebasevertexai\.googleapis[\s\S]*my-project[\s\S]*api-not-enabled/ + ); expect(mockFetch).to.be.called; }); }); diff --git a/packages/vertexai/src/requests/request.ts b/packages/vertexai/src/requests/request.ts index 8c563d8ccfc..edb894d7f76 100644 --- a/packages/vertexai/src/requests/request.ts +++ b/packages/vertexai/src/requests/request.ts @@ -166,12 +166,13 @@ export async function makeRequest( ) { throw new VertexAIError( VertexAIErrorCode.API_NOT_ENABLED, - `The Vertex AI for Firebase SDK requires the Firebase Vertex AI API ` + - `firebasevertexai.googleapis.com to be enabled for your ` + - `project. Get started in the Firebase Console` + - ` (https://console.firebase.google.com/project/${url.apiSettings.project}/genai/vertex)` + - ` or verify that the API is enabled in the Google Cloud` + - ` Console (https://console.developers.google.com/apis/api/firebasevertexai.googleapis.com/overview?project=${url.apiSettings.project}).`, + `The Vertex AI in Firebase SDK requires the Vertex AI in Firebase + API ('firebasevertexai.googleapis.com') to be enabled in your + Firebase project. Enable this API by visiting the Firebase Console + at https://console.firebase.google.com/project/${url.apiSettings.project}/genai/ + and clicking "Get started". If you enabled this API recently, + wait a few minutes for the action to propagate to our systems and + then retry.`, { status: response.status, statusText: response.statusText, From 26d6c3b63e0ce4d9c9424f5ac430ab759515a4a9 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 2 Oct 2024 12:11:05 -0400 Subject: [PATCH 12/21] Upgrade cjs bundles for storage and performance (#8557) These should have been part of the bigger PR, but I missed these. --- packages/performance/rollup.config.js | 2 +- packages/storage/rollup.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/performance/rollup.config.js b/packages/performance/rollup.config.js index 4752b5cfc02..ca9fdde7f54 100644 --- a/packages/performance/rollup.config.js +++ b/packages/performance/rollup.config.js @@ -55,7 +55,7 @@ const cjsBuild = { external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), plugins: [ ...buildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) + replace(generateBuildTargetReplaceConfig('cjs', 2017)) ] }; diff --git a/packages/storage/rollup.config.js b/packages/storage/rollup.config.js index 21431d1a2a3..093cca0c654 100644 --- a/packages/storage/rollup.config.js +++ b/packages/storage/rollup.config.js @@ -100,7 +100,7 @@ const browserBuilds = [ alias(generateAliasConfig('browser')), ...buildPlugins, replace({ - ...generateBuildTargetReplaceConfig('cjs', 5), + ...generateBuildTargetReplaceConfig('cjs', 2017), '__RUNTIME_ENV__': '' }) ], From 95d3309920df19d965f1545e053db7ca48aca2c0 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 2 Oct 2024 12:11:56 -0400 Subject: [PATCH 13/21] Rollup JS files with rollup-typescript-plugin (#8503) The rollup-typescript-plugin does not transpile JS files using the TS compiler by default. This means that external dependencies that provide JS bundles will not be transpiled to the target ES version specified in the TypeScript config used by the plugin. This resulted in one of our dependencies (https://github.com/jakearchibald/idb) being included in the CDN bundles without being transpiled to ES5 (the target ES version). Since this dependencies bundle uses ES2018 syntax (object spread operator `{ ...x }`), this upgraded our CDN bundles' minimum ES version requirement to ES2018 which isn't compatible with older browser versions. To see the ES2018 syntax in one of the CDN bundles, see https://www.gstatic.com/firebasejs/10.13.1/firebase-app.js and search for `...oldTraps`. --- packages/firebase/rollup.config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/firebase/rollup.config.js b/packages/firebase/rollup.config.js index beeb2123ba8..fda0dc0ebb0 100644 --- a/packages/firebase/rollup.config.js +++ b/packages/firebase/rollup.config.js @@ -36,6 +36,8 @@ const typescriptPlugin = rollupTypescriptPlugin({ const typescriptPluginCDN = rollupTypescriptPlugin({ typescript, + allowJs: true, + include: ['*.ts', '**/*.ts', '*.js', '**/*.js'], tsconfigOverride: { compilerOptions: { declaration: false From 8018307100cee9eab2b00623313c8fa6d7f160c7 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Thu, 10 Oct 2024 10:00:46 -0400 Subject: [PATCH 14/21] Fix tsc errors in vertex tests (#8562) --- .../src/models/generative-model.test.ts | 54 +++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/packages/vertexai/src/models/generative-model.test.ts b/packages/vertexai/src/models/generative-model.test.ts index 75d98eb6ec4..e03f39e8a83 100644 --- a/packages/vertexai/src/models/generative-model.test.ts +++ b/packages/vertexai/src/models/generative-model.test.ts @@ -62,12 +62,21 @@ describe('GenerativeModel', () => { it('passes params through to generateContent', async () => { const genModel = new GenerativeModel(fakeVertexAI, { model: 'my-model', - tools: [{ functionDeclarations: [{ name: 'myfunc' }] }], + tools: [ + { + functionDeclarations: [ + { + name: 'myfunc', + description: 'mydesc' + } + ] + } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } }, systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] } }); expect(genModel.tools?.length).to.equal(1); - expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal( + expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal( FunctionCallingMode.NONE ); expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly'); @@ -122,12 +131,21 @@ describe('GenerativeModel', () => { it('generateContent overrides model values', async () => { const genModel = new GenerativeModel(fakeVertexAI, { model: 'my-model', - tools: [{ functionDeclarations: [{ name: 'myfunc' }] }], + tools: [ + { + functionDeclarations: [ + { + name: 'myfunc', + description: 'mydesc' + } + ] + } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } }, systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] } }); expect(genModel.tools?.length).to.equal(1); - expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal( + expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal( FunctionCallingMode.NONE ); expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly'); @@ -139,7 +157,13 @@ describe('GenerativeModel', () => { ); await genModel.generateContent({ contents: [{ role: 'user', parts: [{ text: 'hello' }] }], - tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }], + tools: [ + { + functionDeclarations: [ + { name: 'otherfunc', description: 'otherdesc' } + ] + } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } }, systemInstruction: { role: 'system', parts: [{ text: 'be formal' }] } }); @@ -162,12 +186,14 @@ describe('GenerativeModel', () => { it('passes params through to chat.sendMessage', async () => { const genModel = new GenerativeModel(fakeVertexAI, { model: 'my-model', - tools: [{ functionDeclarations: [{ name: 'myfunc' }] }], + tools: [ + { functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } }, systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] } }); expect(genModel.tools?.length).to.equal(1); - expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal( + expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal( FunctionCallingMode.NONE ); expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly'); @@ -222,12 +248,14 @@ describe('GenerativeModel', () => { it('startChat overrides model values', async () => { const genModel = new GenerativeModel(fakeVertexAI, { model: 'my-model', - tools: [{ functionDeclarations: [{ name: 'myfunc' }] }], + tools: [ + { functionDeclarations: [{ name: 'myfunc', description: 'mydesc' }] } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.NONE } }, systemInstruction: { role: 'system', parts: [{ text: 'be friendly' }] } }); expect(genModel.tools?.length).to.equal(1); - expect(genModel.toolConfig?.functionCallingConfig.mode).to.equal( + expect(genModel.toolConfig?.functionCallingConfig?.mode).to.equal( FunctionCallingMode.NONE ); expect(genModel.systemInstruction?.parts[0].text).to.equal('be friendly'); @@ -239,7 +267,13 @@ describe('GenerativeModel', () => { ); await genModel .startChat({ - tools: [{ functionDeclarations: [{ name: 'otherfunc' }] }], + tools: [ + { + functionDeclarations: [ + { name: 'otherfunc', description: 'otherdesc' } + ] + } + ], toolConfig: { functionCallingConfig: { mode: FunctionCallingMode.AUTO } }, From 4be5b0e926a022f04abf34477f3d7bdc3df3a14c Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 15 Oct 2024 12:02:22 -0700 Subject: [PATCH 15/21] Make SafetySettings.method optional (#8567) * Make SafetySettings.method optional * Update API reports --------- Co-authored-by: hsubox76 --- common/api-review/vertexai.api.md | 2 +- packages/vertexai/src/types/requests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/api-review/vertexai.api.md b/common/api-review/vertexai.api.md index a3f7b30b994..041bc62451f 100644 --- a/common/api-review/vertexai.api.md +++ b/common/api-review/vertexai.api.md @@ -541,7 +541,7 @@ export interface SafetySetting { // (undocumented) category: HarmCategory; // (undocumented) - method: HarmBlockMethod; + method?: HarmBlockMethod; // (undocumented) threshold: HarmBlockThreshold; } diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts index c844ddfb878..e86918a8ed8 100644 --- a/packages/vertexai/src/types/requests.ts +++ b/packages/vertexai/src/types/requests.ts @@ -63,7 +63,7 @@ export interface GenerateContentRequest extends BaseParams { export interface SafetySetting { category: HarmCategory; threshold: HarmBlockThreshold; - method: HarmBlockMethod; + method?: HarmBlockMethod; } /** From ec0a6708cba37e28ea2d3729d6f6ffba1f40eb8b Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 15 Oct 2024 13:31:43 -0700 Subject: [PATCH 16/21] [Vertex GA] Regenerate docs after Vertex GA changes (#8505) --- docs-devsite/_toc.yaml | 127 +++--- docs-devsite/index.md | 2 +- docs-devsite/vertexai-preview.chatsession.md | 138 ------ ...texai-preview.functiondeclarationschema.md | 70 --- ...eview.functiondeclarationschemaproperty.md | 125 ------ ...rtexai-preview.functiondeclarationstool.md | 35 -- ...rtexai-preview.generatecontentcandidate.md | 87 ---- .../vertexai-preview.generationconfig.md | 107 ----- .../vertexai-preview.generativemodel.md | 201 --------- docs-devsite/vertexai-preview.md | 397 ----------------- docs-devsite/vertexai.arrayschema.md | 57 +++ ...w.baseparams.md => vertexai.baseparams.md} | 4 +- docs-devsite/vertexai.booleanschema.md | 43 ++ docs-devsite/vertexai.chatsession.md | 138 ++++++ ...eview.citation.md => vertexai.citation.md} | 12 +- ...tadata.md => vertexai.citationmetadata.md} | 4 +- ...preview.content.md => vertexai.content.md} | 4 +- ...uest.md => vertexai.counttokensrequest.md} | 4 +- ...nse.md => vertexai.counttokensresponse.md} | 6 +- ...rordata.md => vertexai.customerrordata.md} | 10 +- ...i-preview.date_2.md => vertexai.date_2.md} | 6 +- ...rtexai.enhancedgeneratecontentresponse.md} | 6 +- ...rordetails.md => vertexai.errordetails.md} | 8 +- ...eview.filedata.md => vertexai.filedata.md} | 4 +- ...ledatapart.md => vertexai.filedatapart.md} | 12 +- ...nctioncall.md => vertexai.functioncall.md} | 6 +- ...g.md => vertexai.functioncallingconfig.md} | 4 +- ...llpart.md => vertexai.functioncallpart.md} | 10 +- ...ion.md => vertexai.functiondeclaration.md} | 12 +- .../vertexai.functiondeclarationstool.md | 35 ++ ...sponse.md => vertexai.functionresponse.md} | 6 +- ...rt.md => vertexai.functionresponsepart.md} | 10 +- .../vertexai.generatecontentcandidate.md | 87 ++++ ....md => vertexai.generatecontentrequest.md} | 12 +- ...md => vertexai.generatecontentresponse.md} | 8 +- ...t.md => vertexai.generatecontentresult.md} | 4 +- ...> vertexai.generatecontentstreamresult.md} | 6 +- docs-devsite/vertexai.generationconfig.md | 118 +++++ ...b.md => vertexai.generativecontentblob.md} | 4 +- docs-devsite/vertexai.generativemodel.md | 201 +++++++++ ...on.md => vertexai.groundingattribution.md} | 8 +- ...adata.md => vertexai.groundingmetadata.md} | 6 +- ...datapart.md => vertexai.inlinedatapart.md} | 10 +- docs-devsite/vertexai.integerschema.md | 43 ++ docs-devsite/vertexai.md | 412 ++++++++++++++++++ ...modelparams.md => vertexai.modelparams.md} | 12 +- docs-devsite/vertexai.numberschema.md | 43 ++ docs-devsite/vertexai.objectschema.md | 71 +++ .../vertexai.objectschemainterface.md | 43 ++ ...feedback.md => vertexai.promptfeedback.md} | 8 +- ...toptions.md => vertexai.requestoptions.md} | 8 +- ...> vertexai.retrievedcontextattribution.md} | 4 +- ...fetyrating.md => vertexai.safetyrating.md} | 14 +- ...tysetting.md => vertexai.safetysetting.md} | 6 +- docs-devsite/vertexai.schema.md | 250 +++++++++++ docs-devsite/vertexai.schemainterface.md | 36 ++ docs-devsite/vertexai.schemaparams.md | 21 + docs-devsite/vertexai.schemarequest.md | 47 ++ docs-devsite/vertexai.schemashared.md | 103 +++++ ...preview.segment.md => vertexai.segment.md} | 6 +- ...tparams.md => vertexai.startchatparams.md} | 12 +- docs-devsite/vertexai.stringschema.md | 57 +++ ...eview.textpart.md => vertexai.textpart.md} | 8 +- ...w.toolconfig.md => vertexai.toolconfig.md} | 4 +- ...emetadata.md => vertexai.usagemetadata.md} | 8 +- ...eview.vertexai.md => vertexai.vertexai.md} | 6 +- ...exaierror.md => vertexai.vertexaierror.md} | 19 +- ...options.md => vertexai.vertexaioptions.md} | 2 +- ...ometadata.md => vertexai.videometadata.md} | 4 +- ...ribution.md => vertexai.webattribution.md} | 4 +- packages/vertexai/src/api.ts | 4 +- packages/vertexai/src/errors.ts | 2 +- packages/vertexai/src/methods/chat-session.ts | 4 +- .../vertexai/src/models/generative-model.ts | 4 +- packages/vertexai/src/public-types.ts | 2 +- .../vertexai/src/requests/response-helpers.ts | 2 +- .../vertexai/src/requests/schema-builder.ts | 2 +- packages/vertexai/src/types/content.ts | 12 +- packages/vertexai/src/types/error.ts | 4 +- packages/vertexai/src/types/requests.ts | 19 +- packages/vertexai/src/types/responses.ts | 8 +- packages/vertexai/src/types/schema.ts | 14 +- 82 files changed, 2069 insertions(+), 1413 deletions(-) delete mode 100644 docs-devsite/vertexai-preview.chatsession.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationschema.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md delete mode 100644 docs-devsite/vertexai-preview.functiondeclarationstool.md delete mode 100644 docs-devsite/vertexai-preview.generatecontentcandidate.md delete mode 100644 docs-devsite/vertexai-preview.generationconfig.md delete mode 100644 docs-devsite/vertexai-preview.generativemodel.md delete mode 100644 docs-devsite/vertexai-preview.md create mode 100644 docs-devsite/vertexai.arrayschema.md rename docs-devsite/{vertexai-preview.baseparams.md => vertexai.baseparams.md} (67%) create mode 100644 docs-devsite/vertexai.booleanschema.md create mode 100644 docs-devsite/vertexai.chatsession.md rename docs-devsite/{vertexai-preview.citation.md => vertexai.citation.md} (68%) rename docs-devsite/{vertexai-preview.citationmetadata.md => vertexai.citationmetadata.md} (64%) rename docs-devsite/{vertexai-preview.content.md => vertexai.content.md} (76%) rename docs-devsite/{vertexai-preview.counttokensrequest.md => vertexai.counttokensrequest.md} (68%) rename docs-devsite/{vertexai-preview.counttokensresponse.md => vertexai.counttokensresponse.md} (67%) rename docs-devsite/{vertexai-preview.customerrordata.md => vertexai.customerrordata.md} (54%) rename docs-devsite/{vertexai-preview.date_2.md => vertexai.date_2.md} (78%) rename docs-devsite/{vertexai-preview.enhancedgeneratecontentresponse.md => vertexai.enhancedgeneratecontentresponse.md} (61%) rename docs-devsite/{vertexai-preview.errordetails.md => vertexai.errordetails.md} (68%) rename docs-devsite/{vertexai-preview.filedata.md => vertexai.filedata.md} (81%) rename docs-devsite/{vertexai-preview.filedatapart.md => vertexai.filedatapart.md} (60%) rename docs-devsite/{vertexai-preview.functioncall.md => vertexai.functioncall.md} (57%) rename docs-devsite/{vertexai-preview.functioncallingconfig.md => vertexai.functioncallingconfig.md} (71%) rename docs-devsite/{vertexai-preview.functioncallpart.md => vertexai.functioncallpart.md} (59%) rename docs-devsite/{vertexai-preview.functiondeclaration.md => vertexai.functiondeclaration.md} (57%) create mode 100644 docs-devsite/vertexai.functiondeclarationstool.md rename docs-devsite/{vertexai-preview.functionresponse.md => vertexai.functionresponse.md} (50%) rename docs-devsite/{vertexai-preview.functionresponsepart.md => vertexai.functionresponsepart.md} (58%) create mode 100644 docs-devsite/vertexai.generatecontentcandidate.md rename docs-devsite/{vertexai-preview.generatecontentrequest.md => vertexai.generatecontentrequest.md} (54%) rename docs-devsite/{vertexai-preview.generatecontentresponse.md => vertexai.generatecontentresponse.md} (50%) rename docs-devsite/{vertexai-preview.generatecontentresult.md => vertexai.generatecontentresult.md} (69%) rename docs-devsite/{vertexai-preview.generatecontentstreamresult.md => vertexai.generatecontentstreamresult.md} (52%) create mode 100644 docs-devsite/vertexai.generationconfig.md rename docs-devsite/{vertexai-preview.generativecontentblob.md => vertexai.generativecontentblob.md} (76%) create mode 100644 docs-devsite/vertexai.generativemodel.md rename docs-devsite/{vertexai-preview.groundingattribution.md => vertexai.groundingattribution.md} (58%) rename docs-devsite/{vertexai-preview.groundingmetadata.md => vertexai.groundingmetadata.md} (66%) rename docs-devsite/{vertexai-preview.inlinedatapart.md => vertexai.inlinedatapart.md} (60%) create mode 100644 docs-devsite/vertexai.integerschema.md create mode 100644 docs-devsite/vertexai.md rename docs-devsite/{vertexai-preview.modelparams.md => vertexai.modelparams.md} (54%) create mode 100644 docs-devsite/vertexai.numberschema.md create mode 100644 docs-devsite/vertexai.objectschema.md create mode 100644 docs-devsite/vertexai.objectschemainterface.md rename docs-devsite/{vertexai-preview.promptfeedback.md => vertexai.promptfeedback.md} (66%) rename docs-devsite/{vertexai-preview.requestoptions.md => vertexai.requestoptions.md} (61%) rename docs-devsite/{vertexai-preview.retrievedcontextattribution.md => vertexai.retrievedcontextattribution.md} (76%) rename docs-devsite/{vertexai-preview.safetyrating.md => vertexai.safetyrating.md} (55%) rename docs-devsite/{vertexai-preview.safetysetting.md => vertexai.safetysetting.md} (66%) create mode 100644 docs-devsite/vertexai.schema.md create mode 100644 docs-devsite/vertexai.schemainterface.md create mode 100644 docs-devsite/vertexai.schemaparams.md create mode 100644 docs-devsite/vertexai.schemarequest.md create mode 100644 docs-devsite/vertexai.schemashared.md rename docs-devsite/{vertexai-preview.segment.md => vertexai.segment.md} (75%) rename docs-devsite/{vertexai-preview.startchatparams.md => vertexai.startchatparams.md} (51%) create mode 100644 docs-devsite/vertexai.stringschema.md rename docs-devsite/{vertexai-preview.textpart.md => vertexai.textpart.md} (72%) rename docs-devsite/{vertexai-preview.toolconfig.md => vertexai.toolconfig.md} (71%) rename docs-devsite/{vertexai-preview.usagemetadata.md => vertexai.usagemetadata.md} (63%) rename docs-devsite/{vertexai-preview.vertexai.md => vertexai.vertexai.md} (62%) rename docs-devsite/{vertexai-preview.vertexaierror.md => vertexai.vertexaierror.md} (57%) rename docs-devsite/{vertexai-preview.vertexaioptions.md => vertexai.vertexaioptions.md} (87%) rename docs-devsite/{vertexai-preview.videometadata.md => vertexai.videometadata.md} (66%) rename docs-devsite/{vertexai-preview.webattribution.md => vertexai.webattribution.md} (79%) diff --git a/docs-devsite/_toc.yaml b/docs-devsite/_toc.yaml index 3a04923f8de..a27f2832eb7 100644 --- a/docs-devsite/_toc.yaml +++ b/docs-devsite/_toc.yaml @@ -455,105 +455,124 @@ toc: path: /docs/reference/js/storage.uploadtask.md - title: UploadTaskSnapshot path: /docs/reference/js/storage.uploadtasksnapshot.md - - title: vertexai-preview - path: /docs/reference/js/vertexai-preview.md + - title: vertexai + path: /docs/reference/js/vertexai.md section: + - title: ArraySchema + path: /docs/reference/js/vertexai.arrayschema.md - title: BaseParams - path: /docs/reference/js/vertexai-preview.baseparams.md + path: /docs/reference/js/vertexai.baseparams.md + - title: BooleanSchema + path: /docs/reference/js/vertexai.booleanschema.md - title: ChatSession - path: /docs/reference/js/vertexai-preview.chatsession.md + path: /docs/reference/js/vertexai.chatsession.md - title: Citation - path: /docs/reference/js/vertexai-preview.citation.md + path: /docs/reference/js/vertexai.citation.md - title: CitationMetadata - path: /docs/reference/js/vertexai-preview.citationmetadata.md + path: /docs/reference/js/vertexai.citationmetadata.md - title: Content - path: /docs/reference/js/vertexai-preview.content.md + path: /docs/reference/js/vertexai.content.md - title: CountTokensRequest - path: /docs/reference/js/vertexai-preview.counttokensrequest.md + path: /docs/reference/js/vertexai.counttokensrequest.md - title: CountTokensResponse - path: /docs/reference/js/vertexai-preview.counttokensresponse.md + path: /docs/reference/js/vertexai.counttokensresponse.md - title: CustomErrorData - path: /docs/reference/js/vertexai-preview.customerrordata.md + path: /docs/reference/js/vertexai.customerrordata.md - title: Date_2 - path: /docs/reference/js/vertexai-preview.date_2.md + path: /docs/reference/js/vertexai.date_2.md - title: EnhancedGenerateContentResponse - path: /docs/reference/js/vertexai-preview.enhancedgeneratecontentresponse.md + path: /docs/reference/js/vertexai.enhancedgeneratecontentresponse.md - title: ErrorDetails - path: /docs/reference/js/vertexai-preview.errordetails.md + path: /docs/reference/js/vertexai.errordetails.md - title: FileData - path: /docs/reference/js/vertexai-preview.filedata.md + path: /docs/reference/js/vertexai.filedata.md - title: FileDataPart - path: /docs/reference/js/vertexai-preview.filedatapart.md + path: /docs/reference/js/vertexai.filedatapart.md - title: FunctionCall - path: /docs/reference/js/vertexai-preview.functioncall.md + path: /docs/reference/js/vertexai.functioncall.md - title: FunctionCallingConfig - path: /docs/reference/js/vertexai-preview.functioncallingconfig.md + path: /docs/reference/js/vertexai.functioncallingconfig.md - title: FunctionCallPart - path: /docs/reference/js/vertexai-preview.functioncallpart.md + path: /docs/reference/js/vertexai.functioncallpart.md - title: FunctionDeclaration - path: /docs/reference/js/vertexai-preview.functiondeclaration.md - - title: FunctionDeclarationSchema - path: /docs/reference/js/vertexai-preview.functiondeclarationschema.md - - title: FunctionDeclarationSchemaProperty - path: >- - /docs/reference/js/vertexai-preview.functiondeclarationschemaproperty.md + path: /docs/reference/js/vertexai.functiondeclaration.md - title: FunctionDeclarationsTool - path: /docs/reference/js/vertexai-preview.functiondeclarationstool.md + path: /docs/reference/js/vertexai.functiondeclarationstool.md - title: FunctionResponse - path: /docs/reference/js/vertexai-preview.functionresponse.md + path: /docs/reference/js/vertexai.functionresponse.md - title: FunctionResponsePart - path: /docs/reference/js/vertexai-preview.functionresponsepart.md + path: /docs/reference/js/vertexai.functionresponsepart.md - title: GenerateContentCandidate - path: /docs/reference/js/vertexai-preview.generatecontentcandidate.md + path: /docs/reference/js/vertexai.generatecontentcandidate.md - title: GenerateContentRequest - path: /docs/reference/js/vertexai-preview.generatecontentrequest.md + path: /docs/reference/js/vertexai.generatecontentrequest.md - title: GenerateContentResponse - path: /docs/reference/js/vertexai-preview.generatecontentresponse.md + path: /docs/reference/js/vertexai.generatecontentresponse.md - title: GenerateContentResult - path: /docs/reference/js/vertexai-preview.generatecontentresult.md + path: /docs/reference/js/vertexai.generatecontentresult.md - title: GenerateContentStreamResult - path: /docs/reference/js/vertexai-preview.generatecontentstreamresult.md + path: /docs/reference/js/vertexai.generatecontentstreamresult.md - title: GenerationConfig - path: /docs/reference/js/vertexai-preview.generationconfig.md + path: /docs/reference/js/vertexai.generationconfig.md - title: GenerativeContentBlob - path: /docs/reference/js/vertexai-preview.generativecontentblob.md + path: /docs/reference/js/vertexai.generativecontentblob.md - title: GenerativeModel - path: /docs/reference/js/vertexai-preview.generativemodel.md + path: /docs/reference/js/vertexai.generativemodel.md - title: GroundingAttribution - path: /docs/reference/js/vertexai-preview.groundingattribution.md + path: /docs/reference/js/vertexai.groundingattribution.md - title: GroundingMetadata - path: /docs/reference/js/vertexai-preview.groundingmetadata.md + path: /docs/reference/js/vertexai.groundingmetadata.md - title: InlineDataPart - path: /docs/reference/js/vertexai-preview.inlinedatapart.md + path: /docs/reference/js/vertexai.inlinedatapart.md + - title: IntegerSchema + path: /docs/reference/js/vertexai.integerschema.md - title: ModelParams - path: /docs/reference/js/vertexai-preview.modelparams.md + path: /docs/reference/js/vertexai.modelparams.md + - title: NumberSchema + path: /docs/reference/js/vertexai.numberschema.md + - title: ObjectSchema + path: /docs/reference/js/vertexai.objectschema.md + - title: ObjectSchemaInterface + path: /docs/reference/js/vertexai.objectschemainterface.md - title: PromptFeedback - path: /docs/reference/js/vertexai-preview.promptfeedback.md + path: /docs/reference/js/vertexai.promptfeedback.md - title: RequestOptions - path: /docs/reference/js/vertexai-preview.requestoptions.md + path: /docs/reference/js/vertexai.requestoptions.md - title: RetrievedContextAttribution - path: /docs/reference/js/vertexai-preview.retrievedcontextattribution.md + path: /docs/reference/js/vertexai.retrievedcontextattribution.md - title: SafetyRating - path: /docs/reference/js/vertexai-preview.safetyrating.md + path: /docs/reference/js/vertexai.safetyrating.md - title: SafetySetting - path: /docs/reference/js/vertexai-preview.safetysetting.md + path: /docs/reference/js/vertexai.safetysetting.md + - title: Schema + path: /docs/reference/js/vertexai.schema.md + - title: SchemaInterface + path: /docs/reference/js/vertexai.schemainterface.md + - title: SchemaParams + path: /docs/reference/js/vertexai.schemaparams.md + - title: SchemaRequest + path: /docs/reference/js/vertexai.schemarequest.md + - title: SchemaShared + path: /docs/reference/js/vertexai.schemashared.md - title: Segment - path: /docs/reference/js/vertexai-preview.segment.md + path: /docs/reference/js/vertexai.segment.md - title: StartChatParams - path: /docs/reference/js/vertexai-preview.startchatparams.md + path: /docs/reference/js/vertexai.startchatparams.md + - title: StringSchema + path: /docs/reference/js/vertexai.stringschema.md - title: TextPart - path: /docs/reference/js/vertexai-preview.textpart.md + path: /docs/reference/js/vertexai.textpart.md - title: ToolConfig - path: /docs/reference/js/vertexai-preview.toolconfig.md + path: /docs/reference/js/vertexai.toolconfig.md - title: UsageMetadata - path: /docs/reference/js/vertexai-preview.usagemetadata.md + path: /docs/reference/js/vertexai.usagemetadata.md - title: VertexAI - path: /docs/reference/js/vertexai-preview.vertexai.md + path: /docs/reference/js/vertexai.vertexai.md - title: VertexAIError - path: /docs/reference/js/vertexai-preview.vertexaierror.md + path: /docs/reference/js/vertexai.vertexaierror.md - title: VertexAIOptions - path: /docs/reference/js/vertexai-preview.vertexaioptions.md + path: /docs/reference/js/vertexai.vertexaioptions.md - title: VideoMetadata - path: /docs/reference/js/vertexai-preview.videometadata.md + path: /docs/reference/js/vertexai.videometadata.md - title: WebAttribution - path: /docs/reference/js/vertexai-preview.webattribution.md + path: /docs/reference/js/vertexai.webattribution.md diff --git a/docs-devsite/index.md b/docs-devsite/index.md index 0064652e792..82fdb36f076 100644 --- a/docs-devsite/index.md +++ b/docs-devsite/index.md @@ -27,5 +27,5 @@ https://github.com/firebase/firebase-js-sdk | [@firebase/performance](./performance.md#performance_package) | The Firebase Performance Monitoring Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/remote-config](./remote-config.md#remote-config_package) | The Firebase Remote Config Web SDK. This SDK does not work in a Node.js environment. | | [@firebase/storage](./storage.md#storage_package) | Cloud Storage for Firebase | -| [@firebase/vertexai-preview](./vertexai-preview.md#vertexai-preview_package) | The Vertex AI in Firebase Web SDK. | +| [@firebase/vertexai](./vertexai.md#vertexai_package) | The Vertex AI in Firebase Web SDK. | diff --git a/docs-devsite/vertexai-preview.chatsession.md b/docs-devsite/vertexai-preview.chatsession.md deleted file mode 100644 index d8dc691d186..00000000000 --- a/docs-devsite/vertexai-preview.chatsession.md +++ /dev/null @@ -1,138 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# ChatSession class -ChatSession class that enables sending chat messages and stores history of sent and received messages so far. - -Signature: - -```typescript -export declare class ChatSession -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai-preview.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [model](./vertexai-preview.chatsession.md#chatsessionmodel) | | string | | -| [params](./vertexai-preview.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | -| [requestOptions](./vertexai-preview.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [getHistory()](./vertexai-preview.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | -| [sendMessage(request)](./vertexai-preview.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | -| [sendMessageStream(request)](./vertexai-preview.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | - -## ChatSession.(constructor) - -Constructs a new instance of the `ChatSession` class - -Signature: - -```typescript -constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| apiSettings | ApiSettings | | -| model | string | | -| params | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) \| undefined | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) \| undefined | | - -## ChatSession.model - -Signature: - -```typescript -model: string; -``` - -## ChatSession.params - -Signature: - -```typescript -params?: StartChatParams | undefined; -``` - -## ChatSession.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions | undefined; -``` - -## ChatSession.getHistory() - -Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. - -Signature: - -```typescript -getHistory(): Promise; -``` -Returns: - -Promise<[Content](./vertexai-preview.content.md#content_interface)\[\]> - -## ChatSession.sendMessage() - -Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) - -Signature: - -```typescript -sendMessage(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> - -## ChatSession.sendMessageStream() - -Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. - -Signature: - -```typescript -sendMessageStream(request: string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - diff --git a/docs-devsite/vertexai-preview.functiondeclarationschema.md b/docs-devsite/vertexai-preview.functiondeclarationschema.md deleted file mode 100644 index 7d0e5809d41..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationschema.md +++ /dev/null @@ -1,70 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationSchema interface -Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). - -Signature: - -```typescript -export interface FunctionDeclarationSchema -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [description](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemadescription) | string | Optional. Description of the parameter. | -| [properties](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemaproperties) | { \[k: string\]: [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface); } | The format of the parameter. | -| [required](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschemarequired) | string\[\] | Optional. Array of required parameters. | -| [type](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschematype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | The type of the parameter. | - -## FunctionDeclarationSchema.description - -Optional. Description of the parameter. - -Signature: - -```typescript -description?: string; -``` - -## FunctionDeclarationSchema.properties - -The format of the parameter. - -Signature: - -```typescript -properties: { - [k: string]: FunctionDeclarationSchemaProperty; - }; -``` - -## FunctionDeclarationSchema.required - -Optional. Array of required parameters. - -Signature: - -```typescript -required?: string[]; -``` - -## FunctionDeclarationSchema.type - -The type of the parameter. - -Signature: - -```typescript -type: FunctionDeclarationSchemaType; -``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md b/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md deleted file mode 100644 index ac2e1262dd0..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationschemaproperty.md +++ /dev/null @@ -1,125 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationSchemaProperty interface -Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. - -Signature: - -```typescript -export interface FunctionDeclarationSchemaProperty -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [description](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertydescription) | string | Optional. The description of the property. | -| [enum](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyenum) | string\[\] | Optional. The enum of the property. | -| [example](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyexample) | unknown | Optional. The example of the property. | -| [format](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyformat) | string | Optional. The format of the property. | -| [items](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyitems) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | -| [nullable](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertynullable) | boolean | Optional. Whether the property is nullable. | -| [properties](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyproperties) | { \[k: string\]: [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface); } | Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). | -| [required](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertyrequired) | string\[\] | Optional. Array of required property. | -| [type](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemapropertytype) | [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). | - -## FunctionDeclarationSchemaProperty.description - -Optional. The description of the property. - -Signature: - -```typescript -description?: string; -``` - -## FunctionDeclarationSchemaProperty.enum - -Optional. The enum of the property. - -Signature: - -```typescript -enum?: string[]; -``` - -## FunctionDeclarationSchemaProperty.example - -Optional. The example of the property. - -Signature: - -```typescript -example?: unknown; -``` - -## FunctionDeclarationSchemaProperty.format - -Optional. The format of the property. - -Signature: - -```typescript -format?: string; -``` - -## FunctionDeclarationSchemaProperty.items - -Optional. The items of the property. [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) - -Signature: - -```typescript -items?: FunctionDeclarationSchema; -``` - -## FunctionDeclarationSchemaProperty.nullable - -Optional. Whether the property is nullable. - -Signature: - -```typescript -nullable?: boolean; -``` - -## FunctionDeclarationSchemaProperty.properties - -Optional. Map of [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface). - -Signature: - -```typescript -properties?: { - [k: string]: FunctionDeclarationSchema; - }; -``` - -## FunctionDeclarationSchemaProperty.required - -Optional. Array of required property. - -Signature: - -```typescript -required?: string[]; -``` - -## FunctionDeclarationSchemaProperty.type - -Optional. The type of the property. [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype). - -Signature: - -```typescript -type?: FunctionDeclarationSchemaType; -``` diff --git a/docs-devsite/vertexai-preview.functiondeclarationstool.md b/docs-devsite/vertexai-preview.functiondeclarationstool.md deleted file mode 100644 index d1af4351a23..00000000000 --- a/docs-devsite/vertexai-preview.functiondeclarationstool.md +++ /dev/null @@ -1,35 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# FunctionDeclarationsTool interface -A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. - -Signature: - -```typescript -export declare interface FunctionDeclarationsTool -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [functionDeclarations](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | - -## FunctionDeclarationsTool.functionDeclarations - -Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. - -Signature: - -```typescript -functionDeclarations?: FunctionDeclaration[]; -``` diff --git a/docs-devsite/vertexai-preview.generatecontentcandidate.md b/docs-devsite/vertexai-preview.generatecontentcandidate.md deleted file mode 100644 index 9f36fab1e87..00000000000 --- a/docs-devsite/vertexai-preview.generatecontentcandidate.md +++ /dev/null @@ -1,87 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerateContentCandidate interface -A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -export interface GenerateContentCandidate -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [citationMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | | -| [content](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai-preview.content.md#content_interface) | | -| [finishMessage](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | -| [finishReason](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai-preview.md#finishreason) | | -| [groundingMetadata](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | | -| [index](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidateindex) | number | | -| [safetyRatings](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | - -## GenerateContentCandidate.citationMetadata - -Signature: - -```typescript -citationMetadata?: CitationMetadata; -``` - -## GenerateContentCandidate.content - -Signature: - -```typescript -content: Content; -``` - -## GenerateContentCandidate.finishMessage - -Signature: - -```typescript -finishMessage?: string; -``` - -## GenerateContentCandidate.finishReason - -Signature: - -```typescript -finishReason?: FinishReason; -``` - -## GenerateContentCandidate.groundingMetadata - -Signature: - -```typescript -groundingMetadata?: GroundingMetadata; -``` - -## GenerateContentCandidate.index - -Signature: - -```typescript -index: number; -``` - -## GenerateContentCandidate.safetyRatings - -Signature: - -```typescript -safetyRatings?: SafetyRating[]; -``` diff --git a/docs-devsite/vertexai-preview.generationconfig.md b/docs-devsite/vertexai-preview.generationconfig.md deleted file mode 100644 index b14dfea053b..00000000000 --- a/docs-devsite/vertexai-preview.generationconfig.md +++ /dev/null @@ -1,107 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerationConfig interface -Config options for content-related requests - -Signature: - -```typescript -export interface GenerationConfig -``` - -## Properties - -| Property | Type | Description | -| --- | --- | --- | -| [candidateCount](./vertexai-preview.generationconfig.md#generationconfigcandidatecount) | number | | -| [frequencyPenalty](./vertexai-preview.generationconfig.md#generationconfigfrequencypenalty) | number | | -| [maxOutputTokens](./vertexai-preview.generationconfig.md#generationconfigmaxoutputtokens) | number | | -| [presencePenalty](./vertexai-preview.generationconfig.md#generationconfigpresencepenalty) | number | | -| [responseMimeType](./vertexai-preview.generationconfig.md#generationconfigresponsemimetype) | string | Output response mimetype of the generated candidate text. Supported mimetypes are text/plain (default, text output) and application/json (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. | -| [stopSequences](./vertexai-preview.generationconfig.md#generationconfigstopsequences) | string\[\] | | -| [temperature](./vertexai-preview.generationconfig.md#generationconfigtemperature) | number | | -| [topK](./vertexai-preview.generationconfig.md#generationconfigtopk) | number | | -| [topP](./vertexai-preview.generationconfig.md#generationconfigtopp) | number | | - -## GenerationConfig.candidateCount - -Signature: - -```typescript -candidateCount?: number; -``` - -## GenerationConfig.frequencyPenalty - -Signature: - -```typescript -frequencyPenalty?: number; -``` - -## GenerationConfig.maxOutputTokens - -Signature: - -```typescript -maxOutputTokens?: number; -``` - -## GenerationConfig.presencePenalty - -Signature: - -```typescript -presencePenalty?: number; -``` - -## GenerationConfig.responseMimeType - -Output response mimetype of the generated candidate text. Supported mimetypes are `text/plain` (default, text output) and `application/json` (JSON response in the candidates). The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature. - -Signature: - -```typescript -responseMimeType?: string; -``` - -## GenerationConfig.stopSequences - -Signature: - -```typescript -stopSequences?: string[]; -``` - -## GenerationConfig.temperature - -Signature: - -```typescript -temperature?: number; -``` - -## GenerationConfig.topK - -Signature: - -```typescript -topK?: number; -``` - -## GenerationConfig.topP - -Signature: - -```typescript -topP?: number; -``` diff --git a/docs-devsite/vertexai-preview.generativemodel.md b/docs-devsite/vertexai-preview.generativemodel.md deleted file mode 100644 index a50fac631cc..00000000000 --- a/docs-devsite/vertexai-preview.generativemodel.md +++ /dev/null @@ -1,201 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# GenerativeModel class -Class for generative model APIs. - -Signature: - -```typescript -export declare class GenerativeModel -``` - -## Constructors - -| Constructor | Modifiers | Description | -| --- | --- | --- | -| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai-preview.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | - -## Properties - -| Property | Modifiers | Type | Description | -| --- | --- | --- | --- | -| [generationConfig](./vertexai-preview.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | -| [model](./vertexai-preview.generativemodel.md#generativemodelmodel) | | string | | -| [requestOptions](./vertexai-preview.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | -| [safetySettings](./vertexai-preview.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | -| [systemInstruction](./vertexai-preview.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.generativemodel.md#generativemodeltools) | | [Tool](./vertexai-preview.md#tool)\[\] | | - -## Methods - -| Method | Modifiers | Description | -| --- | --- | --- | -| [countTokens(request)](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | -| [generateContent(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [generateContentStream(request)](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | -| [startChat(startChatParams)](./vertexai-preview.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | - -## GenerativeModel.(constructor) - -Constructs a new instance of the `GenerativeModel` class - -Signature: - -```typescript -constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | - -## GenerativeModel.generationConfig - -Signature: - -```typescript -generationConfig: GenerationConfig; -``` - -## GenerativeModel.model - -Signature: - -```typescript -model: string; -``` - -## GenerativeModel.requestOptions - -Signature: - -```typescript -requestOptions?: RequestOptions; -``` - -## GenerativeModel.safetySettings - -Signature: - -```typescript -safetySettings: SafetySetting[]; -``` - -## GenerativeModel.systemInstruction - -Signature: - -```typescript -systemInstruction?: Content; -``` - -## GenerativeModel.toolConfig - -Signature: - -```typescript -toolConfig?: ToolConfig; -``` - -## GenerativeModel.tools - -Signature: - -```typescript -tools?: Tool[]; -``` - -## GenerativeModel.countTokens() - -Counts the tokens in the provided request. - -Signature: - -```typescript -countTokens(request: CountTokensRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface)> - -## GenerativeModel.generateContent() - -Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). - -Signature: - -```typescript -generateContent(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface)> - -## GenerativeModel.generateContentStream() - -Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. - -Signature: - -```typescript -generateContentStream(request: GenerateContentRequest | string | Array): Promise; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| request | [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai-preview.md#part)> | | - -Returns: - -Promise<[GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface)> - -## GenerativeModel.startChat() - -Gets a new [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. - -Signature: - -```typescript -startChat(startChatParams?: StartChatParams): ChatSession; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| startChatParams | [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | | - -Returns: - -[ChatSession](./vertexai-preview.chatsession.md#chatsession_class) - diff --git a/docs-devsite/vertexai-preview.md b/docs-devsite/vertexai-preview.md deleted file mode 100644 index 27829c8ad2e..00000000000 --- a/docs-devsite/vertexai-preview.md +++ /dev/null @@ -1,397 +0,0 @@ -Project: /docs/reference/js/_project.yaml -Book: /docs/reference/_book.yaml -page_type: reference - -{% comment %} -DO NOT EDIT THIS FILE! -This is generated by the JS SDK team, and any local changes will be -overwritten. Changes should be made in the source code at -https://github.com/firebase/firebase-js-sdk -{% endcomment %} - -# vertexai-preview package -The Vertex AI in Firebase Web SDK. - -## Functions - -| Function | Description | -| --- | --- | -| function(app, ...) | -| [getVertexAI(app, options)](./vertexai-preview.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. | -| function(vertexAI, ...) | -| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai-preview.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | - -## Classes - -| Class | Description | -| --- | --- | -| [ChatSession](./vertexai-preview.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | -| [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) | Class for generative model APIs. | -| [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI in Firebase SDK. | - -## Enumerations - -| Enumeration | Description | -| --- | --- | -| [BlockReason](./vertexai-preview.md#blockreason) | Reason that a prompt was blocked. | -| [FinishReason](./vertexai-preview.md#finishreason) | Reason that a candidate finished. | -| [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | -| [FunctionDeclarationSchemaType](./vertexai-preview.md#functiondeclarationschematype) | Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ | -| [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | -| [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | -| [HarmCategory](./vertexai-preview.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | -| [HarmProbability](./vertexai-preview.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | -| [HarmSeverity](./vertexai-preview.md#harmseverity) | Harm severity levels. | -| [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. | - -## Interfaces - -| Interface | Description | -| --- | --- | -| [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | -| [Citation](./vertexai-preview.citation.md#citation_interface) | A single citation. | -| [CitationMetadata](./vertexai-preview.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). | -| [Content](./vertexai-preview.content.md#content_interface) | Content type for both prompts and response candidates. | -| [CountTokensRequest](./vertexai-preview.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) | -| [CountTokensResponse](./vertexai-preview.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). | -| [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | -| [Date\_2](./vertexai-preview.date_2.md#date_2_interface) | Protobuf google.type.Date | -| [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | -| [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | -| [FileData](./vertexai-preview.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | -| [FileDataPart](./vertexai-preview.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) | -| [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | -| [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | -| [FunctionCallPart](./vertexai-preview.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). | -| [FunctionDeclaration](./vertexai-preview.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | -| [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Schema for parameters passed to [FunctionDeclaration.parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters). | -| [FunctionDeclarationSchemaProperty](./vertexai-preview.functiondeclarationschemaproperty.md#functiondeclarationschemaproperty_interface) | Schema is used to define the format of input/output data. Represents a select subset of an OpenAPI 3.0 schema object. More fields may be added in the future as needed. | -| [FunctionDeclarationsTool](./vertexai-preview.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | -| [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. | -| [FunctionResponsePart](./vertexai-preview.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). | -| [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) | -| [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | -| [GenerateContentResult](./vertexai-preview.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. | -| [GenerateContentStreamResult](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | -| [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | Config options for content-related requests | -| [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | -| [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface) | | -| [GroundingMetadata](./vertexai-preview.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | -| [InlineDataPart](./vertexai-preview.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | -| [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | -| [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | -| [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). | -| [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) | -| [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | -| [Segment](./vertexai-preview.segment.md#segment_interface) | | -| [StartChatParams](./vertexai-preview.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). | -| [TextPart](./vertexai-preview.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | -| [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | -| [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). | -| [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | An instance of the Vertex AI in Firebase SDK. | -| [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI in Firebase SDK. | -| [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Describes the input video content. | -| [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | - -## Variables - -| Variable | Description | -| --- | --- | -| [POSSIBLE\_ROLES](./vertexai-preview.md#possible_roles) | Possible roles. | - -## Type Aliases - -| Type Alias | Description | -| --- | --- | -| [Part](./vertexai-preview.md#part) | Content part - includes text, image/video, or function call/response part types. | -| [Role](./vertexai-preview.md#role) | Role is the producer of the content. | -| [Tool](./vertexai-preview.md#tool) | Defines a tool that model can call to access external knowledge. | - -## function(app, ...) - -### getVertexAI(app, options) {:#getvertexai_04094cf} - -Returns a [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance for the given app. - -Signature: - -```typescript -export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | -| options | [VertexAIOptions](./vertexai-preview.vertexaioptions.md#vertexaioptions_interface) | | - -Returns: - -[VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) - -## function(vertexAI, ...) - -### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} - -Returns a [GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. - -Signature: - -```typescript -export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; -``` - -#### Parameters - -| Parameter | Type | Description | -| --- | --- | --- | -| vertexAI | [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) | | -| modelParams | [ModelParams](./vertexai-preview.modelparams.md#modelparams_interface) | | -| requestOptions | [RequestOptions](./vertexai-preview.requestoptions.md#requestoptions_interface) | | - -Returns: - -[GenerativeModel](./vertexai-preview.generativemodel.md#generativemodel_class) - -## POSSIBLE\_ROLES - -Possible roles. - -Signature: - -```typescript -POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] -``` - -## Part - -Content part - includes text, image/video, or function call/response part types. - -Signature: - -```typescript -export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; -``` - -## Role - -Role is the producer of the content. - -Signature: - -```typescript -export declare type Role = (typeof POSSIBLE_ROLES)[number]; -``` - -## Tool - -Defines a tool that model can call to access external knowledge. - -Signature: - -```typescript -export declare type Tool = FunctionDeclarationsTool; -``` - -## BlockReason - -Reason that a prompt was blocked. - -Signature: - -```typescript -export declare enum BlockReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| BLOCKED\_REASON\_UNSPECIFIED | "BLOCKED_REASON_UNSPECIFIED" | | -| OTHER | "OTHER" | | -| SAFETY | "SAFETY" | | - -## FinishReason - -Reason that a candidate finished. - -Signature: - -```typescript -export declare enum FinishReason -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| FINISH\_REASON\_UNSPECIFIED | "FINISH_REASON_UNSPECIFIED" | | -| MAX\_TOKENS | "MAX_TOKENS" | | -| OTHER | "OTHER" | | -| RECITATION | "RECITATION" | | -| SAFETY | "SAFETY" | | -| STOP | "STOP" | | - -## FunctionCallingMode - - -Signature: - -```typescript -export declare enum FunctionCallingMode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ANY | "ANY" | | -| AUTO | "AUTO" | | -| MODE\_UNSPECIFIED | "MODE_UNSPECIFIED" | | -| NONE | "NONE" | | - -## FunctionDeclarationSchemaType - -Contains the list of OpenAPI data types as defined by https://swagger.io/docs/specification/data-models/data-types/ - -Signature: - -```typescript -export declare enum FunctionDeclarationSchemaType -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ARRAY | "ARRAY" | Array type. | -| BOOLEAN | "BOOLEAN" | Boolean type. | -| INTEGER | "INTEGER" | Integer type. | -| NUMBER | "NUMBER" | Number type. | -| OBJECT | "OBJECT" | Object type. | -| STRING | "STRING" | String type. | - -## HarmBlockMethod - - -Signature: - -```typescript -export declare enum HarmBlockMethod -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_BLOCK\_METHOD\_UNSPECIFIED | "HARM_BLOCK_METHOD_UNSPECIFIED" | | -| PROBABILITY | "PROBABILITY" | | -| SEVERITY | "SEVERITY" | | - -## HarmBlockThreshold - -Threshold above which a prompt or candidate will be blocked. - -Signature: - -```typescript -export declare enum HarmBlockThreshold -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | -| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | -| BLOCK\_NONE | "BLOCK_NONE" | | -| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | -| HARM\_BLOCK\_THRESHOLD\_UNSPECIFIED | "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | | - -## HarmCategory - -Harm categories that would cause prompts or candidates to be blocked. - -Signature: - -```typescript -export declare enum HarmCategory -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | -| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | -| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | -| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | -| HARM\_CATEGORY\_UNSPECIFIED | "HARM_CATEGORY_UNSPECIFIED" | | - -## HarmProbability - -Probability that a prompt or candidate matches a harm category. - -Signature: - -```typescript -export declare enum HarmProbability -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_PROBABILITY\_UNSPECIFIED | "HARM_PROBABILITY_UNSPECIFIED" | | -| HIGH | "HIGH" | | -| LOW | "LOW" | | -| MEDIUM | "MEDIUM" | | -| NEGLIGIBLE | "NEGLIGIBLE" | | - -## HarmSeverity - -Harm severity levels. - -Signature: - -```typescript -export declare enum HarmSeverity -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | -| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | -| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | -| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | -| HARM\_SEVERITY\_UNSPECIFIED | "HARM_SEVERITY_UNSPECIFIED" | | - -## VertexAIErrorCode - -Standardized error codes that [VertexAIError](./vertexai-preview.vertexaierror.md#vertexaierror_class) can have. - -Signature: - -```typescript -export declare const enum VertexAIErrorCode -``` - -## Enumeration Members - -| Member | Value | Description | -| --- | --- | --- | -| ERROR | "error" | A generic error occurred. | -| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | -| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | -| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | -| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | -| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | -| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | -| REQUEST\_ERROR | "request-error" | An error occurred in a request. | -| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | - diff --git a/docs-devsite/vertexai.arrayschema.md b/docs-devsite/vertexai.arrayschema.md new file mode 100644 index 00000000000..8f228baf9e8 --- /dev/null +++ b/docs-devsite/vertexai.arrayschema.md @@ -0,0 +1,57 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ArraySchema class +Schema class for "array" types. The `items` param should refer to the type of item that can be a member of the array. + +Signature: + +```typescript +export declare class ArraySchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, items)](./vertexai.arrayschema.md#arrayschemaconstructor) | | Constructs a new instance of the ArraySchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [items](./vertexai.arrayschema.md#arrayschemaitems) | | [TypedSchema](./vertexai.md#typedschema) | | + +## ArraySchema.(constructor) + +Constructs a new instance of the `ArraySchema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaParams, items: TypedSchema); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| items | [TypedSchema](./vertexai.md#typedschema) | | + +## ArraySchema.items + +Signature: + +```typescript +items: TypedSchema; +``` diff --git a/docs-devsite/vertexai-preview.baseparams.md b/docs-devsite/vertexai.baseparams.md similarity index 67% rename from docs-devsite/vertexai-preview.baseparams.md rename to docs-devsite/vertexai.baseparams.md index 6756c919ccc..382ec825210 100644 --- a/docs-devsite/vertexai-preview.baseparams.md +++ b/docs-devsite/vertexai.baseparams.md @@ -22,8 +22,8 @@ export interface BaseParams | Property | Type | Description | | --- | --- | --- | -| [generationConfig](./vertexai-preview.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai-preview.generationconfig.md#generationconfig_interface) | | -| [safetySettings](./vertexai-preview.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai-preview.safetysetting.md#safetysetting_interface)\[\] | | +| [generationConfig](./vertexai.baseparams.md#baseparamsgenerationconfig) | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | +| [safetySettings](./vertexai.baseparams.md#baseparamssafetysettings) | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | ## BaseParams.generationConfig diff --git a/docs-devsite/vertexai.booleanschema.md b/docs-devsite/vertexai.booleanschema.md new file mode 100644 index 00000000000..89449f26142 --- /dev/null +++ b/docs-devsite/vertexai.booleanschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# BooleanSchema class +Schema class for "boolean" types. + +Signature: + +```typescript +export declare class BooleanSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.booleanschema.md#booleanschemaconstructor) | | Constructs a new instance of the BooleanSchema class | + +## BooleanSchema.(constructor) + +Constructs a new instance of the `BooleanSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.chatsession.md b/docs-devsite/vertexai.chatsession.md new file mode 100644 index 00000000000..cc5a75ace16 --- /dev/null +++ b/docs-devsite/vertexai.chatsession.md @@ -0,0 +1,138 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ChatSession class +ChatSession class that enables sending chat messages and stores history of sent and received messages so far. + +Signature: + +```typescript +export declare class ChatSession +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(apiSettings, model, params, requestOptions)](./vertexai.chatsession.md#chatsessionconstructor) | | Constructs a new instance of the ChatSession class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [model](./vertexai.chatsession.md#chatsessionmodel) | | string | | +| [params](./vertexai.chatsession.md#chatsessionparams) | | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | +| [requestOptions](./vertexai.chatsession.md#chatsessionrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [getHistory()](./vertexai.chatsession.md#chatsessiongethistory) | | Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. | +| [sendMessage(request)](./vertexai.chatsession.md#chatsessionsendmessage) | | Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | +| [sendMessageStream(request)](./vertexai.chatsession.md#chatsessionsendmessagestream) | | Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. | + +## ChatSession.(constructor) + +Constructs a new instance of the `ChatSession` class + +Signature: + +```typescript +constructor(apiSettings: ApiSettings, model: string, params?: StartChatParams | undefined, requestOptions?: RequestOptions | undefined); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| apiSettings | ApiSettings | | +| model | string | | +| params | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) \| undefined | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) \| undefined | | + +## ChatSession.model + +Signature: + +```typescript +model: string; +``` + +## ChatSession.params + +Signature: + +```typescript +params?: StartChatParams | undefined; +``` + +## ChatSession.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions | undefined; +``` + +## ChatSession.getHistory() + +Gets the chat history so far. Blocked prompts are not added to history. Neither blocked candidates nor the prompts that generated them are added to history. + +Signature: + +```typescript +getHistory(): Promise; +``` +Returns: + +Promise<[Content](./vertexai.content.md#content_interface)\[\]> + +## ChatSession.sendMessage() + +Sends a chat message and receives a non-streaming [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) + +Signature: + +```typescript +sendMessage(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> + +## ChatSession.sendMessageStream() + +Sends a chat message and receives the response as a [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) containing an iterable stream and a response promise. + +Signature: + +```typescript +sendMessageStream(request: string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + diff --git a/docs-devsite/vertexai-preview.citation.md b/docs-devsite/vertexai.citation.md similarity index 68% rename from docs-devsite/vertexai-preview.citation.md rename to docs-devsite/vertexai.citation.md index 10a615ee247..b5f5a19f231 100644 --- a/docs-devsite/vertexai-preview.citation.md +++ b/docs-devsite/vertexai.citation.md @@ -22,12 +22,12 @@ export interface Citation | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai-preview.citation.md#citationendindex) | number | | -| [license](./vertexai-preview.citation.md#citationlicense) | string | | -| [publicationDate](./vertexai-preview.citation.md#citationpublicationdate) | Date | | -| [startIndex](./vertexai-preview.citation.md#citationstartindex) | number | | -| [title](./vertexai-preview.citation.md#citationtitle) | string | | -| [uri](./vertexai-preview.citation.md#citationuri) | string | | +| [endIndex](./vertexai.citation.md#citationendindex) | number | | +| [license](./vertexai.citation.md#citationlicense) | string | | +| [publicationDate](./vertexai.citation.md#citationpublicationdate) | Date | | +| [startIndex](./vertexai.citation.md#citationstartindex) | number | | +| [title](./vertexai.citation.md#citationtitle) | string | | +| [uri](./vertexai.citation.md#citationuri) | string | | ## Citation.endIndex diff --git a/docs-devsite/vertexai-preview.citationmetadata.md b/docs-devsite/vertexai.citationmetadata.md similarity index 64% rename from docs-devsite/vertexai-preview.citationmetadata.md rename to docs-devsite/vertexai.citationmetadata.md index fa740ca1af7..e3d41a37d98 100644 --- a/docs-devsite/vertexai-preview.citationmetadata.md +++ b/docs-devsite/vertexai.citationmetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CitationMetadata interface -Citation metadata that may be found on a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface). +Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). Signature: @@ -22,7 +22,7 @@ export interface CitationMetadata | Property | Type | Description | | --- | --- | --- | -| [citations](./vertexai-preview.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai-preview.citation.md#citation_interface)\[\] | | +| [citations](./vertexai.citationmetadata.md#citationmetadatacitations) | [Citation](./vertexai.citation.md#citation_interface)\[\] | | ## CitationMetadata.citations diff --git a/docs-devsite/vertexai-preview.content.md b/docs-devsite/vertexai.content.md similarity index 76% rename from docs-devsite/vertexai-preview.content.md rename to docs-devsite/vertexai.content.md index 26198a3951f..7a4634a62bc 100644 --- a/docs-devsite/vertexai-preview.content.md +++ b/docs-devsite/vertexai.content.md @@ -22,8 +22,8 @@ export interface Content | Property | Type | Description | | --- | --- | --- | -| [parts](./vertexai-preview.content.md#contentparts) | [Part](./vertexai-preview.md#part)\[\] | | -| [role](./vertexai-preview.content.md#contentrole) | [Role](./vertexai-preview.md#role) | | +| [parts](./vertexai.content.md#contentparts) | [Part](./vertexai.md#part)\[\] | | +| [role](./vertexai.content.md#contentrole) | [Role](./vertexai.md#role) | | ## Content.parts diff --git a/docs-devsite/vertexai-preview.counttokensrequest.md b/docs-devsite/vertexai.counttokensrequest.md similarity index 68% rename from docs-devsite/vertexai-preview.counttokensrequest.md rename to docs-devsite/vertexai.counttokensrequest.md index 07e5f0d85f3..db519b7eb11 100644 --- a/docs-devsite/vertexai-preview.counttokensrequest.md +++ b/docs-devsite/vertexai.counttokensrequest.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensRequest interface -Params for calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens) +Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) Signature: @@ -22,7 +22,7 @@ export interface CountTokensRequest | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai-preview.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | +| [contents](./vertexai.counttokensrequest.md#counttokensrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | ## CountTokensRequest.contents diff --git a/docs-devsite/vertexai-preview.counttokensresponse.md b/docs-devsite/vertexai.counttokensresponse.md similarity index 67% rename from docs-devsite/vertexai-preview.counttokensresponse.md rename to docs-devsite/vertexai.counttokensresponse.md index d097d5aacff..2978f9a45bb 100644 --- a/docs-devsite/vertexai-preview.counttokensresponse.md +++ b/docs-devsite/vertexai.counttokensresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # CountTokensResponse interface -Response from calling [GenerativeModel.countTokens()](./vertexai-preview.generativemodel.md#generativemodelcounttokens). +Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). Signature: @@ -22,8 +22,8 @@ export interface CountTokensResponse | Property | Type | Description | | --- | --- | --- | -| [totalBillableCharacters](./vertexai-preview.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | -| [totalTokens](./vertexai-preview.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | +| [totalBillableCharacters](./vertexai.counttokensresponse.md#counttokensresponsetotalbillablecharacters) | number | The total number of billable characters counted across all instances from the request. | +| [totalTokens](./vertexai.counttokensresponse.md#counttokensresponsetotaltokens) | number | The total number of tokens counted across all instances from the request. | ## CountTokensResponse.totalBillableCharacters diff --git a/docs-devsite/vertexai-preview.customerrordata.md b/docs-devsite/vertexai.customerrordata.md similarity index 54% rename from docs-devsite/vertexai-preview.customerrordata.md rename to docs-devsite/vertexai.customerrordata.md index f0af0574161..701b1b84c49 100644 --- a/docs-devsite/vertexai-preview.customerrordata.md +++ b/docs-devsite/vertexai.customerrordata.md @@ -22,10 +22,10 @@ export interface CustomErrorData | Property | Type | Description | | --- | --- | --- | -| [errorDetails](./vertexai-preview.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai-preview.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | -| [response](./vertexai-preview.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) | -| [status](./vertexai-preview.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | -| [statusText](./vertexai-preview.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | +| [errorDetails](./vertexai.customerrordata.md#customerrordataerrordetails) | [ErrorDetails](./vertexai.errordetails.md#errordetails_interface)\[\] | Optional additional details about the error. | +| [response](./vertexai.customerrordata.md#customerrordataresponse) | [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | +| [status](./vertexai.customerrordata.md#customerrordatastatus) | number | HTTP status code of the error response. | +| [statusText](./vertexai.customerrordata.md#customerrordatastatustext) | string | HTTP status text of the error response. | ## CustomErrorData.errorDetails @@ -39,7 +39,7 @@ errorDetails?: ErrorDetails[]; ## CustomErrorData.response -Response from a [GenerateContentRequest](./vertexai-preview.generatecontentrequest.md#generatecontentrequest_interface) +Response from a [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) Signature: diff --git a/docs-devsite/vertexai-preview.date_2.md b/docs-devsite/vertexai.date_2.md similarity index 78% rename from docs-devsite/vertexai-preview.date_2.md rename to docs-devsite/vertexai.date_2.md index 5af031447c4..cf073bb86fe 100644 --- a/docs-devsite/vertexai-preview.date_2.md +++ b/docs-devsite/vertexai.date_2.md @@ -22,9 +22,9 @@ export interface Date | Property | Type | Description | | --- | --- | --- | -| [day](./vertexai-preview.date_2.md#date_2day) | number | | -| [month](./vertexai-preview.date_2.md#date_2month) | number | | -| [year](./vertexai-preview.date_2.md#date_2year) | number | | +| [day](./vertexai.date_2.md#date_2day) | number | | +| [month](./vertexai.date_2.md#date_2month) | number | | +| [year](./vertexai.date_2.md#date_2year) | number | | ## Date\_2.day diff --git a/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md b/docs-devsite/vertexai.enhancedgeneratecontentresponse.md similarity index 61% rename from docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md rename to docs-devsite/vertexai.enhancedgeneratecontentresponse.md index 132c5ed0be2..535fb9def8f 100644 --- a/docs-devsite/vertexai-preview.enhancedgeneratecontentresponse.md +++ b/docs-devsite/vertexai.enhancedgeneratecontentresponse.md @@ -17,14 +17,14 @@ Response object wrapped with helper methods. ```typescript export interface EnhancedGenerateContentResponse extends GenerateContentResponse ``` -Extends: [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface) +Extends: [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [functionCalls](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface)\[\] \| undefined | | -| [text](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | +| [functionCalls](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsefunctioncalls) | () => [FunctionCall](./vertexai.functioncall.md#functioncall_interface)\[\] \| undefined | | +| [text](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponsetext) | () => string | Returns the text string from the response, if available. Throws if the prompt or candidate was blocked. | ## EnhancedGenerateContentResponse.functionCalls diff --git a/docs-devsite/vertexai-preview.errordetails.md b/docs-devsite/vertexai.errordetails.md similarity index 68% rename from docs-devsite/vertexai-preview.errordetails.md rename to docs-devsite/vertexai.errordetails.md index 45e84a618ab..68959343439 100644 --- a/docs-devsite/vertexai-preview.errordetails.md +++ b/docs-devsite/vertexai.errordetails.md @@ -22,10 +22,10 @@ export interface ErrorDetails | Property | Type | Description | | --- | --- | --- | -| ["@type"](./vertexai-preview.errordetails.md#errordetails"@type") | string | | -| [domain](./vertexai-preview.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | -| [metadata](./vertexai-preview.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | -| [reason](./vertexai-preview.errordetails.md#errordetailsreason) | string | The reason for the error. | +| ["@type"](./vertexai.errordetails.md#errordetails"@type") | string | | +| [domain](./vertexai.errordetails.md#errordetailsdomain) | string | The domain where the error occurred. | +| [metadata](./vertexai.errordetails.md#errordetailsmetadata) | Record<string, unknown> | Additional metadata about the error. | +| [reason](./vertexai.errordetails.md#errordetailsreason) | string | The reason for the error. | ## ErrorDetails."@type" diff --git a/docs-devsite/vertexai-preview.filedata.md b/docs-devsite/vertexai.filedata.md similarity index 81% rename from docs-devsite/vertexai-preview.filedata.md rename to docs-devsite/vertexai.filedata.md index 577b4b1910d..7e000174692 100644 --- a/docs-devsite/vertexai-preview.filedata.md +++ b/docs-devsite/vertexai.filedata.md @@ -22,8 +22,8 @@ export interface FileData | Property | Type | Description | | --- | --- | --- | -| [fileUri](./vertexai-preview.filedata.md#filedatafileuri) | string | | -| [mimeType](./vertexai-preview.filedata.md#filedatamimetype) | string | | +| [fileUri](./vertexai.filedata.md#filedatafileuri) | string | | +| [mimeType](./vertexai.filedata.md#filedatamimetype) | string | | ## FileData.fileUri diff --git a/docs-devsite/vertexai-preview.filedatapart.md b/docs-devsite/vertexai.filedatapart.md similarity index 60% rename from docs-devsite/vertexai-preview.filedatapart.md rename to docs-devsite/vertexai.filedatapart.md index e03c056f588..74512fa6d29 100644 --- a/docs-devsite/vertexai-preview.filedatapart.md +++ b/docs-devsite/vertexai.filedatapart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FileDataPart interface -Content part interface if the part represents [FileData](./vertexai-preview.filedata.md#filedata_interface) +Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) Signature: @@ -22,11 +22,11 @@ export interface FileDataPart | Property | Type | Description | | --- | --- | --- | -| [fileData](./vertexai-preview.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai-preview.filedata.md#filedata_interface) | | -| [functionCall](./vertexai-preview.filedatapart.md#filedatapartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.filedatapart.md#filedatapartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.filedatapart.md#filedatapartinlinedata) | never | | -| [text](./vertexai-preview.filedatapart.md#filedataparttext) | never | | +| [fileData](./vertexai.filedatapart.md#filedatapartfiledata) | [FileData](./vertexai.filedata.md#filedata_interface) | | +| [functionCall](./vertexai.filedatapart.md#filedatapartfunctioncall) | never | | +| [functionResponse](./vertexai.filedatapart.md#filedatapartfunctionresponse) | never | | +| [inlineData](./vertexai.filedatapart.md#filedatapartinlinedata) | never | | +| [text](./vertexai.filedatapart.md#filedataparttext) | never | | ## FileDataPart.fileData diff --git a/docs-devsite/vertexai-preview.functioncall.md b/docs-devsite/vertexai.functioncall.md similarity index 57% rename from docs-devsite/vertexai-preview.functioncall.md rename to docs-devsite/vertexai.functioncall.md index 60e0ea50dc4..ca7bc015438 100644 --- a/docs-devsite/vertexai-preview.functioncall.md +++ b/docs-devsite/vertexai.functioncall.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCall interface -A predicted [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. +A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. Signature: @@ -22,8 +22,8 @@ export interface FunctionCall | Property | Type | Description | | --- | --- | --- | -| [args](./vertexai-preview.functioncall.md#functioncallargs) | object | | -| [name](./vertexai-preview.functioncall.md#functioncallname) | string | | +| [args](./vertexai.functioncall.md#functioncallargs) | object | | +| [name](./vertexai.functioncall.md#functioncallname) | string | | ## FunctionCall.args diff --git a/docs-devsite/vertexai-preview.functioncallingconfig.md b/docs-devsite/vertexai.functioncallingconfig.md similarity index 71% rename from docs-devsite/vertexai-preview.functioncallingconfig.md rename to docs-devsite/vertexai.functioncallingconfig.md index 1965fb76e95..3724fec5bf7 100644 --- a/docs-devsite/vertexai-preview.functioncallingconfig.md +++ b/docs-devsite/vertexai.functioncallingconfig.md @@ -21,8 +21,8 @@ export interface FunctionCallingConfig | Property | Type | Description | | --- | --- | --- | -| [allowedFunctionNames](./vertexai-preview.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | -| [mode](./vertexai-preview.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai-preview.md#functioncallingmode) | | +| [allowedFunctionNames](./vertexai.functioncallingconfig.md#functioncallingconfigallowedfunctionnames) | string\[\] | | +| [mode](./vertexai.functioncallingconfig.md#functioncallingconfigmode) | [FunctionCallingMode](./vertexai.md#functioncallingmode) | | ## FunctionCallingConfig.allowedFunctionNames diff --git a/docs-devsite/vertexai-preview.functioncallpart.md b/docs-devsite/vertexai.functioncallpart.md similarity index 59% rename from docs-devsite/vertexai-preview.functioncallpart.md rename to docs-devsite/vertexai.functioncallpart.md index 5da204692f9..af8ccf1109a 100644 --- a/docs-devsite/vertexai-preview.functioncallpart.md +++ b/docs-devsite/vertexai.functioncallpart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionCallPart interface -Content part interface if the part represents a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface). +Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionCallPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) | | -| [functionResponse](./vertexai-preview.functioncallpart.md#functioncallpartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.functioncallpart.md#functioncallpartinlinedata) | never | | -| [text](./vertexai-preview.functioncallpart.md#functioncallparttext) | never | | +| [functionCall](./vertexai.functioncallpart.md#functioncallpartfunctioncall) | [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | | +| [functionResponse](./vertexai.functioncallpart.md#functioncallpartfunctionresponse) | never | | +| [inlineData](./vertexai.functioncallpart.md#functioncallpartinlinedata) | never | | +| [text](./vertexai.functioncallpart.md#functioncallparttext) | never | | ## FunctionCallPart.functionCall diff --git a/docs-devsite/vertexai-preview.functiondeclaration.md b/docs-devsite/vertexai.functiondeclaration.md similarity index 57% rename from docs-devsite/vertexai-preview.functiondeclaration.md rename to docs-devsite/vertexai.functiondeclaration.md index e178c7e8bc3..211c1dd868d 100644 --- a/docs-devsite/vertexai-preview.functiondeclaration.md +++ b/docs-devsite/vertexai.functiondeclaration.md @@ -22,18 +22,18 @@ export declare interface FunctionDeclaration | Property | Type | Description | | --- | --- | --- | -| [description](./vertexai-preview.functiondeclaration.md#functiondeclarationdescription) | string | Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. | -| [name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | -| [parameters](./vertexai-preview.functiondeclaration.md#functiondeclarationparameters) | [FunctionDeclarationSchema](./vertexai-preview.functiondeclarationschema.md#functiondeclarationschema_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | +| [description](./vertexai.functiondeclaration.md#functiondeclarationdescription) | string | Description and purpose of the function. Model uses it to decide how and whether to call the function. | +| [name](./vertexai.functiondeclaration.md#functiondeclarationname) | string | The name of the function to call. Must start with a letter or an underscore. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a max length of 64. | +| [parameters](./vertexai.functiondeclaration.md#functiondeclarationparameters) | [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Optional. Describes the parameters to this function in JSON Schema Object format. Reflects the Open API 3.03 Parameter Object. Parameter names are case-sensitive. For a function with no parameters, this can be left unset. | ## FunctionDeclaration.description -Optional. Description and purpose of the function. Model uses it to decide how and whether to call the function. +Description and purpose of the function. Model uses it to decide how and whether to call the function. Signature: ```typescript -description?: string; +description: string; ``` ## FunctionDeclaration.name @@ -53,5 +53,5 @@ Optional. Describes the parameters to this function in JSON Schema Object format Signature: ```typescript -parameters?: FunctionDeclarationSchema; +parameters?: ObjectSchemaInterface; ``` diff --git a/docs-devsite/vertexai.functiondeclarationstool.md b/docs-devsite/vertexai.functiondeclarationstool.md new file mode 100644 index 00000000000..5e728046639 --- /dev/null +++ b/docs-devsite/vertexai.functiondeclarationstool.md @@ -0,0 +1,35 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# FunctionDeclarationsTool interface +A `FunctionDeclarationsTool` is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. + +Signature: + +```typescript +export declare interface FunctionDeclarationsTool +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [functionDeclarations](./vertexai.functiondeclarationstool.md#functiondeclarationstoolfunctiondeclarations) | [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface)\[\] | Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. | + +## FunctionDeclarationsTool.functionDeclarations + +Optional. One or more function declarations to be passed to the model along with the current user query. Model may decide to call a subset of these functions by populating [FunctionCall](./vertexai.functioncall.md#functioncall_interface) in the response. User should provide a [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) for each function call in the next turn. Based on the function responses, the model will generate the final response back to the user. Maximum 64 function declarations can be provided. + +Signature: + +```typescript +functionDeclarations?: FunctionDeclaration[]; +``` diff --git a/docs-devsite/vertexai-preview.functionresponse.md b/docs-devsite/vertexai.functionresponse.md similarity index 50% rename from docs-devsite/vertexai-preview.functionresponse.md rename to docs-devsite/vertexai.functionresponse.md index d89ace08df1..0ca553e0e6b 100644 --- a/docs-devsite/vertexai-preview.functionresponse.md +++ b/docs-devsite/vertexai.functionresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponse interface -The result output from a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai-preview.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai-preview.functioncall.md#functioncall_interface) made based on model prediction. +The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. Signature: @@ -22,8 +22,8 @@ export interface FunctionResponse | Property | Type | Description | | --- | --- | --- | -| [name](./vertexai-preview.functionresponse.md#functionresponsename) | string | | -| [response](./vertexai-preview.functionresponse.md#functionresponseresponse) | object | | +| [name](./vertexai.functionresponse.md#functionresponsename) | string | | +| [response](./vertexai.functionresponse.md#functionresponseresponse) | object | | ## FunctionResponse.name diff --git a/docs-devsite/vertexai-preview.functionresponsepart.md b/docs-devsite/vertexai.functionresponsepart.md similarity index 58% rename from docs-devsite/vertexai-preview.functionresponsepart.md rename to docs-devsite/vertexai.functionresponsepart.md index 4e246d625f6..1905c98cdc7 100644 --- a/docs-devsite/vertexai-preview.functionresponsepart.md +++ b/docs-devsite/vertexai.functionresponsepart.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # FunctionResponsePart interface -Content part interface if the part represents [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface). +Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). Signature: @@ -22,10 +22,10 @@ export interface FunctionResponsePart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai-preview.functionresponse.md#functionresponse_interface) | | -| [inlineData](./vertexai-preview.functionresponsepart.md#functionresponsepartinlinedata) | never | | -| [text](./vertexai-preview.functionresponsepart.md#functionresponseparttext) | never | | +| [functionCall](./vertexai.functionresponsepart.md#functionresponsepartfunctioncall) | never | | +| [functionResponse](./vertexai.functionresponsepart.md#functionresponsepartfunctionresponse) | [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | | +| [inlineData](./vertexai.functionresponsepart.md#functionresponsepartinlinedata) | never | | +| [text](./vertexai.functionresponsepart.md#functionresponseparttext) | never | | ## FunctionResponsePart.functionCall diff --git a/docs-devsite/vertexai.generatecontentcandidate.md b/docs-devsite/vertexai.generatecontentcandidate.md new file mode 100644 index 00000000000..a30eef55485 --- /dev/null +++ b/docs-devsite/vertexai.generatecontentcandidate.md @@ -0,0 +1,87 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerateContentCandidate interface +A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +export interface GenerateContentCandidate +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [citationMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidatecitationmetadata) | [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | | +| [content](./vertexai.generatecontentcandidate.md#generatecontentcandidatecontent) | [Content](./vertexai.content.md#content_interface) | | +| [finishMessage](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishmessage) | string | | +| [finishReason](./vertexai.generatecontentcandidate.md#generatecontentcandidatefinishreason) | [FinishReason](./vertexai.md#finishreason) | | +| [groundingMetadata](./vertexai.generatecontentcandidate.md#generatecontentcandidategroundingmetadata) | [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | | +| [index](./vertexai.generatecontentcandidate.md#generatecontentcandidateindex) | number | | +| [safetyRatings](./vertexai.generatecontentcandidate.md#generatecontentcandidatesafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | + +## GenerateContentCandidate.citationMetadata + +Signature: + +```typescript +citationMetadata?: CitationMetadata; +``` + +## GenerateContentCandidate.content + +Signature: + +```typescript +content: Content; +``` + +## GenerateContentCandidate.finishMessage + +Signature: + +```typescript +finishMessage?: string; +``` + +## GenerateContentCandidate.finishReason + +Signature: + +```typescript +finishReason?: FinishReason; +``` + +## GenerateContentCandidate.groundingMetadata + +Signature: + +```typescript +groundingMetadata?: GroundingMetadata; +``` + +## GenerateContentCandidate.index + +Signature: + +```typescript +index: number; +``` + +## GenerateContentCandidate.safetyRatings + +Signature: + +```typescript +safetyRatings?: SafetyRating[]; +``` diff --git a/docs-devsite/vertexai-preview.generatecontentrequest.md b/docs-devsite/vertexai.generatecontentrequest.md similarity index 54% rename from docs-devsite/vertexai-preview.generatecontentrequest.md rename to docs-devsite/vertexai.generatecontentrequest.md index 68ce52340e8..31f1103a2e2 100644 --- a/docs-devsite/vertexai-preview.generatecontentrequest.md +++ b/docs-devsite/vertexai.generatecontentrequest.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentRequest interface -Request sent through [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) +Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) Signature: ```typescript export interface GenerateContentRequest extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [contents](./vertexai-preview.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai-preview.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [contents](./vertexai.generatecontentrequest.md#generatecontentrequestcontents) | [Content](./vertexai.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai.generatecontentrequest.md#generatecontentrequestsysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.generatecontentrequest.md#generatecontentrequesttoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.generatecontentrequest.md#generatecontentrequesttools) | [Tool](./vertexai.md#tool)\[\] | | ## GenerateContentRequest.contents diff --git a/docs-devsite/vertexai-preview.generatecontentresponse.md b/docs-devsite/vertexai.generatecontentresponse.md similarity index 50% rename from docs-devsite/vertexai-preview.generatecontentresponse.md rename to docs-devsite/vertexai.generatecontentresponse.md index cb0fb0e3209..304674c9b6f 100644 --- a/docs-devsite/vertexai-preview.generatecontentresponse.md +++ b/docs-devsite/vertexai.generatecontentresponse.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResponse interface -Individual response from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. +Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). `generateContentStream()` will return one in each chunk until the stream is done. Signature: @@ -22,9 +22,9 @@ export interface GenerateContentResponse | Property | Type | Description | | --- | --- | --- | -| [candidates](./vertexai-preview.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | -| [promptFeedback](./vertexai-preview.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai-preview.promptfeedback.md#promptfeedback_interface) | | -| [usageMetadata](./vertexai-preview.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai-preview.usagemetadata.md#usagemetadata_interface) | | +| [candidates](./vertexai.generatecontentresponse.md#generatecontentresponsecandidates) | [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface)\[\] | | +| [promptFeedback](./vertexai.generatecontentresponse.md#generatecontentresponsepromptfeedback) | [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | | +| [usageMetadata](./vertexai.generatecontentresponse.md#generatecontentresponseusagemetadata) | [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | | ## GenerateContentResponse.candidates diff --git a/docs-devsite/vertexai-preview.generatecontentresult.md b/docs-devsite/vertexai.generatecontentresult.md similarity index 69% rename from docs-devsite/vertexai-preview.generatecontentresult.md rename to docs-devsite/vertexai.generatecontentresult.md index 87249a5bc55..3e162f9ebb2 100644 --- a/docs-devsite/vertexai-preview.generatecontentresult.md +++ b/docs-devsite/vertexai.generatecontentresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentResult interface -Result object returned from [GenerativeModel.generateContent()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontent) call. +Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. Signature: @@ -22,7 +22,7 @@ export interface GenerateContentResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai-preview.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | +| [response](./vertexai.generatecontentresult.md#generatecontentresultresponse) | [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | | ## GenerateContentResult.response diff --git a/docs-devsite/vertexai-preview.generatecontentstreamresult.md b/docs-devsite/vertexai.generatecontentstreamresult.md similarity index 52% rename from docs-devsite/vertexai-preview.generatecontentstreamresult.md rename to docs-devsite/vertexai.generatecontentstreamresult.md index 6fd46600079..340abb1d0bd 100644 --- a/docs-devsite/vertexai-preview.generatecontentstreamresult.md +++ b/docs-devsite/vertexai.generatecontentstreamresult.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # GenerateContentStreamResult interface -Result object returned from [GenerativeModel.generateContentStream()](./vertexai-preview.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. +Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over `stream` to get chunks as they come in and/or use the `response` promise to get the aggregated response when the stream is done. Signature: @@ -22,8 +22,8 @@ export interface GenerateContentStreamResult | Property | Type | Description | | --- | --- | --- | -| [response](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | -| [stream](./vertexai-preview.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai-preview.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [response](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultresponse) | Promise<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | +| [stream](./vertexai.generatecontentstreamresult.md#generatecontentstreamresultstream) | AsyncGenerator<[EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface)> | | ## GenerateContentStreamResult.response diff --git a/docs-devsite/vertexai.generationconfig.md b/docs-devsite/vertexai.generationconfig.md new file mode 100644 index 00000000000..3c3d0a14ffa --- /dev/null +++ b/docs-devsite/vertexai.generationconfig.md @@ -0,0 +1,118 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerationConfig interface +Config options for content-related requests + +Signature: + +```typescript +export interface GenerationConfig +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [candidateCount](./vertexai.generationconfig.md#generationconfigcandidatecount) | number | | +| [frequencyPenalty](./vertexai.generationconfig.md#generationconfigfrequencypenalty) | number | | +| [maxOutputTokens](./vertexai.generationconfig.md#generationconfigmaxoutputtokens) | number | | +| [presencePenalty](./vertexai.generationconfig.md#generationconfigpresencepenalty) | number | | +| [responseMimeType](./vertexai.generationconfig.md#generationconfigresponsemimetype) | string | Output response MIME type of the generated candidate text. Supported MIME types are text/plain (default, text output), application/json (JSON response in the candidates), and text/x.enum. | +| [responseSchema](./vertexai.generationconfig.md#generationconfigresponseschema) | [TypedSchema](./vertexai.md#typedschema) \| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like Schema.string() or Schema.object() or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified responseMIMEType supports a schema; currently this is limited to application/json and text/x.enum. | +| [stopSequences](./vertexai.generationconfig.md#generationconfigstopsequences) | string\[\] | | +| [temperature](./vertexai.generationconfig.md#generationconfigtemperature) | number | | +| [topK](./vertexai.generationconfig.md#generationconfigtopk) | number | | +| [topP](./vertexai.generationconfig.md#generationconfigtopp) | number | | + +## GenerationConfig.candidateCount + +Signature: + +```typescript +candidateCount?: number; +``` + +## GenerationConfig.frequencyPenalty + +Signature: + +```typescript +frequencyPenalty?: number; +``` + +## GenerationConfig.maxOutputTokens + +Signature: + +```typescript +maxOutputTokens?: number; +``` + +## GenerationConfig.presencePenalty + +Signature: + +```typescript +presencePenalty?: number; +``` + +## GenerationConfig.responseMimeType + +Output response MIME type of the generated candidate text. Supported MIME types are `text/plain` (default, text output), `application/json` (JSON response in the candidates), and `text/x.enum`. + +Signature: + +```typescript +responseMimeType?: string; +``` + +## GenerationConfig.responseSchema + +Output response schema of the generated candidate text. This value can be a class generated with a [Schema](./vertexai.schema.md#schema_class) static method like `Schema.string()` or `Schema.object()` or it can be a plain JS object matching the [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) interface.
Note: This only applies when the specified `responseMIMEType` supports a schema; currently this is limited to `application/json` and `text/x.enum`. + +Signature: + +```typescript +responseSchema?: TypedSchema | SchemaRequest; +``` + +## GenerationConfig.stopSequences + +Signature: + +```typescript +stopSequences?: string[]; +``` + +## GenerationConfig.temperature + +Signature: + +```typescript +temperature?: number; +``` + +## GenerationConfig.topK + +Signature: + +```typescript +topK?: number; +``` + +## GenerationConfig.topP + +Signature: + +```typescript +topP?: number; +``` diff --git a/docs-devsite/vertexai-preview.generativecontentblob.md b/docs-devsite/vertexai.generativecontentblob.md similarity index 76% rename from docs-devsite/vertexai-preview.generativecontentblob.md rename to docs-devsite/vertexai.generativecontentblob.md index b5dcb272027..dfcd098291f 100644 --- a/docs-devsite/vertexai-preview.generativecontentblob.md +++ b/docs-devsite/vertexai.generativecontentblob.md @@ -22,8 +22,8 @@ export interface GenerativeContentBlob | Property | Type | Description | | --- | --- | --- | -| [data](./vertexai-preview.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | -| [mimeType](./vertexai-preview.generativecontentblob.md#generativecontentblobmimetype) | string | | +| [data](./vertexai.generativecontentblob.md#generativecontentblobdata) | string | Image as a base64 string. | +| [mimeType](./vertexai.generativecontentblob.md#generativecontentblobmimetype) | string | | ## GenerativeContentBlob.data diff --git a/docs-devsite/vertexai.generativemodel.md b/docs-devsite/vertexai.generativemodel.md new file mode 100644 index 00000000000..7105f9c100b --- /dev/null +++ b/docs-devsite/vertexai.generativemodel.md @@ -0,0 +1,201 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# GenerativeModel class +Class for generative model APIs. + +Signature: + +```typescript +export declare class GenerativeModel +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(vertexAI, modelParams, requestOptions)](./vertexai.generativemodel.md#generativemodelconstructor) | | Constructs a new instance of the GenerativeModel class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [generationConfig](./vertexai.generativemodel.md#generativemodelgenerationconfig) | | [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | | +| [model](./vertexai.generativemodel.md#generativemodelmodel) | | string | | +| [requestOptions](./vertexai.generativemodel.md#generativemodelrequestoptions) | | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | +| [safetySettings](./vertexai.generativemodel.md#generativemodelsafetysettings) | | [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface)\[\] | | +| [systemInstruction](./vertexai.generativemodel.md#generativemodelsysteminstruction) | | [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.generativemodel.md#generativemodeltoolconfig) | | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.generativemodel.md#generativemodeltools) | | [Tool](./vertexai.md#tool)\[\] | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [countTokens(request)](./vertexai.generativemodel.md#generativemodelcounttokens) | | Counts the tokens in the provided request. | +| [generateContent(request)](./vertexai.generativemodel.md#generativemodelgeneratecontent) | | Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [generateContentStream(request)](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) | | Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. | +| [startChat(startChatParams)](./vertexai.generativemodel.md#generativemodelstartchat) | | Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. | + +## GenerativeModel.(constructor) + +Constructs a new instance of the `GenerativeModel` class + +Signature: + +```typescript +constructor(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | + +## GenerativeModel.generationConfig + +Signature: + +```typescript +generationConfig: GenerationConfig; +``` + +## GenerativeModel.model + +Signature: + +```typescript +model: string; +``` + +## GenerativeModel.requestOptions + +Signature: + +```typescript +requestOptions?: RequestOptions; +``` + +## GenerativeModel.safetySettings + +Signature: + +```typescript +safetySettings: SafetySetting[]; +``` + +## GenerativeModel.systemInstruction + +Signature: + +```typescript +systemInstruction?: Content; +``` + +## GenerativeModel.toolConfig + +Signature: + +```typescript +toolConfig?: ToolConfig; +``` + +## GenerativeModel.tools + +Signature: + +```typescript +tools?: Tool[]; +``` + +## GenerativeModel.countTokens() + +Counts the tokens in the provided request. + +Signature: + +```typescript +countTokens(request: CountTokensRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface)> + +## GenerativeModel.generateContent() + +Makes a single non-streaming call to the model and returns an object containing a single [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). + +Signature: + +```typescript +generateContent(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface)> + +## GenerativeModel.generateContentStream() + +Makes a single streaming call to the model and returns an object containing an iterable stream that iterates over all chunks in the streaming response as well as a promise that returns the final aggregated response. + +Signature: + +```typescript +generateContentStream(request: GenerateContentRequest | string | Array): Promise; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| request | [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) \| string \| Array<string \| [Part](./vertexai.md#part)> | | + +Returns: + +Promise<[GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface)> + +## GenerativeModel.startChat() + +Gets a new [ChatSession](./vertexai.chatsession.md#chatsession_class) instance which can be used for multi-turn chats. + +Signature: + +```typescript +startChat(startChatParams?: StartChatParams): ChatSession; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| startChatParams | [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | | + +Returns: + +[ChatSession](./vertexai.chatsession.md#chatsession_class) + diff --git a/docs-devsite/vertexai-preview.groundingattribution.md b/docs-devsite/vertexai.groundingattribution.md similarity index 58% rename from docs-devsite/vertexai-preview.groundingattribution.md rename to docs-devsite/vertexai.groundingattribution.md index 2c7d2f09e0b..b72d8150635 100644 --- a/docs-devsite/vertexai-preview.groundingattribution.md +++ b/docs-devsite/vertexai.groundingattribution.md @@ -21,10 +21,10 @@ export interface GroundingAttribution | Property | Type | Description | | --- | --- | --- | -| [confidenceScore](./vertexai-preview.groundingattribution.md#groundingattributionconfidencescore) | number | | -| [retrievedContext](./vertexai-preview.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | -| [segment](./vertexai-preview.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai-preview.segment.md#segment_interface) | | -| [web](./vertexai-preview.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai-preview.webattribution.md#webattribution_interface) | | +| [confidenceScore](./vertexai.groundingattribution.md#groundingattributionconfidencescore) | number | | +| [retrievedContext](./vertexai.groundingattribution.md#groundingattributionretrievedcontext) | [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [segment](./vertexai.groundingattribution.md#groundingattributionsegment) | [Segment](./vertexai.segment.md#segment_interface) | | +| [web](./vertexai.groundingattribution.md#groundingattributionweb) | [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | ## GroundingAttribution.confidenceScore diff --git a/docs-devsite/vertexai-preview.groundingmetadata.md b/docs-devsite/vertexai.groundingmetadata.md similarity index 66% rename from docs-devsite/vertexai-preview.groundingmetadata.md rename to docs-devsite/vertexai.groundingmetadata.md index 5f40a00457d..186f00d29a7 100644 --- a/docs-devsite/vertexai-preview.groundingmetadata.md +++ b/docs-devsite/vertexai.groundingmetadata.md @@ -22,9 +22,9 @@ export interface GroundingMetadata | Property | Type | Description | | --- | --- | --- | -| [groundingAttributions](./vertexai-preview.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai-preview.groundingattribution.md#groundingattribution_interface)\[\] | | -| [retrievalQueries](./vertexai-preview.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | -| [webSearchQueries](./vertexai-preview.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | +| [groundingAttributions](./vertexai.groundingmetadata.md#groundingmetadatagroundingattributions) | [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface)\[\] | | +| [retrievalQueries](./vertexai.groundingmetadata.md#groundingmetadataretrievalqueries) | string\[\] | | +| [webSearchQueries](./vertexai.groundingmetadata.md#groundingmetadatawebsearchqueries) | string\[\] | | ## GroundingMetadata.groundingAttributions diff --git a/docs-devsite/vertexai-preview.inlinedatapart.md b/docs-devsite/vertexai.inlinedatapart.md similarity index 60% rename from docs-devsite/vertexai-preview.inlinedatapart.md rename to docs-devsite/vertexai.inlinedatapart.md index ae05f80ddb7..0cb064fc357 100644 --- a/docs-devsite/vertexai-preview.inlinedatapart.md +++ b/docs-devsite/vertexai.inlinedatapart.md @@ -22,11 +22,11 @@ export interface InlineDataPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai-preview.generativecontentblob.md#generativecontentblob_interface) | | -| [text](./vertexai-preview.inlinedatapart.md#inlinedataparttext) | never | | -| [videoMetadata](./vertexai-preview.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai-preview.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | +| [functionCall](./vertexai.inlinedatapart.md#inlinedatapartfunctioncall) | never | | +| [functionResponse](./vertexai.inlinedatapart.md#inlinedatapartfunctionresponse) | never | | +| [inlineData](./vertexai.inlinedatapart.md#inlinedatapartinlinedata) | [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | | +| [text](./vertexai.inlinedatapart.md#inlinedataparttext) | never | | +| [videoMetadata](./vertexai.inlinedatapart.md#inlinedatapartvideometadata) | [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Applicable if inlineData is a video. | ## InlineDataPart.functionCall diff --git a/docs-devsite/vertexai.integerschema.md b/docs-devsite/vertexai.integerschema.md new file mode 100644 index 00000000000..4822bdd618b --- /dev/null +++ b/docs-devsite/vertexai.integerschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# IntegerSchema class +Schema class for "integer" types. + +Signature: + +```typescript +export declare class IntegerSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.integerschema.md#integerschemaconstructor) | | Constructs a new instance of the IntegerSchema class | + +## IntegerSchema.(constructor) + +Constructs a new instance of the `IntegerSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.md b/docs-devsite/vertexai.md new file mode 100644 index 00000000000..d7eed6f2f86 --- /dev/null +++ b/docs-devsite/vertexai.md @@ -0,0 +1,412 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# vertexai package +The Vertex AI in Firebase Web SDK. + +## Functions + +| Function | Description | +| --- | --- | +| function(app, ...) | +| [getVertexAI(app, options)](./vertexai.md#getvertexai_04094cf) | Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. | +| function(vertexAI, ...) | +| [getGenerativeModel(vertexAI, modelParams, requestOptions)](./vertexai.md#getgenerativemodel_e3037c9) | Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. | + +## Classes + +| Class | Description | +| --- | --- | +| [ArraySchema](./vertexai.arrayschema.md#arrayschema_class) | Schema class for "array" types. The items param should refer to the type of item that can be a member of the array. | +| [BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) | Schema class for "boolean" types. | +| [ChatSession](./vertexai.chatsession.md#chatsession_class) | ChatSession class that enables sending chat messages and stores history of sent and received messages so far. | +| [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) | Class for generative model APIs. | +| [IntegerSchema](./vertexai.integerschema.md#integerschema_class) | Schema class for "integer" types. | +| [NumberSchema](./vertexai.numberschema.md#numberschema_class) | Schema class for "number" types. | +| [ObjectSchema](./vertexai.objectschema.md#objectschema_class) | Schema class for "object" types. The properties param must be a map of Schema objects. | +| [Schema](./vertexai.schema.md#schema_class) | 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.) | +| [StringSchema](./vertexai.stringschema.md#stringschema_class) | Schema class for "string" types. Can be used with or without enum values. | +| [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) | Error class for the Vertex AI in Firebase SDK. | + +## Enumerations + +| Enumeration | Description | +| --- | --- | +| [BlockReason](./vertexai.md#blockreason) | Reason that a prompt was blocked. | +| [FinishReason](./vertexai.md#finishreason) | Reason that a candidate finished. | +| [FunctionCallingMode](./vertexai.md#functioncallingmode) | | +| [HarmBlockMethod](./vertexai.md#harmblockmethod) | | +| [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | Threshold above which a prompt or candidate will be blocked. | +| [HarmCategory](./vertexai.md#harmcategory) | Harm categories that would cause prompts or candidates to be blocked. | +| [HarmProbability](./vertexai.md#harmprobability) | Probability that a prompt or candidate matches a harm category. | +| [HarmSeverity](./vertexai.md#harmseverity) | Harm severity levels. | +| [SchemaType](./vertexai.md#schematype) | Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) | +| [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. | + +## Interfaces + +| Interface | Description | +| --- | --- | +| [BaseParams](./vertexai.baseparams.md#baseparams_interface) | Base parameters for a number of methods. | +| [Citation](./vertexai.citation.md#citation_interface) | A single citation. | +| [CitationMetadata](./vertexai.citationmetadata.md#citationmetadata_interface) | Citation metadata that may be found on a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface). | +| [Content](./vertexai.content.md#content_interface) | Content type for both prompts and response candidates. | +| [CountTokensRequest](./vertexai.counttokensrequest.md#counttokensrequest_interface) | Params for calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens) | +| [CountTokensResponse](./vertexai.counttokensresponse.md#counttokensresponse_interface) | Response from calling [GenerativeModel.countTokens()](./vertexai.generativemodel.md#generativemodelcounttokens). | +| [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) | Details object that contains data originating from a bad HTTP response. | +| [Date\_2](./vertexai.date_2.md#date_2_interface) | Protobuf google.type.Date | +| [EnhancedGenerateContentResponse](./vertexai.enhancedgeneratecontentresponse.md#enhancedgeneratecontentresponse_interface) | Response object wrapped with helper methods. | +| [ErrorDetails](./vertexai.errordetails.md#errordetails_interface) | Details object that may be included in an error response. | +| [FileData](./vertexai.filedata.md#filedata_interface) | Data pointing to a file uploaded on Google Cloud Storage. | +| [FileDataPart](./vertexai.filedatapart.md#filedatapart_interface) | Content part interface if the part represents [FileData](./vertexai.filedata.md#filedata_interface) | +| [FunctionCall](./vertexai.functioncall.md#functioncall_interface) | A predicted [FunctionCall](./vertexai.functioncall.md#functioncall_interface) returned from the model that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing the parameters and their values. | +| [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | +| [FunctionCallPart](./vertexai.functioncallpart.md#functioncallpart_interface) | Content part interface if the part represents a [FunctionCall](./vertexai.functioncall.md#functioncall_interface). | +| [FunctionDeclaration](./vertexai.functiondeclaration.md#functiondeclaration_interface) | Structured representation of a function declaration as defined by the [OpenAPI 3.0 specification](https://spec.openapis.org/oas/v3.0.3). Included in this declaration are the function name and parameters. This FunctionDeclaration is a representation of a block of code that can be used as a Tool by the model and executed by the client. | +| [FunctionDeclarationsTool](./vertexai.functiondeclarationstool.md#functiondeclarationstool_interface) | A FunctionDeclarationsTool is a piece of code that enables the system to interact with external systems to perform an action, or set of actions, outside of knowledge and scope of the model. | +| [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface) | The result output from a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) that contains a string representing the [FunctionDeclaration.name](./vertexai.functiondeclaration.md#functiondeclarationname) and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of a [FunctionCall](./vertexai.functioncall.md#functioncall_interface) made based on model prediction. | +| [FunctionResponsePart](./vertexai.functionresponsepart.md#functionresponsepart_interface) | Content part interface if the part represents [FunctionResponse](./vertexai.functionresponse.md#functionresponse_interface). | +| [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | A candidate returned as part of a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [GenerateContentRequest](./vertexai.generatecontentrequest.md#generatecontentrequest_interface) | Request sent through [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) | +| [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface) | Individual response from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) and [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream). generateContentStream() will return one in each chunk until the stream is done. | +| [GenerateContentResult](./vertexai.generatecontentresult.md#generatecontentresult_interface) | Result object returned from [GenerativeModel.generateContent()](./vertexai.generativemodel.md#generativemodelgeneratecontent) call. | +| [GenerateContentStreamResult](./vertexai.generatecontentstreamresult.md#generatecontentstreamresult_interface) | Result object returned from [GenerativeModel.generateContentStream()](./vertexai.generativemodel.md#generativemodelgeneratecontentstream) call. Iterate over stream to get chunks as they come in and/or use the response promise to get the aggregated response when the stream is done. | +| [GenerationConfig](./vertexai.generationconfig.md#generationconfig_interface) | Config options for content-related requests | +| [GenerativeContentBlob](./vertexai.generativecontentblob.md#generativecontentblob_interface) | Interface for sending an image. | +| [GroundingAttribution](./vertexai.groundingattribution.md#groundingattribution_interface) | | +| [GroundingMetadata](./vertexai.groundingmetadata.md#groundingmetadata_interface) | Metadata returned to client when grounding is enabled. | +| [InlineDataPart](./vertexai.inlinedatapart.md#inlinedatapart_interface) | Content part interface if the part represents an image. | +| [ModelParams](./vertexai.modelparams.md#modelparams_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | +| [ObjectSchemaInterface](./vertexai.objectschemainterface.md#objectschemainterface_interface) | Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. | +| [PromptFeedback](./vertexai.promptfeedback.md#promptfeedback_interface) | If the prompt was blocked, this will be populated with blockReason and the relevant safetyRatings. | +| [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). | +| [RetrievedContextAttribution](./vertexai.retrievedcontextattribution.md#retrievedcontextattribution_interface) | | +| [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface) | A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) | +| [SafetySetting](./vertexai.safetysetting.md#safetysetting_interface) | Safety setting that can be sent as part of request parameters. | +| [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | Interface for [Schema](./vertexai.schema.md#schema_class) class. | +| [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. | +| [SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface) | Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. | +| [SchemaShared](./vertexai.schemashared.md#schemashared_interface) | Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. | +| [Segment](./vertexai.segment.md#segment_interface) | | +| [StartChatParams](./vertexai.startchatparams.md#startchatparams_interface) | Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). | +| [TextPart](./vertexai.textpart.md#textpart_interface) | Content part interface if the part represents a text string. | +| [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | Tool config. This config is shared for all tools provided in the request. | +| [UsageMetadata](./vertexai.usagemetadata.md#usagemetadata_interface) | Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). | +| [VertexAI](./vertexai.vertexai.md#vertexai_interface) | An instance of the Vertex AI in Firebase SDK. | +| [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | Options when initializing the Vertex AI in Firebase SDK. | +| [VideoMetadata](./vertexai.videometadata.md#videometadata_interface) | Describes the input video content. | +| [WebAttribution](./vertexai.webattribution.md#webattribution_interface) | | + +## Variables + +| Variable | Description | +| --- | --- | +| [POSSIBLE\_ROLES](./vertexai.md#possible_roles) | Possible roles. | + +## Type Aliases + +| Type Alias | Description | +| --- | --- | +| [Part](./vertexai.md#part) | Content part - includes text, image/video, or function call/response part types. | +| [Role](./vertexai.md#role) | Role is the producer of the content. | +| [Tool](./vertexai.md#tool) | Defines a tool that model can call to access external knowledge. | +| [TypedSchema](./vertexai.md#typedschema) | A type that includes all specific Schema types. | + +## function(app, ...) + +### getVertexAI(app, options) {:#getvertexai_04094cf} + +Returns a [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance for the given app. + +Signature: + +```typescript +export declare function getVertexAI(app?: FirebaseApp, options?: VertexAIOptions): VertexAI; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| app | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) to use. | +| options | [VertexAIOptions](./vertexai.vertexaioptions.md#vertexaioptions_interface) | | + +Returns: + +[VertexAI](./vertexai.vertexai.md#vertexai_interface) + +## function(vertexAI, ...) + +### getGenerativeModel(vertexAI, modelParams, requestOptions) {:#getgenerativemodel_e3037c9} + +Returns a [GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) class with methods for inference and other functionality. + +Signature: + +```typescript +export declare function getGenerativeModel(vertexAI: VertexAI, modelParams: ModelParams, requestOptions?: RequestOptions): GenerativeModel; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| vertexAI | [VertexAI](./vertexai.vertexai.md#vertexai_interface) | | +| modelParams | [ModelParams](./vertexai.modelparams.md#modelparams_interface) | | +| requestOptions | [RequestOptions](./vertexai.requestoptions.md#requestoptions_interface) | | + +Returns: + +[GenerativeModel](./vertexai.generativemodel.md#generativemodel_class) + +## POSSIBLE\_ROLES + +Possible roles. + +Signature: + +```typescript +POSSIBLE_ROLES: readonly ["user", "model", "function", "system"] +``` + +## Part + +Content part - includes text, image/video, or function call/response part types. + +Signature: + +```typescript +export declare type Part = TextPart | InlineDataPart | FunctionCallPart | FunctionResponsePart | FileDataPart; +``` + +## Role + +Role is the producer of the content. + +Signature: + +```typescript +export declare type Role = (typeof POSSIBLE_ROLES)[number]; +``` + +## Tool + +Defines a tool that model can call to access external knowledge. + +Signature: + +```typescript +export declare type Tool = FunctionDeclarationsTool; +``` + +## TypedSchema + +A type that includes all specific Schema types. + +Signature: + +```typescript +export declare type TypedSchema = IntegerSchema | NumberSchema | StringSchema | BooleanSchema | ObjectSchema | ArraySchema; +``` + +## BlockReason + +Reason that a prompt was blocked. + +Signature: + +```typescript +export declare enum BlockReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| OTHER | "OTHER" | | +| SAFETY | "SAFETY" | | + +## FinishReason + +Reason that a candidate finished. + +Signature: + +```typescript +export declare enum FinishReason +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| MAX\_TOKENS | "MAX_TOKENS" | | +| OTHER | "OTHER" | | +| RECITATION | "RECITATION" | | +| SAFETY | "SAFETY" | | +| STOP | "STOP" | | + +## FunctionCallingMode + + +Signature: + +```typescript +export declare enum FunctionCallingMode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ANY | "ANY" | | +| AUTO | "AUTO" | | +| NONE | "NONE" | | + +## HarmBlockMethod + + +Signature: + +```typescript +export declare enum HarmBlockMethod +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| PROBABILITY | "PROBABILITY" | | +| SEVERITY | "SEVERITY" | | + +## HarmBlockThreshold + +Threshold above which a prompt or candidate will be blocked. + +Signature: + +```typescript +export declare enum HarmBlockThreshold +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| BLOCK\_LOW\_AND\_ABOVE | "BLOCK_LOW_AND_ABOVE" | | +| BLOCK\_MEDIUM\_AND\_ABOVE | "BLOCK_MEDIUM_AND_ABOVE" | | +| BLOCK\_NONE | "BLOCK_NONE" | | +| BLOCK\_ONLY\_HIGH | "BLOCK_ONLY_HIGH" | | + +## HarmCategory + +Harm categories that would cause prompts or candidates to be blocked. + +Signature: + +```typescript +export declare enum HarmCategory +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_CATEGORY\_DANGEROUS\_CONTENT | "HARM_CATEGORY_DANGEROUS_CONTENT" | | +| HARM\_CATEGORY\_HARASSMENT | "HARM_CATEGORY_HARASSMENT" | | +| HARM\_CATEGORY\_HATE\_SPEECH | "HARM_CATEGORY_HATE_SPEECH" | | +| HARM\_CATEGORY\_SEXUALLY\_EXPLICIT | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | | + +## HarmProbability + +Probability that a prompt or candidate matches a harm category. + +Signature: + +```typescript +export declare enum HarmProbability +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HIGH | "HIGH" | | +| LOW | "LOW" | | +| MEDIUM | "MEDIUM" | | +| NEGLIGIBLE | "NEGLIGIBLE" | | + +## HarmSeverity + +Harm severity levels. + +Signature: + +```typescript +export declare enum HarmSeverity +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| HARM\_SEVERITY\_HIGH | "HARM_SEVERITY_HIGH" | | +| HARM\_SEVERITY\_LOW | "HARM_SEVERITY_LOW" | | +| HARM\_SEVERITY\_MEDIUM | "HARM_SEVERITY_MEDIUM" | | +| HARM\_SEVERITY\_NEGLIGIBLE | "HARM_SEVERITY_NEGLIGIBLE" | | + +## SchemaType + +Contains the list of OpenAPI data types as defined by the [OpenAPI specification](https://swagger.io/docs/specification/data-models/data-types/) + +Signature: + +```typescript +export declare enum SchemaType +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| ARRAY | "array" | Array type. | +| BOOLEAN | "boolean" | Boolean type. | +| INTEGER | "integer" | Integer type. | +| NUMBER | "number" | Number type. | +| OBJECT | "object" | Object type. | +| STRING | "string" | String type. | + +## VertexAIErrorCode + +Standardized error codes that [VertexAIError](./vertexai.vertexaierror.md#vertexaierror_class) can have. + +Signature: + +```typescript +export declare const enum VertexAIErrorCode +``` + +## Enumeration Members + +| Member | Value | Description | +| --- | --- | --- | +| API\_NOT\_ENABLED | "api-not-enabled" | An error due to the Firebase API not being enabled in the Console. | +| ERROR | "error" | A generic error occurred. | +| FETCH\_ERROR | "fetch-error" | An error occurred while performing a fetch. | +| INVALID\_CONTENT | "invalid-content" | An error associated with a Content object. | +| INVALID\_SCHEMA | "invalid-schema" | An error due to invalid Schema input. | +| NO\_API\_KEY | "no-api-key" | An error occurred due to a missing Firebase API key. | +| NO\_MODEL | "no-model" | An error occurred due to a model name not being specified during initialization. | +| NO\_PROJECT\_ID | "no-project-id" | An error occurred due to a missing project ID. | +| PARSE\_FAILED | "parse-failed" | An error occurred while parsing. | +| REQUEST\_ERROR | "request-error" | An error occurred in a request. | +| RESPONSE\_ERROR | "response-error" | An error occurred in a response. | + diff --git a/docs-devsite/vertexai-preview.modelparams.md b/docs-devsite/vertexai.modelparams.md similarity index 54% rename from docs-devsite/vertexai-preview.modelparams.md rename to docs-devsite/vertexai.modelparams.md index 34d68f86714..590bc14e435 100644 --- a/docs-devsite/vertexai-preview.modelparams.md +++ b/docs-devsite/vertexai.modelparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # ModelParams interface -Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). Signature: ```typescript export interface ModelParams extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [model](./vertexai-preview.modelparams.md#modelparamsmodel) | string | | -| [systemInstruction](./vertexai-preview.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.modelparams.md#modelparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [model](./vertexai.modelparams.md#modelparamsmodel) | string | | +| [systemInstruction](./vertexai.modelparams.md#modelparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.modelparams.md#modelparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.modelparams.md#modelparamstools) | [Tool](./vertexai.md#tool)\[\] | | ## ModelParams.model diff --git a/docs-devsite/vertexai.numberschema.md b/docs-devsite/vertexai.numberschema.md new file mode 100644 index 00000000000..8fdd9374652 --- /dev/null +++ b/docs-devsite/vertexai.numberschema.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# NumberSchema class +Schema class for "number" types. + +Signature: + +```typescript +export declare class NumberSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.numberschema.md#numberschemaconstructor) | | Constructs a new instance of the NumberSchema class | + +## NumberSchema.(constructor) + +Constructs a new instance of the `NumberSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + diff --git a/docs-devsite/vertexai.objectschema.md b/docs-devsite/vertexai.objectschema.md new file mode 100644 index 00000000000..8731960b220 --- /dev/null +++ b/docs-devsite/vertexai.objectschema.md @@ -0,0 +1,71 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchema class +Schema class for "object" types. The `properties` param must be a map of `Schema` objects. + +Signature: + +```typescript +export declare class ObjectSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, properties, optionalProperties)](./vertexai.objectschema.md#objectschemaconstructor) | | Constructs a new instance of the ObjectSchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [optionalProperties](./vertexai.objectschema.md#objectschemaoptionalproperties) | | string\[\] | | +| [properties](./vertexai.objectschema.md#objectschemaproperties) | | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | + +## ObjectSchema.(constructor) + +Constructs a new instance of the `ObjectSchema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaParams, properties: { + [k: string]: TypedSchema; + }, optionalProperties?: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| properties | { \[k: string\]: [TypedSchema](./vertexai.md#typedschema); } | | +| optionalProperties | string\[\] | | + +## ObjectSchema.optionalProperties + +Signature: + +```typescript +optionalProperties: string[]; +``` + +## ObjectSchema.properties + +Signature: + +```typescript +properties: { + [k: string]: TypedSchema; + }; +``` diff --git a/docs-devsite/vertexai.objectschemainterface.md b/docs-devsite/vertexai.objectschemainterface.md new file mode 100644 index 00000000000..6a4e052d183 --- /dev/null +++ b/docs-devsite/vertexai.objectschemainterface.md @@ -0,0 +1,43 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# ObjectSchemaInterface interface +Interface for [ObjectSchema](./vertexai.objectschema.md#objectschema_class) class. + +Signature: + +```typescript +export interface ObjectSchemaInterface extends SchemaInterface +``` +Extends: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [optionalProperties](./vertexai.objectschemainterface.md#objectschemainterfaceoptionalproperties) | string\[\] | | +| [type](./vertexai.objectschemainterface.md#objectschemainterfacetype) | [SchemaType.OBJECT](./vertexai.md#schematypeobject_enummember) | | + +## ObjectSchemaInterface.optionalProperties + +Signature: + +```typescript +optionalProperties?: string[]; +``` + +## ObjectSchemaInterface.type + +Signature: + +```typescript +type: SchemaType.OBJECT; +``` diff --git a/docs-devsite/vertexai-preview.promptfeedback.md b/docs-devsite/vertexai.promptfeedback.md similarity index 66% rename from docs-devsite/vertexai-preview.promptfeedback.md rename to docs-devsite/vertexai.promptfeedback.md index cb27f10c8c3..369ef02051d 100644 --- a/docs-devsite/vertexai-preview.promptfeedback.md +++ b/docs-devsite/vertexai.promptfeedback.md @@ -22,16 +22,16 @@ export interface PromptFeedback | Property | Type | Description | | --- | --- | --- | -| [blockReason](./vertexai-preview.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai-preview.md#blockreason) | | -| [blockReasonMessage](./vertexai-preview.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | -| [safetyRatings](./vertexai-preview.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai-preview.safetyrating.md#safetyrating_interface)\[\] | | +| [blockReason](./vertexai.promptfeedback.md#promptfeedbackblockreason) | [BlockReason](./vertexai.md#blockreason) | | +| [blockReasonMessage](./vertexai.promptfeedback.md#promptfeedbackblockreasonmessage) | string | | +| [safetyRatings](./vertexai.promptfeedback.md#promptfeedbacksafetyratings) | [SafetyRating](./vertexai.safetyrating.md#safetyrating_interface)\[\] | | ## PromptFeedback.blockReason Signature: ```typescript -blockReason: BlockReason; +blockReason?: BlockReason; ``` ## PromptFeedback.blockReasonMessage diff --git a/docs-devsite/vertexai-preview.requestoptions.md b/docs-devsite/vertexai.requestoptions.md similarity index 61% rename from docs-devsite/vertexai-preview.requestoptions.md rename to docs-devsite/vertexai.requestoptions.md index 550ec44ce96..5647df804b5 100644 --- a/docs-devsite/vertexai-preview.requestoptions.md +++ b/docs-devsite/vertexai.requestoptions.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # RequestOptions interface -Params passed to [getGenerativeModel()](./vertexai-preview.md#getgenerativemodel_e3037c9). +Params passed to [getGenerativeModel()](./vertexai.md#getgenerativemodel_e3037c9). Signature: @@ -22,8 +22,8 @@ export interface RequestOptions | Property | Type | Description | | --- | --- | --- | -| [baseUrl](./vertexai-preview.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebaseml.googleapis.com | -| [timeout](./vertexai-preview.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. | +| [baseUrl](./vertexai.requestoptions.md#requestoptionsbaseurl) | string | Base url for endpoint. Defaults to https://firebaseml.googleapis.com | +| [timeout](./vertexai.requestoptions.md#requestoptionstimeout) | number | Request timeout in milliseconds. Defaults to 180 seconds (180000ms). | ## RequestOptions.baseUrl @@ -37,7 +37,7 @@ baseUrl?: string; ## RequestOptions.timeout -Request timeout in milliseconds. +Request timeout in milliseconds. Defaults to 180 seconds (180000ms). Signature: diff --git a/docs-devsite/vertexai-preview.retrievedcontextattribution.md b/docs-devsite/vertexai.retrievedcontextattribution.md similarity index 76% rename from docs-devsite/vertexai-preview.retrievedcontextattribution.md rename to docs-devsite/vertexai.retrievedcontextattribution.md index 0a121cdc004..e36bfacb3ec 100644 --- a/docs-devsite/vertexai-preview.retrievedcontextattribution.md +++ b/docs-devsite/vertexai.retrievedcontextattribution.md @@ -21,8 +21,8 @@ export interface RetrievedContextAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | -| [uri](./vertexai-preview.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | +| [title](./vertexai.retrievedcontextattribution.md#retrievedcontextattributiontitle) | string | | +| [uri](./vertexai.retrievedcontextattribution.md#retrievedcontextattributionuri) | string | | ## RetrievedContextAttribution.title diff --git a/docs-devsite/vertexai-preview.safetyrating.md b/docs-devsite/vertexai.safetyrating.md similarity index 55% rename from docs-devsite/vertexai-preview.safetyrating.md rename to docs-devsite/vertexai.safetyrating.md index 65b1bc8fb42..b5f204bef2c 100644 --- a/docs-devsite/vertexai-preview.safetyrating.md +++ b/docs-devsite/vertexai.safetyrating.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # SafetyRating interface -A safety rating associated with a [GenerateContentCandidate](./vertexai-preview.generatecontentcandidate.md#generatecontentcandidate_interface) +A safety rating associated with a [GenerateContentCandidate](./vertexai.generatecontentcandidate.md#generatecontentcandidate_interface) Signature: @@ -22,12 +22,12 @@ export interface SafetyRating | Property | Type | Description | | --- | --- | --- | -| [blocked](./vertexai-preview.safetyrating.md#safetyratingblocked) | boolean | | -| [category](./vertexai-preview.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | -| [probability](./vertexai-preview.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai-preview.md#harmprobability) | | -| [probabilityScore](./vertexai-preview.safetyrating.md#safetyratingprobabilityscore) | number | | -| [severity](./vertexai-preview.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai-preview.md#harmseverity) | | -| [severityScore](./vertexai-preview.safetyrating.md#safetyratingseverityscore) | number | | +| [blocked](./vertexai.safetyrating.md#safetyratingblocked) | boolean | | +| [category](./vertexai.safetyrating.md#safetyratingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | +| [probability](./vertexai.safetyrating.md#safetyratingprobability) | [HarmProbability](./vertexai.md#harmprobability) | | +| [probabilityScore](./vertexai.safetyrating.md#safetyratingprobabilityscore) | number | | +| [severity](./vertexai.safetyrating.md#safetyratingseverity) | [HarmSeverity](./vertexai.md#harmseverity) | | +| [severityScore](./vertexai.safetyrating.md#safetyratingseverityscore) | number | | ## SafetyRating.blocked diff --git a/docs-devsite/vertexai-preview.safetysetting.md b/docs-devsite/vertexai.safetysetting.md similarity index 66% rename from docs-devsite/vertexai-preview.safetysetting.md rename to docs-devsite/vertexai.safetysetting.md index 78678315805..6aad50963cd 100644 --- a/docs-devsite/vertexai-preview.safetysetting.md +++ b/docs-devsite/vertexai.safetysetting.md @@ -22,9 +22,9 @@ export interface SafetySetting | Property | Type | Description | | --- | --- | --- | -| [category](./vertexai-preview.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai-preview.md#harmcategory) | | -| [method](./vertexai-preview.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai-preview.md#harmblockmethod) | | -| [threshold](./vertexai-preview.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai-preview.md#harmblockthreshold) | | +| [category](./vertexai.safetysetting.md#safetysettingcategory) | [HarmCategory](./vertexai.md#harmcategory) | | +| [method](./vertexai.safetysetting.md#safetysettingmethod) | [HarmBlockMethod](./vertexai.md#harmblockmethod) | | +| [threshold](./vertexai.safetysetting.md#safetysettingthreshold) | [HarmBlockThreshold](./vertexai.md#harmblockthreshold) | | ## SafetySetting.category diff --git a/docs-devsite/vertexai.schema.md b/docs-devsite/vertexai.schema.md new file mode 100644 index 00000000000..f4a36c3c506 --- /dev/null +++ b/docs-devsite/vertexai.schema.md @@ -0,0 +1,250 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# Schema class +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.) + +Signature: + +```typescript +export declare abstract class Schema implements SchemaInterface +``` +Implements: [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams)](./vertexai.schema.md#schemaconstructor) | | Constructs a new instance of the Schema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [description](./vertexai.schema.md#schemadescription) | | string | Optional. The description of the property. | +| [example](./vertexai.schema.md#schemaexample) | | unknown | Optional. The example of the property. | +| [format](./vertexai.schema.md#schemaformat) | | string | Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
| +| [nullable](./vertexai.schema.md#schemanullable) | | boolean | Optional. Whether the property is nullable. Defaults to false. | +| [type](./vertexai.schema.md#schematype) | | [SchemaType](./vertexai.md#schematype) | Optional. The type of the property. [SchemaType](./vertexai.md#schematype). | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [array(arrayParams)](./vertexai.schema.md#schemaarray) | static | | +| [boolean(booleanParams)](./vertexai.schema.md#schemaboolean) | static | | +| [enumString(stringParams)](./vertexai.schema.md#schemaenumstring) | static | | +| [integer(integerParams)](./vertexai.schema.md#schemainteger) | static | | +| [number(numberParams)](./vertexai.schema.md#schemanumber) | static | | +| [object(objectParams)](./vertexai.schema.md#schemaobject) | static | | +| [string(stringParams)](./vertexai.schema.md#schemastring) | static | | + +## Schema.(constructor) + +Constructs a new instance of the `Schema` class + +Signature: + +```typescript +constructor(schemaParams: SchemaInterface); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface) | | + +## Schema.description + +Optional. The description of the property. + +Signature: + +```typescript +description?: string; +``` + +## Schema.example + +Optional. The example of the property. + +Signature: + +```typescript +example?: unknown; +``` + +## Schema.format + +Optional. The format of the property. Supported formats:
  • for NUMBER type: "float", "double"
  • for INTEGER type: "int32", "int64"
  • for STRING type: "email", "byte", etc
+ +Signature: + +```typescript +format?: string; +``` + +## Schema.nullable + +Optional. Whether the property is nullable. Defaults to false. + +Signature: + +```typescript +nullable: boolean; +``` + +## Schema.type + +Optional. The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` + +## Schema.array() + +Signature: + +```typescript +static array(arrayParams: SchemaParams & { + items: Schema; + }): ArraySchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| arrayParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { items: [Schema](./vertexai.schema.md#schema_class); } | | + +Returns: + +[ArraySchema](./vertexai.arrayschema.md#arrayschema_class) + +## Schema.boolean() + +Signature: + +```typescript +static boolean(booleanParams?: SchemaParams): BooleanSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| booleanParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[BooleanSchema](./vertexai.booleanschema.md#booleanschema_class) + +## Schema.enumString() + +Signature: + +```typescript +static enumString(stringParams: SchemaParams & { + enum: string[]; + }): StringSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { enum: string\[\]; } | | + +Returns: + +[StringSchema](./vertexai.stringschema.md#stringschema_class) + +## Schema.integer() + +Signature: + +```typescript +static integer(integerParams?: SchemaParams): IntegerSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| integerParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[IntegerSchema](./vertexai.integerschema.md#integerschema_class) + +## Schema.number() + +Signature: + +```typescript +static number(numberParams?: SchemaParams): NumberSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| numberParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[NumberSchema](./vertexai.numberschema.md#numberschema_class) + +## Schema.object() + +Signature: + +```typescript +static object(objectParams: SchemaParams & { + properties: { + [k: string]: Schema; + }; + optionalProperties?: string[]; + }): ObjectSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| objectParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) & { properties: { \[k: string\]: [Schema](./vertexai.schema.md#schema_class); }; optionalProperties?: string\[\]; } | | + +Returns: + +[ObjectSchema](./vertexai.objectschema.md#objectschema_class) + +## Schema.string() + +Signature: + +```typescript +static string(stringParams?: SchemaParams): StringSchema; +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| stringParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | + +Returns: + +[StringSchema](./vertexai.stringschema.md#stringschema_class) + diff --git a/docs-devsite/vertexai.schemainterface.md b/docs-devsite/vertexai.schemainterface.md new file mode 100644 index 00000000000..3992c9e5116 --- /dev/null +++ b/docs-devsite/vertexai.schemainterface.md @@ -0,0 +1,36 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaInterface interface +Interface for [Schema](./vertexai.schema.md#schema_class) class. + +Signature: + +```typescript +export interface SchemaInterface extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [type](./vertexai.schemainterface.md#schemainterfacetype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | + +## SchemaInterface.type + +The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` diff --git a/docs-devsite/vertexai.schemaparams.md b/docs-devsite/vertexai.schemaparams.md new file mode 100644 index 00000000000..3c6d9f385fd --- /dev/null +++ b/docs-devsite/vertexai.schemaparams.md @@ -0,0 +1,21 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaParams interface +Params passed to [Schema](./vertexai.schema.md#schema_class) static methods to create specific [Schema](./vertexai.schema.md#schema_class) classes. + +Signature: + +```typescript +export interface SchemaParams extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaInterface](./vertexai.schemainterface.md#schemainterface_interface)> + diff --git a/docs-devsite/vertexai.schemarequest.md b/docs-devsite/vertexai.schemarequest.md new file mode 100644 index 00000000000..f12259b1608 --- /dev/null +++ b/docs-devsite/vertexai.schemarequest.md @@ -0,0 +1,47 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaRequest interface +Final format for [Schema](./vertexai.schema.md#schema_class) params passed to backend requests. + +Signature: + +```typescript +export interface SchemaRequest extends SchemaShared +``` +Extends: [SchemaShared](./vertexai.schemashared.md#schemashared_interface)<[SchemaRequest](./vertexai.schemarequest.md#schemarequest_interface)> + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [required](./vertexai.schemarequest.md#schemarequestrequired) | string\[\] | Optional. Array of required property. | +| [type](./vertexai.schemarequest.md#schemarequesttype) | [SchemaType](./vertexai.md#schematype) | The type of the property. [SchemaType](./vertexai.md#schematype). | + +## SchemaRequest.required + +Optional. Array of required property. + +Signature: + +```typescript +required?: string[]; +``` + +## SchemaRequest.type + +The type of the property. [SchemaType](./vertexai.md#schematype). + +Signature: + +```typescript +type: SchemaType; +``` diff --git a/docs-devsite/vertexai.schemashared.md b/docs-devsite/vertexai.schemashared.md new file mode 100644 index 00000000000..50cc6464ecf --- /dev/null +++ b/docs-devsite/vertexai.schemashared.md @@ -0,0 +1,103 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# SchemaShared interface +Basic [Schema](./vertexai.schema.md#schema_class) properties shared across several Schema-related types. + +Signature: + +```typescript +export interface SchemaShared +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [description](./vertexai.schemashared.md#schemashareddescription) | string | Optional. The description of the property. | +| [enum](./vertexai.schemashared.md#schemasharedenum) | string\[\] | Optional. The enum of the property. | +| [example](./vertexai.schemashared.md#schemasharedexample) | unknown | Optional. The example of the property. | +| [format](./vertexai.schemashared.md#schemasharedformat) | string | Optional. The format of the property. | +| [items](./vertexai.schemashared.md#schemashareditems) | T | Optional. The items of the property. | +| [nullable](./vertexai.schemashared.md#schemasharednullable) | boolean | Optional. Whether the property is nullable. | +| [properties](./vertexai.schemashared.md#schemasharedproperties) | { \[k: string\]: T; } | Optional. Map of Schema objects. | + +## SchemaShared.description + +Optional. The description of the property. + +Signature: + +```typescript +description?: string; +``` + +## SchemaShared.enum + +Optional. The enum of the property. + +Signature: + +```typescript +enum?: string[]; +``` + +## SchemaShared.example + +Optional. The example of the property. + +Signature: + +```typescript +example?: unknown; +``` + +## SchemaShared.format + +Optional. The format of the property. + +Signature: + +```typescript +format?: string; +``` + +## SchemaShared.items + +Optional. The items of the property. + +Signature: + +```typescript +items?: T; +``` + +## SchemaShared.nullable + +Optional. Whether the property is nullable. + +Signature: + +```typescript +nullable?: boolean; +``` + +## SchemaShared.properties + +Optional. Map of `Schema` objects. + +Signature: + +```typescript +properties?: { + [k: string]: T; + }; +``` diff --git a/docs-devsite/vertexai-preview.segment.md b/docs-devsite/vertexai.segment.md similarity index 75% rename from docs-devsite/vertexai-preview.segment.md rename to docs-devsite/vertexai.segment.md index c64bc3ffcda..db61f00a149 100644 --- a/docs-devsite/vertexai-preview.segment.md +++ b/docs-devsite/vertexai.segment.md @@ -21,9 +21,9 @@ export interface Segment | Property | Type | Description | | --- | --- | --- | -| [endIndex](./vertexai-preview.segment.md#segmentendindex) | number | | -| [partIndex](./vertexai-preview.segment.md#segmentpartindex) | number | | -| [startIndex](./vertexai-preview.segment.md#segmentstartindex) | number | | +| [endIndex](./vertexai.segment.md#segmentendindex) | number | | +| [partIndex](./vertexai.segment.md#segmentpartindex) | number | | +| [startIndex](./vertexai.segment.md#segmentstartindex) | number | | ## Segment.endIndex diff --git a/docs-devsite/vertexai-preview.startchatparams.md b/docs-devsite/vertexai.startchatparams.md similarity index 51% rename from docs-devsite/vertexai-preview.startchatparams.md rename to docs-devsite/vertexai.startchatparams.md index f422f7a1ff0..e07bbd91d82 100644 --- a/docs-devsite/vertexai-preview.startchatparams.md +++ b/docs-devsite/vertexai.startchatparams.md @@ -10,23 +10,23 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # StartChatParams interface -Params for [GenerativeModel.startChat()](./vertexai-preview.generativemodel.md#generativemodelstartchat). +Params for [GenerativeModel.startChat()](./vertexai.generativemodel.md#generativemodelstartchat). Signature: ```typescript export interface StartChatParams extends BaseParams ``` -Extends: [BaseParams](./vertexai-preview.baseparams.md#baseparams_interface) +Extends: [BaseParams](./vertexai.baseparams.md#baseparams_interface) ## Properties | Property | Type | Description | | --- | --- | --- | -| [history](./vertexai-preview.startchatparams.md#startchatparamshistory) | [Content](./vertexai-preview.content.md#content_interface)\[\] | | -| [systemInstruction](./vertexai-preview.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai-preview.md#part) \| [Content](./vertexai-preview.content.md#content_interface) | | -| [toolConfig](./vertexai-preview.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai-preview.toolconfig.md#toolconfig_interface) | | -| [tools](./vertexai-preview.startchatparams.md#startchatparamstools) | [Tool](./vertexai-preview.md#tool)\[\] | | +| [history](./vertexai.startchatparams.md#startchatparamshistory) | [Content](./vertexai.content.md#content_interface)\[\] | | +| [systemInstruction](./vertexai.startchatparams.md#startchatparamssysteminstruction) | string \| [Part](./vertexai.md#part) \| [Content](./vertexai.content.md#content_interface) | | +| [toolConfig](./vertexai.startchatparams.md#startchatparamstoolconfig) | [ToolConfig](./vertexai.toolconfig.md#toolconfig_interface) | | +| [tools](./vertexai.startchatparams.md#startchatparamstools) | [Tool](./vertexai.md#tool)\[\] | | ## StartChatParams.history diff --git a/docs-devsite/vertexai.stringschema.md b/docs-devsite/vertexai.stringschema.md new file mode 100644 index 00000000000..bfafe0fe9df --- /dev/null +++ b/docs-devsite/vertexai.stringschema.md @@ -0,0 +1,57 @@ +Project: /docs/reference/js/_project.yaml +Book: /docs/reference/_book.yaml +page_type: reference + +{% comment %} +DO NOT EDIT THIS FILE! +This is generated by the JS SDK team, and any local changes will be +overwritten. Changes should be made in the source code at +https://github.com/firebase/firebase-js-sdk +{% endcomment %} + +# StringSchema class +Schema class for "string" types. Can be used with or without enum values. + +Signature: + +```typescript +export declare class StringSchema extends Schema +``` +Extends: [Schema](./vertexai.schema.md#schema_class) + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(schemaParams, enumValues)](./vertexai.stringschema.md#stringschemaconstructor) | | Constructs a new instance of the StringSchema class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [enum](./vertexai.stringschema.md#stringschemaenum) | | string\[\] | | + +## StringSchema.(constructor) + +Constructs a new instance of the `StringSchema` class + +Signature: + +```typescript +constructor(schemaParams?: SchemaParams, enumValues?: string[]); +``` + +#### Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| schemaParams | [SchemaParams](./vertexai.schemaparams.md#schemaparams_interface) | | +| enumValues | string\[\] | | + +## StringSchema.enum + +Signature: + +```typescript +enum?: string[]; +``` diff --git a/docs-devsite/vertexai-preview.textpart.md b/docs-devsite/vertexai.textpart.md similarity index 72% rename from docs-devsite/vertexai-preview.textpart.md rename to docs-devsite/vertexai.textpart.md index 206168180b2..afee40a369d 100644 --- a/docs-devsite/vertexai-preview.textpart.md +++ b/docs-devsite/vertexai.textpart.md @@ -22,10 +22,10 @@ export interface TextPart | Property | Type | Description | | --- | --- | --- | -| [functionCall](./vertexai-preview.textpart.md#textpartfunctioncall) | never | | -| [functionResponse](./vertexai-preview.textpart.md#textpartfunctionresponse) | never | | -| [inlineData](./vertexai-preview.textpart.md#textpartinlinedata) | never | | -| [text](./vertexai-preview.textpart.md#textparttext) | string | | +| [functionCall](./vertexai.textpart.md#textpartfunctioncall) | never | | +| [functionResponse](./vertexai.textpart.md#textpartfunctionresponse) | never | | +| [inlineData](./vertexai.textpart.md#textpartinlinedata) | never | | +| [text](./vertexai.textpart.md#textparttext) | string | | ## TextPart.functionCall diff --git a/docs-devsite/vertexai-preview.toolconfig.md b/docs-devsite/vertexai.toolconfig.md similarity index 71% rename from docs-devsite/vertexai-preview.toolconfig.md rename to docs-devsite/vertexai.toolconfig.md index 4278eef509b..30c62c17c01 100644 --- a/docs-devsite/vertexai-preview.toolconfig.md +++ b/docs-devsite/vertexai.toolconfig.md @@ -22,12 +22,12 @@ export interface ToolConfig | Property | Type | Description | | --- | --- | --- | -| [functionCallingConfig](./vertexai-preview.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai-preview.functioncallingconfig.md#functioncallingconfig_interface) | | +| [functionCallingConfig](./vertexai.toolconfig.md#toolconfigfunctioncallingconfig) | [FunctionCallingConfig](./vertexai.functioncallingconfig.md#functioncallingconfig_interface) | | ## ToolConfig.functionCallingConfig Signature: ```typescript -functionCallingConfig: FunctionCallingConfig; +functionCallingConfig?: FunctionCallingConfig; ``` diff --git a/docs-devsite/vertexai-preview.usagemetadata.md b/docs-devsite/vertexai.usagemetadata.md similarity index 63% rename from docs-devsite/vertexai-preview.usagemetadata.md rename to docs-devsite/vertexai.usagemetadata.md index 2829c9dbd5d..d254f34335f 100644 --- a/docs-devsite/vertexai-preview.usagemetadata.md +++ b/docs-devsite/vertexai.usagemetadata.md @@ -10,7 +10,7 @@ https://github.com/firebase/firebase-js-sdk {% endcomment %} # UsageMetadata interface -Usage metadata about a [GenerateContentResponse](./vertexai-preview.generatecontentresponse.md#generatecontentresponse_interface). +Usage metadata about a [GenerateContentResponse](./vertexai.generatecontentresponse.md#generatecontentresponse_interface). Signature: @@ -22,9 +22,9 @@ export interface UsageMetadata | Property | Type | Description | | --- | --- | --- | -| [candidatesTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatacandidatestokencount) | number | | -| [promptTokenCount](./vertexai-preview.usagemetadata.md#usagemetadataprompttokencount) | number | | -| [totalTokenCount](./vertexai-preview.usagemetadata.md#usagemetadatatotaltokencount) | number | | +| [candidatesTokenCount](./vertexai.usagemetadata.md#usagemetadatacandidatestokencount) | number | | +| [promptTokenCount](./vertexai.usagemetadata.md#usagemetadataprompttokencount) | number | | +| [totalTokenCount](./vertexai.usagemetadata.md#usagemetadatatotaltokencount) | number | | ## UsageMetadata.candidatesTokenCount diff --git a/docs-devsite/vertexai-preview.vertexai.md b/docs-devsite/vertexai.vertexai.md similarity index 62% rename from docs-devsite/vertexai-preview.vertexai.md rename to docs-devsite/vertexai.vertexai.md index 46c13416370..4797bf8bada 100644 --- a/docs-devsite/vertexai-preview.vertexai.md +++ b/docs-devsite/vertexai.vertexai.md @@ -22,12 +22,12 @@ export interface VertexAI | Property | Type | Description | | --- | --- | --- | -| [app](./vertexai-preview.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. | -| [location](./vertexai-preview.vertexai.md#vertexailocation) | string | | +| [app](./vertexai.vertexai.md#vertexaiapp) | [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) | The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. | +| [location](./vertexai.vertexai.md#vertexailocation) | string | | ## VertexAI.app -The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai-preview.vertexai.md#vertexai_interface) instance is associated with. +The [FirebaseApp](./app.firebaseapp.md#firebaseapp_interface) this [VertexAI](./vertexai.vertexai.md#vertexai_interface) instance is associated with. Signature: diff --git a/docs-devsite/vertexai-preview.vertexaierror.md b/docs-devsite/vertexai.vertexaierror.md similarity index 57% rename from docs-devsite/vertexai-preview.vertexaierror.md rename to docs-devsite/vertexai.vertexaierror.md index 8ad434d0988..86532ac6018 100644 --- a/docs-devsite/vertexai-preview.vertexaierror.md +++ b/docs-devsite/vertexai.vertexaierror.md @@ -23,15 +23,14 @@ export declare class VertexAIError extends FirebaseError | Constructor | Modifiers | Description | | --- | --- | --- | -| [(constructor)(code, message, customErrorData)](./vertexai-preview.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | +| [(constructor)(code, message, customErrorData)](./vertexai.vertexaierror.md#vertexaierrorconstructor) | | Constructs a new instance of the VertexAIError class. | ## Properties | Property | Modifiers | Type | Description | | --- | --- | --- | --- | -| [code](./vertexai-preview.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | | -| [customErrorData](./vertexai-preview.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | | -| [message](./vertexai-preview.vertexaierror.md#vertexaierrormessage) | | string | | +| [code](./vertexai.vertexaierror.md#vertexaierrorcode) | | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | | +| [customErrorData](./vertexai.vertexaierror.md#vertexaierrorcustomerrordata) | | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | | ## VertexAIError.(constructor) @@ -47,9 +46,9 @@ constructor(code: VertexAIErrorCode, message: string, customErrorData?: CustomEr | Parameter | Type | Description | | --- | --- | --- | -| code | [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai-preview.md#vertexaierrorcode). | +| code | [VertexAIErrorCode](./vertexai.md#vertexaierrorcode) | The error code from [VertexAIErrorCode](./vertexai.md#vertexaierrorcode). | | message | string | A human-readable message describing the error. | -| customErrorData | [CustomErrorData](./vertexai-preview.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | +| customErrorData | [CustomErrorData](./vertexai.customerrordata.md#customerrordata_interface) \| undefined | Optional error data. | ## VertexAIError.code @@ -66,11 +65,3 @@ readonly code: VertexAIErrorCode; ```typescript readonly customErrorData?: CustomErrorData | undefined; ``` - -## VertexAIError.message - -Signature: - -```typescript -readonly message: string; -``` diff --git a/docs-devsite/vertexai-preview.vertexaioptions.md b/docs-devsite/vertexai.vertexaioptions.md similarity index 87% rename from docs-devsite/vertexai-preview.vertexaioptions.md rename to docs-devsite/vertexai.vertexaioptions.md index 4b42406eb95..e15b525bfed 100644 --- a/docs-devsite/vertexai-preview.vertexaioptions.md +++ b/docs-devsite/vertexai.vertexaioptions.md @@ -22,7 +22,7 @@ export interface VertexAIOptions | Property | Type | Description | | --- | --- | --- | -| [location](./vertexai-preview.vertexaioptions.md#vertexaioptionslocation) | string | | +| [location](./vertexai.vertexaioptions.md#vertexaioptionslocation) | string | | ## VertexAIOptions.location diff --git a/docs-devsite/vertexai-preview.videometadata.md b/docs-devsite/vertexai.videometadata.md similarity index 66% rename from docs-devsite/vertexai-preview.videometadata.md rename to docs-devsite/vertexai.videometadata.md index 04d8883bae9..b4f872c4e3d 100644 --- a/docs-devsite/vertexai-preview.videometadata.md +++ b/docs-devsite/vertexai.videometadata.md @@ -22,8 +22,8 @@ export interface VideoMetadata | Property | Type | Description | | --- | --- | --- | -| [endOffset](./vertexai-preview.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | -| [startOffset](./vertexai-preview.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [endOffset](./vertexai.videometadata.md#videometadataendoffset) | string | The end offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | +| [startOffset](./vertexai.videometadata.md#videometadatastartoffset) | string | The start offset of the video in protobuf [Duration](https://cloud.google.com/ruby/docs/reference/google-cloud-workflows-v1/latest/Google-Protobuf-Duration#json-mapping) format. | ## VideoMetadata.endOffset diff --git a/docs-devsite/vertexai-preview.webattribution.md b/docs-devsite/vertexai.webattribution.md similarity index 79% rename from docs-devsite/vertexai-preview.webattribution.md rename to docs-devsite/vertexai.webattribution.md index 5db6f94b82e..bb4fecf874d 100644 --- a/docs-devsite/vertexai-preview.webattribution.md +++ b/docs-devsite/vertexai.webattribution.md @@ -21,8 +21,8 @@ export interface WebAttribution | Property | Type | Description | | --- | --- | --- | -| [title](./vertexai-preview.webattribution.md#webattributiontitle) | string | | -| [uri](./vertexai-preview.webattribution.md#webattributionuri) | string | | +| [title](./vertexai.webattribution.md#webattributiontitle) | string | | +| [uri](./vertexai.webattribution.md#webattributionuri) | string | | ## WebAttribution.title diff --git a/packages/vertexai/src/api.ts b/packages/vertexai/src/api.ts index 23c502895d8..42f33ed2a85 100644 --- a/packages/vertexai/src/api.ts +++ b/packages/vertexai/src/api.ts @@ -39,7 +39,7 @@ declare module '@firebase/component' { } /** - * Returns a {@link VertexAI} instance for the given app. + * Returns a {@link VertexAI} instance for the given app. * * @public * @@ -59,7 +59,7 @@ export function getVertexAI( } /** - * Returns a {@link GenerativeModel} class with methods for inference + * Returns a {@link GenerativeModel} class with methods for inference * and other functionality. * * @public diff --git a/packages/vertexai/src/errors.ts b/packages/vertexai/src/errors.ts index ad3f9b72f5a..b643a5f552d 100644 --- a/packages/vertexai/src/errors.ts +++ b/packages/vertexai/src/errors.ts @@ -28,7 +28,7 @@ export class VertexAIError extends FirebaseError { /** * Constructs a new instance of the `VertexAIError` class. * - * @param code - The error code from {@link VertexAIErrorCode}. + * @param code - The error code from {@link VertexAIErrorCode}. * @param message - A human-readable message describing the error. * @param customErrorData - Optional error data. */ diff --git a/packages/vertexai/src/methods/chat-session.ts b/packages/vertexai/src/methods/chat-session.ts index 0d1636c1cd8..bfa3f2a660f 100644 --- a/packages/vertexai/src/methods/chat-session.ts +++ b/packages/vertexai/src/methods/chat-session.ts @@ -71,7 +71,7 @@ export class ChatSession { /** * Sends a chat message and receives a non-streaming - * {@link GenerateContentResult} + * {@link GenerateContentResult} */ async sendMessage( request: string | Array @@ -125,7 +125,7 @@ export class ChatSession { /** * Sends a chat message and receives the response as a - * {@link GenerateContentStreamResult} containing an iterable stream + * {@link GenerateContentStreamResult} containing an iterable stream * and a response promise. */ async sendMessageStream( diff --git a/packages/vertexai/src/models/generative-model.ts b/packages/vertexai/src/models/generative-model.ts index 88be3ee6436..e719529967c 100644 --- a/packages/vertexai/src/models/generative-model.ts +++ b/packages/vertexai/src/models/generative-model.ts @@ -116,7 +116,7 @@ export class GenerativeModel { /** * Makes a single non-streaming call to the model - * and returns an object containing a single {@link GenerateContentResponse}. + * and returns an object containing a single {@link GenerateContentResponse}. */ async generateContent( request: GenerateContentRequest | string | Array @@ -163,7 +163,7 @@ export class GenerativeModel { } /** - * Gets a new {@link ChatSession} instance which can be used for + * Gets a new {@link ChatSession} instance which can be used for * multi-turn chats. */ startChat(startChatParams?: StartChatParams): ChatSession { diff --git a/packages/vertexai/src/public-types.ts b/packages/vertexai/src/public-types.ts index fbc5d51084d..280fee9d1cd 100644 --- a/packages/vertexai/src/public-types.ts +++ b/packages/vertexai/src/public-types.ts @@ -25,7 +25,7 @@ export * from './types'; */ export interface VertexAI { /** - * The {@link @firebase/app#FirebaseApp} this {@link VertexAI} instance is associated with. + * The {@link @firebase/app#FirebaseApp} this {@link VertexAI} instance is associated with. */ app: FirebaseApp; location: string; diff --git a/packages/vertexai/src/requests/response-helpers.ts b/packages/vertexai/src/requests/response-helpers.ts index 1b43602b0cb..efff09591a6 100644 --- a/packages/vertexai/src/requests/response-helpers.ts +++ b/packages/vertexai/src/requests/response-helpers.ts @@ -119,7 +119,7 @@ export function getText(response: GenerateContentResponse): string { } /** - * Returns {@link FunctionCall}s associated with first candidate. + * Returns {@link FunctionCall}s associated with first candidate. */ export function getFunctionCalls( response: GenerateContentResponse diff --git a/packages/vertexai/src/requests/schema-builder.ts b/packages/vertexai/src/requests/schema-builder.ts index 8a36aaa8997..3d219d58b13 100644 --- a/packages/vertexai/src/requests/schema-builder.ts +++ b/packages/vertexai/src/requests/schema-builder.ts @@ -239,7 +239,7 @@ export class ArraySchema extends Schema { /** * Schema class for "object" types. - * The `properties` param must be a map of Schema. + * The `properties` param must be a map of `Schema` objects. * @public */ export class ObjectSchema extends Schema { diff --git a/packages/vertexai/src/types/content.ts b/packages/vertexai/src/types/content.ts index ad2906671e4..abf5d29222a 100644 --- a/packages/vertexai/src/types/content.ts +++ b/packages/vertexai/src/types/content.ts @@ -82,7 +82,7 @@ export interface VideoMetadata { } /** - * Content part interface if the part represents a {@link FunctionCall}. + * Content part interface if the part represents a {@link FunctionCall}. * @public */ export interface FunctionCallPart { @@ -93,7 +93,7 @@ export interface FunctionCallPart { } /** - * Content part interface if the part represents {@link FunctionResponse}. + * Content part interface if the part represents {@link FunctionResponse}. * @public */ export interface FunctionResponsePart { @@ -104,7 +104,7 @@ export interface FunctionResponsePart { } /** - * Content part interface if the part represents {@link FileData} + * Content part interface if the part represents {@link FileData} * @public */ export interface FileDataPart { @@ -116,7 +116,7 @@ export interface FileDataPart { } /** - * A predicted {@link FunctionCall} returned from the model + * A predicted {@link FunctionCall} returned from the model * that contains a string representing the {@link FunctionDeclaration.name} * and a structured JSON object containing the parameters and their values. * @public @@ -127,11 +127,11 @@ export interface FunctionCall { } /** - * The result output from a {@link FunctionCall} that contains a string + * The result output from a {@link FunctionCall} that contains a string * representing the {@link FunctionDeclaration.name} * and a structured JSON object containing any output * from the function is used as context to the model. - * This should contain the result of a {@link FunctionCall} + * This should contain the result of a {@link FunctionCall} * made based on model prediction. * @public */ diff --git a/packages/vertexai/src/types/error.ts b/packages/vertexai/src/types/error.ts index aaaf19f05b3..8d83a52a0aa 100644 --- a/packages/vertexai/src/types/error.ts +++ b/packages/vertexai/src/types/error.ts @@ -50,7 +50,7 @@ export interface CustomErrorData { /** HTTP status text of the error response. */ statusText?: string; - /** Response from a {@link GenerateContentRequest} */ + /** Response from a {@link GenerateContentRequest} */ response?: GenerateContentResponse; /** Optional additional details about the error. */ @@ -58,7 +58,7 @@ export interface CustomErrorData { } /** - * Standardized error codes that {@link VertexAIError} can have. + * Standardized error codes that {@link VertexAIError} can have. * * @public */ diff --git a/packages/vertexai/src/types/requests.ts b/packages/vertexai/src/types/requests.ts index e86918a8ed8..61013471316 100644 --- a/packages/vertexai/src/types/requests.ts +++ b/packages/vertexai/src/types/requests.ts @@ -35,7 +35,7 @@ export interface BaseParams { } /** - * Params passed to {@link getGenerativeModel}. + * Params passed to {@link getGenerativeModel}. * @public */ export interface ModelParams extends BaseParams { @@ -81,17 +81,18 @@ export interface GenerationConfig { frequencyPenalty?: number; /** * Output response MIME type of the generated candidate text. - * Supported MIME types are `text/plain` (default, text output) and `application/json` - * (JSON response in the candidates). + * Supported MIME types are `text/plain` (default, text output), + * `application/json` (JSON response in the candidates), and + * `text/x.enum`. */ responseMimeType?: string; /** * Output response schema of the generated candidate text. This - * value can be a class generated with a {@link Schema} static method + * value can be a class generated with a {@link Schema} static method * like `Schema.string()` or `Schema.object()` or it can be a plain - * JS object matching the {@link SchemaRequest} interface. + * JS object matching the {@link SchemaRequest} interface. *
Note: This only applies when the specified `responseMIMEType` supports a schema; currently - * this is limited to `application/json`. + * this is limited to `application/json` and `text/x.enum`. */ responseSchema?: TypedSchema | SchemaRequest; } @@ -116,7 +117,7 @@ export interface CountTokensRequest { } /** - * Params passed to {@link getGenerativeModel}. + * Params passed to {@link getGenerativeModel}. * @public */ export interface RequestOptions { @@ -176,8 +177,8 @@ export declare interface FunctionDeclarationsTool { * Optional. One or more function declarations * to be passed to the model along with the current user query. Model may * decide to call a subset of these functions by populating - * {@link FunctionCall} in the response. User should - * provide a {@link FunctionResponse} for each + * {@link FunctionCall} in the response. User should + * provide a {@link FunctionResponse} for each * function call in the next turn. Based on the function responses, the model will * generate the final response back to the user. Maximum 64 function * declarations can be provided. diff --git a/packages/vertexai/src/types/responses.ts b/packages/vertexai/src/types/responses.ts index 026002a851d..83cd4366f12 100644 --- a/packages/vertexai/src/types/responses.ts +++ b/packages/vertexai/src/types/responses.ts @@ -75,7 +75,7 @@ export interface GenerateContentResponse { } /** - * Usage metadata about a {@link GenerateContentResponse}. + * Usage metadata about a {@link GenerateContentResponse}. * * @public */ @@ -97,7 +97,7 @@ export interface PromptFeedback { } /** - * A candidate returned as part of a {@link GenerateContentResponse}. + * A candidate returned as part of a {@link GenerateContentResponse}. * @public */ export interface GenerateContentCandidate { @@ -111,7 +111,7 @@ export interface GenerateContentCandidate { } /** - * Citation metadata that may be found on a {@link GenerateContentCandidate}. + * Citation metadata that may be found on a {@link GenerateContentCandidate}. * @public */ export interface CitationMetadata { @@ -187,7 +187,7 @@ export interface Date { } /** - * A safety rating associated with a {@link GenerateContentCandidate} + * A safety rating associated with a {@link GenerateContentCandidate} * @public */ export interface SafetyRating { diff --git a/packages/vertexai/src/types/schema.ts b/packages/vertexai/src/types/schema.ts index 7b8f34d89d6..fca213431ad 100644 --- a/packages/vertexai/src/types/schema.ts +++ b/packages/vertexai/src/types/schema.ts @@ -37,7 +37,7 @@ export enum SchemaType { } /** - * Basic {@link Schema} properties shared across several Schema-related + * Basic {@link Schema} properties shared across several Schema-related * types. * @public */ @@ -48,7 +48,7 @@ export interface SchemaShared { description?: string; /** Optional. The items of the property. */ items?: T; - /** Optional. Map of Schemas. */ + /** Optional. Map of `Schema` objects. */ properties?: { [k: string]: T; }; @@ -62,14 +62,14 @@ export interface SchemaShared { } /** - * Params passed to {@link Schema} static methods to create specific - * {@link Schema} classes. + * Params passed to {@link Schema} static methods to create specific + * {@link Schema} classes. * @public */ export interface SchemaParams extends SchemaShared {} /** - * Final format for {@link Schema} params passed to backend requests. + * Final format for {@link Schema} params passed to backend requests. * @public */ export interface SchemaRequest extends SchemaShared { @@ -83,7 +83,7 @@ export interface SchemaRequest extends SchemaShared { } /** - * Interface for {@link Schema} class. + * Interface for {@link Schema} class. * @public */ export interface SchemaInterface extends SchemaShared { @@ -95,7 +95,7 @@ export interface SchemaInterface extends SchemaShared { } /** - * Interface for {@link ObjectSchema} class. + * Interface for {@link ObjectSchema} class. * @public */ export interface ObjectSchemaInterface extends SchemaInterface { From 9c645aa3589ab234b6b4055bb31a96511cdd5812 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Tue, 15 Oct 2024 16:40:35 -0400 Subject: [PATCH 17/21] Close emulator file after download is complete (#8572) * close file * Add test:ci to end of test command in CI * revert workflow file changes * format --- scripts/emulator-testing/emulators/emulator.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 85f190bcba9..f149debca14 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -75,7 +75,17 @@ export abstract class Emulator { const reader = resp.body.getReader(); reader.read().then(function readChunk({ done, value }): any { if (done) { - downloadComplete(); + console.log('Emulator download is done.'); + writer.close(err => { + if (err) { + downloadFailed( + `Failed to close the downloaded emulator file: ${err}` + ); + } + + console.log('Closed downloaded emulator file.'); + downloadComplete(); + }); } else { writer.write(value); return reader.read().then(readChunk); @@ -92,7 +102,6 @@ export abstract class Emulator { downloadPromise.then( () => { - console.log('Download complete'); // Change emulator binary file permission to 'rwxr-xr-x'. // The execute permission is required for it to be able to start // with 'java -jar'. From 045420f7ea54621d1d02b3a437608322b8522854 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Tue, 15 Oct 2024 13:44:42 -0700 Subject: [PATCH 18/21] rename vertexai package reference in a changeset (#8573) --- .changeset/little-cows-tie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/little-cows-tie.md b/.changeset/little-cows-tie.md index 988329e2f0e..4811531323f 100644 --- a/.changeset/little-cows-tie.md +++ b/.changeset/little-cows-tie.md @@ -25,7 +25,7 @@ '@firebase/database': patch 'firebase': patch '@firebase/template': patch -'@firebase/vertexai-preview': patch +'@firebase/vertexai': patch '@firebase/storage': patch '@firebase/logger': patch '@firebase/auth': patch From dc211c627680affe6a39fdc4cd692e8a124233c3 Mon Sep 17 00:00:00 2001 From: Christina Holland Date: Wed, 16 Oct 2024 11:53:46 -0700 Subject: [PATCH 19/21] Missed one doc change from a PR (#8575) --- docs-devsite/vertexai.safetysetting.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs-devsite/vertexai.safetysetting.md b/docs-devsite/vertexai.safetysetting.md index 6aad50963cd..17fa1cff839 100644 --- a/docs-devsite/vertexai.safetysetting.md +++ b/docs-devsite/vertexai.safetysetting.md @@ -39,7 +39,7 @@ category: HarmCategory; Signature: ```typescript -method: HarmBlockMethod; +method?: HarmBlockMethod; ``` ## SafetySetting.threshold From 97f80a8fbed659c5d7022d13f326fb3e21121d9a Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 16 Oct 2024 17:20:16 -0400 Subject: [PATCH 20/21] Overwrite undefined candidate index (#8577) * Overwrite undefined candidate index * Fix index overwrite condition to only be true when index is not a property --- .../vertexai/src/methods/generate-content.ts | 4 ++-- .../vertexai/src/requests/response-helpers.ts | 20 +++++++++++++++++++ .../vertexai/src/requests/stream-reader.ts | 11 +++++++--- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/packages/vertexai/src/methods/generate-content.ts b/packages/vertexai/src/methods/generate-content.ts index 2dee91f12e8..0944b38016a 100644 --- a/packages/vertexai/src/methods/generate-content.ts +++ b/packages/vertexai/src/methods/generate-content.ts @@ -23,7 +23,7 @@ import { RequestOptions } from '../types'; import { Task, makeRequest } from '../requests/request'; -import { addHelpers } from '../requests/response-helpers'; +import { createEnhancedContentResponse } from '../requests/response-helpers'; import { processStream } from '../requests/stream-reader'; import { ApiSettings } from '../types/internal'; @@ -59,7 +59,7 @@ export async function generateContent( requestOptions ); const responseJson: GenerateContentResponse = await response.json(); - const enhancedResponse = addHelpers(responseJson); + const enhancedResponse = createEnhancedContentResponse(responseJson); return { response: enhancedResponse }; diff --git a/packages/vertexai/src/requests/response-helpers.ts b/packages/vertexai/src/requests/response-helpers.ts index efff09591a6..3521dc1bc5f 100644 --- a/packages/vertexai/src/requests/response-helpers.ts +++ b/packages/vertexai/src/requests/response-helpers.ts @@ -25,6 +25,26 @@ import { } from '../types'; import { VertexAIError } from '../errors'; +/** + * Creates an EnhancedGenerateContentResponse object that has helper functions and + * other modifications that improve usability. + */ +export function createEnhancedContentResponse( + response: GenerateContentResponse +): EnhancedGenerateContentResponse { + /** + * The Vertex AI backend omits default values. + * This causes the `index` property to be omitted from the first candidate in the + * response, since it has index 0, and 0 is a default value. + */ + if (response.candidates && !response.candidates[0].hasOwnProperty('index')) { + response.candidates[0].index = 0; + } + + const responseWithHelpers = addHelpers(response); + return responseWithHelpers; +} + /** * Adds convenience helper methods to a response object, including stream * chunks (as long as each chunk is a complete GenerateContentResponse JSON). diff --git a/packages/vertexai/src/requests/stream-reader.ts b/packages/vertexai/src/requests/stream-reader.ts index c4163d26b60..da8eca71880 100644 --- a/packages/vertexai/src/requests/stream-reader.ts +++ b/packages/vertexai/src/requests/stream-reader.ts @@ -24,7 +24,7 @@ import { VertexAIErrorCode } from '../types'; import { VertexAIError } from '../errors'; -import { addHelpers } from './response-helpers'; +import { createEnhancedContentResponse } from './response-helpers'; const responseLineRE = /^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/; @@ -57,7 +57,10 @@ async function getResponsePromise( while (true) { const { done, value } = await reader.read(); if (done) { - return addHelpers(aggregateResponses(allResponses)); + const enhancedResponse = createEnhancedContentResponse( + aggregateResponses(allResponses) + ); + return enhancedResponse; } allResponses.push(value); } @@ -72,7 +75,9 @@ async function* generateResponseSequence( if (done) { break; } - yield addHelpers(value); + + const enhancedResponse = createEnhancedContentResponse(value); + yield enhancedResponse; } } From b5392d93f671d4ed7339aec478719424469c71e7 Mon Sep 17 00:00:00 2001 From: Daniel La Rocque Date: Wed, 16 Oct 2024 17:51:26 -0400 Subject: [PATCH 21/21] Upgrade Vertex Mock Responses to V5 (#8579) * Upgrade to mock responses v4 * Upgrade from v4 to v5 mock responses --- packages/vertexai/src/requests/response-helpers.ts | 1 + packages/vertexai/src/requests/stream-reader.ts | 4 +++- scripts/update_vertexai_responses.sh | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/vertexai/src/requests/response-helpers.ts b/packages/vertexai/src/requests/response-helpers.ts index 3521dc1bc5f..0435f1711ce 100644 --- a/packages/vertexai/src/requests/response-helpers.ts +++ b/packages/vertexai/src/requests/response-helpers.ts @@ -36,6 +36,7 @@ export function createEnhancedContentResponse( * The Vertex AI backend omits default values. * This causes the `index` property to be omitted from the first candidate in the * response, since it has index 0, and 0 is a default value. + * See: https://github.com/firebase/firebase-js-sdk/issues/8566 */ if (response.candidates && !response.candidates[0].hasOwnProperty('index')) { response.candidates[0].index = 0; diff --git a/packages/vertexai/src/requests/stream-reader.ts b/packages/vertexai/src/requests/stream-reader.ts index da8eca71880..8162407d90b 100644 --- a/packages/vertexai/src/requests/stream-reader.ts +++ b/packages/vertexai/src/requests/stream-reader.ts @@ -151,7 +151,9 @@ export function aggregateResponses( for (const response of responses) { if (response.candidates) { for (const candidate of response.candidates) { - const i = candidate.index; + // Index will be undefined if it's the first index (0), so we should use 0 if it's undefined. + // See: https://github.com/firebase/firebase-js-sdk/issues/8566 + const i = candidate.index || 0; if (!aggregatedResponse.candidates) { aggregatedResponse.candidates = []; } diff --git a/scripts/update_vertexai_responses.sh b/scripts/update_vertexai_responses.sh index 27c32a09ead..101eac90d9f 100755 --- a/scripts/update_vertexai_responses.sh +++ b/scripts/update_vertexai_responses.sh @@ -17,7 +17,7 @@ # This script replaces mock response files for Vertex AI unit tests with a fresh # clone of the shared repository of Vertex AI test data. -RESPONSES_VERSION='v3.*' # The major version of mock responses to use +RESPONSES_VERSION='v5.*' # The major version of mock responses to use REPO_NAME="vertexai-sdk-test-data" REPO_LINK="https://github.com/FirebaseExtended/$REPO_NAME.git"