@itwin/ecschema-metadata 5.2.0-dev.7 → 5.3.0-dev.1
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/CHANGELOG.md +36 -1
- package/lib/cjs/Deserialization/JsonProps.d.ts +9 -2
- package/lib/cjs/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/cjs/Deserialization/JsonProps.js.map +1 -1
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +37 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js +58 -0
- package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -0
- package/lib/cjs/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
- package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/cjs/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
- package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -0
- 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 +62 -34
- package/lib/cjs/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js +1 -0
- package/lib/cjs/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts +20 -3
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/IncrementalSchemaLocater.js +7 -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 +2 -7
- package/lib/cjs/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js +17 -17
- package/lib/cjs/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js +4 -4
- package/lib/cjs/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts +10 -4
- package/lib/cjs/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaParser.js +19 -19
- package/lib/cjs/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -1
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js +7 -24
- package/lib/cjs/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/cjs/Metadata/EntityClass.js +1 -1
- package/lib/cjs/Metadata/EntityClass.js.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/cjs/Metadata/KindOfQuantity.js +9 -22
- package/lib/cjs/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/cjs/Metadata/Schema.d.ts +2 -0
- package/lib/cjs/Metadata/Schema.d.ts.map +1 -1
- package/lib/cjs/Metadata/Schema.js +4 -0
- package/lib/cjs/Metadata/Schema.js.map +1 -1
- package/lib/cjs/ecschema-metadata.d.ts +2 -1
- package/lib/cjs/ecschema-metadata.d.ts.map +1 -1
- package/lib/cjs/ecschema-metadata.js +2 -1
- package/lib/cjs/ecschema-metadata.js.map +1 -1
- package/lib/esm/Deserialization/JsonProps.d.ts +9 -2
- package/lib/esm/Deserialization/JsonProps.d.ts.map +1 -1
- package/lib/esm/Deserialization/JsonProps.js.map +1 -1
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +37 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.js +54 -0
- package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -0
- package/lib/esm/{SchemaFormatsProvider.d.ts → Formatting/SchemaFormatsProvider.d.ts} +1 -1
- package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -0
- package/lib/esm/{SchemaFormatsProvider.js → Formatting/SchemaFormatsProvider.js} +6 -6
- package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -0
- 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 +61 -33
- package/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js +1 -0
- package/lib/esm/IncrementalLoading/FullSchemaQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts +20 -3
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js +7 -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 +2 -7
- package/lib/esm/IncrementalLoading/IncrementalSchemaReader.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts +4 -4
- package/lib/esm/IncrementalLoading/SchemaItemParsers.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js +17 -17
- package/lib/esm/IncrementalLoading/SchemaItemParsers.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js +4 -4
- package/lib/esm/IncrementalLoading/SchemaItemQueries.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts +10 -4
- package/lib/esm/IncrementalLoading/SchemaParser.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaParser.js +19 -19
- package/lib/esm/IncrementalLoading/SchemaParser.js.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.d.ts.map +1 -1
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js +7 -24
- package/lib/esm/IncrementalLoading/SchemaStubQueries.js.map +1 -1
- package/lib/esm/Metadata/EntityClass.js +1 -1
- package/lib/esm/Metadata/EntityClass.js.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.d.ts.map +1 -1
- package/lib/esm/Metadata/KindOfQuantity.js +9 -22
- package/lib/esm/Metadata/KindOfQuantity.js.map +1 -1
- package/lib/esm/Metadata/Schema.d.ts +2 -0
- package/lib/esm/Metadata/Schema.d.ts.map +1 -1
- package/lib/esm/Metadata/Schema.js +4 -0
- package/lib/esm/Metadata/Schema.js.map +1 -1
- package/lib/esm/ecschema-metadata.d.ts +2 -1
- package/lib/esm/ecschema-metadata.d.ts.map +1 -1
- package/lib/esm/ecschema-metadata.js +2 -1
- package/lib/esm/ecschema-metadata.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/cjs/SchemaFormatsProvider.d.ts.map +0 -1
- package/lib/cjs/SchemaFormatsProvider.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
- package/lib/esm/SchemaFormatsProvider.d.ts.map +0 -1
- package/lib/esm/SchemaFormatsProvider.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAMhG,OAAO,EAAE,mBAAmB,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpF,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,4BAA4B,CAAC;AAE5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAoFnD;;;;GAIG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,wBAAwB;IACvE;;OAEG;IACH,IAAuB,OAAO;QAC5B,OAAO,KAAK,CAAC,OAAoC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAgBD;;;;;;OAMG;IACI,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,OAAsB;QACrE,gHAAgH;QAChH,gHAAgH;QAChH,kCAAkC;QAClC,IAAI,CAAC,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC;YAClD,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAExC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzB,MAAM,WAAW,GAAG,IA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,CAAC,CAAC;IAEF,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,UAAU,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;QAC9E,MAAM,eAAe,CAAC,UAAU,EAAE;YAChC,GAAG,UAAU;YACb,IAAI,EAAE,UAAU,CAAC,IAAK;YACtB,cAAc,EAAE,mBAAmB,CAAC,UAAU,CAAC,cAAe,CAAE;YAChE,MAAM,EAAE,OAAO,CAAC,MAAM;gBACpB,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1E,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;QAEH,MAAM,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAE5C,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC5C,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACnF,MAAM,eAAe,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACrC,GAAG,SAAS;gBACZ,IAAI,EAAE,SAAS,CAAC,IAAK;gBACrB,cAAc,EAAE,mBAAmB,CAAC,SAAS,CAAC,cAAe,CAAE;aAChE,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;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 { SchemaContext } from \"../Context\";\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\nimport { parseSchemaItemType, SchemaItemType, SchemaMatchType } from \"../ECObjects\";\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\nimport { PerformanceLogger } from \"./PerformanceLogger\";\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { SchemaParser } from \"./SchemaParser\";\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\n\ninterface SchemaItemInfo {\n readonly name: string;\n readonly schemaItemType: SchemaItemType;\n}\n\ninterface SchemaInfoRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly references: string;\n}\n\ninterface SchemaStubRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly displayLabel: string;\n readonly description: string;\n readonly references: string;\n readonly items: string;\n}\n\ninterface BaseClassStubRow {\n readonly schema: string;\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n}\n\ninterface SchemaItemStubRow {\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier?: number;\n readonly baseClasses?: Array<BaseClassStubRow>;\n readonly mixins?: Array<{\n readonly schema: string,\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n readonly baseClasses?: Array<BaseClassStubRow>\n }>;\n}\n\ninterface SchemaRow {\n schema: string\n}\n\ninterface SchemaItemRow {\n item: string | SchemaItemProps;\n}\n\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K]\n};\n\ninterface QueryParameters {\n [parameterName: string]: string | number;\n}\n\n/**\n * Query options used by the ECSqlSchemaLocater.\n * @internal\n */\nexport interface ECSqlQueryOptions {\n parameters?: QueryParameters;\n limit?: number;\n}\n\n/**\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\n * schema is to be loaded. All options are optional.\n * @internal\n */\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\n /** Query for Schemas using multiple queries. Defaults to false. */\n readonly useMultipleQueries?: boolean;\n /** Collects query execution performance data. Defaults to false. */\n readonly performanceLogger?: PerformanceLogger;\n}\n\n/**\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\n * EC [Schema] instances from an iModelDb using ECSql queries.\n * @internal\n */\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\n /**\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\n */\n protected override get options(): ECSqlSchemaLocaterOptions {\n return super.options as ECSqlSchemaLocaterOptions;\n }\n\n /**\n * Initializes a new ECSqlSchemaLocater instance.\n * @param options The options used by this Schema locater.\n */\n constructor(options?: ECSqlSchemaLocaterOptions) {\n super(options);\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\n\n /**\n * Gets the [[SchemaProps]] for the given schema key.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\n\n /**\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @internal\n */\n public async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\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(context))\n return this.getSchemaProps(schemaKey);\n\n const start = Date.now();\n const schemaProps = this.options.useMultipleQueries\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\n : await this.getFullSchema(schemaKey, context);\n\n this.options.performanceLogger?.logSchema(start, schemaKey.name);\n\n return schemaProps;\n };\n\n /**\n * Gets the [[SchemaProps]] without schemaItems.\n */\n /**\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @returns\n * @internal\n */\n public async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n return SchemaParser.parse(schema, context);\n }\n\n /**\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\n * @param context The schema context to lookup the meta schema.\n * @returns true if the context has a supported meta schema version, false otherwise.\n */\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\n return metaSchemaInfo !== undefined;\n };\n\n /**\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to which the schema belongs.\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\n * @internal\n */\n public async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\n }\n\n /**\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\n * @internal\n */\n public async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\n }\n\n /**\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\n * @internal\n */\n public async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\n }\n\n /**\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\n }\n\n\n /**\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.structQuery;\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\n }\n\n /**\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\n }\n\n /**\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\n }\n\n /**\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\n }\n\n /**\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\n }\n\n /**\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\n }\n\n /**\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\n }\n\n /**\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\n }\n\n /**\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\n }\n\n /**\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\n * @internal\n */\n public async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\n }\n\n /**\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\n * @internal\n */\n public async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\n return schemaRows.map((schemaRow) => (\n {\n alias: schemaRow.alias,\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\n }\n ));\n }\n\n /**\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\n * can be included in the initial fetch.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\n * @internal\n */\n public async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\n const [schemaRow] = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\n parameters: { schemaName: schemaKey.name },\n limit: 1\n });\n\n if (!schemaRow)\n return undefined;\n\n const schemaPartials: Array<SchemaProps> = [];\n const addSchema = async (key: SchemaKey) => {\n const stub = await this.createSchemaProps(key, context);\n schemaPartials.push(stub);\n\n if (stub.references) {\n for (const referenceProps of stub.references) {\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\n }\n }\n }\n\n return stub;\n };\n\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\n if (!schemaStub) {\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\n }\n\n if (!schemaStub.items) {\n Object.assign(schemaStub, { items: {} });\n }\n\n const existingItem = schemaStub.items![itemInfo.name] || {};\n Object.assign(schemaStub.items!, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\n };\n\n const reviver = (_key: string, value: any) => {\n if (value === null) {\n return undefined;\n }\n return value;\n };\n\n await addSchema(schemaKey);\n\n await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);\n\n return schemaPartials;\n }\n\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\n const start = Date.now();\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\n this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);\n\n if (itemRows.length === 0)\n return [];\n\n const items = itemRows.map((itemRow: SchemaItemRow) => {\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\n });\n\n return await SchemaParser.parseSchemaItems(items, schemaName, context) as Array<TRow> ?? []\n }\n\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n if (schema.items) {\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\n }\n\n return SchemaParser.parse(schema, context);\n }\n\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\n if (!schema)\n return undefined;\n\n schema.items = {};\n await Promise.all([\n this.getEntities(schemaKey.name, context),\n this.getMixins(schemaKey.name, context),\n this.getStructs(schemaKey.name, context),\n this.getRelationships(schemaKey.name, context),\n this.getCustomAttributeClasses(schemaKey.name, context),\n this.getKindOfQuantities(schemaKey.name, context),\n this.getPropertyCategories(schemaKey.name, context),\n this.getEnumerations(schemaKey.name, context),\n this.getUnits(schemaKey.name, context),\n this.getInvertedUnits(schemaKey.name, context),\n this.getUnitSystems(schemaKey.name, context),\n this.getConstants(schemaKey.name, context),\n this.getPhenomenon(schemaKey.name, context),\n this.getFormats(schemaKey.name, context)\n ]).then((itemResults) => {\n const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));\n flatItemList.forEach((schemaItem) => {\n schema.items![schemaItem.name!] = schemaItem;\n });\n });\n\n return schema;\n }\n}\n\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\n return { schemaKey: SchemaKey.parseString(referenceName) };\n}\n\nasync function parseSchemaItemStubs(schemaName: string, context: SchemaContext, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler) {\n if (!itemRows || itemRows.length === 0) {\n return;\n }\n\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\n if (!baseClasses || baseClasses.length < 2)\n return;\n\n for (let index = baseClasses.length - 1; index >= 0;) {\n const currentItem = baseClasses[index--];\n const baseClassItem = baseClasses[index];\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\n\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, context);\n await addItemsHandler(currentItem.schema, {\n ...schemaItem,\n name: schemaItem.name!,\n schemaItemType: parseSchemaItemType(schemaItem.schemaItemType!)!,\n baseClass: baseClassName,\n });\n }\n };\n\n for (const itemRow of itemRows) {\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, context);\n await addItemsHandler(schemaName, {\n ...schemaItem,\n name: schemaItem.name!,\n schemaItemType: parseSchemaItemType(schemaItem.schemaItemType!)!,\n mixins: itemRow.mixins\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\n : undefined,\n });\n\n await parseBaseClasses(itemRow.baseClasses);\n\n for (const mixinRow of itemRow.mixins || []) {\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, context);\n await addItemsHandler(mixinRow.schema, {\n ...mixinItem,\n name: mixinItem.name!,\n schemaItemType: parseSchemaItemType(mixinItem.schemaItemType!)!,\n });\n await parseBaseClasses(mixinRow.baseClasses);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ECSqlSchemaLocater.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/ECSqlSchemaLocater.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,OAAO,EAAkB,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAwB,MAAM,4BAA4B,CAAC;AAC5F,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AA2DnD,MAAM,eAAe,GAAG,sCAAsC,CAAC;AAqB/D;;;;GAIG;AACH,MAAM,OAAgB,kBAAmB,SAAQ,wBAAwB;IACvE;;OAEG;IACH,IAAuB,OAAO;QAC5B,OAAO,KAAK,CAAC,OAAoC,CAAC;IACpD,CAAC;IAED;;;OAGG;IACH,YAAY,OAAmC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;IAgBD;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,SAAoB,EAAE,OAAsB;QACxE,gHAAgH;QAChH,gHAAgH;QAChH,kCAAkC;QAClC,IAAI,CAAC,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC;YAClD,OAAO,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAExC,MAAM,UAAU,G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cAAc;aACzC,CAAC,CAAC;YACH,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;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 *--------------------------------------------------------------------------------------------*/\nimport { Logger } from \"@itwin/core-bentley\";\nimport { SchemaContext } from \"../Context\";\nimport { ConstantProps, CustomAttributeClassProps, EntityClassProps, EnumerationProps, InvertedUnitProps, KindOfQuantityProps, MixinProps,\n PhenomenonProps, PropertyCategoryProps, RelationshipClassProps, SchemaItemFormatProps, SchemaItemProps, SchemaItemUnitProps, SchemaProps,\n StructClassProps, UnitSystemProps } from \"../Deserialization/JsonProps\";\nimport { SchemaItemType, SchemaMatchType } from \"../ECObjects\";\nimport { SchemaInfo, WithSchemaKey } from \"../Interfaces\";\nimport { SchemaKey } from \"../SchemaKey\";\nimport { FullSchemaQueries } from \"./FullSchemaQueries\";\nimport { IncrementalSchemaLocater, SchemaLocaterOptions } from \"./IncrementalSchemaLocater\";\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { SchemaParser } from \"./SchemaParser\";\nimport { ecsqlQueries } from \"./SchemaStubQueries\";\n\ninterface SchemaItemInfo {\n readonly name: string;\n readonly schemaItemType: SchemaItemType;\n}\n\ninterface SchemaInfoRow {\n readonly name: string;\n readonly version: string;\n readonly alias: string;\n readonly label: string;\n readonly description: string; \n readonly references: string;\n}\n\ninterface SchemaStubRow {\n readonly item: string;\n}\n\ninterface BaseClassStubRow {\n readonly schema: string;\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n}\n\ninterface SchemaItemStubRow {\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier?: number;\n readonly baseClasses?: Array<BaseClassStubRow>;\n readonly mixins?: Array<{\n readonly schema: string,\n readonly name: string;\n readonly schemaItemType: string;\n readonly modifier: number;\n readonly baseClasses?: Array<BaseClassStubRow>\n }>;\n}\n\ninterface SchemaRow {\n schema: string\n}\n\ninterface SchemaItemRow {\n item: string | SchemaItemProps;\n}\n\ntype AddSchemaItemHandler = <T extends SchemaItemInfo>(schemaName: string, itemStub: T) => Promise<void>;\n\ntype MutableSchemaProps = {\n -readonly [K in keyof SchemaProps]: SchemaProps[K];\n};\n\ninterface QueryParameters {\n [parameterName: string]: string | number;\n}\n\nconst LOGGER_CATEGORY = \"IncrementalSchemaLoading.Performance\";\n\n/**\n * Query options used by the ECSqlSchemaLocater.\n * @internal\n */\nexport interface ECSqlQueryOptions {\n parameters?: QueryParameters;\n limit?: number;\n}\n\n/**\n * Defines the [[ECSqlSchemaLocater]] options which determine how each\n * schema is to be loaded. All options are optional.\n * @internal\n */\nexport interface ECSqlSchemaLocaterOptions extends SchemaLocaterOptions {\n /** Query for Schemas using multiple queries. Defaults to false. */\n readonly useMultipleQueries?: boolean;\n}\n\n/**\n * An abstract [[IncrementalSchemaLocater]] implementation for loading\n * EC [Schema] instances from an iModelDb using ECSql queries.\n * @internal\n */\nexport abstract class ECSqlSchemaLocater extends IncrementalSchemaLocater {\n /**\n * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.\n */\n protected override get options(): ECSqlSchemaLocaterOptions {\n return super.options as ECSqlSchemaLocaterOptions;\n }\n\n /**\n * Initializes a new ECSqlSchemaLocater instance.\n * @param options The options used by this Schema locater.\n */\n constructor(options?: ECSqlSchemaLocaterOptions) {\n super(options);\n }\n\n /**\n * Executes the given ECSql query and returns the resulting rows.\n * @param query The ECSql query to execute.\n * @param options Optional arguments to control the query result.\n * @returns A promise that resolves to the resulting rows.\n */\n protected abstract executeQuery<TRow>(query: string, options?: ECSqlQueryOptions): Promise<ReadonlyArray<TRow>>;\n\n /**\n * Gets the [[SchemaProps]] for the given schema key.\n * @param schemaKey The schema key of the schema to be resolved.\n */\n protected abstract getSchemaProps(schemaKey: SchemaKey): Promise<SchemaProps | undefined>\n\n /**\n * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined\n * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @internal\n */\n protected async getSchemaJson(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\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(context))\n return this.getSchemaProps(schemaKey);\n\n const queryStart = Date.now();\n const schemaProps = this.options.useMultipleQueries\n ? await this.getFullSchemaMultipleQueries(schemaKey, context)\n : await this.getFullSchema(schemaKey, context);\n\n const queryDuration = Date.now() - queryStart;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved SchemaProps for ${schemaKey.name} in ${queryDuration}ms`, {\n schemaName: schemaKey.name,\n queryMode: this.options.useMultipleQueries ? \"parallel\" : \"single\",\n duration: queryDuration,\n });\n\n return schemaProps;\n };\n\n /**\n * Gets the [[SchemaProps]] without schemaItems for the given schema name.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to use for resolving references.\n * @returns\n * @internal\n */\n private async getSchemaNoItems(schemaName: string, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return SchemaParser.parse(schema, schemaInfos);\n }\n\n /**\n * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.\n * @param context The schema context to lookup the meta schema.\n * @returns true if the context has a supported meta schema version, false otherwise.\n */\n protected async supportPartialSchemaLoading(context: SchemaContext): Promise<boolean> {\n const metaSchemaKey = new SchemaKey(\"ECDbMeta\", 4, 0, 3);\n const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, SchemaMatchType.LatestWriteCompatible);\n return metaSchemaInfo !== undefined;\n };\n\n /**\n * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The [[SchemaContext]] to which the schema belongs.\n * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.\n * @internal\n */\n protected async getEntities(schema: string, context: SchemaContext, queryOverride?: string): Promise<EntityClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.entityQuery;\n return this.querySchemaItem<EntityClassProps>(context, schema, query, \"EntityClass\");\n }\n\n /**\n * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.\n * @internal\n */\n protected async getMixins(schema: string, context: SchemaContext, queryOverride?: string): Promise<MixinProps[]> {\n const query = queryOverride ?? FullSchemaQueries.mixinQuery;\n return this.querySchemaItem<MixinProps>(context, schema, query, \"Mixin\");\n }\n\n /**\n * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.\n * @internal\n */\n protected async getRelationships(schema: string, context: SchemaContext, queryOverride?: string): Promise<RelationshipClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.relationshipClassQuery;\n return this.querySchemaItem<RelationshipClassProps>(context, schema, query, \"RelationshipClass\");\n }\n\n /**\n * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getCustomAttributeClasses(schema: string, context: SchemaContext, queryOverride?: string): Promise<CustomAttributeClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.customAttributeQuery;\n return this.querySchemaItem<CustomAttributeClassProps>(context, schema, query, \"CustomAttributeClass\");\n }\n\n\n /**\n * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.\n * @param schemaName The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getStructs(schema: string, context: SchemaContext, queryOverride?: string): Promise<StructClassProps[]> {\n const query = queryOverride ?? FullSchemaQueries.structQuery;\n return this.querySchemaItem<StructClassProps>(context, schema, query, \"StructClass\");\n }\n\n /**\n * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getKindOfQuantities(schema: string, context: SchemaContext): Promise<KindOfQuantityProps[]> {\n return this.querySchemaItem<KindOfQuantityProps>(context, schema, SchemaItemQueries.kindOfQuantity(true), \"KindOfQuantity\");\n }\n\n /**\n * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getPropertyCategories(schema: string, context: SchemaContext): Promise<PropertyCategoryProps[]> {\n return this.querySchemaItem<PropertyCategoryProps>(context, schema, SchemaItemQueries.propertyCategory(true), \"PropertyCategory\");\n }\n\n /**\n * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getEnumerations(schema: string, context: SchemaContext): Promise<EnumerationProps[]> {\n return this.querySchemaItem<EnumerationProps>(context, schema, SchemaItemQueries.enumeration(true), \"Enumeration\");\n }\n\n /**\n * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getUnits(schema: string, context: SchemaContext): Promise<SchemaItemUnitProps[]> {\n return this.querySchemaItem<SchemaItemUnitProps>(context, schema, SchemaItemQueries.unit(true), \"Unit\");\n }\n\n /**\n * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getInvertedUnits(schema: string, context: SchemaContext): Promise<InvertedUnitProps[]> {\n return this.querySchemaItem<InvertedUnitProps>(context, schema, SchemaItemQueries.invertedUnit(true), \"InvertedUnit\");\n }\n\n /**\n * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getConstants(schema: string, context: SchemaContext): Promise<ConstantProps[]> {\n return this.querySchemaItem<ConstantProps>(context, schema, SchemaItemQueries.constant(true), \"Constant\");\n }\n\n /**\n * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getUnitSystems(schema: string, context: SchemaContext): Promise<UnitSystemProps[]> {\n return this.querySchemaItem<UnitSystemProps>(context, schema, SchemaItemQueries.unitSystem(true), \"UnitSystem\");\n }\n\n /**\n * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getPhenomenon(schema: string, context: SchemaContext): Promise<PhenomenonProps[]> {\n return this.querySchemaItem<PhenomenonProps>(context, schema, SchemaItemQueries.phenomenon(true), \"Phenomenon\");\n }\n\n /**\n * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.\n * @param schema The name of the Schema.\n * @param context The SchemaContext to which the schema belongs.\n * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.\n * @internal\n */\n protected async getFormats(schema: string, context: SchemaContext): Promise<SchemaItemFormatProps[]> {\n return this.querySchemaItem<SchemaItemFormatProps>(context, schema, SchemaItemQueries.format(true), \"Format\");\n }\n\n /**\n * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.\n * @internal\n */\n protected async loadSchemaInfos(): Promise<ReadonlyArray<SchemaInfo>> {\n const schemaRows = await this.executeQuery<SchemaInfoRow>(ecsqlQueries.schemaInfoQuery);\n return schemaRows.map((schemaRow) => (\n {\n alias: schemaRow.alias,\n description: schemaRow.description,\n label: schemaRow.label,\n schemaKey: SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),\n references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),\n }\n ));\n }\n\n /**\n * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy\n * can be included in the initial fetch.\n * @param schemaKey The [[SchemaKey]] of the schema to be resolved.\n * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].\n * @internal\n */\n protected async getSchemaPartials(schemaKey: SchemaKey, context: SchemaContext): Promise<ReadonlyArray<SchemaProps> | undefined> {\n const queryStart = Date.now();\n const itemRows = await this.executeQuery<SchemaStubRow>(ecsqlQueries.schemaStubQuery, {\n parameters: { schemaName: schemaKey.name }\n });\n\n const queryDuration = Date.now() - queryStart;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved PartialSchema for ${schemaKey.name} in ${queryDuration}ms`, {\n schemaName: schemaKey.name,\n itemCount: itemRows.length,\n duration: queryDuration,\n });\n\n if (itemRows.length === 0)\n return undefined;\n\n const schemaPartials: Array<SchemaProps> = [];\n const addSchema = async (key: SchemaKey) => {\n const stub = await this.createSchemaProps(key, context);\n schemaPartials.push(stub);\n\n if (stub.references) {\n for (const referenceProps of stub.references) {\n if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {\n await addSchema(SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));\n }\n }\n }\n\n return stub;\n };\n\n const addItems = async (schemaName: string, itemInfo: SchemaItemInfo) => {\n let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);\n if (!schemaStub) {\n schemaStub = await addSchema(SchemaKey.parseString(`${schemaName}.0.0.0`));\n }\n\n let items = schemaStub.items;\n if (!items) {\n Object.assign(schemaStub, items = { items: {} });\n }\n\n const existingItem = items[itemInfo.name] || {};\n Object.assign(items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });\n };\n\n const reviver = (_key: string, value: any) => {\n return value === null ? undefined : value;\n };\n\n await addSchema(schemaKey);\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n const stubItems = itemRows.map((itemRow) => {\n return JSON.parse(itemRow.item, reviver) as SchemaItemStubRow;\n });\n await parseSchemaItemStubs(schemaKey.name, stubItems, addItems, schemaInfos);\n\n return schemaPartials;\n }\n\n private async querySchemaItem<TRow extends SchemaItemProps>(context: SchemaContext, schemaName: string, query: string, schemaType: string): Promise<Array<TRow>> {\n const start = Date.now();\n const itemRows = await this.executeQuery<SchemaItemRow>(query, { parameters: { schemaName } });\n\n const queryDuration = Date.now() - start;\n Logger.logTrace(LOGGER_CATEGORY, `Recieved rows of ${schemaType} items for ${schemaName} in ${queryDuration}ms`, {\n schemaName,\n itemCount: itemRows.length,\n itemType: schemaType,\n duration: queryDuration,\n });\n\n if (itemRows.length === 0)\n return [];\n\n const items = itemRows.map((itemRow: SchemaItemRow) => {\n return \"string\" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;\n });\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return await SchemaParser.parseSchemaItems(items, schemaName, schemaInfos) as Array<TRow> ?? []\n }\n\n private async getFullSchema(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schemaRows = await this.executeQuery<SchemaRow>(FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });\n const schemaRow = schemaRows[0];\n if (schemaRow === undefined)\n return undefined;\n\n // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.\n const schema = JSON.parse(schemaRow.schema) as SchemaProps;\n if (schema.items) {\n (schema as any).items = (schema.items as any).map((itemRow: SchemaItemRow) => { return itemRow.item; });\n }\n\n const schemaInfos = await this._schemaInfoCache.getSchemasByContext(context) ?? [];\n return SchemaParser.parse(schema, schemaInfos);\n }\n\n private async getFullSchemaMultipleQueries(schemaKey: SchemaKey, context: SchemaContext): Promise<SchemaProps | undefined> {\n const schema = await this.getSchemaNoItems(schemaKey.name, context) as MutableSchemaProps;\n if (!schema)\n return undefined;\n\n const items = schema.items || (schema.items = {});\n await Promise.all([\n this.getEntities(schemaKey.name, context),\n this.getMixins(schemaKey.name, context),\n this.getStructs(schemaKey.name, context),\n this.getRelationships(schemaKey.name, context),\n this.getCustomAttributeClasses(schemaKey.name, context),\n this.getKindOfQuantities(schemaKey.name, context),\n this.getPropertyCategories(schemaKey.name, context),\n this.getEnumerations(schemaKey.name, context),\n this.getUnits(schemaKey.name, context),\n this.getInvertedUnits(schemaKey.name, context),\n this.getUnitSystems(schemaKey.name, context),\n this.getConstants(schemaKey.name, context),\n this.getPhenomenon(schemaKey.name, context),\n this.getFormats(schemaKey.name, context)\n ]).then((itemResults) => {\n const flatItemList = itemResults.reduce((acc, result) => acc.concat(result));\n flatItemList.forEach((schemaItem) => {\n if(!schemaItem.name) {\n // This should never be happen, as we query the schema items by name from the database, but since the SchemaProps\n // have name optional, we need the check here to make the compiler happy.\n throw new Error(`SchemaItem with no name encountered in schema ${schemaKey.name}`);\n }\n items[schemaItem.name] = schemaItem;\n });\n });\n\n return schema;\n }\n}\n\nfunction parseSchemaReference(referenceName: string): WithSchemaKey {\n return { schemaKey: SchemaKey.parseString(referenceName) };\n}\n\nasync function parseSchemaItemStubs(schemaName: string, itemRows: Array<SchemaItemStubRow>, addItemsHandler: AddSchemaItemHandler, schemaInfos: Iterable<SchemaInfo>) {\n if (!itemRows || itemRows.length === 0) {\n return;\n }\n\n const parseBaseClasses = async (baseClasses: Array<BaseClassStubRow> | undefined) => {\n if (!baseClasses || baseClasses.length < 2)\n return;\n\n for (let index = baseClasses.length - 1; index >= 0;) {\n const currentItem = baseClasses[index--];\n const baseClassItem = baseClasses[index];\n const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;\n\n const schemaItem = await SchemaParser.parseItem(currentItem, currentItem.schema, schemaInfos);\n await addItemsHandler(currentItem.schema, {\n ...schemaItem,\n name: schemaItem.name,\n schemaItemType: schemaItem.schemaItemType,\n baseClass: baseClassName,\n });\n }\n };\n\n for (const itemRow of itemRows) {\n const schemaItem = await SchemaParser.parseItem(itemRow, schemaName, schemaInfos);\n await addItemsHandler(schemaName, {\n ...schemaItem,\n name: schemaItem.name,\n schemaItemType: schemaItem.schemaItemType,\n mixins: itemRow.mixins\n ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })\n : undefined,\n });\n\n await parseBaseClasses(itemRow.baseClasses);\n\n for (const mixinRow of itemRow.mixins || []) {\n const mixinItem = await SchemaParser.parseItem(mixinRow, mixinRow.schema, schemaInfos);\n await addItemsHandler(mixinRow.schema, {\n ...mixinItem,\n name: mixinItem.name,\n schemaItemType: mixinItem.schemaItemType,\n });\n await parseBaseClasses(mixinRow.baseClasses);\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullSchemaQueries.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/FullSchemaQueries.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FullSchemaQueries.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/FullSchemaQueries.ts"],"names":[],"mappings":"AA2mBA;;;GAGG;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;CAQ7B,CAAC"}
|
|
@@ -70,6 +70,7 @@ const selectBaseClasses = `
|
|
|
70
70
|
INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
|
|
71
71
|
ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
|
|
72
72
|
WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
|
|
73
|
+
ORDER BY [baseClassMap].[Ordinal] ASC
|
|
73
74
|
LIMIT 1
|
|
74
75
|
`;
|
|
75
76
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FullSchemaQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/FullSchemaQueries.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AAEH,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;IACrC,OAAO;;cAEK,KAAK;cACL,KAAK;cACL,KAAK;cACL,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC5C,OAAO;;cAEK,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9C,OAAO;;;;kCAIyB,KAAK;;GAEpC,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,o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IAE5B,iBAAiB,CAAC,YAAY,CAAC,IAAI,CAAC;;IAEpC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC;;IAElC,iBAAiB,CAAC,QAAQ,CAAC,IAAI,CAAC;;IAEhC,iBAAiB,CAAC,UAAU,CAAC,IAAI,CAAC;;IAElC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC;;CAEjC,CAAC;AAEF;;GAEG;AACH,MAAM,kBAAkB,GAAG;;IAEvB,oBAAoB;;;;;;;;;;2BAUG,qBAAqB,CAAC,WAAW,CAAC;;;;;;;;;;;;CAY5D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG;;IAEhB,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,2BAA2B;IAC3B,eAAe;;;;;;;;;;2BAUQ,qBAAqB,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;CAoB5D,CAAC;AAEF;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,sBAAsB;IACtB,UAAU;IACV,WAAW;IACX,oBAAoB;CACrB,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 *--------------------------------------------------------------------------------------------*/\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { modifier, strength, strengthDirection } from \"./SchemaStubQueries\";\n\n/**\n * Queries that return full Schema JSON data are found here. Shared SELECTS and\n * WITH clauses are broken down into individual variables.\n */\n\nconst propertyType = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[Kind] = 0 THEN 'PrimitiveProperty'\n WHEN [${alias}].[Kind] = 1 THEN 'StructProperty'\n WHEN [${alias}].[Kind] = 2 THEN 'PrimitiveArrayProperty'\n WHEN [${alias}].[Kind] = 3 THEN 'StructArrayProperty'\n WHEN [${alias}].[Kind] = 4 THEN 'NavigationProperty'\n ELSE NULL\n END\n `;\n};\n\nconst navigationDirection = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[NavigationDirection] = 1 THEN 'Forward'\n WHEN [${alias}].[NavigationDirection] = 2 THEN 'Backward'\n ELSE NULL\n END\n `;\n};\n\nconst schemaCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 1\n ORDER BY [ca].[Ordinal]\n `;\n};\n\n/**\n * Selects customAttribute data for each class type.\n */\nconst classCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 30\n ORDER BY [ca].[Ordinal]\n `;\n};\n\nconst propertyCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 992\n ORDER BY [ca].[Ordinal]\n `;\n};\n\n\n/**\n * Selects base class data for each class type.\n */\nconst selectBaseClasses = `\n SELECT\n ec_classname([baseClass].[ECInstanceId], 's.c')\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n LIMIT 1\n`;\n\n/**\n * Selects class property data for each class type. ClassProperties\n * is a common table expression (CTE or WITH clause) defined below.\n */\nconst selectProperties = `\n SELECT\n json_group_array(json([classProperties].[property]))\n FROM\n [ClassProperties] [classProperties]\n WHERE\n [classProperties].[ClassId] = [class].[ECInstanceId]\n`;\n\n/**\n * A CTE used to select AppliesTo from IsMixin CustomAttributes for a given Mixin.\n */\nconst withAppliesTo = `\n AppliesToCTE AS (\n SELECT\n [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],\n [appliesToSchema].[name] as [AppliesToSchema],\n json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]\n FROM [meta].[CustomAttribute] [ca]\n JOIN [meta].[ECClassDef] [mixinAppliesTo]\n ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]\n JOIN [meta].[ECSchemaDef] [appliesToSchema]\n ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]\n WHERE [ca].[ContainerType] = 30\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'\n )\n`;\n\n/**\n * A CTE used to select Schema reference data for a given Schema.\n */\nconst withSchemaReferences = `\nSchemaReferences as (\n SELECT\n [ref].[SourceECInstanceId] as [SchemaId],\n json_object(\n 'name', [Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor]))\n ) as [reference]\n FROM\n [meta].[ECSchemaDef] as [refSchema]\n INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]\n ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]\n)\n`;\n\n/**\n * A CTE used to select Relationship constraints for a given RelationshipClass.\n */\nconst withRelationshipConstraints = `\nClassRelationshipConstraints as (\n SELECT\n [rhc].[SourceECInstanceId] as [ClassId],\n [constraintDef].[ECInstanceId] as [ConstraintId],\n [RelationshipEnd],\n CONCAT('(', [MultiplicityLowerLimit], '..', IIF([MultiplicityUpperLimit] IS NULL, '*', [MultiplicityUpperLimit]), ')') as [Multiplicity],\n [IsPolyMorphic],\n [RoleLabel],\n IIF([constraintDef].[AbstractConstraintClass] IS NOT NULL, ec_classname([constraintDef].[AbstractConstraintClass].[Id], 's.c'), null) as [AbstractConstraint],\n IIF ([rchc].[TargetECInstanceId] IS NOT NULL, JSON_GROUP_ARRAY(ec_classname([rchc].[TargetECInstanceId], 's.c')), null) as [ConstraintClasses]\n FROM\n [meta].[ECRelationshipConstraintDef] [constraintDef]\n JOIN [meta].[RelationshipHasConstraints] [rhc]\n ON [rhc].[TargetECInstanceId] = [constraintDef].[ECInstanceId]\n JOIN [meta].[RelationshipConstraintHasClasses] [rchc]\n ON [rchc].[SourceECInstanceId] = [constraintDef].[ECInstanceId]\n GROUP BY [constraintDef].[ECInstanceId]\n)\n`;\n\n/**\n * A CTE used to select Class property data for a given Class.\n */\nconst withClassProperties = `\nClassProperties as (\nSELECT\n [cop].[SourceECInstanceId] as [ClassId],\n json_object(\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'isReadOnly', IIF([pd].[IsReadOnly] = 1, json('true'), NULL),\n 'priority', [pd].[Priority],\n 'category', IIF([categoryDef].[Name] IS NULL, NULL, CONCAT([categorySchemaDef].[Name], '.', [categoryDef].[Name])),\n 'kindOfQuantity', IIF([koqDef].[Name] IS NULL, NULL, CONCAT([koqSchemaDef].[Name], '.', [koqDef].[Name])),\n 'typeName',\n CASE\n WHEN [pd].[Kind] = 0 OR [pd].[Kind] = 2 Then\n CASE\n WHEN [enumDef].[Name] IS NOT NULL Then CONCAT([enumSchemaDef].[Name], '.', [enumDef].[Name])\n WHEN [pd].[PrimitiveType] = 257 Then 'binary'\n WHEN [pd].[PrimitiveType] = 513 Then 'boolean'\n WHEN [pd].[PrimitiveType] = 769 Then 'dateTime'\n WHEN [pd].[PrimitiveType] = 1025 Then 'double'\n WHEN [pd].[PrimitiveType] = 1281 Then 'int'\n WHEN [pd].[PrimitiveType] = 1537 Then 'long'\n WHEN [pd].[PrimitiveType] = 1793 Then 'point2d'\n WHEN [pd].[PrimitiveType] = 2049 Then 'point3d'\n WHEN [pd].[PrimitiveType] = 2305 Then 'string'\n WHEN [pd].[PrimitiveType] = 2561 Then 'Bentley.Geometry.Common.IGeometry'\n ELSE null\n END\n WHEN [pd].[Kind] = 1 OR [pd].[Kind] = 3 Then\n CONCAT([structSchemaDef].[Name], '.', [structDef].[Name])\n ELSE null\n END,\n 'type', ${propertyType(\"pd\")},\n 'minLength', [pd].[PrimitiveTypeMinLength],\n 'maxLength', [pd].[PrimitiveTypeMaxLength],\n 'minValue', [pd].[PrimitiveTypeMinValue],\n 'maxValue', [pd].[PrimitiveTypeMaxValue],\n 'extendedTypeName', [pd].[ExtendedTypeName],\n 'minOccurs', [pd].[ArrayMinOccurs],\n 'maxOccurs', [pd].[ArrayMaxOccurs],\n 'direction', ${navigationDirection(\"pd\")},\n 'relationshipName', IIF([navRelDef].[Name] IS NULL, NULL, CONCAT([navSchemaDef].[Name], '.', [navRelDef].[Name])),\n 'customAttributes', (${propertyCustomAttribute(\"pd\")})\n ) as [property]\nFROM\n [meta].[ECPropertyDef] as [pd]\nJOIN [meta].[ClassOwnsLocalProperties] [cop]\n ON cop.[TargetECInstanceId] = [pd].[ECInstanceId]\nLEFT JOIN [meta].[ECEnumerationDef] [enumDef]\n ON [enumDef].[ECInstanceId] = [pd].[Enumeration].[Id]\nLEFT JOIN [meta].[ECSchemaDef] enumSchemaDef\n ON [enumSchemaDef].[ECInstanceId] = [enumDef].[Schema].[Id]\nLEFT JOIN [meta].[PropertyCategoryDef] [categoryDef]\n ON [categoryDef].[ECInstanceId] = [pd].[Category].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [categorySchemaDef]\n ON [categorySchemaDef].[ECInstanceId] = [categoryDef].[Schema].[Id]\nLEFT JOIN [meta].[KindOfQuantityDef] [koqDef]\n ON [koqDef].[ECInstanceId] = [pd].[KindOfQuantity].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [koqSchemaDef]\n ON [koqSchemaDef].[ECInstanceId] = [koqDef].[Schema].[Id]\nLEFT JOIN [meta].[ECClassDef] [structDef]\n ON structDef.[ECInstanceId] = [pd].[StructClass].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [structSchemaDef]\n ON [structSchemaDef].[ECInstanceId] = [structDef].[Schema].[Id]\nLEFT JOIN [meta].[ECClassDef] [navRelDef]\n ON [navRelDef].[ECInstanceId] = [pd].[NavigationRelationshipClass].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [navSchemaDef]\n ON [navSchemaDef].[ECInstanceId] = [navRelDef].[Schema].[Id]\n)\n`;\n\n/**\n * Query that provides EntityClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Entity classes.\n */\nconst baseEntityQuery = `\n SELECT\n [sd].[Name] as [schema],\n json_object (\n 'schemaItemType', 'EntityClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'mixins', (\n SELECT\n json_group_array(\n ec_classname([baseClass].[ECInstanceId], 's.c')\n )\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 0 AND\n [sd].[Name] = :schemaName\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].Id Is ([CoreCA].[IsMixin]))\n `;\n\n/**\n * EntityClass query used to when querying for EntityClass data only. Not used\n * for full Schema load via single query.\n */\nconst entityQuery = `\n WITH\n ${withClassProperties}\n ${baseEntityQuery}\n `\n\n/**\n * Query that provides Mixin data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Mixin classes.\n */\nconst baseMixinQuery = `\n SELECT\n [sd].[Name] as [schema],\n json_object (\n 'schemaItemType', 'Mixin',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]\n ),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [class].[ECInstanceId] AND [ca].[ContainerType] = 30\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') <> 'IsMixin'\n ),\n 'properties', (\n SELECT\n json_group_array(json([classProperties].[property]))\n FROM\n [ClassProperties] [classProperties]\n WHERE\n [classProperties].[ClassId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 0 AND\n [sd].[Name] = :schemaName\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n `;\n\n/**\n* Mixin query used to when querying for Mixin data only. Not used\n* for full Schema load via single query.\n*/\nconst mixinQuery = `\n WITH\n ${withAppliesTo},\n ${withClassProperties}\n${baseMixinQuery}\n`\n\n/**\n * Query that provides RelationshipClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Relationship classes.\n */\nconst baseRelationshipClassQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'RelationshipClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'strength', ${strength(\"class\")},\n 'strengthDirection', ${strengthDirection(\"class\")},\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n ),\n 'source', (\n SELECT\n json_object (\n 'multiplicity', [sourceConst].[Multiplicity],\n 'roleLabel', [sourceConst].[RoleLabel],\n 'polymorphic', IIF([sourceConst].[IsPolyMorphic] = 1, json('true'), json('false')),\n 'abstractConstraint', [sourceConst].[AbstractConstraint],\n 'constraintClasses', json([sourceConst].[ConstraintClasses]),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [sourceConst].[ConstraintId] AND [ca].[ContainerType] = 1024\n ORDER BY [ca].[Ordinal]\n )\n )\n FROM\n [ClassRelationshipConstraints] [sourceConst]\n WHERE [sourceConst].[relationshipEnd] = 0\n AND [sourceConst].[ClassId] = [class].[ECInstanceId]\n ),\n 'target', (\n SELECT\n json_object (\n 'multiplicity', [targetConst].[Multiplicity],\n 'roleLabel', [targetConst].[RoleLabel],\n 'polymorphic', IIF([targetConst].[IsPolyMorphic] = 1, json('true'), json('false')),\n 'abstractConstraint', [targetConst].[AbstractConstraint],\n 'constraintClasses', json([targetConst].[ConstraintClasses]),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [targetConst].[ConstraintId] AND [ca].[ContainerType] = 2048\n ORDER BY [ca].[Ordinal]\n )\n )\n FROM\n [ClassRelationshipConstraints] [targetConst]\n WHERE [targetConst].[relationshipEnd] = 1\n AND [targetConst].[ClassId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 1 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n* RelationshipClass query used to when querying for RelationshipClass data only. Not used\n* for full Schema load via single query.\n*/\nconst relationshipClassQuery = `\n WITH\n ${withClassProperties},\n ${withRelationshipConstraints}\n${baseRelationshipClassQuery}\n`\n\n/**\n * Query that provides StructClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Struct classes.\n */\nconst baseStructQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'StructClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS item\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 2 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n * StructClass query used to when querying for StructClass data only. Not used\n * for full Schema load via single query.\n */\nconst structQuery = `\n WITH\n ${withClassProperties}\n${baseStructQuery}\n`\n\n/**\n * Query that provides CustomAttributeClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for CustomAttribute classes.\n */\nconst baseCustomAttributeQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'CustomAttributeClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'appliesTo', [class].[CustomAttributeContainerType],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] sd ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 3 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n * CustomAttributeClass query used to when querying for CustomAttributeClass data only. Not used\n * for full Schema load via single query.\n */\nconst customAttributeQuery = `\nWITH\n ${withClassProperties}\n${baseCustomAttributeQuery}\n`\n\n/**\n * Used by full schema load query via single query. Allows\n * all SchemaItemTypes to be queried at once.\n */\nconst withSchemaItems = `\nSchemaItems AS (\n ${baseEntityQuery}\n UNION ALL\n ${baseRelationshipClassQuery}\n UNION ALL\n ${baseStructQuery}\n UNION ALL\n ${baseMixinQuery}\n UNION ALL\n ${baseCustomAttributeQuery}\n UNION ALL\n ${SchemaItemQueries.kindOfQuantity(true)}\n UNION ALL\n ${SchemaItemQueries.enumeration(true)}\n UNION ALL\n ${SchemaItemQueries.propertyCategory(true)}\n UNION ALL\n ${SchemaItemQueries.unit(true)}\n UNION ALL\n ${SchemaItemQueries.invertedUnit(true)}\n UNION ALL\n ${SchemaItemQueries.unitSystem(true)}\n UNION ALL\n ${SchemaItemQueries.constant(true)}\n UNION ALL\n ${SchemaItemQueries.phenomenon(true)}\n UNION ALL\n ${SchemaItemQueries.format(true)}\n)\n`;\n\n/**\n * Query for Schema data without SchemaItems\n */\nconst schemaNoItemsQuery = `\nWITH\n ${withSchemaReferences}\nSELECT\n json_object (\n 'name', [schemaDef].[Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),\n 'alias', [schemaDef].[Alias],\n 'label', [schemaDef].[DisplayLabel],\n 'description', [schemaDef].[Description],\n 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],\n 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],\n 'customAttributes', (${schemaCustomAttribute(\"schemaDef\")}),\n 'references', (\n SELECT\n json_group_array(json([schemaReferences].[reference]))\n FROM\n [SchemaReferences] [schemaReferences]\n WHERE\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\n )\n ) as [schema]\nFROM\n [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName\n`;\n\n/**\n * Query to load a full Schema via a single query.\n */\nconst schemaQuery = `\nWITH\n ${withAppliesTo},\n ${withSchemaReferences},\n ${withClassProperties},\n ${withRelationshipConstraints},\n ${withSchemaItems}\nSELECT\n json_object (\n 'name', [schemaDef].[Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),\n 'alias', [schemaDef].[Alias],\n 'label', [schemaDef].[DisplayLabel],\n 'description', [schemaDef].[Description],\n 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],\n 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],\n 'customAttributes', (${schemaCustomAttribute(\"schemaDef\")}),\n 'references', (\n SELECT\n json_group_array(json([schemaReferences].[reference]))\n FROM\n [SchemaReferences] [schemaReferences]\n WHERE\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\n ),\n 'items', (\n SELECT\n json_group_array(json(json_object(\n 'item', json([items].[item])\n )))\n FROM\n [SchemaItems] [items]\n )\n) as [schema]\nFROM\n [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName\n`;\n\n/**\n * Queries for loading full Schema JSON.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const FullSchemaQueries = {\n schemaQuery,\n schemaNoItemsQuery,\n entityQuery,\n relationshipClassQuery,\n mixinQuery,\n structQuery,\n customAttributeQuery\n};\n"]}
|
|
1
|
+
{"version":3,"file":"FullSchemaQueries.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/FullSchemaQueries.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;;GAGG;AAEH,MAAM,YAAY,GAAG,CAAC,KAAa,EAAE,EAAE;IACrC,OAAO;;cAEK,KAAK;cACL,KAAK;cACL,KAAK;cACL,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,mBAAmB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC5C,OAAO;;cAEK,KAAK;cACL,KAAK;;;GAGhB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC9C,OAAO;;;;kCAIyB,KAAK;;GAEpC,CAAC;AACJ,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,oBAAoB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC7C,OAAO;;;;kCAIyB,KAAK;;GAEpC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,KAAa,EAAE,EAAE;IAChD,OAAO;;;;kCAIyB,KAAK;;GAEpC,CAAC;AACJ,CAAC,CAAC;AAGF;;GAEG;AACH,MAAM,iBAAiB,GAAG;;;;;;;;;;CAUzB,CAAC;AAEF;;;GAGG;AACH,MAAM,gBAAgB,GAAG;;;;;;;CAOxB,CAAC;AAEF;;GAEG;AACH,MAAM,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;CAY5D,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,GAAG;;IAEhB,aAAa;IACb,oBAAoB;IACpB,mBAAmB;IACnB,2BAA2B;IAC3B,eAAe;;;;;;;;;;2BAUQ,qBAAqB,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;CAoB5D,CAAC;AAEF;;;GAGG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,WAAW;IACX,kBAAkB;IAClB,WAAW;IACX,sBAAsB;IACtB,UAAU;IACV,WAAW;IACX,oBAAoB;CACrB,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 *--------------------------------------------------------------------------------------------*/\nimport { SchemaItemQueries } from \"./SchemaItemQueries\";\nimport { modifier, strength, strengthDirection } from \"./SchemaStubQueries\";\n\n/**\n * Queries that return full Schema JSON data are found here. Shared SELECTS and\n * WITH clauses are broken down into individual variables.\n */\n\nconst propertyType = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[Kind] = 0 THEN 'PrimitiveProperty'\n WHEN [${alias}].[Kind] = 1 THEN 'StructProperty'\n WHEN [${alias}].[Kind] = 2 THEN 'PrimitiveArrayProperty'\n WHEN [${alias}].[Kind] = 3 THEN 'StructArrayProperty'\n WHEN [${alias}].[Kind] = 4 THEN 'NavigationProperty'\n ELSE NULL\n END\n `;\n};\n\nconst navigationDirection = (alias: string) => {\n return `\n CASE\n WHEN [${alias}].[NavigationDirection] = 1 THEN 'Forward'\n WHEN [${alias}].[NavigationDirection] = 2 THEN 'Backward'\n ELSE NULL\n END\n `;\n};\n\nconst schemaCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 1\n ORDER BY [ca].[Ordinal]\n `;\n};\n\n/**\n * Selects customAttribute data for each class type.\n */\nconst classCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 30\n ORDER BY [ca].[Ordinal]\n `;\n};\n\nconst propertyCustomAttribute = (alias: string) => {\n return `\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 992\n ORDER BY [ca].[Ordinal]\n `;\n};\n\n\n/**\n * Selects base class data for each class type.\n */\nconst selectBaseClasses = `\n SELECT\n ec_classname([baseClass].[ECInstanceId], 's.c')\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n ORDER BY [baseClassMap].[Ordinal] ASC\n LIMIT 1\n`;\n\n/**\n * Selects class property data for each class type. ClassProperties\n * is a common table expression (CTE or WITH clause) defined below.\n */\nconst selectProperties = `\n SELECT\n json_group_array(json([classProperties].[property]))\n FROM\n [ClassProperties] [classProperties]\n WHERE\n [classProperties].[ClassId] = [class].[ECInstanceId]\n`;\n\n/**\n * A CTE used to select AppliesTo from IsMixin CustomAttributes for a given Mixin.\n */\nconst withAppliesTo = `\n AppliesToCTE AS (\n SELECT\n [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],\n [appliesToSchema].[name] as [AppliesToSchema],\n json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]\n FROM [meta].[CustomAttribute] [ca]\n JOIN [meta].[ECClassDef] [mixinAppliesTo]\n ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]\n JOIN [meta].[ECSchemaDef] [appliesToSchema]\n ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]\n WHERE [ca].[ContainerType] = 30\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'\n )\n`;\n\n/**\n * A CTE used to select Schema reference data for a given Schema.\n */\nconst withSchemaReferences = `\nSchemaReferences as (\n SELECT\n [ref].[SourceECInstanceId] as [SchemaId],\n json_object(\n 'name', [Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor]))\n ) as [reference]\n FROM\n [meta].[ECSchemaDef] as [refSchema]\n INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]\n ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]\n)\n`;\n\n/**\n * A CTE used to select Relationship constraints for a given RelationshipClass.\n */\nconst withRelationshipConstraints = `\nClassRelationshipConstraints as (\n SELECT\n [rhc].[SourceECInstanceId] as [ClassId],\n [constraintDef].[ECInstanceId] as [ConstraintId],\n [RelationshipEnd],\n CONCAT('(', [MultiplicityLowerLimit], '..', IIF([MultiplicityUpperLimit] IS NULL, '*', [MultiplicityUpperLimit]), ')') as [Multiplicity],\n [IsPolyMorphic],\n [RoleLabel],\n IIF([constraintDef].[AbstractConstraintClass] IS NOT NULL, ec_classname([constraintDef].[AbstractConstraintClass].[Id], 's.c'), null) as [AbstractConstraint],\n IIF ([rchc].[TargetECInstanceId] IS NOT NULL, JSON_GROUP_ARRAY(ec_classname([rchc].[TargetECInstanceId], 's.c')), null) as [ConstraintClasses]\n FROM\n [meta].[ECRelationshipConstraintDef] [constraintDef]\n JOIN [meta].[RelationshipHasConstraints] [rhc]\n ON [rhc].[TargetECInstanceId] = [constraintDef].[ECInstanceId]\n JOIN [meta].[RelationshipConstraintHasClasses] [rchc]\n ON [rchc].[SourceECInstanceId] = [constraintDef].[ECInstanceId]\n GROUP BY [constraintDef].[ECInstanceId]\n)\n`;\n\n/**\n * A CTE used to select Class property data for a given Class.\n */\nconst withClassProperties = `\nClassProperties as (\nSELECT\n [cop].[SourceECInstanceId] as [ClassId],\n json_object(\n 'name', [pd].[Name],\n 'label', [pd].[DisplayLabel],\n 'description', [pd].[Description],\n 'isReadOnly', IIF([pd].[IsReadOnly] = 1, json('true'), NULL),\n 'priority', [pd].[Priority],\n 'category', IIF([categoryDef].[Name] IS NULL, NULL, CONCAT([categorySchemaDef].[Name], '.', [categoryDef].[Name])),\n 'kindOfQuantity', IIF([koqDef].[Name] IS NULL, NULL, CONCAT([koqSchemaDef].[Name], '.', [koqDef].[Name])),\n 'typeName',\n CASE\n WHEN [pd].[Kind] = 0 OR [pd].[Kind] = 2 Then\n CASE\n WHEN [enumDef].[Name] IS NOT NULL Then CONCAT([enumSchemaDef].[Name], '.', [enumDef].[Name])\n WHEN [pd].[PrimitiveType] = 257 Then 'binary'\n WHEN [pd].[PrimitiveType] = 513 Then 'boolean'\n WHEN [pd].[PrimitiveType] = 769 Then 'dateTime'\n WHEN [pd].[PrimitiveType] = 1025 Then 'double'\n WHEN [pd].[PrimitiveType] = 1281 Then 'int'\n WHEN [pd].[PrimitiveType] = 1537 Then 'long'\n WHEN [pd].[PrimitiveType] = 1793 Then 'point2d'\n WHEN [pd].[PrimitiveType] = 2049 Then 'point3d'\n WHEN [pd].[PrimitiveType] = 2305 Then 'string'\n WHEN [pd].[PrimitiveType] = 2561 Then 'Bentley.Geometry.Common.IGeometry'\n ELSE null\n END\n WHEN [pd].[Kind] = 1 OR [pd].[Kind] = 3 Then\n CONCAT([structSchemaDef].[Name], '.', [structDef].[Name])\n ELSE null\n END,\n 'type', ${propertyType(\"pd\")},\n 'minLength', [pd].[PrimitiveTypeMinLength],\n 'maxLength', [pd].[PrimitiveTypeMaxLength],\n 'minValue', [pd].[PrimitiveTypeMinValue],\n 'maxValue', [pd].[PrimitiveTypeMaxValue],\n 'extendedTypeName', [pd].[ExtendedTypeName],\n 'minOccurs', [pd].[ArrayMinOccurs],\n 'maxOccurs', [pd].[ArrayMaxOccurs],\n 'direction', ${navigationDirection(\"pd\")},\n 'relationshipName', IIF([navRelDef].[Name] IS NULL, NULL, CONCAT([navSchemaDef].[Name], '.', [navRelDef].[Name])),\n 'customAttributes', (${propertyCustomAttribute(\"pd\")})\n ) as [property]\nFROM\n [meta].[ECPropertyDef] as [pd]\nJOIN [meta].[ClassOwnsLocalProperties] [cop]\n ON cop.[TargetECInstanceId] = [pd].[ECInstanceId]\nLEFT JOIN [meta].[ECEnumerationDef] [enumDef]\n ON [enumDef].[ECInstanceId] = [pd].[Enumeration].[Id]\nLEFT JOIN [meta].[ECSchemaDef] enumSchemaDef\n ON [enumSchemaDef].[ECInstanceId] = [enumDef].[Schema].[Id]\nLEFT JOIN [meta].[PropertyCategoryDef] [categoryDef]\n ON [categoryDef].[ECInstanceId] = [pd].[Category].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [categorySchemaDef]\n ON [categorySchemaDef].[ECInstanceId] = [categoryDef].[Schema].[Id]\nLEFT JOIN [meta].[KindOfQuantityDef] [koqDef]\n ON [koqDef].[ECInstanceId] = [pd].[KindOfQuantity].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [koqSchemaDef]\n ON [koqSchemaDef].[ECInstanceId] = [koqDef].[Schema].[Id]\nLEFT JOIN [meta].[ECClassDef] [structDef]\n ON structDef.[ECInstanceId] = [pd].[StructClass].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [structSchemaDef]\n ON [structSchemaDef].[ECInstanceId] = [structDef].[Schema].[Id]\nLEFT JOIN [meta].[ECClassDef] [navRelDef]\n ON [navRelDef].[ECInstanceId] = [pd].[NavigationRelationshipClass].[Id]\nLEFT JOIN [meta].[ECSchemaDef] [navSchemaDef]\n ON [navSchemaDef].[ECInstanceId] = [navRelDef].[Schema].[Id]\n)\n`;\n\n/**\n * Query that provides EntityClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Entity classes.\n */\nconst baseEntityQuery = `\n SELECT\n [sd].[Name] as [schema],\n json_object (\n 'schemaItemType', 'EntityClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'mixins', (\n SELECT\n json_group_array(\n ec_classname([baseClass].[ECInstanceId], 's.c')\n )\n FROM\n [meta].[ECClassDef] [baseClass]\n INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]\n ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]\n WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 0 AND\n [sd].[Name] = :schemaName\n AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].Id Is ([CoreCA].[IsMixin]))\n `;\n\n/**\n * EntityClass query used to when querying for EntityClass data only. Not used\n * for full Schema load via single query.\n */\nconst entityQuery = `\n WITH\n ${withClassProperties}\n ${baseEntityQuery}\n `\n\n/**\n * Query that provides Mixin data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Mixin classes.\n */\nconst baseMixinQuery = `\n SELECT\n [sd].[Name] as [schema],\n json_object (\n 'schemaItemType', 'Mixin',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'appliesTo', (\n SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))\n FROM [AppliesToCTE] [atCTE]\n WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]\n ),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [class].[ECInstanceId] AND [ca].[ContainerType] = 30\n AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') <> 'IsMixin'\n ),\n 'properties', (\n SELECT\n json_group_array(json([classProperties].[property]))\n FROM\n [ClassProperties] [classProperties]\n WHERE\n [classProperties].[ClassId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 0 AND\n [sd].[Name] = :schemaName\n AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]\n AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))\n `;\n\n/**\n* Mixin query used to when querying for Mixin data only. Not used\n* for full Schema load via single query.\n*/\nconst mixinQuery = `\n WITH\n ${withAppliesTo},\n ${withClassProperties}\n${baseMixinQuery}\n`\n\n/**\n * Query that provides RelationshipClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Relationship classes.\n */\nconst baseRelationshipClassQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'RelationshipClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'strength', ${strength(\"class\")},\n 'strengthDirection', ${strengthDirection(\"class\")},\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n ),\n 'source', (\n SELECT\n json_object (\n 'multiplicity', [sourceConst].[Multiplicity],\n 'roleLabel', [sourceConst].[RoleLabel],\n 'polymorphic', IIF([sourceConst].[IsPolyMorphic] = 1, json('true'), json('false')),\n 'abstractConstraint', [sourceConst].[AbstractConstraint],\n 'constraintClasses', json([sourceConst].[ConstraintClasses]),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [sourceConst].[ConstraintId] AND [ca].[ContainerType] = 1024\n ORDER BY [ca].[Ordinal]\n )\n )\n FROM\n [ClassRelationshipConstraints] [sourceConst]\n WHERE [sourceConst].[relationshipEnd] = 0\n AND [sourceConst].[ClassId] = [class].[ECInstanceId]\n ),\n 'target', (\n SELECT\n json_object (\n 'multiplicity', [targetConst].[Multiplicity],\n 'roleLabel', [targetConst].[RoleLabel],\n 'polymorphic', IIF([targetConst].[IsPolyMorphic] = 1, json('true'), json('false')),\n 'abstractConstraint', [targetConst].[AbstractConstraint],\n 'constraintClasses', json([targetConst].[ConstraintClasses]),\n 'customAttributes', (\n SELECT\n json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))\n FROM [meta].[CustomAttribute] [ca]\n WHERE [ca].[ContainerId] = [targetConst].[ConstraintId] AND [ca].[ContainerType] = 2048\n ORDER BY [ca].[Ordinal]\n )\n )\n FROM\n [ClassRelationshipConstraints] [targetConst]\n WHERE [targetConst].[relationshipEnd] = 1\n AND [targetConst].[ClassId] = [class].[ECInstanceId]\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 1 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n* RelationshipClass query used to when querying for RelationshipClass data only. Not used\n* for full Schema load via single query.\n*/\nconst relationshipClassQuery = `\n WITH\n ${withClassProperties},\n ${withRelationshipConstraints}\n${baseRelationshipClassQuery}\n`\n\n/**\n * Query that provides StructClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for Struct classes.\n */\nconst baseStructQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'StructClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS item\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 2 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n * StructClass query used to when querying for StructClass data only. Not used\n * for full Schema load via single query.\n */\nconst structQuery = `\n WITH\n ${withClassProperties}\n${baseStructQuery}\n`\n\n/**\n * Query that provides CustomAttributeClass data and is shared by two cases:\n * 1. A single query to return a full schema.\n * 2. When querying a full schema with multiple schema item queries or\n * when just querying for CustomAttribute classes.\n */\nconst baseCustomAttributeQuery = `\n SELECT\n [sd].Name as schema,\n json_object (\n 'schemaItemType', 'CustomAttributeClass',\n 'name', [class].[Name],\n 'label', [class].[DisplayLabel],\n 'description', [class].[Description],\n 'appliesTo', [class].[CustomAttributeContainerType],\n 'modifier', ${modifier(\"class\")},\n 'baseClass', (\n ${selectBaseClasses}\n ),\n 'customAttributes', (${classCustomAttribute(\"class\")}),\n 'properties', (\n ${selectProperties}\n )\n ) AS [item]\n FROM [meta].[ECClassDef] [class]\n JOIN\n [meta].[ECSchemaDef] sd ON [sd].[ECInstanceId] = [class].[Schema].[Id]\n WHERE [class].[Type] = 3 AND\n [sd].[Name] = :schemaName\n `;\n\n/**\n * CustomAttributeClass query used to when querying for CustomAttributeClass data only. Not used\n * for full Schema load via single query.\n */\nconst customAttributeQuery = `\nWITH\n ${withClassProperties}\n${baseCustomAttributeQuery}\n`\n\n/**\n * Used by full schema load query via single query. Allows\n * all SchemaItemTypes to be queried at once.\n */\nconst withSchemaItems = `\nSchemaItems AS (\n ${baseEntityQuery}\n UNION ALL\n ${baseRelationshipClassQuery}\n UNION ALL\n ${baseStructQuery}\n UNION ALL\n ${baseMixinQuery}\n UNION ALL\n ${baseCustomAttributeQuery}\n UNION ALL\n ${SchemaItemQueries.kindOfQuantity(true)}\n UNION ALL\n ${SchemaItemQueries.enumeration(true)}\n UNION ALL\n ${SchemaItemQueries.propertyCategory(true)}\n UNION ALL\n ${SchemaItemQueries.unit(true)}\n UNION ALL\n ${SchemaItemQueries.invertedUnit(true)}\n UNION ALL\n ${SchemaItemQueries.unitSystem(true)}\n UNION ALL\n ${SchemaItemQueries.constant(true)}\n UNION ALL\n ${SchemaItemQueries.phenomenon(true)}\n UNION ALL\n ${SchemaItemQueries.format(true)}\n)\n`;\n\n/**\n * Query for Schema data without SchemaItems\n */\nconst schemaNoItemsQuery = `\nWITH\n ${withSchemaReferences}\nSELECT\n json_object (\n 'name', [schemaDef].[Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),\n 'alias', [schemaDef].[Alias],\n 'label', [schemaDef].[DisplayLabel],\n 'description', [schemaDef].[Description],\n 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],\n 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],\n 'customAttributes', (${schemaCustomAttribute(\"schemaDef\")}),\n 'references', (\n SELECT\n json_group_array(json([schemaReferences].[reference]))\n FROM\n [SchemaReferences] [schemaReferences]\n WHERE\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\n )\n ) as [schema]\nFROM\n [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName\n`;\n\n/**\n * Query to load a full Schema via a single query.\n */\nconst schemaQuery = `\nWITH\n ${withAppliesTo},\n ${withSchemaReferences},\n ${withClassProperties},\n ${withRelationshipConstraints},\n ${withSchemaItems}\nSELECT\n json_object (\n 'name', [schemaDef].[Name],\n 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),\n 'alias', [schemaDef].[Alias],\n 'label', [schemaDef].[DisplayLabel],\n 'description', [schemaDef].[Description],\n 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],\n 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],\n 'customAttributes', (${schemaCustomAttribute(\"schemaDef\")}),\n 'references', (\n SELECT\n json_group_array(json([schemaReferences].[reference]))\n FROM\n [SchemaReferences] [schemaReferences]\n WHERE\n [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]\n ),\n 'items', (\n SELECT\n json_group_array(json(json_object(\n 'item', json([items].[item])\n )))\n FROM\n [SchemaItems] [items]\n )\n) as [schema]\nFROM\n [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName\n`;\n\n/**\n * Queries for loading full Schema JSON.\n * @internal\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const FullSchemaQueries = {\n schemaQuery,\n schemaNoItemsQuery,\n entityQuery,\n relationshipClassQuery,\n mixinQuery,\n structQuery,\n customAttributeQuery\n};\n"]}
|
|
@@ -4,6 +4,11 @@ import { SchemaMatchType } from "../ECObjects";
|
|
|
4
4
|
import { SchemaInfo } from "../Interfaces";
|
|
5
5
|
import { Schema } from "../Metadata/Schema";
|
|
6
6
|
import { SchemaKey } from "../SchemaKey";
|
|
7
|
+
interface IncrementalSchemaInfo extends SchemaInfo {
|
|
8
|
+
readonly description?: string;
|
|
9
|
+
readonly label?: string;
|
|
10
|
+
}
|
|
11
|
+
type LoadSchemaInfoHandler = (context: SchemaContext) => Promise<Iterable<SchemaInfo>>;
|
|
7
12
|
/**
|
|
8
13
|
* Defines the SchemaLocater Options which determine how each schema is to be loaded.
|
|
9
14
|
* All options are optional.
|
|
@@ -24,7 +29,7 @@ export interface SchemaLocaterOptions {
|
|
|
24
29
|
*/
|
|
25
30
|
export declare abstract class IncrementalSchemaLocater implements ISchemaLocater {
|
|
26
31
|
private readonly _options;
|
|
27
|
-
|
|
32
|
+
protected readonly _schemaInfoCache: SchemaInfoCache;
|
|
28
33
|
/**
|
|
29
34
|
* Initializes a new instance of the IncrementalSchemaLocater class.
|
|
30
35
|
* @param options The [[SchemaLocaterOptions]] that control the loading of the schema.
|
|
@@ -78,7 +83,7 @@ export declare abstract class IncrementalSchemaLocater implements ISchemaLocater
|
|
|
78
83
|
* @param context The schema context to load the schema infos for.
|
|
79
84
|
* @returns A promise that resolves to an iterable of schema infos.
|
|
80
85
|
*/
|
|
81
|
-
abstract loadSchemaInfos(context: SchemaContext): Promise<Iterable<SchemaInfo>>;
|
|
86
|
+
protected abstract loadSchemaInfos(context: SchemaContext): Promise<Iterable<SchemaInfo>>;
|
|
82
87
|
/**
|
|
83
88
|
* Checks if the context contains the right schemas to support incremental schema loading.
|
|
84
89
|
* @param context The schema context to check.
|
|
@@ -93,7 +98,7 @@ export declare abstract class IncrementalSchemaLocater implements ISchemaLocater
|
|
|
93
98
|
* @param schemaInfo The schema info of the schema to load.
|
|
94
99
|
* @param schemaContext The schema context to load the schema into.
|
|
95
100
|
*/
|
|
96
|
-
loadSchema(schemaInfo: SchemaInfo, schemaContext: SchemaContext): Promise<Schema>;
|
|
101
|
+
protected loadSchema(schemaInfo: SchemaInfo, schemaContext: SchemaContext): Promise<Schema>;
|
|
97
102
|
/**
|
|
98
103
|
* Creates a SchemaProps object by loading the Schema information from the given SchemaContext.
|
|
99
104
|
* @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.
|
|
@@ -106,4 +111,16 @@ export declare abstract class IncrementalSchemaLocater implements ISchemaLocater
|
|
|
106
111
|
private startLoadingFullSchema;
|
|
107
112
|
private sortSchemaPartials;
|
|
108
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Helper class to manage schema infos for a schema context.
|
|
116
|
+
*/
|
|
117
|
+
declare class SchemaInfoCache {
|
|
118
|
+
private readonly _schemaInfoCache;
|
|
119
|
+
private readonly _schemaInfoLoader;
|
|
120
|
+
constructor(schemaInfoLoader: LoadSchemaInfoHandler);
|
|
121
|
+
getSchemasByContext(context: SchemaContext): Promise<IncrementalSchemaInfo[] | undefined>;
|
|
122
|
+
lookup(schemaKey: SchemaKey, matchType: SchemaMatchType, context: SchemaContext): Promise<IncrementalSchemaInfo | undefined>;
|
|
123
|
+
remove(schemaKey: SchemaKey, context: SchemaContext): void;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
|
109
126
|
//# sourceMappingURL=IncrementalSchemaLocater.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"IncrementalSchemaLocater.d.ts","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaLocater.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAwB,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,U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AAG,IAAI;CAUlE"}
|
|
@@ -86,6 +86,8 @@ export class IncrementalSchemaLocater {
|
|
|
86
86
|
// to fetch the whole schema json.
|
|
87
87
|
if (!await this.supportPartialSchemaLoading(schemaContext)) {
|
|
88
88
|
const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);
|
|
89
|
+
if (schemaJson === undefined)
|
|
90
|
+
throw new ECSchemaError(ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema, ${schemaInfo.schemaKey.name}.${schemaInfo.schemaKey.version.toString()}`);
|
|
89
91
|
return Schema.fromJson(schemaJson, schemaContext);
|
|
90
92
|
}
|
|
91
93
|
// Fetches the schema partials for the given schema key. The first item in the array is the
|
|
@@ -116,18 +118,19 @@ export class IncrementalSchemaLocater {
|
|
|
116
118
|
const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, SchemaMatchType.Latest);
|
|
117
119
|
if (!schemaInfo)
|
|
118
120
|
throw new Error(`Schema ${schemaKey.name} could not be found.`);
|
|
121
|
+
const schemaReferences = [];
|
|
119
122
|
const schemaProps = {
|
|
120
123
|
$schema: ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
|
|
121
124
|
name: schemaKey.name,
|
|
122
125
|
alias: schemaInfo.alias,
|
|
123
126
|
version: schemaInfo.schemaKey.version.toString(),
|
|
124
|
-
|
|
127
|
+
description: schemaInfo.description,
|
|
128
|
+
label: schemaInfo.label,
|
|
129
|
+
references: schemaReferences,
|
|
125
130
|
items: {}
|
|
126
131
|
};
|
|
127
|
-
if (!schemaProps.references)
|
|
128
|
-
throw new Error(`Schema references is undefined for the Schema ${schemaInfo.schemaKey.name}`);
|
|
129
132
|
schemaInfo.references.forEach((ref) => {
|
|
130
|
-
|
|
133
|
+
schemaReferences.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });
|
|
131
134
|
});
|
|
132
135
|
return schemaProps;
|
|
133
136
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSch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AAC,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 private 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,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAmBpE;;;;;;;;GAQG;AACH,MAAM,OAAgB,wBAAwB;IAC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AAC,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\ninterface IncrementalSchemaInfo extends SchemaInfo {\n readonly description?: string;\n readonly label?: string;\n}\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) as IncrementalSchemaInfo | undefined;\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 description: schemaInfo.description,\n label: schemaInfo.label,\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<IncrementalSchemaInfo>>;\n private readonly _schemaInfoLoader: LoadSchemaInfoHandler;\n\n constructor(schemaInfoLoader: LoadSchemaInfoHandler) {\n this._schemaInfoCache = new WeakMap<SchemaContext, Array<IncrementalSchemaInfo>>();\n this._schemaInfoLoader = schemaInfoLoader;\n }\n\n public async getSchemasByContext(context: SchemaContext): Promise<IncrementalSchemaInfo[] | 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<IncrementalSchemaInfo | 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;
|
|
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"}
|
|
@@ -2,7 +2,6 @@ import { SchemaReadHelper } from "../Deserialization/Helper";
|
|
|
2
2
|
import { JsonParser } from "../Deserialization/JsonParser";
|
|
3
3
|
import { SchemaItemType } from "../ECObjects";
|
|
4
4
|
import { ECClass } from "../Metadata/Class";
|
|
5
|
-
import { SchemaItem } from "../Metadata/SchemaItem";
|
|
6
5
|
import { SchemaLoadingController } from "../utils/SchemaLoadingController";
|
|
7
6
|
/**
|
|
8
7
|
* Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]
|
|
@@ -45,12 +44,7 @@ export class IncrementalSchemaReader extends SchemaReadHelper {
|
|
|
45
44
|
// The fromJSON method of the actual class instances may complain about missing properties in the props, so
|
|
46
45
|
// calling the fromJSON on the ECClass ensures only the bare minimum is loaded.
|
|
47
46
|
if (this._incremental && schemaItemObject && schemaItem) {
|
|
48
|
-
|
|
49
|
-
SchemaItem.prototype.fromJSONSync.call(schemaItem, schemaItemObject);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
schemaItem.fromJSONSync(schemaItemObject);
|
|
53
|
-
}
|
|
47
|
+
await schemaItem.fromJSON(schemaItemObject);
|
|
54
48
|
}
|
|
55
49
|
this.schemaItemLoading(schemaItem);
|
|
56
50
|
return schemaItem;
|
|
@@ -61,6 +55,7 @@ export class IncrementalSchemaReader extends SchemaReadHelper {
|
|
|
61
55
|
if (schemaItem.loadingController === undefined) {
|
|
62
56
|
const controller = new SchemaLoadingController();
|
|
63
57
|
schemaItem.setLoadingController(controller);
|
|
58
|
+
return this.schemaItemLoading(schemaItem);
|
|
64
59
|
}
|
|
65
60
|
if (ECClass.isECClass(schemaItem)
|
|
66
61
|
|| schemaItem.schemaItemType === SchemaItemType.KindOfQuantity
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IncrementalSchemaReader.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"IncrementalSchemaReader.js","sourceRoot":"","sources":["../../../src/IncrementalLoading/IncrementalSchemaReader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OA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AG,IAAI,uBAAuB,EAAE,CAAC;YACjD,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;YAE5C,OAAO,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC;eAC5B,UAAU,CAAC,cAAc,KAAK,cAAc,CAAC,cAAc;eAC3D,UAAU,CAAC,cAAc,KAAK,cAAc,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","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}"]}
|