-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor entity services to receive the request
- Loading branch information
1 parent
e1620af
commit bc5d782
Showing
15 changed files
with
54 additions
and
45 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
apps/orchestration/src/store/entity/core/service/address-book.service.ts
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 |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { AddressBookAccountEntity } from '@narval/authz-shared' | ||
import { AddressBookAccountEntity, CreateAddressBookAccountRequest } from '@narval/authz-shared' | ||
import { Injectable } from '@nestjs/common' | ||
import { AddressBookRepository } from '../../persistence/repository/address-book.repository' | ||
|
||
@Injectable() | ||
export class AddressBookService { | ||
constructor(private addressBookRepository: AddressBookRepository) {} | ||
|
||
create(orgId: string, account: AddressBookAccountEntity): Promise<AddressBookAccountEntity> { | ||
return this.addressBookRepository.create(orgId, account) | ||
create(orgId: string, data: CreateAddressBookAccountRequest): Promise<AddressBookAccountEntity> { | ||
return this.addressBookRepository.create(orgId, data.request.account) | ||
} | ||
} |
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
22 changes: 14 additions & 8 deletions
22
apps/orchestration/src/store/entity/core/service/organization.service.ts
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 |
---|---|---|
@@ -1,35 +1,41 @@ | ||
import { CredentialEntity, OrganizationEntity, UserEntity, UserRole } from '@narval/authz-shared' | ||
import { | ||
CreateOrganizationRequest, | ||
CredentialEntity, | ||
OrganizationEntity, | ||
UserEntity, | ||
UserRole | ||
} from '@narval/authz-shared' | ||
import { Injectable } from '@nestjs/common' | ||
import { OrganizationRepository } from '../../persistence/repository/organization.repository' | ||
import { UserService } from './user.service' | ||
import { UserRepository } from '../../persistence/repository/user.repository' | ||
|
||
@Injectable() | ||
export class OrganizationService { | ||
constructor( | ||
private orgRepository: OrganizationRepository, | ||
private userService: UserService | ||
private userRepository: UserRepository | ||
) {} | ||
|
||
async create(input: { uid: string; rootCredential: CredentialEntity }): Promise<{ | ||
async create(input: CreateOrganizationRequest): Promise<{ | ||
organization: OrganizationEntity | ||
rootUser: UserEntity | ||
rootCredential: CredentialEntity | ||
}> { | ||
const { uid, rootCredential } = input | ||
const { uid, credential } = input.request.organization | ||
|
||
const rootUser: UserEntity = { | ||
uid: input.rootCredential.userId, | ||
uid: credential.userId, | ||
role: UserRole.ROOT | ||
} | ||
|
||
await this.userService.create(uid, rootUser, input.rootCredential) | ||
await this.userRepository.create(uid, rootUser, credential) | ||
|
||
const organization = await this.orgRepository.create(uid) | ||
|
||
return { | ||
organization, | ||
rootUser, | ||
rootCredential | ||
rootCredential: credential | ||
} | ||
} | ||
} |
4 changes: 3 additions & 1 deletion
4
apps/orchestration/src/store/entity/core/service/user-group.service.ts
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
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