Skip to content

fix: add dataconnect-generated stubs and fix TypeScript errors in emb…#42

Closed
groupthinking wants to merge 1 commit intomainfrom
claude/slack-check-status-update-R47Ph
Closed

fix: add dataconnect-generated stubs and fix TypeScript errors in emb…#42
groupthinking wants to merge 1 commit intomainfrom
claude/slack-check-status-update-R47Ph

Conversation

@groupthinking
Copy link
Owner

…eddings

  • Create stub types for Firebase Data Connect SDK
  • Add explicit type assertions for JSON responses
  • Add explicit VideoEmbedding type to map callbacks
  • Move dataconnect-generated inside src to satisfy rootDir constraint

https://claude.ai/code/session_015Pd3a6hinTenCNrPRGiZqE

…eddings

- Create stub types for Firebase Data Connect SDK
- Add explicit type assertions for JSON responses
- Add explicit VideoEmbedding type to map callbacks
- Move dataconnect-generated inside src to satisfy rootDir constraint

https://claude.ai/code/session_015Pd3a6hinTenCNrPRGiZqE
Copilot AI review requested due to automatic review settings February 28, 2026 17:36
@vercel
Copy link
Contributor

vercel bot commented Feb 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v0-uvai Error Error Open in v0 Feb 28, 2026 5:36pm

@railway-app railway-app bot temporarily deployed to EventRelay / EventRelay-pr-42 February 28, 2026 17:37 Destroyed
@railway-app
Copy link

railway-app bot commented Feb 28, 2026

🚅 Deployed to the EventRelay-pr-42 environment in EventRelay

Service Status Web Updated (UTC)
guides ✅ Success (View Logs) Web Feb 28, 2026 at 5:39 pm
eslint-config ✅ Success (View Logs) Web Feb 28, 2026 at 5:39 pm
web ✅ Success (View Logs) Web Feb 28, 2026 at 5:39 pm
EventRelay ✅ Success (View Logs) Web Feb 28, 2026 at 5:39 pm
supabase ✅ Success (View Logs) Feb 28, 2026 at 5:39 pm

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the robustness and type safety of the embeddings package. It introduces mock implementations and type definitions for the Firebase Data Connect SDK, allowing the application to compile and run in environments lacking the auto-generated SDK. Additionally, it refines JSON response handling with explicit type assertions and clarifies data transformations with specific type annotations, leading to a more reliable and maintainable codebase.

Highlights

  • Firebase Data Connect SDK Stubs: Introduced stub types and implementations for the Firebase Data Connect SDK to ensure functionality in environments where the SDK is not auto-generated, such as Vercel builds.
  • Improved Type Safety: Enhanced type safety by adding explicit TypeScript type assertions for JSON responses from external API calls across several functions.
  • Module Path Correction: Corrected import paths for the newly generated Data Connect stubs, moving them into the 'src' directory to align with 'rootDir' constraints.
  • Explicit Type Annotations: Applied explicit 'VideoEmbedding' type annotations in mapping functions to improve clarity and type checking when processing embedding records.
Changelog
  • packages/embeddings/src/dataconnect-generated/index.d.ts
    • Added TypeScript declaration file for Firebase Data Connect SDK stubs, defining interfaces like 'VideoEmbedding' and response types.
  • packages/embeddings/src/dataconnect-generated/index.d.ts.map
    • Added source map for the Data Connect SDK stub declaration file.
  • packages/embeddings/src/dataconnect-generated/index.js
    • Added JavaScript implementation for Firebase Data Connect SDK stubs, which throw errors if Data Connect is not configured.
  • packages/embeddings/src/dataconnect-generated/index.js.map
    • Added source map for the Data Connect SDK stub JavaScript file.
  • packages/embeddings/src/dataconnect-generated/index.ts
    • Added TypeScript source file for Firebase Data Connect SDK stubs, including type definitions and stub function implementations.
  • packages/embeddings/src/embedding.ts
    • Updated the import path for 'dataconnect-generated' and imported the 'VideoEmbedding' type.
    • Added an explicit type assertion for the JSON response in 'generateEmbedding'.
    • Added an explicit type assertion for the JSON response and simplified the map callback in 'generateEmbeddings'.
    • Added an explicit type assertion for the JSON response in 'getAccessToken'.
    • Added an explicit 'VideoEmbedding' type assertion to the map callback in 'getEmbeddingsForJob'.
    • Added an explicit 'VideoEmbedding' type assertion to the map callback in 'listRecentEmbeddings'.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces stub files for Firebase Data Connect to facilitate builds in environments where the SDK is unavailable, and it resolves several TypeScript errors by adding explicit type assertions. These changes enhance the type safety and robustness of the embeddings package, aligning with the project's strict type hinting standards. My review includes suggestions to further improve maintainability by using named interfaces for API responses to reduce code duplication and by exporting a shared UUID type for better reusability.

}

