Skip to content

@sourceloop/core / Exports

@sourceloop/core

Table of contents

Namespaces

Enumerations

Classes

Interfaces

Type Aliases

Variables

Functions

Type Aliases

AbstractConstructor

Ƭ AbstractConstructor<T>: (...args: any[]) => T

Type parameters

Name
T

Type declaration

• (...args)

Parameters
Name Type
...args any[]

Defined in

packages/core/src/mixins/types.ts:25


AbstractConstructorWithGuard

Ƭ AbstractConstructorWithGuard<M, ID>: AbstractConstructor<WithTenantGuard<M, ID>>

Type parameters

Name Type
M extends EntityWithTenantId
ID ID

Defined in

packages/core/src/components/tenant-utilities/types.ts:101


CrudRestService

Ƭ CrudRestService<T, S>: Object

Type parameters

Name Type
T extends Entity
S extends Entity = T

Type declaration

Name Type
count (token: string, where?: Where<T> | string) => Promise<Count>
create (token: string, data: DataObject<T>) => Promise<T>
delete (token: string, where?: Where<T> | string) => Promise<void>
deleteById (token: string, id: string) => Promise<void>
find (token: string, filter?: Filter<T> | string) => Promise<S[]>
findById (token: string, id: string, filter?: FilterExcludingWhere<T> | string) => Promise<S>
replaceById (token: string, id: string, data: DataObject<T>) => Promise<void>
update (token: string, data: DataObject<T>, where?: Where<T> | string) => Promise<Count>
updateById (token: string, id: string, data: DataObject<T>) => Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:18


CrudRestServiceModifier

Ƭ CrudRestServiceModifier<T>: (service: CrudRestService<T>, model: ModelConstructor<T>, config: RestRelationConfig[]) => ModifiedRestService<T>

Type parameters

Name Type
T extends Entity

Type declaration

▸ (service, model, config): ModifiedRestService<T>

Parameters
Name Type
service CrudRestService<T>
model ModelConstructor<T>
config RestRelationConfig[]
Returns

ModifiedRestService<T>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:81


CrudServiceForModel

Ƭ CrudServiceForModel<T>: Object

Type parameters

Name Type
T extends Model

Type declaration

Name Type
count (token: string, where?: Where<T>) => Promise<Count>
create (token: string, data: DataObject<T>) => Promise<T>
find (token: string, filter?: Filter<T>) => Promise<T[]>
update (token: string, data: T, where?: Where<T>) => Promise<Count>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:42


EntityRestConfig

Ƭ EntityRestConfig: Object

The EntityRestConfig type defines the configuration options for a RESTful entity.

Property

The "model" property is a reference to the constructor function of the entity model. It represents the data structure and behavior of the entity in your application.

Property

The basePath property is an optional string that represents the base path for the REST API endpoints associated with the entity. It is used to define the URL prefix for all the endpoints related to this entity.

Property

The relations property is an optional array of RestRelationConfig objects. Each RestRelationConfig object represents a relation between the current entity and another entity. It defines how the relation should be handled in the REST API.

Property

The restOperations property is an optional array of RestOperationTemplate objects. These objects define the REST operations that can be performed on the entity.

Type declaration

Name Type Description
basePath? string The basePath?: string; property in the EntityRestConfig type is an optional property that represents the base path for the REST API endpoints associated with the entity. It is used to define the URL prefix for all the endpoints related to this entity.
model ModelConstructor<Entity> The model property in the EntityRestConfig type is used to specify the constructor function of the entity model. It represents the data structure and behavior of the entity in your application.
relations? RestRelationConfig[] The relations?: RestRelationConfig[]; property in the EntityRestConfig type is used to define the relations between the current entity and an entity of another microservice.
restOperations? RestOperationTemplate[] The restOperations property in the EntityRestConfig type is an optional array of RestOperationTemplate objects. These objects define the REST operations that can be performed on the entity. Each RestOperationTemplate object contains a template property that defines the details of a REST operation, such as the method, URL, headers, path, query, options, body, and response configuration. The functions property in the RestOperationTemplate object maps function names to an array of strings, where each string represents a specific argument for the request

Defined in

packages/core/src/components/proxy-builder/types.ts:42


EntityWithTenantId

Ƭ EntityWithTenantId: Entity & { tenantId: string }

Defined in

packages/core/src/components/tenant-utilities/types.ts:18


HttpAuthenticationVerifier

Ƭ HttpAuthenticationVerifier: (username?: string, password?: string) => boolean

Type declaration

▸ (username?, password?): boolean

