chore: reorganize backend folder structure — Phase 3 (REST API)#41126
chore: reorganize backend folder structure — Phase 3 (REST API)#41126sampaiodiego wants to merge 5 commits into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
b2c1f14 to
5ead36e
Compare
⏭️ Hacktron Security Check — SkippedReason: This PR exceeds Hacktron's 200-file review cap and will not be scanned. Split the PR into smaller changes for review coverage.
|
There was a problem hiding this comment.
2 issues found across 220 files
Note: This PR contains a large number of files. cubic only reviews up to 200 files per PR, so some files may not have been reviewed. cubic prioritizes the most important files to review.
Tip: cubic used a learning from your PR history. Let your coding agent read cubic learnings directly with the cubic MCP.
Re-trigger cubic
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #41126 +/- ##
===========================================
+ Coverage 69.14% 69.16% +0.02%
===========================================
Files 3433 3535 +102
Lines 132323 138107 +5784
Branches 23091 24542 +1451
===========================================
+ Hits 91489 95527 +4038
- Misses 37472 38558 +1086
- Partials 3362 4022 +660
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
…API) Move the community REST API framework and all REST endpoints from `app/api/server/` into `server/api/`, extending the responsibility-based structure: - framework files → `server/api/` (ApiClass, api, router, definition, …) - `ajv.ts` → `server/api/validation/` - `helpers/` + `lib/` merged → `server/api/lib/` - `v1/` → `server/api/v1/`, `middlewares/` → `server/api/v1/middlewares/` - all livechat community REST → `server/api/v1/omnichannel/` (flat). Both former source dirs (`livechat/server/api/v1/` and the older `livechat/imports/server/rest/`) land here; the single filename collision (`agent.ts`) is resolved by renaming the imports/rest one to `agentDepartments.ts` (it only registers `livechat/agents/:agentId/departments`). The two registration aggregators are folded into `server/api/v1/omnichannel/index.ts` and the `app/livechat/server` API files are removed entirely. Migration-script hardening (mandatory per the plan): add the license-boundary guard to move-module.mjs and move-batch.mjs, single-file/index-aware external-import rewriting, and `tests/` to the import-scan dirs. Files move as-is; only import paths change. Verified with `yarn lint --quiet` and `tsc --noEmit`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…API) Mirror the Phase 3 REST API restructure inside `ee/`, staying entirely under the Enterprise license boundary (no file leaves `ee/`): - `ee/app/livechat-enterprise/server/api/` → `ee/server/api/v1/omnichannel/` (endpoints + `lib/` + relocated index aggregator) - `ee/app/api-enterprise/server/` → `ee/server/api/` (canned-responses endpoint → `v1/`, `lib/` → `api/lib/`, `middlewares/` → `v1/middlewares/`) - fold the `api-enterprise` index aggregator into `ee/server/index.ts` and delete it; repoint `livechat-enterprise/server/index.ts` at the new omnichannel aggregator. Files move as-is; only import paths change. Verified with `yarn lint --quiet` and `tsc --noEmit`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Phase-3 moved app/api/server/** into server/api/**, which silently broke test string-literals that lint and tsc cannot see: - proxyquire/jest.mock keys are matched literally against the loaded module's import specifiers; after the move they no longer matched, so the real modules loaded (crashing the mocha run via meteor/* or returning undefined and failing assertions). - Jest testMatch and .mocharc.js spec globs pointed at old dirs, so moved specs stopped being discovered (getUserInfo.spec.ts was orphaned). Fixes: - FileUpload.spec.ts, eraseTeam.spec.ts, getServerInfo.spec.ts, getUserInfo.spec.ts, checkPermissions.spec.ts, checkPermissionsForInvocation.spec.ts — rewrite stale mock keys to the moved modules' new specifiers. - jest.config.ts / .mocharc.js — re-wire discovery globs for the moved specs, keeping jest and mocha specs in separate globs (ignore the Jest getUserInfo.spec.ts from the mocha server/api/lib glob). - MIGRATION_PLAN.md — document the proxyquire/jest.mock + runner-glob failure mode and the per-move fix procedure. yarn testunit now passes (jest: 1818 passed/8 skipped; mocha: 1954 passing/0 failing). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The guard checked `p.split('/').includes('ee')` on the raw relative
string, so a `..` segment could slip a boundary-crossing move past it:
`--to ee/../server/foo` contains the literal `ee` segment but resolves
into the community tree, so an `ee/app/foo -> ee/../server/foo` move was
allowed and would silently relicense the EE file.
Resolve and relativize against ROOT before splitting so `..` is
collapsed first. Addresses cubic review on PR 41126.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
4e3d83a to
66e2489
Compare
|
Caution These are security findings reported by the security scanners configured in Layne. Findings may contain false positives - review them and fix what makes sense. If you believe a finding is not valid, contact the security team. Layne found 4 high issues in this PR. View 4 finding(s)
|
Proposed changes
Phase 3 of the backend folder-structure migration: move the REST API framework and all REST endpoints into the responsibility-based
server/api/structure. Files move as-is — only import paths change, no refactoring.Folder structure
Community — before
Community — after
EE mirror — before / after (stays inside
ee/)Before
After
Two commits for reviewability:
1. Community (
app/api/server/→server/api/)server/api/(ApiClass,api,router,definition, …)ajv.ts→server/api/validation/helpers/+lib/merged →server/api/lib/v1/→server/api/v1/,middlewares/→server/api/v1/middlewares/server/api/v1/omnichannel/(flat). Both former source dirs (livechat/server/api/v1/and the olderlivechat/imports/server/rest/) land here. The single filename collision (agent.ts) is resolved by renaming the imports/rest one toagentDepartments.ts(it only registerslivechat/agents/:agentId/departments). The two registration aggregators are folded intoserver/api/v1/omnichannel/index.ts, and theapp/livechat/serverAPI files are removed entirely.2. EE mirror (within
ee/, license boundary preserved — no file leavesee/)ee/app/livechat-enterprise/server/api/→ee/server/api/v1/omnichannel/ee/app/api-enterprise/server/→ee/server/api/(endpoint →v1/,lib/→api/lib/,middlewares/→v1/middlewares/)api-enterpriseindex aggregator folded intoee/server/index.tsand deletedMigration-script hardening (mandatory per plan)
move-module.mjs+move-batch.mjs(refuses any move crossing theee/boundary)git mvimport updates)tests/to the import-scan dirs (caught bytsc, missed by lint)Verification
yarn lint --quiet— clean (0 unresolved imports)tsc --noEmit --skipLibCheck— 0 errorsverify-no-old-imports.mjs— 0 stragglers for every Phase 3 pathNote
Not run here (need a running server/DB): the REST API integration suite and manual endpoint smoke tests.
Commit-split caveat: the community move repoints the EE files it later relocates, so those import edits ride in commit 2 — the branch tip is fully green, but commit 1 alone isn't independently buildable for a few leaf EE API files.
🤖 Generated with Claude Code