UNPKG

3.51 kBTypeScriptView Raw
1import { Entity, EntityIdentifiable, Constructable } from '../entity';
2import type { Expandable } from '../expandable';
3import type { Selectable } from './selectable';
4/**
5 * Represents a navigation property of an OData entity.
6 *
7 * OData is a relational data model, i.e. entities can be related to one another.
8 * For example, BusinessPartner is in a 1:n relation with BusinessPartnerAddress and in a 1:1 relation with Customer.
9 * Like normal properties, navigation properties can be used for selecting (expanding) and filtering.
10 * For example, when constructing a query on the BusinessPartner entity, an instance of `Link<BusinessPartner, Customer>`
11 * can be passed as argument to the select function, e.g. `BusinessPartner.TO_CUSTOMER`.
12 *
13 * NOTE: Due to historical development the Link and its extensions are used in the following way:
14 * OData v2 entity: 1:N is a [[Link]], 1:0..1 is a [[OneToOneLink]]
15 * OData v4 entity: 1:N is a [[OneToManyLink]], 1:0..1 is a [[OneToOneLink]]
16 *
17 * See also: [[Selectable]]
18 * @typeparam EntityT - Type of the entity to be linked from
19 * @typeparam LinkedEntityT - Type of the entity to be linked to
20 */
21export declare class Link<EntityT extends Entity, LinkedEntityT extends Entity = any> implements EntityIdentifiable<EntityT> {
22 readonly _fieldName: string;
23 readonly _entityConstructor: Constructable<EntityT>;
24 readonly _linkedEntity: Constructable<LinkedEntityT>;
25 /**
26 * @deprecated Since v1.21.0. Use [[clone]] instead.
27 * Create a new link based on a given link.
28 * @typeparam EntityT - Type of the entity to be linked from
29 * @typeparam LinkedEntityT - Type of the entity to be linked to
30 * @param link - Link to be cloned
31 * @returns Newly created link
32 */
33 static clone<EntityT1 extends Entity, LinkedEntityT1 extends Entity>(link: Link<EntityT1, LinkedEntityT1>): Link<EntityT1, LinkedEntityT1>;
34 readonly _entity: EntityT;
35 /**
36 * @deprecated Since v1.21.0. Use [[_selects]] directly.
37 * List of selectables on the linked entity.
38 */
39 get selects(): Selectable<LinkedEntityT>[];
40 /**
41 * List of selectables on the linked entity.
42 */
43 _selects: Selectable<LinkedEntityT>[];
44 _expand: Expandable<LinkedEntityT>[];
45 /**
46 * Creates an instance of Link.
47 * @param _fieldName - Name of the linking field to be used in the OData request.
48 * @param _entityConstructor - Constructor type of the entity the field belongs to
49 * @param _linkedEntity - Constructor type of the linked entity
50 */
51 constructor(_fieldName: string, _entityConstructor: Constructable<EntityT>, _linkedEntity: Constructable<LinkedEntityT>);
52 /**
53 * Creates a selection on a linked entity. Has the same behavior as [[GetAllRequestBuilder.select | GetAllRequestBuilderV2.select]] and [[GetByKeyRequestBuilderV4.select]] but for linked entities.
54 *
55 * See also, [[Selectable]]
56 * @param selects - Selection of fields or links on a linked entity
57 * @returns The link itself, to facilitate method chaining
58 */
59 select(...selects: Selectable<LinkedEntityT>[]): this;
60 expand(...expands: Expandable<LinkedEntityT>[]): this;
61 /**
62 * Create a new link based on a given link.
63 * @typeparam EntityT - Type of the entity to be linked from
64 * @typeparam LinkedEntityT - Type of the entity to be linked to
65 * @param link - Link to be cloned
66 * @returns Newly created link
67 */
68 clone(): this;
69}
70//# sourceMappingURL=link.d.ts.map
\No newline at end of file