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

export interface IReq_WorkspaceReadFile extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceReadFile
> {
  method: 'workspaceReadFile';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    content: string;
  };
}

export interface IReq_WorkspaceWriteFile extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceWriteFile
> {
  method: 'workspaceWriteFile';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
    content: string;
  };
  response: {};
}

export interface IReq_WorkspaceReadDir extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceReadDir
> {
  method: 'workspaceReadDir';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    entries: Array<{ type: 'file' | 'directory'; name: string; path: string }>;
  };
}

export interface IReq_WorkspaceMkdir extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceMkdir
> {
  method: 'workspaceMkdir';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {};
}

export interface IReq_WorkspaceRm extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceRm
> {
  method: 'workspaceRm';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
    recursive?: boolean;
  };
  response: {};
}

export interface IReq_WorkspaceExists extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceExists
> {
  method: 'workspaceExists';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    path: string;
  };
  response: {
    exists: boolean;
  };
}

export interface IReq_WorkspaceExec extends plugins.typedrequestInterfaces.implementsTR<
  plugins.typedrequestInterfaces.ITypedRequest,
  IReq_WorkspaceExec
> {
  method: 'workspaceExec';
  request: {
    identity: data.IIdentity;
    serviceName: string;
    command: string;
    args?: string[];
  };
  response: {
    stdout: string;
    stderr: string;
    exitCode: number;
  };
}
