Skip to content

refactor: adminjourneys modern#8755

Open
mikeallisonJS wants to merge 11 commits intomainfrom
00-00-MA-refactor-adminjourneys-modern
Open

refactor: adminjourneys modern#8755
mikeallisonJS wants to merge 11 commits intomainfrom
00-00-MA-refactor-adminjourneys-modern

Conversation

@mikeallisonJS
Copy link
Collaborator

@mikeallisonJS mikeallisonJS commented Feb 19, 2026

Summary by CodeRabbit

  • New Features

    • Modern API exposes adminJourneys (status/template/team filters) and getJourneyProfile for authenticated users.
  • Chores

    • Migrated adminJourneys and getJourneyProfile from the legacy API to the modern API; legacy endpoints removed.
  • Bug Fixes / API Changes

    • Removed JourneyProfile update fields lastActiveTeamId and journeyFlowBackButtonClicked.
  • Tests

    • Added test suites covering adminJourneys and getJourneyProfile behaviors.

- Added `adminJourneys` query to fetch journeys based on user roles and filters.
- Implemented `getJourneyProfile` query to retrieve user-specific journey profiles.
- Created corresponding test files for both queries to ensure functionality and access control.
- Updated journey schema index to include new queries.
- Removed deprecated `adminJourneys` and `getJourneyProfile` queries from the legacy schema.
- Updated the modern schema to include refined `adminJourneys` and `getJourneyProfile` queries with improved access control.
- Adjusted resolver logic to enhance filtering and user role checks for journey access.
- Cleaned up related test cases to reflect the changes in query structure and functionality.
@mikeallisonJS mikeallisonJS self-assigned this Feb 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Relocates two public GraphQL query fields—adminJourneys and getJourneyProfile—from the legacy api-journeys API to the api-journeys-modern API; legacy schema and resolver exposures removed, and equivalent schema entries, resolvers, and tests added in the modern API.

Changes

Cohort / File(s) Summary
Gateway & Schemas
apis/api-gateway/schema.graphql, apis/api-journeys-modern/schema.graphql, apis/api-journeys/schema.graphql
Moved adminJourneys and getJourneyProfile query fields from API_JOURNEYS to API_JOURNEYS_MODERN in gateway and per-API schema files.
adminJourneys — Modern API
apis/api-journeys-modern/src/schema/journey/adminJourneys.query.ts, apis/api-journeys-modern/src/schema/journey/adminJourneys.query.spec.ts, apis/api-journeys-modern/src/schema/journey/index.ts
Added adminJourneys query implementation with auth, ACL/filter construction, Prisma query execution, and comprehensive tests covering auth, filters, and error paths.
getJourneyProfile — Modern API
apis/api-journeys-modern/src/schema/journeyProfile/getJourneyProfile.query.ts, apis/api-journeys-modern/src/schema/journeyProfile/getJourneyProfile.query.spec.ts, apis/api-journeys-modern/src/schema/journeyProfile/index.ts
Added authenticated getJourneyProfile query implementation and tests for found/null/unauthorized scenarios.
Legacy API removals
apis/api-journeys/src/app/modules/journey/journey.graphql, apis/api-journeys/src/app/modules/journey/journey.resolver.ts, apis/api-journeys/src/app/modules/journey/journey.resolver.spec.ts, apis/api-journeys/src/app/modules/journeyProfile/journeyProfile.graphql, apis/api-journeys/src/app/modules/journeyProfile/journeyProfile.resolver.ts
Removed legacy adminJourneys and getJourneyProfile exposures, removed related tests/imports, and dropped two fields from JourneyProfileUpdateInput.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ModernAPI as Modern API (GraphQL)
    participant Auth as Auth Service
    participant Profile as JourneyProfile (Prisma)
    participant Journeys as Journeys (Prisma)

    Client->>ModernAPI: adminJourneys(status, template, teamId, useLastActiveTeamId)
    ModernAPI->>Auth: validate token / get userId
    Auth-->>ModernAPI: userId
    alt useLastActiveTeamId == true
        ModernAPI->>Profile: findUnique(where: { userId })
        Profile-->>ModernAPI: journeyProfile (or null)
    end
    ModernAPI->>Journeys: findMany(where: ACL ∧ filters)
    Journeys-->>ModernAPI: [Journey]
    ModernAPI-->>Client: [Journey]
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • csiyang
  • tanflem
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: relocating adminJourneys and getJourneyProfile fields from the legacy API to the modern graph.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 00-00-MA-refactor-adminjourneys-modern

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

Warnings
⚠️ ❗ Big PR (695 changes)

(change count - 695): Pull Request size seems relatively large. If Pull Request contains multiple changes, split each into separate PR will helps faster, easier review.

Generated by 🚫 dangerJS against eb0116d

@nx-cloud
Copy link

nx-cloud bot commented Feb 19, 2026

View your CI Pipeline Execution ↗ for commit eb0116d

Command Status Duration Result
nx run journeys-e2e:e2e ✅ Succeeded 21s View ↗
nx run journeys-admin-e2e:e2e ✅ Succeeded 31s View ↗
nx run watch-e2e:e2e ✅ Succeeded 35s View ↗
nx run resources-e2e:e2e ✅ Succeeded 27s View ↗
nx run short-links-e2e:e2e ✅ Succeeded 11s View ↗
nx run player-e2e:e2e ✅ Succeeded 4s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 6s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
Additional runs (20) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-02-26 22:26:17 UTC

@github-actions github-actions bot temporarily deployed to Preview - journeys February 19, 2026 00:03 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 19, 2026 00:03 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 19, 2026 00:03 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 19, 2026 00:03 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 19, 2026 00:04 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
short-links ✅ Ready short-links preview Fri Feb 27 11:13:23 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Fri Feb 27 11:13:15 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Fri Feb 27 11:16:33 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Fri Feb 27 11:20:18 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Fri Feb 27 11:13:30 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Fri Feb 27 11:13:44 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Fri Feb 27 11:13:33 NZDT 2026

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (3)
apis/api-journeys-modern/src/schema/journeyProfile/getJourneyProfile.query.spec.ts (1)

15-24: Add an explicit type for the mockUser fixture.

The test fixture includes a roles property not present in the standard User interface from @core/yoga/firebaseClient, so a local type keeps the fixture type-safe and prevents drift.

