Spaces:
Paused
Paused
Download node_modules/@huggingface/hub/src/lib/delete-collection.ts from ken-q/opencode-home: direct link, hf CLI and curl.
- Browser
- Download file 941 Bytes
-
https://huggingface.co/spaces/ken-q/opencode-home/resolve/main/node_modules/%40huggingface/hub/src/lib/delete-collection.ts
- Command line
-
hf download hf://spaces/ken-q/opencode-home/node_modules/@huggingface/hub/src/lib/delete-collection.ts
-
curl -L -o delete-collection.ts https://huggingface.co/spaces/ken-q/opencode-home/resolve/main/node_modules/%40huggingface/hub/src/lib/delete-collection.ts
941 Bytes
| import { HUB_URL } from "../consts"; | |
| import { createApiError } from "../error"; | |
| import type { CredentialsParams } from "../types/public"; | |
| import { checkCredentials } from "../utils/checkCredentials"; | |
| export async function deleteCollection( | |
| params: { | |
| /** | |
| * The slug of the collection to delete. | |
| */ | |
| slug: string; | |
| hubUrl?: string; | |
| /** | |
| * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. | |
| */ | |
| fetch?: typeof fetch; | |
| } & Partial<CredentialsParams>, | |
| ): Promise<void> { | |
| if (!params.slug) { | |
| throw new TypeError("slug is required"); | |
| } | |
| const accessToken = checkCredentials(params); | |
| const res = await (params.fetch ?? fetch)(`${params.hubUrl ?? HUB_URL}/api/collections/${params.slug}`, { | |
| method: "DELETE", | |
| headers: { | |
| Authorization: `Bearer ${accessToken}`, | |
| "Content-Type": "application/json", | |
| }, | |
| }); | |
| if (!res.ok) { | |
| throw await createApiError(res); | |
| } | |
| } | |