1 | ;
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | if (typeof b !== "function" && b !== null)
|
11 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12 | extendStatics(d, b);
|
13 | function __() { this.constructor = d; }
|
14 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15 | };
|
16 | })();
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.EdmTypeField = void 0;
|
19 | var filter_1 = require("../filter");
|
20 | var complex_type_field_1 = require("./complex-type-field");
|
21 | var field_1 = require("./field");
|
22 | /**
|
23 | * Represents a property of an OData entity with an EDM type.
|
24 | *
|
25 | * `EdmTypeField`s are used as static properties of entities or EDM typed fields of complex type fields. They are generated from the OData metadata, i.e. for each property of
|
26 | * an OData entity, that has an EDM type, there is one static instance of `EdmTypeField` (or rather one of its subclasses) in the corresponding generated class file.
|
27 | * `EdmTypeField`s are used to represent the domain of more or less primitive values that can be used in select, filter and order by functions.
|
28 | * For example, when constructing a query on the BusinessPartner entity, an instance of `EdmTypeField<BusinessPartner, string>`
|
29 | * can be supplied as argument to the select function, e.g. `BusinessPartner.FIRST_NAME`.
|
30 | *
|
31 | * See also: [[Selectable]]
|
32 | * @typeparam EntityT - Type of the entity the field belongs to
|
33 | * @typeparam EdmOrFieldT - EDM type of the field. Deprecated: Field type of the field.
|
34 | * @typeparam NullableT - Boolean type that represents whether the field is nullable.
|
35 | * @typeparam SelectableT - Boolean type that represents whether the field is selectable.
|
36 | */
|
37 | var EdmTypeField = /** @class */ (function (_super) {
|
38 | __extends(EdmTypeField, _super);
|
39 | /**
|
40 | * Creates an instance of EdmTypeField.
|
41 | * @param fieldName - Actual name of the field used in the OData request.
|
42 | * @param _fieldOf - Constructor type of the entity the field belongs to.
|
43 | * @param edmType - Type of the field according to the metadata description.
|
44 | * @param fieldOptions - Optional settings for this field.
|
45 | */
|
46 | function EdmTypeField(fieldName, _fieldOf, edmType, fieldOptions) {
|
47 | var _this = _super.call(this, fieldName, complex_type_field_1.getEntityConstructor(_fieldOf), fieldOptions) || this;
|
48 | _this._fieldOf = _fieldOf;
|
49 | _this.edmType = edmType;
|
50 | return _this;
|
51 | }
|
52 | /**
|
53 | * Creates an instance of Filter for this field and the given value using the operator 'eq', i.e. `==`.
|
54 | * @param value - Value to be used in the filter
|
55 | * @returns The resulting filter
|
56 | */
|
57 | EdmTypeField.prototype.equals = function (value) {
|
58 | return new filter_1.Filter(this.fieldPath(), 'eq', value, this.edmType);
|
59 | };
|
60 | /**
|
61 | * Creates an instance of Filter for this field and the given value using the operator 'ne', i.e. `!=`.
|
62 | * @param value - Value to be used in the filter
|
63 | * @returns The resulting filter
|
64 | */
|
65 | EdmTypeField.prototype.notEquals = function (value) {
|
66 | return new filter_1.Filter(this.fieldPath(), 'ne', value, this.edmType);
|
67 | };
|
68 | /**
|
69 | * Path to the field to be used in filter and order by queries.
|
70 | * @returns Path to the field to be used in filter and order by queries.
|
71 | */
|
72 | EdmTypeField.prototype.fieldPath = function () {
|
73 | return this._fieldOf instanceof complex_type_field_1.ComplexTypeField
|
74 | ? this._fieldOf.fieldPath() + "/" + this._fieldName
|
75 | : this._fieldName;
|
76 | };
|
77 | return EdmTypeField;
|
78 | }(field_1.Field));
|
79 | exports.EdmTypeField = EdmTypeField;
|
80 | //# sourceMappingURL=edm-type-field.js.map |
\ | No newline at end of file |