-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tenant-management): add saastenantrepo for webhook handler
add saastenantrepo for webhook handler gh-34
- Loading branch information
1 parent
44f897a
commit 2a6e78a
Showing
4 changed files
with
94 additions
and
1 deletion.
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
89 changes: 89 additions & 0 deletions
89
services/tenant-management-service/src/repositories/saas-tenant.repository.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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import {Getter, inject} from '@loopback/core'; | ||
import { | ||
BelongsToAccessor, | ||
HasManyRepositoryFactory, | ||
juggler, | ||
repository, | ||
} from '@loopback/repository'; | ||
import { | ||
DefaultTransactionalUserModifyRepository, | ||
IAuthUserWithPermissions, | ||
} from '@sourceloop/core'; | ||
import {AuthenticationBindings} from 'loopback4-authentication'; | ||
|
||
import { | ||
Address, | ||
Contact, | ||
Lead, | ||
Resource, | ||
Tenant, | ||
TenantRelations, | ||
} from '../models'; | ||
import {ContactRepository} from './contact.repository'; | ||
import {LeadRepository} from './lead.repository'; | ||
import {ResourceRepository} from './resource.repository'; | ||
import {AddressRepository} from './address.repository'; | ||
import {TenantManagementDbSourceName} from '../types'; | ||
|
||
export class SaasTenantRepository extends DefaultTransactionalUserModifyRepository< | ||
Tenant, | ||
typeof Tenant.prototype.id, | ||
TenantRelations | ||
> { | ||
public readonly contacts: HasManyRepositoryFactory< | ||
Contact, | ||
typeof Tenant.prototype.id | ||
>; | ||
|
||
public readonly resources: HasManyRepositoryFactory< | ||
Resource, | ||
typeof Tenant.prototype.id | ||
>; | ||
|
||
public readonly lead: BelongsToAccessor<Lead, typeof Tenant.prototype.id>; | ||
|
||
public readonly address: BelongsToAccessor< | ||
Address, | ||
typeof Tenant.prototype.id | ||
>; | ||
|
||
constructor( | ||
@inject(`datasources.${TenantManagementDbSourceName}`) | ||
dataSource: juggler.DataSource, | ||
@inject.getter(AuthenticationBindings.CURRENT_USER) | ||
public readonly getCurrentUser: Getter<IAuthUserWithPermissions>, | ||
@repository.getter('ContactRepository') | ||
protected contactRepositoryGetter: Getter<ContactRepository>, | ||
@repository.getter('LeadRepository') | ||
protected leadRepositoryGetter: Getter<LeadRepository>, | ||
@repository.getter('ResourceRepository') | ||
protected resourceRepositoryGetter: Getter<ResourceRepository>, | ||
@repository.getter('AddressRepository') | ||
protected addressRepositoryGetter: Getter<AddressRepository>, | ||
) { | ||
super(Tenant, dataSource, getCurrentUser); | ||
this.lead = this.createBelongsToAccessorFor('lead', leadRepositoryGetter); | ||
this.registerInclusionResolver('lead', this.lead.inclusionResolver); | ||
this.contacts = this.createHasManyRepositoryFactoryFor( | ||
'contacts', | ||
contactRepositoryGetter, | ||
); | ||
this.registerInclusionResolver('contacts', this.contacts.inclusionResolver); | ||
|
||
this.resources = this.createHasManyRepositoryFactoryFor( | ||
'resources', | ||
resourceRepositoryGetter, | ||
); | ||
this.registerInclusionResolver( | ||
'resources', | ||
this.resources.inclusionResolver, | ||
); | ||
|
||
this.address = this.createBelongsToAccessorFor( | ||
'address', | ||
addressRepositoryGetter, | ||
); | ||
this.registerInclusionResolver('address', this.address.inclusionResolver); | ||
} | ||
} | ||
|
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