export type UserDictWord = {surface: string, priority: number, context_id?: number | undefined, part_of_speech: string, part_of_speech_detail_1: string, part_of_speech_detail_2: string, part_of_speech_detail_3: string, inflectional_type: string, inflectional_form: string, stem: string, yomi: string, pronunciation: string, accent_type: number, mora_count?: number | undefined, accent_associative_rule: string}; export type CreateApiImportUserDictArgs = {override: boolean, body: {[key: string]: UserDictWord}}; export type CreateApiImportUserDictOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Import User Dict Words * * POST /import_user_dict */ export const createApiImportUserDict = async (args: CreateApiImportUserDictArgs, options: CreateApiImportUserDictOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.override != null) query.append("override", String(args.override)) const url = `${baseUrl.replace(/\/+$/, '')}/import_user_dict${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 undefined };