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

import * as z from 'zod'

/**
 * ApiBaseUrlResponse
 */
export const zApiBaseUrlResponse = z.object({
  api_base_url: z.string(),
})

/**
 * ApiKeyItem
 */
export const zApiKeyItem = z.object({
  created_at: z.int().nullish(),
  id: z.string(),
  last_used_at: z.int().nullish(),
  token: z.string(),
  type: z.string(),
})

/**
 * ApiKeyList
 */
export const zApiKeyList = z.object({
  data: z.array(zApiKeyItem),
})

/**
 * SegmentBatchImportStatusResponse
 */
export const zSegmentBatchImportStatusResponse = z.object({
  job_id: z.string(),
  job_status: z.string(),
})

/**
 * BatchImportPayload
 */
export const zBatchImportPayload = z.object({
  upload_file_id: z.string(),
})

/**
 * ExternalDatasetCreatePayload
 */
export const zExternalDatasetCreatePayload = z.object({
  description: z.string().max(400).nullish(),
  external_knowledge_api_id: z.string(),
  external_knowledge_id: z.string(),
  external_retrieval_model: z.record(z.string(), z.unknown()).nullish(),
  name: z.string().min(1).max(100),
})

/**
 * ExternalKnowledgeApiPayload
 */
export const zExternalKnowledgeApiPayload = z.object({
  name: z.string().min(1).max(40),
  settings: z.record(z.string(), z.unknown()),
})

/**
 * UsageCountResponse
 */
export const zUsageCountResponse = z.object({
  count: z.int(),
  is_using: z.boolean(),
})

/**
 * IndexingEstimatePayload
 */
export const zIndexingEstimatePayload = z.object({
  dataset_id: z.string().nullish(),
  doc_form: z.string().optional().default('text_model'),
  doc_language: z.string().optional().default('English'),
  indexing_technique: z.string(),
  info_list: z.record(z.string(), z.unknown()),
  process_rule: z.record(z.string(), z.unknown()),
})

/**
 * NotionEstimatePayload
 */
export const zNotionEstimatePayload = z.object({
  doc_form: z.string().optional().default('text_model'),
  doc_language: z.string().optional().default('English'),
  notion_info_list: z.array(z.record(z.string(), z.unknown())),
  process_rule: z.record(z.string(), z.unknown()),
})

/**
 * RetrievalSettingResponse
 */
export const zRetrievalSettingResponse = z.object({
  retrieval_method: z.array(z.string()),
})

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

/**
 * AutoDisableLogsResponse
 */
export const zAutoDisableLogsResponse = z.object({
  count: z.int(),
  document_ids: z.array(z.string()),
})

/**
 * DocumentBatchDownloadZipPayload
 *
 * Request payload for bulk downloading documents as a zip archive.
 */
export const zDocumentBatchDownloadZipPayload = z.object({
  document_ids: z.array(z.uuid()).min(1).max(100),
})

/**
 * GenerateSummaryPayload
 */
export const zGenerateSummaryPayload = z.object({
  document_list: z.array(z.string()),
})

/**
 * UrlResponse
 */
export const zUrlResponse = z.object({
  url: z.string(),
})

/**
 * DocumentStatusResponse
 */
export const zDocumentStatusResponse = z.object({
  cleaning_completed_at: z.int().nullable(),
  completed_at: z.int().nullable(),
  completed_segments: z.int().nullish(),
  error: z.string().nullable(),
  id: z.string(),
  indexing_status: z.string(),
  parsing_completed_at: z.int().nullable(),
  paused_at: z.int().nullable(),
  processing_started_at: z.int().nullable(),
  splitting_completed_at: z.int().nullable(),
  stopped_at: z.int().nullable(),
  total_segments: z.int().nullish(),
})

/**
 * DocumentStatusListResponse
 */
export const zDocumentStatusListResponse = z.object({
  data: z.array(zDocumentStatusResponse),
})

/**
 * DocumentMetadataUpdatePayload
 */
export const zDocumentMetadataUpdatePayload = z.object({
  doc_metadata: z.unknown().optional(),
  doc_type: z.string().nullish(),
})

/**
 * SimpleResultMessageResponse
 */
export const zSimpleResultMessageResponse = z.object({
  message: z.string(),
  result: z.string(),
})

/**
 * DocumentRenamePayload
 */
export const zDocumentRenamePayload = z.object({
  name: z.string(),
})

/**
 * SegmentCreatePayload
 */
export const zSegmentCreatePayload = z.object({
  answer: z.string().nullish(),
  attachment_ids: z.array(z.string()).nullish(),
  content: z.string(),
  keywords: z.array(z.string()).nullish(),
})

/**
 * SegmentUpdatePayload
 */
export const zSegmentUpdatePayload = z.object({
  answer: z.string().nullish(),
  attachment_ids: z.array(z.string()).nullish(),
  content: z.string(),
  keywords: z.array(z.string()).nullish(),
  regenerate_child_chunks: z.boolean().optional().default(false),
  summary: z.string().nullish(),
})

/**
 * ChildChunkCreatePayload
 */
export const zChildChunkCreatePayload = z.object({
  content: z.string(),
})

/**
 * ChildChunkUpdatePayload
 */
export const zChildChunkUpdatePayload = z.object({
  content: z.string(),
})

/**
 * ErrorDocsResponse
 */
export const zErrorDocsResponse = z.object({
  data: z.array(zDocumentStatusResponse),
  total: z.int(),
})

/**
 * ExternalHitTestingPayload
 */
export const zExternalHitTestingPayload = z.object({
  external_retrieval_model: z.record(z.string(), z.unknown()).nullish(),
  metadata_filtering_conditions: z.record(z.string(), z.unknown()).nullish(),
  query: z.string(),
})

/**
 * MetadataArgs
 */
export const zMetadataArgs = z.object({
  name: z.string(),
  type: z.enum(['number', 'string', 'time']),
})

/**
 * DatasetMetadataResponse
 */
export const zDatasetMetadataResponse = z.object({
  id: z.string(),
  name: z.string(),
  type: z.string(),
})

/**
 * MetadataUpdatePayload
 */
export const zMetadataUpdatePayload = z.object({
  name: z.string(),
})

/**
 * PartialMemberListResponse
 */
export const zPartialMemberListResponse = z.object({
  data: z.array(z.string()),
})

/**
 * DocumentRetryPayload
 */
export const zDocumentRetryPayload = z.object({
  document_ids: z.array(z.string()),
})

/**
 * UsageCheckResponse
 */
export const zUsageCheckResponse = z.object({
  is_using: z.boolean(),
})

/**
 * PermissionEnum
 *
 * Shared permission levels for resources (datasets, credentials, etc.)
 */
export const zPermissionEnum = z.enum(['all_team_members', 'only_me', 'partial_members'])

/**
 * DatasetCreatePayload
 */
export const zDatasetCreatePayload = z.object({
  description: z.string().max(400).optional().default(''),
  external_knowledge_api_id: z.string().nullish(),
  external_knowledge_id: z.string().nullish(),
  indexing_technique: z.string().nullish(),
  name: z.string().min(1).max(40),
  permission: zPermissionEnum.nullish().default('only_me'),
  provider: z.string().optional().default('vendor'),
})

