// This file is auto-generated by @hey-api/openapi-ts

import { oc } from '@orpc/contract'
import * as z from 'zod'

import {
  zDeleteAccountSessionsBySessionIdPath,
  zDeleteAccountSessionsBySessionIdResponse,
  zDeleteAccountSessionsSelfResponse,
  zDeleteWorkspacesByWorkspaceIdMembersByMemberIdPath,
  zDeleteWorkspacesByWorkspaceIdMembersByMemberIdResponse,
  zGetAccountResponse,
  zGetAccountSessionsQuery,
  zGetAccountSessionsResponse,
  zGetAppsByAppIdCheckDependenciesPath,
  zGetAppsByAppIdCheckDependenciesResponse,
  zGetAppsByAppIdDescribePath,
  zGetAppsByAppIdDescribeQuery,
  zGetAppsByAppIdDescribeResponse,
  zGetAppsByAppIdExportPath,
  zGetAppsByAppIdExportQuery,
  zGetAppsByAppIdExportResponse,
  zGetAppsByAppIdFormHumanInputByFormTokenPath,
  zGetAppsByAppIdFormHumanInputByFormTokenResponse,
  zGetAppsByAppIdTasksByTaskIdEventsPath,
  zGetAppsByAppIdTasksByTaskIdEventsQuery,
  zGetAppsByAppIdTasksByTaskIdEventsResponse,
  zGetAppsQuery,
  zGetAppsResponse,
  zGetHealthResponse,
  zGetOauthDeviceLookupQuery,
  zGetOauthDeviceLookupResponse,
  zGetPermittedExternalAppsQuery,
  zGetPermittedExternalAppsResponse,
  zGetVersionResponse,
  zGetWorkspacesByWorkspaceIdMembersPath,
  zGetWorkspacesByWorkspaceIdMembersQuery,
  zGetWorkspacesByWorkspaceIdMembersResponse,
  zGetWorkspacesByWorkspaceIdPath,
  zGetWorkspacesByWorkspaceIdResponse,
  zGetWorkspacesResponse,
  zPostAppsByAppIdFilesUploadPath,
  zPostAppsByAppIdFilesUploadResponse,
  zPostAppsByAppIdFormHumanInputByFormTokenBody,
  zPostAppsByAppIdFormHumanInputByFormTokenPath,
  zPostAppsByAppIdFormHumanInputByFormTokenResponse,
  zPostAppsByAppIdRunBody,
  zPostAppsByAppIdRunPath,
  zPostAppsByAppIdRunResponse,
  zPostAppsByAppIdTasksByTaskIdStopPath,
  zPostAppsByAppIdTasksByTaskIdStopResponse,
  zPostOauthDeviceApproveBody,
  zPostOauthDeviceApproveResponse,
  zPostOauthDeviceCodeBody,
  zPostOauthDeviceCodeResponse,
  zPostOauthDeviceDenyBody,
  zPostOauthDeviceDenyResponse,
  zPostOauthDeviceTokenBody,
  zPostOauthDeviceTokenResponse,
  zPostWorkspacesByWorkspaceIdAppsImportsBody,
  zPostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmPath,
  zPostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmResponse,
  zPostWorkspacesByWorkspaceIdAppsImportsPath,
  zPostWorkspacesByWorkspaceIdAppsImportsResponse,
  zPostWorkspacesByWorkspaceIdMembersBody,
  zPostWorkspacesByWorkspaceIdMembersPath,
  zPostWorkspacesByWorkspaceIdMembersResponse,
  zPostWorkspacesByWorkspaceIdSwitchPath,
  zPostWorkspacesByWorkspaceIdSwitchResponse,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleBody,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRolePath,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleResponse,
} from './zod.gen'

export const get = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getHealth',
    path: '/_health',
    tags: ['openapi'],
  })
  .output(zGetHealthResponse)

export const health = {
  get,
}

