Skip to content

@sourceloop/core / Exports / TenantGuardService

Class: TenantGuardService<T, ID>

Type parameters

Name Type
T extends EntityWithTenantId
ID ID

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new TenantGuardService<T, ID>(getCurrentUser)

Type parameters

Name Type
T extends Entity<T> & { tenantId: string }
ID ID

Parameters

Name Type
getCurrentUser Getter<UserInToken>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:21

Properties

getCurrentUser

Readonly getCurrentUser: Getter<UserInToken>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:23

Methods

addTenantIDMultiple

Private addTenantIDMultiple<R>(entities): Promise<R[]>

Type parameters

Name Type
R extends EntityWithTenantId | Partial<T> |

Parameters

Name Type
entities R[]

Returns

Promise<R[]>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:139


addTenantId

Private addTenantId<S>(entity): Promise<S>

Type parameters

Name Type
S extends EntityWithTenantId | Partial<T> |

Parameters

Name Type
entity S

Returns

Promise<S>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:130


addTenantToFilter

Private addTenantToFilter(filter?, id?): Promise<Filter<T>>

Parameters

Name Type
filter? Filter<T>
id? ID

Returns

Promise<Filter<T>>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:168


addTenantToWhere

Private addTenantToWhere(where?, id?): Promise<Where<T>>

Parameters

Name Type
where? Where<T>
id? ID

Returns

Promise<Where<T>>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:161


buildWhere

Private buildWhere(user, where?, id?): Where<T>

Parameters

Name Type
user UserInToken
where? Where<T>
id? ID

Returns

Where<T>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:182


checkTenantId

Private checkTenantId(data): Promise<void>

Parameters

Name Type
data DataObject<T>

Returns

Promise<void>

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:116


count

count(where?): Promise<Where<T>>

Parameters

Name Type
where? Where<T>

Returns

Promise<Where<T>>

Implementation of

ITenantGuard.count

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:43


create

create(data): Promise<DataObject<T>>

Parameters

Name Type
data DataObject<T>

Returns

Promise<DataObject<T>>

Implementation of

ITenantGuard.create

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:51


createAll

createAll<R>(data): Promise<R[]>

Type parameters

Name Type
R extends EntityWithTenantId | Partial<T> |

Parameters

Name Type
data R[]

Returns

Promise<R[]>

Implementation of

ITenantGuard.createAll

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:55


delete

delete(entity): Promise<{ entity: T ; where: Where<T> }>

Parameters

Name Type
entity T

Returns

Promise<{ entity: T ; where: Where<T> }>

Implementation of

ITenantGuard.delete

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:104


deleteAll

deleteAll(where?): Promise<Where<T>>

Parameters

Name Type
where? Where<T>

Returns

Promise<Where<T>>

Implementation of

ITenantGuard.deleteAll

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:112


deleteById

deleteById(id): Promise<Where<T>>

Parameters

Name Type
id ID

Returns

Promise<Where<T>>

Implementation of

ITenantGuard.deleteById

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:100


exists

exists(id): Promise<Where<T>>

Parameters

Name Type
id ID

Returns

Promise<Where<T>>

Implementation of

ITenantGuard.exists

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:47


find

find(filter?): Promise<Filter<T>>

Parameters

Name Type
filter? Filter<T>

Returns

Promise<Filter<T>>

Implementation of

ITenantGuard.find

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:31


findById

findById(id, filter?): Promise<Filter<T>>

Parameters

Name Type
id ID
filter? FilterExcludingWhere<T>

Returns

Promise<Filter<T>>

Implementation of

ITenantGuard.findById

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:39


findOne

findOne(filter?): Promise<Filter<T>>

Parameters

Name Type
filter? Filter<T>

Returns

Promise<Filter<T>>

Implementation of

ITenantGuard.findOne

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:35


replaceById

replaceById(id, data): Promise<{ data: DataObject<T> ; where: Where<T> }>

Parameters

Name Type
id ID
data DataObject<T>

Returns

Promise<{ data: DataObject<T> ; where: Where<T> }>

Implementation of

ITenantGuard.replaceById

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:63


save

save(entity): Promise<T>

Parameters

Name Type
entity T

Returns

Promise<T>

Implementation of

ITenantGuard.save

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:59


skipTenantGuard

skipTenantGuard(): Promise<boolean>

Returns

Promise<boolean>

Implementation of

ITenantGuard.skipTenantGuard

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:26


update

update(data): Promise<{ data: T ; where: Where<T> }>

Parameters

Name Type
data T

Returns

Promise<{ data: T ; where: Where<T> }>

Implementation of

ITenantGuard.update

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:81


updateAll

updateAll(data, where?): Promise<{ data: DataObject<T> ; where: Where<T> }>

Parameters

Name Type
data DataObject<T>
where? Where<T>

Returns

Promise<{ data: DataObject<T> ; where: Where<T> }>

Implementation of

ITenantGuard.updateAll

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:89


updateById

updateById<R>(id, data): Promise<{ data: R ; where: Where<T> }>

Type parameters

Name Type
R extends EntityWithTenantId | Partial<T> |

Parameters

Name Type
id ID
data R

Returns

Promise<{ data: R ; where: Where<T> }>

Implementation of

ITenantGuard.updateById

Defined in

packages/core/src/components/tenant-utilities/services/tenant-guard.service.ts:70