import {z} from 'zod' export type CreateApiApplicationsPrivateGiteaAppArgs = {body: {project_uuid: string, server_uuid: string, environment_name?: string | undefined, environment_uuid?: string | undefined, gitea_app_uuid: string, git_repository: string, git_branch: string, ports_exposes?: string | undefined, destination_uuid?: string | undefined, build_pack: 'nixpacks' | 'railpack' | 'static' | 'dockerfile' | 'dockercompose', name?: string | undefined, description?: string | undefined, domains?: string | undefined, noindex_domains?: Array | undefined, git_commit_sha?: string | undefined, docker_registry_image_name?: string | undefined, docker_registry_image_tag?: string | undefined, is_static?: boolean | undefined, is_spa?: boolean | undefined, is_auto_deploy_enabled?: boolean | undefined, is_force_https_enabled?: boolean | undefined, is_preview_deployments_enabled?: boolean | undefined, static_image?: 'nginx:alpine' | undefined, install_command?: string | undefined, build_command?: string | undefined, start_command?: string | undefined, ports_mappings?: string | undefined, base_directory?: string | undefined, publish_directory?: string | undefined, health_check_enabled?: boolean | undefined, health_check_path?: string | undefined, health_check_port?: (string | null) | undefined, health_check_host?: (string | null) | undefined, health_check_method?: string | undefined, health_check_return_code?: number | undefined, health_check_scheme?: string | undefined, health_check_response_text?: (string | null) | undefined, health_check_interval?: number | undefined, health_check_timeout?: number | undefined, health_check_retries?: number | undefined, health_check_start_period?: number | undefined, limits_memory?: string | undefined, limits_memory_swap?: string | undefined, limits_memory_swappiness?: number | undefined, limits_memory_reservation?: string | undefined, limits_cpus?: string | undefined, limits_cpuset?: (string | null) | undefined, limits_cpu_shares?: number | undefined, custom_labels?: string | undefined, custom_docker_run_options?: string | undefined, post_deployment_command?: string | undefined, post_deployment_command_container?: string | undefined, pre_deployment_command?: string | undefined, pre_deployment_command_container?: string | undefined, manual_webhook_secret_github?: string | undefined, manual_webhook_secret_gitlab?: string | undefined, manual_webhook_secret_bitbucket?: string | undefined, manual_webhook_secret_gitea?: string | undefined, redirect?: ('www' | 'non-www' | 'both' | null) | undefined, instant_deploy?: boolean | undefined, dockerfile?: string | undefined, dockerfile_location?: string | undefined, dockerfile_target_build?: (string | null) | undefined, docker_compose_location?: string | undefined, docker_compose_custom_start_command?: string | undefined, docker_compose_custom_build_command?: string | undefined, docker_compose_domains?: (Array<{name?: string | undefined, domain?: string | undefined, redirect?: ('www' | 'non-www' | 'both' | null) | undefined}>) | undefined, watch_paths?: string | undefined, use_build_server?: (boolean | null) | undefined, use_build_secrets?: boolean | undefined, is_git_submodules_enabled?: boolean | undefined, is_git_lfs_enabled?: boolean | undefined, is_git_shallow_clone_enabled?: boolean | undefined, is_auto_cancel_queued_deployments_enabled?: boolean | undefined, is_auto_cancel_building_deployments_enabled?: boolean | undefined, disable_build_cache?: boolean | undefined, inject_build_args_to_dockerfile?: boolean | undefined, include_source_commit_in_build?: boolean | undefined, include_network_hosts_in_build?: boolean | undefined, is_env_sorting_enabled?: boolean | undefined, redact_all_env_values_in_logs?: boolean | undefined, include_coolify_default_variables?: boolean | undefined, is_pr_deployments_public_enabled?: boolean | undefined, stop_grace_period?: (number | null) | undefined, rolling_update_drain_seconds?: number | undefined, docker_images_to_keep?: number | undefined, is_gzip_enabled?: boolean | undefined, is_stripprefix_enabled?: boolean | undefined, is_permanent_redirect_enabled?: boolean | undefined, traefik_certificate_resolver?: (string | null) | undefined, is_container_label_readonly_enabled?: boolean | undefined, is_raw_compose_deployment_enabled?: boolean | undefined, is_log_drain_enabled?: boolean | undefined, is_gpu_enabled?: boolean | undefined, gpu_driver?: (string | null) | undefined, gpu_count?: (string | null) | undefined, gpu_device_ids?: (string | null) | undefined, gpu_options?: (string | null) | undefined, is_consistent_container_name_enabled?: boolean | undefined, is_image_scan_enabled?: boolean | undefined, custom_internal_name?: (string | null) | undefined, custom_container_name_prefix?: (string | null) | undefined, preview_url_template?: string | undefined, max_restart_count?: number | undefined, is_http_basic_auth_enabled?: boolean | undefined, http_basic_auth_username?: (string | null) | undefined, http_basic_auth_password?: (string | null) | undefined, http_basic_auth_hash_algorithm?: ('bcrypt' | 'argon2id') | undefined, http_basic_auth_bcrypt_cost?: number | undefined, http_basic_auth_argon2id_memory_cost?: number | undefined, http_basic_auth_argon2id_time_cost?: number | undefined, connect_to_docker_network?: boolean | undefined, force_domain_override?: boolean | undefined, autogenerate_domain?: boolean | undefined, is_container_label_escape_enabled?: boolean | undefined, tags?: Array | undefined, is_preserve_repository_enabled?: boolean | undefined}}; export type CreateApiApplicationsPrivateGiteaAppOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiApplicationsPrivateGiteaAppResponse = z.object({uuid: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Create (Private - Gitea App) * * POST /applications/private-gitea-app */ export const createApiApplicationsPrivateGiteaApp = async (args: CreateApiApplicationsPrivateGiteaAppArgs, options?: CreateApiApplicationsPrivateGiteaAppOptions) => { const {baseUrl = "https://app.coolify.io/api/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/applications/private-gitea-app${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiApplicationsPrivateGiteaAppResponse, await res.json()) };