Skip to content

@sourceloop/core / Exports / RestServiceModifier

Class: RestServiceModifier<T, S>

Type parameters

Name Type
T extends Entity
S extends Entity

Implements

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new RestServiceModifier<T, S>(resolverGetter, _validateToken, req?)

Type parameters

Name Type
T extends Entity<T>
S extends Entity<S>

Parameters

Name Type
resolverGetter Getter<IRestResolver<T, S>[]>
_validateToken (context: RestServiceModifier<T, S>, token?: string) => string
req? Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:42

Properties

_validateToken

Private _validateToken: (context: RestServiceModifier<T, S>, token?: string) => string

Type declaration

▸ (context, token?): string

Parameters
Name Type
context RestServiceModifier<T, S>
token? string
Returns

string

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:46


req

Private Optional req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:50


resolverGetter

Private resolverGetter: Getter<IRestResolver<T, S>[]>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:44


resolvers

Private resolvers: IRestResolver<T, S>[]

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:41


token

Private token: string

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:40

Methods

_configsHaveRelations

Private _configsHaveRelations(configs, name): boolean

Parameters

Name Type
configs RestRelationConfig[]
name string

Returns

boolean

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:303


_extraFilters

Private _extraFilters(configs): InclusionFilter[]

Parameters

Name Type
configs RestRelationConfig[]

Returns

InclusionFilter[]

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:223


_relationsFromFilter

Private _relationsFromFilter(configs, filter?): { restRelations: RestRelationConfig[] ; scopeMap: Map<string, Filter<S>> } | { restRelations: never[] = []; scopeMap: Map<any, any> }

It takes a filter and a list of relations, and returns a list of relations that are REST relations, and a map of scopes for those relations

Parameters

Name Type Description
configs RestRelationConfig[] RestRelationConfig[]
filter? Filter<T> The filter object that was passed to the find method.

Returns

{ restRelations: RestRelationConfig[] ; scopeMap: Map<string, Filter<S>> } | { restRelations: never[] = []; scopeMap: Map<any, any> }

An object with two properties: restRelations and scopeMap.

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:177


_resolveRelations

Private _resolveRelations(relations, scopeMap, model, results, token?): Promise<T[]>

It takes a list of relations, a list of results, and a token, and returns a list of results with the relations resolved

Parameters

Name Type Description
relations RestRelationConfig[] RestRelationConfig[]
scopeMap Map<string, Filter<S>> Map>
model ModelConstructor<T> The model class that we are querying
results T[] The results of the query.
token? string The access token of the current user.

Returns

Promise<T[]>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:244


_updateFilter

Private _updateFilter(extraIncludes, filter, normalRelations): void

Parameters

Name Type
extraIncludes InclusionFilter[]
filter Filter<T>
normalRelations InclusionFilter[]

Returns

void

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:209


count

count(service, where?, token?): Promise<Count>

Parameters

Name Type
service CrudRestService<T, T>
where? Where<T>
token? string

Returns

Promise<Count>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:130


create

create(service, data, token?): Promise<T>

Parameters

Name Type
service CrudRestService<T, T>
data DataObject<T>
token? string

Returns

Promise<T>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:78


delete

delete(service, where?, token?): Promise<void>

Parameters

Name Type
service CrudRestService<T, T>
where? Where<T>
token? string

Returns

Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:147


deleteById

deleteById(service, id, token?): Promise<void>

Parameters

Name Type
service CrudRestService<T, T>
id string
token? string

Returns

Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:144


find

find(service, model, config, filter?, token?, inclusionConfig?): Promise<T[]>

Parameters

Name Type
service CrudRestService<T, T>
model ModelConstructor<T>
config RestRelationConfig[]
filter? Filter<T>
token? string
inclusionConfig? RestRelationConfig

Returns

Promise<T[]>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:105


findById

findById(service, model, config, id, filter?, token?): Promise<T>

Parameters

Name Type
service CrudRestService<T, T>
model ModelConstructor<T>
config RestRelationConfig[]
id string
filter? FilterExcludingWhere<T>
token? string

Returns

Promise<T>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:81


replaceById

replaceById(service, id, data, token?): Promise<void>

Parameters

Name Type
service CrudRestService<T, T>
id string
data DataObject<T>
token? string

Returns

Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:162


update

update(service, data, where?, token?): Promise<Count>

Parameters

Name Type
service CrudRestService<T, T>
data DataObject<T>
where? Where<T>
token? string

Returns

Promise<Count>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:150


updateById

updateById(service, id, data, token?): Promise<void>

Parameters

Name Type
service CrudRestService<T, T>
id string
data DataObject<T>
token? string

Returns

Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:136


value

value(): Promise<(service: CrudRestService<T, T>, model: ModelConstructor<T>, config: RestRelationConfig[]) => { count: (...args: [where?: Where, token?: string]) => Promise<Count> ; create: (...args: [data: DataObject, token?: string]) => Promise<T> ; delete: (...args: [where?: Where, token?: string]) => Promise<void> ; deleteById: (...args: [id: string, token?: string]) => Promise<void> ; find: (...args: [filter?: Filter, token?: string, inclusionConfig?: RestRelationConfig]) => Promise<T[]> ; findById: (...args: [id: string, filter?: FilterExcludingWhere, token?: string]) => Promise<T> ; replaceById: (...args: [id: string, data: DataObject, token?: string]) => Promise<void> ; update: (...args: [data: DataObject<T>, where?: Where, token?: string]) => Promise<Count> ; updateById: (...args: [id: string, data: DataObject, token?: string]) => Promise<void> }>

Returns

Promise<(service: CrudRestService<T, T>, model: ModelConstructor<T>, config: RestRelationConfig[]) => { count: (...args: [where?: Where, token?: string]) => Promise<Count> ; create: (...args: [data: DataObject, token?: string]) => Promise<T> ; delete: (...args: [where?: Where, token?: string]) => Promise<void> ; deleteById: (...args: [id: string, token?: string]) => Promise<void> ; find: (...args: [filter?: Filter, token?: string, inclusionConfig?: RestRelationConfig]) => Promise<T[]> ; findById: (...args: [id: string, filter?: FilterExcludingWhere, token?: string]) => Promise<T> ; replaceById: (...args: [id: string, data: DataObject, token?: string]) => Promise<void> ; update: (...args: [data: DataObject<T>, where?: Where, token?: string]) => Promise<Count> ; updateById: (...args: [id: string, data: DataObject, token?: string]) => Promise<void> }>

Implementation of

Provider.value

Defined in

packages/core/src/components/proxy-builder/services/rest-service-modifier.provider.ts:56