Skip to content

Build your personal knowledge base with Trilium Notes

refactor(ocr): move TextRepresentationResponse into `server_api`

Elian Doran9cfad0fe6a86
diff --git a/apps/client/src/widgets/type_widgets/ReadOnlyTextRepresentation.tsx b/apps/client/src/widgets/type_widgets/ReadOnlyTextRepresentation.tsx
index 308698d1d5..c67cc4dfd9 100644
--- a/apps/client/src/widgets/type_widgets/ReadOnlyTextRepresentation.tsx
+++ b/apps/client/src/widgets/type_widgets/ReadOnlyTextRepresentation.tsx
@@ -1,5 +1,6 @@
import "./ReadOnlyTextRepresentation.css";
+import type { TextRepresentationResponse } from "@triliumnext/commons";
import { useEffect, useState } from "preact/hooks";
import { t } from "../../services/i18n";
@@ -8,14 +9,6 @@ import toast from "../../services/toast";
import { formatDateTime } from "../../services/utils";
import { TypeWidgetProps } from "./type_widget";
-interface TextRepresentationResponse {
- success: boolean;
- text: string;
- hasOcr: boolean;
- extractedAt: string | null;
- message?: string;
-}
-
type State =
| { kind: "loading" }
| { kind: "loaded"; text: string; extractedAt: string | null }
diff --git a/apps/server/src/routes/api/ocr.ts b/apps/server/src/routes/api/ocr.ts
index 6b94322ad6..ab4008090c 100644
--- a/apps/server/src/routes/api/ocr.ts
+++ b/apps/server/src/routes/api/ocr.ts
@@ -1,3 +1,4 @@
+import { TextRepresentationResponse } from "@triliumnext/commons";
import type { Request } from "express";
import becca from "../../becca/becca.js";
@@ -301,7 +302,7 @@ async function getNoteOCRText(req: Request<{ noteId: string }>) {
text: ocrText || '',
hasOcr: !!ocrText,
extractedAt
- };
+ } satisfies TextRepresentationResponse;
}
export default {
diff --git a/packages/commons/src/lib/server_api.ts b/packages/commons/src/lib/server_api.ts
index 3edf99ec64..293bfa47bf 100644
--- a/packages/commons/src/lib/server_api.ts
+++ b/packages/commons/src/lib/server_api.ts
@@ -288,6 +288,14 @@ export interface ToMarkdownResponse {
markdownContent: string;
}
+export interface TextRepresentationResponse {
+ success: boolean;
+ text: string;
+ hasOcr: boolean;
+ extractedAt: string | null;
+ message?: string;
+}
+
export interface IconRegistry {
sources: {
prefix: string;