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

import * as z from 'zod'

/**
 * AgentProviderResponse
 */
export const zAgentProviderResponse = z.record(z.string(), z.unknown())

/**
 * AgentProviderListResponse
 */
export const zAgentProviderListResponse = z.array(z.record(z.string(), z.unknown()))

/**
 * SnippetImportPayload
 *
 * Payload for importing snippet from DSL.
 */
export const zSnippetImportPayload = z.object({
  description: z.string().nullish(),
  mode: z.string(),
  name: z.string().nullish(),
  snippet_id: z.string().nullish(),
  yaml_content: z.string().nullish(),
  yaml_url: z.string().nullish(),
})

/**
 * TextFileResponse
 */
export const zTextFileResponse = z.string()

/**
 * SnippetUseCountResponse
 */
export const zSnippetUseCountResponse = z.object({
  result: z.string(),
  use_count: z.int(),
})

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

/**
 * EndpointCreatePayload
 */
export const zEndpointCreatePayload = z.object({
  name: z.string().min(1),
  plugin_unique_identifier: z.string(),
  settings: z.record(z.string(), z.unknown()),
})

/**
 * SuccessResponse
 */
export const zSuccessResponse = z.object({
  success: z.boolean(),
})

/**
 * EndpointIdPayload
 */
export const zEndpointIdPayload = z.object({
  endpoint_id: z.string(),
})

/**
 * LegacyEndpointUpdatePayload
 */
export const zLegacyEndpointUpdatePayload = z.object({
  endpoint_id: z.string(),
  name: z.string().min(1),
  settings: z.record(z.string(), z.unknown()),
})

/**
 * EndpointUpdatePayload
 */
export const zEndpointUpdatePayload = z.object({
  name: z.string().min(1),
  settings: z.record(z.string(), z.unknown()),
})

/**
 * MemberInvitePayload
 */
export const zMemberInvitePayload = z.object({
  emails: z.array(z.string()).min(1),
  language: z.string().nullish(),
  role: z.string(),
})

/**
 * MemberInviteErrorResponse
 */
export const zMemberInviteErrorResponse = z.object({
  code: z.enum(['invalid_param', 'invalid_role', 'limit_exceeded']),
  message: z.string(),
  status: z.literal(400),
})

/**
 * OwnerTransferCheckPayload
 */
export const zOwnerTransferCheckPayload = z.object({
  code: z.string(),
  token: z.string(),
})

/**
 * VerificationTokenResponse
 */
export const zVerificationTokenResponse = z.object({
  email: z.string(),
  is_valid: z.boolean(),
  token: z.string(),
})

/**
 * OwnerTransferEmailPayload
 */
export const zOwnerTransferEmailPayload = z.object({
  language: z.string().nullish(),
})

/**
 * SimpleResultDataResponse
 */
export const zSimpleResultDataResponse = z.object({
  data: z.string(),
  result: z.string(),
})

/**
 * MemberActionResponse
 */
export const zMemberActionResponse = z.object({
  result: z.string(),
  tenant_id: z.string(),
})

/**
 * OwnerTransferPayload
 */
export const zOwnerTransferPayload = z.object({
  token: z.string(),
})

/**
 * MemberRoleUpdatePayload
 */
export const zMemberRoleUpdatePayload = z.object({
  role: z.string(),
})

/**
 * ModelProviderPaymentCheckoutUrlResponse
 */
export const zModelProviderPaymentCheckoutUrlResponse = z.object({
  payment_link: z.string(),
})

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

/**
 * ProviderCredentialsResponse
 */
export const zProviderCredentialsResponse = z.object({
  credentials: z.record(z.string(), z.unknown()).nullish(),
})

/**
 * ParserCredentialCreate
 */
export const zParserCredentialCreate = z.object({
  credentials: z.record(z.string(), z.unknown()),
  name: z.string().max(30).nullish(),
})

/**
 * ParserCredentialUpdate
 */
export const zParserCredentialUpdate = z.object({
  credential_id: z.string(),
  credentials: z.record(z.string(), z.unknown()),
  name: z.string().max(30).nullish(),
})

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

/**
 * ParserCredentialValidate
 */
export const zParserCredentialValidate = z.object({
  credentials: z.record(z.string(), z.unknown()),
})

/**
 * ValidationResultResponse
 */
export const zValidationResultResponse = z.object({
  error: z.string().nullish(),
  result: z.enum(['error', 'success']),
})

/**
 * LoadBalancingCredentialValidateResponse
 */
export const zLoadBalancingCredentialValidateResponse = z.object({
  error: z.string().nullish(),
  result: z.string(),
})

/**
 * ParserPreferredProviderType
 */
export const zParserPreferredProviderType = z.object({
  preferred_provider_type: z.enum(['custom', 'system']),
})

/**
 * WorkspacePermissionResponse
 */
export const zWorkspacePermissionResponse = z.object({
  allow_member_invite: z.boolean(),
  allow_owner_transfer: z.boolean(),
  workspace_id: z.string(),
})

/**
 * BinaryFileResponse
 */
export const zBinaryFileResponse = z.custom<Blob | File>(
  (value) => value instanceof Blob || value instanceof File,
)

/**
 * PluginAutoUpgradeChangeResponse
 */
export const zPluginAutoUpgradeChangeResponse = z.object({
  message: z.string().nullish(),
  success: z.boolean(),
})

/**
 * PluginDebuggingKeyResponse
 */
export const zPluginDebuggingKeyResponse = z.object({
  host: z.string(),
  key: z.string(),
  port: z.int(),
})

/**
 * ParserGithubInstall
 */
export const zParserGithubInstall = z.object({
  package: z.string(),
  plugin_unique_identifier: z.string(),
  repo: z.string(),
  version: z.string(),
})

/**
 * ParserPluginIdentifiers
 */
export const zParserPluginIdentifiers = z.object({
  plugin_unique_identifiers: z.array(z.string()),
})

/**
 * ParserLatest
 */
export const zParserLatest = z.object({
  plugin_ids: z.array(z.string()),
})

/**
 * ParserDynamicOptionsWithCredentials
 */
export const zParserDynamicOptionsWithCredentials = z.object({
  action: z.string(),
  credential_id: z.string(),
  credentials: z.record(z.string(), z.unknown()),
  parameter: z.string(),
  plugin_id: z.string(),
  provider: z.string(),
})

/**
 * PluginReadmeResponse
 */
export const zPluginReadmeResponse = z.object({
  readme: z.string(),
})

/**
 * ParserUninstall
 */
export const zParserUninstall = z.object({
  plugin_installation_id: z.string(),
})

/**
 * ParserGithubUpgrade
 */
export const zParserGithubUpgrade = z.object({
  new_plugin_unique_identifier: z.string(),
  original_plugin_unique_identifier: z.string(),
  package: z.string(),
  repo: z.string(),
  version: z.string(),
})

/**
 * ParserMarketplaceUpgrade
 */
export const zParserMarketplaceUpgrade = z.object({
  new_plugin_unique_identifier: z.string(),
  original_plugin_unique_identifier: z.string(),
})

/**
 * ParserGithubUpload
 */
export const zParserGithubUpload = z.object({
  package: z.string(),
  repo: z.string(),
  version: z.string(),
})

/**
 * AccessPolicy
 */
export const zAccessPolicy = z.object({
  category: z.string().optional().default(''),
  created_at: z.int().optional().default(0),
  description: z.string().optional().default(''),
  id: z.string(),
  is_builtin: z.boolean().optional().default(false),
  name: z.string(),
  permission_keys: z.array(z.string()).optional(),
  policy_key: z.string().optional().default(''),
  resource_type: z.string(),
  tenant_id: z.string().optional().default(''),
  updated_at: z.int().optional().default(0),
})

/**
 * AccessPolicyBindingState
 */
export const zAccessPolicyBindingState = z.object({
  binding_id: z.string(),
  is_locked: z.boolean().optional().default(false),
})

/**
 * _DeleteMemberBindingsRequest
 */
export const zDeleteMemberBindingsRequest = z.object({
  account_ids: z.array(z.string()).optional(),
})

/**
 * ReplaceUserAccessPolicies
 */
export const zReplaceUserAccessPolicies = z.object({
  access_policy_ids: z.array(z.string()).optional(),
  account_ids: z.array(z.string()).optional(),
})

/**
 * ReplaceUserAccessPoliciesResponse
 */
export const zReplaceUserAccessPoliciesResponse = z.object({
  access_policies: z.array(zAccessPolicy).optional(),
})

/**
 * ResourceWhitelist
 */
export const zResourceWhitelist = z.object({
  account_ids: z.array(z.string()).optional(),
})

/**
 * _ReplaceMemberRolesRequest
 */
export const zReplaceMemberRolesRequest = z.object({
  role_ids: z.array(z.string()).optional().default([]),
})

/**
 * RBACRole
 */
export const zRbacRole = z.object({
  category: z.string().optional().default(''),
  description: z.string().optional().default(''),
  id: z.string(),
  is_builtin: z.boolean().optional().default(false),
  name: z.string(),
  permission_keys: z.array(z.string()).optional(),
  role_tag: z.string().optional().default(''),
  tenant_id: z.string().nullish(),
  type: z.string(),
})

/**
 * MemberRolesResponse
 */
export const zMemberRolesResponse = z.object({
  account_id: z.string(),
  roles: z.array(zRbacRole).optional(),
})

/**
 * _ReplaceBindingsRequest
 */
export const zReplaceBindingsRequest = z.object({
  account_ids: z.array(z.string()).optional(),
  role_ids: z.array(z.string()).optional(),
})

/**
 * ApiToolProviderDeletePayload
 */
export const zApiToolProviderDeletePayload = z.object({
  provider: z.string(),
})

/**
 * ApiProviderRemoteSchemaResponse
 */
export const zApiProviderRemoteSchemaResponse = z.object({
  schema: z.string(),
})

/**
 * ApiToolSchemaPayload
 */
export const zApiToolSchemaPayload = z.object({
  schema: z.string(),
})

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

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

/**
 * ToolOAuthCustomClientPayload
 */
export const zToolOAuthCustomClientPayload = z.object({
  client_params: z.record(z.string(), z.unknown()).nullish(),
  enable_oauth_custom_client: z.boolean().nullish().default(true),
})

/**
 * BuiltinToolUpdatePayload
 */
export const zBuiltinToolUpdatePayload = z.object({
  credential_id: z.string(),
  credentials: z.record(z.string(), z.unknown()).nullish(),
  name: z.string().max(30).nullish(),
})

/**
 * MCPProviderDeletePayload
 */
export const zMcpProviderDeletePayload = z.object({
  provider_id: z.string(),
})

/**
 * MCPAuthPayload
 */
export const zMcpAuthPayload = z.object({
  authorization_code: z.string().nullish(),
  provider_id: z.string(),
})

/**
 * MCPAuthResponse
 */
export const zMcpAuthResponse = z.object({
  authorization_url: z.string().nullish(),
  result: z.literal('success').nullish(),
})

/**
 * WorkflowToolDeletePayload
 */
export const zWorkflowToolDeletePayload = z.object({
  workflow_tool_id: z.string(),
})

/**
 * TriggerOAuthClientPayload
 */
export const zTriggerOAuthClientPayload = z.object({
  client_params: z.record(z.string(), z.unknown()).nullish(),
  enabled: z.boolean().nullish(),
})

/**
 * TriggerSubscriptionBuilderUpdatePayload
 */
export const zTriggerSubscriptionBuilderUpdatePayload = z.object({
  credentials: z.record(z.string(), z.unknown()).nullish(),
  name: z.string().nullish(),
  parameters: z.record(z.string(), z.unknown()).nullish(),
  properties: z.record(z.string(), z.unknown()).nullish(),
})

/**
 * TriggerSubscriptionBuilderCreatePayload
 */
export const zTriggerSubscriptionBuilderCreatePayload = z.object({
  credential_type: z.string().optional().default('unauthorized'),
})

/**
 * TriggerSubscriptionBuilderVerifyPayload
 */
export const zTriggerSubscriptionBuilderVerifyPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
})

/**
 * TriggerVerificationResponse
 */
export const zTriggerVerificationResponse = z.object({
  verified: z.boolean(),
})

/**
 * TriggerProviderErrorResponse
 */
export const zTriggerProviderErrorResponse = z.object({
  error: z.string(),
})

/**
 * WorkspaceCustomConfigPayload
 */
export const zWorkspaceCustomConfigPayload = z.object({
  remove_webapp_brand: z.boolean().nullish(),
  replace_webapp_logo: z.string().nullish(),
})

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

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

/**
 * SwitchWorkspacePayload
 */
export const zSwitchWorkspacePayload = z.object({
  tenant_id: z.string(),
})

/**
 * TenantListItemResponse
 */
export const zTenantListItemResponse = z.object({
  created_at: z.int().nullish(),
  current: z.boolean(),
  id: z.string(),
  last_opened_at: z.int().nullish(),
  name: z.string().nullish(),
  plan: z.string().nullish(),
  status: z.string().nullish(),
})

/**
 * TenantListResponse
 */
export const zTenantListResponse = z.object({
  workspaces: z.array(zTenantListItemResponse),
})

/**
 * WorkspaceCustomConfigResponse
 */
export const zWorkspaceCustomConfigResponse = z.object({
  remove_webapp_brand: z.boolean().nullish(),
  replace_webapp_logo: z.string().nullish(),
})

/**
 * TenantInfoResponse
 */
export const zTenantInfoResponse = z.object({
  created_at: z.int().nullish(),
  custom_config: zWorkspaceCustomConfigResponse.nullish(),
  id: z.string(),
  in_trial: z.boolean().nullish(),
  name: z.string().nullish(),
  next_credit_reset_date: z.int().nullish(),
  plan: z.string().nullish(),
  role: z.string().nullish(),
  status: z.string().nullish(),
  trial_credits: z.int().nullish(),
  trial_credits_exhausted_at: z.int().nullish(),
  trial_credits_used: z.int().nullish(),
  trial_end_reason: z.string().nullish(),
})

/**
 * WorkspaceTenantResultResponse
 */
export const zWorkspaceTenantResultResponse = z.object({
  result: z.string(),
  tenant: zTenantInfoResponse,
})

/**
 * SwitchWorkspaceResponse
 */
export const zSwitchWorkspaceResponse = z.object({
  new_tenant: zTenantInfoResponse,
  result: z.string(),
})

/**
 * IconInfo
 *
 * Icon information model.
 */
export const zIconInfo = z.object({
  icon: z.string().nullish(),
  icon_background: z.string().nullish(),
  icon_type: z.enum(['emoji', 'image']).nullish(),
  icon_url: z.string().nullish(),
})

/**
 * UpdateSnippetPayload
 *
 * Payload for updating a snippet.
 */
export const zUpdateSnippetPayload = z.object({
  description: z.string().max(2000).nullish(),
  icon_info: zIconInfo.nullish(),
  name: z.string().min(1).max(255).nullish(),
})

/**
 * InputFieldDefinition
 *
 * Input field definition for snippet parameters.
 */
export const zInputFieldDefinition = z.object({
  default: z.string().nullish(),
  hint: z.boolean().nullish(),
  label: z.string().nullish(),
  max_length: z.int().nullish(),
  options: z.array(z.string()).nullish(),
  placeholder: z.string().nullish(),
  required: z.boolean().nullish(),
  type: z.string().nullish(),
})

/**
 * CreateSnippetPayload
 *
 * Payload for creating a new snippet.
 */
export const zCreateSnippetPayload = z.object({
  description: z.string().max(2000).nullish(),
  graph: z.record(z.string(), z.unknown()).nullish(),
  icon_info: zIconInfo.nullish(),
  input_fields: z.array(zInputFieldDefinition).nullish(),
  name: z.string().min(1).max(255),
  type: z.enum(['group', 'node']).optional().default('node'),
})

