feat: replace in-memory PrismaService fake with real PrismaClient (#475) - #537
Conversation
…E-ORG#475) - Rewrite PrismaService to extend PrismaClient with @prisma/adapter-pg - Remove all 13 Map-based in-memory stores (1532 -> 420 lines) - reset() now executes TRUNCATE TABLE ... CASCADE - Add Postgres 16 service to CI workflow - Fix BuyerDisputeService to explicitly transition escrow to DISPUTED - Fix vendor-analytics integration test (remove direct store access) - Update 4 test files for real PrismaClient API
|
@mayborn005 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Bring the real-PrismaClient PR up to date with base dev (~40 commits). Conflict resolutions: - src/prisma/prisma.service.ts: keep the PR's real PrismaClient (drop the in-memory fake). - test/unit/prisma.service.spec.ts, src/prisma/escrow-event-logging.spec.ts: keep the PR's real-DB-oriented tests. Upstream's added assertions targeted fake-only behaviour (sync throw on plaintext contact, auto-DISPUTED side effects, notifications without a parent escrow, no-arg effectiveDatabaseUrl undefined) and do not hold against a real PrismaClient. - .github/workflows/ci.yml: accept upstream's deletion (its coverage/typecheck work was consolidated into test.yml in JSE-ORG#525). Note: this merge is textually clean but not yet green. The fake->real swap surfaces ~151 type errors in code the base added against the fake's loose types (Decimal/JsonValue/enums/required itemRef), and @prisma/adapter-pg + pg still need to be added to package.json. Those are follow-up commits. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HzXa5DbrJ4CsnYs4Sx4qiK
Reconcile the fake->real PrismaClient swap with ~40 commits of base code
that was written against the in-memory fake's loose types.
- Declare the previously-undeclared driver-adapter deps so `npm ci` installs
them: @prisma/adapter-pg, pg (deps) and @types/pg (devDep).
- prisma.service.ts: enable query-event logging via constructor `log` option
and narrow $on('query') to Prisma.QueryEvent; drop dead input types; add
boundary mappers (toEscrowRecord/toFailedTransactionRecord/
toVendorAccountDetailsRecord/toVendorTrackingSettingsRecord) that convert
generated rows (Decimal, JsonValue) to the hand-written *Record contract
(number, plain objects) the rest of the app and its tests depend on.
- escrow / dlq / vendor repositories: convert rows through the mappers;
write JSON columns via Prisma.DbNull / InputJsonValue.
- admin-stats: Number() the Decimal _sum.amount aggregate.
- analytics: type $queryRaw result as an array.
- schema: add Notification.providerMessageId / attemptCount / lastResponseCode
(persisted by NotificationsService; previously only in the fake) + migration.
Production `tsc --noEmit` is clean. Remaining type errors are confined to
test/spec files and the benchmark script (follow-up commit).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HzXa5DbrJ4CsnYs4Sx4qiK
…pecs Make `npm run typecheck` (tsc --noEmit) fully green after the fake->real PrismaClient migration. Type-only test changes plus repair of pre-existing bad-merge corruption inherited from base dev. - Add required `itemRef` to escrow creates; annotate `state: '...' as const` where widening broke EscrowRecord/EscrowSummaryDto assignability (escrow/dispute/admin-stats/analytics/cross-vendor/tracking-poll specs). - Add missing fields to VendorTrackingSettingsRecord mocks; cast the DLQ ABANDONED record; pass the new DlqService arg to SorobanPollerService; use Prisma.DbNull for null JSON columns. - prisma.service.spec.ts: drop the invalid `@jest/globals` Test import, remove unused e1..e4 bindings, Prisma.DbNull for ledgerFeedback. - Remove duplicated halves left by earlier bad merges in tracing.interceptor.spec, tracing.middleware.spec, and notification-retry-queue.service.spec. - config.module.spec.ts: repair the corrupted abortEarly block, the three missing sync-test `});`, the duplicate Keypair import, and restore the dropped ALL_KNOWN_KEYS definition. - benchmark script: array-typed $queryRaw, itemRef on seed escrows. No assertions or test intent changed. Note: the repo-wide `lint:check` job was already red on base dev (pre-existing prettier/require/console violations in untouched files); the files changed here are formatted clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HzXa5DbrJ4CsnYs4Sx4qiK
|
@Omoboi-dev please review and merge PR |
- bind this for Prisma query-event logger (v7 Proxy unbound methods) - single-statement TRUNCATE with advisory lock to avoid reset deadlocks - seed vendor profiles in tests/seed for escrow FK constraints - use DisputeStatus enum in admin stats query - validate ADMIN_ADDRESS with stellarPublicKey schema - pass encryption key config to LogisticsService constructor
|
Hi @Omoboi-dev 👋 Just a heads-up: I've pushed an update to this branch (head However, the 6 CI workflow runs (Test, Lint, E2E, Integration, Docker Build, DB Migrations) are currently waiting for your approval — GitHub's fork-PR gate keeps them at action_required. Could you approve the runs so we can confirm green, and then review/merge? This resolves #475. Thanks! 🙏 |
|
Hello @mayborn005 will review your pr and merge accordingly. |
closes PrismaService is an in-memory fake; replace it with a real PrismaClient #475
What
Why
Closes #
How
Checklist
npm run validatepasses locally (typecheck, lint, test)anytypes introducedfix(escrow): correct auto release eligibility queryNotes for the reviewer