MCPcopy Create free account
hub / github.com/Kong/insomnia / pullRemoteBackendProject

Function pullRemoteBackendProject

packages/insomnia/src/main/cloud-sync/vcs.ts:151–187  ·  view source on GitHub ↗
(
  sender: WebContents,
  { organizationId, backendProjectId, remoteId }: PullRemoteBackendProjectOptions,
)

Source from the content-addressed store, hash-verified

149};
150
151export const pullRemoteBackendProject = async (
152 sender: WebContents,
153 { organizationId, backendProjectId, remoteId }: PullRemoteBackendProjectOptions,
154) => {
155 return runWithSyncRenderer(sender, async () => {
156 ensureStoreConfigured();
157 const projects = await remoteBackendProjects({
158 teamId: organizationId,
159 teamProjectId: remoteId,
160 });
161 const backendProject = projects.find(project => project.id === backendProjectId) as
162 | BackendProjectWithTeam
163 | undefined;
164
165 invariant(backendProject, 'Backend project not found');
166
167 const project = await services.project.getByRemoteId(remoteId);
168 invariant(project?.remoteId, 'Project is not a remote project');
169
170 // backendProject.rootDocumentId is the target workspace's id, so the pull runs on that
171 // workspace's own VCS instance directly — no need for a separate isolated instance to shield
172 // a singleton's mutable state from other concurrent sync.invoke calls.
173 await removeBackendProjectsForRoot(backendProject.rootDocumentId);
174 const vcs = getVCSForWorkspace(backendProject.rootDocumentId);
175 const { workspaceId } = await pullBackendProject({
176 vcs,
177 backendProject,
178 remoteProject: project as RemoteProject,
179 });
180 invariant(typeof workspaceId === 'string', 'Workspace not found after pulling backend project');
181
182 return {
183 projectId: project._id,
184 workspaceId,
185 };
186 });
187};

Callers 1

Calls 8

remoteBackendProjectsFunction · 0.90
invariantFunction · 0.90
pullBackendProjectFunction · 0.90
runWithSyncRendererFunction · 0.85
ensureStoreConfiguredFunction · 0.85
getVCSForWorkspaceFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected