Skip to content

Implement Bitrix24Partners support (issue #70)#109

Open
KarlsonComplete wants to merge 70 commits into
mesilov:claude/bitrix24-issue-70-01PSzKghSeJKibfs1z3wb8sXfrom
KarlsonComplete:claude/bitrix24-issue-70-01PSzKghSeJKibfs1z3wb8sX
Open

Implement Bitrix24Partners support (issue #70)#109
KarlsonComplete wants to merge 70 commits into
mesilov:claude/bitrix24-issue-70-01PSzKghSeJKibfs1z3wb8sXfrom
KarlsonComplete:claude/bitrix24-issue-70-01PSzKghSeJKibfs1z3wb8sX

Conversation

@KarlsonComplete

@KarlsonComplete KarlsonComplete commented Apr 19, 2026

Copy link
Copy Markdown
Collaborator

This commit implements comprehensive support for Bitrix24Partners following the established DDD/CQRS patterns in the codebase.

Features Implemented:

Core Domain

  • Bitrix24Partner entity with full interface implementation
  • Repository with all required query methods
  • Doctrine XML mapping with unique constraint on bitrix24PartnerId
  • PhoneNumber Doctrine custom type for phone number storage

Use Cases (CQRS)

  • Create: Create new partner records
  • Update: Update partner information
  • Delete: Soft-delete partners (mark as deleted)
  • MarkAsBlocked: Block partner accounts
  • MarkAsActive: Reactivate blocked partners

CLI Tools

  • ScrapePartnersCommand: Web scraper for https://www.bitrix24.ru/partners/
    • Parses partner data from HTML
    • Generates CSV output
    • Configurable URL and output path
  • ImportPartnersCsvCommand: CSV import utility
    • Bulk import partners from CSV files
    • Phone number parsing with libphonenumber
    • Error handling with --skip-errors option

Testing

  • Unit tests for entity (extends SDK contract tests)
  • Unit tests for Create command validation

Technical Details:

  • Follows existing bounded context patterns
  • Uses value objects where appropriate
  • Implements domain events for all state changes
  • Full validation in command constructors
  • Comprehensive error handling

Resolves: #70

Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #70
License MIT

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Bitrix24Partners module by renaming bitrix24PartnerId to bitrix24PartnerNumber and transitioning the repository to a composition-based approach. It also introduces email validation, updates PHP and PHPUnit version requirements, adds a maintainer skill definition, and improves testing infrastructure with a new partner builder. Feedback identifies inconsistent Docker command usage in the Makefile, suggests a more standard PHP version constraint, notes PSR-12 style regressions, recommends better HTML error handling, and identifies a typo in a directory name.

Comment thread Makefile
Comment thread composer.json
Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php Outdated
Comment thread .agents/skills/bitrix24-php-lib-maintainer/SKILL.md

@camaxtly camaxtly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

19-04-2026

Comment thread config/xml/Bitrix24.Lib.Bitrix24Partners.Entity.Bitrix24Partner.dcm.xml Outdated
Comment thread src/Bitrix24Partners/Entity/Bitrix24Partner.php Outdated
Comment thread src/Bitrix24Partners/Entity/Bitrix24Partner.php Outdated
Comment thread src/Bitrix24Partners/Entity/Bitrix24Partner.php Outdated
Comment thread src/Bitrix24Partners/Entity/Bitrix24Partner.php Outdated
Comment thread src/Bitrix24Partners/Entity/Bitrix24Partner.php
Comment thread src/Bitrix24Partners/Infrastructure/Doctrine/Bitrix24PartnerRepository.php Outdated
Comment thread src/Bitrix24Partners/UseCase/Delete/Handler.php Outdated
…logic:

- Add `Bitrix24PartnerNotFoundException` handling to UseCase Handlers (`Create`, `Update`, `Delete`, `MarkAsBlocked`, `MarkAsActive`) for better error management and logging.
- Enhance field validation in `Update.Command` to ensure stricter checks.
- Introduce `logoUrl` field in `Bitrix24Partner` entity and adjust related UseCases and tests.
- Refactor tests to include new scenarios and improve data consistency.
- Replace `docker-compose` with `docker compose` in `Makefile`.
- Introduce `bitrix24:partners:scrape:v2` command with updated logic.
- Register `ScrapePartnersCommand_V2` in the console application.
- Integrate Monolog for detailed logging throughout the scraping process.
- Refactor `ScrapePartnersCommand_V2` to enhance parsing logic and improve error handling.
- Introduce support for fetching partner logos and storing results in a CSV file.
- Streamline HTTP requests and implement configurable delays.
…а, изменил сигнатуры методов сущности и добавил поддержку логотипа партнера.
@KarlsonComplete KarlsonComplete changed the title Claude/bitrix24 issue 70 01 p sz kgh se j kibfs1z3wb8s x Implement Bitrix24Partners support (issue #70) Apr 26, 2026
Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php Outdated
Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php

@camaxtly camaxtly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

26-04-2026

Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php Outdated
Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php Outdated
Comment thread src/Bitrix24Partners/Console/ScrapePartnersCommand.php Outdated
Comment thread src/Bitrix24Partners/UseCase/Create/Handler.php
Comment thread src/Bitrix24Partners/UseCase/Delete/Handler.php
- Add `Uuid::v7()` support in `Bitrix24Partner` constructors and builders.
- Improve validation for partner creation with `bitrix24PartnerNumber`.
- Update Doctrine mapping for `bitrix24PartnerNumber` to use `unique` attribute.
…erBuilder:

- Remove redundant `withBitrix24PartnerNumber` calls from tests.
- Adjust `Bitrix24PartnerBuilder` to expand possible number range.
- Reorder `clear()` in `Update.HandlerTest` for better test consistency.
…dize database truncation across functional tests.
- Implement stricter non-empty string checks for `site`, `email`, `openLineId`, `externalId`, and `logoUrl` in `Update.Command` and `Bitrix24Partner` entity.
- Update associated tests to cover new validation scenarios.
…s, and refactor `Makefile` and `console` setup.
…aper` services and integrated them into `ScrapePartnersCommandV2` for improved modularity and reusability.
…ScrapePartnersCommandV2: добавлена обработка блокировок, настройки задержек, детектирование пустых страниц и обновлён механизм работы с доменом.
…rtnersCsvCommand, улучшил обработку пустых страниц и блокировок в ScrapePartnersCommandV2, добавил загрузку .env.local.
…вил документацию по командам скрейпинга и импорта партнёров.
…ацию всех пунктов, включая BanDetector, processPartner, Bitrix24Zone enum, и обновление документации.

@camaxtly camaxtly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24-05-2026

Comment thread docs/dev/partner-import-scenarios.md Outdated
Comment thread docs/dev/partner-import-scenarios.md Outdated
Comment thread docs/commands/partner-commands.md Outdated
Comment thread docs/commands/partner-commands.md Outdated
Comment thread docs/commands/partner-commands.md Outdated
Comment thread docs/commands/partner-scenarios.md Outdated
Comment thread docs/commands/partner-scenarios.md Outdated
Comment thread docs/commands/partner-scenarios.md Outdated
Comment thread docs/commands/partner-scenarios.md Outdated
Comment thread docs/commands/partner-scenarios.md Outdated
…r update logic into `ScrapeWorkflow` and `ScrapePartnersCommand` for improved modularity and maintainability. Update ScrapeConfig to support specific partner updates. Streamline progress tracking and error handling.
…r file organization:

- Replace `outputFile` with `outputDir` across configurations, workflows, and commands.
- Introduce timestamped filenames for output files.
- Update state management to support directory-based operations.
- Adjust tests, Makefile commands, and verbosity outputs accordingly.
…scrape configuration to introduce `requestDelay`. Simplify `ScrapeWorkflow` start context resolution and improve state management consistency.
- Remove `.opencode/plans/2026-05-26-fix-output-dir-resume-logic.md` to declutter repository.
- Refactor `ScrapeConfig` to use nullable `outputFile` and remove auto-generation.
- Update `ScrapeStateManager` to store full `output_file` paths and add output-dir validation on resume.
- Split `resolveStartContext` into `resolveResumeContext` and `getPageRange` in `ScrapeWorkflow`.
- Refactor `ScrapePartnersCommand` for single-pass output-file resolution and verbosity improvements.
- Introduce `ScrapeOptions` for streamlined scraping configurations.
…ortStats`, update method signatures, and streamline CSV file handling and import command default directory.
…leted partners, add option to include deleted in queries, and improve logging for skipped operations.
…enarios in `partner-scenarios.md`

- Introduce `partner-common.md` with guidelines for CSV format, ban detection, and partner handling.
- Simplify and consolidate `partner-scenarios.md` to focus on key scraping use cases.
- Replace per-scenario options with centralized documentation for `partners:scrape` command.
- Update examples and workflows to reflect streamlined scraping architecture and functionality.
…emove obsolete `Upsert` tests, commands, and handlers; add `Import` equivalents.
…ated use cases; streamline `Command` test cases by removing redundant assertions.
… maintainability:

- Replace redundant `(new Bitrix24PartnerBuilder())` with `new Bitrix24PartnerBuilder()` across test files for cleaner syntax.
- Remove unused properties and refine logic in `ScrapeProgress`.
- Introduce `phpstan-baseline.neon` for static analysis error management.
- Update `ScrapeConfig` and commands to align with stricter type declarations and nullable handling.
- Bump `phpstan` and `rector` versions in `composer.json` for enhanced static analysis.
- Restructure and streamline test scenarios for `MarkAsActive`, `Update`, `Delete`, and `Import`.
…age, commands, options, workflows, and error handling.

@camaxtly camaxtly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

31-05-2026

Comment thread docs/commands/partner-common.md Outdated
Comment thread docs/commands/partner-import-scenarios.md Outdated
Comment thread docs/commands/partner-import-scenarios.md Outdated
Comment thread docs/commands/partner-import-scenarios.md
Comment thread docs/commands/partner-import-scenarios.md Outdated
Comment thread src/Bitrix24Partners/Infrastructure/Doctrine/Bitrix24PartnerRepository.php Outdated
Comment thread src/Bitrix24Partners/UseCase/Import/Handler.php Outdated
Comment thread src/Bitrix24Partners/UseCase/Import/Handler.php Outdated
Comment thread src/Bitrix24Partners/UseCase/Import/Handler.php Outdated
use League\Csv\Writer;
use Psr\Log\LoggerInterface;

class ScrapeWorkflow

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

посмотреть позже ---

…h normalization, update related methods, and adjust test assertions. Fix partner ID validation in `ScrapePartnersCommand`.
…ed partner mapping, update `ImportWorkflow` to use `PartnerSyncView`, adjust repository to return raw partner data, and clean up redundant interface usage.
…and related documentation for clarity on relative path usage.
Comment thread docs/commands/partner-common.md Outdated
…ate default directory references in documentation and examples, and remove unused `DEFAULT_OUTPUT_DIR` constant.
…SV-based data import to evaluate performance of `findAllActiveAsArray` and `findAllActive` methods.
…target, introduce `PartnerSyncViewTest`, refactor `ImportWorkflow` to use `Bitrix24PartnerReadModel`, and migrate repository logic for `findAllActiveAsArray` to `Bitrix24PartnerReadModel`.
…xcessive validation errors, add detailed error reporting, and improve import summary output.
…ior, add error handling details for import, and explain idempotent import logic.
…ImportResult`, and `ImportPartnersCsvCommand` for readability and consistency.

@camaxtly camaxtly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

05-07-2026

Comment thread docs/commands/partner-scenarios.md Outdated
Comment thread docs/commands/partner-scraper-scenarios.md
Comment thread docs/commands/partner-common.md Outdated
Comment thread docs/commands/partner-common.md Outdated
CSV = полный источник истины. Действия: **создание**, **обновление**, **пропуск**, **софт-делит**.

```bash
php bin/console bitrix24:partners:import var/scraper/partners.csv

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Примеры из документации должны работать. Тут или относительный путь или абсолютный.

Добавить issue, где в скил мейнтейнера добавить блок по проверке документации. Требование - все примеры в документации должны быть рабочие.

use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class ImportWorkflow

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай все-же вынесем массовые операции из usecase и положим просто в корень контекста. Тут будет просто папка import и все в ней.

Comment thread src/Bitrix24Partners/UseCase/Import/ImportWorkflow.php Outdated
use League\Csv\Writer;
use Psr\Log\LoggerInterface;

class ScrapeWorkflow

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже выносим из юзкейсов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants