mirror of
https://github.com/Kong/insomnia.git
synced 2026-08-04 11:52:33 -04:00
refactor: move main-only sync helpers
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import FileSystemDriver from '../store/drivers/file-system-driver';
|
||||
import type { MergeConflict } from '../types';
|
||||
import { VCS } from './vcs';
|
||||
import FileSystemDriver from '../../sync/store/drivers/file-system-driver';
|
||||
import type { MergeConflict } from '../../sync/types';
|
||||
import { VCS } from '../../sync/vcs/vcs';
|
||||
|
||||
export type ConflictHandler = (
|
||||
conflicts: MergeConflict[],
|
||||
@@ -1,11 +1,11 @@
|
||||
import { type RemoteProject, type Workspace } from '~/insomnia-data';
|
||||
import { database, models } from '~/insomnia-data';
|
||||
import type { BackendProjectWithTeam } from '~/sync/types';
|
||||
|
||||
import { DEFAULT_BRANCH_NAME } from '../../common/constants';
|
||||
import type { BackendProjectWithTeam } from './normalize-backend-project-team';
|
||||
import { interceptAccessError } from './util';
|
||||
import type { VCS } from './vcs';
|
||||
|
||||
import { interceptAccessError } from '../../sync/vcs/util';
|
||||
import type { VCS } from '../../sync/vcs/vcs';
|
||||
|
||||
interface Options {
|
||||
vcs: VCS;
|
||||
backendProject: BackendProjectWithTeam;
|
||||
@@ -4,12 +4,11 @@ import { randomUUID } from 'node:crypto';
|
||||
import { app, type WebContents } from 'electron';
|
||||
|
||||
import type { RemoteProject } from '~/insomnia-data';
|
||||
import type { BackendProjectWithTeam, MergeConflict } from '~/sync/types';
|
||||
import { services } from '~/insomnia-data';
|
||||
import type { MergeConflict } from '~/sync/types';
|
||||
import { createVCS } from '~/sync/vcs/create-vcs';
|
||||
import { createVCS } from '~/main/cloud-sync/create-vcs';
|
||||
import { UserAbortResolveMergeConflictError } from '~/sync/vcs/errors';
|
||||
import type { BackendProjectWithTeam } from '~/sync/vcs/normalize-backend-project-team';
|
||||
import { pullBackendProject } from '~/sync/vcs/pull-backend-project';
|
||||
import { pullBackendProject } from '~/main/cloud-sync/pull-backend-project';
|
||||
import type { VCS } from '~/sync/vcs/vcs';
|
||||
import { invariant } from '~/utils/invariant';
|
||||
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { createBuilder, type Schema } from '@develohpanda/fluent-builder';
|
||||
|
||||
import { baseModelSchema } from '../../models/__schemas__/model-schemas';
|
||||
import type { BackendProject, Branch, MergeConflict, SnapshotStateEntry, StatusCandidate, Team } from '../types';
|
||||
import type { BackendProjectWithTeam } from '../vcs/normalize-backend-project-team';
|
||||
import type {
|
||||
BackendProject,
|
||||
BackendProjectWithTeam,
|
||||
Branch,
|
||||
MergeConflict,
|
||||
SnapshotStateEntry,
|
||||
StatusCandidate,
|
||||
Team,
|
||||
} from '../types';
|
||||
|
||||
export const projectSchema: Schema<BackendProject> = {
|
||||
id: () => 'id',
|
||||
|
||||
@@ -11,6 +11,14 @@ export interface BackendProject {
|
||||
rootDocumentId: string;
|
||||
}
|
||||
|
||||
export interface BackendProjectWithTeams extends BackendProject {
|
||||
teams: Team[];
|
||||
}
|
||||
|
||||
export interface BackendProjectWithTeam extends BackendProject {
|
||||
team: Team;
|
||||
}
|
||||
|
||||
export type DocumentKey = string;
|
||||
|
||||
export type BlobId = string;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import type { BackendProject, Team } from '../types';
|
||||
|
||||
export interface BackendProjectWithTeams extends BackendProject {
|
||||
teams: Team[];
|
||||
}
|
||||
|
||||
export interface BackendProjectWithTeam extends BackendProject {
|
||||
team: Team;
|
||||
}
|
||||
|
||||
export const normalizeBackendProjectTeam = (backend: BackendProjectWithTeams): BackendProjectWithTeam => ({
|
||||
id: backend.id,
|
||||
name: backend.name,
|
||||
rootDocumentId: backend.rootDocumentId,
|
||||
// A backend project is guaranteed to exist on exactly one team
|
||||
team: backend.teams[0],
|
||||
});
|
||||
@@ -19,6 +19,7 @@ import type { BaseDriver } from '../store/drivers/base';
|
||||
import compress from '../store/hooks/compress';
|
||||
import type {
|
||||
BackendProject,
|
||||
BackendProjectWithTeams,
|
||||
Branch,
|
||||
DocumentKey,
|
||||
Head,
|
||||
@@ -29,7 +30,6 @@ import type {
|
||||
StageEntry,
|
||||
StatusCandidate,
|
||||
} from '../types';
|
||||
import type { BackendProjectWithTeams } from './normalize-backend-project-team';
|
||||
import {
|
||||
compareBranches,
|
||||
generateCandidateMap,
|
||||
|
||||
Reference in New Issue
Block a user