/**
 * SimpleAccountResponse
 */
export const zSimpleAccountResponse = z.object({
  email: z.string(),
  id: z.string(),
  name: z.string(),
})

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

/**
 * SnippetType
 *
 * Snippet Type Enum
 */
export const zSnippetType = z.enum(['group', 'node'])

/**
 * SnippetResponse
 */
export const zSnippetResponse = z.object({
  created_at: z.int(),
  created_by: zSimpleAccountResponse.nullable(),
  description: z.string().nullable(),
  graph: z.record(z.string(), z.unknown()),
  icon_info: z.record(z.string(), z.unknown()).nullable(),
  id: z.string(),
  input_fields: z.array(z.record(z.string(), z.unknown())),
  is_published: z.boolean(),
  name: z.string(),
  tags: z.array(zSnippetTagResponse),
  type: zSnippetType,
  updated_at: z.int(),
  updated_by: zSimpleAccountResponse.nullable(),
  use_count: z.int(),
  version: z.int(),
})

/**
 * SnippetListItemResponse
 */
export const zSnippetListItemResponse = z.object({
  author_name: z.string().nullable(),
  created_at: z.int(),
  created_by: z.string().nullable(),
  description: z.string().nullable(),
  icon_info: z.record(z.string(), z.unknown()).nullable(),
  id: z.string(),
  is_published: z.boolean(),
  name: z.string(),
  tags: z.array(zSnippetTagResponse),
  type: zSnippetType,
  updated_at: z.int(),
  updated_by: z.string().nullable(),
  use_count: z.int(),
  version: z.int(),
})

/**
 * SnippetPaginationResponse
 */
export const zSnippetPaginationResponse = z.object({
  data: z.array(zSnippetListItemResponse),
  has_more: z.boolean(),
  limit: z.int(),
  page: z.int(),
  total: z.int(),
})

/**
 * ImportStatus
 */
export const zImportStatus = z.enum(['completed', 'completed-with-warnings', 'failed', 'pending'])

/**
 * DslImportWarning
 *
 * Portable DSL reference that could not be restored in the target workspace.
 */
export const zDslImportWarning = z.object({
  code: z.string(),
  details: z.record(z.string(), z.unknown()).optional(),
  message: z.string(),
  path: z.string(),
})

/**
 * SnippetImportResponse
 */
export const zSnippetImportResponse = z.object({
  current_dsl_version: z.string(),
  error: z.string(),
  id: z.string(),
  imported_dsl_version: z.string(),
  snippet_id: z.string().nullable(),
  status: zImportStatus,
  warnings: z.array(zDslImportWarning),
})

/**
 * AccountWithRoleResponse
 */
export const zAccountWithRoleResponse = z.object({
  avatar: z.string().nullish(),
  avatar_url: z.string().nullable(),
  created_at: z.int().nullish(),
  email: z.string(),
  id: z.string(),
  last_active_at: z.int().nullish(),
  last_login_at: z.int().nullish(),
  name: z.string(),
  role: z.string(),
  roles: z.array(z.record(z.string(), z.string())).optional(),
  status: z.string(),
})

/**
 * AccountWithRoleListResponse
 */
export const zAccountWithRoleListResponse = z.object({
  accounts: z.array(zAccountWithRoleResponse),
})

/**
 * MemberInviteSuccessResponse
 */
export const zMemberInviteSuccessResponse = z.object({
  email: z.string(),
  status: z.literal('success'),
  url: z.string(),
})

/**
 * MemberInviteAlreadyMemberResponse
 */
export const zMemberInviteAlreadyMemberResponse = z.object({
  email: z.string(),
  message: z.string(),
  status: z.literal('already_member'),
})

/**
 * MemberInviteFailedResponse
 */
export const zMemberInviteFailedResponse = z.object({
  email: z.string(),
  message: z.string(),
  status: z.literal('failed'),
})

/**
 * MemberInviteResponse
 */
export const zMemberInviteResponse = z.object({
  invitation_results: z.array(
    z.union([
      z
        .object({
          status: z.literal('success'),
        })
        .and(zMemberInviteSuccessResponse),
      z
        .object({
          status: z.literal('already_member'),
        })
        .and(zMemberInviteAlreadyMemberResponse),
      z
        .object({
          status: z.literal('failed'),
        })
        .and(zMemberInviteFailedResponse),
    ]),
  ),
  result: z.literal('success'),
  tenant_id: z.string(),
})

/**
 * ModelType
 *
 * Enum class for model type.
 */
export const zModelType = z.enum([
  'llm',
  'moderation',
  'rerank',
  'speech2text',
  'text-embedding',
  'tts',
])

/**
 * ParserDeleteModels
 */
export const zParserDeleteModels = z.object({
  model: z.string(),
  model_type: zModelType,
})

/**
 * ParserDeleteCredential
 */
export const zParserDeleteCredential = z.object({
  credential_id: z.string(),
  model: z.string(),
  model_type: zModelType,
})

/**
 * ParserCreateCredential
 */
export const zParserCreateCredential = z.object({
  credentials: z.record(z.string(), z.unknown()),
  model: z.string(),
  model_type: zModelType,
  name: z.string().max(30).nullish(),
})

/**
 * ParserUpdateCredential
 */
export const zParserUpdateCredential = z.object({
  credential_id: z.string(),
  credentials: z.record(z.string(), z.unknown()),
  model: z.string(),
  model_type: zModelType,
  name: z.string().max(30).nullish(),
})

/**
 * ParserSwitch
 */
export const zParserSwitch = z.object({
  credential_id: z.string(),
  model: z.string(),
  model_type: zModelType,
})

/**
 * ParserValidate
 */
export const zParserValidate = z.object({
  credentials: z.record(z.string(), z.unknown()),
  model: z.string(),
  model_type: zModelType,
})

/**
 * LoadBalancingCredentialPayload
 */
export const zLoadBalancingCredentialPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  model: z.string(),
  model_type: zModelType,
})

/**
 * Inner
 */
export const zInner = z.object({
  model: z.string().nullish(),
  model_type: zModelType,
  provider: z.string().nullish(),
})

/**
 * ParserPostDefault
 */
export const zParserPostDefault = z.object({
  model_settings: z.array(zInner),
})

/**
 * LoadBalancingPayload
 */
export const zLoadBalancingPayload = z.object({
  configs: z.array(z.record(z.string(), z.unknown())).nullish(),
  enabled: z.boolean().nullish(),
})

/**
 * ParserPostModels
 */
export const zParserPostModels = z.object({
  config_from: z.string().nullish(),
  credential_id: z.string().nullish(),
  load_balancing: zLoadBalancingPayload.nullish(),
  model: z.string(),
  model_type: zModelType,
})

/**
 * CredentialConfiguration
 *
 * Model class for credential configuration.
 */
export const zCredentialConfiguration = z.object({
  credential_id: z.string(),
  credential_name: z.string(),
})

/**
 * TenantPluginAutoUpgradeCategory
 */
export const zTenantPluginAutoUpgradeCategory = z.enum([
  'agent-strategy',
  'datasource',
  'extension',
  'model',
  'tool',
  'trigger',
])

/**
 * ParserExcludePlugin
 */
export const zParserExcludePlugin = z.object({
  category: zTenantPluginAutoUpgradeCategory,
  plugin_id: z.string(),
})

/**
 * LatestPluginCache
 */
export const zLatestPluginCache = z.object({
  alternative_plugin_id: z.string(),
  deprecated_reason: z.string(),
  plugin_id: z.string(),
  status: z.enum(['active', 'deleted']),
  unique_identifier: z.string(),
  version: z.string(),
})

/**
 * PluginVersionsResponse
 */
export const zPluginVersionsResponse = z.object({
  versions: z.record(z.string(), zLatestPluginCache.nullable()),
})

/**
 * TenantPluginDebugPermission
 */
export const zTenantPluginDebugPermission = z.enum(['admins', 'everyone', 'noone'])

/**
 * TenantPluginInstallPermission
 */
export const zTenantPluginInstallPermission = z.enum(['admins', 'everyone', 'noone'])

/**
 * ParserPermissionChange
 */
export const zParserPermissionChange = z.object({
  debug_permission: zTenantPluginDebugPermission.optional().default('everyone'),
  install_permission: zTenantPluginInstallPermission.optional().default('everyone'),
})

/**
 * PluginPermissionResponse
 */
export const zPluginPermissionResponse = z.object({
  debug_permission: zTenantPluginDebugPermission,
  install_permission: zTenantPluginInstallPermission,
})

/**
 * Pagination
 */
export const zPagination = z.object({
  current_page: z.int().optional().default(0),
  per_page: z.int().optional().default(0),
  total_count: z.int().optional().default(0),
  total_pages: z.int().optional().default(0),
})

/**
 * _AccessPolicyList
 */
export const zAccessPolicyList = z.object({
  data: z.array(zAccessPolicy).optional(),
  pagination: zPagination.nullish(),
})

/**
 * _RBACRoleList
 */
export const zRbacRoleList = z.object({
  data: z.array(zRbacRole).optional(),
  pagination: zPagination.nullish(),
})

/**
 * AccessPolicyMemberBinding
 */
export const zAccessPolicyMemberBinding = z.object({
  access_policy_id: z.string(),
  account_id: z.string(),
  account_name: z.string().optional().default(''),
  created_at: z.int().optional().default(0),
  id: z.string(),
  resource_id: z.string().optional().default(''),
  resource_type: z.string(),
  tenant_id: z.string().optional().default(''),
})

/**
 * MemberBindingsResponse
 */
export const zMemberBindingsResponse = z.object({
  data: z.array(zAccessPolicyMemberBinding).optional(),
})

/**
 * AccessPolicyRoleBinding
 */
export const zAccessPolicyRoleBinding = z.object({
  access_policy_id: z.string(),
  created_at: z.int().optional().default(0),
  id: z.string(),
  resource_id: z.string().optional().default(''),
  resource_type: z.string(),
  role_id: z.string(),
  role_name: z.string().optional().default(''),
  tenant_id: z.string().optional().default(''),
})

/**
 * RoleBindingsResponse
 */
export const zRoleBindingsResponse = z.object({
  data: z.array(zAccessPolicyRoleBinding).optional(),
})

/**
 * RBACResourceWhitelistScope
 *
 * Whitelist scopes accepted by RBAC app and dataset access config APIs.
 */
export const zRbacResourceWhitelistScope = z.enum(['all', 'only_me', 'specific'])

/**
 * _ResourceAccessScopeRequest
 */
export const zResourceAccessScopeRequest = z.object({
  scope: zRbacResourceWhitelistScope,
})

/**
 * WorkspacePermissionSnapshot
 */
export const zWorkspacePermissionSnapshot = z.object({
  permission_keys: z.array(z.string()).optional(),
})

/**
 * MembersInRole
 */
export const zMembersInRole = z.object({
  account_id: z.string().optional().default(''),
  account_name: z.string().optional().default(''),
})

/**
 * _MembersInRoleList
 */
export const zMembersInRoleList = z.object({
  data: z.array(zMembersInRole).optional(),
  pagination: zPagination.nullish(),
})

/**
 * AccessPolicyAccount
 */
export const zAccessPolicyAccount = z.object({
  account_id: z.string(),
  account_name: z.string(),
  avatar: z.string().optional().default(''),
  binding_id: z.string(),
  email: z.string().optional().default(''),
  is_locked: z.boolean().optional().default(false),
})

/**
 * AccessPolicyRole
 */
export const zAccessPolicyRole = z.object({
  binding_id: z.string(),
  is_locked: z.boolean().optional().default(false),
  role_id: z.string(),
  role_name: z.string(),
  role_tag: z.string().optional().default(''),
})

/**
 * AccessMatrixItem
 */
export const zAccessMatrixItem = z.object({
  accounts: z.array(zAccessPolicyAccount).optional(),
  policy: zAccessPolicy.nullish(),
  roles: z.array(zAccessPolicyRole).optional(),
})

/**
 * AppAccessMatrix
 */
export const zAppAccessMatrix = z.object({
  app_id: z.string().optional().default(''),
  items: z.array(zAccessMatrixItem).optional(),
})

/**
 * DatasetAccessMatrix
 */
export const zDatasetAccessMatrix = z.object({
  dataset_id: z.string().optional().default(''),
  items: z.array(zAccessMatrixItem).optional(),
})

/**
 * WorkspaceAccessMatrix
 */
export const zWorkspaceAccessMatrix = z.object({
  items: z.array(zAccessMatrixItem).optional(),
  pagination: zPagination.nullish(),
})

/**
 * ToolEmojiIcon
 */
export const zToolEmojiIcon = z.object({
  background: z.string(),
  content: z.string(),
})

/**
 * ApiProviderSchemaType
 *
 * Enum class for api provider schema type.
 */
export const zApiProviderSchemaType = z.enum([
  'openai_actions',
  'openai_plugin',
  'openapi',
  'swagger',
])

/**
 * ApiToolProviderAddPayload
 */
export const zApiToolProviderAddPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  custom_disclaimer: z.string().optional().default(''),
  icon: zToolEmojiIcon,
  labels: z.array(z.string()).nullish(),
  privacy_policy: z.string().nullish(),
  provider: z.string(),
  schema: z.string(),
  schema_type: zApiProviderSchemaType,
})

/**
 * ApiToolTestPayload
 */
export const zApiToolTestPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  parameters: z.record(z.string(), z.unknown()),
  provider_name: z.string().nullish(),
  schema: z.string(),
  schema_type: zApiProviderSchemaType,
  tool_name: z.string(),
})

/**
 * ApiToolProviderUpdatePayload
 */
export const zApiToolProviderUpdatePayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  custom_disclaimer: z.string().optional().default(''),
  icon: zToolEmojiIcon,
  labels: z.array(z.string()).nullish(),
  original_provider: z.string(),
  privacy_policy: z.string().nullish(),
  provider: z.string(),
  schema: z.string(),
  schema_type: zApiProviderSchemaType,
})

/**
 * ApiToolPreviewResult
 */
export const zApiToolPreviewResult = z.object({
  error: z.string().optional(),
  result: z.string().optional(),
})

/**
 * ApiToolPreviewResponse
 */
export const zApiToolPreviewResponse = zApiToolPreviewResult

/**
 * CredentialType
 */
export const zCredentialType = z.enum(['api-key', 'oauth2', 'unauthorized'])

/**
 * BuiltinToolAddPayload
 */
export const zBuiltinToolAddPayload = z.object({
  credentials: z.record(z.string(), z.unknown()),
  name: z.string().max(30).nullish(),
  type: zCredentialType,
  visibility: z.string().nullish(),
})

/**
 * SubscriptionBuilderApiEntity
 */
export const zSubscriptionBuilderApiEntity = z.object({
  credential_type: zCredentialType,
  credentials: z.record(z.string(), z.string()),
  endpoint: z.string(),
  id: z.string(),
  name: z.string(),
  parameters: z.record(z.string(), z.unknown()),
  properties: z.record(z.string(), z.unknown()),
  provider: z.string(),
})

/**
 * TriggerSubscriptionBuilderCreateResponse
 */
export const zTriggerSubscriptionBuilderCreateResponse = z.object({
  subscription_builder: zSubscriptionBuilderApiEntity,
})

/**
 * TriggerOAuthAuthorizeResponse
 */
export const zTriggerOAuthAuthorizeResponse = z.object({
  authorization_url: z.string(),
  subscription_builder: zSubscriptionBuilderApiEntity,
  subscription_builder_id: z.string(),
})

/**
 * ToolProviderCredentialApiEntity
 */