export const get2 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getVersion',
    path: '/_version',
    tags: ['openapi'],
  })
  .output(zGetVersionResponse)

export const version = {
  get: get2,
}

export const delete_ = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'deleteAccountSessionsSelf',
    path: '/account/sessions/self',
    tags: ['openapi'],
  })
  .output(zDeleteAccountSessionsSelfResponse)

export const self = {
  delete: delete_,
}

export const delete2 = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'deleteAccountSessionsBySessionId',
    path: '/account/sessions/{session_id}',
    tags: ['openapi'],
  })
  .input(z.object({ params: zDeleteAccountSessionsBySessionIdPath }))
  .output(zDeleteAccountSessionsBySessionIdResponse)

export const bySessionId = {
  delete: delete2,
}

export const get3 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAccountSessions',
    path: '/account/sessions',
    tags: ['openapi'],
  })
  .input(z.object({ query: zGetAccountSessionsQuery.optional() }))
  .output(zGetAccountSessionsResponse)

export const sessions = {
  get: get3,
  self,
  bySessionId,
}

export const get4 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAccount',
    path: '/account',
    tags: ['openapi'],
  })
  .output(zGetAccountResponse)

export const account = {
  get: get4,
  sessions,
}

export const get5 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdCheckDependencies',
    path: '/apps/{app_id}/check-dependencies',
    tags: ['openapi'],
  })
  .input(z.object({ params: zGetAppsByAppIdCheckDependenciesPath }))
  .output(zGetAppsByAppIdCheckDependenciesResponse)

export const checkDependencies = {
  get: get5,
}

export const get6 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdDescribe',
    path: '/apps/{app_id}/describe',
    tags: ['openapi'],
  })
  .input(
    z.object({
      params: zGetAppsByAppIdDescribePath,
      query: zGetAppsByAppIdDescribeQuery.optional(),
    }),
  )
  .output(zGetAppsByAppIdDescribeResponse)

export const describe = {
  get: get6,
}

export const get7 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdExport',
    path: '/apps/{app_id}/export',
    tags: ['openapi'],
  })
  .input(
    z.object({ params: zGetAppsByAppIdExportPath, query: zGetAppsByAppIdExportQuery.optional() }),
  )
  .output(zGetAppsByAppIdExportResponse)

export const export_ = {
  get: get7,
}

/**
 * Upload a file to use as an input variable when running the app
 */
export const post = oc
  .route({
    description: 'Upload a file to use as an input variable when running the app',
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postAppsByAppIdFilesUpload',
    path: '/apps/{app_id}/files/upload',
    successStatus: 201,
    tags: ['openapi'],
  })
  .input(z.object({ params: zPostAppsByAppIdFilesUploadPath }))
  .output(zPostAppsByAppIdFilesUploadResponse)

export const upload = {
  post,
}

export const files = {
  upload,
}

export const get8 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdFormHumanInputByFormToken',
    path: '/apps/{app_id}/form/human_input/{form_token}',
    tags: ['openapi'],
  })
  .input(z.object({ params: zGetAppsByAppIdFormHumanInputByFormTokenPath }))
  .output(zGetAppsByAppIdFormHumanInputByFormTokenResponse)

export const post2 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postAppsByAppIdFormHumanInputByFormToken',
    path: '/apps/{app_id}/form/human_input/{form_token}',
    tags: ['openapi'],
  })
  .input(
    z.object({
      body: zPostAppsByAppIdFormHumanInputByFormTokenBody,
      params: zPostAppsByAppIdFormHumanInputByFormTokenPath,
    }),
  )
  .output(zPostAppsByAppIdFormHumanInputByFormTokenResponse)

export const byFormToken = {
  get: get8,
  post: post2,
}

export const humanInput = {
  byFormToken,
}

export const form = {
  humanInput,
}

