UNPKG

5.11 kBTypeScriptView Raw
1import { ODataVersion } from '@sap-cloud-sdk/util';
2import { EdmTypeShared } from '../edm-types';
3import { Constructable, Entity } from '../entity';
4import { Field, FieldOptions } from './field';
5import { ComplexTypeNamespace } from './complex-type-namespace';
6import type { ConstructorOrField } from './constructor-or-field';
7/**
8 * Represents a complex type property of an entity or a complex type.
9 *
10 * `ComplexTypeField`s are used as static properties of entities and are generated from the metadata, i.e. for each property of
11 * an OData entity, that has a complex type, there exists one static instance of `ComplexTypeField` (or rather one of its subclasses) in the corresponding generated class file.
12 * `ComplexTypeField`s are used to represent the domain of complex or custom structures that can be used in select, filter and order by functions.
13 * For example, when constructing a query on the TimeSheetEntry entity, an instance of `ComplexTypeField<TimeSheetEntry>`
14 * can be supplied as argument to the select function, e.g. `TimeSheetEntry.TIME_SHEET_DATA_FIELDS`.
15 * Moreover, classes implementing this abstract class will provide property fields, that can be used for filtering and ordering.
16 *
17 * See also: [[Selectable]]
18 * @typeparam EntityT - Type of the entity the field belongs to.
19 * @typeparam ComplexT - Type of complex type represented by this field.
20 * @typeparam NullableT - Boolean type that represents whether the field is nullable.
21 * @typeparam SelectableT - Boolean type that represents whether the field is selectable.
22 */
23export declare abstract class ComplexTypeField<EntityT extends Entity, ComplexT = any, NullableT extends boolean = false, SelectableT extends boolean = false> extends Field<EntityT, NullableT, SelectableT> {
24 readonly fieldOf: ConstructorOrField<EntityT, ComplexT>;
25 /**
26 * @hidden
27 * Note that this property is crucial, although not really used.
28 * If it is removed this class becomes structural equivalent to e.g. ComplexTypeStringPropertyField which leads to unexpected behavior on the `selectable` list of objects.
29 */
30 readonly complexTypeName?: string;
31 /**
32 * The complex type of the complex type property represented by this.
33 */
34 readonly _complexType: ComplexTypeNamespace<ComplexT>;
35 /**
36 * @deprecated Since v1.19.0.
37 *
38 * Creates an instance of ComplexTypeField.
39 * @param fieldName - Actual name of the field as used in the OData request.
40 * @param entityConstructor - Constructor type of the entity the field belongs to.
41 * @param complexTypeName - Name of the type of the field according to the metadata description.
42 */
43 constructor(fieldName: string, entityConstructor: Constructable<EntityT>, complexTypeName: string);
44 /**
45 * @deprecated Since v1.27.0. Use other constructors instead.
46 * Creates an instance of ComplexTypeField.
47 * @param fieldName - Actual name of the field as used in the OData request.
48 * @param fieldOf - Either the parent entity constructor of the parent complex type this field belongs to.
49 */
50 constructor(fieldName: string, fieldOf: ConstructorOrField<EntityT, ComplexT>);
51 /**
52 * Creates an instance of ComplexTypeField.
53 * @param fieldName - Actual name of the field as used in the OData request.
54 * @param fieldOf - Either the parent entity constructor of the parent complex type this field belongs to.
55 * @param complexType - The complex type of the complex type property represented by this.
56 * @param fieldOptions - Optional settings for this field.
57 */
58 constructor(fieldName: string, fieldOf: ConstructorOrField<EntityT, ComplexT>, complexType: ComplexTypeNamespace<ComplexT>, fieldOptions?: FieldOptions<NullableT, SelectableT>);
59 /**
60 * Gets the path to the complex type property represented by this.
61 * @returns The path to the complex type property.
62 */
63 fieldPath(): string;
64}
65/**
66 * Convenience method to get the entity constructor of the parent of a complex type.
67 * @param fieldOf - Either an entity constructor or another complex type field.
68 * @returns The constructor of the transitive parent entity;
69 */
70export declare function getEntityConstructor<EntityT extends Entity, ComplexT>(fieldOf: ConstructorOrField<EntityT, ComplexT>): Constructable<EntityT>;
71/**
72 * Convenience method to get the [[EdmTypeShared]] from the overloaded constructor.
73 * The two scenarios are:
74 * - `complexTypeNameOrEdmType` is of type `EdmTypeShared` and `edmTypeOrUndefined` is `undefined`
75 * - `complexTypeNameOrEdmType` is of type `string` and `edmTypeOrUndefined` is of type `EdmTypeShared`
76 * @param complexTypeNameOrEdmType - Either the name of the complex type or the EDM type.
77 * @param edmTypeOrUndefined - Either the EDM type or `undefined`.
78 * @returns The EDM type resolved for the two arguments.
79 */
80export declare function getEdmType<VersionT extends ODataVersion | 'any'>(complexTypeNameOrEdmType: string | EdmTypeShared<VersionT>, edmTypeOrUndefined?: EdmTypeShared<VersionT>): EdmTypeShared<VersionT>;
81//# sourceMappingURL=complex-type-field.d.ts.map
\No newline at end of file