refactor: Introduce dedicated Document and Asset types and migrate codebase from DocumentLike.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user