@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
69 lines (68 loc) • 4.44 kB
TypeScript
import { Filter } from '../filter';
import { Field } from './field';
import type { EntityBase, EntityIdentifiable } from '../entity-base';
import type { EdmTypeShared } from '../edm-types';
import type { DeSerializers, DeserializedType } from '../de-serializers';
import type { ConstructorOrField } from './constructor-or-field';
import type { FieldOptions } from './field';
/**
* Convenience type that maps the given field type to a new type that is either nullable or not, depending on the given `NullableT`.
* @template FieldT - Field type of the field.
* @template NullableT - Boolean type that represents whether the field is nullable.
*/
export type NullableFieldType<FieldT, NullableT extends boolean> = NullableT extends true ? FieldT | null : FieldT;
/**
* Convenience type that maps the given EDM type to a field type. It also considers whether the field is nullable.
* @template EdmT - EDM type of the field. Deprecated: Field type of the field.
* @template NullableT - Boolean type that represents whether the field is nullable.
*/
export type FieldTypeByEdmType<T extends DeSerializers, EdmT extends EdmTypeShared<'any'>, NullableT extends boolean> = NullableFieldType<DeserializedType<T, EdmT>, NullableT>;
/**
* Represents a property of an OData entity with an EDM type.
*
* `EdmTypeField`s are used as static properties of entities or EDM typed fields of complex type fields. They are generated from the OData metadata, i.e. for each property of
* an OData entity, that has an EDM type, there is one static instance of `EdmTypeField` (or rather one of its subclasses) in the corresponding generated class file.
* `EdmTypeField`s are used to represent the domain of more or less primitive values that can be used in select, filter and order by functions.
* For example, when constructing a query on the BusinessPartner entity, an instance of `EdmTypeField<BusinessPartner, string>`
* can be supplied as argument to the select function, e.g. `BusinessPartner.FIRST_NAME`.
*
* See also: {@link Selectable}.
* @template EntityT - Type of the entity the field belongs to.
* @template DeSerializersT - Type of the (de-)serializers.
* @template EdmT - EDM type of the field.
* @template NullableT - Boolean type that represents whether the field is nullable.
* @template SelectableT - Boolean type that represents whether the field is selectable.
*/
export declare class EdmTypeField<EntityT extends EntityBase, DeSerializersT extends DeSerializers, EdmT extends EdmTypeShared<'any'>, NullableT extends boolean = false, SelectableT extends boolean = false> extends Field<EntityT, NullableT, SelectableT> implements EntityIdentifiable<EntityT, DeSerializersT> {
readonly _fieldOf: ConstructorOrField<EntityT>;
readonly edmType: EdmT;
_deSerializers: DeSerializersT;
readonly _entity: EntityT;
/**
* Creates an instance of EdmTypeField.
* @param fieldName - Actual name of the field used in the OData request.
* @param _fieldOf - Constructor type of the entity the field belongs to.
* @param edmType - Type of the field according to the metadata description.
* @param _deSerializers - (De-)serializers used for transformation.
* @param fieldOptions - Optional settings for this field.
*/
constructor(fieldName: string, _fieldOf: ConstructorOrField<EntityT>, edmType: EdmT, _deSerializers: DeSerializersT, // Only necessary for the type, unused otherwise
fieldOptions?: FieldOptions<NullableT, SelectableT>);
/**
* Creates an instance of Filter for this field and the given value using the operator 'eq', i.e. `==`.
* @param value - Value to be used in the filter.
* @returns The resulting filter.
*/
equals(value: FieldTypeByEdmType<DeSerializersT, EdmT, NullableT>): Filter<EntityT, DeSerializersT, FieldTypeByEdmType<DeSerializersT, EdmT, NullableT>>;
/**
* Creates an instance of Filter for this field and the given value using the operator 'ne', i.e. `!=`.
* @param value - Value to be used in the filter.
* @returns The resulting filter.
*/
notEquals(value: FieldTypeByEdmType<DeSerializersT, EdmT, NullableT>): Filter<EntityT, DeSerializersT, FieldTypeByEdmType<DeSerializersT, EdmT, NullableT>>;
/**
* Path to the field to be used in filter and order by queries.
* @returns Path to the field to be used in filter and order by queries.
*/
fieldPath(): string;
}