refactor: Introduce dedicated Document and Asset types and migrate codebase from DocumentLike.

This commit is contained in:
2025-11-26 00:38:01 +01:00
parent 93dcde471f
commit 342714528a
31 changed files with 282 additions and 442 deletions
+9 -11
View File
@@ -1,18 +1,16 @@
import { resolveDocumentAssetUrl, resolveAssetUrl } from '../asset_manager';
import type {
DocumentLike as AssetManagerDocumentLike,
DocumentVersionLike,
AssetLike as AssetManagerAssetLike,
GetAsset as AssetManagerGetAsset,
} from '../asset_manager';
import type {
Document,
DocumentVersion,
} from '../types/documents';
import type { AssetLike } from '../types/assets';
export interface DocumentLike extends AssetManagerDocumentLike {
current_version?: DocumentVersionLike | null;
}
export type { Document, DocumentVersion, AssetLike };
export type AssetLike = AssetManagerAssetLike;
export type EnsurePreviewData = (id: string) => Promise<DocumentLike | null>;
export type EnsurePreviewData = (id: string) => Promise<Document | null>;
export type EnsureAssetUrl = (
id: string,
asset: AssetLike,
@@ -21,13 +19,13 @@ export type EnsureAssetUrl = (
export type GetDocumentAsset = AssetManagerGetAsset;
interface ResolveOcrTextUrlOptions {
document: DocumentLike | null;
document: Document | null;
ensurePreviewData?: EnsurePreviewData;
getDocumentAsset?: GetDocumentAsset;
ensureAssetUrl?: EnsureAssetUrl;
}
const pickAsset = (doc?: DocumentLike | null, getDocumentAsset?: GetDocumentAsset): AssetLike | null => {
const pickAsset = (doc?: Document | null, getDocumentAsset?: GetDocumentAsset): AssetLike | null => {
if (!doc || !getDocumentAsset) {
return null;
}