Skip to content

postgres - feat: migrating to hookified and advanced functions#1857

Merged
jaredwray merged 3 commits intomainfrom
postgres---feat-migrating-to-hookified-and-advanced-functions
Feb 22, 2026
Merged

postgres - feat: migrating to hookified and advanced functions#1857
jaredwray merged 3 commits intomainfrom
postgres---feat-migrating-to-hookified-and-advanced-functions

Conversation

@jaredwray
Copy link
Owner

@jaredwray jaredwray commented Feb 22, 2026

Please check if the PR fulfills these requirements

  • Followed the Contributing and Code of Conduct guidelines.
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
postgres - feat: migrating to hookified and advanced functions

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jaredwray, 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 focuses on modernizing the PostgreSQL storage adapter by integrating the hookified library, which replaces the traditional EventEmitter pattern. This change allows for more advanced and structured hook management within the adapter. Concurrently, the PR significantly enhances type safety across the adapter's methods by introducing explicit generic types and return type annotations, leading to a more robust and maintainable codebase. Additionally, internal property access has been refined for better encapsulation.

Highlights

  • Migration to Hookified: The KeyvPostgres class has been refactored to extend Hookified instead of EventEmitter, introducing a more advanced and flexible event/hook system for the adapter.
  • Enhanced Type Safety: Explicit generic type parameters and return types have been added to various methods such as get, getMany, set, setMany, delete, deleteMany, clear, iterator, and has, significantly improving the type safety and predictability of the PostgreSQL adapter.
  • Namespace Encapsulation: The namespace property has been refactored into a private _namespace with public getter and setter accessors, enhancing encapsulation and control over how the namespace is accessed and modified.
  • Test Suite Updates: The test suite has been updated to reflect changes in error handling, specifically replacing a test for iterator query failures with a new test for connection failure error emissions.
Changelog
  • pnpm-lock.yaml
    • Added 'hookified' dependency for the 'storage/postgres' package.
    • Removed and re-added '@vitest/mocker' dependency with updated 'vite' version.
  • storage/postgres/package.json
    • Added 'hookified' as a dependency.
  • storage/postgres/src/index.ts
    • Replaced 'EventEmitter' import with 'Hookified' import.
    • Updated 'KeyvPostgres' class to extend 'Hookified'.
    • Refactored 'namespace' property to private '_namespace' with public getter and setter.
    • Added v8 ignore comments for test coverage exclusion around error emission.
    • Introduced generic type parameters and explicit return types for get, getMany, set, setMany, delete, deleteMany, clear, iterator, and has methods.
    • Updated this.namespace references to this._namespace.
  • storage/postgres/test/test.ts
    • Removed the test case for iterator error emission on query failure.
    • Added a new test case to verify error emission when the database connection fails.
Activity
  • No human activity has been recorded on this pull request yet.
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 is a nice improvement for the @keyv/postgres adapter. It migrates from Node's EventEmitter to hookified, enhancing the event and hook system. A major part of this change is the introduction of stricter types across the adapter's methods, using generics and explicit return types, which significantly improves type safety and the developer experience. Additionally, the namespace property is now properly encapsulated. The code changes are solid. My only suggestion is to refactor a test case that relies on setTimeout to make it more robust and prevent potential flakiness in the test suite.

@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.95%. Comparing base (fba5d8c) to head (351b0ef).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1857   +/-   ##
=======================================
  Coverage   99.95%   99.95%           
=======================================
  Files          32       32           
  Lines        2434     2439    +5     
  Branches      440      439    -1     
=======================================
+ Hits         2433     2438    +5     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray jaredwray merged commit d66d9ff into main Feb 22, 2026
8 checks passed
@jaredwray jaredwray deleted the postgres---feat-migrating-to-hookified-and-advanced-functions branch February 22, 2026 03:07
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.

1 participant