export const zToolProviderCredentialApiEntity = z.object({
  created_by: z.string().optional().default(''),
  credential_type: zCredentialType,
  credentials: z.record(z.string(), z.unknown()).optional(),
  from_other_member: z.boolean().optional().default(false),
  id: z.string(),
  is_default: z.boolean().optional().default(false),
  name: z.string(),
  partial_member_list: z.array(z.string()).optional(),
  provider: z.string(),
  visibility: z.string().optional().default('all_team_members'),
})

/**
 * ToolProviderCredentialInfoApiEntity
 */
export const zToolProviderCredentialInfoApiEntity = z.object({
  credentials: z.array(zToolProviderCredentialApiEntity),
  is_oauth_custom_client_enabled: z.boolean().optional().default(false),
  supported_credential_types: z.array(zCredentialType),
})

/**
 * ToolProviderCredentialListResponse
 */
export const zToolProviderCredentialListResponse = z.array(zToolProviderCredentialApiEntity)

/**
 * MCPAuthentication
 */
export const zMcpAuthentication = z.object({
  client_id: z.string(),
  client_secret: z.string().nullish(),
})

/**
 * MCPConfiguration
 */
export const zMcpConfiguration = z.object({
  sse_read_timeout: z.number().optional().default(300),
  timeout: z.number().optional().default(30),
})

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

/**
 * PluginParameterOption
 */
export const zPluginParameterOption = z.object({
  icon: z.string().nullish(),
  label: zI18nObject,
  value: z.string(),
})

/**
 * PluginDynamicOptionsResponse
 */
export const zPluginDynamicOptionsResponse = z.object({
  options: z.array(zPluginParameterOption),
})

/**
 * ToolLabel
 *
 * Tool label
 */
export const zToolLabel = z.object({
  icon: z.string(),
  label: zI18nObject,
  name: z.string(),
})

/**
 * ToolLabelListResponse
 */
export const zToolLabelListResponse = z.array(zToolLabel)

/**
 * ToolProviderType
 *
 * Enum class for tool provider
 */
export const zToolProviderType = z.enum([
  'api',
  'app',
  'builtin',
  'dataset-retrieval',
  'mcp',
  'plugin',
  'workflow',
])

/**
 * IdentityMode
 *
 * How Dify forwards the end-user's identity to an MCP server.
 */
export const zIdentityMode = z.enum(['idp_token', 'off'])

/**
 * MCPProviderCreatePayload
 */
export const zMcpProviderCreatePayload = z.object({
  authentication: zMcpAuthentication.nullish(),
  configuration: zMcpConfiguration.nullish(),
  headers: z.record(z.string(), z.string()).nullish(),
  icon: z.string(),
  icon_background: z.string().optional().default(''),
  icon_type: z.string(),
  identity_mode: zIdentityMode.nullish(),
  name: z.string(),
  server_identifier: z.string(),
  server_url: z.string(),
})

/**
 * MCPProviderUpdatePayload
 */
export const zMcpProviderUpdatePayload = z.object({
  authentication: zMcpAuthentication.nullish(),
  configuration: zMcpConfiguration.nullish(),
  headers: z.record(z.string(), z.string()).nullish(),
  icon: z.string(),
  icon_background: z.string().optional().default(''),
  icon_type: z.string(),
  identity_mode: zIdentityMode.nullish(),
  name: z.string(),
  provider_id: z.string(),
  server_identifier: z.string(),
  server_url: z.string(),
})

/**
 * TriggerCreationMethod
 */
export const zTriggerCreationMethod = z.enum(['APIKEY', 'MANUAL', 'OAUTH'])

/**
 * RequestLog
 */
export const zRequestLog = z.object({
  created_at: z.iso.datetime(),
  endpoint: z.string(),
  id: z.string(),
  request: z.record(z.string(), z.unknown()),
  response: z.record(z.string(), z.unknown()),
})

/**
 * TriggerSubscriptionBuilderLogsResponse
 */
export const zTriggerSubscriptionBuilderLogsResponse = z.object({
  logs: z.array(zRequestLog),
})

/**
 * TriggerProviderSubscriptionApiEntity
 */
export const zTriggerProviderSubscriptionApiEntity = z.object({
  credential_type: zCredentialType,
  credentials: z.record(z.string(), z.unknown()),
  endpoint: z.string(),
  id: z.string(),
  name: z.string(),
  parameters: z.record(z.string(), z.unknown()),
  properties: z.record(z.string(), z.unknown()),
  provider: z.string(),
  workflows_in_use: z.int(),
})

/**
 * TriggerProviderSubscriptionListResponse
 */
export const zTriggerProviderSubscriptionListResponse = z.array(
  zTriggerProviderSubscriptionApiEntity,
)

/**
 * PluginDependencyType
 */
export const zPluginDependencyType = z.enum(['github', 'marketplace', 'package'])

/**
 * Github
 */
export const zGithub = z.object({
  github_plugin_unique_identifier: z.string(),
  package: z.string(),
  repo: z.string(),
  version: z.string(),
})

/**
 * Marketplace
 */
export const zMarketplace = z.object({
  marketplace_plugin_unique_identifier: z.string(),
  version: z.string().nullish(),
})

/**
 * Package
 */
export const zPackage = z.object({
  plugin_unique_identifier: z.string(),
  version: z.string().nullish(),
})

/**
 * PluginDependency
 */
export const zPluginDependency = z.object({
  current_identifier: z.string().nullish(),
  type: zPluginDependencyType,
  value: z.union([zGithub, zMarketplace, zPackage]),
})

/**
 * SnippetDependencyCheckResponse
 */
export const zSnippetDependencyCheckResponse = z.object({
  leaked_dependencies: z.array(zPluginDependency),
})

/**
 * ConfigurateMethod
 *
 * Enum class for configurate method of provider model.
 */
export const zConfigurateMethod = z.enum(['customizable-model', 'predefined-model'])

/**
 * ProviderType
 */
export const zProviderType = z.enum(['custom', 'system'])

/**
 * ModelFeature
 *
 * Enum class for llm feature.
 */
export const zModelFeature = z.enum([
  'agent-thought',
  'audio',
  'document',
  'multi-tool-call',
  'polling',
  'stream-tool-call',
  'structured-output',
  'tool-call',
  'video',
  'vision',
])

/**
 * FetchFrom
 *
 * Enum class for fetch from.
 */
export const zFetchFrom = z.enum(['customizable-model', 'predefined-model'])

/**
 * ModelPropertyKey
 *
 * Enum class for model property key.
 */
export const zModelPropertyKey = z.enum([
  'audio_type',
  'context_size',
  'default_voice',
  'file_upload_limit',
  'max_characters_per_chunk',
  'max_chunks',
  'max_workers',
  'mode',
  'supported_file_extensions',
  'voices',
  'word_limit',
])

/**
 * ModelStatus
 *
 * Enum class for model status.
 */
export const zModelStatus = z.enum([
  'active',
  'credential-removed',
  'disabled',
  'no-configure',
  'no-permission',
  'quota-exceeded',
])

/**
 * ModelLoadBalancingConfigResponse
 */
export const zModelLoadBalancingConfigResponse = z.object({
  credential_id: z.string().nullish(),
  credentials: z.record(z.string(), z.unknown()),
  enabled: z.boolean(),
  id: z.string(),
  in_cooldown: z.boolean(),
  name: z.string(),
  ttl: z.int(),
})

/**
 * ModelLoadBalancingResponse
 */
export const zModelLoadBalancingResponse = z.object({
  configs: z.array(zModelLoadBalancingConfigResponse),
  enabled: z.boolean(),
})

/**
 * ModelCredentialResponse
 */
export const zModelCredentialResponse = z.object({
  available_credentials: z.array(zCredentialConfiguration),
  credentials: z.record(z.string(), z.unknown()),
  current_credential_id: z.string().nullish(),
  current_credential_name: z.string().nullish(),
  load_balancing: zModelLoadBalancingResponse,
})

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

/**
 * ProviderHelpEntity
 *
 * Model class for provider help.
 */
export const zProviderHelpEntity = z.object({
  title: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  url: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
})

/**
 * ParameterType
 *
 * Enum class for parameter type.
 */
export const zParameterType = z.enum(['boolean', 'float', 'int', 'string', 'text'])

/**
 * ParameterRule
 *
 * Model class for parameter rule.
 */
export const zParameterRule = z.object({
  default: z.unknown().nullish(),
  help: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  max: z.number().nullish(),
  min: z.number().nullish(),
  name: z.string(),
  options: z.array(z.string()).optional().default([]),
  precision: z.int().nullish(),
  required: z.boolean().optional().default(false),
  type: zParameterType,
  use_template: z.string().nullish(),
})

/**
 * ModelParameterRuleListResponse
 */
export const zModelParameterRuleListResponse = z.object({
  data: z.array(zParameterRule),
})

/**
 * ProviderModelWithStatusEntity
 *
 * Model class for model response.
 */
export const zProviderModelWithStatusEntity = z.object({
  deprecated: z.boolean().optional().default(false),
  features: z.array(zModelFeature).nullish(),
  fetch_from: zFetchFrom,
  has_invalid_load_balancing_configs: z.boolean().optional().default(false),
  label: zI18nObject,
  load_balancing_enabled: z.boolean().optional().default(false),
  model: z.string(),
  model_properties: z.record(z.string(), z.unknown()),
  model_type: zModelType,
  status: zModelStatus,
})

/**
 * CustomConfigurationStatus
 *
 * Enum class for custom configuration status.
 */
export const zCustomConfigurationStatus = z.enum(['active', 'no-configure'])

/**
 * ProviderWithModelsResponse
 *
 * Model class for provider with models response.
 */
export const zProviderWithModelsResponse = z.object({
  icon_small: zI18nObject.nullish(),
  icon_small_dark: zI18nObject.nullish(),
  label: zI18nObject,
  models: z.array(zProviderModelWithStatusEntity),
  provider: z.string(),
  status: zCustomConfigurationStatus,
  tenant_id: z.string(),
})

/**
 * AvailableModelListResponse
 */
export const zAvailableModelListResponse = z.object({
  data: z.array(zProviderWithModelsResponse),
})

/**
 * TenantPluginAutoUpgradeStrategySetting
 */
export const zTenantPluginAutoUpgradeStrategySetting = z.enum(['disabled', 'fix_only', 'latest'])

/**
 * TenantPluginAutoUpgradeMode
 */
export const zTenantPluginAutoUpgradeMode = z.enum(['all', 'exclude', 'partial'])

/**
 * PluginAutoUpgradeSettingsPayload
 */
export const zPluginAutoUpgradeSettingsPayload = z.object({
  exclude_plugins: z.array(z.string()).optional(),
  include_plugins: z.array(z.string()).optional(),
  strategy_setting: zTenantPluginAutoUpgradeStrategySetting.optional().default('fix_only'),
  upgrade_mode: zTenantPluginAutoUpgradeMode.optional().default('exclude'),
  upgrade_time_of_day: z.int().optional().default(0),
})

/**
 * ParserAutoUpgradeChange
 */
export const zParserAutoUpgradeChange = z.object({
  auto_upgrade: zPluginAutoUpgradeSettingsPayload,
  category: zTenantPluginAutoUpgradeCategory,
})

/**
 * PluginAutoUpgradeSettingsResponseModel
 */
export const zPluginAutoUpgradeSettingsResponseModel = z.object({
  exclude_plugins: z.array(z.string()),
  include_plugins: z.array(z.string()),
  strategy_setting: zTenantPluginAutoUpgradeStrategySetting,
  upgrade_mode: zTenantPluginAutoUpgradeMode,
  upgrade_time_of_day: z.int(),
})

/**
 * PluginAutoUpgradeFetchResponse
 */
export const zPluginAutoUpgradeFetchResponse = z.object({
  auto_upgrade: zPluginAutoUpgradeSettingsResponseModel,
  category: zTenantPluginAutoUpgradeCategory,
})

/**
 * PluginCategory
 */
export const zPluginCategory = z.enum([
  'agent-strategy',
  'datasource',
  'extension',
  'model',
  'tool',
  'trigger',
])

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

/**
 * Meta
 */
export const zMeta = z.object({
  minimum_dify_version: z.string().nullish(),
  version: z.string().nullish(),
})

/**
 * Plugins
 */
export const zPlugins = z.object({
  datasources: z.array(z.string()).nullish(),
  endpoints: z.array(z.string()).nullish(),
  models: z.array(z.string()).nullish(),
  tools: z.array(z.string()).nullish(),
  triggers: z.array(z.string()).nullish(),
})

/**
 * PluginInstallTaskStatus
 */
export const zPluginInstallTaskStatus = z.enum(['failed', 'pending', 'running', 'success'])

/**
 * PluginInstallTaskPluginStatus
 */
export const zPluginInstallTaskPluginStatus = z.object({
  icon: z.string(),
  labels: zI18nObject,
  message: z.string(),
  plugin_id: z.string(),
  plugin_unique_identifier: z.string(),
  source: z.string().nullish(),
  status: zPluginInstallTaskStatus,
})

/**
 * PluginInstallTask
 */
export const zPluginInstallTask = z.object({
  completed_plugins: z.int(),
  created_at: z.iso.datetime(),
  id: z.string(),
  plugins: z.array(zPluginInstallTaskPluginStatus),
  status: zPluginInstallTaskStatus,
  total_plugins: z.int(),
  updated_at: z.iso.datetime(),
})

/**
 * PluginInstallTaskStartResponse
 */
export const zPluginInstallTaskStartResponse = z.object({
  all_installed: z.boolean(),
  task: zPluginInstallTask.nullish(),
  task_id: z.string(),
})

/**
 * PluginTasksResponse
 */
export const zPluginTasksResponse = z.object({
  tasks: z.array(zPluginInstallTask),
})

/**
 * PluginTaskResponse
 */
export const zPluginTaskResponse = z.object({
  task: zPluginInstallTask,
})

/**
 * PluginInstallationSource
 */
export const zPluginInstallationSource = z.enum(['github', 'marketplace', 'package', 'remote'])

/**
 * PluginBundleDependencyType
 */
export const zPluginBundleDependencyType = z.enum(['github', 'marketplace', 'package'])

/**
 * PluginBundleDependency
 */
export const zPluginBundleDependency = z.object({
  type: zPluginBundleDependencyType,
  value: z.union([zGithub, zMarketplace, zPackage]),
})

/**
 * PluginBundleUploadResponse
 */
export const zPluginBundleUploadResponse = z.array(zPluginBundleDependency)

/**
 * AuthorizedCategory
 */
export const zAuthorizedCategory = z.enum(['community', 'langgenius', 'partner'])

/**
 * PluginVerification
 *
 * Verification of the plugin.
 */
export const zPluginVerification = z.object({
  authorized_category: zAuthorizedCategory,
})

/**
 * PluginCategoryBuiltinToolResponse
 */
export const zPluginCategoryBuiltinToolResponse = z.object({
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  labels: z.array(z.string()),
  name: z.string(),
  output_schema: z.record(z.string(), z.unknown()),
  parameters: z.array(z.record(z.string(), z.unknown())).nullish(),
})

/**
 * PluginCategoryBuiltinToolProviderResponse
 */