// UUID type for job IDs
type UUID = `${string}-${string}-${string}-${string}-${string}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The UUID type is used in the signatures of exported functions like getJobEmbeddings, but it's not exported itself. Exporting it would allow other modules, like embedding.ts, to use it directly. This would avoid the need to redefine or cast to the template literal string `${string}-${string}-${string}-${string}-${string}`, reducing duplication and improving maintainability.

Suggested change
type UUID = `${string}-${string}-${string}-${string}-${string}`;
export type UUID = `${string}-${string}-${string}-${string}-${string}`;

Comment on lines +140 to +142
const data = (await response.json()) as {
predictions: Array<{ embeddings: { values: number[] } }>;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This anonymous type for the API response is also used in the generateEmbedding function. To improve maintainability and avoid code duplication, it would be better to define a named interface (e.g., EmbeddingResponse) in a shared location (like the types section at the top of this file) and reuse it here and in generateEmbedding.

{ headers: { "Metadata-Flavor": "Google" } }
);
const data = await response.json();
const data = (await response.json()) as { access_token: string };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and maintainability, consider defining a named interface for this API response shape (e.g., AccessTokenResponse) instead of using an inline anonymous type. This makes the code more self-documenting and easier to manage.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds in-repo Firebase Data Connect SDK stubs and tightens TypeScript typing in the embeddings package to fix build/type errors, while keeping generated code under src/ to satisfy the package’s rootDir constraint.

Changes:

  • Adds src/dataconnect-generated stub module (types + functions that throw) to unblock builds when Data Connect SDK isn’t present.
  • Adds explicit JSON response type assertions for Vertex AI embedding responses and metadata-server access token responses.
  • Imports and applies an explicit VideoEmbedding type for Data Connect query result mapping.

Reviewed changes

Copilot reviewed 3 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/embeddings/src/embedding.ts Updates Data Connect import path, adds JSON response assertions, and types Data Connect mapping callbacks.
packages/embeddings/src/dataconnect-generated/index.ts Introduces TypeScript stub interfaces + stubbed SDK functions that throw when called.
packages/embeddings/src/dataconnect-generated/index.js Checked-in compiled stub output (JS).
packages/embeddings/src/dataconnect-generated/index.js.map Checked-in source map for compiled stub output.
packages/embeddings/src/dataconnect-generated/index.d.ts Checked-in generated declaration output.
packages/embeddings/src/dataconnect-generated/index.d.ts.map Checked-in declaration source map.

@@ -148,7 +153,7 @@ async function getAccessToken(): Promise<string> {
"http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token",
{ headers: { "Metadata-Flavor": "Google" } }
);
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In getAccessToken(), the metadata server fetch result isn’t checked before calling response.json(). If the metadata server returns a non-2xx (e.g., permission/availability issues), this will throw a less-informative JSON parsing error. Consider checking response.ok and throwing an error that includes the status and response body before parsing.

Suggested change
);
);
if (!response.ok) {
const body = await response.text().catch(() => "<unable to read response body>");
throw new Error(`Metadata server error: ${response.status} ${body}`);
}

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +7
/**
* Stub types for Firebase Data Connect SDK
*
* In production, this file would be auto-generated by Firebase Data Connect.
* For Vercel builds where Data Connect isn't available, we provide stubs
* that throw helpful errors at runtime.
*/
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These dataconnect-generated stubs are TypeScript source, but this PR also checks in compiled artifacts (index.js, .map, .d.ts, .d.ts.map) under src/. Keeping build outputs alongside sources is prone to drift and can confuse module resolution; it’s usually better to commit only the .ts stub here and let tsc generate JS/declarations into dist/ during the package build.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +9
"use strict";
/**
* Stub types for Firebase Data Connect SDK
*
* In production, this file would be auto-generated by Firebase Data Connect.
* For Vercel builds where Data Connect isn't available, we provide stubs
* that throw helpful errors at runtime.
*/
Object.defineProperty(exports, "__esModule", { value: true });
Copy link

Copilot AI Feb 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be a compiled build artifact checked into src/ (along with source maps). Since the package build already runs tsc to produce dist/, keeping this file in src/ risks stale code and duplicate/ambiguous module resolution. Consider removing it from source control and generating it in dist/ instead.

Copilot uses AI. Check for mistakes.
@groupthinking
Copy link
Owner Author

Closing — these fixes were already merged via PR #41 (fix/embeddings-build-errors). This branch is stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants