@sap-cloud-sdk/odata-common
Version:
SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.
52 lines (51 loc) • 2.75 kB
TypeScript
import { Filter } from '../filter';
import { Field } from './field';
import type { EntityBase } from '../entity-base';
import type { EdmTypeShared } from '../edm-types';
import type { DeSerializers } from '../de-serializers';
import type { FieldOptions } from './field';
import type { ConstructorOrField } from './constructor-or-field';
/**
* Represents a property with an enum value.
* @typeParam EntityT - Type of the entity the field belongs to.
* @typeParam EnumT - Enum type that contains all valid enum entries for this field.
* @typeParam NullableT - Boolean type that represents whether the field is nullable.
* @typeParam SelectableT - Boolean type that represents whether the field is selectable.
*/
export declare class EnumField<EntityT extends EntityBase, DeSerializersT extends DeSerializers, EnumT extends string = string, NullableT extends boolean = false, SelectableT extends boolean = false> extends Field<EntityT, NullableT, SelectableT> {
readonly _fieldOf: ConstructorOrField<EntityT>;
readonly enumType?: Record<string, EnumT> | undefined;
readonly edmType: EdmTypeShared<any>;
/**
* Creates an instance of EnumField.
* @param fieldName - Actual name of the field used in the OData request.
* @param _fieldOf - The constructor of the entity or the complex type field this field belongs to.
* @param enumType - Enum type of the field according to the metadata description.
* @param fieldOptions - Optional settings for this field.
*/
constructor(fieldName: string, _fieldOf: ConstructorOrField<EntityT>, enumType?: Record<string, EnumT> | undefined, fieldOptions?: FieldOptions<NullableT, SelectableT>);
/**
* Gets the path to the complex type property represented by this.
* @returns The path to the complex type property.
*/
fieldPath(): string;
/**
* 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: EnumType<EnumT>): Filter<EntityT, DeSerializersT, string>;
/**
* 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: EnumType<EnumT>): Filter<EntityT, DeSerializersT, string>;
}
/**
* Convenient type to reflect all the values of a string based enum as a union type.
* @typeParam T - String based enum type
* @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-1.html#template-literal-types
* @internal
*/
export type EnumType<T extends string> = `${T}`;