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

import * as z from 'zod'

/**
 * DatasourceCredentialPayload
 */
export const zDatasourceCredentialPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  name: z.string().max(100).nullish(),
})

/**
 * SimpleResultResponse
 */
export const zSimpleResultResponse = z.object({
  result: z.string(),
})

/**
 * DatasourceCustomClientPayload
 */
export const zDatasourceCustomClientPayload = z.object({
  client_params: z.record(z.string(), z.unknown()).nullish(),
  enable_oauth_custom_client: z.boolean().nullish(),
})

/**
 * DatasourceDefaultPayload
 */
export const zDatasourceDefaultPayload = z.object({
  id: z.string(),
})

/**
 * DatasourceCredentialDeletePayload
 */
export const zDatasourceCredentialDeletePayload = z.object({
  credential_id: z.string(),
})

/**
 * DatasourceCredentialUpdatePayload
 */
export const zDatasourceCredentialUpdatePayload = z.object({
  credential_id: z.string(),
  credentials: z.record(z.string(), z.unknown()).nullish(),
  name: z.string().max(100).nullish(),
})

/**
 * DatasourceUpdateNamePayload
 */
export const zDatasourceUpdateNamePayload = z.object({
  credential_id: z.string(),
  name: z.string().max(100),
})

/**
 * DatasourceCredentialResponse
 */
export const zDatasourceCredentialResponse = z.object({
  avatar_url: z.string().nullable(),
  credential: z.record(z.string(), z.unknown()),
  id: z.string(),
  is_default: z.boolean(),
  name: z.string(),
  type: z.string(),
})

/**
 * DatasourceCredentialListResponse
 */
export const zDatasourceCredentialListResponse = z.object({
  result: z.array(zDatasourceCredentialResponse),
})

/**
 * I18nObject
 *
 * Model class for i18n object.
 */
export const zI18nObject = z.object({
  en_US: z.string(),
  ja_JP: z.string().nullish(),
  pt_BR: z.string().nullish(),
  zh_Hans: z.string().nullish(),
})

/**
 * Option
 */
export const zOption = z.object({
  label: zI18nObject,
  value: z.string(),
})

/**
 * AppSelectorScope
 */
export const zAppSelectorScope = z.enum(['all', 'chat', 'completion', 'workflow'])

/**
 * ModelSelectorScope
 */
export const zModelSelectorScope = z.enum([
  'llm',
  'moderation',
  'rerank',
  'speech2text',
  'text-embedding',
  'tts',
  'vision',
])

/**
 * ToolSelectorScope
 */
export const zToolSelectorScope = z.enum(['all', 'builtin', 'custom', 'workflow'])

/**
 * ProviderConfigType
 */
export const zProviderConfigType = z.enum([
  'app-selector',
  'array[tools]',
  'boolean',
  'model-selector',
  'secret-input',
  'select',
  'text-input',
])

/**
 * ProviderConfig
 *
 * Model class for common provider settings like credentials
 */
export const zProviderConfig = z.object({
  default: z.union([z.int(), z.string(), z.number(), z.boolean()]).nullish(),
  help: zI18nObject.nullish(),
  label: zI18nObject.nullish(),
  multiple: z.boolean().optional().default(false),
  name: z.string(),
  options: z.array(zOption).nullish(),
  placeholder: zI18nObject.nullish(),
  required: z.boolean().optional().default(false),
  scope: z.union([zAppSelectorScope, zModelSelectorScope, zToolSelectorScope]).nullish(),
  type: zProviderConfigType,
  url: z.string().nullish(),
})

/**
 * DatasourceOAuthSchemaResponse
 */
export const zDatasourceOAuthSchemaResponse = z.object({
  client_schema: z.array(zProviderConfig),
  credentials_schema: z.array(zProviderConfig),
  is_oauth_custom_client_enabled: z.boolean(),
  is_system_oauth_params_exists: z.boolean(),
  oauth_custom_client_params: z.record(z.string(), z.unknown()).nullable(),
  redirect_uri: z.string(),
})

