Skip to content

Commit dd15fa0

Browse files
committed
Tests passing again! Onto Next.js
1 parent b68d638 commit dd15fa0

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

js/plugins/firebase/jest.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const config: Config = {
4141

4242
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
4343
transformIgnorePatterns: ['/node_modules/'],
44+
45+
moduleNameMapper: {
46+
'^(\\.{1,2}/.*)\\.js$': '$1',
47+
},
4448
};
4549

4650
export default config;

js/plugins/firebase/src/context.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import { ContextProvider, RequestData, UserFacingError } from '@genkit-ai/core';
1818
import { DecodedAppCheckToken, getAppCheck } from 'firebase-admin/app-check';
1919
import { DecodedIdToken, getAuth } from 'firebase-admin/auth';
20-
import { initializeAppIfNecessary } from './helpers';
20+
import { initializeAppIfNecessary } from './helpers.js';
2121

2222
/**
2323
* Debug features that can be enabled to simplify testing.
@@ -131,14 +131,14 @@ export interface DeclarativePolicy {
131131
}
132132

133133
/**
134-
* Calling firebaseAuth() without any parameters merely parses firebase context data.
134+
* Calling firebaseContext() without any parameters merely parses firebase context data.
135135
* It does not do any validation on the data found. To do automatic validation,
136136
* pass either an options object or function for freeform validation.
137137
*/
138138
export function firebaseContext<I = any>(): FirebaseContextProvider<I>;
139139

140140
/**
141-
* Calling firebaseAuth() with a declarative policy both parses and enforces context.
141+
* Calling firebaseContext() with a declarative policy both parses and enforces context.
142142
* Honors the same environment variables that Cloud Functions for Firebase does to
143143
* mock token validation in preproduction environmets.
144144
*/
@@ -147,8 +147,8 @@ export function firebaseContext<I = any>(
147147
): FirebaseContextProvider<I>;
148148

149149
/**
150-
* Calling firebaseAuth() with a policy context parses context but delegates enforcement.
151-
* To control the message sent to a user, throw UserFacingError from genkit/requestMiddleware.
150+
* Calling firebaseContext() with a policy callback parses context but delegates enforcement.
151+
* To control the message sent to a user, throw UserFacingError.
152152
* For security reasons, other error types will be returned as a 500 "internal error".
153153
*/
154154
export function firebaseContext<I = any>(

js/pnpm-lock.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/testapps/esm/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
"author": "",
1919
"license": "ISC",
2020
"dependencies": {
21+
"@genkit-ai/api-key": "workspace:*",
2122
"@genkit-ai/checks": "workspace:*",
2223
"@genkit-ai/dev-local-vectorstore": "workspace:*",
2324
"@genkit-ai/evaluator": "workspace:*",
25+
"@genkit-ai/express": "workspace:*",
2426
"@genkit-ai/firebase": "workspace:*",
2527
"@genkit-ai/google-cloud": "workspace:*",
2628
"@genkit-ai/googleai": "workspace:*",

js/testapps/esm/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17+
import { apiKey } from '@genkit-ai/api-key';
1718
import { checks } from '@genkit-ai/checks';
1819
import { devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore';
1920
import { genkitEval } from '@genkit-ai/evaluator';
21+
import { expressHandler } from '@genkit-ai/express';
2022
import { enableFirebaseTelemetry } from '@genkit-ai/firebase';
23+
import { firebaseContext } from '@genkit-ai/firebase/context';
2124
import { enableGoogleCloudTelemetry } from '@genkit-ai/google-cloud';
2225
import { googleAI } from '@genkit-ai/googleai';
2326
import { vertexAI } from '@genkit-ai/vertexai';
@@ -29,6 +32,8 @@ import { chroma } from 'genkitx-chromadb';
2932
import { ollama } from 'genkitx-ollama';
3033
import { pinecone } from 'genkitx-pinecone';
3134

35+
apiKey();
36+
firebaseContext();
3237
enableFirebaseTelemetry;
3338
enableGoogleCloudTelemetry;
3439
checks;
@@ -44,3 +49,5 @@ devLocalVectorstore;
4449
genkitEval;
4550

4651
export const ai = genkit({});
52+
const hello = ai.defineFlow('hello', () => 'hello');
53+
expressHandler(hello, { context: apiKey() });

0 commit comments

Comments
 (0)