Suggested refactor
+type MockUser = {
+  id: string
+  email: string
+  emailVerified: boolean
+  firstName: string
+  lastName: string
+  imageUrl: string | null
+  roles: string[]
+}
+
-  const mockUser = {
+  const mockUser: MockUser = {
     id: 'userId',
     email: 'test@example.com',
     emailVerified: true,
     firstName: 'Test',
     lastName: 'User',
     imageUrl: null,
     roles: []
   }

Per coding guidelines: **/*.{ts,tsx}: Define a type if possible.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apis/api-journeys-modern/src/schema/journeyProfile/getJourneyProfile.query.spec.ts`
around lines 15 - 24, The test fixture mockUser in the getJourneyProfile suite
lacks an explicit type and includes a roles property not present on the standard
User type; define a local interface or type alias (e.g., MockUser or TestUser)
that describes the exact shape used in the test (including id, email,
emailVerified, firstName, lastName, imageUrl, and roles) and annotate the
mockUser constant with that type so the fixture is type-safe and cannot drift
from expected fields; update the mockUser declaration in the
describe('getJourneyProfile') block to use that new type.
apis/api-journeys-modern/src/schema/journey/adminJourneys.query.ts (2)

114-119: No pagination on findMany — unbounded result set.

If a user has access to a large number of journeys (e.g., a team manager of a prolific team), this query returns all of them in a single response. If this matches the original api-journeys behavior, it's fine for this migration PR, but worth adding pagination (take/cursor) as a follow-up to protect against performance degradation at scale.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apis/api-journeys-modern/src/schema/journey/adminJourneys.query.ts` around
lines 114 - 119, The prisma.journey.findMany call currently returns an unbounded
result set (using accessibleJourneys and filter merged into where), so add
pagination parameters (e.g., accept and pass through take/skip or cursor-based
args) to limit results and support cursor paging; modify the call site that
builds query (the object referenced by query) or the findMany invocation to
include take and cursor (and a stable orderBy, e.g., id or createdAt) so callers
can request paged slices and the server enforces a sane default limit when none
provided.

64-111: Consider consolidating duplicate ACL branches.

The team manager/member and journey owner/editor conditions differ only by role and could each be merged using in:

♻️ Suggested consolidation
       const accessibleJourneys: Prisma.JourneyWhereInput = {
         OR: [
-          // user is a team manager
+          // user is a team manager or member
           {
             team: {
               userTeams: {
                 some: {
                   userId,
-                  role: UserTeamRole.manager
-                }
-              }
-            }
-          },
-          // user is a team member
-          {
-            team: {
-              userTeams: {
-                some: {
-                  userId,
-                  role: UserTeamRole.member
+                  role: { in: [UserTeamRole.manager, UserTeamRole.member] }
                 }
               }
             }
           },
-          // user is a journey owner
+          // user is a journey owner or editor
           {
             userJourneys: {
               some: {
                 userId,
-                role: UserJourneyRole.owner
-              }
-            }
-          },
-          // user is a journey editor
-          {
-            userJourneys: {
-              some: {
-                userId,
-                role: UserJourneyRole.editor
+                role: { in: [UserJourneyRole.owner, UserJourneyRole.editor] }
               }
             }
           },

That said, if this mirrors the original api-journeys implementation for migration fidelity, keeping it as-is is fine. Based on learnings, the migration to api-journeys-modern should preserve the same structure as the original api-journeys implementation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apis/api-journeys-modern/src/schema/journey/adminJourneys.query.ts` around
lines 64 - 111, The ACL query in accessibleJourneys duplicates nearly identical
branches for team roles and journey roles; consolidate them by replacing the
separate manager/member branches with a single team.userTeams.some condition
using role: { in: [...] } for UserTeamRole and likewise merge the userJourneys
owner/editor branches into one using role: { in: [...] } for UserJourneyRole,
keeping the rest of the Prisma.JourneyWhereInput structure (including the
published template branch with PrismaJourneyStatus.published) intact so the
logic and symbols accessibleJourneys, UserTeamRole, UserJourneyRole remain
unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apis/api-journeys-modern/src/schema/journey/adminJourneys.query.ts`:
- Around line 114-119: The prisma.journey.findMany call currently returns an
unbounded result set (using accessibleJourneys and filter merged into where), so
add pagination parameters (e.g., accept and pass through take/skip or
cursor-based args) to limit results and support cursor paging; modify the call
site that builds query (the object referenced by query) or the findMany
invocation to include take and cursor (and a stable orderBy, e.g., id or
createdAt) so callers can request paged slices and the server enforces a sane
default limit when none provided.
- Around line 64-111: The ACL query in accessibleJourneys duplicates nearly
identical branches for team roles and journey roles; consolidate them by
replacing the separate manager/member branches with a single team.userTeams.some
condition using role: { in: [...] } for UserTeamRole and likewise merge the
userJourneys owner/editor branches into one using role: { in: [...] } for
UserJourneyRole, keeping the rest of the Prisma.JourneyWhereInput structure
(including the published template branch with PrismaJourneyStatus.published)
intact so the logic and symbols accessibleJourneys, UserTeamRole,
UserJourneyRole remain unchanged.

In
`@apis/api-journeys-modern/src/schema/journeyProfile/getJourneyProfile.query.spec.ts`:
- Around line 15-24: The test fixture mockUser in the getJourneyProfile suite
lacks an explicit type and includes a roles property not present on the standard
User type; define a local interface or type alias (e.g., MockUser or TestUser)
that describes the exact shape used in the test (including id, email,
emailVerified, firstName, lastName, imageUrl, and roles) and annotate the
mockUser constant with that type so the fixture is type-safe and cannot drift
from expected fields; update the mockUser declaration in the
describe('getJourneyProfile') block to use that new type.

- Added `ExecutionResult` type to the admin journeys query tests for better type safety.
- Removed the mock for anonymous user as it was not utilized in the tests.
- Updated test cases to ensure consistent handling of query results and improved readability.
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 19, 2026 00:16 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 19, 2026 00:16 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 19, 2026 00:16 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 19, 2026 00:16 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 19, 2026 00:16 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 19, 2026 02:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 19, 2026 02:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 19, 2026 02:44 Inactive
@jianwei1 jianwei1 removed the on stage label Feb 19, 2026
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 20, 2026 22:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 20, 2026 22:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 20, 2026 22:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 20, 2026 22:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 20, 2026 22:44 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 26, 2026 22:04 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 26, 2026 22:04 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 26, 2026 22:04 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 26, 2026 22:04 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 26, 2026 22:04 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links February 26, 2026 22:11 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources February 26, 2026 22:11 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin February 26, 2026 22:11 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin February 26, 2026 22:11 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys February 26, 2026 22:11 Inactive
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.

3 participants