refactor: remove Anki import/export and simplify card system
- Remove Anki apkg import/export functionality - Remove OCR feature module - Remove note and note-type modules - Simplify card/deck modules (remove spaced repetition complexity) - Update translator and dictionary features - Clean up unused translations and update i18n files - Simplify prisma schema
This commit is contained in:
@@ -1,30 +1,38 @@
|
||||
"use server";
|
||||
|
||||
import { ActionInputLookUpDictionary, ActionOutputLookUpDictionary, validateActionInputLookUpDictionary } from "./dictionary-action-dto";
|
||||
import { ValidateError } from "@/lib/errors";
|
||||
import { executeDictionaryLookup } from "@/lib/bigmodel/dictionary/orchestrator";
|
||||
import { createLogger } from "@/lib/logger";
|
||||
import { serviceLookUp } from "./dictionary-service";
|
||||
import { LookUpError } from "@/lib/errors";
|
||||
import {
|
||||
ActionInputLookUpDictionary,
|
||||
ActionOutputLookUpDictionary,
|
||||
validateActionInputLookUpDictionary,
|
||||
} from "./dictionary-action-dto";
|
||||
|
||||
const log = createLogger("dictionary-action");
|
||||
|
||||
export const actionLookUpDictionary = async (dto: ActionInputLookUpDictionary): Promise<ActionOutputLookUpDictionary> => {
|
||||
try {
|
||||
return {
|
||||
message: 'success',
|
||||
success: true,
|
||||
data: await serviceLookUp(validateActionInputLookUpDictionary(dto))
|
||||
};
|
||||
} catch (e) {
|
||||
if (e instanceof ValidateError) {
|
||||
return {
|
||||
success: false,
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
log.error("Dictionary lookup failed", { error: e instanceof Error ? e.message : String(e) });
|
||||
return {
|
||||
success: false,
|
||||
message: 'Unknown error occured.'
|
||||
};
|
||||
export async function actionLookUpDictionary(
|
||||
input: unknown,
|
||||
): Promise<ActionOutputLookUpDictionary> {
|
||||
try {
|
||||
const validated = validateActionInputLookUpDictionary(input);
|
||||
|
||||
const result = await executeDictionaryLookup(
|
||||
validated.text,
|
||||
validated.queryLang,
|
||||
validated.definitionLang
|
||||
);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Lookup successful",
|
||||
data: result,
|
||||
};
|
||||
} catch (e) {
|
||||
if (e instanceof LookUpError) {
|
||||
return { success: false, message: e.message };
|
||||
}
|
||||
};
|
||||
log.error("Dictionary lookup failed", { error: e instanceof Error ? e.message : String(e) });
|
||||
return { success: false, message: "Lookup failed" };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user