UNPKG

@finos/legend-application-pure-ide

Version:
128 lines 3.79 kB
/** * Copyright (c) 2020-present, Goldman Sachs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { guaranteeType } from '@finos/legend-shared'; import { createModelSchema, primitive, custom, SKIP, deserialize, optional, } from 'serializr'; export var ConceptType; (function (ConceptType) { // PRIMITIVE = 'Primitive', ConceptType["PACKAGE"] = "Package"; ConceptType["PROFILE"] = "Profile"; ConceptType["TAG"] = "Tag"; ConceptType["STEREOTYPE"] = "Stereotype"; ConceptType["CLASS"] = "Class"; ConceptType["ASSOCIATION"] = "Association"; ConceptType["PROPERTY"] = "Property"; ConceptType["QUALIFIED_PROPERTY"] = "QualifiedProperty"; ConceptType["ENUMERATION"] = "Enumeration"; ConceptType["ENUM_VALUE"] = "Enum"; ConceptType["MEASURE"] = "Measure"; ConceptType["UNIT"] = "Unit"; ConceptType["FUNCTION"] = "ConcreteFunctionDefinition"; ConceptType["NATIVE_FUNCTION"] = "NativeFunction"; ConceptType["DIAGRAM"] = "Diagram"; ConceptType["DATABASE"] = "Database"; ConceptType["MAPPING"] = "Mapping"; })(ConceptType || (ConceptType = {})); class ConceptAttribute { pureId; pureType; pureName; // test?: string; // boolean get id() { return this.pureId; } } export class PackageConceptAttribute extends ConceptAttribute { deprecated; } createModelSchema(PackageConceptAttribute, { pureId: primitive(), pureType: primitive(), deprecated: primitive(), }); export class PropertyConceptAttribute extends ConceptAttribute { RO; // boolean classPath; file; line; // number column; // number get id() { return `${this.classPath}.${this.pureId}`; } } createModelSchema(PropertyConceptAttribute, { pureId: primitive(), pureName: primitive(), pureType: primitive(), RO: primitive(), classPath: primitive(), file: primitive(), line: primitive(), column: primitive(), }); export class ElementConceptAttribute extends ConceptAttribute { RO; // boolean notpublic; user; // boolean file; line; // number column; // number } createModelSchema(ElementConceptAttribute, { pureId: primitive(), pureName: optional(primitive()), pureType: primitive(), RO: primitive(), notpublic: primitive(), user: primitive(), file: primitive(), line: primitive(), column: primitive(), }); export class ConceptNode { li_attr; id; text; test; pct; icon; children; state; getNodeAttribute(clazz) { return guaranteeType(this.li_attr, clazz, `Expected concept node attribute to be of type '${clazz.name}'`); } } createModelSchema(ConceptNode, { li_attr: custom(() => SKIP, (value) => { if (value.classPath) { return deserialize(PropertyConceptAttribute, value); } else if (value.file) { return deserialize(ElementConceptAttribute, value); } else { return deserialize(PackageConceptAttribute, value); } }), id: primitive(), text: primitive(), test: optional(primitive()), pct: optional(primitive()), icon: primitive(), children: primitive(), state: primitive(), }); //# sourceMappingURL=ConceptTree.js.map