Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

3.7 KB
Raw Blame
// This file is auto-generated by @hey-api/openapi-ts

import * as z from 'zod'

/**
 * AllowedExtensionsResponse
 */
export const zAllowedExtensionsResponse = z.object({
  allowed_extensions: z.array(z.string()),
})

/**
 * ErrorResponse
 *
 * Documented non-2xx body emitted by ``register_external_error_handlers``.
 *
 * ``params`` and ``details`` appear only on the errors that set them. The schema
 * stays open because ``HTTPException.data`` may carry extra keys.
 */
export const zErrorResponse = z.object({
  code: z.string(),
  details: z.record(z.string(), z.unknown()).optional(),
  message: z.string(),
  params: z.string().optional(),
  status: z.int(),
})

/**
 * UploadConfig
 */
export const zUploadConfig = z.object({
  attachment_image_file_size_limit: z.int(),
  audio_file_size_limit: z.int(),
  batch_count_limit: z.int(),
  file_size_limit: z.int(),
  file_upload_limit: z.int(),
  image_file_batch_limit: z.int(),
  image_file_size_limit: z.int(),
  knowledge_file_size_limit: z.int(),
  single_chunk_attachment_limit: z.int(),
  skill_file_size_limit: z.int(),
  video_file_size_limit: z.int(),
  workflow_file_upload_limit: z.int(),
})

/**
 * FileResponse
 */
export const zFileResponse = z.object({
  conversation_id: z.uuid().nullish(),
  created_at: z.int().nullish(),
  created_by: z.uuid().nullish(),
  extension: z.string().nullish(),
  file_key: z.string().nullish(),
  id: z.uuid(),
  mime_type: z.string().nullish(),
  name: z.string(),
  original_url: z.string().nullish(),
  preview_url: z.string().nullish(),
  reference: z.string().nullish(),
  size: z.int(),
  source_url: z.string().nullish(),
  tenant_id: z.uuid().nullish(),
  user_id: z.uuid().nullish(),
})

/**
 * FileExtensionBlockedError
 *
 * The file extension is blocked for security reasons.
 */
export const zFileExtensionBlockedError = zErrorResponse.and(
  z.object({
    code: z.literal('file_extension_blocked'),
    status: z.literal(400),
  }),
)

/**
 * FilenameNotExistsError
 *
 * The specified filename does not exist.
 */
export const zFilenameNotExistsError = zErrorResponse.and(
  z.object({
    code: z.literal('filename_not_exists_error'),
    status: z.literal(400),
  }),
)

/**
 * NoFileUploadedError
 *
 * Please upload your file.
 */
export const zNoFileUploadedError = zErrorResponse.and(
  z.object({
    code: z.literal('no_file_uploaded'),
    status: z.literal(400),
  }),
)

/**
 * TooManyFilesError
 *
 * Only one file is allowed.
 */
export const zTooManyFilesError = zErrorResponse.and(
  z.object({
    code: z.literal('too_many_files'),
    status: z.literal(400),
  }),
)

/**
 * FileTooLargeError
 *
 * File size exceeded. {message}
 */
export const zFileTooLargeError = zErrorResponse.and(
  z.object({
    code: z.literal('file_too_large'),
    status: z.literal(413),
  }),
)

/**
 * UnsupportedFileTypeError
 *
 * File type not allowed.
 */
export const zUnsupportedFileTypeError = zErrorResponse.and(
  z.object({
    code: z.literal('unsupported_file_type'),
    status: z.literal(415),
  }),
)

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

/**
 * Success
 */
export const zGetFilesSupportTypeResponse = zAllowedExtensionsResponse

/**
 * Success
 */
export const zGetFilesUploadResponse = zUploadConfig

export const zPostFilesUploadBody = z.object({
  file: z.custom<Blob | File>((value) => value instanceof Blob || value instanceof File),
  source: z.enum(['datasets']).optional(),
})

/**
 * File uploaded successfully
 */
export const zPostFilesUploadResponse = zFileResponse

export const zGetFilesByFileIdPreviewPath = z.object({
  file_id: z.uuid(),
})

/**
 * Success
 */
export const zGetFilesByFileIdPreviewResponse = zTextContentResponse