mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
ecafd5f32a
* chore: Update JSON importer to use zip streaming, new importer flow * chore: Drop teamId from import urlId collision check and remove unused internal-id scaffolding urlId is globally unique on Document/Collection so the team scope was wrong. Also removes leftover internal-id generation in JSONAPIImportTask that was never used in task input/output. * Restore classes used upstream
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { FileOperationFormat, FileOperationType } from "@shared/types";
|
|
import { FileOperation } from "@server/models";
|
|
import type { Event as TEvent, FileOperationEvent } from "@server/types";
|
|
import ExportHTMLZipTask from "../tasks/ExportHTMLZipTask";
|
|
import ExportJSONTask from "../tasks/ExportJSONTask";
|
|
import ExportMarkdownZipTask from "../tasks/ExportMarkdownZipTask";
|
|
import BaseProcessor from "./BaseProcessor";
|
|
|
|
export default class FileOperationCreatedProcessor extends BaseProcessor {
|
|
static applicableEvents: TEvent["name"][] = ["fileOperations.create"];
|
|
|
|
async perform(event: FileOperationEvent) {
|
|
const fileOperation = await FileOperation.unscoped().findByPk(
|
|
event.modelId,
|
|
{
|
|
rejectOnEmpty: true,
|
|
}
|
|
);
|
|
|
|
// Imports no longer flow through FileOperation — both JSON and Markdown
|
|
// zip imports run through the API-import pipeline (`imports.create` →
|
|
// {Markdown,JSON}APIImportTask). This dispatcher only handles exports.
|
|
if (fileOperation.type === FileOperationType.Export) {
|
|
switch (fileOperation.format) {
|
|
case FileOperationFormat.HTMLZip:
|
|
await new ExportHTMLZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.MarkdownZip:
|
|
await new ExportMarkdownZipTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
case FileOperationFormat.JSON:
|
|
await new ExportJSONTask().schedule({
|
|
fileOperationId: event.modelId,
|
|
});
|
|
break;
|
|
default:
|
|
}
|
|
}
|
|
}
|
|
}
|