import { Context } from '@loopback/core'; import { Entity, HasManyDefinition, RelationType } from '@loopback/repository'; import { IRestResolver, ResolvedMap, RestLinkerParams, RestResolverParams } from '../types'; export declare class HasManyRestResolver implements IRestResolver { private readonly context; constructor(context: Context); type: RelationType; resolve({ relationConfig, relationMetadata, results, scope, token, }: RestResolverParams & { relationMetadata: HasManyDefinition; }): Promise>; /** * The function `_resolveHasManyThrough` handles resolving a has-many-through relation in TypeScript, * extracting necessary data and mapping related results. * @param - The `_resolveHasManyThrough` function is responsible for resolving a has-many-through * relationship in a REST API resolver. Here is an explanation of the parameters used in the * function: * @returns The `_resolveHasManyThrough` method returns the mapped related results based on the * provided parameters and configurations. */ private _resolveHasManyThrough; /** * The function `_getThroughKeys` retrieves key information for a HasMany relation, including keys * from a through model if specified. * @param {HasManyDefinition} relationMetadata - The `relationMetadata` parameter is of type * `HasManyDefinition`, which likely contains metadata information about a has-many relationship in a * data model. It may include details such as the source and target models, keys used for the * relationship, and possibly a through model for a many-to-many relationship. * @returns The function `_getThroughKeys` returns an object with three properties: `keyFromThrough`, * `keyToThrough`, and `keyTo`. */ private _getThroughKeys; /** * The function `_extractThroughData` extracts data from an array of objects based on specified * properties and returns a set of IDs and a map of key-value pairs. * @param {T[]} results - The `results` parameter is an array of objects of type `T`. * @param throughModelProperty - The `throughModelProperty` parameter is the property of the object * `T` that contains the through data. * @param {string} keyToThrough - The `keyToThrough` parameter in the `_extractThroughData` function * represents the key in the through data object that is used as the identifier for mapping purposes. * It is the key that is used to uniquely identify each item in the through data. * @param {string} keyFromThrough - The `keyFromThrough` parameter in the `_extractThroughData` * function represents the key in the through data object that you want to extract values from and * store in the `throughMap`. This key is used as the value in the map where the key is the * `keyToThrough` value. * @returns The function `_extractThroughData` returns an object with two properties: `idsSet`, which * is a Set containing unique values extracted from the `keyToThrough` property of the through data, * and `throughMap`, which is a Map where the key is extracted from the `keyToThrough` property and * the value is extracted from the `keyFromThrough` property of the through data. */ private _extractThroughData; /** * The function `_mapRelatedResults` creates a map of related results based on a specified key and * relation metadata. * @param {S[]} relatedResults - The `relatedResults` parameter is an array of elements of type `S`, * which represents the related results that need to be mapped. * @param throughMap - The `throughMap` parameter is a Map that maps a key from one type `S` to another * key of type `S`. It is used to retrieve a key from the `relatedResults` based on the `keyTo` * property of type `S`. * @param keyTo - The `keyTo` parameter in the `_mapRelatedResults` function is a property key of the * type `S`. It is used to access a specific property of the items in the `relatedResults` array. * @param {HasManyDefinition} relationMetadata - The `relationMetadata` parameter in the * `_mapRelatedResults` function is of type `HasManyDefinition`. It likely contains metadata * information related to a has-many relationship in the context of the function's operation. This * metadata could include details such as the through model, model names, and other relevant * information * @returns The function `_mapRelatedResults` is returning a `Map` object that maps keys of type * `S[keyof S] | T[keyof T]` to arrays of type `S[]`. */ private _mapRelatedResults; private _resolveHasManyOnly; link(params: RestLinkerParams & { relationMetadata: HasManyDefinition; }): Promise; private addConditionToScope; private findRelatedData; private toPascalCase; private getService; }