// 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,
  zGetAccountSessionsResponse,
  zGetAppsByAppIdDescribePath,
  zGetAppsByAppIdDescribeQuery,
  zGetAppsByAppIdDescribeResponse,
  zGetAppsByAppIdFormHumanInputByFormTokenPath,
  zGetAppsByAppIdFormHumanInputByFormTokenResponse,
  zGetAppsByAppIdTasksByTaskIdEventsPath,
  zGetAppsByAppIdTasksByTaskIdEventsResponse,
  zGetAppsQuery,
  zGetAppsResponse,
  zGetHealthResponse,
  zGetOauthDeviceLookupQuery,
  zGetOauthDeviceLookupResponse,
  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,
  zPostWorkspacesByWorkspaceIdMembersBody,
  zPostWorkspacesByWorkspaceIdMembersPath,
  zPostWorkspacesByWorkspaceIdMembersResponse,
  zPostWorkspacesByWorkspaceIdSwitchPath,
  zPostWorkspacesByWorkspaceIdSwitchResponse,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleBody,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRolePath,
  zPutWorkspacesByWorkspaceIdMembersByMemberIdRoleResponse,
} from './zod.gen'

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const get = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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'],
  })
  .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,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const get5 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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: get5,
}

/**
 * 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,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const get6 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdFormHumanInputByFormToken',
    path: '/apps/{app_id}/form/human_input/{form_token}',
    tags: ['openapi'],
  })
  .input(z.object({ params: zGetAppsByAppIdFormHumanInputByFormTokenPath }))
  .output(zGetAppsByAppIdFormHumanInputByFormTokenResponse)

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const post2 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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: get6,
  post: post2,
}

export const humanInput = {
  byFormToken,
}

export const form = {
  humanInput,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const post3 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const get7 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getAppsByAppIdTasksByTaskIdEvents',
    path: '/apps/{app_id}/tasks/{task_id}/events',
    tags: ['openapi'],
  })
  .input(z.object({ params: zGetAppsByAppIdTasksByTaskIdEventsPath }))
  .output(zGetAppsByAppIdTasksByTaskIdEventsResponse)

export const events = {
  get: get7,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const post4 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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 = {
  describe,
  files,
  form,
  run,
  tasks,
}

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

export const apps = {
  get: get8,
  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 get9 = 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: get9,
}

/**
 * Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.
 *
 * @deprecated
 */
export const post8 = oc
  .route({
    deprecated: true,
    description:
      'Generated contract types may be inaccurate because backend OpenAPI annotations are incomplete. Do not migrate callers until the generated contract is accurate.',
    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 get10 = oc
  .route({
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getPermittedExternalApps',
    path: '/permitted-external-apps',
    tags: ['openapi'],
  })
  .output(zGetPermittedExternalAppsResponse)

export const permittedExternalApps = {
  get: get10,
}

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 get11 = 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 post9 = 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: get11,
  post: post9,
  byMemberId,
}

export const post10 = 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: post10,
}

export const get12 = 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: get12,
  members,
  switch: switch_,
}

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

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

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