export const post3 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postAppsByAppIdRun',
    path: '/apps/{app_id}/run',
    tags: ['openapi'],
  })
  .input(z.object({ body: zPostAppsByAppIdRunBody, params: zPostAppsByAppIdRunPath }))
  .output(zPostAppsByAppIdRunResponse)

export const run = {
  post: post3,
}

export const get9 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdTasksByTaskIdEvents',
    path: '/apps/{app_id}/tasks/{task_id}/events',
    tags: ['openapi'],
  })
  .input(
    z.object({
      params: zGetAppsByAppIdTasksByTaskIdEventsPath,
      query: zGetAppsByAppIdTasksByTaskIdEventsQuery.optional(),
    }),
  )
  .output(zGetAppsByAppIdTasksByTaskIdEventsResponse)

export const events = {
  get: get9,
}

export const post4 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postAppsByAppIdTasksByTaskIdStop',
    path: '/apps/{app_id}/tasks/{task_id}/stop',
    tags: ['openapi'],
  })
  .input(z.object({ params: zPostAppsByAppIdTasksByTaskIdStopPath }))
  .output(zPostAppsByAppIdTasksByTaskIdStopResponse)

export const stop = {
  post: post4,
}

export const byTaskId = {
  events,
  stop,
}

export const tasks = {
  byTaskId,
}

export const byAppId = {
  checkDependencies,
  describe,
  export: export_,
  files,
  form,
  run,
  tasks,
}

export const get10 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getApps',
    path: '/apps',
    tags: ['openapi'],
  })
  .input(z.object({ query: zGetAppsQuery }))
  .output(zGetAppsResponse)

export const apps = {
  get: get10,
  byAppId,
}

export const post5 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postOauthDeviceApprove',
    path: '/oauth/device/approve',
    tags: ['openapi'],
  })
  .input(z.object({ body: zPostOauthDeviceApproveBody }))
  .output(zPostOauthDeviceApproveResponse)

export const approve = {
  post: post5,
}

export const post6 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postOauthDeviceCode',
    path: '/oauth/device/code',
    tags: ['openapi'],
  })
  .input(z.object({ body: zPostOauthDeviceCodeBody }))
  .output(zPostOauthDeviceCodeResponse)

export const code = {
  post: post6,
}

export const post7 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postOauthDeviceDeny',
    path: '/oauth/device/deny',
    tags: ['openapi'],
  })
  .input(z.object({ body: zPostOauthDeviceDenyBody }))
  .output(zPostOauthDeviceDenyResponse)

export const deny = {
  post: post7,
}

export const get11 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getOauthDeviceLookup',
    path: '/oauth/device/lookup',
    tags: ['openapi'],
  })
  .input(z.object({ query: zGetOauthDeviceLookupQuery }))
  .output(zGetOauthDeviceLookupResponse)

export const lookup = {
  get: get11,
}

export const post8 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postOauthDeviceToken',
    path: '/oauth/device/token',
    tags: ['openapi'],
  })
  .input(z.object({ body: zPostOauthDeviceTokenBody }))
  .output(zPostOauthDeviceTokenResponse)

export const token = {
  post: post8,
}

export const device = {
  approve,
  code,
  deny,
  lookup,
  token,
}

export const oauth = {
  device,
}

export const get12 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getPermittedExternalApps',
    path: '/permitted-external-apps',
    tags: ['openapi'],
  })
  .input(z.object({ query: zGetPermittedExternalAppsQuery.optional() }))
  .output(zGetPermittedExternalAppsResponse)

export const permittedExternalApps = {
  get: get12,
}

export const post9 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postWorkspacesByWorkspaceIdAppsImportsByImportIdConfirm',
    path: '/workspaces/{workspace_id}/apps/imports/{import_id}/confirm',
    tags: ['openapi'],
  })
  .input(z.object({ params: zPostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmPath }))
  .output(zPostWorkspacesByWorkspaceIdAppsImportsByImportIdConfirmResponse)

export const confirm = {
  post: post9,
}

