export type DeleteApiStoreNameGraphsArgs = {storeName: string, default?: boolean | undefined, graph?: string | undefined}; export type DeleteApiStoreNameGraphsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Deletes a named graph or removes all triples from the default graph * * DELETE /{storeName}/graphs */ export const deleteApiStoreNameGraphs = async (args: DeleteApiStoreNameGraphsArgs, options: DeleteApiStoreNameGraphsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.default != null) query.append("default", String(args.default)) if (args.graph != null) query.append("graph", String(args.graph)) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.storeName))}/graphs${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };