export type PatchApiComponentsEnrichIdArgs = {id: string, repository?: string | undefined}; export type PatchApiComponentsEnrichIdOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Automatically enrich component metadata * * PATCH /components/enrich/{id} */ export const patchApiComponentsEnrichId = async (args: PatchApiComponentsEnrichIdArgs, options: PatchApiComponentsEnrichIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.repository != null) query.append("repository", String(args.repository)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/components/enrich/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };