Skip to content

Commit d27cd8e

Browse files
authored
Enable first npm publish (#8120)
1 parent e946e73 commit d27cd8e

File tree

12 files changed

+52
-44
lines changed

12 files changed

+52
-44
lines changed

.github/workflows/canary-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ jobs:
7373
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
7474
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
7575
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
76+
NPM_TOKEN_VERTEX: ${{secrets.NPM_TOKEN_VERTEX}}
7677
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
7778
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
7879
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}

.github/workflows/prerelease-manual-deploy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ jobs:
7676
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
7777
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
7878
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
79+
NPM_TOKEN_VERTEX: ${{secrets.NPM_TOKEN_VERTEX}}
7980
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
8081
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
8182
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}

.github/workflows/release-prod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ jobs:
8686
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
8787
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
8888
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
89+
NPM_TOKEN_VERTEX: ${{secrets.NPM_TOKEN_VERTEX}}
8990
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
9091
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
9192
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}

.github/workflows/release-staging.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ jobs:
112112
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
113113
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
114114
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
115+
NPM_TOKEN_VERTEX: ${{secrets.NPM_TOKEN_VERTEX}}
115116
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
116117
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
117118
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}

packages/vertexai/src/api.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
import { ModelParams } from './types';
1818
import { getGenerativeModel } from './api';
1919
import { expect } from 'chai';
20-
import { Vertex } from './public-types';
20+
import { VertexAI } from './public-types';
2121
import { GenerativeModel } from './models/generative-model';
2222
import { VertexError } from './errors';
2323

