import type { IntegrationAccountRequirement, TriggerDefinition } from "../types" const WEBFLOW_SITE_READ_ACCOUNT = webflowAccount(["sites:read"]) export const webflowTriggerDefinitions = { webflowCollectionItemChanged: { account: webflowAccount(["cms:read"]), type: "webflow.collectionItem.changed", }, webflowCollectionItemCreated: { account: webflowAccount(["cms:read"]), type: "webflow.collectionItem.created", }, webflowCollectionItemDeleted: { account: webflowAccount(["cms:read"]), type: "webflow.collectionItem.deleted", }, webflowCollectionItemPublished: { account: webflowAccount(["cms:read"]), type: "webflow.collectionItem.published", }, webflowCollectionItemUnpublished: { account: webflowAccount(["cms:read"]), type: "webflow.collectionItem.unpublished", }, webflowCommentCreated: { account: webflowAccount(["comments:read"]), type: "webflow.comment.created", }, webflowEvent: { account: webflowAccount([ "cms:read", "comments:read", "ecommerce:read", "forms:read", "pages:read", "sites:read", ]), type: "webflow.event", }, webflowFormSubmitted: { account: webflowAccount(["forms:read"]), type: "webflow.form.submitted", }, webflowInventoryChanged: { account: webflowAccount(["ecommerce:read"]), type: "webflow.inventory.changed", }, webflowOrderChanged: { account: webflowAccount(["ecommerce:read"]), type: "webflow.order.changed", }, webflowOrderCreated: { account: webflowAccount(["ecommerce:read"]), type: "webflow.order.created", }, webflowPageCreated: { account: webflowAccount(["pages:read"]), type: "webflow.page.created", }, webflowPageDeleted: { account: webflowAccount(["pages:read"]), type: "webflow.page.deleted", }, webflowPageMetadataUpdated: { account: webflowAccount(["pages:read"]), type: "webflow.page.metadataUpdated", }, webflowSitePublished: { account: WEBFLOW_SITE_READ_ACCOUNT, type: "webflow.site.published", }, } as const satisfies Record /** * Requires webhook management plus the scopes needed for delivered events. * * @param eventScopes - Read scopes required by the selected provider events. */ function webflowAccount( eventScopes: readonly string[], ): IntegrationAccountRequirement<"webflow"> { return { connectionOptions: [ { connectionMethodId: "oauth", requiredScopes: ["sites:write", ...eventScopes], }, ], serviceId: "webflow", } }