import { z } from "zod"; import type { IntegrationService, ProsemirrorDoc } from "./types"; import { CollectionPermission, type ImportableIntegrationService, IssueTrackerIntegrationService, } from "./types"; import { PageType } from "plugins/notion/shared/types"; const BaseImportInputItemSchema = z.object({ permission: z.enum(CollectionPermission).optional(), }); export type BaseImportInput = z.infer[]; export const NotionImportInputItemSchema = BaseImportInputItemSchema.extend({ type: z.enum(PageType).optional(), externalId: z.string().optional(), }); export type NotionImportInput = z.infer[]; export type ImportInput = T extends IntegrationService.Notion ? NotionImportInput : BaseImportInput; export const BaseImportTaskInputItemSchema = z.object({ externalId: z.string(), parentExternalId: z.string().optional(), collectionExternalId: z.string().optional(), }); export type BaseImportTaskInput = z.infer< typeof BaseImportTaskInputItemSchema >[]; export const NotionImportTaskInputItemSchema = BaseImportTaskInputItemSchema.extend({ type: z.enum(PageType), }); export type NotionImportTaskInput = z.infer< typeof NotionImportTaskInputItemSchema >[]; export type ImportTaskInput = T extends IntegrationService.Notion ? NotionImportTaskInput : BaseImportTaskInput; // No reason to be here except for co-location with import task input. export type ImportTaskOutput = { externalId: string; title: string; emoji?: string; author?: string; content: ProsemirrorDoc; createdAt?: Date; updatedAt?: Date; }[]; export const IssueSource = z.object({ id: z.string().nonempty(), name: z.string().nonempty(), owner: z.object({ id: z.string().nonempty(), name: z.string().nonempty(), }), service: z.enum(IssueTrackerIntegrationService), }); export type IssueSource = z.infer;