@itwin/ecschema2ts 5.0.0-dev.89 → 5.0.0-dev.90
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/ecschema2ts.js
CHANGED
|
@@ -177,7 +177,7 @@ class ECSchemaToTs {
|
|
|
177
177
|
if (ecClass.fullName === elementECClassName)
|
|
178
178
|
return interfacesTs;
|
|
179
179
|
// only generate props interface for entity if the class has properties
|
|
180
|
-
if (ecClass.schemaItemType === ecschema_metadata_1.SchemaItemType.EntityClass &&
|
|
180
|
+
if (ecClass.schemaItemType === ecschema_metadata_1.SchemaItemType.EntityClass && !ecClass.hasLocalProperties)
|
|
181
181
|
return interfacesTs;
|
|
182
182
|
// convert description to typescript comment only for mixin or struct
|
|
183
183
|
if (ecClass.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass && ecClass.description)
|
|
@@ -249,7 +249,7 @@ class ECSchemaToTs {
|
|
|
249
249
|
// determine prop type to pass in the constructor
|
|
250
250
|
let propsBaseTsType;
|
|
251
251
|
const propsBase = this.getBaseClassWithProps(ecClass);
|
|
252
|
-
if (ecClass.fullName !== elementECClassName && ecClass.
|
|
252
|
+
if (ecClass.fullName !== elementECClassName && ecClass.hasLocalProperties) {
|
|
253
253
|
const moduleName = `${this._schema.schemaKey.name}ElementProps`;
|
|
254
254
|
propsBaseTsType = this.addImportClass(classNameToModule, moduleName, `${ecClass.name}Props`);
|
|
255
255
|
}
|
|
@@ -276,10 +276,10 @@ class ECSchemaToTs {
|
|
|
276
276
|
* @param classNameToModule Typescrip modules to be updated after the conversion
|
|
277
277
|
*/
|
|
278
278
|
convertPropsToTsVars(ecClass, classNameToModule) {
|
|
279
|
-
if (ecClass.
|
|
279
|
+
if (!ecClass.hasLocalProperties)
|
|
280
280
|
return [];
|
|
281
281
|
const outputStrings = [];
|
|
282
|
-
for (const ecProperty of ecClass.
|
|
282
|
+
for (const ecProperty of ecClass.getPropertiesSync(true)) {
|
|
283
283
|
// not generate ts variable declaration for property that has CustomHandledProperty ca
|
|
284
284
|
if (ecProperty.customAttributes && ecProperty.customAttributes.has(customHandledPropertyCA))
|
|
285
285
|
continue;
|
|
@@ -432,7 +432,7 @@ class ECSchemaToTs {
|
|
|
432
432
|
const visited = new Set();
|
|
433
433
|
visited.add(ecClass.fullName);
|
|
434
434
|
this.traverseBaseClass(ecClass, visited, (base) => {
|
|
435
|
-
if (base.
|
|
435
|
+
if (base.hasLocalProperties) {
|
|
436
436
|
res.push(base);
|
|
437
437
|
return false;
|
|
438
438
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecschema2ts.js","sourceRoot":"","sources":["../../src/ecschema2ts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gEAEkC;AAOlC,MAAM,uBAAuB,GAAW,+BAA+B,CAAC;AACxE,MAAM,kBAAkB,GAAW,iBAAiB,CAAC;AACrD,MAAM,gBAAgB,GAAyC;IAC7D,gBAAgB,EAAE;QAChB,UAAU,EAAE,oBAAoB;QAChC,oBAAoB,EAAE,kBAAkB;KACzC;IACD,iBAAiB,EAAE;QACjB,UAAU,EAAE,qBAAqB;QACjC,oBAAoB,EAAE,mBAAmB;KAC1C;IACD,cAAc,EAAE;QACd,UAAU,EAAE,sBAAsB;QAClC,oBAAoB,EAAE,gBAAgB;KACvC;IACD,eAAe,EAAE;QACf,UAAU,EAAE,qBAAqB;QACjC,oBAAoB,EAAE,iBAAiB;KACxC;CACF,CAAC;AAEF;;GAEG;AACH,MAAa,YAAY;IACf,qBAAqB,CAAc;IACnC,qCAAqC,CAAsB;IAC3D,OAAO,CAAU;IACjB,eAAe,CAAe;IAEtC;QACE,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAE1B,IAAI,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAU,CAAC;QAC/C,IAAI,CAAC,qCAAqC,GAAG,IAAI,GA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cAAc,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,CAAC;aAC5D,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;YAC5E,cAAc,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;QAElE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;YAC7B,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;QAE9E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAC,QAAgB;QACxC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAllBD,oCAklBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport {\n ECClass, ECClassModifier, EntityClass, Enumeration, EnumerationProperty, Mixin, PrimitiveProperty, PrimitiveType, Schema, SchemaItem, SchemaItemType, StructClass, StructProperty,\n} from \"@itwin/ecschema-metadata\";\n\ninterface TsBentleyModule {\n moduleName: string;\n resolvedConflictName: string;\n}\n\nconst customHandledPropertyCA: string = \"BisCore.CustomHandledProperty\";\nconst elementECClassName: string = \"BisCore.Element\";\nconst tsBentleyModules: { [index: string]: TsBentleyModule } = {\n tsIModelJsCommon: {\n moduleName: \"@itwin/core-common\",\n resolvedConflictName: \"BeIModelJsCommon\",\n },\n tsIModelJsBackend: {\n moduleName: \"@itwin/core-backend\",\n resolvedConflictName: \"BeIModelJsBackend\",\n },\n tsGeometryCore: {\n moduleName: \"@itwin/core-geometry\",\n resolvedConflictName: \"BeGeometryCore\",\n },\n tsBentleyJsCore: {\n moduleName: \"@itwin/core-bentley\",\n resolvedConflictName: \"BeBentleyJsCore\",\n },\n};\n\n/**\n * @beta\n */\nexport class ECSchemaToTs {\n private _tsBentleyModuleNames: Set<string>;\n private _tsBentleyModuleResolvedConflictNames: Map<string, string>;\n private _schema?: Schema;\n private _schemaItemList: SchemaItem[];\n\n public constructor() {\n this._schema = undefined;\n this._schemaItemList = [];\n\n this._tsBentleyModuleNames = new Set<string>();\n this._tsBentleyModuleResolvedConflictNames = new Map<string, string>();\n for (const key in tsBentleyModules) {\n if (tsBentleyModules.hasOwnProperty(key)) {\n const moduleName: string = tsBentleyModules[key].moduleName;\n const resolvedPrefix: string = tsBentleyModules[key].resolvedConflictName;\n this._tsBentleyModuleNames.add(moduleName);\n this._tsBentleyModuleResolvedConflictNames.set(moduleName, resolvedPrefix);\n }\n }\n }\n\n /**\n * Given the schema, the function will converted it to typescript strings\n * @param schema The schema to be converted to typescript strings\n */\n public convertSchemaToTs(schema: Schema): { schemaTsString: string, elemTsString: string, propsTsString: string } {\n // convert schema to typescript String\n this._schema = schema;\n this.dependencyToFront();\n const schemaTsString = this.convertSchemaToTsClass();\n const elemTsString = this.convertElemToTsClasses();\n const propsTsString = this.convertPropsToTsInterfaces();\n\n return { schemaTsString, elemTsString, propsTsString };\n }\n\n /**\n * The function will push all the base classes to be the first ones in the schema item list.\n * For example, if class A extends base class B and base class C, B and C will be on the first of the list and then A at the end.\n * If B extends C, then B will be first and C will be next in the list and then A at the end.\n * If B and C does not depend on each other, the order of B and C will not be important.\n * The arrangement is to make sure that base class will be converted first and then, derived classes and so on\n */\n private dependencyToFront(): void {\n const uniqueItemName: Set<string> = new Set<string>();\n const schemaItemsList: SchemaItem[] = [];\n for (const schemaItem of this._schema!.getItems()) {\n // base class to the item list first;\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.StructClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.EntityClass:\n const ecClass = schemaItem as ECClass;\n const baseList = this.getAllBaseClasses(ecClass);\n for (let i = baseList.length - 1; i >= 0; --i) {\n const base = baseList[i];\n if (base.schema.schemaKey.compareByName(this._schema!.schemaKey) && !uniqueItemName.has(base.name)) {\n schemaItemsList.push(baseList[i]);\n uniqueItemName.add(base.name);\n }\n }\n break;\n default:\n break;\n }\n\n if (!uniqueItemName.has(schemaItem.name)) {\n uniqueItemName.add(schemaItem.name);\n schemaItemsList.push(schemaItem);\n }\n }\n\n this._schemaItemList = schemaItemsList;\n }\n\n /**\n * The function converts the schema meta data to typescript Schema class\n */\n private convertSchemaToTsClass(): string {\n const schemaName = this._schema!.schemaKey.name;\n let outputString: string = \"\";\n\n // import modules\n outputString += \"import { ClassRegistry, Schema, Schemas } from \\\"@itwin/core-backend\\\";\\n\";\n outputString += `import * as elementsModule from \"./${schemaName}Elements\";\\n\\n`;\n\n // create new schema class\n outputString += `export class ${schemaName} extends Schema {\\n`;\n\n // schemaName() method\n outputString += ` public static get schemaName(): string { return \"${schemaName}\"; }\\n\\n`;\n\n // registerSchema method\n outputString += \" public static registerSchema() {\\n\";\n outputString += ` if (!Schemas.getRegisteredSchema(${schemaName}.name))\\n`;\n outputString += ` Schemas.registerSchema(${schemaName});\\n`;\n outputString += \" }\\n\\n\";\n\n // constructor\n outputString += \" protected constructor() {\\n\";\n outputString += \" super();\\n\";\n outputString += ` ClassRegistry.registerModule(elementsModule, ${schemaName});\\n`;\n outputString += \" }\\n\";\n\n outputString += \"}\\n\\n\";\n\n return outputString;\n }\n\n /**\n * The function converts the schema item to respective typescript classes\n */\n private convertElemToTsClasses(): string {\n const classNameToModule: Map<string, string> = new Map<string, string>();\n let classTs: string = \"\";\n for (const schemaItem of this._schemaItemList) {\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.EntityClass:\n classTs += this.convertEntityToTs(schemaItem as EntityClass, classNameToModule);\n break;\n case SchemaItemType.Enumeration:\n classTs += this.convertEnumToTs(schemaItem as Enumeration);\n break;\n default:\n continue;\n }\n }\n\n let outputString: string = this.convertImportToTsImport(classNameToModule);\n outputString += `\\n${classTs}`;\n return outputString;\n }\n\n /**\n * The function converts the schema item properties to respective typescript props interfaces\n */\n private convertPropsToTsInterfaces(): string {\n const classNameToModule: Map<string, string> = new Map<string, string>();\n let interfacesTs: string = \"\";\n for (const schemaItem of this._schemaItemList) {\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n interfacesTs += this.convertECClassPropsToTsInterface(schemaItem as (Mixin | StructClass | EntityClass), classNameToModule);\n break;\n default:\n continue;\n }\n }\n\n let outputString: string = this.convertImportToTsImport(classNameToModule);\n outputString += `\\n${interfacesTs}`;\n return outputString;\n }\n\n /**\n * Convert mixin or struct class or entity class to respective typescript interface\n * @param ecClass Schema mixin or struct or entity to be converted typescript interface\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertECClassPropsToTsInterface(ecClass: Mixin | StructClass | EntityClass, classNameToModule: Map<string, string>): string {\n let interfacesTs: string = \"\";\n\n // no interface props for BisCore Element\n if (ecClass.fullName === elementECClassName)\n return interfacesTs;\n\n // only generate props interface for entity if the class has properties\n if (ecClass.schemaItemType === SchemaItemType.EntityClass && (!ecClass.properties || ecClass.properties.next().done))\n return interfacesTs;\n\n // convert description to typescript comment only for mixin or struct\n if (ecClass.schemaItemType !== SchemaItemType.EntityClass && ecClass.description)\n interfacesTs += `${this.convertDescriptionToTsComment(ecClass.description)}\\n`;\n\n // build interface for props in ecClass\n interfacesTs += `export interface ${ecClass.name}`;\n if (ecClass.schemaItemType === SchemaItemType.EntityClass)\n interfacesTs += \"Props\";\n\n // Extend it with base ecClass Props interface if there is any\n const baseClasses = this.getBaseClassWithProps(ecClass);\n if (baseClasses.length > 0) {\n interfacesTs += \" extends \";\n\n let separator = \"\";\n for (const base of baseClasses) {\n interfacesTs += separator + this.addImportBasePropsClass(classNameToModule, base, ecClass);\n separator = \", \";\n }\n } else if (ecClass.schemaItemType === SchemaItemType.EntityClass)\n interfacesTs += ` extends ${this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"EntityProps\")}`;\n\n // build props for ecClass\n interfacesTs += \" {\";\n const propertiesTs = this.convertPropsToTsVars(ecClass, classNameToModule);\n for (const varDeclarationLine of propertiesTs)\n interfacesTs += `\\n ${varDeclarationLine}`;\n interfacesTs += \"\\n}\\n\\n\";\n\n return interfacesTs;\n }\n\n /**\n * Convert schema enumeration to typescript enumeration\n * @param ecEnum Schema enumeration to be converted to typescript enumeration\n */\n private convertEnumToTs(ecEnum: Enumeration): string {\n let outputString: string = \"\";\n if (ecEnum.description)\n outputString += `${this.convertDescriptionToTsComment(ecEnum.description)}\\n`;\n\n outputString += `export const enum ${ecEnum.name} {\\n`;\n for (const ecEnumerator of ecEnum.enumerators) {\n outputString += ` ${ecEnumerator.label}`;\n if (ecEnum.isInt)\n outputString += ` = ${ecEnumerator.value}`;\n else if (ecEnum.isString)\n outputString += ` = \"${ecEnumerator.value}\"`;\n outputString += \",\\n\";\n }\n\n outputString += \"}\\n\\n\";\n return outputString;\n }\n\n /**\n * Convert schema entity to typescript entity class. The typescript class will implement respective props\n * typescript interface if the schema entity class has properties\n * @param ecClass Schema class to be converted to typescript class\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertEntityToTs(ecClass: EntityClass, classNameToModule: Map<string, string>): string {\n let outputString: string = \"\";\n if (ecClass.description)\n outputString += `${this.convertDescriptionToTsComment(ecClass.description)}\\n`;\n\n let modifier: string = \"\";\n if (ecClass.modifier === ECClassModifier.Abstract)\n modifier = \"abstract \";\n outputString += `export ${modifier}class ${ecClass.name} extends `;\n\n // extend base class if there is any. Default will be Entity class defined in @itwin/core-backend\n const base = ecClass.getBaseClassSync();\n if (base)\n outputString += this.addImportBaseClass(classNameToModule, base, ecClass);\n else\n outputString += this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsBackend.moduleName, \"Entity\");\n\n // determine prop type to pass in the constructor\n let propsBaseTsType: string;\n const propsBase = this.getBaseClassWithProps(ecClass);\n if (ecClass.fullName !== elementECClassName && ecClass.properties && !ecClass.properties.next().done) {\n const moduleName: string = `${this._schema!.schemaKey.name}ElementProps`;\n propsBaseTsType = this.addImportClass(classNameToModule, moduleName, `${ecClass.name}Props`);\n } else if (propsBase.length > 0)\n propsBaseTsType = this.addImportBasePropsClass(classNameToModule, propsBase[0], ecClass);\n else\n propsBaseTsType = this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"EntityProps\");\n\n // implement the ecClass props if it has properties\n if (`${ecClass.name}Props` === propsBaseTsType)\n outputString += ` implements ${propsBaseTsType}`;\n\n // write constructor and className function for class\n const iModelDbTsType: string = this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsBackend.moduleName, \"IModelDb\");\n\n outputString += \" {\\n\";\n outputString += ` public static get className(): string { return \"${ecClass.name}\"; }\\n\\n`;\n outputString += ` public constructor (props: ${propsBaseTsType}, iModel: ${iModelDbTsType}) {\\n`;\n outputString += \" super(props, iModel);\\n\";\n outputString += \" }\\n\";\n outputString += \"}\\n\\n\";\n\n return outputString;\n }\n\n /**\n * Convert class properties to typescript member declaration\n * @param ecClass The schema class that has the properties to be converted to typescript member variables\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertPropsToTsVars(ecClass: ECClass, classNameToModule: Map<string, string>): string[] {\n if (ecClass.properties === undefined || ecClass.properties.next().done)\n return [];\n\n const outputStrings: string[] = [];\n for (const ecProperty of ecClass.properties) {\n // not generate ts variable declaration for property that has CustomHandledProperty ca\n if (ecProperty.customAttributes && ecProperty.customAttributes.has(customHandledPropertyCA))\n continue;\n\n let varDeclarationLine: string = `${this.lowerPropertyName(ecProperty.name)}?: `;\n if (ecProperty.isPrimitive()) {\n // determine Ts type of the primitive\n let typeTs: string = \"\";\n if (ecProperty.extendedTypeName)\n typeTs = this.convertExtendedTypeNameToTsType(ecProperty.extendedTypeName, classNameToModule);\n else if (ecProperty.isEnumeration()) {\n const ecEnumProperty = ecProperty as EnumerationProperty;\n const ecEnum = ecEnumProperty.enumeration!;\n typeTs = this.addImportClass(classNameToModule, `${ecEnum.schemaKey.name}Elements`, ecEnum.name);\n } else {\n const ecPrimitiveProperty = ecProperty as PrimitiveProperty;\n typeTs = this.convertPrimitiveTypeToTsType(ecPrimitiveProperty.primitiveType, classNameToModule);\n }\n\n varDeclarationLine += typeTs;\n } else if (ecProperty.isStruct()) {\n // import struct class if it is in different schema\n const ecStructProperty = ecProperty as StructProperty;\n const structClass = ecStructProperty.structClass;\n if (!structClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n varDeclarationLine += this.addImportClass(classNameToModule, `${structClass.schema.schemaKey.name}ElementProps`, structClass.name);\n else\n varDeclarationLine += structClass.name;\n\n } else if (ecProperty.isNavigation())\n varDeclarationLine += this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"RelatedElementProps\");\n\n if (ecProperty.isArray())\n varDeclarationLine += \"[]\";\n varDeclarationLine += \";\";\n\n outputStrings.push(varDeclarationLine);\n }\n\n return outputStrings;\n }\n\n /**\n * Convert schema extended type to typescript type\n * @param typeName Schema extended type to be converted to typescript type\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertExtendedTypeNameToTsType(typeName: string, classNameToModule: Map<string, string>): string {\n switch (typeName) {\n case \"Json\":\n return \"any\";\n case \"BeGuid\":\n return this.addImportClass(classNameToModule, tsBentleyModules.tsBentleyJsCore.moduleName, \"GuidString\");\n default:\n return \"any\";\n }\n }\n\n /**\n * Convert schema primitive type to typescript type\n * @param type Schema primitive type to be converted to typescript type\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertPrimitiveTypeToTsType(type: PrimitiveType, classNameToModule: Map<string, string>) {\n switch (type) {\n case PrimitiveType.Binary:\n return \"any\";\n case PrimitiveType.Boolean:\n return \"boolean\";\n case PrimitiveType.DateTime:\n return \"Date\";\n case PrimitiveType.Double:\n return \"number\";\n case PrimitiveType.Integer:\n return \"number\";\n case PrimitiveType.Long:\n // eslint-disable-next-line no-console\n console.log(\"Primitive type Long is not currently supported during conversion. It will be treated as type 'any'\");\n return \"any\";\n case PrimitiveType.String:\n return \"string\";\n case PrimitiveType.Point2d:\n return this.addImportClass(classNameToModule, tsBentleyModules.tsGeometryCore.moduleName, \"Point2d\");\n case PrimitiveType.Point3d:\n return this.addImportClass(classNameToModule, tsBentleyModules.tsGeometryCore.moduleName, \"Point3d\");\n case PrimitiveType.IGeometry:\n // eslint-disable-next-line no-console\n console.log(\"Primitive type IGeometry is not currently supported during conversion. It will be treated as type 'any'\");\n return \"any\";\n default:\n // eslint-disable-next-line no-console\n console.log(\"Unknown primitive type during conversion. It will be treated as type 'any'\");\n return \"any\";\n }\n }\n\n /**\n * Convert schema description to typescript comment\n * @param description Schema description to be converted to typescript comment\n */\n private convertDescriptionToTsComment(description: string) {\n let outputString: string = \"/**\\n\";\n\n let wordCount: number = 0;\n let begin: number = 0;\n let spaceBegin: number = 0;\n let spaceIdx: number = description.indexOf(\" \", spaceBegin);\n while (spaceIdx !== -1) {\n // new line for every 20 words\n ++wordCount;\n if (wordCount === 20) {\n wordCount = 0;\n outputString += ` * ${description.substring(begin, spaceIdx)}\\n`;\n begin = spaceIdx + 1;\n }\n\n spaceBegin = spaceIdx + 1;\n while (description[spaceBegin] === \" \")\n ++spaceBegin;\n\n spaceIdx = description.indexOf(\" \", spaceBegin);\n }\n\n // append the last word\n outputString += ` * ${description.substring(begin)}\\n`;\n\n outputString += \" */\";\n return outputString;\n }\n\n /**\n * Convert all modules needed for the converted schema types to typescript import statements\n * @param classNameToModule Modules to be converted to typescript imports statement\n */\n private convertImportToTsImport(classNameToModule: Map<string, string>): string {\n const moduleToTsTypes: Map<string, Set<string>> = new Map<string, Set<string>>();\n classNameToModule.forEach((moduleNames: string, className: string) => {\n if (!moduleToTsTypes.has(moduleNames))\n moduleToTsTypes.set(moduleNames, new Set<string>());\n\n moduleToTsTypes.get(moduleNames)!.add(className);\n });\n\n let outputString: string = \"\";\n moduleToTsTypes.forEach((classNames: Set<string>, moduleName: string) => {\n if (!this._tsBentleyModuleNames.has(moduleName))\n moduleName = `./${moduleName}`;\n\n outputString += \"import { \";\n let separator = \"\";\n for (const className of classNames) {\n outputString += separator + className;\n separator = \", \";\n }\n outputString += ` } from \"${moduleName}\";\\n`;\n });\n\n return outputString;\n }\n\n /**\n * Traverse the inheritance tree to retrieve first base classes that have properties\n * @param ecClass Schema class to be traverse\n */\n private getBaseClassWithProps(ecClass: ECClass): ECClass[] {\n const res: ECClass[] = [];\n const visited: Set<string> = new Set<string>();\n visited.add(ecClass.fullName);\n this.traverseBaseClass(ecClass, visited, (base: ECClass) => {\n if (base.properties && !base.properties.next().done) {\n res.push(base);\n return false;\n }\n\n return true;\n });\n\n return res;\n }\n\n /**\n * Traverse the inheritance tree to retrieve base classes of a schema class\n * @param ecClass Schema class to be traverse\n */\n private getAllBaseClasses(ecClass: ECClass): ECClass[] {\n const res: ECClass[] = [];\n const visited: Set<string> = new Set<string>();\n visited.add(ecClass.fullName);\n this.traverseBaseClass(ecClass, visited, (base: ECClass) => {\n res.push(base);\n return true;\n });\n\n return res;\n }\n\n /**\n * Traverse the inheritance tree horizontally and vertically of a schema class\n * @param ecClass Schema class to be traverse\n * @param visited Set of classes that are already visited\n * @param shouldTraverseDown Lambda to determine if it should traverse more vertically\n */\n private traverseBaseClass(ecClass: ECClass, visited: Set<string>, shouldTraverseDown: (base: ECClass) => boolean): void {\n const base = ecClass.getBaseClassSync();\n if (base === undefined || visited.has(base.fullName))\n return;\n\n const baseList: ECClass[] = [base];\n if (ecClass.schemaItemType === SchemaItemType.EntityClass) {\n const entity = ecClass as EntityClass;\n for (const mixin of entity.getMixinsSync())\n baseList.push(mixin);\n }\n\n for (const eachBase of baseList) {\n visited.add(eachBase.fullName);\n if (shouldTraverseDown(eachBase))\n this.traverseBaseClass(eachBase, visited, shouldTraverseDown);\n }\n }\n\n /**\n * Add required typescript class that is to be imported from a required module during Schema conversion to typescript. If there is naming conflict\n * it will resolve it by appending prefix name with class name, for example: import { element as BisCoreElement } from \"BisCoreElement\";\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param refModule Typescript module that the typescrip class comes from\n * @param className Required Typescript class for the conversion\n */\n private addImportClass(classNameToModule: Map<string, string>, refModule: string, className: string): string {\n if (!classNameToModule.has(className)) {\n classNameToModule.set(className, refModule);\n return className;\n }\n\n if (classNameToModule.get(className) === refModule)\n return className;\n\n let resolvedPrefix: string = refModule;\n if (this._tsBentleyModuleResolvedConflictNames.has(refModule))\n resolvedPrefix = this._tsBentleyModuleResolvedConflictNames.get(refModule)!;\n\n const renameClassName = `${className} as ${resolvedPrefix}${className}`;\n if (!classNameToModule.has(renameClassName)) {\n classNameToModule.set(renameClassName, refModule);\n }\n\n return resolvedPrefix + className;\n }\n\n /**\n * Add appropriate typescript props interface to the classNameToModule and return the corresponding typescript base props interface\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param baseECClass Base class of ecClass that has properties. Its name will be used to derived typescript base props interface\n * @param ecClass ECClass to be converted to Typescript\n */\n private addImportBasePropsClass(classNameToModule: Map<string, string>, baseECClass: ECClass, ecClass: ECClass): string {\n let baseName: string = baseECClass.name;\n if (baseECClass.schemaItemType === SchemaItemType.EntityClass)\n baseName += \"Props\";\n\n // find external module to import\n let externalModule: string = \"\";\n const shouldImportJsCommon = (baseECClass.fullName === elementECClassName) ||\n (baseECClass.schema.schemaKey.name === \"BisCore\" && ecClass.schema.schemaKey.name !== \"BisCore\");\n if (shouldImportJsCommon)\n externalModule = tsBentleyModules.tsIModelJsCommon.moduleName;\n else if (!baseECClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n externalModule = `${baseECClass.schema.schemaKey.name}ElementProps`;\n\n if (externalModule.length !== 0)\n baseName = this.addImportClass(classNameToModule, externalModule, baseName);\n\n return baseName;\n }\n\n /**\n * Add appropriate typescript base class to the classNameToModule and return the corresponding typescript base class\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param baseECClass Base class of ecClass\n * @param ecClass ECClass to be converted to Typescript\n */\n private addImportBaseClass(classNameToModule: Map<string, string>, baseECClass: ECClass, ecClass: ECClass): string {\n let baseName: string = baseECClass.name;\n\n // find external module to import for base class\n let externalModule: string = \"\";\n if (baseECClass.schema.schemaKey.name === \"BisCore\" && ecClass.schema.schemaKey.name !== \"BisCore\")\n externalModule = tsBentleyModules.tsIModelJsBackend.moduleName;\n else if (!baseECClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n externalModule = `${baseECClass.schema.schemaKey.name}Elements`;\n\n if (externalModule.length !== 0)\n baseName = this.addImportClass(classNameToModule, externalModule, baseName);\n\n return baseName;\n }\n\n /**\n * Lower the first character of the property name\n * @param propName Property name\n */\n private lowerPropertyName(propName: string): string {\n return propName.charAt(0).toLowerCase() + propName.slice(1);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ecschema2ts.js","sourceRoot":"","sources":["../../src/ecschema2ts.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,gEAEkC;AAOlC,MAAM,uBAAuB,GAAW,+BAA+B,CAAC;AACxE,MAAM,kBAAkB,GAAW,iBAAiB,CAAC;AACrD,MAAM,gBAAgB,GAAyC;IAC7D,gBAAgB,EAAE;QAChB,UAAU,EAAE,oBAAoB;QAChC,oBAAoB,EAAE,kBAAkB;KACzC;IACD,iBAAiB,EAAE;QACjB,UAAU,EAAE,qBAAqB;QACjC,oBAAoB,EAAE,mBAAmB;KAC1C;IACD,cAAc,EAAE;QACd,UAAU,EAAE,sBAAsB;QAClC,oBAAoB,EAAE,gBAAgB;KACvC;IACD,eAAe,EAAE;QACf,UAAU,EAAE,qBAAqB;QACjC,oBAAoB,EAAE,iBAAiB;KACxC;CACF,CAAC;AAEF;;GAEG;AACH,MAAa,YAAY;IACf,qBAAqB,CAAc;IACnC,qCAAq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AAI,KAAK,SAAS;YAChG,cAAc,GAAG,gBAAgB,CAAC,iBAAiB,CAAC,UAAU,CAAC;aAC5D,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC;YAC5E,cAAc,GAAG,GAAG,WAAW,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC;QAElE,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC;YAC7B,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,EAAE,cAAc,EAAE,QAAQ,CAAC,CAAC;QAE9E,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;OAGG;IACK,iBAAiB,CAAC,QAAgB;QACxC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AAllBD,oCAklBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n\nimport {\n ECClass, ECClassModifier, EntityClass, Enumeration, EnumerationProperty, Mixin, PrimitiveProperty, PrimitiveType, Schema, SchemaItem, SchemaItemType, StructClass, StructProperty,\n} from \"@itwin/ecschema-metadata\";\n\ninterface TsBentleyModule {\n moduleName: string;\n resolvedConflictName: string;\n}\n\nconst customHandledPropertyCA: string = \"BisCore.CustomHandledProperty\";\nconst elementECClassName: string = \"BisCore.Element\";\nconst tsBentleyModules: { [index: string]: TsBentleyModule } = {\n tsIModelJsCommon: {\n moduleName: \"@itwin/core-common\",\n resolvedConflictName: \"BeIModelJsCommon\",\n },\n tsIModelJsBackend: {\n moduleName: \"@itwin/core-backend\",\n resolvedConflictName: \"BeIModelJsBackend\",\n },\n tsGeometryCore: {\n moduleName: \"@itwin/core-geometry\",\n resolvedConflictName: \"BeGeometryCore\",\n },\n tsBentleyJsCore: {\n moduleName: \"@itwin/core-bentley\",\n resolvedConflictName: \"BeBentleyJsCore\",\n },\n};\n\n/**\n * @beta\n */\nexport class ECSchemaToTs {\n private _tsBentleyModuleNames: Set<string>;\n private _tsBentleyModuleResolvedConflictNames: Map<string, string>;\n private _schema?: Schema;\n private _schemaItemList: SchemaItem[];\n\n public constructor() {\n this._schema = undefined;\n this._schemaItemList = [];\n\n this._tsBentleyModuleNames = new Set<string>();\n this._tsBentleyModuleResolvedConflictNames = new Map<string, string>();\n for (const key in tsBentleyModules) {\n if (tsBentleyModules.hasOwnProperty(key)) {\n const moduleName: string = tsBentleyModules[key].moduleName;\n const resolvedPrefix: string = tsBentleyModules[key].resolvedConflictName;\n this._tsBentleyModuleNames.add(moduleName);\n this._tsBentleyModuleResolvedConflictNames.set(moduleName, resolvedPrefix);\n }\n }\n }\n\n /**\n * Given the schema, the function will converted it to typescript strings\n * @param schema The schema to be converted to typescript strings\n */\n public convertSchemaToTs(schema: Schema): { schemaTsString: string, elemTsString: string, propsTsString: string } {\n // convert schema to typescript String\n this._schema = schema;\n this.dependencyToFront();\n const schemaTsString = this.convertSchemaToTsClass();\n const elemTsString = this.convertElemToTsClasses();\n const propsTsString = this.convertPropsToTsInterfaces();\n\n return { schemaTsString, elemTsString, propsTsString };\n }\n\n /**\n * The function will push all the base classes to be the first ones in the schema item list.\n * For example, if class A extends base class B and base class C, B and C will be on the first of the list and then A at the end.\n * If B extends C, then B will be first and C will be next in the list and then A at the end.\n * If B and C does not depend on each other, the order of B and C will not be important.\n * The arrangement is to make sure that base class will be converted first and then, derived classes and so on\n */\n private dependencyToFront(): void {\n const uniqueItemName: Set<string> = new Set<string>();\n const schemaItemsList: SchemaItem[] = [];\n for (const schemaItem of this._schema!.getItems()) {\n // base class to the item list first;\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.StructClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.EntityClass:\n const ecClass = schemaItem as ECClass;\n const baseList = this.getAllBaseClasses(ecClass);\n for (let i = baseList.length - 1; i >= 0; --i) {\n const base = baseList[i];\n if (base.schema.schemaKey.compareByName(this._schema!.schemaKey) && !uniqueItemName.has(base.name)) {\n schemaItemsList.push(baseList[i]);\n uniqueItemName.add(base.name);\n }\n }\n break;\n default:\n break;\n }\n\n if (!uniqueItemName.has(schemaItem.name)) {\n uniqueItemName.add(schemaItem.name);\n schemaItemsList.push(schemaItem);\n }\n }\n\n this._schemaItemList = schemaItemsList;\n }\n\n /**\n * The function converts the schema meta data to typescript Schema class\n */\n private convertSchemaToTsClass(): string {\n const schemaName = this._schema!.schemaKey.name;\n let outputString: string = \"\";\n\n // import modules\n outputString += \"import { ClassRegistry, Schema, Schemas } from \\\"@itwin/core-backend\\\";\\n\";\n outputString += `import * as elementsModule from \"./${schemaName}Elements\";\\n\\n`;\n\n // create new schema class\n outputString += `export class ${schemaName} extends Schema {\\n`;\n\n // schemaName() method\n outputString += ` public static get schemaName(): string { return \"${schemaName}\"; }\\n\\n`;\n\n // registerSchema method\n outputString += \" public static registerSchema() {\\n\";\n outputString += ` if (!Schemas.getRegisteredSchema(${schemaName}.name))\\n`;\n outputString += ` Schemas.registerSchema(${schemaName});\\n`;\n outputString += \" }\\n\\n\";\n\n // constructor\n outputString += \" protected constructor() {\\n\";\n outputString += \" super();\\n\";\n outputString += ` ClassRegistry.registerModule(elementsModule, ${schemaName});\\n`;\n outputString += \" }\\n\";\n\n outputString += \"}\\n\\n\";\n\n return outputString;\n }\n\n /**\n * The function converts the schema item to respective typescript classes\n */\n private convertElemToTsClasses(): string {\n const classNameToModule: Map<string, string> = new Map<string, string>();\n let classTs: string = \"\";\n for (const schemaItem of this._schemaItemList) {\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.EntityClass:\n classTs += this.convertEntityToTs(schemaItem as EntityClass, classNameToModule);\n break;\n case SchemaItemType.Enumeration:\n classTs += this.convertEnumToTs(schemaItem as Enumeration);\n break;\n default:\n continue;\n }\n }\n\n let outputString: string = this.convertImportToTsImport(classNameToModule);\n outputString += `\\n${classTs}`;\n return outputString;\n }\n\n /**\n * The function converts the schema item properties to respective typescript props interfaces\n */\n private convertPropsToTsInterfaces(): string {\n const classNameToModule: Map<string, string> = new Map<string, string>();\n let interfacesTs: string = \"\";\n for (const schemaItem of this._schemaItemList) {\n switch (schemaItem.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n interfacesTs += this.convertECClassPropsToTsInterface(schemaItem as (Mixin | StructClass | EntityClass), classNameToModule);\n break;\n default:\n continue;\n }\n }\n\n let outputString: string = this.convertImportToTsImport(classNameToModule);\n outputString += `\\n${interfacesTs}`;\n return outputString;\n }\n\n /**\n * Convert mixin or struct class or entity class to respective typescript interface\n * @param ecClass Schema mixin or struct or entity to be converted typescript interface\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertECClassPropsToTsInterface(ecClass: Mixin | StructClass | EntityClass, classNameToModule: Map<string, string>): string {\n let interfacesTs: string = \"\";\n\n // no interface props for BisCore Element\n if (ecClass.fullName === elementECClassName)\n return interfacesTs;\n\n // only generate props interface for entity if the class has properties\n if (ecClass.schemaItemType === SchemaItemType.EntityClass && !ecClass.hasLocalProperties)\n return interfacesTs;\n\n // convert description to typescript comment only for mixin or struct\n if (ecClass.schemaItemType !== SchemaItemType.EntityClass && ecClass.description)\n interfacesTs += `${this.convertDescriptionToTsComment(ecClass.description)}\\n`;\n\n // build interface for props in ecClass\n interfacesTs += `export interface ${ecClass.name}`;\n if (ecClass.schemaItemType === SchemaItemType.EntityClass)\n interfacesTs += \"Props\";\n\n // Extend it with base ecClass Props interface if there is any\n const baseClasses = this.getBaseClassWithProps(ecClass);\n if (baseClasses.length > 0) {\n interfacesTs += \" extends \";\n\n let separator = \"\";\n for (const base of baseClasses) {\n interfacesTs += separator + this.addImportBasePropsClass(classNameToModule, base, ecClass);\n separator = \", \";\n }\n } else if (ecClass.schemaItemType === SchemaItemType.EntityClass)\n interfacesTs += ` extends ${this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"EntityProps\")}`;\n\n // build props for ecClass\n interfacesTs += \" {\";\n const propertiesTs = this.convertPropsToTsVars(ecClass, classNameToModule);\n for (const varDeclarationLine of propertiesTs)\n interfacesTs += `\\n ${varDeclarationLine}`;\n interfacesTs += \"\\n}\\n\\n\";\n\n return interfacesTs;\n }\n\n /**\n * Convert schema enumeration to typescript enumeration\n * @param ecEnum Schema enumeration to be converted to typescript enumeration\n */\n private convertEnumToTs(ecEnum: Enumeration): string {\n let outputString: string = \"\";\n if (ecEnum.description)\n outputString += `${this.convertDescriptionToTsComment(ecEnum.description)}\\n`;\n\n outputString += `export const enum ${ecEnum.name} {\\n`;\n for (const ecEnumerator of ecEnum.enumerators) {\n outputString += ` ${ecEnumerator.label}`;\n if (ecEnum.isInt)\n outputString += ` = ${ecEnumerator.value}`;\n else if (ecEnum.isString)\n outputString += ` = \"${ecEnumerator.value}\"`;\n outputString += \",\\n\";\n }\n\n outputString += \"}\\n\\n\";\n return outputString;\n }\n\n /**\n * Convert schema entity to typescript entity class. The typescript class will implement respective props\n * typescript interface if the schema entity class has properties\n * @param ecClass Schema class to be converted to typescript class\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertEntityToTs(ecClass: EntityClass, classNameToModule: Map<string, string>): string {\n let outputString: string = \"\";\n if (ecClass.description)\n outputString += `${this.convertDescriptionToTsComment(ecClass.description)}\\n`;\n\n let modifier: string = \"\";\n if (ecClass.modifier === ECClassModifier.Abstract)\n modifier = \"abstract \";\n outputString += `export ${modifier}class ${ecClass.name} extends `;\n\n // extend base class if there is any. Default will be Entity class defined in @itwin/core-backend\n const base = ecClass.getBaseClassSync();\n if (base)\n outputString += this.addImportBaseClass(classNameToModule, base, ecClass);\n else\n outputString += this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsBackend.moduleName, \"Entity\");\n\n // determine prop type to pass in the constructor\n let propsBaseTsType: string;\n const propsBase = this.getBaseClassWithProps(ecClass);\n if (ecClass.fullName !== elementECClassName && ecClass.hasLocalProperties) {\n const moduleName: string = `${this._schema!.schemaKey.name}ElementProps`;\n propsBaseTsType = this.addImportClass(classNameToModule, moduleName, `${ecClass.name}Props`);\n } else if (propsBase.length > 0)\n propsBaseTsType = this.addImportBasePropsClass(classNameToModule, propsBase[0], ecClass);\n else\n propsBaseTsType = this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"EntityProps\");\n\n // implement the ecClass props if it has properties\n if (`${ecClass.name}Props` === propsBaseTsType)\n outputString += ` implements ${propsBaseTsType}`;\n\n // write constructor and className function for class\n const iModelDbTsType: string = this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsBackend.moduleName, \"IModelDb\");\n\n outputString += \" {\\n\";\n outputString += ` public static get className(): string { return \"${ecClass.name}\"; }\\n\\n`;\n outputString += ` public constructor (props: ${propsBaseTsType}, iModel: ${iModelDbTsType}) {\\n`;\n outputString += \" super(props, iModel);\\n\";\n outputString += \" }\\n\";\n outputString += \"}\\n\\n\";\n\n return outputString;\n }\n\n /**\n * Convert class properties to typescript member declaration\n * @param ecClass The schema class that has the properties to be converted to typescript member variables\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertPropsToTsVars(ecClass: ECClass, classNameToModule: Map<string, string>): string[] {\n if (!ecClass.hasLocalProperties)\n return [];\n\n const outputStrings: string[] = [];\n for (const ecProperty of ecClass.getPropertiesSync(true)) {\n // not generate ts variable declaration for property that has CustomHandledProperty ca\n if (ecProperty.customAttributes && ecProperty.customAttributes.has(customHandledPropertyCA))\n continue;\n\n let varDeclarationLine: string = `${this.lowerPropertyName(ecProperty.name)}?: `;\n if (ecProperty.isPrimitive()) {\n // determine Ts type of the primitive\n let typeTs: string = \"\";\n if (ecProperty.extendedTypeName)\n typeTs = this.convertExtendedTypeNameToTsType(ecProperty.extendedTypeName, classNameToModule);\n else if (ecProperty.isEnumeration()) {\n const ecEnumProperty = ecProperty as EnumerationProperty;\n const ecEnum = ecEnumProperty.enumeration!;\n typeTs = this.addImportClass(classNameToModule, `${ecEnum.schemaKey.name}Elements`, ecEnum.name);\n } else {\n const ecPrimitiveProperty = ecProperty as PrimitiveProperty;\n typeTs = this.convertPrimitiveTypeToTsType(ecPrimitiveProperty.primitiveType, classNameToModule);\n }\n\n varDeclarationLine += typeTs;\n } else if (ecProperty.isStruct()) {\n // import struct class if it is in different schema\n const ecStructProperty = ecProperty as StructProperty;\n const structClass = ecStructProperty.structClass;\n if (!structClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n varDeclarationLine += this.addImportClass(classNameToModule, `${structClass.schema.schemaKey.name}ElementProps`, structClass.name);\n else\n varDeclarationLine += structClass.name;\n\n } else if (ecProperty.isNavigation())\n varDeclarationLine += this.addImportClass(classNameToModule, tsBentleyModules.tsIModelJsCommon.moduleName, \"RelatedElementProps\");\n\n if (ecProperty.isArray())\n varDeclarationLine += \"[]\";\n varDeclarationLine += \";\";\n\n outputStrings.push(varDeclarationLine);\n }\n\n return outputStrings;\n }\n\n /**\n * Convert schema extended type to typescript type\n * @param typeName Schema extended type to be converted to typescript type\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertExtendedTypeNameToTsType(typeName: string, classNameToModule: Map<string, string>): string {\n switch (typeName) {\n case \"Json\":\n return \"any\";\n case \"BeGuid\":\n return this.addImportClass(classNameToModule, tsBentleyModules.tsBentleyJsCore.moduleName, \"GuidString\");\n default:\n return \"any\";\n }\n }\n\n /**\n * Convert schema primitive type to typescript type\n * @param type Schema primitive type to be converted to typescript type\n * @param classNameToModule Typescrip modules to be updated after the conversion\n */\n private convertPrimitiveTypeToTsType(type: PrimitiveType, classNameToModule: Map<string, string>) {\n switch (type) {\n case PrimitiveType.Binary:\n return \"any\";\n case PrimitiveType.Boolean:\n return \"boolean\";\n case PrimitiveType.DateTime:\n return \"Date\";\n case PrimitiveType.Double:\n return \"number\";\n case PrimitiveType.Integer:\n return \"number\";\n case PrimitiveType.Long:\n // eslint-disable-next-line no-console\n console.log(\"Primitive type Long is not currently supported during conversion. It will be treated as type 'any'\");\n return \"any\";\n case PrimitiveType.String:\n return \"string\";\n case PrimitiveType.Point2d:\n return this.addImportClass(classNameToModule, tsBentleyModules.tsGeometryCore.moduleName, \"Point2d\");\n case PrimitiveType.Point3d:\n return this.addImportClass(classNameToModule, tsBentleyModules.tsGeometryCore.moduleName, \"Point3d\");\n case PrimitiveType.IGeometry:\n // eslint-disable-next-line no-console\n console.log(\"Primitive type IGeometry is not currently supported during conversion. It will be treated as type 'any'\");\n return \"any\";\n default:\n // eslint-disable-next-line no-console\n console.log(\"Unknown primitive type during conversion. It will be treated as type 'any'\");\n return \"any\";\n }\n }\n\n /**\n * Convert schema description to typescript comment\n * @param description Schema description to be converted to typescript comment\n */\n private convertDescriptionToTsComment(description: string) {\n let outputString: string = \"/**\\n\";\n\n let wordCount: number = 0;\n let begin: number = 0;\n let spaceBegin: number = 0;\n let spaceIdx: number = description.indexOf(\" \", spaceBegin);\n while (spaceIdx !== -1) {\n // new line for every 20 words\n ++wordCount;\n if (wordCount === 20) {\n wordCount = 0;\n outputString += ` * ${description.substring(begin, spaceIdx)}\\n`;\n begin = spaceIdx + 1;\n }\n\n spaceBegin = spaceIdx + 1;\n while (description[spaceBegin] === \" \")\n ++spaceBegin;\n\n spaceIdx = description.indexOf(\" \", spaceBegin);\n }\n\n // append the last word\n outputString += ` * ${description.substring(begin)}\\n`;\n\n outputString += \" */\";\n return outputString;\n }\n\n /**\n * Convert all modules needed for the converted schema types to typescript import statements\n * @param classNameToModule Modules to be converted to typescript imports statement\n */\n private convertImportToTsImport(classNameToModule: Map<string, string>): string {\n const moduleToTsTypes: Map<string, Set<string>> = new Map<string, Set<string>>();\n classNameToModule.forEach((moduleNames: string, className: string) => {\n if (!moduleToTsTypes.has(moduleNames))\n moduleToTsTypes.set(moduleNames, new Set<string>());\n\n moduleToTsTypes.get(moduleNames)!.add(className);\n });\n\n let outputString: string = \"\";\n moduleToTsTypes.forEach((classNames: Set<string>, moduleName: string) => {\n if (!this._tsBentleyModuleNames.has(moduleName))\n moduleName = `./${moduleName}`;\n\n outputString += \"import { \";\n let separator = \"\";\n for (const className of classNames) {\n outputString += separator + className;\n separator = \", \";\n }\n outputString += ` } from \"${moduleName}\";\\n`;\n });\n\n return outputString;\n }\n\n /**\n * Traverse the inheritance tree to retrieve first base classes that have properties\n * @param ecClass Schema class to be traverse\n */\n private getBaseClassWithProps(ecClass: ECClass): ECClass[] {\n const res: ECClass[] = [];\n const visited: Set<string> = new Set<string>();\n visited.add(ecClass.fullName);\n this.traverseBaseClass(ecClass, visited, (base: ECClass) => {\n if (base.hasLocalProperties) {\n res.push(base);\n return false;\n }\n\n return true;\n });\n\n return res;\n }\n\n /**\n * Traverse the inheritance tree to retrieve base classes of a schema class\n * @param ecClass Schema class to be traverse\n */\n private getAllBaseClasses(ecClass: ECClass): ECClass[] {\n const res: ECClass[] = [];\n const visited: Set<string> = new Set<string>();\n visited.add(ecClass.fullName);\n this.traverseBaseClass(ecClass, visited, (base: ECClass) => {\n res.push(base);\n return true;\n });\n\n return res;\n }\n\n /**\n * Traverse the inheritance tree horizontally and vertically of a schema class\n * @param ecClass Schema class to be traverse\n * @param visited Set of classes that are already visited\n * @param shouldTraverseDown Lambda to determine if it should traverse more vertically\n */\n private traverseBaseClass(ecClass: ECClass, visited: Set<string>, shouldTraverseDown: (base: ECClass) => boolean): void {\n const base = ecClass.getBaseClassSync();\n if (base === undefined || visited.has(base.fullName))\n return;\n\n const baseList: ECClass[] = [base];\n if (ecClass.schemaItemType === SchemaItemType.EntityClass) {\n const entity = ecClass as EntityClass;\n for (const mixin of entity.getMixinsSync())\n baseList.push(mixin);\n }\n\n for (const eachBase of baseList) {\n visited.add(eachBase.fullName);\n if (shouldTraverseDown(eachBase))\n this.traverseBaseClass(eachBase, visited, shouldTraverseDown);\n }\n }\n\n /**\n * Add required typescript class that is to be imported from a required module during Schema conversion to typescript. If there is naming conflict\n * it will resolve it by appending prefix name with class name, for example: import { element as BisCoreElement } from \"BisCoreElement\";\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param refModule Typescript module that the typescrip class comes from\n * @param className Required Typescript class for the conversion\n */\n private addImportClass(classNameToModule: Map<string, string>, refModule: string, className: string): string {\n if (!classNameToModule.has(className)) {\n classNameToModule.set(className, refModule);\n return className;\n }\n\n if (classNameToModule.get(className) === refModule)\n return className;\n\n let resolvedPrefix: string = refModule;\n if (this._tsBentleyModuleResolvedConflictNames.has(refModule))\n resolvedPrefix = this._tsBentleyModuleResolvedConflictNames.get(refModule)!;\n\n const renameClassName = `${className} as ${resolvedPrefix}${className}`;\n if (!classNameToModule.has(renameClassName)) {\n classNameToModule.set(renameClassName, refModule);\n }\n\n return resolvedPrefix + className;\n }\n\n /**\n * Add appropriate typescript props interface to the classNameToModule and return the corresponding typescript base props interface\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param baseECClass Base class of ecClass that has properties. Its name will be used to derived typescript base props interface\n * @param ecClass ECClass to be converted to Typescript\n */\n private addImportBasePropsClass(classNameToModule: Map<string, string>, baseECClass: ECClass, ecClass: ECClass): string {\n let baseName: string = baseECClass.name;\n if (baseECClass.schemaItemType === SchemaItemType.EntityClass)\n baseName += \"Props\";\n\n // find external module to import\n let externalModule: string = \"\";\n const shouldImportJsCommon = (baseECClass.fullName === elementECClassName) ||\n (baseECClass.schema.schemaKey.name === \"BisCore\" && ecClass.schema.schemaKey.name !== \"BisCore\");\n if (shouldImportJsCommon)\n externalModule = tsBentleyModules.tsIModelJsCommon.moduleName;\n else if (!baseECClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n externalModule = `${baseECClass.schema.schemaKey.name}ElementProps`;\n\n if (externalModule.length !== 0)\n baseName = this.addImportClass(classNameToModule, externalModule, baseName);\n\n return baseName;\n }\n\n /**\n * Add appropriate typescript base class to the classNameToModule and return the corresponding typescript base class\n * @param classNameToModule Typescript modules that is needed for the conversion. It maps typescript class with the required modules\n * @param baseECClass Base class of ecClass\n * @param ecClass ECClass to be converted to Typescript\n */\n private addImportBaseClass(classNameToModule: Map<string, string>, baseECClass: ECClass, ecClass: ECClass): string {\n let baseName: string = baseECClass.name;\n\n // find external module to import for base class\n let externalModule: string = \"\";\n if (baseECClass.schema.schemaKey.name === \"BisCore\" && ecClass.schema.schemaKey.name !== \"BisCore\")\n externalModule = tsBentleyModules.tsIModelJsBackend.moduleName;\n else if (!baseECClass.schema.schemaKey.compareByName(ecClass.schema.schemaKey))\n externalModule = `${baseECClass.schema.schemaKey.name}Elements`;\n\n if (externalModule.length !== 0)\n baseName = this.addImportClass(classNameToModule, externalModule, baseName);\n\n return baseName;\n }\n\n /**\n * Lower the first character of the property name\n * @param propName Property name\n */\n private lowerPropertyName(propName: string): string {\n return propName.charAt(0).toLowerCase() + propName.slice(1);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@itwin/ecschema2ts",
|
|
3
3
|
"description": "Command line tools that takes an ECSchema xml file and outputs a typescript module",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "5.0.0-dev.
|
|
5
|
+
"version": "5.0.0-dev.90",
|
|
6
6
|
"bin": {
|
|
7
7
|
"ecschema2ts": "./bin/index.js"
|
|
8
8
|
},
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"rimraf": "^6.0.1",
|
|
40
40
|
"source-map-support": "^0.5.6",
|
|
41
41
|
"typescript": "~5.6.2",
|
|
42
|
-
"@itwin/build-tools": "5.0.0-dev.
|
|
42
|
+
"@itwin/build-tools": "5.0.0-dev.90"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@xmldom/xmldom": "~0.8.10",
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
"chalk": "^3.0.0",
|
|
48
48
|
"commander": "^2.14.1",
|
|
49
49
|
"fs-extra": "^8.1.0",
|
|
50
|
-
"@itwin/ecschema-locaters": "5.0.0-dev.
|
|
51
|
-
"@itwin/core-
|
|
52
|
-
"@itwin/core-
|
|
53
|
-
"@itwin/core-
|
|
54
|
-
"@itwin/
|
|
55
|
-
"@itwin/
|
|
50
|
+
"@itwin/ecschema-locaters": "5.0.0-dev.90",
|
|
51
|
+
"@itwin/core-bentley": "5.0.0-dev.90",
|
|
52
|
+
"@itwin/core-common": "5.0.0-dev.90",
|
|
53
|
+
"@itwin/core-backend": "5.0.0-dev.90",
|
|
54
|
+
"@itwin/ecschema-metadata": "5.0.0-dev.90",
|
|
55
|
+
"@itwin/core-geometry": "5.0.0-dev.90"
|
|
56
56
|
},
|
|
57
57
|
"nyc": {
|
|
58
58
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|