-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TECH] Migrer l'api pour attacher une organisation fille dans src/org…
- Loading branch information
Showing
36 changed files
with
137 additions
and
92 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
2 changes: 1 addition & 1 deletion
2
api/lib/infrastructure/repositories/data-protection-officer-repository.js
This file contains 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
2 changes: 1 addition & 1 deletion
2
...ure/serializers/jsonapi/organizations-administration/organization-for-admin-serializer.js
This file contains 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
This file contains 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
This file contains 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
This file contains 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
14 changes: 14 additions & 0 deletions
14
api/src/organizational-entities/application/organization-controller.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { usecases } from '../domain/usecases/index.js'; | ||
|
||
const attachChildOrganization = async function (request, h) { | ||
const { childOrganizationId } = request.payload; | ||
const { organizationId: parentOrganizationId } = request.params; | ||
|
||
await usecases.attachChildOrganizationToOrganization({ childOrganizationId, parentOrganizationId }); | ||
|
||
return h.response().code(204); | ||
}; | ||
|
||
export const organizationController = { | ||
attachChildOrganization, | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Joi from 'joi'; | ||
|
||
import { securityPreHandlers } from '../../shared/application/security-pre-handlers.js'; | ||
import { identifiersType } from '../../shared/domain/types/identifiers-type.js'; | ||
import { organizationController } from './organization-controller.js'; | ||
|
||
const register = async function (server) { | ||
server.route([ | ||
{ | ||
method: 'POST', | ||
path: '/api/admin/organizations/{organizationId}/attach-child-organization', | ||
config: { | ||
pre: [ | ||
{ | ||
method: securityPreHandlers.checkAdminMemberHasRoleSuperAdmin, | ||
assign: 'hasAuthorizationToAccessAdminScope', | ||
}, | ||
], | ||
validate: { | ||
params: Joi.object({ | ||
organizationId: identifiersType.organizationId, | ||
}), | ||
payload: Joi.object({ | ||
childOrganizationId: identifiersType.organizationId, | ||
}), | ||
}, | ||
handler: organizationController.attachChildOrganization, | ||
tags: ['api', 'admin', 'organizational-entities', 'organizations'], | ||
notes: [ | ||
"- **Cette route est restreinte aux utilisateurs authentifiés ayant un rôle SUPER_ADMIN, METIER ou SUPPORT permettant un accès à l'application d'administration de Pix**\n" + | ||
"- Elle permet d'attacher une organisation mère à une organisation fille", | ||
], | ||
}, | ||
}, | ||
]); | ||
}; | ||
|
||
const name = 'organizational-entities-api'; | ||
const organizationalEntitiesRoutes = [{ register, name }]; | ||
|
||
export { organizationalEntitiesRoutes }; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { DomainError } from '../../../lib/domain/errors.js'; | ||
|
||
class UnableToAttachChildOrganizationToParentOrganizationError extends DomainError { | ||
constructor({ | ||
code = 'UNABLE_TO_ATTACH_CHILD_ORGANIZATION_TO_PARENT_ORGANIZATION', | ||
message = 'Unable to attach child organization to parent organization', | ||
meta, | ||
} = {}) { | ||
super(message); | ||
this.code = code; | ||
this.meta = meta; | ||
} | ||
} | ||
|
||
export { UnableToAttachChildOrganizationToParentOrganizationError }; |
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ns-administration/OrganizationForAdmin.js → ...ies/domain/models/OrganizationForAdmin.js
This file contains 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
File renamed without changes.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { dirname, join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { injectDependencies } from '../../../shared/infrastructure/utils/dependency-injection.js'; | ||
import { importNamedExportsFromDirectory } from '../../../shared/infrastructure/utils/import-named-exports-from-directory.js'; | ||
import * as organizationForAdminRepository from '../../infrastructure/repositories/organization-for-admin-repository.js'; | ||
|
||
const path = dirname(fileURLToPath(import.meta.url)); | ||
|
||
const dependencies = { | ||
organizationForAdminRepository, | ||
}; | ||
|
||
const usecasesWithoutInjectedDependencies = { | ||
...(await importNamedExportsFromDirectory({ path: join(path, './'), ignoredFileNames: ['index.js'] })), | ||
}; | ||
|
||
const usecases = injectDependencies(usecasesWithoutInjectedDependencies, dependencies); | ||
|
||
export { usecases }; |
12 changes: 6 additions & 6 deletions
12
...ries/organization-for-admin-repository.js → ...ries/organization-for-admin-repository.js
This file contains 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
4 changes: 2 additions & 2 deletions
4
api/tests/integration/domain/usecases/create-organization_test.js
This file contains 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
2 changes: 1 addition & 1 deletion
2
...n/domain/usecases/update-certification-center-data-protection-officer-information_test.js
This file contains 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
2 changes: 1 addition & 1 deletion
2
...tegration/domain/usecases/update-organization-data-protection-officer-information_test.js
This file contains 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
2 changes: 1 addition & 1 deletion
2
api/tests/integration/infrastructure/repositories/data-protection-officer-repository_test.js
This file contains 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
4 changes: 2 additions & 2 deletions
4
...ach-child-organization-route-post_test.js → ...ach-child-organization-route-post_test.js
This file contains 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
Oops, something went wrong.