import { packageStorage } from "kody:runtime"; import type { CheckConnectionInput, ConnectionStatus } from "./domain"; import { openStorySession } from "./story-run"; /** * Check whether the stored `teddyPinguinToken` reaches a Teddy & Pinguin account. * Call this before the first story, after saving or rotating the token, and whenever a * story call returns `disconnected`. Read-only: no story is created and no quota is spent. * * @param input - Optional `contentLocale` for the message language (defaults to `"de"`) * @returns `connected`, `disconnected` with a `tokenSetupUrl`, or `unreachable` * * @example * import checkConnection from 'kody:@jpfi/stories/check-connection' * * const connection = await checkConnection() * if (connection.status !== 'connected') console.log(connection.message) */ export default async function checkConnection( input: CheckConnectionInput = {}, ): Promise { const session = await openStorySession(await packageStorage()); return session.checkConnection(input); }