@itwin/ecschema-metadata 5.2.0-dev.17 → 5.2.0-dev.18
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/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js +40 -20
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +2 -2
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js +1 -0
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +8 -2
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js +6 -6
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts +18 -24
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js +39 -19
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +2 -2
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +5 -4
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js +1 -0
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts +8 -2
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js +6 -6
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/package.json +6 -6
- package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts +0 -60
- package/lib/cjs/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
- package/lib/cjs/IncrementalLoading/PerformanceLogger.js +0 -82
- package/lib/cjs/IncrementalLoading/PerformanceLogger.js.map +0 -1
- package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts +0 -60
- package/lib/esm/IncrementalLoading/PerformanceLogger.d.ts.map +0 -1
- package/lib/esm/IncrementalLoading/PerformanceLogger.js +0 -78
- package/lib/esm/IncrementalLoading/PerformanceLogger.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaLocater.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,4CAAqD;AAGrD,wEAAqE;AACrE,4CAA+C;AAC/C,4CAA6D;AAE7D,+CAA4C;AAC5C,4CAAyC;AACzC,8EAA2E;AAC3E,uEAAoE;AAcpE;;;;;;;;GAQG;AACH,MAAsB,wBAAwB;IAC3B,QAAQ,CAAuB;IAC7B,gBAAgB,CAAkB;IAErD;;;OAGG;IACH,YAAY,OAA8B;QACxC,IAAI,CAAC,QAAQ,GAAG,OAAO,IAAI,EAAE,CAAC;QAE9B,IAAI,CAAC,gBAAgB,GAAG,IAAI,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC5D,OAAO,IAAI,CAAC,e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O,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC7F,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,SAAoB,EAAE,OAAsB;QACxD,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,kBAAkB;YACrB,OAAO;QAET,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;QACzG,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF","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 *--------------------------------------------------------------------------------------------*/\nimport { ECSchemaNamespaceUris } from \"../Constants\";\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\nimport { SchemaProps } from \"../Deserialization/JsonProps\";\nimport { SchemaGraphUtil } from \"../Deserialization/SchemaGraphUtil\";\nimport { SchemaMatchType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { SchemaLoadingController } from \"../utils/SchemaLoadingController\";\nimport { IncrementalSchemaReader } from \"./IncrementalSchemaReader\";\n\ntype LoadSchemaInfoHandler = (context: SchemaContext) => Promise<Iterable<SchemaInfo>>;\n\n/**\n * Defines the SchemaLocater Options which determine how each schema is to be loaded.\n * All options are optional.\n * @beta\n */\nexport interface SchemaLocaterOptions {\n /** Only load partial schemas. Full schema information will not be retrieved. Defaults to false. */\n readonly loadPartialSchemaOnly?: boolean;\n}\n\n/**\n * A [[ISchemaLocater]] implementation for locating and retrieving EC [[Schema]]\n * objects incrementally instead of the full schema and it's references at once. This is useful for large schemas that\n * take a long time to load, but clients need a rough skeleton of the schema as fast as possible.\n *\n * The IncrementalSchemaLocater is a locater around the [[IncrementalSchemaLocater]] to be used in a\n * [[SchemaContext]].\n * @internal\n */\nexport abstract class IncrementalSchemaLocater implements ISchemaLocater {\n private readonly _options: SchemaLocaterOptions;\n protected readonly _schemaInfoCache: SchemaInfoCache;\n\n /**\n * Initializes a new instance of the IncrementalSchemaLocater class.\n * @param options The [[SchemaLocaterOptions]] that control the loading of the schema.\n */\n constructor(options?: SchemaLocaterOptions) {\n this._options = options || {};\n\n this._schemaInfoCache = new SchemaInfoCache(async (context) => {\n return this.loadSchemaInfos(context);\n });\n }\n\n /** Gets the options how the schema locater load the schemas. */\n protected get options(): SchemaLocaterOptions {\n return this._options;\n }\n\n /**\n * Gets the [[SchemaInfo]] which matches the provided SchemaKey. The SchemaInfo may be returned\n * before the schema is fully loaded. May return the entire Schema so long as it is completely loaded as it satisfies\n * the SchemaInfo interface.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n return this._schemaInfoCache.lookup(schemaKey, matchType, context);\n }\n\n /**\n * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.\n * For schemas that may have references, construct and call through a SchemaContext instead.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n const schemaInfo = await this.getSchemaInfo(schemaKey, matchType, context);\n return schemaInfo\n ? this.loadSchema(schemaInfo, context)\n : undefined;\n }\n\n /**\n * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.\n * For schemas that may have references, construct and call through a SchemaContext instead.\n * NOT IMPLEMENTED IN THIS LOCATER - ALWAYS RETURNS UNDEFINED.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n * @returns Incremental schema loading does not work synchronously, this will always return undefined.\n */\n public getSchemaSync(_schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\n return undefined;\n }\n\n /**\n * Gets the schema partials for the given schema key. The first item in the array is the\n * actual schema props of the schema to load, the following items are partial schema props\n * of referenced schemas.\n * @param schemaKey The schema key of the requested schema.\n * @param context The schema context.\n */\n protected abstract getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined>;\n\n /**\n * Gets the full schema json for the requested schema key.\n * @param schemaKey The schema key of the requested schema.\n * @param context The schema context.\n */\n protected abstract getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined>;\n\n /**\n * Loads the schema info objects for the given context.\n * @param context The schema context to load the schema infos for.\n * @returns A promise that resolves to an iterable of schema infos.\n */\n public abstract loadSchemaInfos(context: SchemaContext): Promise<Iterable<SchemaInfo>>;\n\n /**\n * Checks if the context contains the right schemas to support incremental schema loading.\n * @param context The schema context to check.\n * @returns true if incremental schema loading is supported, false otherwise.\n */\n protected abstract supportPartialSchemaLoading(context: SchemaContext): Promise<boolean>;\n\n /**\n * Start loading the schema for the given schema info incrementally. The schema is returned\n * as soon as the schema stub is loaded while the schema fully resolves in the background. It should\n * only be called by the IncrementalSchemaLocater if a schema has not been loaded or started to\n * load yet.\n * @param schemaInfo The schema info of the schema to load.\n * @param schemaContext The schema context to load the schema into.\n */\n public async loadSchema(schemaInfo: SchemaInfo, schemaContext: SchemaContext): Promise<Schema> {\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\n // to fetch the whole schema json.\n if (!await this.supportPartialSchemaLoading(schemaContext)) {\n const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);\n return Schema.fromJson(schemaJson!, schemaContext);\n }\n\n // Fetches the schema partials for the given schema key. The first item in the array is the\n // actual schema props of the schema to load, the following items are schema props of referenced\n // schema items that are needed to resolve the schema properly.\n const schemaPartials = await this.getSchemaPartials(schemaInfo.schemaKey, schemaContext);\n if (schemaPartials === undefined)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema, ${schemaInfo.schemaKey.name}.${schemaInfo.schemaKey.version.toString()}`);\n\n // Sort the partials in dependency order to ensure referenced schemas exist in the schema context\n // when they get requested. Otherwise the context would call this method again and for referenced\n // schemas, we would not want to request the whole schema props.\n const sortedPartials = await this.sortSchemaPartials(schemaPartials, schemaContext);\n for (const schemaProps of sortedPartials) {\n await this.startLoadingPartialSchema(schemaProps, schemaContext);\n }\n\n const schema = await schemaContext.getCachedSchema(schemaInfo.schemaKey);\n if (!schema)\n throw new Error(`Schema ${schemaInfo.schemaKey.name} could not be found.`);\n\n return schema;\n }\n\n /**\n * Creates a SchemaProps object by loading the Schema information from the given SchemaContext.\n * @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.\n * @param schemaContext The SchemaContext holding the Schema.\n * @returns The SchemaProps object.\n */\n protected async createSchemaProps(schemaKey: SchemaKey, schemaContext: SchemaContext): Promise<SchemaProps> {\n const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, SchemaMatchType.Latest);\n if (!schemaInfo)\n throw new Error(`Schema ${schemaKey.name} could not be found.`);\n const schemaProps: SchemaProps = {\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n name: schemaKey.name,\n alias: schemaInfo.alias,\n version: schemaInfo.schemaKey.version.toString(),\n references: [],\n items: {}\n };\n\n if (!schemaProps.references)\n throw new Error(`Schema references is undefined for the Schema ${schemaInfo.schemaKey.name}`);\n\n schemaInfo.references.forEach((ref) => {\n schemaProps.references!.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });\n });\n\n return schemaProps;\n }\n\n private async startLoadingPartialSchema(schemaProps: SchemaProps, schemaContext: SchemaContext): Promise<void> {\n if (schemaContext.schemaExists(SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`))) {\n return;\n }\n\n const controller = new SchemaLoadingController();\n const schemaReader = new IncrementalSchemaReader(schemaContext, true);\n const schema = new Schema(schemaContext);\n schema.setLoadingController(controller);\n\n await schemaReader.readSchema(schema, schemaProps);\n\n if (!this._options.loadPartialSchemaOnly)\n controller.start(this.startLoadingFullSchema(schema));\n }\n\n private async loadFullSchema(schema: Schema): Promise<void> {\n const fullSchemaProps = await this.getSchemaJson(schema.schemaKey, schema.context)\n const reader = new IncrementalSchemaReader(schema.context, false);\n await reader.readSchema(schema, fullSchemaProps, false);\n }\n\n private async startLoadingFullSchema(schema: Schema): Promise<void> {\n if (!schema.loadingController)\n return;\n\n // If the schema is already resolved, return it directly.\n if (schema.loadingController.isComplete || schema.loadingController.inProgress) {\n return;\n }\n\n // Since the schema relies on it's references, they get triggered to be resolved\n // first by recursively calling this method. After all references has been resolved\n // the schema itself gets resolved.\n await Promise.all(schema.references.map(async (referenceSchema) => {\n if (referenceSchema.loadingController && referenceSchema.loadingController.inProgress)\n return referenceSchema.loadingController.wait();\n else\n return this.startLoadingFullSchema(referenceSchema);\n }));\n\n return this.loadFullSchema(schema);\n }\n\n private async sortSchemaPartials(schemaPartials: ReadonlyArray<SchemaProps>, schemaContext: SchemaContext): Promise<ReadonlyArray<SchemaProps>> {\n const schemaInfos: Array<SchemaInfo & { props: SchemaProps }> = [];\n for (const schemaProps of schemaPartials) {\n const schemaKey = SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`);\n const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, SchemaMatchType.Latest);\n if (!schemaInfo)\n throw new Error(`Schema ${schemaKey.name} could not be found.`);\n\n schemaInfos.push({ ...schemaInfo, props: schemaProps });\n }\n\n const orderedSchemaInfos = SchemaGraphUtil.buildDependencyOrderedSchemaInfoList(schemaInfos) as Array<SchemaInfo & { props: SchemaProps }>;\n return orderedSchemaInfos.map((schemaInfo) => schemaInfo.props);\n }\n}\n\n/**\n * Helper class to manage schema infos for a schema context.\n */\nclass SchemaInfoCache {\n private readonly _schemaInfoCache: WeakMap<SchemaContext, Array<SchemaInfo>>;\n private readonly _schemaInfoLoader: LoadSchemaInfoHandler;\n\n constructor(schemaInfoLoader: LoadSchemaInfoHandler) {\n this._schemaInfoCache = new WeakMap<SchemaContext, Array<SchemaInfo>>();\n this._schemaInfoLoader = schemaInfoLoader;\n }\n\n public async getSchemasByContext(context: SchemaContext): Promise<SchemaInfo[] | undefined> {\n if (!this._schemaInfoCache.has(context)) {\n const schemaInfos = await this._schemaInfoLoader(context);\n this._schemaInfoCache.set(context, Array.from(schemaInfos));\n }\n return this._schemaInfoCache.get(context);\n }\n\n public async lookup(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const contextSchemaInfos = await this.getSchemasByContext(context);\n return contextSchemaInfos\n ? contextSchemaInfos.find((schemaInfo) => schemaInfo.schemaKey.matches(schemaKey, matchType))\n : undefined;\n }\n\n public remove(schemaKey: SchemaKey, context: SchemaContext): void {\n const contextSchemaInfos = this._schemaInfoCache.get(context);\n if (!contextSchemaInfos)\n return;\n\n const index = contextSchemaInfos.findIndex((schemaInfo) => schemaInfo.schemaKey.name === schemaKey.name);\n if (index !== -1) {\n contextSchemaInfos.splice(index, 1);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IncrementalSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaLocater.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,4CAAqD;AA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CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAC1D,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC9D,CAAC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAoB,EAAE,SAA0B,EAAE,OAAsB;QAC1F,MAAM,kBAAkB,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACnE,OAAO,kBAAkB;YACvB,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;YAC7F,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEM,MAAM,CAAC,SAAoB,EAAE,OAAsB;QACxD,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,kBAAkB;YACrB,OAAO;QAET,MAAM,KAAK,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,KAAK,SAAS,CAAC,IAAI,CAAC,CAAC;QACzG,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;YACjB,kBAAkB,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;CACF","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 *--------------------------------------------------------------------------------------------*/\nimport { ECSchemaNamespaceUris } from \"../Constants\";\nimport { ISchemaLocater, SchemaContext } from \"../Context\";\nimport { SchemaProps, SchemaReferenceProps } from \"../Deserialization/JsonProps\";\nimport { SchemaGraphUtil } from \"../Deserialization/SchemaGraphUtil\";\nimport { SchemaMatchType } from \"../ECObjects\";\nimport { ECSchemaError, ECSchemaStatus } from \"../Exception\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { SchemaLoadingController } from \"../utils/SchemaLoadingController\";\nimport { IncrementalSchemaReader } from \"./IncrementalSchemaReader\";\n\ntype LoadSchemaInfoHandler = (context: SchemaContext) => Promise<Iterable<SchemaInfo>>;\n\n/**\n * Defines the SchemaLocater Options which determine how each schema is to be loaded.\n * All options are optional.\n * @beta\n */\nexport interface SchemaLocaterOptions {\n /** Only load partial schemas. Full schema information will not be retrieved. Defaults to false. */\n readonly loadPartialSchemaOnly?: boolean;\n}\n\n/**\n * A [[ISchemaLocater]] implementation for locating and retrieving EC [[Schema]]\n * objects incrementally instead of the full schema and it's references at once. This is useful for large schemas that\n * take a long time to load, but clients need a rough skeleton of the schema as fast as possible.\n *\n * The IncrementalSchemaLocater is a locater around the [[IncrementalSchemaLocater]] to be used in a\n * [[SchemaContext]].\n * @internal\n */\nexport abstract class IncrementalSchemaLocater implements ISchemaLocater {\n private readonly _options: SchemaLocaterOptions;\n protected readonly _schemaInfoCache: SchemaInfoCache;\n\n /**\n * Initializes a new instance of the IncrementalSchemaLocater class.\n * @param options The [[SchemaLocaterOptions]] that control the loading of the schema.\n */\n constructor(options?: SchemaLocaterOptions) {\n this._options = options || {};\n\n this._schemaInfoCache = new SchemaInfoCache(async (context) => {\n return this.loadSchemaInfos(context);\n });\n }\n\n /** Gets the options how the schema locater load the schemas. */\n protected get options(): SchemaLocaterOptions {\n return this._options;\n }\n\n /**\n * Gets the [[SchemaInfo]] which matches the provided SchemaKey. The SchemaInfo may be returned\n * before the schema is fully loaded. May return the entire Schema so long as it is completely loaded as it satisfies\n * the SchemaInfo interface.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n */\n public async getSchemaInfo(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n return this._schemaInfoCache.lookup(schemaKey, matchType, context);\n }\n\n /**\n * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.\n * For schemas that may have references, construct and call through a SchemaContext instead.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n */\n public async getSchema(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<Schema | undefined> {\n const schemaInfo = await this.getSchemaInfo(schemaKey, matchType, context);\n return schemaInfo\n ? this.loadSchema(schemaInfo, context)\n : undefined;\n }\n\n /**\n * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.\n * For schemas that may have references, construct and call through a SchemaContext instead.\n * NOT IMPLEMENTED IN THIS LOCATER - ALWAYS RETURNS UNDEFINED.\n * @param schemaKey The [[SchemaKey]] to look up.\n * @param matchType The [[SchemaMatchType]] to use against candidate schemas.\n * @param context The [[SchemaContext]] for loading schema references.\n * @returns Incremental schema loading does not work synchronously, this will always return undefined.\n */\n public getSchemaSync(_schemaKey: Readonly<SchemaKey>, _matchType: SchemaMatchType, _context: SchemaContext): Schema | undefined {\n return undefined;\n }\n\n /**\n * Gets the schema partials for the given schema key. The first item in the array is the\n * actual schema props of the schema to load, the following items are partial schema props\n * of referenced schemas.\n * @param schemaKey The schema key of the requested schema.\n * @param context The schema context.\n */\n protected abstract getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined>;\n\n /**\n * Gets the full schema json for the requested schema key.\n * @param schemaKey The schema key of the requested schema.\n * @param context The schema context.\n */\n protected abstract getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined>;\n\n /**\n * Loads the schema info objects for the given context.\n * @param context The schema context to load the schema infos for.\n * @returns A promise that resolves to an iterable of schema infos.\n */\n protected abstract loadSchemaInfos(context: SchemaContext): Promise<Iterable<SchemaInfo>>;\n\n /**\n * Checks if the context contains the right schemas to support incremental schema loading.\n * @param context The schema context to check.\n * @returns true if incremental schema loading is supported, false otherwise.\n */\n protected abstract supportPartialSchemaLoading(context: SchemaContext): Promise<boolean>;\n\n /**\n * Start loading the schema for the given schema info incrementally. The schema is returned\n * as soon as the schema stub is loaded while the schema fully resolves in the background. It should\n * only be called by the IncrementalSchemaLocater if a schema has not been loaded or started to\n * load yet.\n * @param schemaInfo The schema info of the schema to load.\n * @param schemaContext The schema context to load the schema into.\n */\n protected async loadSchema(schemaInfo: SchemaInfo, schemaContext: SchemaContext): Promise<Schema> {\n // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema\n // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface\n // to fetch the whole schema json.\n if (!await this.supportPartialSchemaLoading(schemaContext)) {\n const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);\n if(schemaJson === undefined)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema, ${schemaInfo.schemaKey.name}.${schemaInfo.schemaKey.version.toString()}`);\n\n return Schema.fromJson(schemaJson, schemaContext);\n }\n\n // Fetches the schema partials for the given schema key. The first item in the array is the\n // actual schema props of the schema to load, the following items are schema props of referenced\n // schema items that are needed to resolve the schema properly.\n const schemaPartials = await this.getSchemaPartials(schemaInfo.schemaKey, schemaContext);\n if (schemaPartials === undefined)\n throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema, ${schemaInfo.schemaKey.name}.${schemaInfo.schemaKey.version.toString()}`);\n\n // Sort the partials in dependency order to ensure referenced schemas exist in the schema context\n // when they get requested. Otherwise the context would call this method again and for referenced\n // schemas, we would not want to request the whole schema props.\n const sortedPartials = await this.sortSchemaPartials(schemaPartials, schemaContext);\n for (const schemaProps of sortedPartials) {\n await this.startLoadingPartialSchema(schemaProps, schemaContext);\n }\n\n const schema = await schemaContext.getCachedSchema(schemaInfo.schemaKey);\n if (!schema)\n throw new Error(`Schema ${schemaInfo.schemaKey.name} could not be found.`);\n\n return schema;\n }\n\n /**\n * Creates a SchemaProps object by loading the Schema information from the given SchemaContext.\n * @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.\n * @param schemaContext The SchemaContext holding the Schema.\n * @returns The SchemaProps object.\n */\n protected async createSchemaProps(schemaKey: SchemaKey, schemaContext: SchemaContext): Promise<SchemaProps> {\n const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, SchemaMatchType.Latest);\n if (!schemaInfo)\n throw new Error(`Schema ${schemaKey.name} could not be found.`);\n\n const schemaReferences: Array<SchemaReferenceProps> = [];\n const schemaProps: SchemaProps = {\n $schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n name: schemaKey.name,\n alias: schemaInfo.alias,\n version: schemaInfo.schemaKey.version.toString(),\n references: schemaReferences,\n items: {}\n };\n\n schemaInfo.references.forEach((ref) => {\n schemaReferences.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });\n });\n\n return schemaProps;\n }\n\n private async startLoadingPartialSchema(schemaProps: SchemaProps, schemaContext: SchemaContext): Promise<void> {\n if (schemaContext.schemaExists(SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`))) {\n return;\n }\n\n const controller = new SchemaLoadingController();\n const schemaReader = new IncrementalSchemaReader(schemaContext, true);\n const schema = new Schema(schemaContext);\n schema.setLoadingController(controller);\n\n await schemaReader.readSchema(schema, schemaProps);\n\n if (!this._options.loadPartialSchemaOnly)\n controller.start(this.startLoadingFullSchema(schema));\n }\n\n private async loadFullSchema(schema: Schema): Promise<void> {\n const fullSchemaProps = await this.getSchemaJson(schema.schemaKey, schema.context)\n const reader = new IncrementalSchemaReader(schema.context, false);\n await reader.readSchema(schema, fullSchemaProps, false);\n }\n\n private async startLoadingFullSchema(schema: Schema): Promise<void> {\n if (!schema.loadingController)\n return;\n\n // If the schema is already resolved, return it directly.\n if (schema.loadingController.isComplete || schema.loadingController.inProgress) {\n return;\n }\n\n // Since the schema relies on it's references, they get triggered to be resolved\n // first by recursively calling this method. After all references has been resolved\n // the schema itself gets resolved.\n await Promise.all(schema.references.map(async (referenceSchema) => {\n if (referenceSchema.loadingController && referenceSchema.loadingController.inProgress)\n return referenceSchema.loadingController.wait();\n else\n return this.startLoadingFullSchema(referenceSchema);\n }));\n\n return this.loadFullSchema(schema);\n }\n\n private async sortSchemaPartials(schemaPartials: ReadonlyArray<SchemaProps>, schemaContext: SchemaContext): Promise<ReadonlyArray<SchemaProps>> {\n const schemaInfos: Array<SchemaInfo & { props: SchemaProps }> = [];\n for (const schemaProps of schemaPartials) {\n const schemaKey = SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`);\n const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, SchemaMatchType.Latest);\n if (!schemaInfo)\n throw new Error(`Schema ${schemaKey.name} could not be found.`);\n\n schemaInfos.push({ ...schemaInfo, props: schemaProps });\n }\n\n const orderedSchemaInfos = SchemaGraphUtil.buildDependencyOrderedSchemaInfoList(schemaInfos) as Array<SchemaInfo & { props: SchemaProps }>;\n return orderedSchemaInfos.map((schemaInfo) => schemaInfo.props);\n }\n}\n\n/**\n * Helper class to manage schema infos for a schema context.\n */\nclass SchemaInfoCache {\n private readonly _schemaInfoCache: WeakMap<SchemaContext, Array<SchemaInfo>>;\n private readonly _schemaInfoLoader: LoadSchemaInfoHandler;\n\n constructor(schemaInfoLoader: LoadSchemaInfoHandler) {\n this._schemaInfoCache = new WeakMap<SchemaContext, Array<SchemaInfo>>();\n this._schemaInfoLoader = schemaInfoLoader;\n }\n\n public async getSchemasByContext(context: SchemaContext): Promise<SchemaInfo[] | undefined> {\n if (!this._schemaInfoCache.has(context)) {\n const schemaInfos = await this._schemaInfoLoader(context);\n this._schemaInfoCache.set(context, Array.from(schemaInfos));\n }\n return this._schemaInfoCache.get(context);\n }\n\n public async lookup(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<SchemaInfo | undefined> {\n const contextSchemaInfos = await this.getSchemasByContext(context);\n return contextSchemaInfos\n ? contextSchemaInfos.find((schemaInfo) => schemaInfo.schemaKey.matches(schemaKey, matchType))\n : undefined;\n }\n\n public remove(schemaKey: SchemaKey, context: SchemaContext): void {\n const contextSchemaInfos = this._schemaInfoCache.get(context);\n if (!contextSchemaInfos)\n return;\n\n const index = contextSchemaInfos.findIndex((schemaInfo) => schemaInfo.schemaKey.name === schemaKey.name);\n if (index !== -1) {\n contextSchemaInfos.splice(index, 1);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSchemaReader.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,gBAAgB;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;;;;OAKG;gBACS,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO;IAK9D;;;;OAIG;cACgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO;IAMlF;;;;;;;OAOG;IACmB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAc1J,OAAO,CAAC,iBAAiB;
|
|
1
|
+
{"version":3,"file":"IncrementalSchemaReader.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAI7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGpD;;;;GAIG;AACH,qBAAa,uBAAwB,SAAQ,gBAAgB;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAU;IAEvC;;;;;OAKG;gBACS,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO;IAK9D;;;;OAIG;cACgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,SAAS,GAAG,OAAO;IAMlF;;;;;;;OAOG;IACmB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAc1J,OAAO,CAAC,iBAAiB;CAkB1B"}
|
|
@@ -58,6 +58,7 @@ class IncrementalSchemaReader extends Helper_1.SchemaReadHelper {
|
|
|
58
58
|
if (schemaItem.loadingController === undefined) {
|
|
59
59
|
const controller = new SchemaLoadingController_1.SchemaLoadingController();
|
|
60
60
|
schemaItem.setLoadingController(controller);
|
|
61
|
+
return this.schemaItemLoading(schemaItem);
|
|
61
62
|
}
|
|
62
63
|
if (Class_1.ECClass.isECClass(schemaItem)
|
|
63
64
|
|| schemaItem.schemaItemType === ECObjects_1.SchemaItemType.KindOfQuantity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSchemaReader.js","sourceRoot":"","sources":["../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AS;YAC1B,OAAO;QAET,IAAI,UAAU,CAAC,iBAAiB,KAAK,SAAS,EAAE,CAAC;YAC/C,MAAM,UAAU,GAAG,IAAI,iDAAuB,EAAE,CAAC;YACjD,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;YAE5C,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,eAAO,CAAC,SAAS,CAAC,UAAU,CAAC;eAC5B,UAAU,CAAC,cAAc,KAAK,0BAAc,CAAC,cAAc;eAC3D,UAAU,CAAC,cAAc,KAAK,0BAAc,CAAC,MAAM;YACtD,UAAU,CAAC,iBAAiB,CAAC,UAAU,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC;;YAE7D,UAAU,CAAC,iBAAiB,CAAC,UAAU,GAAG,IAAI,CAAC;IACnD,CAAC;CACF;AAjED,0DAiEC","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 *--------------------------------------------------------------------------------------------*/\nimport { SchemaContext } from \"../Context\";\nimport { SchemaReadHelper } from \"../Deserialization/Helper\";\nimport { JsonParser } from \"../Deserialization/JsonParser\";\nimport { SchemaItemType } from \"../ECObjects\";\nimport { ECClass } from \"../Metadata/Class\";\nimport { Schema } from \"../Metadata/Schema\";\nimport { SchemaItem } from \"../Metadata/SchemaItem\";\nimport { SchemaLoadingController } from \"../utils/SchemaLoadingController\";\n\n/**\n * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]\n * but overrides a few methods to support the incremental schema loading case.\n * @internal\n */\nexport class IncrementalSchemaReader extends SchemaReadHelper {\n private readonly _incremental: boolean;\n\n /**\n * Initializes a new [[IncrementalSchemaReader]] instance.\n * @param schemaContext The [[SchemaContext]] used to load the schemas.\n * @param incremental Indicates that the Schema should be read incrementally.\n * Pass false to load the full schema without an incremental/partial load.\n */\n constructor(schemaContext: SchemaContext, incremental: boolean) {\n super(JsonParser, schemaContext);\n this._incremental = incremental;\n }\n\n /**\n * Indicates that a given [[SchemaItem]] has been fully loaded.\n * @param schemaItem The SchemaItem to check.\n * @returns True if the item has been loaded, false if still in progress.\n */\n protected override isSchemaItemLoaded(schemaItem: SchemaItem | undefined): boolean {\n return schemaItem !== undefined\n && schemaItem.loadingController !== undefined\n && schemaItem.loadingController.isComplete;\n }\n\n /**\n * Starts loading the [[SchemaItem]] identified by the given name and itemType.\n * @param schema The [[Schema]] that contains the SchemaItem.\n * @param name The name of the SchemaItem to load.\n * @param itemType The SchemaItem type name of the item to load.\n * @param schemaItemObject The object accepting the SchemaItem data.\n * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.\n */\n public override async loadSchemaItem(schema: Schema, name: string, itemType: string, schemaItemObject: Readonly<unknown>): Promise<SchemaItem | undefined> {\n const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);\n\n // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.\n // The fromJSON method of the actual class instances may complain about missing properties in the props, so\n // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.\n if (this._incremental && schemaItemObject && schemaItem) {\n await schemaItem.fromJSON(schemaItemObject);\n }\n\n this.schemaItemLoading(schemaItem);\n return schemaItem;\n }\n\n private schemaItemLoading(schemaItem: SchemaItem | undefined): void {\n if (schemaItem === undefined)\n return;\n\n if (schemaItem.loadingController === undefined) {\n const controller = new SchemaLoadingController();\n schemaItem.setLoadingController(controller);\n\n return this.schemaItemLoading(schemaItem);\n }\n\n if (ECClass.isECClass(schemaItem)\n || schemaItem.schemaItemType === SchemaItemType.KindOfQuantity\n || schemaItem.schemaItemType === SchemaItemType.Format)\n schemaItem.loadingController.isComplete = !this._incremental;\n else\n schemaItem.loadingController.isComplete = true;\n }\n}"]}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { SchemaItemProps, SchemaProps } from "../Deserialization/JsonProps";
|
|
2
|
+
import { SchemaItemType } from "../ECObjects";
|
|
2
3
|
import { SchemaInfo } from "../Interfaces";
|
|
3
4
|
import { CustomAttribute } from "../Metadata/CustomAttribute";
|
|
5
|
+
interface NamedSchemaItemProps extends SchemaItemProps {
|
|
6
|
+
name: string;
|
|
7
|
+
schemaItemType: SchemaItemType;
|
|
8
|
+
}
|
|
4
9
|
/**
|
|
5
10
|
* Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
|
|
6
11
|
* This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)
|
|
@@ -24,9 +29,9 @@ export declare class SchemaParser {
|
|
|
24
29
|
* @param context The SchemaContext containing the Schema.
|
|
25
30
|
* @returns The corrected SchemaItemProps.
|
|
26
31
|
*/
|
|
27
|
-
static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<
|
|
32
|
+
static parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps[] | undefined>;
|
|
28
33
|
private static parseItems;
|
|
29
|
-
static parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<
|
|
34
|
+
static parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps>;
|
|
30
35
|
}
|
|
31
36
|
/**
|
|
32
37
|
* Utility method to parse CustomAttribute data retrieved from a ECSql query.
|
|
@@ -39,4 +44,5 @@ export declare function parseCustomAttribute(customAttribute: {
|
|
|
39
44
|
ecSchema: string;
|
|
40
45
|
[propName: string]: any;
|
|
41
46
|
}): CustomAttribute;
|
|
47
|
+
export {};
|
|
42
48
|
//# sourceMappingURL=SchemaParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaParser.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":"AAMA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
|
74
74
|
case ECObjects_1.SchemaItemType.KindOfQuantity:
|
|
75
75
|
const koqParser = new SchemaItemParsers_1.KindOfQuantityParser(schemaName, schemaInfos);
|
|
76
|
-
return koqParser.parse(schemaItem);
|
|
76
|
+
return await koqParser.parse(schemaItem);
|
|
77
77
|
case ECObjects_1.SchemaItemType.EntityClass:
|
|
78
78
|
case ECObjects_1.SchemaItemType.StructClass:
|
|
79
79
|
const classParser = new ClassParsers_1.ClassParser(schemaName, schemaInfos);
|
|
80
|
-
return classParser.parse(schemaItem);
|
|
80
|
+
return await classParser.parse(schemaItem);
|
|
81
81
|
case ECObjects_1.SchemaItemType.RelationshipClass:
|
|
82
82
|
const relationshipParser = new ClassParsers_1.RelationshipClassParser(schemaName, schemaInfos);
|
|
83
|
-
return relationshipParser.parse(schemaItem);
|
|
83
|
+
return await relationshipParser.parse(schemaItem);
|
|
84
84
|
case ECObjects_1.SchemaItemType.Mixin:
|
|
85
85
|
const mixinParser = new ClassParsers_1.MixinParser(schemaName, schemaInfos);
|
|
86
|
-
return mixinParser.parse(schemaItem);
|
|
86
|
+
return await mixinParser.parse(schemaItem);
|
|
87
87
|
case ECObjects_1.SchemaItemType.CustomAttributeClass:
|
|
88
88
|
const caParser = new ClassParsers_1.CustomAttributeClassParser(schemaName, schemaInfos);
|
|
89
|
-
return caParser.parse(schemaItem);
|
|
89
|
+
return await caParser.parse(schemaItem);
|
|
90
90
|
default:
|
|
91
91
|
const itemParser = new SchemaItemParsers_1.SchemaItemParser(schemaName, schemaInfos);
|
|
92
|
-
return itemParser.parse(schemaItem);
|
|
92
|
+
return await itemParser.parse(schemaItem);
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaParser.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/SchemaParser.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;
|
|
1
|
+
{"version":3,"file":"SchemaParser.js","sourceRoot":"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AC,UAAU,CAAyB,CAAC;YAClE;gBACE,MAAM,UAAU,GAAG,IAAI,oCAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;gBACjE,OAAO,MAAM,UAAU,CAAC,KAAK,CAAC,UAAU,CAAyB,CAAC;QACtE,CAAC;IACH,CAAC;CACF;AA9ED,oCA8EC;AAED;;;;;GAKG;AACH,SAAgB,oBAAoB,CAAC,eAA+E;IAClH,OAAO;QACL,GAAG,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC;QAC3C,SAAS,EAAE,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,eAAe,CAAC,OAAO,EAAE;KACpF,CAAA;AACH,CAAC","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 { ECSchemaNamespaceUris } from \"../Constants\";\nimport { SchemaItemProps, SchemaProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType } from \"../ECObjects\";\nimport { SchemaInfo } from \"../Interfaces\";\nimport { CustomAttribute } from \"../Metadata/CustomAttribute\";\nimport { ClassParser, CustomAttributeClassParser, MixinParser, RelationshipClassParser } from \"./ClassParsers\";\nimport { KindOfQuantityParser, SchemaItemParser } from \"./SchemaItemParsers\";\n\nfunction clean(_key: string, value: any) {\n return value === null ? undefined : value;\n}\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\ninterface NamedSchemaItemProps extends SchemaItemProps {\n name: string;\n schemaItemType: SchemaItemType;\n}\n\n/**\n * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.\n * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)\n * returned from the iModelDb is in a different format than is required for a given Schema or\n * SchemaItemProps JSON object.\n * @internal\n */\nexport class SchemaParser {\n /**\n * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps\n * JSON object.\n * @param schema The SchemaProps JSON object to parse.\n * @param context The SchemaContext that will contain the schema and it's references.\n * @returns The corrected SchemaProps JSON.\n */\n public static async parse(schema: SchemaProps, schemaInfos: Iterable<SchemaInfo>): Promise<SchemaProps> {\n const props = schema as MutableSchemaProps;\n props.$schema = ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,\n props.customAttributes = props.customAttributes ? props.customAttributes.map((attr: any) => { return parseCustomAttribute(attr); }) : undefined;\n props.label = props.label === null ? undefined : props.label;\n props.description = props.description === null ? undefined : props.description;\n if (props.items) {\n props.items = await this.parseItems(props.items as any, props.name, schemaInfos);\n }\n\n if (!props.customAttributes || props.customAttributes.length === 0)\n delete props.customAttributes;\n\n const cleaned = JSON.parse(JSON.stringify(props, clean)) as SchemaProps;\n return cleaned;\n }\n\n /**\n * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.\n * @param schemaItems The SchemaItemProps array returned from an iModelDb.\n * @param schemaName The name of the Schema to which the SchemaItemProps belong.\n * @param context The SchemaContext containing the Schema.\n * @returns The corrected SchemaItemProps.\n */\n public static async parseSchemaItems(schemaItems: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps[] | undefined> {\n const items: NamedSchemaItemProps[] = [];\n for (const item of schemaItems) {\n const props = await this.parseItem(item, schemaName, schemaInfos);\n const cleaned = JSON.parse(JSON.stringify(props, clean));\n items.push(cleaned);\n }\n return items.length > 0 ? items : undefined;\n }\n\n private static async parseItems(schemaItemProps: readonly SchemaItemProps[], schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<{ [name: string]: SchemaItemProps } | undefined> {\n const items: { [name: string]: SchemaItemProps } = {};\n for (const itemProps of schemaItemProps) {\n const props = await this.parseItem(itemProps, schemaName, schemaInfos);\n items[props.name] = props;\n delete (props as any).name;\n }\n\n return Object.keys(items).length > 0 ? items : undefined;\n }\n\n public static async parseItem(props: SchemaItemProps, schemaName: string, schemaInfos: Iterable<SchemaInfo>): Promise<NamedSchemaItemProps> {\n const schemaItem = \"string\" === typeof (props) ? JSON.parse(props) : props;\n const type = parseSchemaItemType(schemaItem.schemaItemType);\n switch (type) {\n case SchemaItemType.KindOfQuantity:\n const koqParser = new KindOfQuantityParser(schemaName, schemaInfos);\n return await koqParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.EntityClass:\n case SchemaItemType.StructClass:\n const classParser = new ClassParser(schemaName, schemaInfos);\n return await classParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.RelationshipClass:\n const relationshipParser = new RelationshipClassParser(schemaName, schemaInfos);\n return await relationshipParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.Mixin:\n const mixinParser = new MixinParser(schemaName, schemaInfos);\n return await mixinParser.parse(schemaItem) as NamedSchemaItemProps;\n case SchemaItemType.CustomAttributeClass:\n const caParser = new CustomAttributeClassParser(schemaName, schemaInfos);\n return await caParser.parse(schemaItem) as NamedSchemaItemProps;\n default:\n const itemParser = new SchemaItemParser(schemaName, schemaInfos);\n return await itemParser.parse(schemaItem) as NamedSchemaItemProps;\n }\n }\n}\n\n/**\n * Utility method to parse CustomAttribute data retrieved from a ECSql query.\n * @param customAttribute CustomAttribute data as retrieved from an iModel query.\n * @returns The CustomAttribute instance.\n * @internal\n */\nexport function parseCustomAttribute(customAttribute: { ecClass: string; ecSchema: string;[propName: string]: any; }): CustomAttribute {\n return {\n ...customAttribute[customAttribute.ecClass],\n className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,\n }\n}"]}
|
|
@@ -3,7 +3,6 @@ import { ConstantProps, CustomAttributeClassProps, EntityClassProps, Enumeration
|
|
|
3
3
|
import { SchemaInfo } from "../Interfaces";
|
|
4
4
|
import { SchemaKey } from "../SchemaKey";
|
|
5
5
|
import { IncrementalSchemaLocater, SchemaLocaterOptions } from "./IncrementalSchemaLocater";
|
|
6
|
-
import { PerformanceLogger } from "./PerformanceLogger";
|
|
7
6
|
interface QueryParameters {
|
|
8
7
|
[parameterName: string]: string | number;
|
|
9
8
|
}
|
|
@@ -23,8 +22,6 @@ export interface ECSqlQueryOptions {
|
|
|
23
22
|
export interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {
|
|
24
23
|
/** Query for Schemas using multiple queries. Defaults to false. */
|
|
25
24
|
readonly useMultipleQueries?: boolean;
|
|
26
|
-
/** Collects query execution performance data. Defaults to false. */
|
|
27
|
-
readonly performanceLogger?: PerformanceLogger;
|
|
28
25
|
}
|
|
29
26
|
/**
|
|
30
27
|
* An abstract [[IncrementalSchemaLocater]] implementation for loading
|
|
@@ -60,10 +57,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
60
57
|
* @param context The [[SchemaContext]] to use for resolving references.
|
|
61
58
|
* @internal
|
|
62
59
|
*/
|
|
63
|
-
getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined>;
|
|
64
|
-
/**
|
|
65
|
-
* Gets the [[SchemaProps]] without schemaItems.
|
|
66
|
-
*/
|
|
60
|
+
protected getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined>;
|
|
67
61
|
/**
|
|
68
62
|
* Gets the [[SchemaProps]] without schemaItems for the given schema name.
|
|
69
63
|
* @param schemaName The name of the Schema.
|
|
@@ -71,7 +65,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
71
65
|
* @returns
|
|
72
66
|
* @internal
|
|
73
67
|
*/
|
|
74
|
-
getSchemaNoItems
|
|
68
|
+
private getSchemaNoItems;
|
|
75
69
|
/**
|
|
76
70
|
* Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
|
|
77
71
|
* @param context The schema context to lookup the meta schema.
|
|
@@ -85,7 +79,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
85
79
|
* @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
|
|
86
80
|
* @internal
|
|
87
81
|
*/
|
|
88
|
-
getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]>;
|
|
82
|
+
protected getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]>;
|
|
89
83
|
/**
|
|
90
84
|
* Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
|
|
91
85
|
* @param schemaName The name of the Schema.
|
|
@@ -93,7 +87,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
93
87
|
* @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
|
|
94
88
|
* @internal
|
|
95
89
|
*/
|
|
96
|
-
getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]>;
|
|
90
|
+
protected getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]>;
|
|
97
91
|
/**
|
|
98
92
|
* Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
|
|
99
93
|
* @param schemaName The name of the Schema.
|
|
@@ -101,7 +95,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
101
95
|
* @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
|
|
102
96
|
* @internal
|
|
103
97
|
*/
|
|
104
|
-
getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]>;
|
|
98
|
+
protected getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]>;
|
|
105
99
|
/**
|
|
106
100
|
* Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
|
|
107
101
|
* @param schemaName The name of the Schema.
|
|
@@ -109,7 +103,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
109
103
|
* @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
|
|
110
104
|
* @internal
|
|
111
105
|
*/
|
|
112
|
-
getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]>;
|
|
106
|
+
protected getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]>;
|
|
113
107
|
/**
|
|
114
108
|
* Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
|
|
115
109
|
* @param schemaName The name of the Schema.
|
|
@@ -117,7 +111,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
117
111
|
* @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
|
|
118
112
|
* @internal
|
|
119
113
|
*/
|
|
120
|
-
getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]>;
|
|
114
|
+
protected getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]>;
|
|
121
115
|
/**
|
|
122
116
|
* Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
|
|
123
117
|
* @param schema The name of the Schema.
|
|
@@ -125,7 +119,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
125
119
|
* @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
|
|
126
120
|
* @internal
|
|
127
121
|
*/
|
|
128
|
-
getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]>;
|
|
122
|
+
protected getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]>;
|
|
129
123
|
/**
|
|
130
124
|
* Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
|
|
131
125
|
* @param schema The name of the Schema.
|
|
@@ -133,7 +127,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
133
127
|
* @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
|
|
134
128
|
* @internal
|
|
135
129
|
*/
|
|
136
|
-
getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]>;
|
|
130
|
+
protected getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]>;
|
|
137
131
|
/**
|
|
138
132
|
* Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
|
|
139
133
|
* @param schema The name of the Schema.
|
|
@@ -141,7 +135,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
141
135
|
* @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
|
|
142
136
|
* @internal
|
|
143
137
|
*/
|
|
144
|
-
getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]>;
|
|
138
|
+
protected getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]>;
|
|
145
139
|
/**
|
|
146
140
|
* Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
|
|
147
141
|
* @param schema The name of the Schema.
|
|
@@ -149,7 +143,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
149
143
|
* @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
|
|
150
144
|
* @internal
|
|
151
145
|
*/
|
|
152
|
-
getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]>;
|
|
146
|
+
protected getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]>;
|
|
153
147
|
/**
|
|
154
148
|
* Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
|
|
155
149
|
* @param schema The name of the Schema.
|
|
@@ -157,7 +151,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
157
151
|
* @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
|
|
158
152
|
* @internal
|
|
159
153
|
*/
|
|
160
|
-
getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]>;
|
|
154
|
+
protected getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]>;
|
|
161
155
|
/**
|
|
162
156
|
* Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
|
|
163
157
|
* @param schema The name of the Schema.
|
|
@@ -165,7 +159,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
165
159
|
* @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
|
|
166
160
|
* @internal
|
|
167
161
|
*/
|
|
168
|
-
getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]>;
|
|
162
|
+
protected getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]>;
|
|
169
163
|
/**
|
|
170
164
|
* Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
|
|
171
165
|
* @param schema The name of the Schema.
|
|
@@ -173,7 +167,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
173
167
|
* @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
|
|
174
168
|
* @internal
|
|
175
169
|
*/
|
|
176
|
-
getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]>;
|
|
170
|
+
protected getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]>;
|
|
177
171
|
/**
|
|
178
172
|
* Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
|
|
179
173
|
* @param schema The name of the Schema.
|
|
@@ -181,7 +175,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
181
175
|
* @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
|
|
182
176
|
* @internal
|
|
183
177
|
*/
|
|
184
|
-
getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]>;
|
|
178
|
+
protected getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]>;
|
|
185
179
|
/**
|
|
186
180
|
* Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
|
|
187
181
|
* @param schema The name of the Schema.
|
|
@@ -189,12 +183,12 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
189
183
|
* @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
|
|
190
184
|
* @internal
|
|
191
185
|
*/
|
|
192
|
-
getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]>;
|
|
186
|
+
protected getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]>;
|
|
193
187
|
/**
|
|
194
188
|
* Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
|
|
195
189
|
* @internal
|
|
196
190
|
*/
|
|
197
|
-
loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>>;
|
|
191
|
+
protected loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>>;
|
|
198
192
|
/**
|
|
199
193
|
* Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
|
|
200
194
|
* can be included in the initial fetch.
|
|
@@ -202,7 +196,7 @@ export declare abstract class ECSqlSchemaLocater extends IncrementalSchemaLocate
|
|
|
202
196
|
* @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
|
|
203
197
|
* @internal
|
|
204
198
|
*/
|
|
205
|
-
getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined>;
|
|
199
|
+
protected getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined>;
|
|
206
200
|
private querySchemaItem;
|
|
207
201
|
private getFullSchema;
|
|
208
202
|
private getFullSchemaMultipleQueries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OA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MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAIpG;;;OAGG;cACa,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAWrE;;;;;;OAMG;cACa,iBAAiB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;YA8DlH,eAAe;YAuBf,aAAa;YAgBb,4BAA4B;CAmC3C"}
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
import {
|
|
5
|
+
import { Logger } from "@itwin/core-bentley";
|
|
6
|
+
import { SchemaMatchType } from "../ECObjects";
|
|
6
7
|
import { SchemaKey } from "../SchemaKey";
|
|
7
8
|
import { FullSchemaQueries } from "./FullSchemaQueries";
|
|
8
9
|
import { IncrementalSchemaLocater } from "./IncrementalSchemaLocater";
|
|
9
10
|
import { SchemaItemQueries } from "./SchemaItemQueries";
|
|
10
11
|
import { SchemaParser } from "./SchemaParser";
|
|
11
12
|
import { ecsqlQueries } from "./SchemaStubQueries";
|
|
13
|
+
const LOGGER_CATEGORY = "IncrementalSchemaLoading.Performance";
|
|
12
14
|
/**
|
|
13
15
|
* An abstract [[IncrementalSchemaLocater]] implementation for loading
|
|
14
16
|
* EC [Schema] instances from an iModelDb using ECSql queries.
|
|
@@ -41,17 +43,19 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
41
43
|
// to fetch the whole schema json.
|
|
42
44
|
if (!await this.supportPartialSchemaLoading(context))
|
|
43
45
|
return this.getSchemaProps(schemaKey);
|
|
44
|
-
const
|
|
46
|
+
const queryStart = Date.now();
|
|
45
47
|
const schemaProps = this.options.useMultipleQueries
|
|
46
48
|
? await this.getFullSchemaMultipleQueries(schemaKey, context)
|
|
47
49
|
: await this.getFullSchema(schemaKey, context);
|
|
48
|
-
|
|
50
|
+
const queryDuration = Date.now() - queryStart;
|
|
51
|
+
Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {
|
|
52
|
+
schemaName: schemaKey.name,
|
|
53
|
+
queryMode: this.options.useMultipleQueries ? "parallel" : "single",
|
|
54
|
+
duration: queryDuration,
|
|
55
|
+
});
|
|
49
56
|
return schemaProps;
|
|
50
57
|
}
|
|
51
58
|
;
|
|
52
|
-
/**
|
|
53
|
-
* Gets the [[SchemaProps]] without schemaItems.
|
|
54
|
-
*/
|
|
55
59
|
/**
|
|
56
60
|
* Gets the [[SchemaProps]] without schemaItems for the given schema name.
|
|
57
61
|
* @param schemaName The name of the Schema.
|
|
@@ -244,12 +248,16 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
244
248
|
* @internal
|
|
245
249
|
*/
|
|
246
250
|
async getSchemaPartials(schemaKey, context) {
|
|
247
|
-
const
|
|
251
|
+
const queryStart = Date.now();
|
|
248
252
|
const [schemaRow] = await this.executeQuery(ecsqlQueries.schemaStubQuery, {
|
|
249
253
|
parameters: { schemaName: schemaKey.name },
|
|
250
254
|
limit: 1
|
|
251
255
|
});
|
|
252
|
-
|
|
256
|
+
const queryDuration = Date.now() - queryStart;
|
|
257
|
+
Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {
|
|
258
|
+
schemaName: schemaKey.name,
|
|
259
|
+
duration: queryDuration,
|
|
260
|
+
});
|
|
253
261
|
if (!schemaRow)
|
|
254
262
|
return undefined;
|
|
255
263
|
const schemaPartials = [];
|
|
@@ -270,11 +278,12 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
270
278
|
if (!schemaStub) {
|
|
271
279
|
schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));
|
|
272
280
|
}
|
|
273
|
-
|
|
274
|
-
|
|
281
|
+
let items = schemaStub.items;
|
|
282
|
+
if (!items) {
|
|
283
|
+
Object.assign(schemaStub, items = { items: {} });
|
|
275
284
|
}
|
|
276
|
-
const existingItem =
|
|
277
|
-
Object.assign(
|
|
285
|
+
const existingItem = items[itemInfo.name] || {};
|
|
286
|
+
Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
|
|
278
287
|
};
|
|
279
288
|
const reviver = (_key, value) => {
|
|
280
289
|
if (value === null) {
|
|
@@ -290,7 +299,13 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
290
299
|
async querySchemaItem(context, schemaName, query, schemaType) {
|
|
291
300
|
const start = Date.now();
|
|
292
301
|
const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
|
|
293
|
-
|
|
302
|
+
const queryDuration = Date.now() - start;
|
|
303
|
+
Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {
|
|
304
|
+
schemaName,
|
|
305
|
+
itemCount: itemRows.length,
|
|
306
|
+
itemType: schemaType,
|
|
307
|
+
duration: queryDuration,
|
|
308
|
+
});
|
|
294
309
|
if (itemRows.length === 0)
|
|
295
310
|
return [];
|
|
296
311
|
const items = itemRows.map((itemRow) => {
|
|
@@ -316,7 +331,7 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
316
331
|
const schema = await this.getSchemaNoItems(schemaKey.name, context);
|
|
317
332
|
if (!schema)
|
|
318
333
|
return undefined;
|
|
319
|
-
schema.items = {};
|
|
334
|
+
const items = schema.items || (schema.items = {});
|
|
320
335
|
await Promise.all([
|
|
321
336
|
this.getEntities(schemaKey.name, context),
|
|
322
337
|
this.getMixins(schemaKey.name, context),
|
|
@@ -333,9 +348,14 @@ export class ECSqlSchemaLocater extends IncrementalSchemaLocater {
|
|
|
333
348
|
this.getPhenomenon(schemaKey.name, context),
|
|
334
349
|
this.getFormats(schemaKey.name, context)
|
|
335
350
|
]).then((itemResults) => {
|
|
336
|
-
const flatItemList = itemResults.reduce((acc,
|
|
351
|
+
const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));
|
|
337
352
|
flatItemList.forEach((schemaItem) => {
|
|
338
|
-
|
|
353
|
+
if (!schemaItem.name) {
|
|
354
|
+
// This should never be happen, as we query the schema items by name from the database, but since the SchemaProps
|
|
355
|
+
// have name optional, we need the check here to make the compiler happy.
|
|
356
|
+
throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);
|
|
357
|
+
}
|
|
358
|
+
items[schemaItem.name] = schemaItem;
|
|
339
359
|
});
|
|
340
360
|
});
|
|
341
361
|
return schema;
|
|
@@ -359,7 +379,7 @@ async function parseSchemaItemStubs(schemaName, itemRows, addItemsHandler, schem
|
|
|
359
379
|
await addItemsHandler(currentItem.schema, {
|
|
360
380
|
...schemaItem,
|
|
361
381
|
name: schemaItem.name,
|
|
362
|
-
schemaItemType:
|
|
382
|
+
schemaItemType: schemaItem.schemaItemType,
|
|
363
383
|
baseClass: baseClassName,
|
|
364
384
|
});
|
|
365
385
|
}
|
|
@@ -369,7 +389,7 @@ async function parseSchemaItemStubs(schemaName, itemRows, addItemsHandler, schem
|
|
|
369
389
|
await addItemsHandler(schemaName, {
|
|
370
390
|
...schemaItem,
|
|
371
391
|
name: schemaItem.name,
|
|
372
|
-
schemaItemType:
|
|
392
|
+
schemaItemType: schemaItem.schemaItemType,
|
|
373
393
|
mixins: itemRow.mixins
|
|
374
394
|
? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
|
|
375
395
|
: undefined,
|
|
@@ -380,7 +400,7 @@ async function parseSchemaItemStubs(schemaName, itemRows, addItemsHandler, schem
|
|
|
380
400
|
await addItemsHandler(mixinRow.schema, {
|
|
381
401
|
...mixinItem,
|
|
382
402
|
name: mixinItem.name,
|
|
383
|
-
schemaItemType:
|
|
403
|
+
schemaItemType: mixinItem.schemaItemType,
|
|
384
404
|
});
|
|
385
405
|
await parseBaseClasses(mixinRow.baseClasses);
|
|
386
406
|
}
|