refactor: create insomnia-data and move database files in#9589
refactor: create insomnia-data and move database files in#9589ZxBing0066 merged 7 commits intodevelopfrom
Conversation
Updated import path in documentation for database instance.
✅ Circular References ReportGenerated at: 2026-02-12T09:00:35.676Z Summary
Click to view all circular references in PR (76)Click to view all circular references in base branch (76)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
There was a problem hiding this comment.
Pull request overview
This PR refactors the database layer by creating a new insomnia-data module to better organize database-related code. The refactoring extracts database interfaces, types, and implementations from common/database into a dedicated module with clear separation between platform-agnostic code (src) and Node.js-specific implementations (node-src).
Changes:
- Created new
insomnia-datamodule structure withsrcfor interfaces/types andnode-srcfor Node.js implementations - Updated import paths across the codebase to use new module paths (
~/insomnia-dataand~/insomnia-data/node) - Added ESLint rules to enforce proper import patterns and prevent direct access to internal module paths
- Cleaned up type annotations in tests by removing unnecessary
@ts-expect-errorcomments - Added
DataStoreOptionsinterface to avoid injecting Node.js types into renderer process
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/insomnia/src/insomnia-data/src/database/types.ts |
Defines database interfaces including new DataStoreOptions and generic IDatabase<O> |
packages/insomnia/src/insomnia-data/src/database/index.ts |
Database module entry point with IoC pattern and global database instance |
packages/insomnia/src/insomnia-data/src/index.ts |
Main export point for database module |
packages/insomnia/src/insomnia-data/index.ts |
Top-level export redirecting to src |
packages/insomnia/src/insomnia-data/node-src/database/database-nedb.ts |
Updates import path for database types from new location |
packages/insomnia/src/insomnia-data/node-src/database/database.test.ts |
Updates test imports to reference new module structure |
packages/insomnia/src/insomnia-data/node-src/index.ts |
Exports Node.js-specific implementations |
packages/insomnia/src/insomnia-data/node.ts |
Entry point for Node.js-specific code |
packages/insomnia/src/ui/database.client.ts |
Updates import to use new ~/insomnia-data path |
packages/insomnia/src/main/database.main.ts |
Updates imports for database types and Node implementation |
packages/insomnia/src/entry.main.ts |
Updates imports to use new module paths |
packages/insomnia/src/entry.client.tsx |
Updates imports to use new module paths |
packages/insomnia/src/common/send-request.ts |
Updates database imports to new module |
packages/insomnia/src/common/database/index.ts |
Converted to re-export from ~/insomnia-data for backward compatibility |
packages/insomnia/setup-vitest.ts |
Updates test setup imports |
eslint.config.mjs |
Adds rules to enforce import patterns for insomnia-data module |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * | ||
| * @param impl - The database implementation to use (NeDBDatabase or BridgeDatabase) | ||
| */ | ||
| export async function initDatabase(impl: IDatabase, config?: NeDB.DataStoreOptions, forceReset?: boolean) { |
There was a problem hiding this comment.
The initDatabase function signature uses NeDB.DataStoreOptions, which imports the NeDB type. This can inject Node.js types into the renderer process when this module is imported. Consider using the DataStoreOptions interface defined in types.ts instead, which was specifically created to avoid this issue (as noted by the comment "Avoid import nedb here to prevent it injecting the node types into renderer process" in types.ts line 6).
Background
INS-1819
Changes
insomnia-data