export const zPluginCategoryBuiltinToolProviderResponse = z.object({
  allow_delete: z.boolean(),
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  icon: z.union([z.string(), z.record(z.string(), z.string())]),
  icon_dark: z.union([z.string(), z.record(z.string(), z.string())]).nullable(),
  id: z.string(),
  is_team_authorization: z.boolean(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  labels: z.array(z.string()),
  name: z.string(),
  plugin_id: z.string().nullable(),
  plugin_unique_identifier: z.string().nullable(),
  team_credentials: z.record(z.string(), z.unknown()),
  tools: z.array(zPluginCategoryBuiltinToolResponse),
  type: zToolProviderType,
})

/**
 * RBACRoleAccount
 */
export const zRbacRoleAccount = z.object({
  account_id: z.string(),
  account_name: z.string().optional().default(''),
  avatar: z.string().optional().default(''),
  email: z.string().optional().default(''),
})

/**
 * ResourceUserAccessPolicies
 */
export const zResourceUserAccessPolicies = z.object({
  access_policies: z.array(zAccessPolicy).optional(),
  account: zRbacRoleAccount,
  roles: z.array(zRbacRole).optional(),
})

/**
 * ResourceUserAccessPoliciesResponse
 */
export const zResourceUserAccessPoliciesResponse = z.object({
  data: z.array(zResourceUserAccessPolicies).optional(),
  scope: zRbacResourceWhitelistScope,
})

/**
 * ResourcePermissionKeys
 */
export const zResourcePermissionKeys = z.object({
  permission_keys: z.array(z.string()).optional(),
  resource_id: z.string(),
})

/**
 * ResourcePermissionSnapshot
 */
export const zResourcePermissionSnapshot = z.object({
  default_permission_keys: z.array(z.string()).optional(),
  overrides: z.array(zResourcePermissionKeys).optional(),
})

/**
 * MyPermissionsResponse
 */
export const zMyPermissionsResponse = z.object({
  app: zResourcePermissionSnapshot.optional(),
  dataset: zResourcePermissionSnapshot.optional(),
  workspace: zWorkspacePermissionSnapshot.optional(),
})

/**
 * PermissionCatalogItem
 */
export const zPermissionCatalogItem = z.object({
  description: z.string().optional().default(''),
  key: z.string(),
  name: z.string(),
})

/**
 * PermissionCatalogGroup
 */
export const zPermissionCatalogGroup = z.object({
  description: z.string().optional().default(''),
  group_key: z.string(),
  group_name: z.string(),
  permissions: z.array(zPermissionCatalogItem).optional(),
})

/**
 * PermissionCatalogResponse
 */
export const zPermissionCatalogResponse = z.object({
  groups: z.array(zPermissionCatalogGroup).optional(),
})

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

/**
 * ProviderConfigListResponse
 */
export const zProviderConfigListResponse = z.array(zProviderConfig)

/**
 * BuiltinProviderOAuthClientSchemaResponse
 */
export const zBuiltinProviderOAuthClientSchemaResponse = z.object({
  client_params: z.record(z.string(), z.unknown()).nullish(),
  is_oauth_custom_client_enabled: z.boolean(),
  is_system_oauth_params_exists: z.boolean(),
  redirect_uri: z.string(),
  schema: z.array(zProviderConfig),
})

/**
 * TriggerOAuthClientResponse
 */
export const zTriggerOAuthClientResponse = z.object({
  configured: z.boolean(),
  custom_configured: z.boolean(),
  custom_enabled: z.boolean(),
  oauth_client_schema: z.array(zProviderConfig),
  params: z.record(z.string(), z.unknown()),
  redirect_uri: z.string(),
  system_configured: z.boolean(),
})

/**
 * ToolParameterForm
 */
export const zToolParameterForm = z.enum(['form', 'llm', 'schema'])

/**
 * WorkflowToolParameterConfiguration
 *
 * Workflow tool configuration
 */
export const zWorkflowToolParameterConfiguration = z.object({
  description: z.string(),
  form: zToolParameterForm,
  name: z.string(),
})

/**
 * WorkflowToolCreatePayload
 */
export const zWorkflowToolCreatePayload = z.object({
  description: z.string(),
  icon: zToolEmojiIcon,
  label: z.string(),
  labels: z.array(z.string()).nullish(),
  name: z.string(),
  parameters: z.array(zWorkflowToolParameterConfiguration).optional(),
  privacy_policy: z.string().nullish().default(''),
  workflow_app_id: z.string(),
})

/**
 * WorkflowToolUpdatePayload
 */
export const zWorkflowToolUpdatePayload = z.object({
  description: z.string(),
  icon: zToolEmojiIcon,
  label: z.string(),
  labels: z.array(z.string()).nullish(),
  name: z.string(),
  parameters: z.array(zWorkflowToolParameterConfiguration).optional(),
  privacy_policy: z.string().nullish().default(''),
  workflow_tool_id: z.string(),
})

/**
 * EventIdentity
 *
 * The identity of the event
 */
export const zEventIdentity = z.object({
  author: z.string(),
  label: zI18nObject,
  name: z.string(),
  provider: z.string().nullish(),
})

/**
 * OAuthSchema
 *
 * OAuth schema
 */
export const zOAuthSchema = z.object({
  client_schema: z.array(zProviderConfig).optional(),
  credentials_schema: z.array(zProviderConfig).optional(),
})

/**
 * EndpointDeclarationResponse
 */
export const zEndpointDeclarationResponse = z.object({
  hidden: z.boolean().optional().default(false),
  method: z.string(),
  path: z.string(),
})

/**
 * UnaddedModelConfiguration
 *
 * Model class for provider unadded model configuration.
 */
export const zUnaddedModelConfiguration = z.object({
  model: z.string(),
  model_type: zModelType,
})

/**
 * CustomModelConfiguration
 *
 * Model class for provider custom model configuration.
 */
export const zCustomModelConfiguration = z.object({
  available_model_credentials: z.array(zCredentialConfiguration).optional().default([]),
  credentials: z.record(z.string(), z.unknown()).nullable(),
  current_credential_id: z.string().nullish(),
  current_credential_name: z.string().nullish(),
  model: z.string(),
  model_type: zModelType,
  unadded_to_model_list: z.boolean().optional().default(false),
})

/**
 * CustomConfigurationResponse
 *
 * Model class for provider custom configuration response.
 */
export const zCustomConfigurationResponse = z.object({
  available_credentials: z.array(zCredentialConfiguration).nullish(),
  can_added_models: z.array(zUnaddedModelConfiguration).nullish(),
  current_credential_id: z.string().nullish(),
  current_credential_name: z.string().nullish(),
  custom_models: z.array(zCustomModelConfiguration).nullish(),
  status: zCustomConfigurationStatus,
})

/**
 * FieldModelSchema
 */
export const zFieldModelSchema = z.object({
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  placeholder: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
})

/**
 * ProviderQuotaType
 */
export const zProviderQuotaType = z.enum(['free', 'paid', 'trial'])

/**
 * DatasourceProviderType
 *
 * Enum class for datasource provider
 */
export const zDatasourceProviderType = z.enum([
  'local_file',
  'online_document',
  'online_drive',
  'website_crawl',
])

/**
 * EndpointDeclaration
 *
 * declaration of an endpoint
 */
export const zEndpointDeclaration = z.object({
  hidden: z.boolean().optional().default(false),
  method: z.string(),
  path: z.string(),
})

/**
 * EndpointProviderDeclaration
 *
 * declaration of an endpoint group
 */
export const zEndpointProviderDeclaration = z.object({
  endpoints: z.array(zEndpointDeclaration).nullish(),
  settings: z.array(zProviderConfig).optional(),
})

/**
 * TriggerProviderIdentity
 *
 * The identity of the trigger provider
 */
export const zTriggerProviderIdentity = z.object({
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  icon: z.string().nullish(),
  icon_dark: z.string().nullish(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  name: z.string(),
  tags: z.array(z.string()).optional(),
})

/**
 * PluginParameterTemplate
 */
export const zPluginParameterTemplate = z.object({
  enabled: z.boolean().optional().default(false),
})

/**
 * ToolParameterType
 *
 * removes TOOLS_SELECTOR from PluginParameterType
 */
export const zToolParameterType = z.enum([
  'any',
  'app-selector',
  'array',
  'boolean',
  'checkbox',
  'dynamic-select',
  'file',
  'files',
  'model-selector',
  'number',
  'object',
  'secret-input',
  'select',
  'string',
  'system-files',
])

/**
 * EventParameterType
 *
 * The type of the parameter
 */
export const zEventParameterType = z.enum([
  'app-selector',
  'array',
  'boolean',
  'checkbox',
  'dynamic-select',
  'file',
  'files',
  'model-selector',
  'number',
  'object',
  'select',
  'string',
])

/**
 * PriceConfigResponse
 *
 * Serialized pricing info with codegen-safe decimal string patterns.
 */
export const zPriceConfigResponse = z.object({
  currency: z.string(),
  input: z.string().regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/),
  output: z
    .string()
    .regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/)
    .nullish(),
  unit: z.string().regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/),
})

/**
 * AIModelEntityResponse
 */
export const zAiModelEntityResponse = z.object({
  deprecated: z.boolean().optional().default(false),
  features: z.array(zModelFeature).nullish(),
  fetch_from: zFetchFrom,
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  model: z.string(),
  model_properties: z.record(z.string(), z.unknown()),
  model_type: zModelType,
  parameter_rules: z.array(zParameterRule).optional().default([]),
  pricing: zPriceConfigResponse.nullish(),
})

/**
 * SimpleProviderEntityResponse
 *
 * Simple provider entity response.
 */
export const zSimpleProviderEntityResponse = z.object({
  icon_small: zI18nObject.nullish(),
  icon_small_dark: zI18nObject.nullish(),
  label: zI18nObject,
  models: z.array(zAiModelEntityResponse).optional().default([]),
  provider: z.string(),
  provider_name: z.string().optional().default(''),
  supported_model_types: z.array(zModelType),
  tenant_id: z.string(),
})

/**
 * DefaultModelResponse
 *
 * Default model entity.
 */
export const zDefaultModelResponse = z.object({
  model: z.string(),
  model_type: zModelType,
  provider: zSimpleProviderEntityResponse,
})

/**
 * DefaultModelDataResponse
 */
export const zDefaultModelDataResponse = z.object({
  data: zDefaultModelResponse.nullish(),
})

/**
 * ModelWithProviderEntityResponse
 *
 * Model with provider entity.
 */
export const zModelWithProviderEntityResponse = z.object({
  deprecated: z.boolean().optional().default(false),
  features: z.array(zModelFeature).nullish(),
  fetch_from: zFetchFrom,
  has_invalid_load_balancing_configs: z.boolean().optional().default(false),
  label: zI18nObject,
  load_balancing_enabled: z.boolean().optional().default(false),
  model: z.string(),
  model_properties: z.record(z.string(), z.unknown()),
  model_type: zModelType,
  provider: zSimpleProviderEntityResponse,
  status: zModelStatus,
})

/**
 * ProviderModelListResponse
 */
export const zProviderModelListResponse = z.object({
  data: z.array(zModelWithProviderEntityResponse),
})

/**
 * EndpointProviderConfigI18nResponse
 */
export const zEndpointProviderConfigI18nResponse = z.object({
  en_US: z.string(),
  ja_JP: z.string().nullish(),
  pt_BR: z.string().nullish(),
  zh_Hans: z.string().nullish(),
})

/**
 * EndpointProviderConfigOptionResponse
 */
export const zEndpointProviderConfigOptionResponse = z.object({
  label: zEndpointProviderConfigI18nResponse,
  value: z.string(),
})

/**
 * EndpointProviderConfigScope
 */
export const zEndpointProviderConfigScope = z.enum([
  'all',
  'builtin',
  'chat',
  'completion',
  'custom',
  'llm',
  'moderation',
  'rerank',
  'speech2text',
  'text-embedding',
  'tts',
  'vision',
  'workflow',
])

/**
 * EndpointProviderConfigResponse
 */
export const zEndpointProviderConfigResponse = z.object({
  default: z.union([z.int(), z.string(), z.number(), z.boolean()]).nullish(),
  help: zEndpointProviderConfigI18nResponse.nullish(),
  label: zEndpointProviderConfigI18nResponse.nullish(),
  multiple: z.boolean().optional().default(false),
  name: z.string(),
  options: z.array(zEndpointProviderConfigOptionResponse).nullish(),
  placeholder: zEndpointProviderConfigI18nResponse.nullish(),
  required: z.boolean().optional().default(false),
  scope: zEndpointProviderConfigScope.nullish(),
  type: zProviderConfigType,
  url: z.string().nullish(),
})

/**
 * EndpointProviderDeclarationResponse
 */
export const zEndpointProviderDeclarationResponse = z.object({
  endpoints: z.array(zEndpointDeclarationResponse).nullish(),
  settings: z.array(zEndpointProviderConfigResponse).optional(),
})

/**
 * EndpointListItemResponse
 */
export const zEndpointListItemResponse = z.object({
  created_at: z.iso.datetime(),
  declaration: zEndpointProviderDeclarationResponse.optional(),
  enabled: z.boolean(),
  expired_at: z.iso.datetime(),
  hook_id: z.string(),
  id: z.string(),
  name: z.string(),
  plugin_id: z.string(),
  settings: z.record(z.string(), z.unknown()),
  tenant_id: z.string(),
  updated_at: z.iso.datetime(),
  url: z.string(),
})

/**
 * EndpointListResponse
 */
export const zEndpointListResponse = z.object({
  endpoints: z.array(zEndpointListItemResponse),
})

/**
 * FormShowOnObject
 *
 * Model class for form show on.
 */
export const zFormShowOnObject = z.object({
  value: z.string(),
  variable: z.string(),
})

/**
 * FormOption
 *
 * Model class for form option.
 */
export const zFormOption = z.object({
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  show_on: z.array(zFormShowOnObject).optional().default([]),
  value: z.string(),
})

/**
 * FormType
 *
 * Enum class for form type.
 */
export const zFormType = z.enum(['radio', 'secret-input', 'select', 'switch', 'text-input'])

/**
 * CredentialFormSchema
 *
 * Model class for credential form schema.
 */
export const zCredentialFormSchema = z.object({
  default: z.string().nullish(),
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  max_length: z.int().optional().default(0),
  options: z.array(zFormOption).nullish(),
  placeholder: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  required: z.boolean().optional().default(true),
  show_on: z.array(zFormShowOnObject).optional().default([]),
  type: zFormType,
  variable: z.string(),
})

/**
 * ModelCredentialSchema
 *
 * Model class for model credential schema.
 */
export const zModelCredentialSchema = z.object({
  credential_form_schemas: z.array(zCredentialFormSchema),
  model: zFieldModelSchema,
})

/**
 * ProviderCredentialSchema
 *
 * Model class for provider credential schema.
 */
export const zProviderCredentialSchema = z.object({
  credential_form_schemas: z.array(zCredentialFormSchema),
})

/**
 * ProviderEntityResponse
 *
 * Runtime provider response with codegen-safe model pricing schemas.
 */
export const zProviderEntityResponse = z.object({
  background: z.string().nullish(),
  configurate_methods: z.array(zConfigurateMethod),
  description: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  help: zProviderHelpEntity.nullish(),
  icon_small: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  icon_small_dark: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  model_credential_schema: zModelCredentialSchema.nullish(),
  models: z.array(zAiModelEntityResponse).optional().default([]),
  position: z.record(z.string(), z.array(z.string())).nullish().default({}),
  provider: z.string(),
  provider_credential_schema: zProviderCredentialSchema.nullish(),
  provider_name: z.string().optional().default(''),
  supported_model_types: z.array(zModelType),
})

/**
 * PluginDeclarationResponse
 */
