Improved error handling and added protection against race conditions in the bot controller. Extracted Microsoft domain verification for better maintainability. Added support for custom activity managers and improved documentation.

This commit is contained in:
2025-11-10 22:20:34 +01:00
parent e9a1e2dbcf
commit 84a4461a2f
5 changed files with 96 additions and 14 deletions

View File

@@ -1,10 +1,30 @@
import type { MorePromotion, PromotionalItem } from './DashboardData'
import type { Page } from 'playwright'
import type { MorePromotion, PromotionalItem } from './DashboardData'
/**
* Activity handler contract for solving a single dashboard activity.
* Implementations should be stateless (or hold only a reference to the bot)
* and perform all required steps on the provided page.
*
* **Extensibility Pattern**: This interface allows developers to register custom activity handlers
* for new or unsupported activity types without modifying the core Activities.ts dispatcher.
*
* **Usage Example**:
* ```typescript
* class MyCustomHandler implements ActivityHandler {
* id = 'my-custom-handler'
* canHandle(activity) { return activity.name === 'special-promo' }
* async run(page, activity) {
* // Custom logic here
* }
* }
*
* // In bot initialization:
* bot.activities.registerHandler(new MyCustomHandler())
* ```
*
* **Notes**:
* - Implementations should be stateless (or hold only a reference to the bot)
* - The page is already navigated to the activity tab/window by the caller
* - Custom handlers are checked BEFORE built-in handlers for maximum flexibility
*/
export interface ActivityHandler {
/** Optional identifier used in logging output */