UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

228 lines 8.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CsdlNavigationPropertyPath = exports.CsdlPropertyPath = exports.CsdlString = exports.CsdlEnumMember = exports.CsdlPropertyValue = exports.CsdlRecord = exports.CsdlCollection = exports.CsdlTerm = exports.CsdlAnnotation = exports.CsdlAnnotations = exports.CsdlAnnotable = void 0; class CsdlAnnotable { constructor({ Annotation }) { this.Annotation = Annotation === null || Annotation === void 0 ? void 0 : Annotation.map((a) => new CsdlAnnotation(a)); } toJson() { const json = {}; if (Array.isArray(this.Annotation) && this.Annotation.length > 0) { json['Annotation'] = this.Annotation.map((a) => a.toJson()); } return json; } } exports.CsdlAnnotable = CsdlAnnotable; class CsdlAnnotations extends CsdlAnnotable { constructor(schema, { Target, Qualifier, Annotation, }) { super({ Annotation }); this.schema = schema; this.Target = Target; this.Qualifier = Qualifier; } toJson() { const json = Object.assign(Object.assign({}, super.toJson()), { Target: this.Target }); if (this.Qualifier !== undefined) { json['Qualifier'] = this.Qualifier; } return json; } } exports.CsdlAnnotations = CsdlAnnotations; class CsdlAnnotation { constructor({ Term, String, Bool, Int, Collection, Record, EnumMember, }) { this.Term = Term; this.String = String; this.Bool = Bool; this.Int = Int; this.Collection = Collection === null || Collection === void 0 ? void 0 : Collection.map((a) => new CsdlCollection(a)); this.Record = Record === null || Record === void 0 ? void 0 : Record.map((a) => new CsdlRecord(a)); this.EnumMember = EnumMember === null || EnumMember === void 0 ? void 0 : EnumMember.map((a) => new CsdlEnumMember(a)); } toJson() { const json = { Term: this.Term }; if (this.String !== undefined) { json['String'] = this.String; } if (this.Bool !== undefined) { json['Bool'] = this.Bool; } if (this.Int !== undefined) { json['Int'] = this.Int; } if (Array.isArray(this.Collection) && this.Collection.length > 0) { json['Collection'] = this.Collection.map((m) => m.toJson()); } if (Array.isArray(this.Record) && this.Record.length > 0) { json['Record'] = this.Record.map((m) => m.toJson()); } if (Array.isArray(this.EnumMember) && this.EnumMember.length > 0) { json['EnumMember'] = this.EnumMember.map((m) => m.toJson()); } return json; } } exports.CsdlAnnotation = CsdlAnnotation; class CsdlTerm { constructor(schema, { Name, Type, BaseTerm, DefaultValue, AppliesTo, Nullable, MaxLength, Precision, Scale, SRID, String, Bool, Int, }) { this.schema = schema; this.Name = Name; this.Type = Type; this.BaseTerm = BaseTerm; this.DefaultValue = DefaultValue; this.AppliesTo = AppliesTo; this.Nullable = Nullable; this.MaxLength = MaxLength; this.Precision = Precision; this.Scale = Scale; this.SRID = SRID; this.String = String; this.Bool = Bool; this.Int = Int; } toJson() { const json = { Name: this.Name, Type: this.Type }; if (this.BaseTerm !== undefined) { json['BaseTerm'] = this.BaseTerm; } if (this.DefaultValue !== undefined) { json['DefaultValue'] = this.DefaultValue; } if (this.AppliesTo !== undefined) { json['AppliesTo'] = this.AppliesTo; } if (this.Nullable !== undefined) { json['Nullable'] = this.Nullable; } 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.SRID !== undefined) { json['SRID'] = this.SRID; } if (this.String !== undefined) { json['String'] = this.String; } if (this.Bool !== undefined) { json['Bool'] = this.Bool; } if (this.Int !== undefined) { json['Int'] = this.Int; } return json; } } exports.CsdlTerm = CsdlTerm; class CsdlCollection { constructor({ String, Record, PropertyPath, NavigationPropertyPath, }) { this.String = String === null || String === void 0 ? void 0 : String.map((a) => new CsdlString(a)); this.Record = Record === null || Record === void 0 ? void 0 : Record.map((a) => new CsdlRecord(a)); this.PropertyPath = PropertyPath === null || PropertyPath === void 0 ? void 0 : PropertyPath.map((a) => new CsdlPropertyPath(a)); this.NavigationPropertyPath = NavigationPropertyPath === null || NavigationPropertyPath === void 0 ? void 0 : NavigationPropertyPath.map((a) => new CsdlNavigationPropertyPath(a)); } toJson() { const json = {}; if (Array.isArray(this.String) && this.String.length > 0) { json['String'] = this.String.map((s) => s.toJson()); } if (Array.isArray(this.Record) && this.Record.length > 0) { json['Record'] = this.Record.map((r) => r.toJson()); } if (Array.isArray(this.PropertyPath) && this.PropertyPath.length > 0) { json['PropertyPath'] = this.PropertyPath.map((p) => p.toJson()); } if (Array.isArray(this.NavigationPropertyPath) && this.NavigationPropertyPath.length > 0) { json['NavigationPropertyPath'] = this.NavigationPropertyPath.map((p) => p.toJson()); } return json; } } exports.CsdlCollection = CsdlCollection; class CsdlRecord { constructor({ PropertyValue }) { this.PropertyValue = PropertyValue === null || PropertyValue === void 0 ? void 0 : PropertyValue.map((a) => new CsdlPropertyValue(a)); } toJson() { const json = {}; if (Array.isArray(this.PropertyValue) && this.PropertyValue.length > 0) { json['PropertyValue'] = this.PropertyValue.map((p) => p.toJson()); } return json; } } exports.CsdlRecord = CsdlRecord; class CsdlPropertyValue { constructor({ Name, String, Date, EnumMember, }) { this.Name = Name; this.String = String; this.Date = Date; this.EnumMember = EnumMember === null || EnumMember === void 0 ? void 0 : EnumMember.map((a) => new CsdlEnumMember(a)); } toJson() { const json = { Name: this.Name }; if (this.String !== undefined) { json['String'] = this.String; } if (this.Date !== undefined) { json['Date'] = this.Date; } if (Array.isArray(this.EnumMember) && this.EnumMember.length > 0) { json['EnumMember'] = this.EnumMember.map((m) => m.toJson()); } return json; } } exports.CsdlPropertyValue = CsdlPropertyValue; class CsdlEnumMember { constructor({ TextContent }) { this.TextContent = TextContent; } toJson() { return { TextContent: this.TextContent, }; } } exports.CsdlEnumMember = CsdlEnumMember; class CsdlString { constructor({ TextContent }) { this.TextContent = TextContent; } toJson() { return { TextContent: this.TextContent, }; } } exports.CsdlString = CsdlString; class CsdlPropertyPath { constructor({ TextContent }) { this.TextContent = TextContent; } toJson() { return { TextContent: this.TextContent, }; } } exports.CsdlPropertyPath = CsdlPropertyPath; class CsdlNavigationPropertyPath { constructor({ TextContent }) { this.TextContent = TextContent; } toJson() { return { TextContent: this.TextContent, }; } } exports.CsdlNavigationPropertyPath = CsdlNavigationPropertyPath; //# sourceMappingURL=csdl-annotation.js.map