-
Notifications
You must be signed in to change notification settings - Fork 2.2k
refactor: migrate projects request to insomnia-api package - [INS-1874] #9574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
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 refactors project-related API calls by migrating them from direct insomniaFetch usage to the centralized insomnia-api package. The migration covers team project operations (fetch, create, update, delete) and git project count reporting.
Changes:
- Migrated team project APIs (
fetchTeamProjects,createTeamProject,updateTeamProject,deleteTeamProject) to theinsomnia-apipackage - Migrated git project count update API (
updateGitProjectCount) to theinsomnia-apipackage - Updated all consumer files to use the new API functions from
insomnia-api
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/insomnia-api/src/project.ts |
Added new project API functions with typed interfaces |
packages/insomnia-api/src/index.ts |
Exported project module from package |
packages/insomnia/src/ui/organization-utils.ts |
Updated to use fetchTeamProjects from insomnia-api |
packages/insomnia/src/routes/organization.$organizationId.project.new.tsx |
Updated to use createTeamProject and updateGitProjectCount |
packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update.tsx |
Updated to use createTeamProject, updateTeamProject, and deleteTeamProject |
packages/insomnia/src/routes/organization.$organizationId.project.$projectId.delete.tsx |
Updated to use deleteTeamProject |
packages/insomnia/src/models/helpers/project.ts |
Updated to use createTeamProject |
Comments suppressed due to low confidence (3)
packages/insomnia/src/models/helpers/project.ts:9
- The
insomniaFetchimport is no longer used in this file after migrating tocreateTeamProjectfrom insomnia-api. This unused import should be removed.
import { insomniaFetch } from '../../ui/insomnia-fetch';
packages/insomnia/src/routes/organization.$organizationId.project.new.tsx:11
- The
insomniaFetchimport is no longer used in this file after migrating to the insomnia-api package functions. This unused import should be removed.
import { insomniaFetch } from '~/ui/insomnia-fetch';
packages/insomnia/src/routes/organization.$organizationId.project.$projectId.update.tsx:12
- The
insomniaFetchimport is no longer used in this file after migrating to the insomnia-api package functions. This unused import should be removed.
import { insomniaFetch } from '~/ui/insomnia-fetch';
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
✅ Circular References ReportGenerated at: 2026-01-19T03:28:15.492Z Summary
Click to view all circular references in PR (167)Click to view all circular references in base branch (167)Analysis✅ No Change: This PR does not introduce or remove any circular references. This report was generated automatically by comparing against the |
dd98bc6 to
49e1abc
Compare
| payload?: any; | ||
| } | ||
|
|
||
| export const parseInsomniaFetchError = (error: unknown) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest moving this check to the insomnia-api, as it is part of the api spec. Like the following:
import {createProject, isAPIError} from 'insomnia-api'
try {
const newProject = await createProject({ ... })
} catch (e) {
if(isAPIError(e)) {
if (parsedError.name === 'FORBIDDEN') {
errMessage = 'You do not have permission to create a cloud project in this organization.';
} else if (parsedError.name === 'NEEDS_TO_UPGRADE') {
errMessage = 'Upgrade your account in order to create new Cloud Projects.';
} else if (parsedError.name === 'PROJECT_STORAGE_RESTRICTION') {
errMessage = parsedError.message ?? 'The owner of the organization allows only Local Vault project creation.';
}
throw new Error(errMessage);
}
throw e
}| this.response = response; | ||
| } | ||
| response; | ||
| payload?: any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to add this payload? I didn't find anywhere use this.
| data: { | ||
| name: project.name, | ||
| }, | ||
| const newCloudProject = await createTeamProject({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also update the error handling here.
Migrate the following apis to the
insomnia-apipackage:Since we set
onlyResolveOnSuccessto always true when we registerfetchapi. So I changed all the error handling approaches for the places that send these requests.