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

@@ -75,11 +75,12 @@ export default class ImportJSONTask extends ImportTask {
updatedAt: node.updatedAt ? new Date(node.updatedAt) : undefined,
publishedAt: node.publishedAt ? new Date(node.publishedAt) : null,
collectionId,
sourceId: node.id,
externalId: node.id,
mimeType: "application/json",
parentDocumentId: node.parentDocumentId
? find(
output.documents,
(d) => d.sourceId === node.parentDocumentId
(d) => d.externalId === node.parentDocumentId
)?.id
: null,
id,
@@ -101,7 +102,7 @@ export default class ImportJSONTask extends ImportTask {
buffer: () => zipObject.async("nodebuffer"),
mimeType,
path: node.key,
sourceId: node.id,
externalId: node.id,
});
});
}
@@ -132,7 +133,7 @@ export default class ImportJSONTask extends ImportTask {
)
: item.collection.description,
id: collectionId,
sourceId: item.collection.id,
externalId: item.collection.id,
});
if (Object.values(item.documents).length) {
@@ -149,7 +150,7 @@ export default class ImportJSONTask extends ImportTask {
for (const document of output.documents) {
for (const attachment of output.attachments) {
const encodedPath = encodeURI(
`/api/attachments.redirect?id=${attachment.sourceId}`
`/api/attachments.redirect?id=${attachment.externalId}`
);
document.text = document.text.replace(