import { integrationScope, type IntegrationAccountRequirement, type TriggerDefinition, } from "../types" export const squareTriggerDefinitions = { squareBankAccountCreated: { account: squareAccount(["BANK_ACCOUNTS_READ"]), type: "square.bankAccount.created", }, squareBankAccountDisabled: { account: squareAccount(["BANK_ACCOUNTS_READ"]), type: "square.bankAccount.disabled", }, squareBankAccountVerified: { account: squareAccount(["BANK_ACCOUNTS_READ"]), type: "square.bankAccount.verified", }, squareBookingCreated: { account: squareAccount(["APPOINTMENTS_READ"]), type: "square.booking.created", }, squareBookingCustomAttributeDefinitionOwnedCreated: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.owned.created", }, squareBookingCustomAttributeDefinitionOwnedDeleted: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.owned.deleted", }, squareBookingCustomAttributeDefinitionOwnedUpdated: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.owned.updated", }, squareBookingCustomAttributeDefinitionVisibleCreated: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.visible.created", }, squareBookingCustomAttributeDefinitionVisibleDeleted: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.visible.deleted", }, squareBookingCustomAttributeDefinitionVisibleUpdated: { account: squareAccount([]), type: "square.booking.customAttributeDefinition.visible.updated", }, squareBookingCustomAttributeOwnedDeleted: { account: squareAccount([]), type: "square.booking.customAttribute.owned.deleted", }, squareBookingCustomAttributeOwnedUpdated: { account: squareAccount([]), type: "square.booking.customAttribute.owned.updated", }, squareBookingCustomAttributeVisibleDeleted: { account: squareAccount([]), type: "square.booking.customAttribute.visible.deleted", }, squareBookingCustomAttributeVisibleUpdated: { account: squareAccount([]), type: "square.booking.customAttribute.visible.updated", }, squareBookingUpdated: { account: squareAccount(["APPOINTMENTS_READ"]), type: "square.booking.updated", }, squareCardAutomaticallyUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.card.automaticallyUpdated", }, squareCardCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.card.created", }, squareCardDisabled: { account: squareAccount(["PAYMENTS_READ"]), type: "square.card.disabled", }, squareCardForgotten: { account: squareAccount(["PAYMENTS_READ"]), type: "square.card.forgotten", }, squareCardUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.card.updated", }, squareCatalogVersionUpdated: { account: squareAccount(["ITEMS_READ"]), type: "square.catalog.version.updated", }, squareCustomerCreated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.created", }, squareCustomerCustomAttributeDefinitionOwnedCreated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.owned.created", }, squareCustomerCustomAttributeDefinitionOwnedDeleted: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.owned.deleted", }, squareCustomerCustomAttributeDefinitionOwnedUpdated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.owned.updated", }, squareCustomerCustomAttributeDefinitionVisibleCreated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.visible.created", }, squareCustomerCustomAttributeDefinitionVisibleDeleted: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.visible.deleted", }, squareCustomerCustomAttributeDefinitionVisibleUpdated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttributeDefinition.visible.updated", }, squareCustomerCustomAttributeOwnedDeleted: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttribute.owned.deleted", }, squareCustomerCustomAttributeOwnedUpdated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttribute.owned.updated", }, squareCustomerCustomAttributeVisibleDeleted: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttribute.visible.deleted", }, squareCustomerCustomAttributeVisibleUpdated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.customAttribute.visible.updated", }, squareCustomerDeleted: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.deleted", }, squareCustomerUpdated: { account: squareAccount(["CUSTOMERS_READ"]), type: "square.customer.updated", }, squareDeviceCodePaired: { account: squareAccount(["DEVICE_CREDENTIAL_MANAGEMENT"]), type: "square.device.code.paired", }, squareDeviceCreated: { account: squareAccount(["DEVICES_READ"]), type: "square.device.created", }, squareDisputeCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.dispute.created", }, squareDisputeEvidenceCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.dispute.evidence.created", }, squareDisputeEvidenceDeleted: { account: squareAccount(["PAYMENTS_READ"]), type: "square.dispute.evidence.deleted", }, squareDisputeStateUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.dispute.state.updated", }, squareGiftCardActivityCreated: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.activity.created", }, squareGiftCardActivityUpdated: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.activity.updated", }, squareGiftCardCreated: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.created", }, squareGiftCardCustomerLinked: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.customerLinked", }, squareGiftCardCustomerUnlinked: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.customerUnlinked", }, squareGiftCardUpdated: { account: squareAccount(["GIFTCARDS_READ"]), type: "square.giftCard.updated", }, squareInventoryCountUpdated: { account: squareAccount(["INVENTORY_READ"]), type: "square.inventory.count.updated", }, squareInvoiceCanceled: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.canceled", }, squareInvoiceCreated: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.created", }, squareInvoiceDeleted: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.deleted", }, squareInvoicePaymentMade: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.paymentMade", }, squareInvoicePublished: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.published", }, squareInvoiceRefunded: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.refunded", }, squareInvoiceScheduledChargeFailed: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.scheduledChargeFailed", }, squareInvoiceUpdated: { account: squareAccount(["INVOICES_READ"]), type: "square.invoice.updated", }, squareJobCreated: { account: squareAccount(["EMPLOYEES_READ"]), type: "square.job.created", }, squareJobUpdated: { account: squareAccount(["EMPLOYEES_READ"]), type: "square.job.updated", }, squareLaborScheduledShiftCreated: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.scheduledShift.created", }, squareLaborScheduledShiftDeleted: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.scheduledShift.deleted", }, squareLaborScheduledShiftPublished: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.scheduledShift.published", }, squareLaborScheduledShiftUpdated: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.scheduledShift.updated", }, squareLaborTimecardCreated: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.timecard.created", }, squareLaborTimecardDeleted: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.timecard.deleted", }, squareLaborTimecardUpdated: { account: squareAccount(["TIMECARDS_READ"]), type: "square.labor.timecard.updated", }, squareLocationCreated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.created", }, squareLocationCustomAttributeDefinitionOwnedCreated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.owned.created", }, squareLocationCustomAttributeDefinitionOwnedDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.owned.deleted", }, squareLocationCustomAttributeDefinitionOwnedUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.owned.updated", }, squareLocationCustomAttributeDefinitionVisibleCreated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.visible.created", }, squareLocationCustomAttributeDefinitionVisibleDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.visible.deleted", }, squareLocationCustomAttributeDefinitionVisibleUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttributeDefinition.visible.updated", }, squareLocationCustomAttributeOwnedDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttribute.owned.deleted", }, squareLocationCustomAttributeOwnedUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttribute.owned.updated", }, squareLocationCustomAttributeVisibleDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttribute.visible.deleted", }, squareLocationCustomAttributeVisibleUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.customAttribute.visible.updated", }, squareLocationUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.location.updated", }, squareLoyaltyAccountCreated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.account.created", }, squareLoyaltyAccountDeleted: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.account.deleted", }, squareLoyaltyAccountUpdated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.account.updated", }, squareLoyaltyEventCreated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.event.created", }, squareLoyaltyProgramCreated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.program.created", }, squareLoyaltyProgramUpdated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.program.updated", }, squareLoyaltyPromotionCreated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.promotion.created", }, squareLoyaltyPromotionUpdated: { account: squareAccount(["LOYALTY_READ"]), type: "square.loyalty.promotion.updated", }, squareMerchantCustomAttributeDefinitionOwnedCreated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.owned.created", }, squareMerchantCustomAttributeDefinitionOwnedDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.owned.deleted", }, squareMerchantCustomAttributeDefinitionOwnedUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.owned.updated", }, squareMerchantCustomAttributeDefinitionVisibleCreated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.visible.created", }, squareMerchantCustomAttributeDefinitionVisibleDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.visible.deleted", }, squareMerchantCustomAttributeDefinitionVisibleUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttributeDefinition.visible.updated", }, squareMerchantCustomAttributeOwnedDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttribute.owned.deleted", }, squareMerchantCustomAttributeOwnedUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttribute.owned.updated", }, squareMerchantCustomAttributeVisibleDeleted: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttribute.visible.deleted", }, squareMerchantCustomAttributeVisibleUpdated: { account: squareAccount(["MERCHANT_PROFILE_READ"]), type: "square.merchant.customAttribute.visible.updated", }, squareOauthAuthorizationRevoked: { account: squareAccount([]), type: "square.oauth.authorization.revoked", }, squareOnlineCheckoutLocationSettingsUpdated: { account: squareAccount(["MERCHANT_PROFILE_WRITE", "MERCHANT_PROFILE_READ"]), type: "square.onlineCheckout.locationSettings.updated", }, squareOnlineCheckoutMerchantSettingsUpdated: { account: squareAccount(["MERCHANT_PROFILE_WRITE", "MERCHANT_PROFILE_READ"]), type: "square.onlineCheckout.merchantSettings.updated", }, squareOrderCreated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.created", }, squareOrderCustomAttributeDefinitionOwnedCreated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.owned.created", }, squareOrderCustomAttributeDefinitionOwnedDeleted: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.owned.deleted", }, squareOrderCustomAttributeDefinitionOwnedUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.owned.updated", }, squareOrderCustomAttributeDefinitionVisibleCreated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.visible.created", }, squareOrderCustomAttributeDefinitionVisibleDeleted: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.visible.deleted", }, squareOrderCustomAttributeDefinitionVisibleUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttributeDefinition.visible.updated", }, squareOrderCustomAttributeOwnedDeleted: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttribute.owned.deleted", }, squareOrderCustomAttributeOwnedUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttribute.owned.updated", }, squareOrderCustomAttributeVisibleDeleted: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttribute.visible.deleted", }, squareOrderCustomAttributeVisibleUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.customAttribute.visible.updated", }, squareOrderFulfillmentUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.fulfillment.updated", }, squareOrderUpdated: { account: squareAccount(["ORDERS_READ"]), type: "square.order.updated", }, squarePaymentCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.payment.created", }, squarePaymentUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.payment.updated", }, squarePayoutFailed: { account: squareAccount(["PAYOUTS_READ"]), type: "square.payout.failed", }, squarePayoutPaid: { account: squareAccount(["PAYOUTS_READ"]), type: "square.payout.paid", }, squarePayoutSent: { account: squareAccount(["PAYOUTS_READ"]), type: "square.payout.sent", }, squareRefundCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.refund.created", }, squareRefundUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.refund.updated", }, squareSubscriptionCreated: { account: squareAccount(["SUBSCRIPTIONS_READ"]), type: "square.subscription.created", }, squareSubscriptionUpdated: { account: squareAccount(["SUBSCRIPTIONS_READ"]), type: "square.subscription.updated", }, squareTeamMemberCreated: { account: squareAccount(["EMPLOYEES_READ"]), type: "square.teamMember.created", }, squareTeamMemberUpdated: { account: squareAccount(["EMPLOYEES_READ"]), type: "square.teamMember.updated", }, squareTeamMemberWageSettingUpdated: { account: squareAccount(["EMPLOYEES_READ"]), type: "square.teamMember.wageSetting.updated", }, squareTerminalActionCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.action.created", }, squareTerminalActionUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.action.updated", }, squareTerminalCheckoutCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.checkout.created", }, squareTerminalCheckoutUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.checkout.updated", }, squareTerminalRefundCreated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.refund.created", }, squareTerminalRefundUpdated: { account: squareAccount(["PAYMENTS_READ"]), type: "square.terminal.refund.updated", }, squareTransferOrderCreated: { account: squareAccount(["INVENTORY_WRITE", "INVENTORY_READ"]), type: "square.transferOrder.created", }, squareTransferOrderDeleted: { account: squareAccount(["INVENTORY_WRITE"]), type: "square.transferOrder.deleted", }, squareTransferOrderUpdated: { account: squareAccount(["INVENTORY_WRITE", "INVENTORY_READ"]), type: "square.transferOrder.updated", }, squareVendorCreated: { account: squareAccount(["VENDOR_READ"]), type: "square.vendor.created", }, squareVendorUpdated: { account: squareAccount(["VENDOR_READ"]), type: "square.vendor.updated", }, squareEvent: { account: squareAccount([ "APPOINTMENTS_READ", "BANK_ACCOUNTS_READ", "CUSTOMERS_READ", "DEVICES_READ", "DEVICE_CREDENTIAL_MANAGEMENT", "EMPLOYEES_READ", "GIFTCARDS_READ", "INVENTORY_READ", "INVENTORY_WRITE", "INVOICES_READ", "ITEMS_READ", "LOYALTY_READ", "MERCHANT_PROFILE_READ", "MERCHANT_PROFILE_WRITE", "ORDERS_READ", "PAYMENTS_READ", "PAYOUTS_READ", "SUBSCRIPTIONS_READ", "TIMECARDS_READ", "VENDOR_READ", ]), type: "square.event", }, } as const satisfies Record /** * Requires the seller OAuth scopes needed for delivered Square events. * * @param scopes - Provider permissions required by the event selection. */ function squareAccount( scopes: readonly string[], ): IntegrationAccountRequirement<"square"> { return { connectionOptions: [ { connectionMethodId: "oauth", requiredScopes: scopes.length < 2 ? scopes : [integrationScope.and(...scopes)], }, ], serviceId: "square", } }