import type { IntegrationAccountRequirement, TriggerDefinition } from "../types" const CONTACT = hubspotAccount("crm.objects.contacts.read") const COMPANY = hubspotAccount("crm.objects.companies.read") const DEAL = hubspotAccount("crm.objects.deals.read") const TICKET = hubspotAccount("tickets") export const hubspotTriggerDefinitions = { hubspotCrmEvent: definition( "hubspot.crm.event", hubspotAccount([ "crm.objects.companies.read", "crm.objects.contacts.read", "crm.objects.deals.read", "tickets", ]), ), hubspotCompanyAssociationAdded: definition( "hubspot.company.associationAdded", COMPANY, ), hubspotCompanyAssociationRemoved: definition( "hubspot.company.associationRemoved", COMPANY, ), hubspotCompanyCreated: definition("hubspot.company.created", COMPANY), hubspotCompanyDeleted: definition("hubspot.company.deleted", COMPANY), hubspotCompanyMerged: definition("hubspot.company.merged", COMPANY), hubspotCompanyRestored: definition("hubspot.company.restored", COMPANY), hubspotCompanyUpdated: definition("hubspot.company.updated", COMPANY), hubspotContactAssociationAdded: definition( "hubspot.contact.associationAdded", CONTACT, ), hubspotContactAssociationRemoved: definition( "hubspot.contact.associationRemoved", CONTACT, ), hubspotContactCreated: definition("hubspot.contact.created", CONTACT), hubspotContactDeleted: definition("hubspot.contact.deleted", CONTACT), hubspotContactMerged: definition("hubspot.contact.merged", CONTACT), hubspotContactRestored: definition("hubspot.contact.restored", CONTACT), hubspotContactUpdated: definition("hubspot.contact.updated", CONTACT), hubspotDealAssociationAdded: definition( "hubspot.deal.associationAdded", DEAL, ), hubspotDealAssociationRemoved: definition( "hubspot.deal.associationRemoved", DEAL, ), hubspotDealCreated: definition("hubspot.deal.created", DEAL), hubspotDealDeleted: definition("hubspot.deal.deleted", DEAL), hubspotDealMerged: definition("hubspot.deal.merged", DEAL), hubspotDealRestored: definition("hubspot.deal.restored", DEAL), hubspotDealUpdated: definition("hubspot.deal.updated", DEAL), hubspotTicketAssociationAdded: definition( "hubspot.ticket.associationAdded", TICKET, ), hubspotTicketAssociationRemoved: definition( "hubspot.ticket.associationRemoved", TICKET, ), hubspotTicketCreated: definition("hubspot.ticket.created", TICKET), hubspotTicketDeleted: definition("hubspot.ticket.deleted", TICKET), hubspotTicketMerged: definition("hubspot.ticket.merged", TICKET), hubspotTicketRestored: definition("hubspot.ticket.restored", TICKET), hubspotTicketUpdated: definition("hubspot.ticket.updated", TICKET), } as const satisfies Record /** * Builds one typed HubSpot trigger definition. * * @param type - Public event type. * @param account - Required HubSpot account contract. */ function definition( type: TType, account: IntegrationAccountRequirement<"hubspot">, ) { return { account, type } } /** * Builds an OAuth-only HubSpot trigger account requirement. * * @param requiredScopes - Required OAuth scopes. */ function hubspotAccount( requiredScopes: string | readonly string[], ): IntegrationAccountRequirement<"hubspot"> { return { connectionOptions: [ { connectionMethodId: "oauth", requiredScopes: typeof requiredScopes === "string" ? [requiredScopes] : requiredScopes, }, ], serviceId: "hubspot", } }