feat: use sourceMetadata column for collections in import processes (#10168)

* feat: use sourceMetadata column for collections in import processes

- Update ImportsProcessor to populate sourceMetadata with externalId, externalName, and createdByName for collections
- Add sourceMetadata to collection presenter for API responses
- Ensure collections follow same metadata methodology as documents during imports

Co-authored-by: Tom Moor <tom@getoutline.com>

* Update collection.ts

---------

Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com>
Co-authored-by: Tom Moor <tom@getoutline.com>
This commit is contained in:
codegen-sh[bot]andTom Moor authored and GitHub committed 2025-09-14 08:23:45 -04:00
1 parent e1b29bd854
commit bf68a1d2bf
2 files changed
+16

No files matched your search

+7
View File
@@ -59,6 +59,13 @@ export default async function presentCollection(
if (!options.isPublic) {
res.archivedBy =
collection.archivedBy && presentUser(collection.archivedBy);
res.sourceMetadata = collection.sourceMetadata
? {
externalId: collection.sourceMetadata.externalId,
externalName: collection.sourceMetadata.externalName,
createdByName: collection.sourceMetadata.createdByName,
}
: undefined;
}
return res;
@@ -19,6 +19,7 @@ import {
MentionType,
ProsemirrorData,
ProsemirrorDoc,
SourceMetadata,
} from "@shared/types";
import { colorPalette } from "@shared/utils/collections";
import { CollectionValidation } from "@shared/validations";
@@ -357,6 +358,13 @@ export default abstract class ImportsProcessor<
}
);
// Build sourceMetadata for the collection
const sourceMetadata: SourceMetadata = {
externalId: externalId,
externalName: output.title,
createdByName: output.author,
};
const collection = Collection.build({
id: internalId,
name: output.title,
@@ -372,6 +380,7 @@ export default abstract class ImportsProcessor<
index: collectionIdx,
sort: Collection.DEFAULT_SORT,
permission: collectionItem.permission,
sourceMetadata,
createdAt: output.createdAt ?? now,
updatedAt: output.updatedAt ?? now,
});