24-
const fakeVertex: Vertex = {
24+
const fakeVertexAI: VertexAI = {
2525
app: {
2626
name: 'DEFAULT',
2727
automaticDataCollectionEnabled: true,
@@ -35,30 +35,30 @@ const fakeVertex: Vertex = {
3535

3636
describe('Top level API', () => {
3737
it('getGenerativeModel throws if no model is provided', () => {
38-
expect(() => getGenerativeModel(fakeVertex, {} as ModelParams)).to.throw(
38+
expect(() => getGenerativeModel(fakeVertexAI, {} as ModelParams)).to.throw(
3939
VertexError.NO_MODEL
4040
);
4141
});
4242
it('getGenerativeModel throws if no apiKey is provided', () => {
4343
const fakeVertexNoApiKey = {
44-
...fakeVertex,
44+
...fakeVertexAI,
4545
app: { options: { projectId: 'my-project' } }
46-
} as Vertex;
46+
} as VertexAI;
4747
expect(() =>
4848
getGenerativeModel(fakeVertexNoApiKey, { model: 'my-model' })
4949
).to.throw(VertexError.NO_API_KEY);
5050
});
5151
it('getGenerativeModel throws if no projectId is provided', () => {
5252
const fakeVertexNoProject = {
53-
...fakeVertex,
53+
...fakeVertexAI,
5454
app: { options: { apiKey: 'my-key' } }
55-
} as Vertex;
55+
} as VertexAI;
5656
expect(() =>
5757
getGenerativeModel(fakeVertexNoProject, { model: 'my-model' })
5858
).to.throw(VertexError.NO_PROJECT_ID);
5959
});
6060
it('getGenerativeModel gets a GenerativeModel', () => {
61-
const genModel = getGenerativeModel(fakeVertex, { model: 'my-model' });
61+
const genModel = getGenerativeModel(fakeVertexAI, { model: 'my-model' });
6262
expect(genModel).to.be.an.instanceOf(GenerativeModel);
6363
expect(genModel.model).to.equal('publishers/google/models/my-model');
6464
});

packages/vertexai/src/api.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import { FirebaseApp, getApp, _getProvider } from '@firebase/app';
1919
import { Provider } from '@firebase/component';
2020
import { getModularInstance } from '@firebase/util';
2121
import { DEFAULT_LOCATION, VERTEX_TYPE } from './constants';
22-
import { VertexService } from './service';
23-
import { Vertex, VertexOptions } from './public-types';
22+
import { VertexAIService } from './service';
23+
import { VertexAI, VertexAIOptions } from './public-types';
2424
import { ERROR_FACTORY, VertexError } from './errors';
2525
import { ModelParams, RequestOptions } from './types';
2626
import { GenerativeModel } from './models/generative-model';
@@ -31,21 +31,21 @@ export { GenerativeModel };
3131

3232
declare module '@firebase/component' {
3333
interface NameServiceMapping {
34-
[VERTEX_TYPE]: VertexService;
34+
[VERTEX_TYPE]: VertexAIService;
3535
}
3636
}
3737

3838
/**
39-
* Returns an {@link Vertex} instance for the given app.
39+
* Returns an {@link VertexAI} instance for the given app.
4040
*
4141
* @public
4242
*
4343
* @param app - The {@link @firebase/app#FirebaseApp} to use.
4444
*/
45-
export function getVertex(
45+
export function getVertexAI(
4646
app: FirebaseApp = getApp(),
47-
options?: VertexOptions
48-
): Vertex {
47+
options?: VertexAIOptions
48+
): VertexAI {
4949
app = getModularInstance(app);
5050
// Dependencies
5151
const vertexProvider: Provider<'vertex'> = _getProvider(app, VERTEX_TYPE);
@@ -56,7 +56,7 @@ export function getVertex(
5656
}
5757

5858
export function getGenerativeModel(
59-
vertex: Vertex,
59+
vertex: VertexAI,
6060
modelParams: ModelParams,
6161
requestOptions?: RequestOptions
6262
): GenerativeModel {

packages/vertexai/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323

2424
import { registerVersion, _registerComponent } from '@firebase/app';
25-
import { VertexService } from './service';
25+
import { VertexAIService } from './service';
2626
import { VERTEX_TYPE } from './constants';
2727
import { Component, ComponentType } from '@firebase/component';
2828
import { name, version } from '../package.json';
@@ -41,7 +41,7 @@ function registerVertex(): void {
4141
// getImmediate for FirebaseApp will always succeed
4242
const app = container.getProvider('app').getImmediate();
4343
const appCheckProvider = container.getProvider('app-check-internal');
44-
return new VertexService(app, appCheckProvider, { location });
44+
return new VertexAIService(app, appCheckProvider, { location });
4545
},
4646
ComponentType.PUBLIC
4747
).setMultipleInstances(true)

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
*/
1717
import { expect } from 'chai';
1818
import { GenerativeModel } from './generative-model';
19-
import { Vertex } from '../public-types';
19+
import { VertexAI } from '../public-types';
2020

21-
const fakeVertex: Vertex = {
21+
const fakeVertexAI: VertexAI = {
2222
app: {
2323
name: 'DEFAULT',
2424
automaticDataCollectionEnabled: true,
@@ -32,23 +32,23 @@ const fakeVertex: Vertex = {
3232

3333
describe('GenerativeModel', () => {
3434
it('handles plain model name', () => {
35-
const genModel = new GenerativeModel(fakeVertex, { model: 'my-model' });
35+
const genModel = new GenerativeModel(fakeVertexAI, { model: 'my-model' });
3636
expect(genModel.model).to.equal('publishers/google/models/my-model');
3737
});
3838
it('handles models/ prefixed model name', () => {
39-
const genModel = new GenerativeModel(fakeVertex, {
39+
const genModel = new GenerativeModel(fakeVertexAI, {
4040
model: 'models/my-model'
4141
});
4242
expect(genModel.model).to.equal('publishers/google/models/my-model');
4343
});
4444
it('handles full model name', () => {
45-
const genModel = new GenerativeModel(fakeVertex, {
45+
const genModel = new GenerativeModel(fakeVertexAI, {
4646
model: 'publishers/google/models/my-model'
4747
});
4848
expect(genModel.model).to.equal('publishers/google/models/my-model');
4949
});
5050
it('handles prefixed tuned model name', () => {
51-
const genModel = new GenerativeModel(fakeVertex, {
51+
const genModel = new GenerativeModel(fakeVertexAI, {
5252
model: 'tunedModels/my-model'
5353
});
5454
expect(genModel.model).to.equal('tunedModels/my-model');

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ import {
3636
import { ChatSession } from '../methods/chat-session';
3737
import { countTokens } from '../methods/count-tokens';
3838
import { formatGenerateContentInput } from '../requests/request-helpers';
39-
import { Vertex } from '../public-types';
39+
import { VertexAI } from '../public-types';
4040
import { ERROR_FACTORY, VertexError } from '../errors';
4141
import { ApiSettings } from '../types/internal';
42-
import { VertexService } from '../service';
42+
import { VertexAIService } from '../service';
4343

4444
/**
4545
* Class for generative model APIs.
@@ -54,23 +54,23 @@ export class GenerativeModel {
5454
tools?: Tool[];
5555

5656
constructor(
57-
vertex: Vertex,
57+
vertexAI: VertexAI,
5858
modelParams: ModelParams,
5959
requestOptions?: RequestOptions
6060
) {
61-
if (!vertex.app?.options?.apiKey) {
61+
if (!vertexAI.app?.options?.apiKey) {
6262
throw ERROR_FACTORY.create(VertexError.NO_API_KEY);
63-
} else if (!vertex.app?.options?.projectId) {
63+
} else if (!vertexAI.app?.options?.projectId) {
6464
throw ERROR_FACTORY.create(VertexError.NO_PROJECT_ID);
6565
} else {
6666
this._apiSettings = {
67-
apiKey: vertex.app.options.apiKey,
68-
project: vertex.app.options.projectId,
69-
location: vertex.location
67+
apiKey: vertexAI.app.options.apiKey,
68+
project: vertexAI.app.options.projectId,
69+
location: vertexAI.location
7070
};
71-
if ((vertex as VertexService).appCheck) {
71+
if ((vertexAI as VertexAIService).appCheck) {
7272
this._apiSettings.getAppCheckToken = () =>
73-
(vertex as VertexService).appCheck!.getToken();
73+
(vertexAI as VertexAIService).appCheck!.getToken();
7474
}
7575
}
7676
if (modelParams.model.includes('/')) {

packages/vertexai/src/public-types.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ import { FirebaseApp } from '@firebase/app';
2020
export * from './types';
2121

2222
/**
23-
* An instance of Firebase Vertex.
23+
* An instance of Firebase Vertex AI.
2424
* @public
2525
*/
26-
export interface Vertex {
26+
export interface VertexAI {
2727
/**
28-
* The {@link @firebase/app#FirebaseApp} this {@link Vertex} instance is associated with.
28+
* The {@link @firebase/app#FirebaseApp} this {@link VertexAI} instance is associated with.
2929
*/
3030
app: FirebaseApp;
3131
location: string;
3232
}
3333

34-
export interface VertexOptions {
34+
export interface VertexAIOptions {
3535
location?: string;
3636
}

0 commit comments

Comments
 (0)