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

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

import {
  zGetOauthAuthorizeByProviderPath,
  zGetOauthAuthorizeByProviderQuery,
  zGetOauthAuthorizeByProviderResponse,
  zGetOauthDataSourceBindingByProviderPath,
  zGetOauthDataSourceBindingByProviderQuery,
  zGetOauthDataSourceBindingByProviderResponse,
  zGetOauthDataSourceByProviderByBindingIdSyncPath,
  zGetOauthDataSourceByProviderByBindingIdSyncResponse,
  zGetOauthDataSourceByProviderPath,
  zGetOauthDataSourceByProviderResponse,
  zGetOauthDataSourceCallbackByProviderPath,
  zGetOauthDataSourceCallbackByProviderQuery,
  zGetOauthDataSourceCallbackByProviderResponse,
  zGetOauthLoginByProviderPath,
  zGetOauthLoginByProviderQuery,
  zGetOauthLoginByProviderResponse,
  zGetOauthPluginByProviderIdDatasourceCallbackPath,
  zGetOauthPluginByProviderIdDatasourceCallbackResponse,
  zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlPath,
  zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlResponse,
  zGetOauthPluginByProviderToolAuthorizationUrlPath,
  zGetOauthPluginByProviderToolAuthorizationUrlResponse,
  zGetOauthPluginByProviderToolCallbackPath,
  zGetOauthPluginByProviderToolCallbackResponse,
  zGetOauthPluginByProviderTriggerCallbackPath,
  zGetOauthPluginByProviderTriggerCallbackResponse,
  zPostOauthProviderAccountResponse,
  zPostOauthProviderAuthorizeResponse,
  zPostOauthProviderResponse,
  zPostOauthProviderTokenResponse,
} from './zod.gen'

/**
 * Handle OAuth callback and complete login process
 *
 * 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:
      'Handle OAuth callback and complete login process\n\nGenerated 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: 'getOauthAuthorizeByProvider',
    path: '/oauth/authorize/{provider}',
    tags: ['console'],
  })
  .input(
    z.object({
      params: zGetOauthAuthorizeByProviderPath,
      query: zGetOauthAuthorizeByProviderQuery.optional(),
    }),
  )
  .output(zGetOauthAuthorizeByProviderResponse)

export const byProvider = {
  get,
}

export const authorize = {
  byProvider,
}

/**
 * Bind OAuth data source with authorization code
 */
export const get2 = oc
  .route({
    description: 'Bind OAuth data source with authorization code',
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getOauthDataSourceBindingByProvider',
    path: '/oauth/data-source/binding/{provider}',
    tags: ['console'],
  })
  .input(
    z.object({
      params: zGetOauthDataSourceBindingByProviderPath,
      query: zGetOauthDataSourceBindingByProviderQuery.optional(),
    }),
  )
  .output(zGetOauthDataSourceBindingByProviderResponse)

export const byProvider2 = {
  get: get2,
}

export const binding = {
  byProvider: byProvider2,
}

/**
 * Handle OAuth callback from data source provider
 *
 * 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 get3 = oc
  .route({
    deprecated: true,
    description:
      'Handle OAuth callback from data source provider\n\nGenerated 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: 'getOauthDataSourceCallbackByProvider',
    path: '/oauth/data-source/callback/{provider}',
    tags: ['console'],
  })
  .input(
    z.object({
      params: zGetOauthDataSourceCallbackByProviderPath,
      query: zGetOauthDataSourceCallbackByProviderQuery.optional(),
    }),
  )
  .output(zGetOauthDataSourceCallbackByProviderResponse)

export const byProvider3 = {
  get: get3,
}

export const callback = {
  byProvider: byProvider3,
}

/**
 * Sync data from OAuth data source
 */
export const get4 = oc
  .route({
    description: 'Sync data from OAuth data source',
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getOauthDataSourceByProviderByBindingIdSync',
    path: '/oauth/data-source/{provider}/{binding_id}/sync',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthDataSourceByProviderByBindingIdSyncPath }))
  .output(zGetOauthDataSourceByProviderByBindingIdSyncResponse)

export const sync = {
  get: get4,
}

export const byBindingId = {
  sync,
}

/**
 * Get OAuth authorization URL for data source provider
 */
