← Public packages
@kody/doordash
Order food on DoorDash as a customer through the consumer MCP used by dd-cli.
src/settings.ts
46 lines · 1.3 KB · TypeScript/**
* Optional customer prefs in package storage (address label hints, default tip).
* Live DoorDash addresses still come from the consumer account via ./address.
*/
import { packageStorage } from 'kody:runtime'
import { accessTokenSetupUrl, setupUrls } from './mcp.ts'
export type DoorDashSettings = {
defaultTipRule: string | null
notes: string | null
setup: ReturnType<typeof setupUrls>
}
function trimString(value: unknown) {
return typeof value === 'string' ? value.trim() : ''
}
export async function readSettings(): Promise<DoorDashSettings> {
const storage = packageStorage()
return {
defaultTipRule: trimString(await storage.get('defaultTipRule')) || null,
notes: trimString(await storage.get('notes')) || null,
setup: setupUrls(),
}
}
export default async function settings(
input: { defaultTipRule?: string; notes?: string } = {},
) {
const storage = packageStorage()
const updated: string[] = []
if (input.defaultTipRule !== undefined) {
await storage.set('defaultTipRule', trimString(input.defaultTipRule))
updated.push('defaultTipRule')
}
if (input.notes !== undefined) {
await storage.set('notes', trimString(input.notes))
updated.push('notes')
}
const current = await readSettings()
if (updated.length) return { updated, settings: current }
return current
}
export { accessTokenSetupUrl }