Conversation
80d29c3 to
3d57508
Compare
✅ Circular References ReportGenerated at: 2026-02-03T02:44:31.523Z Summary
Click to view all circular references in PR (85)Click to view all circular references in base branch (85)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 organization-related API calls by migrating them from scattered locations throughout the insomnia package into a centralized insomnia-api package. This improves code organization and maintainability by consolidating all organization API interactions in one place.
Changes:
- Created new
organizations.tsfile ininsomnia-apipackage with all organization-related API functions and type definitions - Updated multiple files to import types and functions from
insomnia-apiinstead of local definitions - Removed duplicate type definitions (
Organization,OrganizationsResponse,StorageRules,FeatureList,Billing,Role,Permission) from various files in theinsomniapackage
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/insomnia-api/src/organizations.ts | New file containing all organization API functions (getOrganizations, checkSeats, getOrganizationRoles, etc.) and related type definitions |
| packages/insomnia-api/src/index.ts | Added export for organizations module |
| packages/insomnia/src/ui/organization-utils.ts | Migrated to use getOrganizations and getOrganizationStorageRule from insomnia-api |
| packages/insomnia/src/ui/components/modals/invite-modal/organization-member-roles-selector.tsx | Updated to import Role type from insomnia-api |
| packages/insomnia/src/ui/components/modals/invite-modal/invite-modal.tsx | Migrated multiple API calls and type definitions to insomnia-api (deleteOrganizationMember, getOrganizationFeatures, getOrgUserPermissions, getOrganizationRoles, getOrganizationMemberRoles) |
| packages/insomnia/src/ui/components/modals/invite-modal/invite-form.tsx | Updated to use checkSeats from insomnia-api |
| packages/insomnia/src/routes/organization.tsx | Updated type imports to use Billing, FeatureList, and Organization from insomnia-api |
| packages/insomnia/src/routes/organization.$organizationId.permissions.tsx | Migrated to use getOrganizationFeatures from insomnia-api |
| packages/insomnia/src/routes/organization.$organizationId.members.$userId.roles.tsx | Updated to use updateUserRoles from insomnia-api |
| packages/insomnia/src/routes/organization.$organizationId.collaborators-check-seats.tsx | Migrated to use checkSeats from insomnia-api |
| packages/insomnia/src/models/organization.ts | Removed type definitions that were migrated to insomnia-api (Organization, Metadata, OrganizationsResponse, StorageRules) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
packages/insomnia/src/ui/components/modals/invite-modal/invite-form.tsx
Outdated
Show resolved
Hide resolved
packages/insomnia/src/routes/organization.$organizationId.permissions.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 33 out of 33 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export const updateUserRoles = ({ | ||
| organizationId, | ||
| userId, | ||
| roleId, | ||
| sessionId, | ||
| }: { | ||
| organizationId: string; | ||
| userId: string; | ||
| roleId: string; | ||
| sessionId: string; | ||
| }) => { | ||
| return fetch({ | ||
| method: 'PATCH', | ||
| path: `/v1/organizations/${organizationId}/members/${userId}/roles`, | ||
| data: { | ||
| roles: [roleId], | ||
| }, | ||
| sessionId, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
The updateUserRoles function should specify a return type generic. The previous implementation expected the API to return { enabled: boolean }, but this function doesn't specify a return type (defaulting to void). If the API returns data, consider adding the return type: fetch<{ enabled: boolean }>({...}) to maintain type safety.
| export const getOrganizationFeatures = ({ | ||
| organizationId, | ||
| sessionId, | ||
| }: { | ||
| organizationId: string; | ||
| sessionId: string; | ||
| }) => { | ||
| return fetch<{ features: FeatureList; billing: Billing }>({ | ||
| method: 'GET', | ||
| path: `/v1/organizations/${organizationId}/features`, | ||
| sessionId, | ||
| }); | ||
| }; |
There was a problem hiding this comment.
The return type of getOrganizationFeatures should likely include undefined to match the previous implementation and the actual usage pattern. The old code typed this as insomniaFetch<{ features: FeatureList; billing: Billing } | undefined> and callers use optional chaining (e.g., res?.features). Consider changing the return type to: fetch<{ features: FeatureList; billing: Billing } | undefined>({...})
b147556 to
f669e33
Compare
| @@ -1,4 +1,5 @@ | |||
| import { type CurrentPlan, type UserProfile } from 'insomnia-api'; | |||
| import { type Billing, type CurrentPlan, type FeatureList, type UserProfile } from 'insomnia-api'; | |||
| import { type Organization } from 'insomnia-api'; | |||
| if (organizationId) { | ||
| getCurrentUserPermissionsInOrg(organizationId).then(permissions => { | ||
| (async () => { | ||
| getOrgUserPermissions({ |
There was a problem hiding this comment.
Should we reset the permission before calling the api? To prevent user operations during the request and fallback when the request fails.
Migrate organizations related apis into
insomnia-apipackage: