export type QueryOptions = {
  limit?: number
  offset?: number
  search?: string
}

export type FrontendPayloadRequestData = {
  appSessionId: string
  requestId: string
  appRequestCode: string
  project?: string
  type: string
  broadcast?: string[] | boolean
  broadcastChannels?: string[]
  format?: string
  userId?: string
  options?: any | QueryOptions
}

export type FrontendPayloadBody<T> = {
  _id: string
  _type: string
  _offline: number
  _owner: string
  _tags: string[]
  _displayName: string
  _completion: string
  _project: string
  _updatedAt: string | Date
  _createdAt: string | Date
  _deleted: boolean
  _source?: Partial<any> | T
  _meta?: Record<string, any>
}

export type FileType = File | { [x: string]: any }

export type BodyContent<T> = {
  items: FrontendPayloadBody<T>[]
  hits?: any
  prevVersion?: any
  deleted?: string[]
  restored?: string[]
  file?: FileType
  parent?: T
  oldParent?: T
}

export type FrontendPayload<T> = FrontendPayloadRequestData & {
  body: BodyContent<T>
  workSessionId?: string
}