export const get5 = oc
  .route({
    description: 'Get OAuth authorization URL for data source provider',
    inputStructure: 'detailed',
    method: 'GET',
    operationId: 'getOauthDataSourceByProvider',
    path: '/oauth/data-source/{provider}',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthDataSourceByProviderPath }))
  .output(zGetOauthDataSourceByProviderResponse)

export const byProvider4 = {
  get: get5,
  byBindingId,
}

export const dataSource = {
  binding,
  callback,
  byProvider: byProvider4,
}

/**
 * Initiate OAuth login process
 *
 * 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:
      'Initiate OAuth login process\n\nGenerated 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: 'getOauthLoginByProvider',
    path: '/oauth/login/{provider}',
    tags: ['console'],
  })
  .input(
    z.object({
      params: zGetOauthLoginByProviderPath,
      query: zGetOauthLoginByProviderQuery.optional(),
    }),
  )
  .output(zGetOauthLoginByProviderResponse)

export const byProvider5 = {
  get: get6,
}

export const login = {
  byProvider: byProvider5,
}

/**
 * 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: 'getOauthPluginByProviderIdDatasourceCallback',
    path: '/oauth/plugin/{provider_id}/datasource/callback',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthPluginByProviderIdDatasourceCallbackPath }))
  .output(zGetOauthPluginByProviderIdDatasourceCallbackResponse)

export const callback2 = {
  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 get8 = 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: 'getOauthPluginByProviderIdDatasourceGetAuthorizationUrl',
    path: '/oauth/plugin/{provider_id}/datasource/get-authorization-url',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlPath }))
  .output(zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlResponse)

export const getAuthorizationUrl = {
  get: get8,
}

export const datasource = {
  callback: callback2,
  getAuthorizationUrl,
}

export const byProviderId = {
  datasource,
}

/**
 * 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 get9 = 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: 'getOauthPluginByProviderToolAuthorizationUrl',
    path: '/oauth/plugin/{provider}/tool/authorization-url',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthPluginByProviderToolAuthorizationUrlPath }))
  .output(zGetOauthPluginByProviderToolAuthorizationUrlResponse)

export const authorizationUrl = {
  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 get10 = 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: 'getOauthPluginByProviderToolCallback',
    path: '/oauth/plugin/{provider}/tool/callback',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthPluginByProviderToolCallbackPath }))
  .output(zGetOauthPluginByProviderToolCallbackResponse)

export const callback3 = {
  get: get10,
}

export const tool = {
  authorizationUrl,
  callback: callback3,
}

/**
 * Handle OAuth callback for trigger provider
 *
 * 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 get11 = 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: 'getOauthPluginByProviderTriggerCallback',
    path: '/oauth/plugin/{provider}/trigger/callback',
    summary: 'Handle OAuth callback for trigger provider',
    tags: ['console'],
  })
  .input(z.object({ params: zGetOauthPluginByProviderTriggerCallbackPath }))
  .output(zGetOauthPluginByProviderTriggerCallbackResponse)

export const callback4 = {
  get: get11,
}

export const trigger = {
  callback: callback4,
}

export const byProvider6 = {
  tool,
  trigger,
}

export const plugin = {
  byProviderId,
  byProvider: byProvider6,
}

/**
 * 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 post = 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: 'postOauthProviderAccount',
    path: '/oauth/provider/account',
    tags: ['console'],
  })
  .output(zPostOauthProviderAccountResponse)

export const account = {
  post,
}

/**
 * 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: 'postOauthProviderAuthorize',
    path: '/oauth/provider/authorize',
    tags: ['console'],
  })
  .output(zPostOauthProviderAuthorizeResponse)

export const authorize2 = {
  post: post2,
}

/**
 * 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: 'postOauthProviderToken',
    path: '/oauth/provider/token',
    tags: ['console'],
  })
  .output(zPostOauthProviderTokenResponse)

export const token = {
  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 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: 'postOauthProvider',
    path: '/oauth/provider',
    tags: ['console'],
  })
  .output(zPostOauthProviderResponse)

export const provider = {
  post: post4,
  account,
  authorize: authorize2,
  token,
}

export const oauth = {
  authorize,
  dataSource,
  login,
  plugin,
  provider,
}

export const contract = {
  oauth,
}