Parameters
Name Type
username? string
password? string
Returns

boolean

Defined in

packages/core/src/components/swagger-authentication/types.ts:5


ISwaggerAuthenticationConfig

Ƭ ISwaggerAuthenticationConfig: Object

Defined in

packages/core/src/components/swagger-authentication/types.ts:10


ModelConstructor

Ƭ ModelConstructor<T>: () => T & { definition: ModelDefinition ; modelName: string }

Type parameters

Name Type
T extends Entity

Defined in

packages/core/src/components/proxy-builder/services/types.ts:119


ModifiedRestService

Ƭ ModifiedRestService<T>: Object

Type parameters

Name Type
T extends Entity

Type declaration

Name Type
count (where?: Where<T>, token?: string) => Promise<Count>
create (data: DataObject<T>, token?: string) => Promise<T>
delete (where?: Where<T>, token?: string) => Promise<void>
deleteById (id: string, token?: string) => Promise<void>
find (filter?: Filter<T>, token?: string, inclusionConfig?: RestRelationConfig) => Promise<T[]>
findById (id: string, filter?: FilterExcludingWhere<T>, token?: string) => Promise<T>
replaceById (id: string, data: DataObject<T>, token?: string) => Promise<void>
update (data: DataObject<T>, where?: Where<T>, token?: string) => Promise<Count>
updateById (id: string, data: DataObject<T>, token?: string) => Promise<void>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:49


OASPathDefinition

Ƭ OASPathDefinition: AnyObject

Defined in

packages/core/src/types.ts:14


OasHiddenApi

Ƭ OasHiddenApi: Object

Type declaration

Name Type
httpMethod HttpMethod
path string

Defined in

packages/core/src/keys.ts:25


ProxyBuilderConfig

Ƭ ProxyBuilderConfig: { baseUrl: string ; configs: (EntityRestConfig | ModelConstructor<Entity>)[] }[]

Defined in

packages/core/src/components/proxy-builder/types.ts:8


ResolvedMap

Ƭ ResolvedMap<Parent, Child>: Map<Child[keyof Child] | Parent[keyof Parent], Child | Child[]>

Type parameters

Name Type
Parent extends Entity
Child extends Entity

Defined in

packages/core/src/components/proxy-builder/services/types.ts:147


ResolverWithMetadata

Ƭ ResolverWithMetadata<T, S>: Object

Type parameters

Name Type
T extends Entity
S extends Entity

Type declaration

Name Type
metadata RelationMetadata
resolver IRestResolver<T, S>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:152


RestLinkerParams

Ƭ RestLinkerParams<Parent, Child>: Object

Type parameters

Name Type
Parent extends Entity
Child extends Entity

Type declaration

Name Type
parent Parent
relationMetadata RelationMetadata
resolvedDataMap ResolvedMap<Parent, Child>
token? string

Defined in

packages/core/src/components/proxy-builder/services/types.ts:140


RestOperationTemplate

Ƭ RestOperationTemplate: Object

The above type defines a template for a REST operation, including the method, URL, headers, path, query, options, body, and response configuration.

Property

The template property is an object that defines the details of a REST operation like method, url, headers, etc.

Property

The functions property is an object that maps function names to an array of arguments for the request. Each of these arguments replaces a value in the template property that is written between {} .

Type declaration

