import {z} from 'zod' export type GetApiApiV1DelegatedApprovalsOptionsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const getApiApiV1DelegatedApprovalsOptionsResponse = z.object({delegatedApprovalOptions: z.array(z.object({name: z.string(), type: z.literal("servicenow"), connection: z.enum(["github", "github-radar", "aws", "databricks", "gcp", "azure-key-vault", "azure-app-configuration", "azure-client-secrets", "azure-devops", "azure-adcs", "adcs", "azure-dns", "humanitec", "terraform-cloud", "vercel", "postgres", "mssql", "mysql", "camunda", "windmill", "auth0", "hashicorp-vault", "ldap", "teamcity", "oci", "oracledb", "1password", "heroku", "render", "flyio", "trigger-dev", "gitlab", "cloudflare", "dns-made-easy", "ultradns", "zabbix", "railway", "bitbucket", "checkly", "supabase", "digital-ocean", "netlify", "okta", "redis", "mongodb", "laravel-forge", "chef", "northflank", "octopus-deploy", "ssh", "dbt", "smb", "winrm", "open-router", "openai", "circleci", "azure-entra-id", "venafi", "venafi-tpp", "external-infisical", "doppler", "netscaler", "palo-alto-networks", "anthropic", "ovh", "devin", "ona", "digicert", "travis-ci", "salesforce", "snowflake", "datadog", "f5-big-ip", "godaddy", "convex", "rundeck", "portainer", "hasura-cloud", "qovery", "cloud-66", "litellm", "fireworks", "kemp-loadmaster", "imperva", "microsoft-intune", "nutanix-prism-central", "powerdns", "spacelift", "daytona", "stripe", "keeper", "hpe-ilo", "servicenow", "s3-compatible", "jira", "clickhouse"])}))}); 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 }; /** * List the delegated approval systems that approval policies can hand their requests to. * * GET /api/v1/delegated-approvals/options */ export const getApiApiV1DelegatedApprovalsOptions = async (options?: GetApiApiV1DelegatedApprovalsOptionsOptions) => { const {baseUrl = "https://us.infisical.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/delegated-approvals/options${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(getApiApiV1DelegatedApprovalsOptionsResponse, await res.json()) };