Skip to content
← Public packages

@kody/openapi

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

src/list.ts

25 lines · 727 B · TypeScript
import {
	toOpenApiBindingSummary,
	type OpenApiBindingSummary,
} from './selection.ts'
import { loadBindings } from './storage.ts'

/**
 * List OpenAPI bindings stored on this forked package.
 * Use before call() when you need the binding names and operation counts.
 *
 * @returns Binding summaries, newest update first
 *
 * @example
 * import list from 'kody:@<username>/openapi/list'
 * const { bindings } = await list()
 */
export default async function list(): Promise<{
	bindings: Array<OpenApiBindingSummary>
}> {
	const stored = await loadBindings()
	const bindings = Object.values(stored)
		.map(toOpenApiBindingSummary)
		.sort((left, right) => right.updatedAt.localeCompare(left.updatedAt))
	return { bindings }
}