Skip to content
← Public packages

@kody/openapi

Bind an OpenAPI spec and call selected operations with saved integration or secret names.

src/unbind.ts

25 lines · 730 B · TypeScript
import { assertBindingName } from './selection.ts'
import { loadBindings, saveBindings } from './storage.ts'

/**
 * Delete a stored OpenAPI binding from this package's storage.
 * Use when the spec is gone or you no longer want that named snapshot.
 *
 * @param input - Binding name
 * @returns The removed name
 *
 * @example
 * import unbind from 'kody:@<username>/openapi/unbind'
 * await unbind({ name: 'acme' })
 */
export default async function unbind(input: { name: string }): Promise<{
	name: string
	removed: boolean
}> {
	const name = assertBindingName(input.name)
	const bindings = await loadBindings()
	const removed = name in bindings
	delete bindings[name]
	await saveBindings(bindings)
	return { name, removed }
}