Resolves issue #1714 , Refactoring reports_to for dynamic calculation and securing oversees updates.#1723
Closed
david-rocca wants to merge 2 commits intov2.8.0_featurefrom
Closed
Resolves issue #1714 , Refactoring reports_to for dynamic calculation and securing oversees updates.#1723david-rocca wants to merge 2 commits intov2.8.0_featurefrom
david-rocca wants to merge 2 commits intov2.8.0_featurefrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes Issue #1714
Summary
This pull request refactors the organization hierarchy system by removing
reports_tofrom database persistence and dynamically calculating it on-the-fly when reading organization data. Direct API modification mapping has been restricted, ensuring onlyoverseesis edited and primarily by Secretariat roles. This eliminates manual synchronization efforts to keep parent-child relationships intact and locks down unauthorized assignment tracking.Important Changes
src/model/baseorg.jsreports_to: Stringfrom the db Mongoose Schema.src/middleware/schemas/BaseOrg.jsonreports_toUUID mapping requirements from the database-layer JSON Schema validation.schemas/registry-org/create-registry-org-request.jsonschemas/registry-org/update-registry-org-request.jsonreports_toexpectations from internal/external JSON specifications preventing incorrect swagger usages.src/controller/org.controller/org.middleware.jsreports_toout ofregistryOnlyqueries into theisNotAllowedrestrictions arrays across creations and updates, catching it pre-validation if supplied.src/controller/registry-org.controller/index.jssrc/controller/org.controller/index.jsbody(['reports_to']).not().exists().withMessage('reports_to must not be present')forcing strict HTTP 400 rejection across allregistryOrgandregistry/orgPUT and POST routes when attempting to directly supplyreports_to.src/controller/registry-org.controller/registry-org.middleware.jsreports_tomapping from memory queries during incoming POST/PUT evaluations.src/repositories/baseOrgRepository.jsgetOrgto dynamically run a manualBaseOrgModel.findOne({ oversees: result.UUID })lightweight fetch and inject it back asreports_togracefully on-the-fly.$lookuphook insidesetAggregateRegistryOrgObjquerying the same relationship matching algorithm into arrays alongside a$condthat injects the variable dynamically.test/integration-tests/registry-org/registryOrgCRUDTest.jsreports_tocleanly via Secretariat'soverseesedits.reports_to must not be presentvalidator failures when users directly target the parameter during creation/update testing phases.Testing
Steps to manually test updated functionality, if possible
overseesarray vector string.reports_tofield parses gracefully with the UUID of the overarching organization.reports_tointo your HTTP requests payload, and evaluate a quick 400 Bad Request error.Notes
.reports_to, they must now switch to configuring parent entities leveraging theoverseesvariable using Secretariat-level clearance.