angular-odata
Version:
Client side OData typescript library for Angular
103 lines • 3.97 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CsdlOnDelete = exports.CsdlReferentialConstraint = exports.CsdlNavigationProperty = exports.CsdlProperty = exports.CsdlStructuralProperty = void 0;
const csdl_annotation_1 = require("./csdl-annotation");
class CsdlStructuralProperty extends csdl_annotation_1.CsdlAnnotable {
constructor({ Name, Type, Nullable, Annotation, }) {
super({ Annotation });
this.Name = Name;
this.Nullable = Nullable;
this.Collection = Type.startsWith('Collection(');
this.Type = this.Collection ? Type.substring(11, Type.length - 1) : Type;
}
toJson() {
return Object.assign(Object.assign({}, super.toJson()), { Name: this.Name, Type: this.Collection ? `Collection(${this.Type})` : this.Type, Nullable: this.Nullable });
}
}
exports.CsdlStructuralProperty = CsdlStructuralProperty;
class CsdlProperty extends CsdlStructuralProperty {
constructor({ Name, Type, Nullable, MaxLength, Precision, Scale, Unicode, SRID, DefaultValue, Annotation, }) {
super({ Name, Type, Nullable, Annotation });
this.MaxLength = MaxLength;
this.Precision = Precision;
this.Scale = Scale;
this.Unicode = Unicode;
this.SRID = SRID;
this.DefaultValue = DefaultValue;
}
toJson() {
const json = Object.assign({}, super.toJson());
if (this.MaxLength !== undefined) {
json['MaxLength'] = this.MaxLength;
}
if (this.Precision !== undefined) {
json['Precision'] = this.Precision;
}
if (this.Scale !== undefined) {
json['Scale'] = this.Scale;
}
if (this.Unicode !== undefined) {
json['Unicode'] = this.Unicode;
}
if (this.SRID !== undefined) {
json['SRID'] = this.SRID;
}
if (this.DefaultValue !== undefined) {
json['DefaultValue'] = this.DefaultValue;
}
return json;
}
}
exports.CsdlProperty = CsdlProperty;
class CsdlNavigationProperty extends CsdlStructuralProperty {
constructor({ Name, Type, Nullable, Partner, ContainsTarget, ReferentialConstraints, OnDelete, Annotation, }) {
super({ Name, Type, Nullable, Annotation });
this.Partner = Partner;
this.ContainsTarget = ContainsTarget;
this.ReferentialConstraints = ReferentialConstraints === null || ReferentialConstraints === void 0 ? void 0 : ReferentialConstraints.map((r) => new CsdlReferentialConstraint(r));
this.OnDelete = OnDelete ? new CsdlOnDelete(OnDelete) : undefined;
}
toJson() {
const json = Object.assign({}, super.toJson());
if (this.Partner !== undefined) {
json['Partner'] = this.Partner;
}
if (this.ContainsTarget !== undefined) {
json['ContainsTarget'] = this.ContainsTarget;
}
if (Array.isArray(this.ReferentialConstraints) &&
this.ReferentialConstraints.length > 0) {
json['ReferentialConstraints'] = this.ReferentialConstraints.map((r) => r.toJson());
}
if (this.OnDelete !== undefined) {
json['OnDelete'] = this.OnDelete;
}
return json;
}
}
exports.CsdlNavigationProperty = CsdlNavigationProperty;
class CsdlReferentialConstraint {
constructor({ Property, ReferencedProperty, }) {
this.Property = Property;
this.ReferencedProperty = ReferencedProperty;
}
toJson() {
return {
Property: this.Property,
ReferencedProperty: this.ReferencedProperty,
};
}
}
exports.CsdlReferentialConstraint = CsdlReferentialConstraint;
class CsdlOnDelete {
constructor({ Action }) {
this.Action = Action;
}
toJson() {
return {
Action: this.Action,
};
}
}
exports.CsdlOnDelete = CsdlOnDelete;
//# sourceMappingURL=csdl-structural-property.js.map