import type { IntegrationAccountRequirement, TriggerDefinition } from "../types" const NOTION_READ_CONTENT_ACCOUNT = notionOAuthAccount(["read_content"]) const NOTION_READ_COMMENTS_ACCOUNT = notionOAuthAccount(["read_comments"]) const NOTION_INSERT_CONTENT_ACCOUNT = notionOAuthAccount(["insert_content"]) export const notionTriggerDefinitions = { notionCommentCreated: notionTrigger( NOTION_READ_COMMENTS_ACCOUNT, "notion.comment.created", ), notionCommentDeleted: notionTrigger( NOTION_READ_COMMENTS_ACCOUNT, "notion.comment.deleted", ), notionCommentUpdated: notionTrigger( NOTION_READ_COMMENTS_ACCOUNT, "notion.comment.updated", ), notionDatabaseCreated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.database.created", ), notionDatabaseDeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.database.deleted", ), notionDatabaseMoved: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.database.moved", ), notionDatabaseUndeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.database.undeleted", ), notionDataSourceContentUpdated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.contentUpdated", ), notionDataSourceCreated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.created", ), notionDataSourceDeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.deleted", ), notionDataSourceMoved: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.moved", ), notionDataSourceSchemaUpdated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.schemaUpdated", ), notionDataSourceUndeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.dataSource.undeleted", ), notionEvent: notionTrigger( notionOAuthAccount(["insert_content", "read_comments", "read_content"]), "notion.event", ), notionFileUploadCompleted: notionTrigger( NOTION_INSERT_CONTENT_ACCOUNT, "notion.fileUpload.completed", ), notionFileUploadCreated: notionTrigger( NOTION_INSERT_CONTENT_ACCOUNT, "notion.fileUpload.created", ), notionFileUploadExpired: notionTrigger( NOTION_INSERT_CONTENT_ACCOUNT, "notion.fileUpload.expired", ), notionFileUploadFailed: notionTrigger( NOTION_INSERT_CONTENT_ACCOUNT, "notion.fileUpload.failed", ), notionPageContentUpdated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.contentUpdated", ), notionPageCreated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.created", ), notionPageDeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.deleted", ), notionPageLocked: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.locked", ), notionPageMoved: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.moved", ), notionPagePropertiesUpdated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.propertiesUpdated", ), notionPageTranscriptDeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.transcriptDeleted", ), notionPageUndeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.undeleted", ), notionPageUnlocked: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.page.unlocked", ), notionViewCreated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.view.created", ), notionViewDeleted: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.view.deleted", ), notionViewUpdated: notionTrigger( NOTION_READ_CONTENT_ACCOUNT, "notion.view.updated", ), } as const satisfies Record /** * Defines one Notion trigger with its exact stable event type. * * @param account - OAuth capability requirements for the event family. * @param type - Stable internal event type. */ function notionTrigger( account: IntegrationAccountRequirement<"notion">, type: TType, ) { return { account, type } } /** * Creates the OAuth-only account requirement for a Notion webhook family. * * @param requiredScopes - Fixed Notion integration capabilities. */ function notionOAuthAccount( requiredScopes: readonly string[], ): IntegrationAccountRequirement<"notion"> { return { connectionOptions: [{ connectionMethodId: "oauth", requiredScopes }], serviceId: "notion", } }