-
Notifications
You must be signed in to change notification settings - Fork 728
feat: add public v1 endpoints (CM-967) #3864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+2,528
−997
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5fe3b63
feat: add public API foundation and members v1 endpoints (CM-967)
skwowet a41c11b
feat: add new endpoints (wip)
skwowet 4a1e8c2
feat: add remaining public APIs and refactor member unmerge flow
skwowet a1b3652
refactor: streamline member unmerge logic
skwowet 323a09e
fix: prettier and linter
skwowet 20650f4
fix: lint
joanagmaia 12fc017
fix: actions errors
joanagmaia f7b1945
fix: lint
joanagmaia 8e76e22
fix: lint issues
joanagmaia c668f64
Merge remote-tracking branch 'origin/main' into feat/CM-967
joanagmaia 8d58023
fix: memberOrganization update
joanagmaia 6d12f8f
fix: address PR comments
joanagmaia 768571f
fix: lint
joanagmaia 875caae
chore: add slack alert to verifyMemberIdentity
joanagmaia fa8b1df
fix: createMemberWorkExperience conflict scenario
joanagmaia 9a890b0
fix: issues in unmerge and update work experience endpoints
joanagmaia 8bca20d
fix: validator
joanagmaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,27 @@ | ||
| import { CommonMemberService } from '@crowd/common_services' | ||
| import { CommonMemberService, invalidateMemberQueryCache } from '@crowd/common_services' | ||
| import { optionsQx } from '@crowd/data-access-layer' | ||
|
|
||
| import MemberService from '@/services/memberService' | ||
|
|
||
| import Permissions from '../../security/permissions' | ||
| import track from '../../segment/track' | ||
| import PermissionChecker from '../../services/user/permissionChecker' | ||
|
|
||
| export default async (req, res) => { | ||
| new PermissionChecker(req).validateHas(Permissions.values.memberEdit) | ||
|
|
||
| const commonMemberService = new CommonMemberService(optionsQx(req), req.temporal, req.log) | ||
| const memberService = new MemberService(req) | ||
| const { memberId } = req.params | ||
| const { memberToMerge } = req.body | ||
|
|
||
| const service = new CommonMemberService(optionsQx(req), req.temporal, req.log) | ||
|
|
||
| const payload = await commonMemberService.merge(req.params.memberId, req.body.memberToMerge, req) | ||
| const payload = await service.merge(memberId, memberToMerge, req) | ||
|
|
||
| // Invalidate member query cache after merge | ||
| try { | ||
| await memberService.invalidateMemberQueryCache([req.params.memberId, req.body.memberToMerge]) | ||
| req.log.debug('Invalidated member query cache after merge') | ||
| await invalidateMemberQueryCache(req.redis, [memberId, memberToMerge]) | ||
| } catch (error) { | ||
| // Don't fail the merge if cache invalidation fails | ||
| req.log.warn('Failed to invalidate member query cache after merge', { error }) | ||
| req.log.warn({ error }, 'Cache invalidation failed after member merge') | ||
| } | ||
|
|
||
| track( | ||
| 'Merge members', | ||
| { memberId: req.params.memberId, memberToMergeId: req.body.memberToMerge }, | ||
| { ...req }, | ||
| ) | ||
|
|
||
| const status = payload.status || 200 | ||
| track('Merge members', { memberId, memberToMergeId: memberToMerge }, req) | ||
|
|
||
| await req.responseHandler.success(req, res, payload, status) | ||
| return req.responseHandler.success(req, res, payload, payload.status ?? 200) | ||
| } |
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
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
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
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| import { Router } from 'express' | ||
|
|
||
| import { identitiesRouter } from './identities' | ||
| import { membersRouter } from './members' | ||
| import { organizationsRouter } from './organizations' | ||
|
|
||
| export function v1Router(): Router { | ||
| const router = Router() | ||
|
|
||
| router.use('/identities', identitiesRouter()) | ||
| router.use('/members', membersRouter()) | ||
| router.use('/organizations', organizationsRouter()) | ||
|
|
||
| return router | ||
| } |
42 changes: 42 additions & 0 deletions
42
backend/src/api/public/v1/members/identities/getMemberIdentities.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import type { Request, Response } from 'express' | ||
| import { z } from 'zod' | ||
|
|
||
| import { NotFoundError } from '@crowd/common' | ||
| import { | ||
| MemberField, | ||
| fetchMemberIdentities, | ||
| findMemberById, | ||
| optionsQx, | ||
| } from '@crowd/data-access-layer' | ||
|
|
||
| import { ok } from '@/utils/api' | ||
| import { validateOrThrow } from '@/utils/validation' | ||
|
|
||
| const paramsSchema = z.object({ | ||
| memberId: z.uuid(), | ||
| }) | ||
|
|
||
| export async function getMemberIdentities(req: Request, res: Response): Promise<void> { | ||
| const { memberId } = validateOrThrow(paramsSchema, req.params) | ||
| const qx = optionsQx(req) | ||
|
|
||
| const member = await findMemberById(qx, memberId, [MemberField.ID]) | ||
|
|
||
| if (!member) throw new NotFoundError('Member not found') | ||
|
|
||
| const rawIdentities = await fetchMemberIdentities(qx, memberId) | ||
|
|
||
| const identities = rawIdentities.map( | ||
| ({ id, value, platform, verified, source, createdAt, updatedAt }) => ({ | ||
| id, | ||
| value, | ||
| platform, | ||
| verified, | ||
| source, | ||
| createdAt, | ||
| updatedAt, | ||
| }), | ||
| ) | ||
|
|
||
| ok(res, { identities }) | ||
| } |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.