/**
 * DatasourceProviderAuthResponse
 */
export const zDatasourceProviderAuthResponse = z.object({
  author: z.string(),
  credential_schema: z.array(zProviderConfig),
  credentials_list: z.array(zDatasourceCredentialResponse),
  description: zI18nObject,
  icon: z.string(),
  label: zI18nObject,
  name: z.string(),
  oauth_schema: zDatasourceOAuthSchemaResponse.nullable(),
  plugin_id: z.string(),
  plugin_unique_identifier: z.string(),
  provider: z.string(),
})

/**
 * DatasourceProviderAuthListResponse
 */
export const zDatasourceProviderAuthListResponse = z.object({
  result: z.array(zDatasourceProviderAuthResponse),
})

/**
 * Default datasource credentials retrieved successfully
 */
export const zGetAuthPluginDatasourceDefaultListResponse = zDatasourceProviderAuthListResponse

/**
 * Datasource credentials retrieved successfully
 */
export const zGetAuthPluginDatasourceListResponse = zDatasourceProviderAuthListResponse

export const zGetAuthPluginDatasourceByProviderIdPath = z.object({
  provider_id: z.string(),
})

/**
 * Datasource credentials retrieved successfully
 */
export const zGetAuthPluginDatasourceByProviderIdResponse = zDatasourceCredentialListResponse

export const zPostAuthPluginDatasourceByProviderIdBody = zDatasourceCredentialPayload

export const zPostAuthPluginDatasourceByProviderIdPath = z.object({
  provider_id: z.string(),
})

/**
 * Datasource credential created successfully
 */
export const zPostAuthPluginDatasourceByProviderIdResponse = zSimpleResultResponse

export const zDeleteAuthPluginDatasourceByProviderIdCustomClientPath = z.object({
  provider_id: z.string(),
})

/**
 * Success
 */
export const zDeleteAuthPluginDatasourceByProviderIdCustomClientResponse = zSimpleResultResponse

export const zPostAuthPluginDatasourceByProviderIdCustomClientBody = zDatasourceCustomClientPayload

export const zPostAuthPluginDatasourceByProviderIdCustomClientPath = z.object({
  provider_id: z.string(),
})

/**
 * Datasource OAuth custom client saved successfully
 */
export const zPostAuthPluginDatasourceByProviderIdCustomClientResponse = zSimpleResultResponse

export const zPostAuthPluginDatasourceByProviderIdDefaultBody = zDatasourceDefaultPayload

export const zPostAuthPluginDatasourceByProviderIdDefaultPath = z.object({
  provider_id: z.string(),
})

/**
 * Success
 */
export const zPostAuthPluginDatasourceByProviderIdDefaultResponse = zSimpleResultResponse

export const zPostAuthPluginDatasourceByProviderIdDeleteBody = zDatasourceCredentialDeletePayload

export const zPostAuthPluginDatasourceByProviderIdDeletePath = z.object({
  provider_id: z.string(),
})

/**
 * Success
 */
export const zPostAuthPluginDatasourceByProviderIdDeleteResponse = zSimpleResultResponse

export const zPostAuthPluginDatasourceByProviderIdUpdateBody = zDatasourceCredentialUpdatePayload

export const zPostAuthPluginDatasourceByProviderIdUpdatePath = z.object({
  provider_id: z.string(),
})

/**
 * Datasource credential updated successfully
 */
export const zPostAuthPluginDatasourceByProviderIdUpdateResponse = zSimpleResultResponse

export const zPostAuthPluginDatasourceByProviderIdUpdateNameBody = zDatasourceUpdateNamePayload

export const zPostAuthPluginDatasourceByProviderIdUpdateNamePath = z.object({
  provider_id: z.string(),
})

/**
 * Success
 */
export const zPostAuthPluginDatasourceByProviderIdUpdateNameResponse = zSimpleResultResponse
