Skip to content

refactor: refactor project related database calls to services#10104

Open
ZxBing0066 wants to merge 8 commits into
developfrom
feat/clean-database-project
Open

refactor: refactor project related database calls to services#10104
ZxBing0066 wants to merge 8 commits into
developfrom
feat/clean-database-project

Conversation

@ZxBing0066

Copy link
Copy Markdown
Member

Background

Remove direct database calls and hide the database behind services.

Changes

  • Add services conventions.md
  • Add generic database-shaped APIs for project services
  • Remove project related database calls to services.

Copilot AI review requested due to automatic review settings June 17, 2026 09:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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) plus getById() and named query helpers.
  • Migrates many project lookups from database.find/findOne/count to services.project.* (including new helpers like listByOrganizationIds and listByGitRepositoryIds).
  • 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.

Comment thread packages/insomnia/src/routes/untracked-projects.tsx Outdated
Comment thread packages/insomnia/src/routes/organization.sync-organizations-and-projects.tsx Outdated
@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-06-26T08:27:45.678Z
Status: ✅ NO CHANGE

Summary

Metric Base (develop) PR Change
Total Circular References 9 9 0 (0.00%)
Click to view all circular references in PR (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (9)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia/src/main/prompt-bridge.ts -> insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/main/window-utils.ts -> insomnia/src/main/plugin-window.ts
insomnia/src/network/network.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the develop branch.

@ZxBing0066 ZxBing0066 requested a review from a team June 18, 2026 05:15
@ZxBing0066 ZxBing0066 enabled auto-merge (squash) June 18, 2026 08: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.

2 participants