Skip to content

Refactor Phase 5: Infra, Map service and Improve test coverage - #58

Merged
1mimhe merged 9 commits into
masterfrom
refactor/phase-5
Oct 4, 2026
Merged

1mimhe merged 9 commits into
masterfrom
refactor/phase-5

Conversation

@1mimhe

@1mimhe 1mimhe commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

No description provided.

1mimhe added 9 commits October 4, 2026 17:49
…rvice

- src/infra/ports/: StoragePort/SmsPort/MapsPort (plain interfaces) +
  PORTS.* tokens, bound in S3Module/SmsModule/MapModule
- S3StorageAdapter/NeshanMapsAdapter/SmsAdapter moved verbatim (same URLs,
  headers, payloads, thrown messages; console.* -> Logger). Deviation:
  SMS requests retry once on network/5xx, then throw the legacy message.
  CodeGeneratorPort skipped (codes.ts already pure/tested).
- Deleted s3.service.ts + sms.service.ts; migrated all importers
  (s3.controller, vehicle, dashboard, package app/tracking, trip-request,
  user interim port, otp) to the tokens; dropped dead PrismaModule import
  from S3Module. MapService is now orchestration over MapsPort +
  CityRepository (no PrismaService, no Neshan HTTP).
- Docs note: BREAKING-CHANGES 4.1 (tracking phone masked +98LAST3) is
  applied in master via #57 — the pending entry predates the merge.

Verification: tsc clean, affected 28 suites / 256 tests green, scoped
eslint 0 errors. No API-visible change (SMS retry is timing-only).
- map/route-filters.ts: extractSignificantPoints + haversineDistance moved
  verbatim as exported pure helpers (threshold constant named); specs cover
  origin inclusion, وارد/priority/long-distance selection, min-distance
  dedup (first candidate passes: lastPoint starts undefined — locked),
  multi-leg accumulation, haversine zero/1-degree/symmetry
- MapService keeps orchestration (intermediate-cities flow, delay) and
  delegates calculateDistance/reverseGeocode/getDirections to MapsPort;
  typed unknown-catch handling removes no-unsafe-* warnings on touched
  paths (2 intentional no-console warnings remain in orchestration)

Verification: tsc clean, map 3 suites / 14 tests green, scoped eslint
0 errors. No API-visible change.
- domain/wallet.service.ts: getWallet (tx-aware) + addFunds via
  TransactionRunner; BigInt serialized only via common/utils/money.ts
  formatMoney (tested: zero/negative/large/null)
- domain/escrow.service.ts: createEscrow/releaseEscrow/
  addFundsAndCreateEscrow; release joins the caller tx (fatal, as before),
  creation stays non-fatal at the trip call-site
- financial.service.ts is now a thin facade (same 5 methods) so the
  controller and trip/package importers are untouched
- Preserved quirks (documented, not fixed): Int/BigInt column mismatch,
  number-domain commission math, totalSpent never incremented,
  non-atomic addFundsAndCreateEscrow, raw Error on missing platform
  wallet (correctly 500s via the filter)

Verification: tsc clean, financial 5 suites / 23 tests green, scoped
eslint 0 errors. No API-visible change.
…vehicle + S3 size limit

- user: drop formatPrismaError wrappers; fix licenseNumber branch writing
  licenseStatus (was nationalIdStatus twice — spec names already expected
  the fix); old error-mapping tests now assert raw propagation
- notification: getAll via TransactionRunner (reads through tx),
  unreadCount query + GET /notification/unread-count route
- support: runner + tx-through getTransporter; updateTransporter-
  Verification throws 404 on missing verificationStatusId (was 500) —
  BREAKING 5.1; new NotFoundMessages.VerificationStatus
- address: runner + CityRepository, tx-through create (was root client);
  dashboard: drop filter wrapper (outputs byte-identical, locked by new
  transporter/sender/admin specs); vehicle: runner + Logger (was console)
- S3: MAX_UPLOAD_SIZE_MB env (default 10) + optional declared `size` on
  all 7 presign endpoints, 400 over the limit — BREAKING 5.2; new
  s3.controller.spec; S3Service->port migration is internal only (5.3)
- controllers: route-level delegation specs for financial/user/vehicle/
  address/support/dashboard/notification/map

Verification: tsc clean, 73 suites / 579 tests green, scoped eslint
0 errors. API-visible: 5.1, 5.2 (5.3 internal).
…e txts

tslib + importHelpers for helper dedup; jest collectCoverageFrom now excludes sibling *.dto.ts and *.d.ts (DTO decorator branches aren't logic); coverage-*.txt ignored. tsc 0.
…t routing

S3 get custom expiry, SmsAdapter sendOtp 4xx no-retry, MapsAdapter calculateDistance with explicit vehicle/trip/waypoints. 28 tests green, scoped eslint 0 errors.
… specs

Last console.* in phase scope replaced with injected Logger (B-4); intermediate-cities branch specs (coords delegation, empty legs, dedupe, non-Error rejections). Map specs green.
Logger instance for Phase 5 Task 3 compliance (no log sites — global filter owns errors); default-pagination spec covers page/limit defaults. Notification specs green.
…icle

Delegation specs for update routes, non-highlighted search, null-sum escrow, wallet-null platform guard, default-vs-tx reads, presign key matrix + size-limit 400, S3 presigned-URL failure blanks, new s3.dto.spec (filename/size validation; fixes no-unnecessary-type-assertion). Full suite: 74 suites / 611 tests green, tsc 0.
@1mimhe
1mimhe merged commit cf0efa9 into master Oct 4, 2026
1 check passed
@1mimhe
1mimhe deleted the refactor/phase-5 branch October 4, 2026 20:46
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.

1 participant