import {z} from 'zod' export type CreateApiV1NameFilesystemRemoveArgs = {name: string, body: {path: string, recursive?: boolean | undefined}}; export type CreateApiV1NameFilesystemRemoveOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const v1RemoveResponse = z.object({}); 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 }; /** * (-- api-linter: core::0136::http-method=disabled * aip.dev/not-precedent: Remove is a custom method on a singleton * resource, not a standard Delete method. It uses POST for consistency * with other custom methods on the Filesystem singleton. --) * (-- api-linter: core::0136::verb-noun=disabled * aip.dev/not-precedent: Remove is a custom method on a singleton * resource. The "remove" verb follows Unix convention (rm) and clearly * conveys imperative action for filesystem operations. --) * (-- api-linter: core::0133::synonyms=disabled * aip.dev/not-precedent: Remove is a custom method on a singleton * resource. The "remove" verb follows Unix convention (rm) and clearly * conveys imperative action. --) * Removes (deletes) a file or directory. * Automatically detects whether the path is a file or directory. * If the path is a symbolic link, the link itself is removed, not its target. * * POST /v1/{name}/filesystem:remove */ export const createApiV1NameFilesystemRemove = async (args: CreateApiV1NameFilesystemRemoveArgs, options: CreateApiV1NameFilesystemRemoveOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/${encodeURIComponent(String(args.name))}/filesystem:remove${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 validateResponse(v1RemoveResponse, await res.json()) };