Skip to content

Commit 534d895

Browse files
authored
Fix and update location field, remove esm5 bundle (#291)
1 parent 0338896 commit 534d895

File tree

11 files changed

+41
-32
lines changed

11 files changed

+41
-32
lines changed

packages/vertexai/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@
1010
"main": "dist/index.cjs.js",
1111
"browser": "dist/esm/index.esm2017.js",
1212
"module": "dist/esm/index.esm2017.js",
13-
"esm5": "dist/index.esm5.js",
1413
"exports": {
1514
".": {
1615
"types": "./dist/src/index.d.ts",
1716
"node": {
1817
"require": "./dist/index.cjs.js",
1918
"import": "./dist/esm/index.esm2017.js"
2019
},
21-
"esm5": "./dist/index.esm5.js",
2220
"browser": {
2321
"require": "./dist/index.cjs.js",
2422
"import": "./dist/esm/index.esm2017.js"

packages/vertexai/rollup.config.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ const es2017BuildPlugins = [
4747
];
4848

4949
const browserBuilds = [
50-
{
51-
input: 'src/index.ts',
52-
output: [{ file: pkg.esm5, format: 'es', sourcemap: true }],
53-
plugins: [
54-
...es5BuildPlugins,
55-
replace({
56-
...generateBuildTargetReplaceConfig('esm', 5),
57-
__PACKAGE_VERSION__: pkg.version
58-
})
59-
],
60-
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
61-
},
6250
{
6351
input: 'src/index.ts',
6452
output: {

packages/vertexai/src/api.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const fakeVertex: Vertex = {
3030
projectId: 'my-project'
3131
}
3232
},
33-
region: 'us-central1'
33+
location: 'us-central1'
3434
};
3535

3636
describe('Top level API', () => {

packages/vertexai/src/api.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Provider } from '@firebase/component';
2020
import { getModularInstance } from '@firebase/util';
2121
import { VERTEX_TYPE } from './constants';
2222
import { VertexService } from './factory';
23-
import { Vertex } from './public-types';
23+
import { Vertex, VertexOptions } from './public-types';
2424
import { ERROR_FACTORY, VertexError } from './errors';
2525
import { ModelParams, RequestOptions } from './types';
2626
import { GenerativeModel } from './models/generative-model';
@@ -42,16 +42,17 @@ declare module '@firebase/component' {
4242
*
4343
* @param app - The {@link @firebase/app#FirebaseApp} to use.
4444
*/
45-
export function getVertex(app: FirebaseApp = getApp()): Vertex {
45+
export function getVertex(
46+
app: FirebaseApp = getApp(),
47+
options?: VertexOptions
48+
): Vertex {
4649
app = getModularInstance(app);
4750
// Dependencies
4851
const vertexProvider: Provider<'vertex'> = _getProvider(app, VERTEX_TYPE);
4952

50-
if (vertexProvider.isInitialized()) {
51-
return vertexProvider.getImmediate();
52-
}
53-
54-
return vertexProvider.initialize();
53+
return vertexProvider.getImmediate({
54+
identifier: options?.location || 'DEFAULT'
55+
});
5556
}
5657

5758
export function getGenerativeModel(

packages/vertexai/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717

1818
export const VERTEX_TYPE = 'vertex';
1919

20-
export const DEFAULT_REGION = 'us-central1';
20+
export const DEFAULT_LOCATION = 'us-central1';

packages/vertexai/src/factory.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
FirebaseAppCheckInternal
2323
} from '@firebase/app-check-interop-types';
2424
import { Provider } from '@firebase/component';
25-
import { DEFAULT_REGION } from './constants';
25+
import { DEFAULT_LOCATION } from './constants';
2626

2727
export function factory(
2828
app: FirebaseApp,
@@ -34,7 +34,7 @@ export function factory(
3434

3535
export class VertexService implements Vertex, _FirebaseService {
3636
appCheck: FirebaseAppCheckInternal | null;
37-
region: string;
37+
location: string;
3838

3939
constructor(
4040
public app: FirebaseApp,
@@ -43,7 +43,7 @@ export class VertexService implements Vertex, _FirebaseService {
4343
) {
4444
const appCheck = appCheckProvider?.getImmediate({ optional: true });
4545
this.appCheck = appCheck || null;
46-
this.region = this.options?.region || DEFAULT_REGION;
46+
this.location = this.options?.location || DEFAULT_LOCATION;
4747
}
4848

4949
_delete(): Promise<void> {

packages/vertexai/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ function registerVertex(): void {
3737
_registerComponent(
3838
new Component(
3939
VERTEX_TYPE,
40-
(container, { instanceIdentifier: region }) => {
40+
(container, { instanceIdentifier: location }) => {
4141
// getImmediate for FirebaseApp will always succeed
4242
const app = container.getProvider('app').getImmediate();
4343
const appCheckProvider = container.getProvider('app-check-internal');
44-
return factory(app, appCheckProvider, { region });
44+
return factory(app, appCheckProvider, { location });
4545
},
4646
ComponentType.PUBLIC
4747
).setMultipleInstances(true)

packages/vertexai/src/models/generative-model.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const fakeVertex: Vertex = {
2727
projectId: 'my-project'
2828
}
2929
},
30-
region: 'us-central1'
30+
location: 'us-central1'
3131
};
3232

3333
describe('GenerativeModel', () => {

packages/vertexai/src/models/generative-model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export class GenerativeModel {
6565
this._apiSettings = {
6666
apiKey: vertex.app.options.apiKey,
6767
project: vertex.app.options.projectId,
68-
location: vertex.region
68+
location: vertex.location
6969
};
7070
}
7171
if (modelParams.model.includes('/')) {

packages/vertexai/src/public-types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ export interface Vertex {
2828
* The {@link @firebase/app#FirebaseApp} this {@link Vertex} instance is associated with.
2929
*/
3030
app: FirebaseApp;
31-
region: string;
31+
location: string;
3232
}
3333

3434
export interface VertexOptions {
35-
region?: string;
35+
location?: string;
3636
}

packages/vertexai/test-utils/mocks-lookup.ts

Lines changed: 22 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)