/**
 * DatasetUpdatePayload
 */
export const zDatasetUpdatePayload = z.object({
  description: z.string().max(400).nullish(),
  embedding_model: z.string().nullish(),
  embedding_model_provider: z.string().nullish(),
  external_knowledge_api_id: z.string().nullish(),
  external_knowledge_id: z.string().nullish(),
  external_retrieval_model: z.record(z.string(), z.unknown()).nullish(),
  icon_info: z.record(z.string(), z.unknown()).nullish(),
  indexing_technique: z.string().nullish(),
  is_multimodal: z.boolean().nullish().default(false),
  name: z.string().min(1).max(40).nullish(),
  partial_member_list: z.array(z.record(z.string(), z.string())).nullish(),
  permission: zPermissionEnum.nullish(),
  retrieval_model: z.record(z.string(), z.unknown()).nullish(),
  summary_index_setting: z.record(z.string(), z.unknown()).nullish(),
})

/**
 * DatasetDocMetadataResponse
 */
export const zDatasetDocMetadataResponse = z.object({
  id: z.string(),
  name: z.string(),
  type: z.string(),
})

/**
 * DatasetExternalKnowledgeInfoResponse
 */
export const zDatasetExternalKnowledgeInfoResponse = z.object({
  external_knowledge_api_endpoint: z.string().nullish(),
  external_knowledge_api_id: z.string().nullish(),
  external_knowledge_api_name: z.string().nullish(),
  external_knowledge_id: z.string().nullish(),
})

/**
 * DatasetExternalRetrievalModelResponse
 */
export const zDatasetExternalRetrievalModelResponse = z.object({
  score_threshold: z.number().nullish(),
  score_threshold_enabled: z.boolean().nullish(),
  top_k: z.int(),
})

/**
 * DatasetIconInfoResponse
 */
export const zDatasetIconInfoResponse = z.object({
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: z.string().nullish(),
  icon_url: z.string().nullish(),
})

/**
 * DatasetSummaryIndexSettingResponse
 */
export const zDatasetSummaryIndexSettingResponse = z.object({
  enable: z.boolean().nullish(),
  model_name: z.string().nullish(),
  model_provider_name: z.string().nullish(),
  summary_prompt: z.string().nullish(),
})

/**
 * DatasetTagResponse
 */
export const zDatasetTagResponse = z.object({
  id: z.string(),
  name: z.string(),
  type: z.string(),
})

/**
 * ExternalKnowledgeApiBindingResponse
 */
export const zExternalKnowledgeApiBindingResponse = z.object({
  id: z.string(),
  name: z.string(),
})

/**
 * ExternalKnowledgeApiResponse
 */
export const zExternalKnowledgeApiResponse = z.object({
  created_at: z.string(),
  created_by: z.string(),
  dataset_bindings: z.array(zExternalKnowledgeApiBindingResponse),
  description: z.string(),
  id: z.string(),
  name: z.string(),
  settings: z.record(z.string(), z.unknown()).nullable(),
  tenant_id: z.string(),
})

/**
 * ExternalKnowledgeApiListResponse
 */
