Skip to content

chore(api): migrate sessions (device management) endpoints to typed HTTP methods - #41397

Draft
devin-ai-integration[bot] wants to merge 2 commits into
developfrom
devin/1784133851-api-endpoint-migration-batch5
Draft

chore(api): migrate sessions (device management) endpoints to typed HTTP methods#41397
devin-ai-integration[bot] wants to merge 2 commits into
developfrom
devin/1784133851-api-endpoint-migration-batch5

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Proposed changes (including videos or screenshots)

Continues the REST API endpoint migration (batch 5), converting the device-management sessions/* endpoints from API.v1.addRoute() to the typed HTTP-method style (API.v1.get/API.v1.post) with elaborate response schemas.

Migrated routes in apps/meteor/ee/server/api/sessions.ts:

  • sessions/list (GET)
  • sessions/info (GET)
  • sessions/logout.me (POST)
  • sessions/list.all (GET)
  • sessions/info.admin (GET)
  • sessions/logout (POST)

Key changes:

  • Request validators moved to the proper option: query for GET (isSessionsPaginateProps/isSessionsProps), body for POST (isSessionsProps).
  • Response validators added for 200 plus the relevant error statuses (400/401/403, and 404 where the route can return "Session not found").
  • Elaborate response schemas instead of weak { type: 'object' }:
    • Registered DeviceManagementSession and DeviceManagementPopulatedSession in the core-typings typia registry (packages/core-typings/src/Ajv.ts) and reference them via $ref (the populated variant references ISessionDevice/IUser sub-schemas).
    • sessions/list / sessions/list.all: PaginatedResult<{ sessions: … }> with count/offset/total.
    • sessions/info / sessions/info.admin: allOf of the entity $ref plus { success: true }. allOf (rather than additionalProperties: false) preserves the existing behavior of returning the full session document.
    • sessions/logout(.me): { sessionId }.
  • Preserved existing licensing (license: ['device-management'] + License.hasModule guard), 2FA, permission, and error semantics. Handlers are unchanged aside from being standalone async function action().
  • Existing manual Endpoints declarations are preserved; no duplicate declarations added.

Excludes endpoints already migrated in #41356.

Issue(s)

N/A — part of the ongoing API endpoint migration.

Steps to test or reproduce

  • yarn workspace @rocket.chat/core-typings run build
  • npx eslint apps/meteor/ee/server/api/sessions.ts packages/core-typings/src/Ajv.ts
  • npx tsc --noEmit --skipLibCheck (no errors in changed files)
  • API e2e: apps/meteor/tests/end-to-end/api/method.roomNameExists.ts / device-management suites

Further comments

Local TypeScript + ESLint pass. sessions/info narrows the model's ISession result to DeviceManagementSession so the SuccessResult types line up; runtime behavior (returning the full document) is unchanged and validated by the allOf schema.

Link to Devin session: https://app.devin.ai/sessions/daf03dc59cb54e958e31a9e9c72fb162

Review in cubic

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@dionisio-bot

dionisio-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Jul 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 334b977

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


guilherme.gazzo seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

… optional to match runtime

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.59%. Comparing base (012dd32) to head (334b977).
⚠️ Report is 56 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #41397      +/-   ##
===========================================
+ Coverage    68.38%   68.59%   +0.20%     
===========================================
  Files         3970     4134     +164     
  Lines       154935   160802    +5867     
  Branches     27807    29435    +1628     
===========================================
+ Hits        105960   110310    +4350     
- Misses       44232    45386    +1154     
- Partials      4743     5106     +363     
Flag Coverage Δ
e2e 58.85% <ø> (-0.41%) ⬇️
e2e-api 45.34% <ø> (+1.30%) ⬆️
unit 70.56% <ø> (+0.27%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant