UNPKG

2.6 kBJavaScriptView Raw
1"use strict";
2var __assign = (this && this.__assign) || function () {
3 __assign = Object.assign || function(t) {
4 for (var s, i = 1, n = arguments.length; i < n; i++) {
5 s = arguments[i];
6 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7 t[p] = s[p];
8 }
9 return t;
10 };
11 return __assign.apply(this, arguments);
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14exports.Field = exports.getFieldOptions = void 0;
15/**
16 * Get field options merged with default values.
17 * The given options take precedence.
18 * @param fieldOptions - Given options.
19 * @returns Given options merged with default values.
20 */
21function getFieldOptions(fieldOptions) {
22 return __assign(__assign({}, defaultFieldOptions), fieldOptions);
23}
24exports.getFieldOptions = getFieldOptions;
25var defaultFieldOptions = {
26 isNullable: false,
27 isSelectable: false
28};
29/**
30 * Abstract representation a property of an OData entity.
31 *
32 * `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
33 * an OData entity, there exists one static instance of `Field` (or rather one of its subclasses) in the corresponding generated class file.
34 * Fields are used to represent the domain of values that can be used in select, filter and order by functions.
35 *
36 * See also: [[Selectable]], [[EdmTypeField]], [[ComplexTypeField]]
37 * @typeparam EntityT - Type of the entity the field belongs to.
38 * @typeparam NullableT - Boolean type that represents whether the field is nullable.
39 * @typeparam SelectableT - Boolean type that represents whether the field is selectable.
40 */
41var Field = /** @class */ (function () {
42 /**
43 * Creates an instance of Field.
44 * @param _fieldName - Actual name of the field used in the OData request
45 * @param _entityConstructor - Constructor type of the entity the field belongs to
46 * @param fieldOptions - Optional settings for this field.
47 */
48 function Field(_fieldName, _entityConstructor, fieldOptions) {
49 this._fieldName = _fieldName;
50 this._entityConstructor = _entityConstructor;
51 this._fieldOptions = getFieldOptions(fieldOptions);
52 }
53 /**
54 * Path to the field to be used in filter and order by queries.
55 * @returns Path to the field to be used in filter and order by queries.
56 */
57 Field.prototype.fieldPath = function () {
58 return this._fieldName;
59 };
60 return Field;
61}());
62exports.Field = Field;
63//# sourceMappingURL=field.js.map
\No newline at end of file