export const zExternalKnowledgeApiListResponse = z.object({
  data: z.array(zExternalKnowledgeApiResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int().nullable(),
})

/**
 * PreviewDetail
 */
export const zPreviewDetail = z.object({
  child_chunks: z.array(z.string()).nullish(),
  content: z.string(),
  summary: z.string().nullish(),
})

/**
 * QAPreviewDetail
 */
export const zQaPreviewDetail = z.object({
  answer: z.string(),
  question: z.string(),
})

/**
 * IndexingEstimateResponse
 */
export const zIndexingEstimateResponse = z.object({
  currency: z.string(),
  preview: z.array(zPreviewDetail),
  qa_preview: z.array(zQaPreviewDetail).nullish(),
  tokens: z.int(),
  total_price: z.union([z.number(), z.int()]),
  total_segments: z.int(),
})

/**
 * IndexingEstimate
 */
export const zIndexingEstimate = z.object({
  preview: z.array(zPreviewDetail),
  qa_preview: z.array(zQaPreviewDetail).nullish(),
  total_segments: z.int(),
})

/**
 * DatasetResponse
 */
export const zDatasetResponse = z.object({
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  data_source_type: z.string().nullish(),
  description: z.string().nullish(),
  id: z.string(),
  indexing_technique: z.string().nullish(),
  name: z.string(),
  permission: z.string().nullish(),
})

/**
 * DatasetMetadataBuiltInFieldResponse
 */
export const zDatasetMetadataBuiltInFieldResponse = z.object({
  name: z.string(),
  type: z.string(),
})

/**
 * DatasetMetadataBuiltInFieldsResponse
 */
export const zDatasetMetadataBuiltInFieldsResponse = z.object({
  fields: z.array(zDatasetMetadataBuiltInFieldResponse),
})

/**
 * ProcessRuleMode
 *
 * Dataset Process Rule Mode
 */
export const zProcessRuleMode = z.enum(['automatic', 'custom', 'hierarchical'])

/**
 * DocumentMetadataResponse
 */
export const zDocumentMetadataResponse = z.object({
  id: z.string(),
  name: z.string(),
  type: z.string(),
  value: z.union([z.string(), z.int(), z.number(), z.boolean()]).nullish(),
})

/**
 * DocumentDetailResponse
 */
export const zDocumentDetailResponse = z.object({
  archived: z.boolean().nullish(),
  average_segment_length: z.number().nullish(),
  completed_at: z.int().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  created_from: z.string().nullish(),
  data_source_detail_dict: z.unknown().optional(),
  data_source_info: z.unknown().optional(),
  data_source_type: z.string().nullish(),
  dataset_process_rule: z.unknown().optional(),
  dataset_process_rule_id: z.string().nullish(),
  disabled_at: z.int().nullish(),
  disabled_by: z.string().nullish(),
  display_status: z.string().nullish(),
  doc_form: z.string().nullish(),
  doc_language: z.string().nullish(),
  doc_metadata: z.array(zDocumentMetadataResponse).nullish(),
  doc_type: z.string().nullish(),
  document_process_rule: z.unknown().optional(),
  enabled: z.boolean().nullish(),
  error: z.string().nullish(),
  hit_count: z.int().nullish(),
  id: z.string(),
  indexing_latency: z.number().nullish(),
  indexing_status: z.string().nullish(),
  name: z.string().nullish(),
  need_summary: z.boolean().nullish(),
  position: z.int().nullish(),
  segment_count: z.int().nullish(),
  tokens: z.int().nullish(),
  updated_at: z.int().nullish(),
})

/**
 * DocumentResponse
 */
export const zDocumentResponse = z.object({
  archived: z.boolean().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  created_from: z.string().nullish(),
  data_source_detail_dict: z.unknown().optional(),
  data_source_info: z.unknown().optional(),
  data_source_type: z.string().nullish(),
  dataset_process_rule_id: z.string().nullish(),
  disabled_at: z.int().nullish(),
  disabled_by: z.string().nullish(),
  display_status: z.string().nullish(),
  doc_form: z.string().nullish(),
  doc_metadata: z.array(zDocumentMetadataResponse).optional(),
  enabled: z.boolean().nullish(),
  error: z.string().nullish(),
  hit_count: z.int().nullish(),
  id: z.string(),
  indexing_status: z.string().nullish(),
  name: z.string(),
  need_summary: z.boolean().nullish(),
  position: z.int().nullish(),
  summary_index_status: z.string().nullish(),
  tokens: z.int().nullish(),
  word_count: z.int().nullish(),
})

/**
 * DatasetAndDocumentResponse
 */
export const zDatasetAndDocumentResponse = z.object({
  batch: z.string(),
  dataset: zDatasetResponse,
  documents: z.array(zDocumentResponse),
})

/**
 * DocumentWithSegmentsResponse
 */
export const zDocumentWithSegmentsResponse = z.object({
  archived: z.boolean().nullish(),
  completed_segments: z.int().nullish(),
  created_at: z.int().nullish(),
  created_by: z.string().nullish(),
  created_from: z.string().nullish(),
  data_source_detail_dict: z.unknown().optional(),
  data_source_info: z.unknown().optional(),
  data_source_type: z.string().nullish(),
  dataset_process_rule_id: z.string().nullish(),
  disabled_at: z.int().nullish(),
  disabled_by: z.string().nullish(),
  display_status: z.string().nullish(),
  doc_form: z.string().nullish(),
  doc_metadata: z.array(zDocumentMetadataResponse).optional(),
  enabled: z.boolean().nullish(),
  error: z.string().nullish(),
  hit_count: z.int().nullish(),
  id: z.string(),
  indexing_status: z.string().nullish(),
  name: z.string(),
  need_summary: z.boolean().nullish(),
  position: z.int().nullish(),
  process_rule_dict: z.unknown().optional(),
  summary_index_status: z.string().nullish(),
  tokens: z.int().nullish(),
  total_segments: z.int().nullish(),
  word_count: z.int().nullish(),
})

/**
 * DocumentWithSegmentsListResponse
 */
export const zDocumentWithSegmentsListResponse = z.object({
  data: z.array(zDocumentWithSegmentsResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
})

export const zJsonValue = z.unknown()

/**
 * DocumentPipelineExecutionLogResponse
 */
export const zDocumentPipelineExecutionLogResponse = z.object({
  datasource_info: zJsonValue.nullish(),
  datasource_node_id: z.string().nullish(),
  datasource_type: z.string().nullish(),
  input_data: zJsonValue.nullish(),
})

/**
 * ChildChunkResponse
 */
export const zChildChunkResponse = z.object({
  content: z.string(),
  created_at: z.int(),
  id: z.string(),
  position: z.int(),
  segment_id: z.string(),
  type: z.string(),
  updated_at: z.int(),
  word_count: z.int(),
})

/**
 * ChildChunkListResponse
 */
export const zChildChunkListResponse = z.object({
  data: z.array(zChildChunkResponse),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
  total_pages: z.int(),
})

/**
 * ChildChunkBatchUpdateResponse
 */
export const zChildChunkBatchUpdateResponse = z.object({
  data: z.array(zChildChunkResponse),
})

/**
 * ChildChunkDetailResponse
 */
export const zChildChunkDetailResponse = z.object({
  data: zChildChunkResponse,
})

/**
 * ChildChunkUpdateArgs
 */
export const zChildChunkUpdateArgs = z.object({
  content: z.string(),
  id: z.string().nullish(),
})

/**
 * ChildChunkBatchUpdatePayload
 */
export const zChildChunkBatchUpdatePayload = z.object({
  chunks: z.array(zChildChunkUpdateArgs),
})

/**
 * SummaryEntryResponse
 */
export const zSummaryEntryResponse = z.object({
  created_at: z.int().nullish(),
  error: z.string().nullish(),
  segment_id: z.string(),
  segment_position: z.int(),
  status: z.string(),
  summary_preview: z.string().nullish(),
  updated_at: z.int().nullish(),
})

/**
 * SummaryStatusResponse
 */
export const zSummaryStatusResponse = z.object({
  completed: z.int().optional().default(0),
  error: z.int().optional().default(0),
  generating: z.int().optional().default(0),
  not_started: z.int().optional().default(0),
  timeout: z.int().optional().default(0),
})

/**
 * DocumentSummaryStatusResponse
 */
export const zDocumentSummaryStatusResponse = z.object({
  summaries: z.array(zSummaryEntryResponse),
  summary_status: zSummaryStatusResponse,
  total_segments: z.int(),
})

/**
 * ExternalHitTestingQueryResponse
 */
export const zExternalHitTestingQueryResponse = z.object({
  content: z.string(),
})

/**
 * ExternalHitTestingRecordResponse
 */
export const zExternalHitTestingRecordResponse = z.object({
  content: z.string().nullish(),
  metadata: z.record(z.string(), z.unknown()).nullish(),
  score: z.number().nullish(),
  title: z.string().nullish(),
})

/**
 * ExternalHitTestingResponse
 */
export const zExternalHitTestingResponse = z.object({
  query: zExternalHitTestingQueryResponse,
  records: z.array(zExternalHitTestingRecordResponse),
})

/**
 * HitTestingQuery
 */
export const zHitTestingQuery = z.object({
  content: z.string(),
})

/**
 * DatasetMetadataListItemResponse
 */
export const zDatasetMetadataListItemResponse = z.object({
  count: z.int().optional().default(0),
  id: z.string(),
  name: z.string(),
  type: z.string(),
})

/**
 * DatasetMetadataListResponse
 */
export const zDatasetMetadataListResponse = z.object({
  built_in_field_enabled: z.boolean(),
  doc_metadata: z.array(zDatasetMetadataListItemResponse),
})

/**
 * RelatedAppResponse
 */
export const zRelatedAppResponse = z.object({
  description: z.string(),
  icon: z.string().nullable(),
  icon_background: z.string().nullable(),
  icon_type: z.string().nullable(),
  icon_url: z.string().nullish(),
  id: z.string(),
  mode: z.string(),
  name: z.string(),
})

/**
 * RelatedAppListResponse
 */
export const zRelatedAppListResponse = z.object({
  data: z.array(zRelatedAppResponse),
  total: z.int(),
})

/**
 * DatasetRerankingModelResponse
 */
export const zDatasetRerankingModelResponse = z.object({
  reranking_model_name: z.string().nullish(),
  reranking_provider_name: z.string().nullish(),
})

/**
 * RerankingModel
 */
export const zRerankingModel = z.object({
  reranking_model_name: z.string().nullish(),
  reranking_provider_name: z.string().nullish(),
})

/**
 * RetrievalMethod
 */
export const zRetrievalMethod = z.enum([
  'full_text_search',
  'hybrid_search',
  'keyword_search',
  'semantic_search',
])

/**
 * PreProcessingRule
 */
export const zPreProcessingRule = z.object({
  enabled: z.boolean(),
  id: z.enum(['remove_extra_spaces', 'remove_stopwords', 'remove_urls_emails']),
})

/**
 * Segmentation
 */
export const zSegmentation = z.object({
  chunk_overlap: z.int().optional().default(0),
  max_tokens: z.int(),
  separator: z.string().optional().default('\n'),
})

/**
 * Rule
 */
export const zRule = z.object({
  parent_mode: z.enum(['full-doc', 'paragraph']).nullish(),
  pre_processing_rules: z.array(zPreProcessingRule).nullish(),
  segmentation: zSegmentation.nullish(),
  subchunk_segmentation: zSegmentation.nullish(),
})

/**
 * ProcessRuleResponse
 */
export const zProcessRuleResponse = z.object({
  limits: z.record(z.string(), z.unknown()),
  mode: zProcessRuleMode,
  rules: zRule.nullish(),
})

/**
 * ProcessRule
 */
export const zProcessRule = z.object({
  mode: zProcessRuleMode,
  rules: zRule.nullish(),
})

/**
 * MetadataDetail
 */
export const zMetadataDetail = z.object({
  id: z.string(),
  name: z.string(),
  value: z.union([z.string(), z.int(), z.number()]).nullish(),
})

/**
 * DocumentMetadataOperation
 */
export const zDocumentMetadataOperation = z.object({
  document_id: z.string(),
  metadata_list: z.array(zMetadataDetail),
  partial_update: z.boolean().optional().default(false),
})

/**
 * MetadataOperationData
 *
 * Metadata operation data
 */
export const zMetadataOperationData = z.object({
  operation_data: z.array(zDocumentMetadataOperation),
})

/**
 * SegmentAttachmentResponse
 */
export const zSegmentAttachmentResponse = z.object({
  extension: z.string(),
  id: z.string(),
  mime_type: z.string().nullable(),
  name: z.string(),
  size: z.int(),
  source_url: z.string(),
})

/**
 * SegmentResponse
 */
export const zSegmentResponse = z.object({
  answer: z.string().nullable(),
  attachments: z.array(zSegmentAttachmentResponse),
  child_chunks: z.array(zChildChunkResponse),
  completed_at: z.int().nullable(),
  content: z.string(),
  created_at: z.int(),
  created_by: z.string(),
  disabled_at: z.int().nullable(),
  disabled_by: z.string().nullable(),
  document_id: z.string(),
  enabled: z.boolean(),
  error: z.string().nullable(),
  hit_count: z.int(),
  id: z.string(),
  index_node_hash: z.string().nullable(),
  index_node_id: z.string().nullable(),
  indexing_at: z.int().nullable(),
  keywords: z.array(z.string()).nullable(),
  position: z.int(),
  sign_content: z.string(),
  status: z.string(),
  stopped_at: z.int().nullable(),
  summary: z.string().nullable(),
  tokens: z.int(),
  updated_at: z.int(),
  updated_by: z.string().nullable(),
  word_count: z.int(),
})

/**
 * SegmentDetailResponse
 */
export const zSegmentDetailResponse = z.object({
  data: zSegmentResponse,
  doc_form: z.string(),
})

/**
 * ConsoleSegmentListResponse
 */
export const zConsoleSegmentListResponse = z.object({
  data: z.array(zSegmentResponse),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
  total_pages: z.int(),
})

/**
 * HitTestingChildChunk
 */
export const zHitTestingChildChunk = z.object({
  content: z.string(),
  id: z.string(),
  position: z.int(),
  score: z.number(),
})

/**
 * HitTestingFile
 */
export const zHitTestingFile = z.object({
  extension: z.string(),
  id: z.string(),
  mime_type: z.string(),
  name: z.string(),
  size: z.int(),
  source_url: z.string(),
})

/**
 * DatasetKeywordSettingResponse
 */
export const zDatasetKeywordSettingResponse = z.object({
  keyword_weight: z.number().nullish(),
})

/**
 * DatasetVectorSettingResponse
 */
export const zDatasetVectorSettingResponse = z.object({
  embedding_model_name: z.string().nullish(),
  embedding_provider_name: z.string().nullish(),
  vector_weight: z.number().nullish(),
})

/**
 * DatasetWeightedScoreResponse
 */
export const zDatasetWeightedScoreResponse = z.object({
  keyword_setting: zDatasetKeywordSettingResponse.optional(),
  vector_setting: zDatasetVectorSettingResponse.optional(),
  weight_type: z.string().nullish(),
})

/**
 * DatasetRetrievalModelResponse
 */
export const zDatasetRetrievalModelResponse = z.object({
  reranking_enable: z.boolean(),
  reranking_mode: z.string().nullish(),
  reranking_model: zDatasetRerankingModelResponse.optional(),
  score_threshold: z.number().nullish(),
  score_threshold_enabled: z.boolean(),
  search_method: z.string(),
  top_k: z.int(),
  weights: zDatasetWeightedScoreResponse.nullish(),
})

/**
 * DatasetDetailResponse
 */
export const zDatasetDetailResponse = z.object({
  app_count: z.int(),
  author_name: z.string().nullable(),
  built_in_field_enabled: z.boolean(),
  chunk_structure: z.string().nullable(),
  created_at: z.int(),
  created_by: z.string(),
  data_source_type: z.string().nullable(),
  description: z.string().nullable(),
  doc_form: z.string().nullable(),
  doc_metadata: z.array(zDatasetDocMetadataResponse),
  document_count: z.int(),
  embedding_available: z.boolean().nullish(),
  embedding_model: z.string().nullable(),
  embedding_model_provider: z.string().nullable(),
  enable_api: z.boolean(),
  external_knowledge_info: zDatasetExternalKnowledgeInfoResponse.optional(),
  external_retrieval_model: zDatasetExternalRetrievalModelResponse.nullable(),
  icon_info: zDatasetIconInfoResponse.optional(),
  id: z.string(),
  indexing_technique: z.string().nullable(),
  is_multimodal: z.boolean(),
  is_published: z.boolean(),
  maintainer: z.string().nullish(),
  name: z.string(),
  permission: z.string(),
  permission_keys: z.array(z.string()).optional(),
  pipeline_id: z.string().nullable(),
  provider: z.string(),
  retrieval_model_dict: zDatasetRetrievalModelResponse,
  runtime_mode: z.string().nullable(),
  summary_index_setting: zDatasetSummaryIndexSettingResponse.optional(),
  tags: z.array(zDatasetTagResponse),
  total_available_documents: z.int(),
  total_documents: z.int(),
  updated_at: z.int(),
  updated_by: z.string().nullable(),
  word_count: z.int(),
})

/**
 * DatasetDetailWithPartialMembersResponse
 */
export const zDatasetDetailWithPartialMembersResponse = z.object({
  app_count: z.int(),
  author_name: z.string().nullable(),
  built_in_field_enabled: z.boolean(),
  chunk_structure: z.string().nullable(),
  created_at: z.int(),
  created_by: z.string(),
  data_source_type: z.string().nullable(),
  description: z.string().nullable(),
  doc_form: z.string().nullable(),
  doc_metadata: z.array(zDatasetDocMetadataResponse),
  document_count: z.int(),
  embedding_available: z.boolean().nullish(),
  embedding_model: z.string().nullable(),
  embedding_model_provider: z.string().nullable(),
  enable_api: z.boolean(),
  external_knowledge_info: zDatasetExternalKnowledgeInfoResponse.optional(),
  external_retrieval_model: zDatasetExternalRetrievalModelResponse.nullable(),
  icon_info: zDatasetIconInfoResponse.optional(),
  id: z.string(),
  indexing_technique: z.string().nullable(),
  is_multimodal: z.boolean(),
  is_published: z.boolean(),
  maintainer: z.string().nullish(),
  name: z.string(),
  partial_member_list: z.array(z.string()).nullish(),
  permission: z.string(),
  permission_keys: z.array(z.string()).optional(),
  pipeline_id: z.string().nullable(),
  provider: z.string(),
  retrieval_model_dict: zDatasetRetrievalModelResponse,
  runtime_mode: z.string().nullable(),
  summary_index_setting: zDatasetSummaryIndexSettingResponse.optional(),
  tags: z.array(zDatasetTagResponse),
  total_available_documents: z.int(),
  total_documents: z.int(),
  updated_at: z.int(),
  updated_by: z.string().nullable(),
  word_count: z.int(),
})

/**
 * DatasetListItemResponse
 */
export const zDatasetListItemResponse = z.object({
  app_count: z.int(),
  author_name: z.string().nullable(),
  built_in_field_enabled: z.boolean(),
  chunk_structure: z.string().nullable(),
  created_at: z.int(),
  created_by: z.string(),
  data_source_type: z.string().nullable(),
  description: z.string().nullable(),
  doc_form: z.string().nullable(),
  doc_metadata: z.array(zDatasetDocMetadataResponse),
  document_count: z.int(),
  embedding_available: z.boolean().nullish(),
  embedding_model: z.string().nullable(),
  embedding_model_provider: z.string().nullable(),
  enable_api: z.boolean(),
  external_knowledge_info: zDatasetExternalKnowledgeInfoResponse.optional(),
  external_retrieval_model: zDatasetExternalRetrievalModelResponse.nullable(),
  icon_info: zDatasetIconInfoResponse.optional(),
  id: z.string(),
  indexing_technique: z.string().nullable(),
  is_multimodal: z.boolean(),
  is_published: z.boolean(),
  maintainer: z.string().nullish(),
  name: z.string(),
  partial_member_list: z.array(z.string()),
  permission: z.string(),
  permission_keys: z.array(z.string()).optional(),
  pipeline_id: z.string().nullable(),
  provider: z.string(),
  retrieval_model_dict: zDatasetRetrievalModelResponse,
  runtime_mode: z.string().nullable(),
  summary_index_setting: zDatasetSummaryIndexSettingResponse.optional(),
  tags: z.array(zDatasetTagResponse),
  total_available_documents: z.int(),
  total_documents: z.int(),
  updated_at: z.int(),
  updated_by: z.string().nullable(),
  word_count: z.int(),
})

/**
 * DatasetListResponse
 */
export const zDatasetListResponse = z.object({
  data: z.array(zDatasetListItemResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
})

/**
 * FileInfo
 */
export const zFileInfo = z.object({
  file_ids: z.array(z.string()),
})

/**
 * WebsiteInfo
 */
export const zWebsiteInfo = z.object({
  job_id: z.string(),
  only_main_content: z.boolean().optional().default(true),
  provider: z.string(),
  urls: z.array(z.string()),
})

/**
 * Condition
 *
 * Condition detail
 */
export const zCondition = z.object({
  comparison_operator: z.enum([
    '<',
    '=',
    '>',
    'after',
    'before',
    'contains',
    'empty',
    'end with',
    'in',
    'is',
    'is not',
    'not contains',
    'not empty',
    'not in',
    'start with',
    '≠',
    '≤',
    '≥',
  ]),
  name: z.string(),
  value: z.union([z.string(), z.array(z.string()), z.number()]).nullish(),
})

/**
 * MetadataFilteringCondition
 *
 * Metadata Filtering Condition.
 */
export const zMetadataFilteringCondition = z.object({
  conditions: z.array(zCondition).nullish(),
  logical_operator: z.enum(['and', 'or']).nullish().default('and'),
})

/**
 * WeightKeywordSetting
 */
export const zWeightKeywordSetting = z.object({
  keyword_weight: z.number(),
})

/**
 * WeightVectorSetting
 */
export const zWeightVectorSetting = z.object({
  embedding_model_name: z.string(),
  embedding_provider_name: z.string(),
  vector_weight: z.number(),
})

/**
 * WeightModel
 */
export const zWeightModel = z.object({
  keyword_setting: zWeightKeywordSetting.nullish(),
  vector_setting: zWeightVectorSetting.nullish(),
  weight_type: z.enum(['customized', 'keyword_first', 'semantic_first']).nullish(),
})

/**
 * RetrievalModel
 */
export const zRetrievalModel = z.object({
  metadata_filtering_conditions: zMetadataFilteringCondition.nullish(),
  reranking_enable: z.boolean(),
  reranking_mode: z.enum(['reranking_model', 'weighted_score']).nullish(),
  reranking_model: zRerankingModel.nullish(),
  score_threshold: z.number().nullish(),
  score_threshold_enabled: z.boolean(),
  search_method: zRetrievalMethod,
  top_k: z.int(),
  weights: zWeightModel.nullish(),
})

/**
 * HitTestingPayload
 */
export const zHitTestingPayload = z.object({
  attachment_ids: z.array(z.string()).nullish(),
  external_retrieval_model: z
    .object({
      score_threshold: z.number().optional(),
      score_threshold_enabled: z.boolean().optional(),
      top_k: z.int().optional(),
    })
    .nullish(),
  query: z.string().max(250),
  retrieval_model: zRetrievalModel.nullish(),
})

/**
 * HitTestingDocument
 */
export const zHitTestingDocument = z.object({
  data_source_type: z.string(),
  doc_metadata: z.unknown().nullable(),
  doc_type: z.string().nullable(),
  id: z.string(),
  name: z.string(),
})

/**
 * HitTestingSegment
 */
export const zHitTestingSegment = z.object({
  answer: z.string().nullable(),
  completed_at: z.int().nullable(),
  content: z.string(),
  created_at: z.int(),
  created_by: z.string(),
  disabled_at: z.int().nullable(),
  disabled_by: z.string().nullable(),
  document: zHitTestingDocument,
  document_id: z.string(),
  enabled: z.boolean(),
  error: z.string().nullable(),
  hit_count: z.int(),
  id: z.string(),
  index_node_hash: z.string().nullable(),
  index_node_id: z.string().nullable(),
  indexing_at: z.int().nullable(),
  keywords: z.array(z.string()),
  position: z.int(),
  sign_content: z.string().nullable(),
  status: z.string(),
  stopped_at: z.int().nullable(),
  tokens: z.int(),
  word_count: z.int(),
})

/**
 * HitTestingRecord
 */
export const zHitTestingRecord = z.object({
  child_chunks: z.array(zHitTestingChildChunk),
  files: z.array(zHitTestingFile),
  score: z.number().nullable(),
  segment: zHitTestingSegment,
  summary: z.string().nullable(),
  tsne_position: z.unknown().nullable(),
})

/**
 * HitTestingResponse
 */
export const zHitTestingResponse = z.object({
  query: zHitTestingQuery,
  records: z.array(zHitTestingRecord),
})

/**
 * DatasetQueryFileInfoResponse
 */
export const zDatasetQueryFileInfoResponse = z.object({
  extension: z.string(),
  id: z.string(),
  mime_type: z.string(),
  name: z.string(),
  size: z.int(),
  source_url: z.string(),
})

/**
 * DatasetQueryContentResponse
 */
export const zDatasetQueryContentResponse = z.object({
  content: z.string(),
  content_type: z.string(),
  file_info: zDatasetQueryFileInfoResponse.nullish(),
})

/**
 * DatasetQueryDetailResponse
 */
export const zDatasetQueryDetailResponse = z.object({
  created_at: z.int(),
  created_by: z.string(),
  created_by_role: z.string(),
  id: z.string(),
  queries: z.array(zDatasetQueryContentResponse),
  source: z.string(),
  source_app_id: z.string().nullable(),
})

/**
 * DatasetQueryListResponse
 */
export const zDatasetQueryListResponse = z.object({
  data: z.array(zDatasetQueryDetailResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
})

/**
 * NotionIcon
 */
export const zNotionIcon = z.object({
  emoji: z.string().nullish(),
  type: z.string(),
  url: z.string().nullish(),
})

/**
 * NotionPage
 */
export const zNotionPage = z.object({
  page_icon: zNotionIcon.nullish(),
  page_id: z.string(),
  page_name: z.string(),
  type: z.string(),
})

/**
 * NotionInfo
 */
export const zNotionInfo = z.object({
  credential_id: z.string(),
  pages: z.array(zNotionPage),
  workspace_id: z.string(),
})

/**
 * InfoList
 */
export const zInfoList = z.object({
  data_source_type: z.enum(['notion_import', 'upload_file', 'website_crawl']),
  file_info_list: zFileInfo.nullish(),
  notion_info_list: z.array(zNotionInfo).nullish(),
  website_info_list: zWebsiteInfo.nullish(),
})

/**
 * DataSource
 */
export const zDataSource = z.object({
  info_list: zInfoList,
})

/**
 * KnowledgeConfig
 */
export const zKnowledgeConfig = z.object({
  data_source: zDataSource.nullish(),
  doc_form: z
    .enum(['hierarchical_model', 'qa_model', 'text_model'])
    .optional()
    .default('text_model'),
  doc_language: z.string().optional().default('English'),
  duplicate: z.boolean().optional().default(true),
  embedding_model: z.string().nullish(),
  embedding_model_provider: z.string().nullish(),
  indexing_technique: z.enum(['economy', 'high_quality']),
  is_multimodal: z.boolean().optional().default(false),
  name: z.string().nullish(),
  original_document_id: z.string().nullish(),
  process_rule: zProcessRule.nullish(),
  retrieval_model: zRetrievalModel.nullish(),
  summary_index_setting: z
    .object({
      enable: z.boolean().optional(),
      model_name: z.string().optional(),
      model_provider_name: z.string().optional(),
      summary_prompt: z.string().optional(),
    })
    .nullish(),
})

export const zGetDatasetsQuery = z.object({
  ids: z.array(z.string()).optional(),
  include_all: z.boolean().optional().default(false),
  keyword: z.string().optional(),
  limit: z.int().optional().default(20),
  page: z.int().optional().default(1),
  tag_ids: z.array(z.string()).optional(),
})

/**
 * Datasets retrieved successfully
 */
export const zGetDatasetsResponse = zDatasetListResponse

export const zPostDatasetsBody = zDatasetCreatePayload

/**
 * Dataset created successfully
 */
export const zPostDatasetsResponse = zDatasetDetailResponse

/**
 * API base info retrieved successfully
 */
export const zGetDatasetsApiBaseInfoResponse = zApiBaseUrlResponse

/**
 * API keys retrieved successfully
 */
export const zGetDatasetsApiKeysResponse = zApiKeyList

/**
 * API key created successfully
 */
export const zPostDatasetsApiKeysResponse = zApiKeyItem

export const zDeleteDatasetsApiKeysByApiKeyIdPath = z.object({
  api_key_id: z.uuid(),
})

/**
 * API key deleted successfully
 */
export const zDeleteDatasetsApiKeysByApiKeyIdResponse = z.void()

export const zGetDatasetsBatchImportStatusByJobIdPath = z.object({
  job_id: z.uuid(),
})

/**
 * Batch import status
 */
export const zGetDatasetsBatchImportStatusByJobIdResponse = zSegmentBatchImportStatusResponse

export const zPostDatasetsBatchImportStatusByJobIdBody = zBatchImportPayload

export const zPostDatasetsBatchImportStatusByJobIdPath = z.object({
  job_id: z.uuid(),
})

/**
 * Batch import started
 */
export const zPostDatasetsBatchImportStatusByJobIdResponse = zSegmentBatchImportStatusResponse

export const zPostDatasetsExternalBody = zExternalDatasetCreatePayload

/**
 * External dataset created successfully
 */
export const zPostDatasetsExternalResponse = zDatasetDetailResponse

export const zGetDatasetsExternalKnowledgeApiQuery = z.object({
  keyword: z.string().optional(),
  limit: z.int().optional().default(20),
  page: z.int().optional().default(1),
})

/**
 * External API templates retrieved successfully
 */
export const zGetDatasetsExternalKnowledgeApiResponse = zExternalKnowledgeApiListResponse

export const zPostDatasetsExternalKnowledgeApiBody = zExternalKnowledgeApiPayload

/**
 * External API template created successfully
 */
export const zPostDatasetsExternalKnowledgeApiResponse = zExternalKnowledgeApiResponse

export const zDeleteDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdPath = z.object({
  external_knowledge_api_id: z.uuid(),
})

/**
 * External knowledge API deleted successfully
 */
export const zDeleteDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdResponse = z.void()

export const zGetDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdPath = z.object({
  external_knowledge_api_id: z.uuid(),
})

/**
 * External API template retrieved successfully
 */
export const zGetDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdResponse =
  zExternalKnowledgeApiResponse

export const zPatchDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdBody =
  zExternalKnowledgeApiPayload

export const zPatchDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdPath = z.object({
  external_knowledge_api_id: z.uuid(),
})

/**
 * External API template updated successfully
 */
export const zPatchDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdResponse =
  zExternalKnowledgeApiResponse

export const zGetDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdUseCheckPath = z.object({
  external_knowledge_api_id: z.uuid(),
})

/**
 * Usage check completed successfully
 */
export const zGetDatasetsExternalKnowledgeApiByExternalKnowledgeApiIdUseCheckResponse =
  zUsageCountResponse

export const zPostDatasetsIndexingEstimateBody = zIndexingEstimatePayload

/**
 * Indexing estimate calculated successfully
 */
export const zPostDatasetsIndexingEstimateResponse = zIndexingEstimateResponse

export const zPostDatasetsInitBody = zKnowledgeConfig

/**
 * Dataset initialized successfully
 */
export const zPostDatasetsInitResponse = zDatasetAndDocumentResponse

/**
 * Built-in fields retrieved successfully
 */
export const zGetDatasetsMetadataBuiltInResponse = zDatasetMetadataBuiltInFieldsResponse

export const zPostDatasetsNotionIndexingEstimateBody = zNotionEstimatePayload

/**
 * Success
 */
export const zPostDatasetsNotionIndexingEstimateResponse = zIndexingEstimate

export const zGetDatasetsProcessRuleQuery = z.object({
  document_id: z.string().optional(),
})

/**
 * Process rules retrieved successfully
 */
export const zGetDatasetsProcessRuleResponse = zProcessRuleResponse

/**
 * Retrieval settings retrieved successfully
 */
export const zGetDatasetsRetrievalSettingResponse = zRetrievalSettingResponse

export const zGetDatasetsRetrievalSettingByVectorTypePath = z.object({
  vector_type: z.string(),
})

/**
 * Mock retrieval settings retrieved successfully
 */
export const zGetDatasetsRetrievalSettingByVectorTypeResponse = zRetrievalSettingResponse

export const zDeleteDatasetsByDatasetIdPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Dataset deleted successfully
 */
export const zDeleteDatasetsByDatasetIdResponse = z.void()

export const zGetDatasetsByDatasetIdPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Dataset retrieved successfully
 */
export const zGetDatasetsByDatasetIdResponse = zDatasetDetailWithPartialMembersResponse

export const zPatchDatasetsByDatasetIdBody = zDatasetUpdatePayload

export const zPatchDatasetsByDatasetIdPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Dataset updated successfully
 */
export const zPatchDatasetsByDatasetIdResponse = zDatasetDetailWithPartialMembersResponse

export const zPostDatasetsByDatasetIdApiKeysByStatusPath = z.object({
  dataset_id: z.uuid(),
  status: z.string(),
})

/**
 * Success
 */
export const zPostDatasetsByDatasetIdApiKeysByStatusResponse = zSimpleResultResponse

export const zGetDatasetsByDatasetIdAutoDisableLogsPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Auto disable logs retrieved successfully
 */
export const zGetDatasetsByDatasetIdAutoDisableLogsResponse = zAutoDisableLogsResponse

export const zGetDatasetsByDatasetIdBatchByBatchIndexingEstimatePath = z.object({
  batch: z.string(),
  dataset_id: z.uuid(),
})

/**
 * Indexing estimate calculated successfully
 */
export const zGetDatasetsByDatasetIdBatchByBatchIndexingEstimateResponse = zIndexingEstimateResponse

export const zGetDatasetsByDatasetIdBatchByBatchIndexingStatusPath = z.object({
  batch: z.string(),
  dataset_id: z.uuid(),
})

/**
 * Indexing status retrieved successfully
 */
export const zGetDatasetsByDatasetIdBatchByBatchIndexingStatusResponse = zDocumentStatusListResponse

export const zDeleteDatasetsByDatasetIdDocumentsPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Documents deleted successfully
 */
export const zDeleteDatasetsByDatasetIdDocumentsResponse = z.void()

export const zGetDatasetsByDatasetIdDocumentsPath = z.object({
  dataset_id: z.uuid(),
})

export const zGetDatasetsByDatasetIdDocumentsQuery = z.object({
  fetch: z.string().optional(),
  keyword: z.string().optional(),
  limit: z.string().optional(),
  page: z.string().optional(),
  sort: z.string().optional(),
  status: z.string().optional(),
})

/**
 * Documents retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsResponse = zDocumentWithSegmentsListResponse

export const zPostDatasetsByDatasetIdDocumentsBody = zKnowledgeConfig

export const zPostDatasetsByDatasetIdDocumentsPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Documents created successfully
 */
export const zPostDatasetsByDatasetIdDocumentsResponse = zDatasetAndDocumentResponse

export const zPostDatasetsByDatasetIdDocumentsDownloadZipBody = zDocumentBatchDownloadZipPayload

export const zPostDatasetsByDatasetIdDocumentsDownloadZipPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * ZIP archive downloaded successfully
 */
export const zPostDatasetsByDatasetIdDocumentsDownloadZipResponse = z.record(
  z.string(),
  z.unknown(),
)

export const zPostDatasetsByDatasetIdDocumentsGenerateSummaryBody = zGenerateSummaryPayload

export const zPostDatasetsByDatasetIdDocumentsGenerateSummaryPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Summary generation started successfully
 */
export const zPostDatasetsByDatasetIdDocumentsGenerateSummaryResponse = zSimpleResultResponse

export const zPostDatasetsByDatasetIdDocumentsMetadataBody = zMetadataOperationData

export const zPostDatasetsByDatasetIdDocumentsMetadataPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Documents metadata updated successfully
 */
export const zPostDatasetsByDatasetIdDocumentsMetadataResponse = z.void()

export const zPatchDatasetsByDatasetIdDocumentsStatusByActionBatchPath = z.object({
  action: z.string(),
  dataset_id: z.uuid(),
})

/**
 * Success
 */
export const zPatchDatasetsByDatasetIdDocumentsStatusByActionBatchResponse = zSimpleResultResponse

export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Document deleted successfully
 */
export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdResponse = z.void()

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdQuery = z.object({
  metadata: z.string().optional(),
})

/**
 * Document retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdResponse = zDocumentDetailResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdDownloadPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Download URL generated successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdDownloadResponse = zUrlResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdIndexingEstimatePath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Indexing estimate calculated successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdIndexingEstimateResponse =
  zIndexingEstimateResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdIndexingStatusPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Indexing status retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdIndexingStatusResponse =
  zDocumentStatusResponse

export const zPutDatasetsByDatasetIdDocumentsByDocumentIdMetadataBody =
  zDocumentMetadataUpdatePayload

export const zPutDatasetsByDatasetIdDocumentsByDocumentIdMetadataPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Document metadata updated successfully
 */
export const zPutDatasetsByDatasetIdDocumentsByDocumentIdMetadataResponse =
  zSimpleResultMessageResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdNotionSyncPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Success
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdNotionSyncResponse = zSimpleResultResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdPipelineExecutionLogPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Pipeline execution log retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdPipelineExecutionLogResponse =
  zDocumentPipelineExecutionLogResponse

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingPausePath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Document paused successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingPauseResponse = z.void()

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingResumePath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Document resumed successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingResumeResponse = z.void()

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingByActionPath = z.object({
  action: z.string(),
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Processing status updated successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdProcessingByActionResponse =
  zSimpleResultResponse

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdRenameBody = zDocumentRenamePayload

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdRenamePath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Document renamed successfully
 */
export const zPostDatasetsByDatasetIdDocumentsByDocumentIdRenameResponse = zDocumentResponse

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentBody = zSegmentCreatePayload

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Segment created successfully
 */
export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentResponse = zSegmentDetailResponse

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentByActionPath = z.object({
  action: z.string(),
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentByActionQuery = z.object({
  segment_id: z.array(z.string()).optional(),
})

/**
 * Success
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentByActionResponse =
  zSimpleResultResponse

export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsQuery = z.object({
  segment_id: z.array(z.string()).optional(),
})

/**
 * Segments deleted successfully
 */
export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsResponse = z.void()

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsQuery = z.object({
  enabled: z.string().optional().default('all'),
  hit_count_gte: z.int().optional(),
  keyword: z.string().optional(),
  limit: z.int().gte(1).lte(100).optional().default(20),
  page: z.int().gte(1).optional().default(1),
  status: z.array(z.string()).optional(),
})

/**
 * Segments retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsResponse =
  zConsoleSegmentListResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBatchImportPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Batch import status
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBatchImportResponse =
  zSegmentBatchImportStatusResponse

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBatchImportBody =
  zBatchImportPayload

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBatchImportPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Batch import started
 */
export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBatchImportResponse =
  zSegmentBatchImportStatusResponse

export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
  segment_id: z.uuid(),
})

/**
 * Segment deleted successfully
 */
export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdResponse = z.void()

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdBody =
  zSegmentUpdatePayload

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
  segment_id: z.uuid(),
})

/**
 * Segment updated successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdResponse =
  zSegmentDetailResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksPath =
  z.object({
    dataset_id: z.uuid(),
    document_id: z.uuid(),
    segment_id: z.uuid(),
  })

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksQuery =
  z.object({
    keyword: z.string().optional(),
    limit: z.int().gte(1).lte(100).optional().default(20),
    page: z.int().gte(1).optional().default(1),
  })

/**
 * Child chunks retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksResponse =
  zChildChunkListResponse

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksBody =
  zChildChunkBatchUpdatePayload

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksPath =
  z.object({
    dataset_id: z.uuid(),
    document_id: z.uuid(),
    segment_id: z.uuid(),
  })

/**
 * Child chunks updated successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksResponse =
  zChildChunkBatchUpdateResponse

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksBody =
  zChildChunkCreatePayload

export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksPath =
  z.object({
    dataset_id: z.uuid(),
    document_id: z.uuid(),
    segment_id: z.uuid(),
  })

/**
 * Child chunk created successfully
 */
export const zPostDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksResponse =
  zChildChunkDetailResponse

export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksByChildChunkIdPath =
  z.object({
    child_chunk_id: z.uuid(),
    dataset_id: z.uuid(),
    document_id: z.uuid(),
    segment_id: z.uuid(),
  })

/**
 * Child chunk deleted successfully
 */
export const zDeleteDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksByChildChunkIdResponse =
  z.void()

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksByChildChunkIdBody =
  zChildChunkUpdatePayload

export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksByChildChunkIdPath =
  z.object({
    child_chunk_id: z.uuid(),
    dataset_id: z.uuid(),
    document_id: z.uuid(),
    segment_id: z.uuid(),
  })

/**
 * Child chunk updated successfully
 */
export const zPatchDatasetsByDatasetIdDocumentsByDocumentIdSegmentsBySegmentIdChildChunksByChildChunkIdResponse =
  zChildChunkDetailResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSummaryStatusPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Summary status retrieved successfully
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdSummaryStatusResponse =
  zDocumentSummaryStatusResponse

export const zGetDatasetsByDatasetIdDocumentsByDocumentIdWebsiteSyncPath = z.object({
  dataset_id: z.uuid(),
  document_id: z.uuid(),
})

/**
 * Success
 */
export const zGetDatasetsByDatasetIdDocumentsByDocumentIdWebsiteSyncResponse = zSimpleResultResponse

export const zGetDatasetsByDatasetIdErrorDocsPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Error documents retrieved successfully
 */
export const zGetDatasetsByDatasetIdErrorDocsResponse = zErrorDocsResponse

export const zPostDatasetsByDatasetIdExternalHitTestingBody = zExternalHitTestingPayload

export const zPostDatasetsByDatasetIdExternalHitTestingPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * External hit testing completed successfully
 */
export const zPostDatasetsByDatasetIdExternalHitTestingResponse = zExternalHitTestingResponse

export const zPostDatasetsByDatasetIdHitTestingBody = zHitTestingPayload

export const zPostDatasetsByDatasetIdHitTestingPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Hit testing completed successfully
 */
export const zPostDatasetsByDatasetIdHitTestingResponse = zHitTestingResponse

export const zGetDatasetsByDatasetIdIndexingStatusPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Indexing status retrieved successfully
 */
export const zGetDatasetsByDatasetIdIndexingStatusResponse = zDocumentStatusListResponse

export const zGetDatasetsByDatasetIdMetadataPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Metadata retrieved successfully
 */
export const zGetDatasetsByDatasetIdMetadataResponse = zDatasetMetadataListResponse

export const zPostDatasetsByDatasetIdMetadataBody = zMetadataArgs

export const zPostDatasetsByDatasetIdMetadataPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Metadata created successfully
 */
export const zPostDatasetsByDatasetIdMetadataResponse = zDatasetMetadataResponse

export const zPostDatasetsByDatasetIdMetadataBuiltInByActionPath = z.object({
  action: z.string(),
  dataset_id: z.uuid(),
})

/**
 * Action completed successfully
 */
export const zPostDatasetsByDatasetIdMetadataBuiltInByActionResponse = z.void()

export const zDeleteDatasetsByDatasetIdMetadataByMetadataIdPath = z.object({
  dataset_id: z.uuid(),
  metadata_id: z.uuid(),
})

/**
 * Metadata deleted successfully
 */
export const zDeleteDatasetsByDatasetIdMetadataByMetadataIdResponse = z.void()

export const zPatchDatasetsByDatasetIdMetadataByMetadataIdBody = zMetadataUpdatePayload

export const zPatchDatasetsByDatasetIdMetadataByMetadataIdPath = z.object({
  dataset_id: z.uuid(),
  metadata_id: z.uuid(),
})

/**
 * Metadata updated successfully
 */
export const zPatchDatasetsByDatasetIdMetadataByMetadataIdResponse = zDatasetMetadataResponse

export const zGetDatasetsByDatasetIdNotionSyncPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Success
 */
export const zGetDatasetsByDatasetIdNotionSyncResponse = zSimpleResultResponse

export const zGetDatasetsByDatasetIdPermissionPartUsersPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Permission users retrieved successfully
 */
export const zGetDatasetsByDatasetIdPermissionPartUsersResponse = zPartialMemberListResponse

export const zGetDatasetsByDatasetIdQueriesPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Query history retrieved successfully
 */
export const zGetDatasetsByDatasetIdQueriesResponse = zDatasetQueryListResponse

export const zGetDatasetsByDatasetIdRelatedAppsPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Related apps retrieved successfully
 */
export const zGetDatasetsByDatasetIdRelatedAppsResponse = zRelatedAppListResponse

export const zPostDatasetsByDatasetIdRetryBody = zDocumentRetryPayload

export const zPostDatasetsByDatasetIdRetryPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Documents retry started successfully
 */
export const zPostDatasetsByDatasetIdRetryResponse = z.void()

export const zGetDatasetsByDatasetIdUseCheckPath = z.object({
  dataset_id: z.uuid(),
})

/**
 * Dataset use status retrieved successfully
 */
export const zGetDatasetsByDatasetIdUseCheckResponse = zUsageCheckResponse

export const zGetDatasetsByResourceIdApiKeysPath = z.object({
  resource_id: z.uuid(),
})

/**
 * API keys retrieved successfully
 */
export const zGetDatasetsByResourceIdApiKeysResponse = zApiKeyList

export const zPostDatasetsByResourceIdApiKeysPath = z.object({
  resource_id: z.uuid(),
})

/**
 * API key created successfully
 */
export const zPostDatasetsByResourceIdApiKeysResponse = zApiKeyItem

export const zDeleteDatasetsByResourceIdApiKeysByApiKeyIdPath = z.object({
  api_key_id: z.uuid(),
  resource_id: z.uuid(),
})

/**
 * API key deleted successfully
 */
export const zDeleteDatasetsByResourceIdApiKeysByApiKeyIdResponse = z.void()
