-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add a Platform service #703
Conversation
Affected libs:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks ✌️ I think this is going in the right direction. I would have liked the auth service to be gone completely though, but maybe this will take too much refactoring.
readonly isApiCompatible$ = this.apiVersion$.pipe( | ||
tap( | ||
(version) => | ||
version < minApiVersion && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that really work for semver? e.g. 4.10.0
might be considered "lower" than 4.2.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes this is not correct, I will add the test of the version in another PR and keep this one as just refactoring.
I don't want that some heavy work is started and brings conflicts because of this refactoring.
0833d60
to
b7bd72f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a first pass on the changes, most of it looks OK but I still stumbled on some possible improvements. I feel like it would have been a great opportunity to get rid of the AuthService as well, but maybe that was taking the refactoring too far?
apps/datahub/src/app/home/home-header/home-header.component.spec.ts
Outdated
Show resolved
Hide resolved
apps/datahub/src/app/home/home-header/home-header.component.spec.ts
Outdated
Show resolved
Hide resolved
libs/api/repository/src/lib/gn4/platform/gn4-platform.service.spec.ts
Outdated
Show resolved
Hide resolved
provide: PlatformServiceInterface, | ||
useClass: Gn4PlatformService, | ||
}, | ||
Gn4PlatformMapper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why this should be provided? Isn't it an explicit dependency of Gn4PlatformService?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's not injected in root, so it has to be injected somehow.
There is no providers
option from services.
import { AvatarServiceInterface } from '../auth/avatar.service.interface' | ||
|
||
@Injectable() | ||
export class Gn4PlatformMapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like these mappers could be simple pure functions exported as is, instead of an Angular service.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I actually wanted to create a static class, but the mappers need for instance the AvatarService
which is injected.
credentialsNonExpired, | ||
...user | ||
} = apiUser | ||
return { ...apiUser, id: id + '' } as UserModel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return { ...apiUser, id: id + '' } as UserModel | |
return { ...apiUser, id: id.toString() } as UserModel |
Many repositories should be implemented.move record repository to this folder.
move all models to this folder
automatic refactoring created wrong path :/
remove code from AuthService and use the platform instead
make things clearer and move the User model in domain from gn4-api
which should be responsible of gathering all domain interface implementation for the gn4 strategy
move from AuthService to PlatformeService
to avoid using global subjects which could create side effects
b7bd72f
to
548263b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go!
Add a platform service interface + a gn4 implementation to centralize
Please read commit history for more information.
Only some parts of the code use this platform, mostly auth Observables, users and version things.
Incrementally, we could move the organizations repositories into it.
Code ready for a review.
Tests will come if it's ok.