export const zPluginDeclarationResponse = z.object({
  agent_strategy: z.record(z.string(), z.unknown()).nullish(),
  author: z.string().nullable(),
  category: zPluginCategory,
  created_at: z.iso.datetime(),
  datasource: z.record(z.string(), z.unknown()).nullish(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  endpoint: z.record(z.string(), z.unknown()).nullish(),
  icon: z.string(),
  icon_dark: z.string().nullish(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  meta: z.record(z.string(), z.unknown()),
  model: zProviderEntityResponse.nullish(),
  name: z.string(),
  plugins: z.record(z.string(), z.array(z.string()).nullable()),
  repo: z.string().nullish(),
  resource: z.record(z.string(), z.unknown()),
  tags: z.array(z.string()).optional(),
  tool: z.record(z.string(), z.unknown()).nullish(),
  trigger: z.record(z.string(), z.unknown()).nullish(),
  verified: z.boolean().optional().default(false),
  version: z.string(),
})

/**
 * PluginInstallationItemResponse
 */
export const zPluginInstallationItemResponse = z.object({
  checksum: z.string(),
  created_at: z.iso.datetime(),
  declaration: zPluginDeclarationResponse,
  endpoints_active: z.int(),
  endpoints_setups: z.int(),
  id: z.string(),
  meta: z.record(z.string(), z.unknown()),
  plugin_id: z.string(),
  plugin_unique_identifier: z.string(),
  runtime_type: z.string(),
  source: zPluginInstallationSource,
  tenant_id: z.string(),
  updated_at: z.iso.datetime(),
  version: z.string(),
})

/**
 * PluginInstallationsResponse
 */
export const zPluginInstallationsResponse = z.object({
  plugins: z.array(zPluginInstallationItemResponse),
})

/**
 * PluginCategoryInstalledPluginResponse
 */
export const zPluginCategoryInstalledPluginResponse = z.object({
  checksum: z.string(),
  created_at: z.iso.datetime(),
  declaration: zPluginDeclarationResponse,
  endpoints_active: z.int(),
  endpoints_setups: z.int(),
  id: z.string(),
  installation_id: z.string(),
  meta: z.record(z.string(), z.unknown()),
  name: z.string(),
  plugin_id: z.string(),
  plugin_unique_identifier: z.string(),
  runtime_type: z.string(),
  source: zPluginInstallationSource,
  tenant_id: z.string(),
  updated_at: z.iso.datetime(),
  version: z.string(),
})

/**
 * PluginCategoryListResponse
 */
export const zPluginCategoryListResponse = z.object({
  builtin_tools: z.array(zPluginCategoryBuiltinToolProviderResponse),
  has_more: z.boolean(),
  plugins: z.array(zPluginCategoryInstalledPluginResponse),
})

/**
 * QuotaUnit
 */
export const zQuotaUnit = z.enum(['credits', 'times', 'tokens'])

/**
 * RestrictModel
 */
export const zRestrictModel = z.object({
  base_model_name: z.string().nullish(),
  model: z.string(),
  model_type: zModelType,
})

/**
 * QuotaConfiguration
 *
 * Model class for provider quota configuration.
 */
export const zQuotaConfiguration = z.object({
  is_valid: z.boolean(),
  quota_limit: z.int(),
  quota_type: zProviderQuotaType,
  quota_unit: zQuotaUnit,
  quota_used: z.int(),
  restrict_models: z.array(zRestrictModel).optional().default([]),
})

/**
 * SystemConfigurationResponse
 *
 * Model class for provider system configuration response.
 */
export const zSystemConfigurationResponse = z.object({
  current_quota_type: zProviderQuotaType.nullish(),
  enabled: z.boolean(),
  quota_configurations: z.array(zQuotaConfiguration).optional().default([]),
})

/**
 * ProviderResponse
 *
 * Model class for provider response.
 */
export const zProviderResponse = z.object({
  background: z.string().nullish(),
  configurate_methods: z.array(zConfigurateMethod),
  custom_configuration: zCustomConfigurationResponse,
  description: zI18nObject.nullish(),
  help: zProviderHelpEntity.nullish(),
  icon_small: zI18nObject.nullish(),
  icon_small_dark: zI18nObject.nullish(),
  label: zI18nObject,
  model_credential_schema: zModelCredentialSchema.nullish(),
  preferred_provider_type: zProviderType,
  provider: z.string(),
  provider_credential_schema: zProviderCredentialSchema.nullish(),
  supported_model_types: z.array(zModelType),
  system_configuration: zSystemConfigurationResponse,
  tenant_id: z.string(),
})

/**
 * ModelProviderListResponse
 */
export const zModelProviderListResponse = z.object({
  data: z.array(zProviderResponse),
})

/**
 * ToolLabelEnum
 */
export const zToolLabelEnum = z.enum([
  'business',
  'design',
  'education',
  'entertainment',
  'finance',
  'image',
  'medical',
  'news',
  'other',
  'productivity',
  'rag',
  'search',
  'social',
  'travel',
  'utilities',
  'videos',
  'weather',
])

/**
 * AgentStrategyProviderIdentity
 *
 * Inherits from ToolProviderIdentity, without any additional fields.
 */
export const zAgentStrategyProviderIdentity = z.object({
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  icon: z.string(),
  icon_dark: z.string().nullish(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  name: z.string(),
  tags: z.array(zToolLabelEnum).nullish().default([]),
})

/**
 * AgentStrategyProviderEntity
 */
export const zAgentStrategyProviderEntity = z.object({
  identity: zAgentStrategyProviderIdentity,
  plugin_id: z.string().nullish(),
})

/**
 * DatasourceProviderIdentity
 */
export const zDatasourceProviderIdentity = z.object({
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  icon: z.string(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  name: z.string(),
  tags: z.array(zToolLabelEnum).nullish().default([]),
})

/**
 * DatasourceProviderEntity
 *
 * Datasource provider entity
 */
export const zDatasourceProviderEntity = z.object({
  credentials_schema: z.array(zProviderConfig).optional(),
  identity: zDatasourceProviderIdentity,
  oauth_schema: zOAuthSchema.nullish(),
  provider_type: zDatasourceProviderType,
})

/**
 * ToolProviderIdentity
 */
export const zToolProviderIdentity = z.object({
  author: z.string(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  icon: z.string(),
  icon_dark: z.string().nullish(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  name: z.string(),
  tags: z.array(zToolLabelEnum).nullish().default([]),
})

/**
 * ToolProviderEntity
 */
export const zToolProviderEntity = z.object({
  credentials_schema: z.array(zProviderConfig).optional(),
  identity: zToolProviderIdentity,
  oauth_schema: zOAuthSchema.nullish(),
  plugin_id: z.string().nullish(),
})

/**
 * PriceConfig
 *
 * Model class for pricing info.
 */
export const zPriceConfig = z.object({
  currency: z.string(),
  input: z.string().regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/),
  output: z
    .string()
    .regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/)
    .nullish(),
  unit: z.string().regex(/^(?![-+.]*$)[+-]?0*\d*\.?\d*$/),
})

/**
 * AIModelEntity
 *
 * Model class for AI model.
 */
export const zAiModelEntity = z.object({
  deprecated: z.boolean().optional().default(false),
  features: z.array(zModelFeature).nullish(),
  fetch_from: zFetchFrom,
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  model: z.string(),
  model_properties: z.record(z.string(), z.unknown()),
  model_type: zModelType,
  parameter_rules: z.array(zParameterRule).optional().default([]),
  pricing: zPriceConfig.nullish(),
})

/**
 * ProviderEntity
 *
 * Runtime-native provider schema.
 *
 * `provider` is the canonical runtime identifier. `provider_name` is a
 * compatibility alias for callers that still resolve providers by short name and
 * is empty when no alias exists.
 */
export const zProviderEntity = z.object({
  background: z.string().nullish(),
  configurate_methods: z.array(zConfigurateMethod),
  description: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  help: zProviderHelpEntity.nullish(),
  icon_small: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  icon_small_dark: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject.nullish(),
  label: zGraphonModelRuntimeEntitiesCommonEntitiesI18nObject,
  model_credential_schema: zModelCredentialSchema.nullish(),
  models: z.array(zAiModelEntity).optional(),
  position: z.record(z.string(), z.array(z.string())).nullish().default({}),
  provider: z.string(),
  provider_credential_schema: zProviderCredentialSchema.nullish(),
  provider_name: z.string().optional().default(''),
  supported_model_types: z.array(zModelType),
})

/**
 * Endpoint
 */
export const zEndpoint = z.object({
  enabled: z.boolean().nullish().default(false),
})

/**
 * Model
 */
export const zModel = z.object({
  enabled: z.boolean().nullish().default(false),
  llm: z.boolean().nullish().default(false),
  moderation: z.boolean().nullish().default(false),
  rerank: z.boolean().nullish().default(false),
  speech2text: z.boolean().nullish().default(false),
  text_embedding: z.boolean().nullish().default(false),
  tts: z.boolean().nullish().default(false),
})

/**
 * Node
 */
export const zNode = z.object({
  enabled: z.boolean().nullish().default(false),
})

/**
 * Storage
 */
export const zStorage = z.object({
  enabled: z.boolean().nullish().default(false),
  size: z.int().gte(1024).lte(1073741824).optional().default(1048576),
})

/**
 * Tool
 */
export const zTool = z.object({
  enabled: z.boolean().nullish().default(false),
})

/**
 * Permission
 */
export const zPermission = z.object({
  endpoint: zEndpoint.nullish(),
  model: zModel.nullish(),
  node: zNode.nullish(),
  storage: zStorage.nullish(),
  tool: zTool.nullish(),
})

/**
 * PluginResourceRequirements
 */
export const zPluginResourceRequirements = z.object({
  memory: z.int(),
  permission: zPermission.nullish(),
})

/**
 * PluginParameterAutoGenerateType
 */
export const zPluginParameterAutoGenerateType = z.enum(['prompt_instruction'])

/**
 * PluginParameterAutoGenerate
 */
export const zPluginParameterAutoGenerate = z.object({
  type: zPluginParameterAutoGenerateType,
})

/**
 * ToolParameter
 *
 * Tool-specific parameter declaration and invocation-value normalization.
 */
export const zToolParameter = z.object({
  auto_generate: zPluginParameterAutoGenerate.nullish(),
  default: z
    .union([
      z.number(),
      z.int(),
      z.string(),
      z.boolean(),
      z.array(z.unknown()),
      z.record(z.string(), z.unknown()),
    ])
    .nullish(),
  form: zToolParameterForm,
  human_description: zI18nObject.nullish(),
  input_schema: z.record(z.string(), z.unknown()).nullish(),
  label: zI18nObject,
  llm_description: z.string().nullish(),
  max: z.union([z.number(), z.int()]).nullish(),
  min: z.union([z.number(), z.int()]).nullish(),
  multiple: z.boolean().optional().default(false),
  name: z.string(),
  options: z.array(zPluginParameterOption).optional(),
  placeholder: zI18nObject.nullish(),
  precision: z.int().nullish(),
  required: z.boolean().optional().default(false),
  scope: z.string().nullish(),
  template: zPluginParameterTemplate.nullish(),
  type: zToolParameterType,
})

/**
 * ApiToolBundle
 *
 * This class is used to store the schema information of an api based tool.
 * such as the url, the method, the parameters, etc.
 */
export const zApiToolBundle = z.object({
  author: z.string(),
  icon: z.string().nullish(),
  method: z.string(),
  openapi: z.record(z.string(), z.unknown()),
  operation_id: z.string().nullish(),
  output_schema: z.record(z.string(), z.unknown()).optional(),
  parameters: z.array(zToolParameter).nullish(),
  server_url: z.string(),
  summary: z.string().nullish(),
})

/**
 * ApiProviderDetailResponse
 */
export const zApiProviderDetailResponse = z.object({
  credentials: z.record(z.string(), z.unknown()).optional(),
  custom_disclaimer: z.string().nullish(),
  description: z.string().nullish(),
  icon: zToolEmojiIcon,
  labels: z.array(z.string()).optional(),
  privacy_policy: z.string().nullish(),
  schema: z.string(),
  schema_type: zApiProviderSchemaType,
  tools: z.array(zApiToolBundle),
})

/**
 * ApiSchemaParseResponse
 */
export const zApiSchemaParseResponse = z.object({
  credentials_schema: z.array(zProviderConfig),
  parameters_schema: z.array(zApiToolBundle),
  schema_type: zApiProviderSchemaType,
  warning: z.record(z.string(), z.string()),
})

/**
 * ToolApiEntity
 */
export const zToolApiEntity = z.object({
  author: z.string(),
  description: zI18nObject,
  label: zI18nObject,
  labels: z.array(z.string()).optional(),
  name: z.string(),
  output_schema: z.record(z.string(), z.unknown()).optional(),
  parameters: z.array(zToolParameter).nullish(),
})

/**
 * ToolApiListResponse
 */
export const zToolApiListResponse = z.array(zToolApiEntity)

/**
 * ToolProviderApiEntityResponse
 */
export const zToolProviderApiEntityResponse = z.object({
  allow_delete: z.boolean().optional().default(true),
  authentication: zMcpAuthentication.nullish(),
  author: z.string(),
  configuration: zMcpConfiguration.nullish(),
  description: zI18nObject,
  icon: z.union([z.string(), z.record(z.string(), z.string())]),
  icon_dark: z
    .union([z.string(), z.record(z.string(), z.string())])
    .optional()
    .default(''),
  id: z.string(),
  identity_mode: z.string().optional().default('off'),
  is_dynamic_registration: z.boolean().optional().default(true),
  is_team_authorization: z.boolean().optional().default(false),
  label: zI18nObject,
  labels: z.array(z.string()).optional(),
  masked_headers: z.record(z.string(), z.string()).nullish(),
  name: z.string(),
  original_headers: z.record(z.string(), z.string()).nullish(),
  plugin_id: z.string().nullish().default(''),
  plugin_unique_identifier: z.string().nullish().default(''),
  server_identifier: z.string().nullish().default(''),
  server_url: z.string().nullish().default(''),
  team_credentials: z.record(z.string(), z.unknown()).optional(),
  tools: z.array(zToolApiEntity).optional(),
  type: zToolProviderType,
  updated_at: z.int().optional(),
  workflow_app_id: z.string().nullish(),
})

/**
 * WorkflowToolDetailResponse
 */
export const zWorkflowToolDetailResponse = z.object({
  description: z.string(),
  icon: zToolEmojiIcon,
  label: z.string(),
  name: z.string(),
  output_schema: z.record(z.string(), z.unknown()).optional(),
  parameters: z.array(zWorkflowToolParameterConfiguration),
  privacy_policy: z.string().nullish(),
  synced: z.boolean(),
  tool: zToolApiEntity,
  workflow_app_id: z.string(),
  workflow_tool_id: z.string(),
})

/**
 * ToolProviderListResponse
 */
export const zToolProviderListResponse = z.array(zToolProviderApiEntityResponse)

/**
 * EventParameter
 *
 * The parameter of the event
 */
export const zEventParameter = z.object({
  auto_generate: zPluginParameterAutoGenerate.nullish(),
  default: z.union([z.int(), z.number(), z.string(), z.array(z.unknown())]).nullish(),
  description: zI18nObject.nullish(),
  label: zI18nObject,
  max: z.union([z.number(), z.int()]).nullish(),
  min: z.union([z.number(), z.int()]).nullish(),
  multiple: z.boolean().optional().default(false),
  name: z.string(),
  options: z.array(zPluginParameterOption).nullish(),
  precision: z.int().nullish(),
  required: z.boolean().optional().default(false),
  scope: z.string().nullish(),
  template: zPluginParameterTemplate.nullish(),
  type: zEventParameterType,
})

/**
 * EventApiEntity
 */
export const zEventApiEntity = z.object({
  description: zI18nObject,
  identity: zEventIdentity,
  name: z.string(),
  output_schema: z.record(z.string(), z.unknown()).nullable(),
  parameters: z.array(zEventParameter),
})

/**
 * SubscriptionConstructor
 *
 * The subscription constructor of the trigger provider
 */
export const zSubscriptionConstructor = z.object({
  credentials_schema: z.array(zProviderConfig).optional(),
  oauth_schema: zOAuthSchema.nullish(),
  parameters: z.array(zEventParameter).optional(),
})

/**
 * TriggerProviderApiEntity
 */
export const zTriggerProviderApiEntity = z.object({
  author: z.string(),
  description: zI18nObject,
  events: z.array(zEventApiEntity),
  icon: z.string().nullish(),
  icon_dark: z.string().nullish(),
  label: zI18nObject,
  name: z.string(),
  plugin_id: z.string().nullish().default(''),
  plugin_unique_identifier: z.string().nullish().default(''),
  subscription_constructor: zSubscriptionConstructor.nullish(),
  subscription_schema: z.array(zProviderConfig).optional(),
  supported_creation_methods: z.array(zTriggerCreationMethod).optional(),
  tags: z.array(z.string()).optional(),
})

/**
 * TriggerProviderListResponse
 */
export const zTriggerProviderListResponse = z.array(zTriggerProviderApiEntity)

/**
 * EventEntity
 *
 * The configuration of an event
 */
export const zEventEntity = z.object({
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  identity: zEventIdentity,
  output_schema: z.record(z.string(), z.unknown()).nullish(),
  parameters: z.array(zEventParameter).optional(),
})

/**
 * TriggerProviderEntity
 *
 * The configuration of a trigger provider
 */
export const zTriggerProviderEntity = z.object({
  events: z.array(zEventEntity).optional(),
  identity: zTriggerProviderIdentity,
  subscription_constructor: zSubscriptionConstructor.nullish(),
  subscription_schema: z.array(zProviderConfig).optional(),
})

/**
 * PluginDeclaration
 */
export const zPluginDeclaration = z.object({
  agent_strategy: zAgentStrategyProviderEntity.nullish(),
  author: z
    .string()
    .regex(/^[a-zA-Z0-9_-]{1,64}$/)
    .nullable(),
  category: zPluginCategory,
  created_at: z.iso.datetime(),
  datasource: zDatasourceProviderEntity.nullish(),
  description: zCoreToolsEntitiesCommonEntitiesI18nObject,
  endpoint: zEndpointProviderDeclaration.nullish(),
  icon: z.string(),
  icon_dark: z.string().nullish(),
  label: zCoreToolsEntitiesCommonEntitiesI18nObject,
  meta: zMeta,
  model: zProviderEntity.nullish(),
  name: z.string().regex(/^[a-z0-9_-]{1,128}$/),
  plugins: zPlugins,
  repo: z.string().nullish(),
  resource: zPluginResourceRequirements,
  tags: z.array(z.string()).optional(),
  tool: zToolProviderEntity.nullish(),
  trigger: zTriggerProviderEntity.nullish(),
  verified: z.boolean().optional().default(false),
  version: z.string(),
})

/**
 * PluginManifestResponse
 */
export const zPluginManifestResponse = z.object({
  manifest: zPluginDeclaration,
})

/**
 * PluginDecodeResponse
 */
export const zPluginDecodeResponse = z.object({
  manifest: zPluginDeclaration,
  unique_identifier: z.string(),
  verification: zPluginVerification.nullish(),
})

/**
 * PluginEntity
 */
export const zPluginEntity = z.object({
  checksum: z.string(),
  created_at: z.iso.datetime(),
  declaration: zPluginDeclaration,
  endpoints_active: z.int(),
  endpoints_setups: z.int(),
  id: z.string(),
  installation_id: z.string(),
  meta: z.record(z.string(), z.unknown()),
  name: z.string(),
  plugin_id: z.string(),
  plugin_unique_identifier: z.string(),
  runtime_type: z.string(),
  source: zPluginInstallationSource,
  tenant_id: z.string(),
  updated_at: z.iso.datetime(),
  version: z.string(),
})

/**
 * PluginListResponse
 */
export const zPluginListResponse = z.object({
  plugins: z.array(zPluginEntity),
  total: z.int(),
})

/**
 * AccountWithRoleResponse
 */
export const zAccountWithRoleResponseWritable = z.object({
  avatar: z.string().nullish(),
  created_at: z.int().nullish(),
  email: z.string(),
  id: z.string(),
  last_active_at: z.int().nullish(),
  last_login_at: z.int().nullish(),
  name: z.string(),
  role: z.string(),
  roles: z.array(z.record(z.string(), z.string())).optional(),
  status: z.string(),
})

/**
 * AccountWithRoleListResponse
 */
export const zAccountWithRoleListResponseWritable = z.object({
  accounts: z.array(zAccountWithRoleResponseWritable),
})

/**
 * Success
 */
export const zGetWorkspacesResponse = zTenantListResponse

/**
 * Success
 */
export const zPostWorkspacesCurrentResponse = zTenantInfoResponse

export const zGetWorkspacesCurrentAgentProviderByProviderNamePath = z.object({
  provider_name: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentAgentProviderByProviderNameResponse = zAgentProviderResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentAgentProvidersResponse = zAgentProviderListResponse

export const zGetWorkspacesCurrentCustomizedSnippetsQuery = z.object({
  creators: z.array(z.string()).optional(),
  is_published: z.boolean().optional(),
  keyword: z.string().optional(),
  limit: z.int().gte(1).lte(100).optional().default(20),
  page: z.int().gte(1).lte(99999).optional().default(1),
  tag_ids: z.array(z.string()).optional(),
})

/**
 * Snippets retrieved successfully
 */
export const zGetWorkspacesCurrentCustomizedSnippetsResponse = zSnippetPaginationResponse

export const zPostWorkspacesCurrentCustomizedSnippetsBody = zCreateSnippetPayload

/**
 * Snippet created successfully
 */
export const zPostWorkspacesCurrentCustomizedSnippetsResponse = zSnippetResponse

export const zPostWorkspacesCurrentCustomizedSnippetsImportsBody = zSnippetImportPayload

/**
 * Snippet imported successfully
 */
export const zPostWorkspacesCurrentCustomizedSnippetsImportsResponse = zSnippetImportResponse

export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmPath = z.object({
  import_id: z.string(),
})

/**
 * Import confirmed successfully
 */
export const zPostWorkspacesCurrentCustomizedSnippetsImportsByImportIdConfirmResponse =
  zSnippetImportResponse

export const zDeleteWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({
  snippet_id: z.uuid(),
})

/**
 * Snippet deleted successfully
 */
export const zDeleteWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = z.void()

export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({
  snippet_id: z.uuid(),
})

/**
 * Snippet retrieved successfully
 */
export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse

export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdBody = zUpdateSnippetPayload

export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdPath = z.object({
  snippet_id: z.uuid(),
})

/**
 * Snippet updated successfully
 */
export const zPatchWorkspacesCurrentCustomizedSnippetsBySnippetIdResponse = zSnippetResponse

export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesPath = z.object({
  snippet_id: z.uuid(),
})

/**
 * Dependencies checked successfully
 */
export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdCheckDependenciesResponse =
  zSnippetDependencyCheckResponse

export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportPath = z.object({
  snippet_id: z.uuid(),
})

export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportQuery = z.object({
  include_secret: z.string().optional().default('false'),
})

/**
 * Snippet exported successfully
 */
export const zGetWorkspacesCurrentCustomizedSnippetsBySnippetIdExportResponse = zTextFileResponse

export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementPath = z.object({
  snippet_id: z.uuid(),
})

/**
 * Use count incremented successfully
 */
export const zPostWorkspacesCurrentCustomizedSnippetsBySnippetIdUseCountIncrementResponse =
  zSnippetUseCountResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentDatasetOperatorsResponse = zAccountWithRoleListResponse

export const zGetWorkspacesCurrentDefaultModelQuery = z.object({
  model_type: z.enum(['llm', 'moderation', 'rerank', 'speech2text', 'text-embedding', 'tts']),
})

/**
 * Default model retrieved successfully
 */
export const zGetWorkspacesCurrentDefaultModelResponse = zDefaultModelDataResponse

export const zPostWorkspacesCurrentDefaultModelBody = zParserPostDefault

/**
 * Success
 */
export const zPostWorkspacesCurrentDefaultModelResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentEndpointsBody = zEndpointCreatePayload

/**
 * Endpoint created successfully
 */
export const zPostWorkspacesCurrentEndpointsResponse = zSuccessResponse

export const zPostWorkspacesCurrentEndpointsCreateBody = zEndpointCreatePayload

/**
 * Endpoint created successfully
 */
export const zPostWorkspacesCurrentEndpointsCreateResponse = zSuccessResponse

export const zPostWorkspacesCurrentEndpointsDeleteBody = zEndpointIdPayload

/**
 * Endpoint deleted successfully
 */
export const zPostWorkspacesCurrentEndpointsDeleteResponse = zSuccessResponse

export const zPostWorkspacesCurrentEndpointsDisableBody = zEndpointIdPayload

/**
 * Endpoint disabled successfully
 */
export const zPostWorkspacesCurrentEndpointsDisableResponse = zSuccessResponse

export const zPostWorkspacesCurrentEndpointsEnableBody = zEndpointIdPayload

/**
 * Endpoint enabled successfully
 */
export const zPostWorkspacesCurrentEndpointsEnableResponse = zSuccessResponse

export const zGetWorkspacesCurrentEndpointsListQuery = z.object({
  page: z.int().gte(1),
  page_size: z.int().gt(0),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentEndpointsListResponse = zEndpointListResponse

export const zGetWorkspacesCurrentEndpointsListPluginQuery = z.object({
  page: z.int().gte(1),
  page_size: z.int().gt(0),
  plugin_id: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentEndpointsListPluginResponse = zEndpointListResponse

export const zPostWorkspacesCurrentEndpointsUpdateBody = zLegacyEndpointUpdatePayload

/**
 * Endpoint updated successfully
 */
export const zPostWorkspacesCurrentEndpointsUpdateResponse = zSuccessResponse

export const zDeleteWorkspacesCurrentEndpointsByIdPath = z.object({
  id: z.string(),
})

/**
 * Endpoint deleted successfully
 */
export const zDeleteWorkspacesCurrentEndpointsByIdResponse = zSuccessResponse

export const zPatchWorkspacesCurrentEndpointsByIdBody = zEndpointUpdatePayload

export const zPatchWorkspacesCurrentEndpointsByIdPath = z.object({
  id: z.string(),
})

/**
 * Endpoint updated successfully
 */
export const zPatchWorkspacesCurrentEndpointsByIdResponse = zSuccessResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentMembersResponse = zAccountWithRoleListResponse

export const zPostWorkspacesCurrentMembersInviteEmailBody = zMemberInvitePayload

/**
 * Success
 */
export const zPostWorkspacesCurrentMembersInviteEmailResponse = zMemberInviteResponse

export const zPostWorkspacesCurrentMembersOwnerTransferCheckBody = zOwnerTransferCheckPayload

/**
 * Success
 */
export const zPostWorkspacesCurrentMembersOwnerTransferCheckResponse = zVerificationTokenResponse

export const zPostWorkspacesCurrentMembersSendOwnerTransferConfirmEmailBody =
  zOwnerTransferEmailPayload

/**
 * Success
 */
export const zPostWorkspacesCurrentMembersSendOwnerTransferConfirmEmailResponse =
  zSimpleResultDataResponse

export const zDeleteWorkspacesCurrentMembersByMemberIdPath = z.object({
  member_id: z.uuid(),
})

/**
 * Success
 */
export const zDeleteWorkspacesCurrentMembersByMemberIdResponse = zMemberActionResponse

export const zPostWorkspacesCurrentMembersByMemberIdOwnerTransferBody = zOwnerTransferPayload

export const zPostWorkspacesCurrentMembersByMemberIdOwnerTransferPath = z.object({
  member_id: z.uuid(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentMembersByMemberIdOwnerTransferResponse = zSimpleResultResponse

export const zPutWorkspacesCurrentMembersByMemberIdUpdateRoleBody = zMemberRoleUpdatePayload

export const zPutWorkspacesCurrentMembersByMemberIdUpdateRolePath = z.object({
  member_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentMembersByMemberIdUpdateRoleResponse = zSimpleResultResponse

export const zGetWorkspacesCurrentModelProvidersQuery = z.object({
  model_type: z
    .enum(['llm', 'moderation', 'rerank', 'speech2text', 'text-embedding', 'tts'])
    .optional(),
})

/**
 * Model providers retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersResponse = zModelProviderListResponse

export const zGetWorkspacesCurrentModelProvidersByProviderCheckoutUrlPath = z.object({
  provider: z.string(),
})

/**
 * Model provider checkout URL retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersByProviderCheckoutUrlResponse =
  zModelProviderPaymentCheckoutUrlResponse

export const zDeleteWorkspacesCurrentModelProvidersByProviderCredentialsBody =
  zParserCredentialDelete

export const zDeleteWorkspacesCurrentModelProvidersByProviderCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Credential deleted successfully
 */
export const zDeleteWorkspacesCurrentModelProvidersByProviderCredentialsResponse = z.void()

export const zGetWorkspacesCurrentModelProvidersByProviderCredentialsPath = z.object({
  provider: z.string(),
})

export const zGetWorkspacesCurrentModelProvidersByProviderCredentialsQuery = z.object({
  credential_id: z.string().optional(),
})

/**
 * Provider credentials retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersByProviderCredentialsResponse =
  zProviderCredentialsResponse

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsBody = zParserCredentialCreate

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Credential created successfully
 */
export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsResponse =
  zSimpleResultResponse

export const zPutWorkspacesCurrentModelProvidersByProviderCredentialsBody = zParserCredentialUpdate

export const zPutWorkspacesCurrentModelProvidersByProviderCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Credential updated successfully
 */
export const zPutWorkspacesCurrentModelProvidersByProviderCredentialsResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsSwitchBody =
  zParserCredentialSwitch

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsSwitchPath = z.object({
  provider: z.string(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsSwitchResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsValidateBody =
  zParserCredentialValidate

export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsValidatePath = z.object({
  provider: z.string(),
})

/**
 * Provider credentials validated successfully
 */
export const zPostWorkspacesCurrentModelProvidersByProviderCredentialsValidateResponse =
  zValidationResultResponse

export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsBody = zParserDeleteModels

export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsPath = z.object({
  provider: z.string(),
})

/**
 * Model deleted successfully
 */
export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsResponse = z.void()

export const zGetWorkspacesCurrentModelProvidersByProviderModelsPath = z.object({
  provider: z.string(),
})

/**
 * Provider models retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersByProviderModelsResponse =
  zProviderModelListResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsBody = zParserPostModels

export const zPostWorkspacesCurrentModelProvidersByProviderModelsPath = z.object({
  provider: z.string(),
})

/**
 * Model updated successfully
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsResponse = zSimpleResultResponse

export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsCredentialsBody =
  zParserDeleteCredential

export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Credential deleted successfully
 */
export const zDeleteWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse = z.void()

export const zGetWorkspacesCurrentModelProvidersByProviderModelsCredentialsPath = z.object({
  provider: z.string(),
})

export const zGetWorkspacesCurrentModelProvidersByProviderModelsCredentialsQuery = z.object({
  config_from: z.string().optional(),
  credential_id: z.string().optional(),
  model: z.string(),
  model_type: z.enum(['llm', 'moderation', 'rerank', 'speech2text', 'text-embedding', 'tts']),
})

/**
 * Model credentials retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse =
  zModelCredentialResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsBody =
  zParserCreateCredential

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Model credential created successfully
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse =
  zSimpleResultResponse

export const zPutWorkspacesCurrentModelProvidersByProviderModelsCredentialsBody =
  zParserUpdateCredential

export const zPutWorkspacesCurrentModelProvidersByProviderModelsCredentialsPath = z.object({
  provider: z.string(),
})

/**
 * Model credential updated successfully
 */
export const zPutWorkspacesCurrentModelProvidersByProviderModelsCredentialsResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsSwitchBody =
  zParserSwitch

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsSwitchPath = z.object({
  provider: z.string(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsSwitchResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsValidateBody =
  zParserValidate

export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsValidatePath = z.object(
  {
    provider: z.string(),
  },
)

/**
 * Model credentials validated successfully
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsCredentialsValidateResponse =
  zValidationResultResponse

export const zPatchWorkspacesCurrentModelProvidersByProviderModelsDisableBody = zParserDeleteModels

export const zPatchWorkspacesCurrentModelProvidersByProviderModelsDisablePath = z.object({
  provider: z.string(),
})

/**
 * Success
 */
export const zPatchWorkspacesCurrentModelProvidersByProviderModelsDisableResponse =
  zSimpleResultResponse

export const zPatchWorkspacesCurrentModelProvidersByProviderModelsEnableBody = zParserDeleteModels

export const zPatchWorkspacesCurrentModelProvidersByProviderModelsEnablePath = z.object({
  provider: z.string(),
})

/**
 * Success
 */
export const zPatchWorkspacesCurrentModelProvidersByProviderModelsEnableResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsCredentialsValidateBody =
  zLoadBalancingCredentialPayload

export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsCredentialsValidatePath =
  z.object({
    provider: z.string(),
  })

/**
 * Credential validation result
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsCredentialsValidateResponse =
  zLoadBalancingCredentialValidateResponse

export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsByConfigIdCredentialsValidateBody =
  zLoadBalancingCredentialPayload

export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsByConfigIdCredentialsValidatePath =
  z.object({
    config_id: z.string(),
    provider: z.string(),
  })

/**
 * Credential validation result
 */
export const zPostWorkspacesCurrentModelProvidersByProviderModelsLoadBalancingConfigsByConfigIdCredentialsValidateResponse =
  zLoadBalancingCredentialValidateResponse

export const zGetWorkspacesCurrentModelProvidersByProviderModelsParameterRulesPath = z.object({
  provider: z.string(),
})

export const zGetWorkspacesCurrentModelProvidersByProviderModelsParameterRulesQuery = z.object({
  model: z.string(),
})

/**
 * Model parameter rules retrieved successfully
 */
export const zGetWorkspacesCurrentModelProvidersByProviderModelsParameterRulesResponse =
  zModelParameterRuleListResponse

export const zPostWorkspacesCurrentModelProvidersByProviderPreferredProviderTypeBody =
  zParserPreferredProviderType

export const zPostWorkspacesCurrentModelProvidersByProviderPreferredProviderTypePath = z.object({
  provider: z.string(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentModelProvidersByProviderPreferredProviderTypeResponse =
  zSimpleResultResponse

export const zGetWorkspacesCurrentModelsModelTypesByModelTypePath = z.object({
  model_type: z.string(),
})

/**
 * Available models retrieved successfully
 */
export const zGetWorkspacesCurrentModelsModelTypesByModelTypeResponse = zAvailableModelListResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentPermissionResponse = zWorkspacePermissionResponse

export const zGetWorkspacesCurrentPluginAssetQuery = z.object({
  file_name: z.string(),
  plugin_unique_identifier: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginAssetResponse = zBinaryFileResponse

export const zPostWorkspacesCurrentPluginAutoUpgradeChangeBody = zParserAutoUpgradeChange

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginAutoUpgradeChangeResponse =
  zPluginAutoUpgradeChangeResponse

export const zPostWorkspacesCurrentPluginAutoUpgradeExcludeBody = zParserExcludePlugin

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginAutoUpgradeExcludeResponse = zSuccessResponse

export const zGetWorkspacesCurrentPluginAutoUpgradeFetchQuery = z.object({
  category: z.enum(['agent-strategy', 'datasource', 'extension', 'model', 'tool', 'trigger']),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginAutoUpgradeFetchResponse = zPluginAutoUpgradeFetchResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginDebuggingKeyResponse = zPluginDebuggingKeyResponse

export const zGetWorkspacesCurrentPluginFetchManifestQuery = z.object({
  plugin_unique_identifier: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginFetchManifestResponse = zPluginManifestResponse

export const zGetWorkspacesCurrentPluginIconQuery = z.object({
  filename: z.string(),
  tenant_id: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginIconResponse = zBinaryFileResponse

export const zPostWorkspacesCurrentPluginInstallGithubBody = zParserGithubInstall

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginInstallGithubResponse = zPluginInstallTaskStartResponse

export const zPostWorkspacesCurrentPluginInstallMarketplaceBody = zParserPluginIdentifiers

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginInstallMarketplaceResponse =
  zPluginInstallTaskStartResponse

export const zPostWorkspacesCurrentPluginInstallPkgBody = zParserPluginIdentifiers

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginInstallPkgResponse = zPluginInstallTaskStartResponse

export const zGetWorkspacesCurrentPluginListQuery = z.object({
  page: z.int().gte(1).optional().default(1),
  page_size: z.int().gte(1).lte(256).optional().default(256),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginListResponse = zPluginListResponse

export const zPostWorkspacesCurrentPluginListInstallationsIdsBody = zParserLatest

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginListInstallationsIdsResponse = zPluginInstallationsResponse

export const zPostWorkspacesCurrentPluginListLatestVersionsBody = zParserLatest

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginListLatestVersionsResponse = zPluginVersionsResponse

export const zGetWorkspacesCurrentPluginMarketplacePkgQuery = z.object({
  plugin_unique_identifier: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginMarketplacePkgResponse = zPluginManifestResponse

export const zGetWorkspacesCurrentPluginParametersDynamicOptionsQuery = z.object({
  action: z.string(),
  credential_id: z.string().optional(),
  parameter: z.string(),
  plugin_id: z.string(),
  provider: z.string(),
  provider_type: z.enum(['tool', 'trigger']),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginParametersDynamicOptionsResponse =
  zPluginDynamicOptionsResponse

export const zPostWorkspacesCurrentPluginParametersDynamicOptionsWithCredentialsBody =
  zParserDynamicOptionsWithCredentials

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginParametersDynamicOptionsWithCredentialsResponse =
  zPluginDynamicOptionsResponse

export const zPostWorkspacesCurrentPluginPermissionChangeBody = zParserPermissionChange

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginPermissionChangeResponse = zSuccessResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginPermissionFetchResponse = zPluginPermissionResponse

export const zGetWorkspacesCurrentPluginReadmeQuery = z.object({
  language: z.string().optional().default('en-US'),
  plugin_unique_identifier: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginReadmeResponse = zPluginReadmeResponse

export const zGetWorkspacesCurrentPluginTasksQuery = z.object({
  page: z.int().gte(1).optional().default(1),
  page_size: z.int().gte(1).lte(256).optional().default(256),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginTasksResponse = zPluginTasksResponse

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginTasksDeleteAllResponse = zSuccessResponse

export const zGetWorkspacesCurrentPluginTasksByTaskIdPath = z.object({
  task_id: z.string(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginTasksByTaskIdResponse = zPluginTaskResponse

export const zPostWorkspacesCurrentPluginTasksByTaskIdDeletePath = z.object({
  task_id: z.string(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginTasksByTaskIdDeleteResponse = zSuccessResponse

export const zPostWorkspacesCurrentPluginTasksByTaskIdDeleteByIdentifierPath = z.object({
  identifier: z.string(),
  task_id: z.string(),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginTasksByTaskIdDeleteByIdentifierResponse = zSuccessResponse

export const zPostWorkspacesCurrentPluginUninstallBody = zParserUninstall

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUninstallResponse = zSuccessResponse

export const zPostWorkspacesCurrentPluginUpgradeGithubBody = zParserGithubUpgrade

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUpgradeGithubResponse = zPluginInstallTaskStartResponse

export const zPostWorkspacesCurrentPluginUpgradeMarketplaceBody = zParserMarketplaceUpgrade

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUpgradeMarketplaceResponse =
  zPluginInstallTaskStartResponse

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUploadBundleResponse = zPluginBundleUploadResponse

export const zPostWorkspacesCurrentPluginUploadGithubBody = zParserGithubUpload

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUploadGithubResponse = zPluginDecodeResponse

export const zPostWorkspacesCurrentPluginUploadPkgBody = z.object({
  pkg: z.custom<Blob | File>((value) => value instanceof Blob || value instanceof File),
})

/**
 * Success
 */
export const zPostWorkspacesCurrentPluginUploadPkgResponse = zPluginDecodeResponse

export const zGetWorkspacesCurrentPluginByCategoryListPath = z.object({
  category: z.string(),
})

export const zGetWorkspacesCurrentPluginByCategoryListQuery = z.object({
  page: z.int().gte(1).optional().default(1),
  page_size: z.int().gte(1).lte(256).optional().default(256),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentPluginByCategoryListResponse = zPluginCategoryListResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAccessPoliciesResponse = zAccessPolicyList

/**
 * Policy created
 */
export const zPostWorkspacesCurrentRbacAccessPoliciesResponse = zAccessPolicy

export const zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdPath = z.object({
  policy_id: z.uuid(),
})

/**
 * Success
 */
export const zDeleteWorkspacesCurrentRbacAccessPoliciesByPolicyIdResponse = zAccessPolicy

export const zGetWorkspacesCurrentRbacAccessPoliciesByPolicyIdPath = z.object({
  policy_id: z.uuid(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAccessPoliciesByPolicyIdResponse = zAccessPolicy

export const zPutWorkspacesCurrentRbacAccessPoliciesByPolicyIdPath = z.object({
  policy_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacAccessPoliciesByPolicyIdResponse = zAccessPolicy

export const zPostWorkspacesCurrentRbacAccessPoliciesByPolicyIdCopyPath = z.object({
  policy_id: z.uuid(),
})

/**
 * Policy copied
 */
export const zPostWorkspacesCurrentRbacAccessPoliciesByPolicyIdCopyResponse = zAccessPolicy

export const zPutWorkspacesCurrentRbacAccessPolicyBindingsByBindingIdLockPath = z.object({
  binding_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacAccessPolicyBindingsByBindingIdLockResponse =
  zAccessPolicyBindingState

export const zPutWorkspacesCurrentRbacAccessPolicyBindingsByBindingIdUnlockPath = z.object({
  binding_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacAccessPolicyBindingsByBindingIdUnlockResponse =
  zAccessPolicyBindingState

export const zDeleteWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsBody =
  zDeleteMemberBindingsRequest

export const zDeleteWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    app_id: z.uuid(),
    policy_id: z.string(),
  })

/**
 * Success
 */
export const zDeleteWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    app_id: z.uuid(),
    policy_id: z.string(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdRoleBindingsPath =
  z.object({
    app_id: z.uuid(),
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPoliciesByPolicyIdRoleBindingsResponse =
  zRoleBindingsResponse

export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPolicyPath = z.object({
  app_id: z.uuid(),
})

export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPolicyQuery = z.object({
  language: z.enum(['en', 'ja', 'zh']).optional(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAppsByAppIdAccessPolicyResponse = zAppAccessMatrix

export const zGetWorkspacesCurrentRbacAppsByAppIdUserAccessPoliciesPath = z.object({
  app_id: z.uuid(),
})

export const zGetWorkspacesCurrentRbacAppsByAppIdUserAccessPoliciesQuery = z.object({
  language: z.enum(['en', 'ja', 'zh']).optional(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAppsByAppIdUserAccessPoliciesResponse =
  zResourceUserAccessPoliciesResponse

export const zPutWorkspacesCurrentRbacAppsByAppIdUsersByTargetAccountIdAccessPoliciesBody =
  zReplaceUserAccessPolicies

export const zPutWorkspacesCurrentRbacAppsByAppIdUsersByTargetAccountIdAccessPoliciesPath =
  z.object({
    app_id: z.uuid(),
    target_account_id: z.uuid(),
  })

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacAppsByAppIdUsersByTargetAccountIdAccessPoliciesResponse =
  zReplaceUserAccessPoliciesResponse

export const zGetWorkspacesCurrentRbacAppsByAppIdWhitelistPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacAppsByAppIdWhitelistResponse = zResourceWhitelist

export const zPutWorkspacesCurrentRbacAppsByAppIdWhitelistBody = zResourceAccessScopeRequest

export const zPutWorkspacesCurrentRbacAppsByAppIdWhitelistPath = z.object({
  app_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacAppsByAppIdWhitelistResponse = zResourceWhitelist

export const zDeleteWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsBody =
  zDeleteMemberBindingsRequest

export const zDeleteWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    dataset_id: z.uuid(),
    policy_id: z.string(),
  })

/**
 * Success
 */
export const zDeleteWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    dataset_id: z.uuid(),
    policy_id: z.string(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

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

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPoliciesByPolicyIdRoleBindingsResponse =
  zRoleBindingsResponse

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

export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPolicyQuery = z.object({
  language: z.enum(['en', 'ja', 'zh']).optional(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdAccessPolicyResponse = zDatasetAccessMatrix

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

export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdUserAccessPoliciesQuery = z.object({
  language: z.enum(['en', 'ja', 'zh']).optional(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdUserAccessPoliciesResponse =
  zResourceUserAccessPoliciesResponse

export const zPutWorkspacesCurrentRbacDatasetsByDatasetIdUsersByTargetAccountIdAccessPoliciesBody =
  zReplaceUserAccessPolicies

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

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacDatasetsByDatasetIdUsersByTargetAccountIdAccessPoliciesResponse =
  zReplaceUserAccessPoliciesResponse

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

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacDatasetsByDatasetIdWhitelistResponse = zResourceWhitelist

export const zPutWorkspacesCurrentRbacDatasetsByDatasetIdWhitelistBody = zResourceAccessScopeRequest

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

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacDatasetsByDatasetIdWhitelistResponse = zResourceWhitelist

export const zGetWorkspacesCurrentRbacMembersByMemberIdRbacRolesPath = z.object({
  member_id: z.uuid(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacMembersByMemberIdRbacRolesResponse = zMemberRolesResponse

export const zPutWorkspacesCurrentRbacMembersByMemberIdRbacRolesBody = zReplaceMemberRolesRequest

export const zPutWorkspacesCurrentRbacMembersByMemberIdRbacRolesPath = z.object({
  member_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacMembersByMemberIdRbacRolesResponse = zMemberRolesResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacMyPermissionsResponse = zMyPermissionsResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolePermissionsCatalogResponse = zPermissionCatalogResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolePermissionsCatalogAppResponse = zPermissionCatalogResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolePermissionsCatalogDatasetResponse =
  zPermissionCatalogResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolesResponse = zRbacRoleList

/**
 * Role created
 */
export const zPostWorkspacesCurrentRbacRolesResponse = zRbacRole

export const zDeleteWorkspacesCurrentRbacRolesByRoleIdPath = z.object({
  role_id: z.uuid(),
})

/**
 * Success
 */
export const zDeleteWorkspacesCurrentRbacRolesByRoleIdResponse = zRbacRole

export const zGetWorkspacesCurrentRbacRolesByRoleIdPath = z.object({
  role_id: z.uuid(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolesByRoleIdResponse = zRbacRole

export const zPutWorkspacesCurrentRbacRolesByRoleIdPath = z.object({
  role_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacRolesByRoleIdResponse = zRbacRole

export const zPostWorkspacesCurrentRbacRolesByRoleIdCopyPath = z.object({
  role_id: z.uuid(),
})

/**
 * Role copied
 */
export const zPostWorkspacesCurrentRbacRolesByRoleIdCopyResponse = zRbacRole

export const zGetWorkspacesCurrentRbacRolesByRoleIdMembersPath = z.object({
  role_id: z.uuid(),
})

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacRolesByRoleIdMembersResponse = zMembersInRoleList

export const zPutWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdBindingsBody =
  zReplaceBindingsRequest

export const zPutWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdBindingsPath = z.object({
  policy_id: z.uuid(),
})

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdBindingsResponse =
  zAccessMatrixItem

export const zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

export const zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdRoleBindingsPath =
  z.object({
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceAppsAccessPoliciesByPolicyIdRoleBindingsResponse =
  zRoleBindingsResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceAppsAccessPolicyResponse = zWorkspaceAccessMatrix

export const zPutWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdBindingsBody =
  zReplaceBindingsRequest

export const zPutWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdBindingsPath =
  z.object({
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zPutWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdBindingsResponse =
  zAccessMatrixItem

export const zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdMemberBindingsPath =
  z.object({
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdMemberBindingsResponse =
  zMemberBindingsResponse

export const zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdRoleBindingsPath =
  z.object({
    policy_id: z.uuid(),
  })

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPoliciesByPolicyIdRoleBindingsResponse =
  zRoleBindingsResponse

/**
 * Success
 */
export const zGetWorkspacesCurrentRbacWorkspaceDatasetsAccessPolicyResponse = zWorkspaceAccessMatrix

/**
 * Tool labels retrieved successfully
 */
export const zGetWorkspacesCurrentToolLabelsResponse = zToolLabelListResponse

export const zPostWorkspacesCurrentToolProviderApiAddBody = zApiToolProviderAddPayload

/**
 * API provider added successfully
 */
export const zPostWorkspacesCurrentToolProviderApiAddResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderApiDeleteBody = zApiToolProviderDeletePayload

/**
 * API provider deleted successfully
 */
export const zPostWorkspacesCurrentToolProviderApiDeleteResponse = zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderApiGetQuery = z.object({
  provider: z.string(),
})

/**
 * API provider retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderApiGetResponse = zApiProviderDetailResponse

export const zGetWorkspacesCurrentToolProviderApiRemoteQuery = z.object({
  url: z.url().min(1).max(2083),
})

/**
 * Remote API provider schema retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderApiRemoteResponse = zApiProviderRemoteSchemaResponse

export const zPostWorkspacesCurrentToolProviderApiSchemaBody = zApiToolSchemaPayload

/**
 * API schema parsed successfully
 */
export const zPostWorkspacesCurrentToolProviderApiSchemaResponse = zApiSchemaParseResponse

export const zPostWorkspacesCurrentToolProviderApiTestPreBody = zApiToolTestPayload

/**
 * API tool test preview completed successfully
 */
export const zPostWorkspacesCurrentToolProviderApiTestPreResponse = zApiToolPreviewResponse

export const zGetWorkspacesCurrentToolProviderApiToolsQuery = z.object({
  provider: z.string(),
})

/**
 * API provider tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderApiToolsResponse = zToolApiListResponse

export const zPostWorkspacesCurrentToolProviderApiUpdateBody = zApiToolProviderUpdatePayload

/**
 * API provider updated successfully
 */
export const zPostWorkspacesCurrentToolProviderApiUpdateResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderAddBody = zBuiltinToolAddPayload

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderAddPath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider added successfully
 */
export const zPostWorkspacesCurrentToolProviderBuiltinByProviderAddResponse = zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialInfoPath = z.object({
  provider: z.string(),
})

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialInfoQuery = z.object({
  include_credential_ids: z.array(z.string()).optional(),
})

/**
 * Builtin provider credential info retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialInfoResponse =
  zToolProviderCredentialInfoApiEntity

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialSchemaByCredentialTypePath =
  z.object({
    credential_type: z.string(),
    provider: z.string(),
  })

/**
 * Builtin provider credential schema retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialSchemaByCredentialTypeResponse =
  zProviderConfigListResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialsPath = z.object({
  provider: z.string(),
})

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialsQuery = z.object({
  include_credential_ids: z.array(z.string()).optional(),
})

/**
 * Builtin provider credentials retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderCredentialsResponse =
  zToolProviderCredentialListResponse

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDefaultCredentialBody =
  zBuiltinProviderDefaultCredentialPayload

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDefaultCredentialPath = z.object({
  provider: z.string(),
})

/**
 * Default credential set successfully
 */
export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDefaultCredentialResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDeleteBody =
  zBuiltinToolCredentialDeletePayload

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDeletePath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider credential deleted successfully
 */
export const zPostWorkspacesCurrentToolProviderBuiltinByProviderDeleteResponse =
  zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderIconPath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider icon
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderIconResponse = z.record(
  z.string(),
  z.unknown(),
)

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderInfoPath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider info retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderInfoResponse =
  zToolProviderApiEntityResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthClientSchemaPath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider OAuth client schema retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthClientSchemaResponse =
  zBuiltinProviderOAuthClientSchemaResponse

export const zDeleteWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientPath = z.object({
  provider: z.string(),
})

/**
 * Custom OAuth client deleted successfully
 */
export const zDeleteWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientResponse =
  zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientPath = z.object({
  provider: z.string(),
})

/**
 * Custom OAuth client retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientResponse = z.record(
  z.string(),
  z.unknown(),
)

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientBody =
  zToolOAuthCustomClientPayload

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientPath = z.object({
  provider: z.string(),
})

/**
 * Custom OAuth client saved successfully
 */
export const zPostWorkspacesCurrentToolProviderBuiltinByProviderOauthCustomClientResponse =
  zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderBuiltinByProviderToolsPath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderBuiltinByProviderToolsResponse = zToolApiListResponse

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderUpdateBody =
  zBuiltinToolUpdatePayload

export const zPostWorkspacesCurrentToolProviderBuiltinByProviderUpdatePath = z.object({
  provider: z.string(),
})

/**
 * Builtin provider updated successfully
 */
export const zPostWorkspacesCurrentToolProviderBuiltinByProviderUpdateResponse =
  zSimpleResultResponse

export const zDeleteWorkspacesCurrentToolProviderMcpBody = zMcpProviderDeletePayload

/**
 * Success
 */
export const zDeleteWorkspacesCurrentToolProviderMcpResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderMcpBody = zMcpProviderCreatePayload

/**
 * MCP provider created successfully
 */
export const zPostWorkspacesCurrentToolProviderMcpResponse = zToolProviderApiEntityResponse

export const zPutWorkspacesCurrentToolProviderMcpBody = zMcpProviderUpdatePayload

/**
 * MCP provider updated successfully
 */
export const zPutWorkspacesCurrentToolProviderMcpResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderMcpAuthBody = zMcpAuthPayload

/**
 * MCP provider authorized successfully
 */
export const zPostWorkspacesCurrentToolProviderMcpAuthResponse = zMcpAuthResponse

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

/**
 * MCP provider retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderMcpToolsByProviderIdResponse =
  zToolProviderApiEntityResponse

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

/**
 * MCP provider tools refreshed successfully
 */
export const zGetWorkspacesCurrentToolProviderMcpUpdateByProviderIdResponse =
  zToolProviderApiEntityResponse

export const zPostWorkspacesCurrentToolProviderWorkflowCreateBody = zWorkflowToolCreatePayload

/**
 * Workflow tool created successfully
 */
export const zPostWorkspacesCurrentToolProviderWorkflowCreateResponse = zSimpleResultResponse

export const zPostWorkspacesCurrentToolProviderWorkflowDeleteBody = zWorkflowToolDeletePayload

/**
 * Workflow tool deleted successfully
 */
export const zPostWorkspacesCurrentToolProviderWorkflowDeleteResponse = zSimpleResultResponse

export const zGetWorkspacesCurrentToolProviderWorkflowGetQuery = z.object({
  workflow_app_id: z.string().optional(),
  workflow_tool_id: z.string().optional(),
})

/**
 * Workflow tool retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderWorkflowGetResponse = zWorkflowToolDetailResponse

export const zGetWorkspacesCurrentToolProviderWorkflowToolsQuery = z.object({
  workflow_tool_id: z.string(),
})

/**
 * Workflow provider tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolProviderWorkflowToolsResponse = zToolApiListResponse

export const zPostWorkspacesCurrentToolProviderWorkflowUpdateBody = zWorkflowToolUpdatePayload

/**
 * Workflow tool updated successfully
 */
export const zPostWorkspacesCurrentToolProviderWorkflowUpdateResponse = zSimpleResultResponse

export const zGetWorkspacesCurrentToolProvidersQuery = z.object({
  type: z.enum(['api', 'builtin', 'mcp', 'model', 'workflow']).optional(),
})

/**
 * Tool providers retrieved successfully
 */
export const zGetWorkspacesCurrentToolProvidersResponse = zToolProviderListResponse

/**
 * API tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolsApiResponse = zToolProviderListResponse

/**
 * Builtin tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolsBuiltinResponse = zToolProviderListResponse

/**
 * MCP tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolsMcpResponse = zToolProviderListResponse

/**
 * Workflow tools retrieved successfully
 */
export const zGetWorkspacesCurrentToolsWorkflowResponse = zToolProviderListResponse

export const zGetWorkspacesCurrentTriggerProviderByProviderIconPath = z.object({
  provider: z.string(),
})

/**
 * Trigger provider icon
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderIconResponse = z.record(
  z.string(),
  z.unknown(),
)

export const zGetWorkspacesCurrentTriggerProviderByProviderInfoPath = z.object({
  provider: z.string(),
})

/**
 * Trigger provider retrieved successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderInfoResponse = zTriggerProviderApiEntity

export const zDeleteWorkspacesCurrentTriggerProviderByProviderOauthClientPath = z.object({
  provider: z.string(),
})

/**
 * Trigger OAuth client deleted successfully
 */
export const zDeleteWorkspacesCurrentTriggerProviderByProviderOauthClientResponse =
  zSimpleResultResponse

export const zGetWorkspacesCurrentTriggerProviderByProviderOauthClientPath = z.object({
  provider: z.string(),
})

/**
 * Trigger OAuth client retrieved successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderOauthClientResponse =
  zTriggerOAuthClientResponse

export const zPostWorkspacesCurrentTriggerProviderByProviderOauthClientBody =
  zTriggerOAuthClientPayload

export const zPostWorkspacesCurrentTriggerProviderByProviderOauthClientPath = z.object({
  provider: z.string(),
})

/**
 * Trigger OAuth client saved successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderOauthClientResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderBuildBySubscriptionBuilderIdBody =
  zTriggerSubscriptionBuilderUpdatePayload

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderBuildBySubscriptionBuilderIdPath =
  z.object({
    provider: z.string(),
    subscription_builder_id: z.string(),
  })

/**
 * Trigger subscription builder built successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderBuildBySubscriptionBuilderIdResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderCreateBody =
  zTriggerSubscriptionBuilderCreatePayload

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderCreatePath =
  z.object({
    provider: z.string(),
  })

/**
 * Trigger subscription builder created successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderCreateResponse =
  zTriggerSubscriptionBuilderCreateResponse

export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderLogsBySubscriptionBuilderIdPath =
  z.object({
    provider: z.string(),
    subscription_builder_id: z.string(),
  })

/**
 * Trigger subscription builder logs retrieved successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderLogsBySubscriptionBuilderIdResponse =
  zTriggerSubscriptionBuilderLogsResponse

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderUpdateBySubscriptionBuilderIdBody =
  zTriggerSubscriptionBuilderUpdatePayload

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderUpdateBySubscriptionBuilderIdPath =
  z.object({
    provider: z.string(),
    subscription_builder_id: z.string(),
  })

/**
 * Trigger subscription builder updated successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderUpdateBySubscriptionBuilderIdResponse =
  zSubscriptionBuilderApiEntity

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderVerifyAndUpdateBySubscriptionBuilderIdBody =
  zTriggerSubscriptionBuilderVerifyPayload

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderVerifyAndUpdateBySubscriptionBuilderIdPath =
  z.object({
    provider: z.string(),
    subscription_builder_id: z.string(),
  })

/**
 * Trigger subscription builder verified successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderVerifyAndUpdateBySubscriptionBuilderIdResponse =
  zTriggerVerificationResponse

export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderBySubscriptionBuilderIdPath =
  z.object({
    provider: z.string(),
    subscription_builder_id: z.string(),
  })

/**
 * Trigger subscription builder retrieved successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsBuilderBySubscriptionBuilderIdResponse =
  zSubscriptionBuilderApiEntity

export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsListPath = z.object({
  provider: z.string(),
})

/**
 * Trigger subscriptions retrieved successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsListResponse =
  zTriggerProviderSubscriptionListResponse

export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsOauthAuthorizePath =
  z.object({
    provider: z.string(),
  })

/**
 * Trigger OAuth authorization URL generated successfully
 */
export const zGetWorkspacesCurrentTriggerProviderByProviderSubscriptionsOauthAuthorizeResponse =
  zTriggerOAuthAuthorizeResponse

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsVerifyBySubscriptionIdBody =
  zTriggerSubscriptionBuilderVerifyPayload

export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsVerifyBySubscriptionIdPath =
  z.object({
    provider: z.string(),
    subscription_id: z.string(),
  })

/**
 * Trigger subscription verified successfully
 */
export const zPostWorkspacesCurrentTriggerProviderByProviderSubscriptionsVerifyBySubscriptionIdResponse =
  zTriggerVerificationResponse

export const zPostWorkspacesCurrentTriggerProviderBySubscriptionIdSubscriptionsDeletePath =
  z.object({
    subscription_id: z.string(),
  })

/**
 * Success
 */
export const zPostWorkspacesCurrentTriggerProviderBySubscriptionIdSubscriptionsDeleteResponse =
  zSimpleResultResponse

export const zPostWorkspacesCurrentTriggerProviderBySubscriptionIdSubscriptionsUpdateBody =
  zTriggerSubscriptionBuilderUpdatePayload

export const zPostWorkspacesCurrentTriggerProviderBySubscriptionIdSubscriptionsUpdatePath =
  z.object({
    subscription_id: z.string(),
  })

/**
 * Trigger subscription updated successfully
 */
export const zPostWorkspacesCurrentTriggerProviderBySubscriptionIdSubscriptionsUpdateResponse =
  zSimpleResultResponse

/**
 * Trigger providers retrieved successfully
 */
export const zGetWorkspacesCurrentTriggersResponse = zTriggerProviderListResponse

export const zPostWorkspacesCustomConfigBody = zWorkspaceCustomConfigPayload

/**
 * Success
 */
export const zPostWorkspacesCustomConfigResponse = zWorkspaceTenantResultResponse

export const zPostWorkspacesCustomConfigWebappLogoUploadBody = z.object({
  file: z.custom<Blob | File>((value) => value instanceof Blob || value instanceof File),
})

/**
 * Logo uploaded
 */
export const zPostWorkspacesCustomConfigWebappLogoUploadResponse = zWorkspaceLogoUploadResponse

export const zPostWorkspacesInfoBody = zWorkspaceInfoPayload

/**
 * Success
 */
export const zPostWorkspacesInfoResponse = zWorkspaceTenantResultResponse

export const zPostWorkspacesSwitchBody = zSwitchWorkspacePayload

/**
 * Success
 */
export const zPostWorkspacesSwitchResponse = zSwitchWorkspaceResponse

export const zGetWorkspacesByTenantIdModelProvidersByProviderByIconTypeByLangPath = z.object({
  icon_type: z.string(),
  lang: z.string(),
  provider: z.string(),
  tenant_id: z.string(),
})

/**
 * Model provider icon
 */
export const zGetWorkspacesByTenantIdModelProvidersByProviderByIconTypeByLangResponse = z.record(
  z.string(),
  z.unknown(),
)
