Store source metadata for imported documents (#6136)

This commit is contained in:
Tom Moor
2023-11-11 10:52:29 -05:00
committed by GitHub
parent 90605e110a
commit 48d688c0a5
16 changed files with 178 additions and 48 deletions

View File

@@ -1,3 +1,4 @@
import path from "path";
import truncate from "lodash/truncate";
import {
AttachmentPreset,
@@ -49,7 +50,7 @@ export type StructuredImportData = {
*/
description?: string | Record<string, any> | null;
/** Optional id from import source, useful for mapping */
sourceId?: string;
externalId?: string;
}[];
documents: {
id: string;
@@ -75,8 +76,9 @@ export type StructuredImportData = {
createdById?: string;
createdByEmail?: string | null;
path: string;
mimeType: string;
/** Optional id from import source, useful for mapping */
sourceId?: string;
externalId?: string;
}[];
attachments: {
id: string;
@@ -85,7 +87,7 @@ export type StructuredImportData = {
mimeType: string;
buffer: () => Promise<Buffer>;
/** Optional id from import source, useful for mapping */
sourceId?: string;
externalId?: string;
}[];
};
@@ -428,7 +430,11 @@ export default abstract class ImportTask extends BaseTask<Props> {
const document = await documentCreator({
...options,
source: "import",
sourceMetadata: {
fileName: path.basename(item.path),
mimeType: item.mimeType,
externalId: item.externalId,
},
id: item.id,
title: item.title,
text,