Files
Tom Moor 8df9c854fa fix: Error imports that have nothing to import (#14577)
An import with no input, or a Notion import with no shared pages, stayed in an active state with no tasks. This blocked new imports for the team until the creator canceled it.
2026-11-13 08:33:36 -05:00

39 lines
1.1 KiB
TypeScript

import { z } from "zod";
import { IntegrationService } from "@shared/types";
import { IntegrationImportBodySchema } from "@server/routes/api/imports/schema";
import { Hook, PluginManager } from "@server/utils/PluginManager";
import config from "../plugin.json";
import router from "./api/notion";
import { NotionImportInputItemSchema } from "../shared/schema";
import env from "./env";
import { NotionImportsProcessor } from "./processors/NotionImportsProcessor";
import NotionAPIImportTask from "./tasks/NotionAPIImportTask";
PluginManager.add({
type: Hook.ImportSchema,
value: IntegrationImportBodySchema.extend({
service: z.literal(IntegrationService.Notion),
input: z.array(NotionImportInputItemSchema).min(1),
}),
});
const enabled = !!env.NOTION_CLIENT_ID && !!env.NOTION_CLIENT_SECRET;
if (enabled) {
PluginManager.add([
{
...config,
type: Hook.API,
value: router,
},
{
type: Hook.Processor,
value: NotionImportsProcessor,
},
{
type: Hook.Task,
value: NotionAPIImportTask,
},
]);
}