export const byImportId = {
  confirm,
}

export const post10 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postWorkspacesByWorkspaceIdAppsImports',
    path: '/workspaces/{workspace_id}/apps/imports',
    tags: ['openapi'],
  })
  .input(
    z.object({
      body: zPostWorkspacesByWorkspaceIdAppsImportsBody,
      params: zPostWorkspacesByWorkspaceIdAppsImportsPath,
    }),
  )
  .output(zPostWorkspacesByWorkspaceIdAppsImportsResponse)

export const imports = {
  post: post10,
  byImportId,
}

export const apps2 = {
  imports,
}

export const put = oc
  .route({
    inputStructure: 'detailed',
    method: 'PUT',
    operationId: 'putWorkspacesByWorkspaceIdMembersByMemberIdRole',
    path: '/workspaces/{workspace_id}/members/{member_id}/role',
    tags: ['openapi'],
  })
  .input(
    z.object({
      body: zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleBody,
      params: zPutWorkspacesByWorkspaceIdMembersByMemberIdRolePath,
    }),
  )
  .output(zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleResponse)

export const role = {
  put,
}

export const delete3 = oc
  .route({
    inputStructure: 'detailed',
    method: 'DELETE',
    operationId: 'deleteWorkspacesByWorkspaceIdMembersByMemberId',
    path: '/workspaces/{workspace_id}/members/{member_id}',
    tags: ['openapi'],
  })
  .input(z.object({ params: zDeleteWorkspacesByWorkspaceIdMembersByMemberIdPath }))
  .output(zDeleteWorkspacesByWorkspaceIdMembersByMemberIdResponse)

export const byMemberId = {
  delete: delete3,
  role,
}

export const get13 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getWorkspacesByWorkspaceIdMembers',
    path: '/workspaces/{workspace_id}/members',
    tags: ['openapi'],
  })
  .input(
    z.object({
      params: zGetWorkspacesByWorkspaceIdMembersPath,
      query: zGetWorkspacesByWorkspaceIdMembersQuery.optional(),
    }),
  )
  .output(zGetWorkspacesByWorkspaceIdMembersResponse)

export const post11 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postWorkspacesByWorkspaceIdMembers',
    path: '/workspaces/{workspace_id}/members',
    successStatus: 201,
    tags: ['openapi'],
  })
  .input(
    z.object({
      body: zPostWorkspacesByWorkspaceIdMembersBody,
      params: zPostWorkspacesByWorkspaceIdMembersPath,
    }),
  )
  .output(zPostWorkspacesByWorkspaceIdMembersResponse)

export const members = {
  get: get13,
  post: post11,
  byMemberId,
}

export const post12 = oc
  .route({
    inputStructure: 'detailed',
    method: 'POST',
    operationId: 'postWorkspacesByWorkspaceIdSwitch',
    path: '/workspaces/{workspace_id}/switch',
    tags: ['openapi'],
  })
  .input(z.object({ params: zPostWorkspacesByWorkspaceIdSwitchPath }))
  .output(zPostWorkspacesByWorkspaceIdSwitchResponse)

export const switch_ = {
  post: post12,
}

export const get14 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getWorkspacesByWorkspaceId',
    path: '/workspaces/{workspace_id}',
    tags: ['openapi'],
  })
  .input(z.object({ params: zGetWorkspacesByWorkspaceIdPath }))
  .output(zGetWorkspacesByWorkspaceIdResponse)

export const byWorkspaceId = {
  get: get14,
  apps: apps2,
  members,
  switch: switch_,
}

export const get15 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getWorkspaces',
    path: '/workspaces',
    tags: ['openapi'],
  })
  .output(zGetWorkspacesResponse)

export const workspaces = {
  get: get15,
  byWorkspaceId,
}

export const contract = {
  health,
  version,
  account,
  apps,
  oauth,
  permittedExternalApps,
  workspaces,
}
