UNPKG

@sap-cloud-sdk/odata-common

Version:

SAP Cloud SDK for JavaScript common functions of OData client generator and OpenAPI clint generator.

53 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Field = void 0; exports.getFieldOptions = getFieldOptions; /** * Get field options merged with default values. * The given options take precedence. * @param fieldOptions - Given options. * @returns Given options merged with default values. * @internal */ function getFieldOptions(fieldOptions) { return { ...defaultFieldOptions, ...fieldOptions }; } const defaultFieldOptions = { isNullable: false, isSelectable: false, precision: 0 }; /** * Abstract representation a property of an OData entity. * * `Field`s are used as static properties of entities or properties of {@link ComplexTypeField}s and are generated from the metadata, i.e. for each property of * an OData entity, there exists one static instance of `Field` (or rather one of its subclasses) in the corresponding generated class file. * Fields are used to represent the domain of values that can be used in select, filter and order by functions. * * See also: {@link Selectable}, {@link EdmTypeField}, {@link ComplexTypeField}. * @typeParam EntityT - Type of the entity the field belongs to. * @typeParam NullableT - Boolean type that represents whether the field is nullable. * @typeParam SelectableT - Boolean type that represents whether the field is selectable. */ class Field { /** * Creates an instance of Field. * @param _fieldName - Actual name of the field used in the OData request. * @param _entityConstructor - Constructor type of the entity the field belongs to. * @param fieldOptions - Optional settings for this field. */ constructor(_fieldName, _entityConstructor, fieldOptions) { this._fieldName = _fieldName; this._entityConstructor = _entityConstructor; this._fieldOptions = getFieldOptions(fieldOptions); } /** * 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() { return this._fieldName; } } exports.Field = Field; //# sourceMappingURL=field.js.map