Conversation
- Implemented GET /api/partners/applications to retrieve all pending applications for the authenticated workspace's default program. - Added OpenAPI specification for the new endpoint. - Updated Zod schemas to support pagination and application data formatting. - Included necessary imports and utility functions for data handling.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a workspace-scoped, plan-restricted GET endpoint to list pending partner applications with pagination; registers OpenAPI operation and response schema; updates Zod schemas and enum validation. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API as "Next.js API\n(route.ts)" rect rgba(100,149,237,0.5)
participant Workspace as "withWorkspace\n(auth/plan)" rect rgba(34,139,34,0.5)
participant Prisma as "Prisma DB" rect rgba(255,165,0,0.5)
participant Formatter as "Formatter\n(format/validate)" rect rgba(147,112,219,0.5)
Client->>API: GET /api/partners/applications?page=&pageSize=
API->>Workspace: validate workspace and plan, get programId
Workspace-->>API: workspace + programId
API->>Prisma: query programEnrollment (status: pending, application != null), include partner.platforms, pagination
Prisma-->>API: enrollments with application and partner
API->>Formatter: transform application fields, polyfill partner.platforms, attach status/groupId
Formatter-->>API: validated array (partnerApplicationSchema)
API-->>Client: 200 JSON response
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/web/lib/zod/schemas/program-application.ts (1)
50-54: Simplify by constructing the object directly from the pagination shape.
getPaginationQuerySchemaalready returns a shape record, so the empty-object-plus-extend is redundant. This also avoids the extraZodObject.extendwrapping:♻️ Proposed refactor
-export const getPartnerApplicationsQuerySchema = z.object({}).extend( - getPaginationQuerySchema({ - pageSize: PARTNERS_MAX_PAGE_SIZE, - }), -); +export const getPartnerApplicationsQuerySchema = z.object( + getPaginationQuerySchema({ pageSize: PARTNERS_MAX_PAGE_SIZE }), +);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/lib/zod/schemas/program-application.ts` around lines 50 - 54, Replace the redundant z.object({}).extend(...) pattern by building the schema directly from the pagination shape: call getPaginationQuerySchema({ pageSize: PARTNERS_MAX_PAGE_SIZE }) and pass its returned shape into z.object to create getPartnerApplicationsQuerySchema (referencing getPartnerApplicationsQuerySchema, getPaginationQuerySchema, and PARTNERS_MAX_PAGE_SIZE).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/app/`(ee)/api/partners/applications/route.ts:
- Line 59: The createdAt field for partner applications is taken from
programEnrollment (createdAt: programEnrollment.createdAt) which differs from
the webhook convention (application.createdAt) and causes inconsistent ordering;
update the listing code in route.ts to use application.createdAt for the
createdAt property and change the query/orderBy to order by
application.createdAt descending so it matches partnerApplicationWebhookSchema /
partnerApplicationSchema and the webhook handler
(apps/web/lib/partners/complete-program-applications.ts).
- Around line 44-71: The mapped "result" can contain nulls due to the `if
(!application) return null` branch inside `applications.map(...)`, which will
make `z.array(partnerApplicationSchema).parse(result)` throw; to fix, either
remove the unreachable null-return branch in the `applications.map` callback
(remove the `if (!application) ...` and assume `application` exists) or ensure
you filter out nulls before parsing (e.g., filter the `result` from
`applications.map` to remove null/undefined entries) so that the value passed to
`NextResponse.json(z.array(partnerApplicationSchema).parse(...))` contains only
valid partner application objects; update code paths that reference
`applications.map`, `formatApplicationFormData`, `polyfillSocialMediaFields`,
and the final `NextResponse.json(...)` call accordingly.
---
Nitpick comments:
In `@apps/web/lib/zod/schemas/program-application.ts`:
- Around line 50-54: Replace the redundant z.object({}).extend(...) pattern by
building the schema directly from the pagination shape: call
getPaginationQuerySchema({ pageSize: PARTNERS_MAX_PAGE_SIZE }) and pass its
returned shape into z.object to create getPartnerApplicationsQuerySchema
(referencing getPartnerApplicationsQuerySchema, getPaginationQuerySchema, and
PARTNERS_MAX_PAGE_SIZE).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 30c443e6-d320-40ee-8aee-7f878d600245
📒 Files selected for processing (5)
apps/web/app/(ee)/api/partners/applications/route.tsapps/web/lib/openapi/partners/index.tsapps/web/lib/openapi/partners/list-partner-applications.tsapps/web/lib/zod/schemas/program-application.tsapps/web/lib/zod/schemas/programs.ts
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
apps/web/app/(ee)/api/partners/applications/route.ts (1)
37-38:⚠️ Potential issue | 🟡 MinorOrder by the same timestamp returned to clients.
The response now exposes
application.createdAt, but pagination still sorts byprogramEnrollment.createdAt. If those timestamps diverge, pages are not ordered by the visible application submission time. Consider ordering by the application’screatedAtas well.Suggested direction
orderBy: { - createdAt: "desc", + application: { + createdAt: "desc", + }, },#!/bin/bash # Verify the route still sorts by enrollment.createdAt while returning application.createdAt. rg -n -C4 'orderBy:|createdAt: application' \ 'apps/web/app/(ee)/api/partners/applications/route.ts'🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/app/`(ee)/api/partners/applications/route.ts around lines 37 - 38, The pagination sort uses programEnrollment.createdAt but the response exposes application.createdAt, so update the query in route handler to order by the application's createdAt instead of programEnrollment.createdAt (or add a secondary orderBy on application.createdAt) so that the returned list is ordered by the same timestamp shown to clients; locate the query referencing orderBy and programEnrollment.createdAt in apps/web/app/(ee)/api/partners/applications/route.ts (the block constructing the DB query and the orderBy clause) and replace or augment it to use application.createdAt as the primary sort key.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/app/`(ee)/api/partners/applications/route.ts:
- Around line 16-41: The pagination schema lets non-integer numbers through,
causing Prisma take/skip to receive floats; update the Zod schema that defines
page and pageSize (the getPaginationQuerySchema used by
getPartnerApplicationsQuerySchema) to add .int() to both page and pageSize so
only integer values pass validation before hitting
prisma.programEnrollment.findMany (which uses take and skip).
---
Duplicate comments:
In `@apps/web/app/`(ee)/api/partners/applications/route.ts:
- Around line 37-38: The pagination sort uses programEnrollment.createdAt but
the response exposes application.createdAt, so update the query in route handler
to order by the application's createdAt instead of programEnrollment.createdAt
(or add a secondary orderBy on application.createdAt) so that the returned list
is ordered by the same timestamp shown to clients; locate the query referencing
orderBy and programEnrollment.createdAt in
apps/web/app/(ee)/api/partners/applications/route.ts (the block constructing the
DB query and the orderBy clause) and replace or augment it to use
application.createdAt as the primary sort key.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d9978d6f-7de5-4765-9645-f7cc9bec78c9
📒 Files selected for processing (1)
apps/web/app/(ee)/api/partners/applications/route.ts
Summary by CodeRabbit
New Features
Documentation / Validation