UNPKG

@sap-cloud-sdk/core

Version:
63 lines 2.6 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Field = exports.getFieldOptions = void 0; /** * Get field options merged with default values. * The given options take precedence. * @param fieldOptions - Given options. * @returns Given options merged with default values. */ function getFieldOptions(fieldOptions) { return __assign(__assign({}, defaultFieldOptions), fieldOptions); } exports.getFieldOptions = getFieldOptions; var defaultFieldOptions = { isNullable: false, isSelectable: false }; /** * Abstract representation a property of an OData entity. * * `Field`s are used as static properties of entities or properties of [[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: [[Selectable]], [[EdmTypeField]], [[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. */ var Field = /** @class */ (function () { /** * 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. */ function Field(_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. */ Field.prototype.fieldPath = function () { return this._fieldName; }; return Field; }()); exports.Field = Field; //# sourceMappingURL=field.js.map