fix: repair main build breakage (65 TS errors) + smoke-test verification#7
fix: repair main build breakage (65 TS errors) + smoke-test verification#7devin-ai-integration[bot] wants to merge 3 commits into
Conversation
…addy + db layers
- caddy-service.ts / caddy-router.ts: correct logger call arg order to
match project logger API (message, context) instead of pino-native
(obj, message)
- db-queries.ts: fix Drizzle column references to match the actual
schema (users.firstName/lastName/phoneNumber, farms.farmName,
harvests.userId/revenue, carbonCredits.tonnes, marketPrices date
comparisons, iot/pipeline/federated aggregations, carbonProjects.annualCredits)
- db-enhancements.ts: read QueryResult.rows for node-postgres driver;
fix logger arg order
- drizzle-enhancements.test.ts: mock db.execute to return { rows }
matching node-postgres shape
- vitest.config.ts + tests/mocks/dapr-stub.ts: alias @dapr/dapr to a
test-only stub so Vitest can load the suite (the real package ships an
ESM proto inside a CommonJS package); production imports unchanged
tsc: 0 errors; vitest: 1076 passed, 30 skipped; build: ok
Co-Authored-By: Patrick Munis <pmunis@gmail.com>
Original prompt from Patrick
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
The mobile job's single-line `run:` values contained `WARN: ` — an unquoted colon-space that YAML reads as a mapping key, so the whole ci-cd.yml failed to parse and every run errored at 0s (pre-existing on main). Single-quote the three affected run values. Co-Authored-By: Patrick Munis <pmunis@gmail.com>
…tion-readiness) The branch-protection gate declared needs: production-audit, but no job by that name exists (the job is production-readiness). GitHub rejects a workflow with a needs edge to a non-existent job, which is why the whole run errored at 0s with no jobs created. Co-Authored-By: Patrick Munis <pmunis@gmail.com>
Summary
After all feature branches were consolidated into
main, the merged tree did not compile —tsc --noEmitreported 65 errors andvitesthad 1 failing test. The Caddy edge-gateway commit and the Drizzle query/enhancement helpers were authored against assumptions that didn't hold once merged. This PR repairs that breakage somainis functional (compiles, builds, tests pass) and adds a smoke test proving the auth → DB round-trip works against real Postgres.Root causes & fixes
1. Logger arg order (caddy-service.ts, caddy-router.ts, db-enhancements.ts)
The project's logger wrapper is
logger.info(message, context), but these files used pino's nativelogger.info(obj, message). All call sites corrected:2. db-queries.ts referenced columns that don't exist in the schema (35 errors)
The query builders assumed a different schema. Mapped every reference to the real Drizzle columns, e.g.:
users.name/users.phone→users.firstName/users.lastName/users.phoneNumberfarms.name→farms.farmNameharvests.farmId/harvests.totalValue→harvests.userId/harvests.revenuecarbonCredits.quantity/pricePerTon→carbonCredits.tonnes/ projectpricePerTonneiotReadings.soilMoisture/...(columns don't exist — genericmetric/valuemodel) → conditionalCASE WHEN metric = '...' THEN valueaggregationspipelineMetrics.recordsWritten/throughputRps→CASE WHEN metricName = '...'overmetricValuefederatedParticipants.contributionScore/localDataSize→localAccuracy/dataPointscarbonProjects.annualSequestration→annualCreditsmarketPrices/harveststimestamp comparisons: passDateobjects instead of date strings3. db-enhancements.ts used array destructuring on a
QueryResult(node-postgres)getDb()usesdrizzle-orm/node-postgres, whosedb.execute()returns{ rows }, not an array:The corresponding unit-test mock was returning a bare array (wrong shape for this driver); updated it to return
{ rows: [...] }.4. Vitest could not load the suite (@dapr/dapr)
The real
@dapr/daprships an ESM proto file inside a CommonJS package, which Vitest's loader can't parse. Added a test-only alias invitest.config.ts→tests/mocks/dapr-stub.tsexposing the same surface used byserver/dapr-client.ts. Production imports the real package unchanged.Verification
npx tsc --noEmit→ 0 errorsnpx vitest run→ 1076 passed, 30 skipped, 0 failednpm run build→ buildsdist/index.js+ PWA (321 precache entries)auth.register→ row persisted (users.id=367) →auth.login→ JWT-protectedauth.mereturns the user; protected endpoints correctly return 401 without a token (middleware enforced)Notes
@dapr/daprstub is strictly a test-loader workaround — it does not establish production Dapr runtime behavior.phase118-integration.test.ts(require live external infra).Link to Devin session: https://app.devin.ai/sessions/87560355a8b7425392cbfab1aa9e89fa
Requested by: @munisp