import * as plugins from '../plugins.ts';
import * as data from '../data/index.ts';

export interface IReq_GetSyncConfigs extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetSyncConfigs
> {
  method: 'getSyncConfigs';
  request: {
    identity: data.IIdentity;
  };
  response: {
    configs: data.ISyncConfig[];
  };
}

export interface IReq_CreateSyncConfig extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_CreateSyncConfig
> {
  method: 'createSyncConfig';
  request: {
    identity: data.IIdentity;
    name: string;
    sourceConnectionId: string;
    targetConnectionId: string;
    targetGroupOffset?: string;
    intervalMinutes?: number;
    enforceDelete?: boolean;
    enforceGroupDelete?: boolean;
    addMirrorHint?: boolean;
    useGroupAvatarsForProjects?: boolean;
  };
  response: {
    config: data.ISyncConfig;
  };
}

export interface IReq_UpdateSyncConfig extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_UpdateSyncConfig
> {
  method: 'updateSyncConfig';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
    name?: string;
    targetGroupOffset?: string;
    intervalMinutes?: number;
    enforceDelete?: boolean;
    enforceGroupDelete?: boolean;
    addMirrorHint?: boolean;
    useGroupAvatarsForProjects?: boolean;
  };
  response: {
    config: data.ISyncConfig;
  };
}

export interface IReq_DeleteSyncConfig extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_DeleteSyncConfig
> {
  method: 'deleteSyncConfig';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
  };
  response: {
    ok: boolean;
  };
}

export interface IReq_PauseSyncConfig extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PauseSyncConfig
> {
  method: 'pauseSyncConfig';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
    paused: boolean;
  };
  response: {
    config: data.ISyncConfig;
  };
}

export interface IReq_TriggerSync extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_TriggerSync
> {
  method: 'triggerSync';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
  };
  response: {
    ok: boolean;
    message: string;
  };
}

export interface IReq_PreviewSync extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PreviewSync
> {
  method: 'previewSync';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
  };
  response: {
    mappings: Array<{ sourceFullPath: string; targetFullPath: string }>;
    deletions: string[];
    groupDeletions: string[];
  };
}

export interface IReq_GetSyncRepoStatuses extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetSyncRepoStatuses
> {
  method: 'getSyncRepoStatuses';
  request: {
    identity: data.IIdentity;
    syncConfigId: string;
  };
  response: {
    statuses: data.ISyncRepoStatus[];
  };
}

export interface IReq_GetSyncLogs extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_GetSyncLogs
> {
  method: 'getSyncLogs';
  request: {
    identity: data.IIdentity;
    limit?: number;
  };
  response: {
    logs: data.ISyncLogEntry[];
  };
}

export interface IReq_PushSyncLog extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_PushSyncLog
> {
  method: 'pushSyncLog';
  request: {
    entry: data.ISyncLogEntry;
  };
  response: {};
}
