UNPKG

angular-odata

Version:

Client side OData typescript library for Angular

78 lines 2.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ODataMetadata = void 0; const csdl_reference_1 = require("./csdl/csdl-reference"); const csdl_schema_1 = require("./csdl/csdl-schema"); class ODataMetadata { constructor(Version, References, Schemas) { this.Version = Version; this.References = References === null || References === void 0 ? void 0 : References.map((r) => new csdl_reference_1.CsdlReference(r)); this.Schemas = Schemas === null || Schemas === void 0 ? void 0 : Schemas.map((s) => new csdl_schema_1.CsdlSchema(s)); } toJson() { return { Version: this.Version, References: this.References.map((r) => r.toJson()), Schemas: this.Schemas.map((s) => s.toJson()), }; } static fromJson(json) { return new ODataMetadata(json.Version, json.References, json.Schemas); } functions() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.Function) !== null && _a !== void 0 ? _a : [])]; }, []); } actions() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.Action) !== null && _a !== void 0 ? _a : [])]; }, []); } enumTypes() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.EnumType) !== null && _a !== void 0 ? _a : [])]; }, []); } entityTypes() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.EntityType) !== null && _a !== void 0 ? _a : [])]; }, []); } complexTypes() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.ComplexType) !== null && _a !== void 0 ? _a : [])]; }, []); } entitySets() { return this.Schemas.reduce((acc, s) => { var _a; return [...acc, ...((_a = s.EntityContainer) !== null && _a !== void 0 ? _a : [])]; }, []).reduce((acc, ec) => { var _a; return [...acc, ...((_a = ec.EntitySet) !== null && _a !== void 0 ? _a : [])]; }, []); } findEnumType(fullName) { return this.enumTypes().find((et) => et.fullName() === fullName); } findEntityType(fullName) { var _a; return (_a = this.entityTypes()) === null || _a === void 0 ? void 0 : _a.find((et) => et.fullName() === fullName); } findComplexType(fullName) { var _a; return (_a = this.complexTypes()) === null || _a === void 0 ? void 0 : _a.find((ct) => ct.fullName() === fullName); } findEntitySet(fullName) { var _a; return (_a = this.entitySets()) === null || _a === void 0 ? void 0 : _a.find((ct) => ct.EntityType === fullName); } } exports.ODataMetadata = ODataMetadata; //# sourceMappingURL=metadata.js.map