Name Type Description
functions { [key: string]: string[]; } The functions property is an object that maps function names to an array of arguments for the request. Each of these arguments replaces a value in the template property that is written between {}
template { body?: string | AnyObject ; fullResponse?: boolean ; headers?: { [key: string]: string | undefined; Authorization?: "{token}" | string ; content-type?: "application/json" | string } ; method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" ; options?: AnyObject & { maxRedirects?: number } ; path?: AnyObject ; query?: AnyObject ; responsePath?: string ; url: string } The template property is an object that defines the details of a REST operation like method, url, headers, etc
template.body? string | AnyObject -
template.fullResponse? boolean -
template.headers? { [key: string]: string | undefined; Authorization?: "{token}" | string ; content-type?: "application/json" | string } -
template.headers.Authorization? "{token}" | string -
template.headers.content-type? "application/json" | string -
template.method "GET" | "POST" | "PUT" | "PATCH" | "DELETE" -
template.options? AnyObject & { maxRedirects?: number } -
template.path? AnyObject -
template.query? AnyObject -
template.responsePath? string -
template.url string -

Defined in

packages/core/src/components/proxy-builder/types.ts:82


RestRelationConfig

Ƭ RestRelationConfig: { disableStringify?: boolean ; name: string ; throughRelation?: string } & RestRelationConfigWithClass | RestRelationConfigWithKey | RestRelationConfigWithModelClass

Defined in

packages/core/src/components/proxy-builder/services/types.ts:87


RestRelationConfigWithClass

Ƭ RestRelationConfigWithClass: Object

Type declaration

Name Type
serviceClass Function

Defined in

packages/core/src/components/proxy-builder/services/types.ts:100


RestRelationConfigWithKey

Ƭ RestRelationConfigWithKey: Object

Type declaration

Name Type
serviceKey string

Defined in

packages/core/src/components/proxy-builder/services/types.ts:97


RestRelationConfigWithModelClass

Ƭ RestRelationConfigWithModelClass: Object

Type declaration

Name Type
modelClass ModelConstructor<Entity>

Defined in

packages/core/src/components/proxy-builder/services/types.ts:103


RestResolverParams

Ƭ RestResolverParams<Parent, Child>: Object

Type parameters

Name Type
Parent extends Entity
Child extends Entity

Type declaration

Name Type
relationConfig RestRelationConfig
relationMetadata RelationMetadata
results Parent[]
scope? Filter<Child>
token? string

Defined in

packages/core/src/components/proxy-builder/services/types.ts:132


SecuritySchemeObjects

Ƭ SecuritySchemeObjects: Object

Index signature

▪ [securityScheme: string]: SecuritySchemeObject | ReferenceObject

Defined in

packages/core/src/security-specs.ts:7

Variables

AuthCacheSourceName

Const AuthCacheSourceName: "AuthCache"

Defined in

packages/core/src/components/bearer-verifier/types.ts:5


BINDING_PREFIX

Const BINDING_PREFIX: "sourceloop.services"

Defined in

packages/core/src/constants/globals.ts:5


CONTENT_TYPE

Const CONTENT_TYPE: Object

Type declaration

Name Type
FORM_URLENCODED string
JSON string
TEXT string
TEXT_HTML string

Defined in

packages/core/src/constants/content-type.constant.ts:5


DisallowedRoles

Const DisallowedRoles: RoleTypes[]

Defined in

packages/core/src/enums/roles.enum.ts:10


ErrorCodes

Const ErrorCodes: Object

Type declaration

Name Type
400 { description: string = 'The syntax of the request entity is incorrect.' }
400.description string
401 { description: string = 'Invalid Credentials.' }
401.description string
404 { description: string = 'The entity requested does not exist.' }
404.description string
422 { description: string = 'The syntax of the request entity is incorrect' }
422.description string

Defined in

packages/core/src/enums/status-codes.enum.ts:63


OPERATION_SECURITY_SPEC

Const OPERATION_SECURITY_SPEC: { HTTPBearer: never[] = [] }[]

Defined in

packages/core/src/security-specs.ts:6


OasKeyMap

Const OasKeyMap: { [key in HttpMethod]: string }

Defined in

packages/core/src/enums/http-oas.enum.ts:13


SECURITY_SCHEME_SPEC

Const SECURITY_SCHEME_SPEC: SecuritySchemeObjects

Defined in

packages/core/src/security-specs.ts:10


ServiceBuilderExtensionPoint

Const ServiceBuilderExtensionPoint: BindingKey<ModifiedRestService<never>>

Defined in

packages/core/src/components/proxy-builder/keys.ts:23


TenantUtilitiesNamespace

Const TenantUtilitiesNamespace: "sourceloop.tenant.utilities"

Defined in

packages/core/src/components/tenant-utilities/keys.ts:5


X_TS_TYPE

Const X_TS_TYPE: "x-ts-type"

Defined in

packages/core/src/constants/globals.ts:6

Functions

BaseEntityMixin

BaseEntityMixin<T, S>(base, config?): typeof base & AbstractConstructor<IBaseEntity>

Type parameters

Name Type
T extends Entity<T>
S extends Constructor<T> | AbstractConstructor<T>

Parameters

Name Type
base S
config? IBaseEntityConfig

Returns

typeof base & AbstractConstructor<IBaseEntity>

Defined in

packages/core/src/mixins/base-entity.mixin.ts:5


TenantGuardMixin

TenantGuardMixin<M, ID, Relations, S>(superClass): S & AbstractConstructor<ICrudRepository<M, ID, Relations>> & AbstractConstructorWithGuard<M, ID>

Type parameters

Name Type
M extends Entity<M> & { tenantId: string }
ID ID
Relations extends object
S extends AbstractConstructor<ICrudRepository<M, ID, Relations>>

Parameters

Name Type
superClass S & AbstractConstructor<ICrudRepository<M, ID, Relations>>

Returns

S & AbstractConstructor<ICrudRepository<M, ID, Relations>> & AbstractConstructorWithGuard<M, ID>

Defined in

packages/core/src/components/tenant-utilities/mixins/tenant-guard.mixin.ts:20


UserModifiableEntityMixin

UserModifiableEntityMixin<T, S>(base, config?): typeof base & AbstractConstructor<IUserModifiableEntity>

Type parameters

Name Type
T extends Entity<T>
S extends Constructor<T> | AbstractConstructor<T>

Parameters

Name Type
base S
config? IUserModifiableEntityConfig

Returns

typeof base & AbstractConstructor<IUserModifiableEntity>

Defined in

packages/core/src/mixins/user-modifiable-entity.mixin.ts:10


asRestResolver

asRestResolver(): ClassDecorator

Returns

ClassDecorator

Defined in

packages/core/src/components/proxy-builder/constants.ts:150


getAge

getAge(dob): number

Parameters

Name Type
dob Date

Returns

number

Defined in

packages/core/src/utils.ts:23


getDOBFromAge

getDOBFromAge(age): Date

Parameters

Name Type
age number

Returns

Date

Defined in

packages/core/src/utils.ts:29


getErrorString

getErrorString(error): any

Parameters

Name Type
error any

Returns

any

Defined in

packages/core/src/utils.ts:12


isConfigWithKey

isConfigWithKey(config): config is Object

Parameters

Name Type
config RestRelationConfig

Returns

config is Object

Defined in

packages/core/src/components/proxy-builder/services/types.ts:107


isConfigWithModelClass

isConfigWithModelClass(config): config is Object

Parameters

Name Type
config RestRelationConfig

Returns

config is Object

Defined in

packages/core/src/components/proxy-builder/services/types.ts:113


isEntityRestConfig

isEntityRestConfig(config): config is EntityRestConfig

Parameters

Name Type
config ModelConstructor<Entity> | EntityRestConfig

Returns

config is EntityRestConfig

Defined in

packages/core/src/components/proxy-builder/types.ts:22


rateLimitKeyGen

rateLimitKeyGen(req): string

Parameters

Name Type
req Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Returns

string

Defined in

packages/core/src/utils.ts:34


rateLimitKeyGenPublic

rateLimitKeyGenPublic(req): string

Parameters

Name Type
req Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

Returns

string

Defined in

packages/core/src/utils.ts:40


restProxyBuilder

restProxyBuilder(basePath): RestOperationTemplate[]

Parameters

Name Type
basePath string

Returns

RestOperationTemplate[]

Defined in

packages/core/src/components/proxy-builder/constants.ts:10


restService

restService(model): (target: Object, member: undefined | string, methodDescriptorOrParameterIndex?: number | TypedPropertyDescriptor<any>) => void

Parameters

Name Type
model ModelConstructor<Entity>

Returns

fn

▸ (target, member, methodDescriptorOrParameterIndex?): void

A decorator to annotate method arguments for automatic injection by LoopBack IoC container.

Example

Usage - Typescript:

1
2
3
4
5
6
7
class InfoController {
  @inject('authentication.user') public userName: string;

  constructor(@inject('application.name') public appName: string) {
  }
  // ...
}

Usage - JavaScript:

  • TODO(bajtos)
Parameters
Name Type
target Object
member undefined | string
methodDescriptorOrParameterIndex? number | TypedPropertyDescriptor<any>
Returns

void

Defined in

packages/core/src/components/proxy-builder/decorators/rest-proxy.decorator.ts:9


tenantGuard

tenantGuard(): <M, ID, Relations, S>(constructor: S & AbstractConstructor<ICrudRepository<M, ID, Relations>>) => S & AbstractConstructor<ICrudRepository<M, ID, Relations>>

This function returns a class decorator that adds a tenant guard mixin to the given repository class.

Returns

fn

▸ <M, ID, Relations, S>(constructor): S & AbstractConstructor<ICrudRepository<M, ID, Relations>>

Type parameters
Name Type
M extends Entity<M> & { tenantId: string }
ID ID
Relations extends object
S extends AbstractConstructor<ICrudRepository<M, ID, Relations>>
Parameters
Name Type
constructor S & AbstractConstructor<ICrudRepository<M, ID, Relations>>
Returns

S & AbstractConstructor<ICrudRepository<M, ID, Relations>>

Defined in

packages/core/src/components/tenant-utilities/decorators/tenant-guard.decorator.ts:11