1 | ;
|
2 | var __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 | };
|
13 | Object.defineProperty(exports, "__esModule", { value: true });
|
14 | exports.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 | */
|
21 | function getFieldOptions(fieldOptions) {
|
22 | return __assign(__assign({}, defaultFieldOptions), fieldOptions);
|
23 | }
|
24 | exports.getFieldOptions = getFieldOptions;
|
25 | var 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 | */
|
41 | var 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 | }());
|
62 | exports.Field = Field;
|
63 | //# sourceMappingURL=field.js.map |
\ | No newline at end of file |