refactor: refactor project related database calls to services#10104
Open
ZxBing0066 wants to merge 8 commits into
Open
refactor: refactor project related database calls to services#10104ZxBing0066 wants to merge 8 commits into
ZxBing0066 wants to merge 8 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR continues the ongoing data-access refactor by removing direct project-related NeDB calls from the app layer and standardizing access through services.project APIs in insomnia-data.
Changes:
- Introduces and documents “database-shaped” service APIs (
list,get,count) plusgetById()and named query helpers. - Migrates many project lookups from
database.find/findOne/counttoservices.project.*(including new helpers likelistByOrganizationIdsandlistByGitRepositoryIds). - Updates app routes, UI utilities, and tests to align with the new project service API surface.
Reviewed changes
Copilot reviewed 56 out of 56 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia/src/utils/router.ts | Switches project lookups to services.project.getById/get |
| packages/insomnia/src/ui/utils/remote-projects.ts | Uses getById for project resolution |
| packages/insomnia/src/ui/organization-utils.ts | Replaces project DB queries with service list calls |
| packages/insomnia/src/ui/hooks/use-insomnia-navigation.ts | Updates navigation project resolver to getById |
| packages/insomnia/src/ui/components/sidebar/project-navigation-sidebar/project-navigation-sidebar.tsx | Uses listByOrganizationIds for Konnect project fetch |
| packages/insomnia/src/ui/components/modals/workspace-duplicate-modal.tsx | Uses listByOrganizationIds to populate project options |
| packages/insomnia/src/ui/components/modals/import-modal/import-projects-modal.tsx | Uses listByOrganizationIds when skipExisting |
| packages/insomnia/src/ui/components/modals/add-request-to-collection-modal.tsx | Uses listByOrganizationIds to populate project options |
| packages/insomnia/src/sync/vcs/migrate-projects-into-organization.ts | Replaces project DB counts/lists with services.project |
| packages/insomnia/src/routes/untracked-projects.tsx | Refactors project query to a project service helper (but currently incorrect logic) |
| packages/insomnia/src/routes/remote-files.tsx | Uses services.project.list for remoteId matching |
| packages/insomnia/src/routes/organization.sync-organizations-and-projects.tsx | Uses project service to find redirect target project |
| packages/insomnia/src/routes/organization.$organizationId.project.new.tsx | Uses listByOrganizationIds for git project counting |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.update.tsx | Uses getById for project lookup |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.new.tsx | Uses getById for project lookup |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.move.tsx | Uses getById for destination project lookup |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.delete.tsx | Uses getById for project lookup |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.tsx | Uses getById and listByOrganizationIds for loader data |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.spec.tsx | Updates test loader project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.spec.generate-request-collection.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.tsx | Updates loader project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mock-server.generate-request-collection.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.mcp.tsx | Updates loader project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.tsx | Updates loader project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.sync-data.tsx | Updates loader/action project lookups to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.push.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.pull.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.fetch.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.insomnia-sync.create-snapshot.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.tsx | Updates loader project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.request.$requestId.grant-access.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.workspace.$workspaceId.debug.reorder.tsx | Updates target project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update-ruleset.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.tsx | Updates loader project lookup to getById and org project listing helper |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.refresh-ruleset.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.move.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.move-workspace.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.list-workspaces.tsx | Updates loader project/org projects lookups to service helpers |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.delete.tsx | Updates action project lookup to getById and org listing helper |
| packages/insomnia/src/routes/organization.$organizationId.project.$projectId.delete-ruleset.tsx | Updates action project lookup to getById |
| packages/insomnia/src/routes/import.resources.tsx | Updates import flow project lookup to getById |
| packages/insomnia/src/routes/git.all-connected-repos.tsx | Uses listByOrganizationIds instead of per-org DB queries |
| packages/insomnia/src/routes/git-credentials.$id.related-projects.tsx | Uses listByGitRepositoryIds helper |
| packages/insomnia/src/routes/commands.tsx | Uses listByOrganizationIds instead of DB $in query |
| packages/insomnia/src/main/git-service.ts | Updates multiple git flows to use getById |
| packages/insomnia/src/main/cloud-sync/initialization.ts | Uses getById for project lookup |
| packages/insomnia/src/konnect/sync.ts | Uses insoservices.project.list for Konnect project preloading |
| packages/insomnia/src/konnect/tests/sync.test.ts | Updates tests to use insoservices.project.list |
| packages/insomnia/src/entry.main.ts | Uses getById for scratchpad, and services.project.count for stats |
| packages/insomnia/src/common/project.ts | Uses listByOrganizationIds for project gathering |
| packages/insomnia/src/common/import.ts | Uses getById and conditional listByOrganizationIds/list |
| packages/insomnia/src/account/session.ts | Uses listByGitRepositoryIds when removing git credentials |
| packages/insomnia-data/node-src/services/project.ts | Refactors project service API surface + adds named list helpers |
| packages/insomnia-data/node-src/services/environment.ts | Uses project service helper for org project listing |
| packages/insomnia-data/node-src/services/CONVENTIONS.md | Adds service API naming/shape conventions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Circular References ReportGenerated at: 2026-06-26T08:27:45.678Z Summary
Click to view all circular references in PR (9)Click to view all circular references in base branch (9)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background
Remove direct database calls and hide the database behind services.
Changes