Skip to content

Commit

Permalink
Tests passing again! Onto Next.js
Browse files Browse the repository at this point in the history
  • Loading branch information
inlined committed Feb 6, 2025
1 parent b68d638 commit dd15fa0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
4 changes: 4 additions & 0 deletions js/plugins/firebase/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const config: Config = {

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
transformIgnorePatterns: ['/node_modules/'],

moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
};

export default config;
10 changes: 5 additions & 5 deletions js/plugins/firebase/src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import { ContextProvider, RequestData, UserFacingError } from '@genkit-ai/core';
import { DecodedAppCheckToken, getAppCheck } from 'firebase-admin/app-check';
import { DecodedIdToken, getAuth } from 'firebase-admin/auth';
import { initializeAppIfNecessary } from './helpers';
import { initializeAppIfNecessary } from './helpers.js';

/**
* Debug features that can be enabled to simplify testing.
Expand Down Expand Up @@ -131,14 +131,14 @@ export interface DeclarativePolicy {
}

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

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

/**
* Calling firebaseAuth() with a policy context parses context but delegates enforcement.
* To control the message sent to a user, throw UserFacingError from genkit/requestMiddleware.
* Calling firebaseContext() with a policy callback parses context but delegates enforcement.
* To control the message sent to a user, throw UserFacingError.
* For security reasons, other error types will be returned as a 500 "internal error".
*/
export function firebaseContext<I = any>(
Expand Down
6 changes: 6 additions & 0 deletions js/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions js/testapps/esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"@genkit-ai/api-key": "workspace:*",
"@genkit-ai/checks": "workspace:*",
"@genkit-ai/dev-local-vectorstore": "workspace:*",
"@genkit-ai/evaluator": "workspace:*",
"@genkit-ai/express": "workspace:*",
"@genkit-ai/firebase": "workspace:*",
"@genkit-ai/google-cloud": "workspace:*",
"@genkit-ai/googleai": "workspace:*",
Expand Down
7 changes: 7 additions & 0 deletions js/testapps/esm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
* limitations under the License.
*/

import { apiKey } from '@genkit-ai/api-key';
import { checks } from '@genkit-ai/checks';
import { devLocalVectorstore } from '@genkit-ai/dev-local-vectorstore';
import { genkitEval } from '@genkit-ai/evaluator';
import { expressHandler } from '@genkit-ai/express';
import { enableFirebaseTelemetry } from '@genkit-ai/firebase';
import { firebaseContext } from '@genkit-ai/firebase/context';
import { enableGoogleCloudTelemetry } from '@genkit-ai/google-cloud';
import { googleAI } from '@genkit-ai/googleai';
import { vertexAI } from '@genkit-ai/vertexai';
Expand All @@ -29,6 +32,8 @@ import { chroma } from 'genkitx-chromadb';
import { ollama } from 'genkitx-ollama';
import { pinecone } from 'genkitx-pinecone';

apiKey();
firebaseContext();
enableFirebaseTelemetry;
enableGoogleCloudTelemetry;
checks;
Expand All @@ -44,3 +49,5 @@ devLocalVectorstore;
genkitEval;

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

0 comments on commit dd15fa0

Please sign in to comment.