mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +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
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import type { Transaction } from "sequelize";
|
|
import type { ImportTaskInput } from "@shared/schema";
|
|
import { ImportTaskPhase, IntegrationService } from "@shared/types";
|
|
import type { Import, ImportTask } from "@server/models";
|
|
import JSONAPIImportTask from "../tasks/JSONAPIImportTask";
|
|
import ImportsProcessor from "./ImportsProcessor";
|
|
|
|
export default class JSONImportsProcessor extends ImportsProcessor<IntegrationService.JSON> {
|
|
protected canProcess(importModel: Import<IntegrationService.JSON>): boolean {
|
|
return importModel.service === IntegrationService.JSON;
|
|
}
|
|
|
|
protected getInitialPhase(): ImportTaskPhase {
|
|
return ImportTaskPhase.Bootstrap;
|
|
}
|
|
|
|
protected async buildTasksInput(
|
|
importModel: Import<IntegrationService.JSON>,
|
|
_transaction: Transaction
|
|
): Promise<ImportTaskInput<IntegrationService.JSON>> {
|
|
if (!importModel.scratch?.storageKey) {
|
|
throw new Error(
|
|
"JSON import is missing scratch.storageKey for the bootstrap phase"
|
|
);
|
|
}
|
|
|
|
return [{ externalId: importModel.input[0].externalId }];
|
|
}
|
|
|
|
protected async scheduleTask(
|
|
importTask: ImportTask<IntegrationService.JSON>
|
|
): Promise<void> {
|
|
await new JSONAPIImportTask().schedule({ importTaskId: importTask.id });
|
|
}
|
|
}
|