export type AdvisorInsightMetric = {key?: string | undefined, value?: number | undefined, unit?: ('percent' | 'count') | undefined, threshold?: (number | null) | undefined, tone?: ('default' | 'success' | 'danger') | undefined, source?: ('deterministic' | 'ai' | 'app') | undefined, checkedAt?: (string | null) | undefined}; export type AdvisorInsightRecommendation = {id?: string | undefined, primary?: boolean | undefined, params?: Record | undefined}; export type AdvisorAppInsightForm = {outcome: 'flagged' | 'clear' | 'not_applicable', checkedAt?: string | undefined, metrics?: Array | undefined, recommendations?: Array | undefined, payload?: {[key: string]: unknown} | undefined}; export type UpdateApiProjectsProjectIdApplicationsApplicationIdentifierModulesModuleKeyAdvisorsInsightsArgs = {projectId: number, applicationIdentifier: string, moduleKey: string, body: AdvisorAppInsightForm}; export type UpdateApiProjectsProjectIdApplicationsApplicationIdentifierModulesModuleKeyAdvisorsInsightsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create or Update Application Advisor Insight * * PUT /projects/{projectId}/applications/{applicationIdentifier}/modules/{moduleKey}/advisors/insights */ export const updateApiProjectsProjectIdApplicationsApplicationIdentifierModulesModuleKeyAdvisorsInsights = async (args: UpdateApiProjectsProjectIdApplicationsApplicationIdentifierModulesModuleKeyAdvisorsInsightsArgs, options?: UpdateApiProjectsProjectIdApplicationsApplicationIdentifierModulesModuleKeyAdvisorsInsightsOptions) => { const {baseUrl = "https://api.crowdin.com/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/projects/${encodeURIComponent(String(args.projectId))}/applications/${encodeURIComponent(String(args.applicationIdentifier))}/modules/${encodeURIComponent(String(args.moduleKey))}/advisors/insights${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };