Files
orderPRO/.paul/phases/01-tech-debt/01-01-SUMMARY.md
Jacek Pyziak f8db8c0162 refactor(01-tech-debt): extract AllegroTokenManager and StringHelper
Phase 1 complete (2/2 plans):

- Plan 01-01: Extract AllegroTokenManager — OAuth token logic
  centralized from 4 classes into dedicated manager class

- Plan 01-02: Extract StringHelper — nullableString/normalizeDateTime/
  normalizeColorHex extracted from 15+ classes into App\Core\Support\StringHelper;
  removed 19 duplicate private methods

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-12 23:36:06 +01:00

4.8 KiB
Raw Blame History

phase, plan, subsystem, tags, requires, provides, affects, tech-stack, key-files, key-decisions, patterns-established, duration, started, completed
phase plan subsystem tags requires provides affects tech-stack key-files key-decisions patterns-established duration started completed
01-tech-debt 01 auth
allegro
oauth
token-manager
refactor
AllegroTokenManager — shared OAuth token resolver for all Allegro services
Eliminated 4-way duplication of token refresh logic
allegro-integration
cron-jobs
shipments
added patterns
Shared service extraction — extract duplicated private methods into injected collaborator
created modified
src/Modules/Settings/AllegroTokenManager.php
src/Modules/Settings/AllegroOrderImportService.php
src/Modules/Settings/AllegroOrdersSyncService.php
src/Modules/Settings/AllegroStatusDiscoveryService.php
src/Modules/Shipments/AllegroShipmentService.php
routes/web.php
src/Core/Application.php
.paul/codebase/CONCERNS.md
DOCS/ARCHITECTURE.md
401 retry paths also use tokenManager->resolveToken() — best-effort, consistent with structural-only scope
AllegroTokenManager wstrzykiwany wszędzie tam gdzie potrzebny jest token Allegro OAuth
~30min 2026-03-12T00:00:00Z 2026-03-12T00:00:00Z

Faza 01 Plan 01: Ekstrakcja AllegroTokenManager

Skonsolidowano zduplikowaną logikę odświeżania tokenów OAuth Allegro z 4 klas do jednej: AllegroTokenManager.

Performance

Metryka Wartość
Czas ~30 min
Zadania 3/3 ukończone
Pliki zmodyfikowane 8
Pliki utworzone 1

Acceptance Criteria Results

Kryterium Status Uwagi
AC-1: AllegroTokenManager — resolveToken() Pass Klasa utworzona z logiką check-expiry + forceRefresh
AC-2: Brak prywatnych metod tokenowych w 4 klasach Pass grep zwrócił 0 wyników dla resolveAccessToken/forceRefreshToken/requireOAuthData
AC-3: Poprawne zależności konstruktorów Pass OrderImport/OrdersSync mają nadal repo; StatusDiscovery/Shipment zastąpiły repo+oauthClient przez tokenManager
AC-4: Wiring zaktualizowany w obu miejscach Pass routes/web.php i Application.php przekazują AllegroTokenManager
AC-5: Aplikacja uruchamia się bez błędów Pass php -l na wszystkich 7 plikach PHP — 0 błędów; użytkownik potwierdził działanie w przeglądarce

Accomplishments

  • Usunięto ~85 linii zduplikowanego kodu z 4 klas (3 metody × 4 klasy)
  • Jeden punkt naprawy w razie błędu w logice odświeżania tokenów
  • CONCERNS.md HIGH item #1 usunięty
  • ARCHITECTURE.md zaktualizowany

Files Created/Modified

Plik Zmiana Cel
src/Modules/Settings/AllegroTokenManager.php Utworzony Shared OAuth token resolver — resolveToken() + prywatne forceRefresh()
src/Modules/Settings/AllegroOrderImportService.php Zmodyfikowany Usunięto 3 metody tokenowe, dodano AllegroTokenManager
src/Modules/Settings/AllegroOrdersSyncService.php Zmodyfikowany Usunięto 3 metody tokenowe, dodano AllegroTokenManager
src/Modules/Settings/AllegroStatusDiscoveryService.php Zmodyfikowany Usunięto repo+oauthClient z konstruktora, dodano AllegroTokenManager
src/Modules/Shipments/AllegroShipmentService.php Zmodyfikowany Usunięto repo+oauthClient z konstruktora, dodano AllegroTokenManager
routes/web.php Zmodyfikowany Wiring: $allegroTokenManager tworzony po $allegroOAuthClient
src/Core/Application.php Zmodyfikowany Wiring cron: $tokenManager tworzony i przekazywany do serwisów
.paul/codebase/CONCERNS.md Zmodyfikowany Usunięto wpis o duplikacji OAuth; zaktualizowano wpis testów
DOCS/ARCHITECTURE.md Zmodyfikowany Dodano AllegroTokenManager do listy klas i opisu

Decisions Made

Decyzja Uzasadnienie Wpływ
401 retry zastąpiony przez tokenManager->resolveToken() (nie forceRefresh public) Plan zabraniał publicznej metody forceRefresh(); zakres: tylko strukturalna ekstrakcja Retry po 401 nie wymusza refreshu jeśli token wg daty jest ważny — marginalny edge case

Deviations from Plan

Brak odchyleń od planu.

Skill Audit

Oczekiwany Wywołany Uwagi
/feature-dev Użytkownik potwierdził przed implementacją
/code-review Przeprowadzony po uzupełnieniu luk — brak nowych bugów
sonar-scanner Uruchomiony — 4 nowe issues (S112 x3, S1142 x1) zlogowane w DOCS/todo.md

Next Phase Readiness

Gotowe:

  • AllegroTokenManager dostępny do wstrzyknięcia w każdym przyszłym serwisie Allegro
  • Wzorzec ekstrakcji shared service ustalony dla przyszłych faz

Obawy:

  • Logika tokenów nadal bez testów (CONCERNS.md HIGH item: "Allegro OAuth Token Refresh Logic Has No Tests")

Blokery: Brak


Phase: 01-tech-debt, Plan: 01 Completed: 2026-03-12