@itwin/ecschema-rpcinterface-tests 5.1.0-dev.59 → 5.1.0-dev.61

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.
@@ -30841,6 +30841,7 @@ var PrimitiveTypeCode;
30841
30841
  * @beta
30842
30842
  * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use the `Property` class from @itwin/ecschema-metadata` instead.
30843
30843
  */
30844
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
30844
30845
  class PropertyMetaData {
30845
30846
  primitiveType;
30846
30847
  structName;
@@ -30926,6 +30927,7 @@ class PropertyMetaData {
30926
30927
  * @beta
30927
30928
  * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `EntityClass` class from `@itwin/ecschema-metadata` instead.
30928
30929
  */
30930
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
30929
30931
  class EntityMetaData {
30930
30932
  /** The Id of the class in the [[IModelDb]] from which the metadata was obtained. */
30931
30933
  classId;
@@ -55001,7 +55003,7 @@ class IModelReadRpcInterface extends _RpcInterface__WEBPACK_IMPORTED_MODULE_0__.
55001
55003
  async getViewStateData(_iModelToken, _viewDefinitionId, _options) { return this.forward(arguments); }
55002
55004
  async readFontJson(_iModelToken) { return this.forward(arguments); } // eslint-disable-line @typescript-eslint/no-deprecated
55003
55005
  async getToolTipMessage(_iModelToken, _elementId) { return this.forward(arguments); }
55004
- /** @deprecated in 3.x - might be removed in next major version. Use ViewStore apis. */
55006
+ /** @deprecated in 3.3.0 - might be removed in next major version. Use ViewStore apis. */
55005
55007
  async getViewThumbnail(_iModelToken, _viewId) { return this.forward(arguments); }
55006
55008
  async getDefaultViewId(_iModelToken) { return this.forward(arguments); }
55007
55009
  async getCustomViewState3dData(_iModelToken, _options) { return this.forward(arguments); }
@@ -60987,8 +60989,11 @@ class SchemaReadHelper {
60987
60989
  * calling getCachedSchema on the context.
60988
60990
  * @param schema The Schema to populate
60989
60991
  * @param rawSchema The serialized data to use to populate the Schema.
60992
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
60993
+ * The default is true. If false, the schema loading will not begin asynchronously in the background because the
60994
+ * schema promise must be added to the context. In this case, only the SchemaInfo is returned.
60990
60995
  */
60991
- async readSchemaInfo(schema, rawSchema) {
60996
+ async readSchemaInfo(schema, rawSchema, addSchemaToCache = true) {
60992
60997
  // Ensure context matches schema context
60993
60998
  if (schema.context) {
60994
60999
  if (this._context !== schema.context)
@@ -61001,15 +61006,15 @@ class SchemaReadHelper {
61001
61006
  // Loads all of the properties on the Schema object
61002
61007
  await schema.fromJSON(this._parser.parseSchema());
61003
61008
  this._schema = schema;
61004
- const schemaInfoReferences = [];
61005
- const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaInfoReferences };
61009
+ const schemaReferences = [];
61010
+ const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaReferences };
61006
61011
  for (const reference of this._parser.getReferences()) {
61007
61012
  const refKey = new _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey(reference.name, _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.ECVersion.fromString(reference.version));
61008
- schemaInfoReferences.push({ schemaKey: refKey });
61013
+ schemaReferences.push({ schemaKey: refKey });
61009
61014
  }
61010
61015
  this._schemaInfo = schemaInfo;
61011
61016
  // Need to add this schema to the context to be able to locate schemaItems within the context.
61012
- if (!this._context.schemaExists(schema.schemaKey)) {
61017
+ if (addSchemaToCache && !this._context.schemaExists(schema.schemaKey)) {
61013
61018
  await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));
61014
61019
  }
61015
61020
  return schemaInfo;
@@ -61018,33 +61023,53 @@ class SchemaReadHelper {
61018
61023
  * Populates the given Schema from a serialized representation.
61019
61024
  * @param schema The Schema to populate
61020
61025
  * @param rawSchema The serialized data to use to populate the Schema.
61026
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
61027
+ * The default is true. If false, the schema will be loaded directly by this method and not from the context's schema cache.
61021
61028
  */
61022
- async readSchema(schema, rawSchema) {
61029
+ async readSchema(schema, rawSchema, addSchemaToCache = true) {
61023
61030
  if (!this._schemaInfo) {
61024
- await this.readSchemaInfo(schema, rawSchema);
61031
+ await this.readSchemaInfo(schema, rawSchema, addSchemaToCache);
61032
+ }
61033
+ // If not adding schema to cache (occurs in readSchemaInfo), we must load the schema here
61034
+ if (!addSchemaToCache) {
61035
+ const loadedSchema = await this.loadSchema(this._schemaInfo, schema);
61036
+ if (undefined === loadedSchema)
61037
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
61038
+ return loadedSchema;
61025
61039
  }
61026
61040
  const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.Latest);
61027
61041
  if (undefined === cachedSchema)
61028
61042
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
61029
61043
  return cachedSchema;
61030
61044
  }
61045
+ /**
61046
+ * Called when a SchemaItem has been successfully loaded by the Helper. The default implementation simply
61047
+ * checks if the schema item is undefined. An implementation of the helper may choose to partially load
61048
+ * a schema item in which case this method would indicate if the item has been fully loaded.
61049
+ * @param schemaItem The SchemaItem to check.
61050
+ * @returns True if the SchemaItem has been fully loaded, false otherwise.
61051
+ */
61052
+ isSchemaItemLoaded(schemaItem) {
61053
+ return schemaItem !== undefined;
61054
+ }
61031
61055
  /* Finish loading the rest of the schema */
61032
61056
  async loadSchema(schemaInfo, schema) {
61033
61057
  // Verify that there are no schema reference cycles, this will start schema loading by loading their headers
61034
61058
  (await _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_8__.SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();
61035
61059
  for (const reference of schemaInfo.references) {
61036
- await this.loadSchemaReference(schemaInfo, reference.schemaKey);
61060
+ await this.loadSchemaReference(schema, reference.schemaKey);
61037
61061
  }
61038
61062
  if (this._visitorHelper)
61039
61063
  await this._visitorHelper.visitSchema(schema, false);
61040
61064
  // Load all schema items
61041
61065
  for (const [itemName, itemType, rawItem] of this._parser.getItems()) {
61042
- // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,
61066
+ // Make sure the item has not already been loaded. No need to check the SchemaContext because all SchemaItems are added to a Schema,
61043
61067
  // which would be found when adding to the context.
61044
- if (await schema.getItem(itemName) !== undefined)
61068
+ const schemaItem = await schema.getItem(itemName);
61069
+ if (this.isSchemaItemLoaded(schemaItem))
61045
61070
  continue;
61046
61071
  const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);
61047
- if (loadedItem && this._visitorHelper) {
61072
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
61048
61073
  await this._visitorHelper.visitSchemaPart(loadedItem);
61049
61074
  }
61050
61075
  }
@@ -61075,12 +61100,8 @@ class SchemaReadHelper {
61075
61100
  this._visitorHelper.visitSchemaSync(schema, false);
61076
61101
  // Load all schema items
61077
61102
  for (const [itemName, itemType, rawItem] of this._parser.getItems()) {
61078
- // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,
61079
- // which would be found when adding to the context.
61080
- if (schema.getItemSync(itemName) !== undefined)
61081
- continue;
61082
61103
  const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);
61083
- if (loadedItem && this._visitorHelper) {
61104
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
61084
61105
  this._visitorHelper.visitSchemaPartSync(loadedItem);
61085
61106
  }
61086
61107
  }
@@ -61093,12 +61114,14 @@ class SchemaReadHelper {
61093
61114
  * Ensures that the schema references can be located and adds them to the schema.
61094
61115
  * @param ref The object to read the SchemaReference's props from.
61095
61116
  */
61096
- async loadSchemaReference(schemaInfo, refKey) {
61117
+ async loadSchemaReference(schema, refKey) {
61097
61118
  const refSchema = await this._context.getSchema(refKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.LatestWriteCompatible);
61098
61119
  if (undefined === refSchema)
61099
- throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schemaInfo.schemaKey.name}`);
61100
- await this._schema.addReference(refSchema);
61101
- const results = this.validateSchemaReferences(this._schema);
61120
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schema.schemaKey.name}`);
61121
+ if (schema.references.find((ref) => ref.schemaKey.matches(refSchema.schemaKey)))
61122
+ return refSchema;
61123
+ await schema.addReference(refSchema);
61124
+ const results = this.validateSchemaReferences(schema);
61102
61125
  let errorMessage = "";
61103
61126
  for (const result of results) {
61104
61127
  errorMessage += `${result}\r\n`;
@@ -61106,6 +61129,7 @@ class SchemaReadHelper {
61106
61129
  if (errorMessage) {
61107
61130
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `${errorMessage}`);
61108
61131
  }
61132
+ return refSchema;
61109
61133
  }
61110
61134
  /**
61111
61135
  * Ensures that the schema references can be located and adds them to the schema.
@@ -61155,73 +61179,97 @@ class SchemaReadHelper {
61155
61179
  * @param schemaItemObject The Object to populate the SchemaItem with.
61156
61180
  */
61157
61181
  async loadSchemaItem(schema, name, itemType, schemaItemObject) {
61158
- let schemaItem;
61182
+ let schemaItem = await schema.getItem(name);
61183
+ if (this.isSchemaItemLoaded(schemaItem)) {
61184
+ return schemaItem;
61185
+ }
61159
61186
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
61160
61187
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
61161
- schemaItem = await schema.createEntityClass(name);
61162
- await this.loadEntityClass(schemaItem, schemaItemObject);
61188
+ schemaItem = schemaItem || await schema.createEntityClass(name);
61189
+ schemaItemObject && await this.loadEntityClass(schemaItem, schemaItemObject);
61163
61190
  break;
61164
61191
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
61165
- schemaItem = await schema.createStructClass(name);
61166
- const structProps = this._parser.parseStructClass(schemaItemObject);
61167
- await this.loadClass(schemaItem, structProps, schemaItemObject);
61192
+ schemaItem = schemaItem || await schema.createStructClass(name);
61193
+ const structProps = schemaItemObject && this._parser.parseStructClass(schemaItemObject);
61194
+ structProps && await this.loadClass(schemaItem, structProps, schemaItemObject);
61168
61195
  break;
61169
61196
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
61170
- schemaItem = await schema.createMixinClass(name);
61171
- await this.loadMixin(schemaItem, schemaItemObject);
61197
+ schemaItem = schemaItem || await schema.createMixinClass(name);
61198
+ schemaItemObject && await this.loadMixin(schemaItem, schemaItemObject);
61172
61199
  break;
61173
61200
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
61174
- schemaItem = await schema.createCustomAttributeClass(name);
61175
- const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);
61176
- await this.loadClass(schemaItem, caClassProps, schemaItemObject);
61201
+ schemaItem = schemaItem || await schema.createCustomAttributeClass(name);
61202
+ const caClassProps = schemaItemObject && this._parser.parseCustomAttributeClass(schemaItemObject);
61203
+ caClassProps && await this.loadClass(schemaItem, caClassProps, schemaItemObject);
61177
61204
  break;
61178
61205
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
61179
- schemaItem = await schema.createRelationshipClass(name);
61180
- await this.loadRelationshipClass(schemaItem, schemaItemObject);
61206
+ schemaItem = schemaItem || await schema.createRelationshipClass(name);
61207
+ schemaItemObject && await this.loadRelationshipClass(schemaItem, schemaItemObject);
61181
61208
  break;
61182
61209
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
61183
- schemaItem = await schema.createKindOfQuantity(name);
61184
- await this.loadKindOfQuantity(schemaItem, schemaItemObject);
61210
+ schemaItem = schemaItem || await schema.createKindOfQuantity(name);
61211
+ schemaItemObject && await this.loadKindOfQuantity(schemaItem, schemaItemObject);
61185
61212
  break;
61186
61213
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
61187
- schemaItem = await schema.createUnit(name);
61188
- await this.loadUnit(schemaItem, schemaItemObject);
61214
+ schemaItem = schemaItem || await schema.createUnit(name);
61215
+ schemaItemObject && await this.loadUnit(schemaItem, schemaItemObject);
61189
61216
  break;
61190
61217
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
61191
- schemaItem = await schema.createConstant(name);
61192
- await this.loadConstant(schemaItem, schemaItemObject);
61218
+ schemaItem = schemaItem || await schema.createConstant(name);
61219
+ schemaItemObject && await this.loadConstant(schemaItem, schemaItemObject);
61193
61220
  break;
61194
61221
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
61195
- schemaItem = await schema.createInvertedUnit(name);
61196
- await this.loadInvertedUnit(schemaItem, schemaItemObject);
61222
+ schemaItem = schemaItem || await schema.createInvertedUnit(name);
61223
+ schemaItemObject && await this.loadInvertedUnit(schemaItem, schemaItemObject);
61197
61224
  break;
61198
61225
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
61199
- schemaItem = await schema.createFormat(name);
61200
- await this.loadFormat(schemaItem, schemaItemObject);
61226
+ schemaItem = schemaItem || await schema.createFormat(name);
61227
+ schemaItemObject && await this.loadFormat(schemaItem, schemaItemObject);
61201
61228
  break;
61202
61229
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Phenomenon:
61203
- schemaItem = await schema.createPhenomenon(name);
61204
- const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);
61205
- await schemaItem.fromJSON(phenomenonProps);
61230
+ schemaItem = schemaItem || await schema.createPhenomenon(name);
61231
+ const phenomenonProps = schemaItemObject && this._parser.parsePhenomenon(schemaItemObject);
61232
+ phenomenonProps && await schemaItem.fromJSON(phenomenonProps);
61206
61233
  break;
61207
61234
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
61208
- schemaItem = await schema.createUnitSystem(name);
61209
- await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
61235
+ schemaItem = schemaItem || await schema.createUnitSystem(name);
61236
+ schemaItemObject && await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
61210
61237
  break;
61211
61238
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.PropertyCategory:
61212
- schemaItem = await schema.createPropertyCategory(name);
61213
- const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);
61214
- await schemaItem.fromJSON(propertyCategoryProps);
61239
+ schemaItem = schemaItem || await schema.createPropertyCategory(name);
61240
+ const propertyCategoryProps = schemaItemObject && this._parser.parsePropertyCategory(schemaItemObject);
61241
+ propertyCategoryProps && schemaItemObject && await schemaItem.fromJSON(propertyCategoryProps);
61215
61242
  break;
61216
61243
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Enumeration:
61217
- schemaItem = await schema.createEnumeration(name);
61218
- const enumerationProps = this._parser.parseEnumeration(schemaItemObject);
61219
- await schemaItem.fromJSON(enumerationProps);
61244
+ schemaItem = schemaItem || await schema.createEnumeration(name);
61245
+ const enumerationProps = schemaItemObject && this._parser.parseEnumeration(schemaItemObject);
61246
+ enumerationProps && await schemaItem.fromJSON(enumerationProps);
61220
61247
  break;
61221
61248
  // NOTE: we are being permissive here and allowing unknown types to silently fail. Not sure if we want to hard fail or just do a basic deserialization
61222
61249
  }
61223
61250
  return schemaItem;
61224
61251
  }
61252
+ /**
61253
+ * Load the customAttribute class dependencies for a set of CustomAttribute objects and add
61254
+ * them to a given custom attribute container.
61255
+ * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
61256
+ * @param customAttributes An iterable set of parsed CustomAttribute objects.
61257
+ */
61258
+ async loadCustomAttributes(container, caProviders) {
61259
+ for (const providerTuple of caProviders) {
61260
+ // First tuple entry is the CA class name.
61261
+ const caClass = await this.findSchemaItem(providerTuple[0]);
61262
+ // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
61263
+ if (caClass && caClass.key.schemaName !== container.schema.name &&
61264
+ !container.schema.getReferenceSync(caClass.key.schemaName)) {
61265
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `Unable to load custom attribute ${caClass.fullName} from container ${container.fullName}, ${caClass.key.schemaName} reference not defined`);
61266
+ }
61267
+ // Second tuple entry ia a function that provides the CA instance.
61268
+ const provider = providerTuple[1];
61269
+ const customAttribute = provider(caClass);
61270
+ container.addCustomAttribute(customAttribute);
61271
+ }
61272
+ }
61225
61273
  /**
61226
61274
  * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
61227
61275
  * @param schema The Schema the SchemaItem to.
@@ -61230,66 +61278,69 @@ class SchemaReadHelper {
61230
61278
  * @param schemaItemObject The Object to populate the SchemaItem with.
61231
61279
  */
61232
61280
  loadSchemaItemSync(schema, name, itemType, schemaItemObject) {
61233
- let schemaItem;
61281
+ let schemaItem = schema.getItemSync(name);
61282
+ if (this.isSchemaItemLoaded(schemaItem)) {
61283
+ return schemaItem;
61284
+ }
61234
61285
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
61235
61286
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
61236
- schemaItem = schema.createEntityClassSync(name);
61287
+ schemaItem = schemaItem || schema.createEntityClassSync(name);
61237
61288
  this.loadEntityClassSync(schemaItem, schemaItemObject);
61238
61289
  break;
61239
61290
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
61240
- schemaItem = schema.createStructClassSync(name);
61291
+ schemaItem = schemaItem || schema.createStructClassSync(name);
61241
61292
  const structProps = this._parser.parseStructClass(schemaItemObject);
61242
61293
  this.loadClassSync(schemaItem, structProps, schemaItemObject);
61243
61294
  break;
61244
61295
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
61245
- schemaItem = schema.createMixinClassSync(name);
61296
+ schemaItem = schemaItem || schema.createMixinClassSync(name);
61246
61297
  this.loadMixinSync(schemaItem, schemaItemObject);
61247
61298
  break;
61248
61299
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
61249
- schemaItem = schema.createCustomAttributeClassSync(name);
61300
+ schemaItem = schemaItem || schema.createCustomAttributeClassSync(name);
61250
61301
  const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);
61251
61302
  this.loadClassSync(schemaItem, caClassProps, schemaItemObject);
61252
61303
  break;
61253
61304
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
61254
- schemaItem = schema.createRelationshipClassSync(name);
61305
+ schemaItem = schemaItem || schema.createRelationshipClassSync(name);
61255
61306
  this.loadRelationshipClassSync(schemaItem, schemaItemObject);
61256
61307
  break;
61257
61308
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
61258
- schemaItem = schema.createKindOfQuantitySync(name);
61309
+ schemaItem = schemaItem || schema.createKindOfQuantitySync(name);
61259
61310
  this.loadKindOfQuantitySync(schemaItem, schemaItemObject);
61260
61311
  break;
61261
61312
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
61262
- schemaItem = schema.createUnitSync(name);
61313
+ schemaItem = schemaItem || schema.createUnitSync(name);
61263
61314
  this.loadUnitSync(schemaItem, schemaItemObject);
61264
61315
  break;
61265
61316
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
61266
- schemaItem = schema.createConstantSync(name);
61317
+ schemaItem = schemaItem || schema.createConstantSync(name);
61267
61318
  this.loadConstantSync(schemaItem, schemaItemObject);
61268
61319
  break;
61269
61320
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
61270
- schemaItem = schema.createInvertedUnitSync(name);
61321
+ schemaItem = schemaItem || schema.createInvertedUnitSync(name);
61271
61322
  this.loadInvertedUnitSync(schemaItem, schemaItemObject);
61272
61323
  break;
61273
61324
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
61274
- schemaItem = schema.createFormatSync(name);
61325
+ schemaItem = schemaItem || schema.createFormatSync(name);
61275
61326
  this.loadFormatSync(schemaItem, schemaItemObject);
61276
61327
  break;
61277
61328
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Phenomenon:
61278
- schemaItem = schema.createPhenomenonSync(name);
61329
+ schemaItem = schemaItem || schema.createPhenomenonSync(name);
61279
61330
  const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);
61280
61331
  schemaItem.fromJSONSync(phenomenonProps);
61281
61332
  break;
61282
61333
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
61283
- schemaItem = schema.createUnitSystemSync(name);
61334
+ schemaItem = schemaItem || schema.createUnitSystemSync(name);
61284
61335
  schemaItem.fromJSONSync(this._parser.parseUnitSystem(schemaItemObject));
61285
61336
  break;
61286
61337
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.PropertyCategory:
61287
- schemaItem = schema.createPropertyCategorySync(name);
61338
+ schemaItem = schemaItem || schema.createPropertyCategorySync(name);
61288
61339
  const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);
61289
61340
  schemaItem.fromJSONSync(propertyCategoryProps);
61290
61341
  break;
61291
61342
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Enumeration:
61292
- schemaItem = schema.createEnumerationSync(name);
61343
+ schemaItem = schemaItem || schema.createEnumerationSync(name);
61293
61344
  const enumerationProps = this._parser.parseEnumeration(schemaItemObject);
61294
61345
  schemaItem.fromJSONSync(enumerationProps);
61295
61346
  break;
@@ -61337,7 +61388,7 @@ class SchemaReadHelper {
61337
61388
  const foundItem = this._parser.findItem(itemName);
61338
61389
  if (foundItem) {
61339
61390
  schemaItem = await this.loadSchemaItem(this._schema, ...foundItem);
61340
- if (!skipVisitor && schemaItem && this._visitorHelper) {
61391
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
61341
61392
  await this._visitorHelper.visitSchemaPart(schemaItem);
61342
61393
  }
61343
61394
  if (loadCallBack && schemaItem)
@@ -61370,7 +61421,7 @@ class SchemaReadHelper {
61370
61421
  const foundItem = this._parser.findItem(itemName);
61371
61422
  if (foundItem) {
61372
61423
  schemaItem = this.loadSchemaItemSync(this._schema, ...foundItem);
61373
- if (!skipVisitor && schemaItem && this._visitorHelper) {
61424
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
61374
61425
  this._visitorHelper.visitSchemaPartSync(schemaItem);
61375
61426
  }
61376
61427
  if (loadCallBack && schemaItem)
@@ -61520,7 +61571,7 @@ class SchemaReadHelper {
61520
61571
  */
61521
61572
  async loadClass(classObj, classProps, rawClass) {
61522
61573
  const baseClassLoaded = async (baseClass) => {
61523
- if (this._visitorHelper)
61574
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
61524
61575
  await this._visitorHelper.visitSchemaPart(baseClass);
61525
61576
  };
61526
61577
  // Load base class first
@@ -61543,7 +61594,7 @@ class SchemaReadHelper {
61543
61594
  */
61544
61595
  loadClassSync(classObj, classProps, rawClass) {
61545
61596
  const baseClassLoaded = async (baseClass) => {
61546
- if (this._visitorHelper)
61597
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
61547
61598
  this._visitorHelper.visitSchemaPartSync(baseClass);
61548
61599
  };
61549
61600
  // Load base class first
@@ -61594,7 +61645,7 @@ class SchemaReadHelper {
61594
61645
  async loadMixin(mixin, rawMixin) {
61595
61646
  const mixinProps = this._parser.parseMixin(rawMixin);
61596
61647
  const appliesToLoaded = async (appliesToClass) => {
61597
- if (this._visitorHelper)
61648
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
61598
61649
  await this._visitorHelper.visitSchemaPart(appliesToClass);
61599
61650
  };
61600
61651
  await this.findSchemaItem(mixinProps.appliesTo, true, appliesToLoaded);
@@ -61608,7 +61659,7 @@ class SchemaReadHelper {
61608
61659
  loadMixinSync(mixin, rawMixin) {
61609
61660
  const mixinProps = this._parser.parseMixin(rawMixin);
61610
61661
  const appliesToLoaded = async (appliesToClass) => {
61611
- if (this._visitorHelper)
61662
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
61612
61663
  await this._visitorHelper.visitSchemaPart(appliesToClass);
61613
61664
  };
61614
61665
  this.findSchemaItemSync(mixinProps.appliesTo, true, appliesToLoaded);
@@ -61804,27 +61855,6 @@ class SchemaReadHelper {
61804
61855
  propertyObj.fromJSONSync(props);
61805
61856
  this.loadCustomAttributesSync(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));
61806
61857
  }
61807
- /**
61808
- * Load the customAttribute class dependencies for a set of CustomAttribute objects and add
61809
- * them to a given custom attribute container.
61810
- * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
61811
- * @param customAttributes An iterable set of parsed CustomAttribute objects.
61812
- */
61813
- async loadCustomAttributes(container, caProviders) {
61814
- for (const providerTuple of caProviders) {
61815
- // First tuple entry is the CA class name.
61816
- const caClass = await this.findSchemaItem(providerTuple[0]);
61817
- // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
61818
- if (caClass && caClass.key.schemaName !== container.schema.name &&
61819
- !container.schema.getReferenceSync(caClass.key.schemaName)) {
61820
- throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `Unable to load custom attribute ${caClass.fullName} from container ${container.fullName}, ${caClass.key.schemaName} reference not defined`);
61821
- }
61822
- // Second tuple entry ia a function that provides the CA instance.
61823
- const provider = providerTuple[1];
61824
- const customAttribute = provider(caClass);
61825
- container.addCustomAttribute(customAttribute);
61826
- }
61827
- }
61828
61858
  /**
61829
61859
  * Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.
61830
61860
  * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
@@ -63178,8 +63208,8 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
63178
63208
  }
63179
63209
  }
63180
63210
  parsePrimitiveProperty(xmlElement) {
63181
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
63182
63211
  const typeName = this.getPropertyTypeName(xmlElement);
63212
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
63183
63213
  const primitivePropertyProps = { ...propertyProps, typeName };
63184
63214
  return primitivePropertyProps;
63185
63215
  }
@@ -63191,7 +63221,7 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
63191
63221
  }
63192
63222
  parsePrimitiveArrayProperty(xmlElement) {
63193
63223
  const typeName = this.getPropertyTypeName(xmlElement);
63194
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
63224
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
63195
63225
  const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);
63196
63226
  return {
63197
63227
  ...propertyProps,
@@ -63466,14 +63496,23 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
63466
63496
  return rawTypeName;
63467
63497
  return this.getQualifiedTypeName(rawTypeName);
63468
63498
  }
63469
- getPrimitiveOrEnumPropertyBaseProps(xmlElement) {
63499
+ getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName) {
63500
+ const primitiveType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parsePrimitiveType)(typeName);
63470
63501
  const propertyProps = this.getPropertyProps(xmlElement);
63471
63502
  const propName = propertyProps.name;
63472
63503
  const extendedTypeName = this.getOptionalAttribute(xmlElement, "extendedTypeName");
63473
63504
  const minLength = this.getOptionalIntAttribute(xmlElement, "minimumLength", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumLength' attribute. It should be a numeric value.`);
63474
63505
  const maxLength = this.getOptionalIntAttribute(xmlElement, "maximumLength", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumLength' attribute. It should be a numeric value.`);
63475
- const minValue = this.getOptionalIntAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
63476
- const maxValue = this.getOptionalIntAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
63506
+ let minValue;
63507
+ let maxValue;
63508
+ if (primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Double || primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Long) {
63509
+ minValue = this.getOptionalFloatAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
63510
+ maxValue = this.getOptionalFloatAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
63511
+ }
63512
+ else {
63513
+ minValue = this.getOptionalIntAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
63514
+ maxValue = this.getOptionalIntAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
63515
+ }
63477
63516
  return {
63478
63517
  ...propertyProps,
63479
63518
  extendedTypeName,
@@ -64629,6 +64668,2441 @@ class ECSchemaError extends _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Ben
64629
64668
  }
64630
64669
 
64631
64670
 
64671
+ /***/ }),
64672
+
64673
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js":
64674
+ /*!*******************************************************************************!*\
64675
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js ***!
64676
+ \*******************************************************************************/
64677
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
64678
+
64679
+ "use strict";
64680
+ __webpack_require__.r(__webpack_exports__);
64681
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
64682
+ /* harmony export */ ClassParser: () => (/* binding */ ClassParser),
64683
+ /* harmony export */ CustomAttributeClassParser: () => (/* binding */ CustomAttributeClassParser),
64684
+ /* harmony export */ MixinParser: () => (/* binding */ MixinParser),
64685
+ /* harmony export */ RelationshipClassParser: () => (/* binding */ RelationshipClassParser)
64686
+ /* harmony export */ });
64687
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
64688
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
64689
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
64690
+ /*---------------------------------------------------------------------------------------------
64691
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
64692
+ * See LICENSE.md in the project root for license terms and full copyright notice.
64693
+ *--------------------------------------------------------------------------------------------*/
64694
+
64695
+
64696
+
64697
+ /**
64698
+ * Parses ClassProps JSON returned from an ECSql query and returns the correct ClassProps JSON.
64699
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the
64700
+ * iModelDb is in a different format than is required for a ClassProps JSON object.
64701
+ * @internal
64702
+ */
64703
+ class ClassParser extends _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__.SchemaItemParser {
64704
+ /**
64705
+ * Parses the given ClassProps JSON returned from an ECSql query.
64706
+ * @param data The ClassProps JSON as returned from an iModelDb.
64707
+ * @returns The corrected ClassProps Json.
64708
+ */
64709
+ async parse(data) {
64710
+ const props = await super.parse(data);
64711
+ if (props.properties) {
64712
+ if (props.properties.length === 0)
64713
+ delete props.properties;
64714
+ else
64715
+ this.parseProperties(props.properties);
64716
+ }
64717
+ return props;
64718
+ }
64719
+ parseProperties(propertyProps) {
64720
+ for (const props of propertyProps) {
64721
+ props.customAttributes = props.customAttributes && props.customAttributes.length > 0 ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
64722
+ if (!props.customAttributes)
64723
+ delete props.customAttributes;
64724
+ }
64725
+ }
64726
+ }
64727
+ /**
64728
+ * Parses the given MixinProps JSON returned from an ECSql query.
64729
+ * @param data The MixinProps JSON as returned from an iModelDb.
64730
+ * @returns The corrected MixinProps Json.
64731
+ * @internal
64732
+ */
64733
+ class MixinParser extends ClassParser {
64734
+ /**
64735
+ * Parses the given MixinProps JSON returned from an ECSql query.
64736
+ * @param data The MixinProps JSON as returned from an iModelDb.
64737
+ * @returns The corrected MixinProps Json.
64738
+ */
64739
+ async parse(data) {
64740
+ const props = await super.parse(data);
64741
+ if (!props.customAttributes)
64742
+ delete props.customAttributes;
64743
+ return props;
64744
+ }
64745
+ }
64746
+ /**
64747
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
64748
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
64749
+ * @returns The corrected CustomAttributeClassProps Json.
64750
+ * @internal
64751
+ */
64752
+ class CustomAttributeClassParser extends ClassParser {
64753
+ /**
64754
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
64755
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
64756
+ * @returns The corrected CustomAttributeClassProps Json.
64757
+ */
64758
+ async parse(data) {
64759
+ const props = await super.parse(data);
64760
+ props.appliesTo = props.appliesTo ? (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.containerTypeToString)(props.appliesTo) : _ECObjects__WEBPACK_IMPORTED_MODULE_0__.CustomAttributeContainerType[_ECObjects__WEBPACK_IMPORTED_MODULE_0__.CustomAttributeContainerType.Any];
64761
+ return props;
64762
+ }
64763
+ }
64764
+ /**
64765
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
64766
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
64767
+ * @returns The corrected RelationshipClassProps Json.
64768
+ * @internal
64769
+ */
64770
+ class RelationshipClassParser extends ClassParser {
64771
+ /**
64772
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
64773
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
64774
+ * @returns The corrected RelationshipClassProps Json.
64775
+ */
64776
+ async parse(data) {
64777
+ const props = await super.parse(data);
64778
+ const source = props.source;
64779
+ const target = props.target;
64780
+ if (source) {
64781
+ source.customAttributes = source.customAttributes ? source.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
64782
+ if (!source.customAttributes)
64783
+ delete source.customAttributes;
64784
+ }
64785
+ if (target) {
64786
+ target.customAttributes = target.customAttributes ? target.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
64787
+ if (!target.customAttributes)
64788
+ delete target.customAttributes;
64789
+ }
64790
+ return props;
64791
+ }
64792
+ }
64793
+
64794
+
64795
+ /***/ }),
64796
+
64797
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js":
64798
+ /*!*************************************************************************************!*\
64799
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js ***!
64800
+ \*************************************************************************************/
64801
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
64802
+
64803
+ "use strict";
64804
+ __webpack_require__.r(__webpack_exports__);
64805
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
64806
+ /* harmony export */ ECSqlSchemaLocater: () => (/* binding */ ECSqlSchemaLocater)
64807
+ /* harmony export */ });
64808
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
64809
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
64810
+ /* harmony import */ var _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FullSchemaQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js");
64811
+ /* harmony import */ var _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
64812
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
64813
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
64814
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
64815
+ /*---------------------------------------------------------------------------------------------
64816
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
64817
+ * See LICENSE.md in the project root for license terms and full copyright notice.
64818
+ *--------------------------------------------------------------------------------------------*/
64819
+
64820
+
64821
+
64822
+
64823
+
64824
+
64825
+
64826
+ /**
64827
+ * An abstract [[IncrementalSchemaLocater]] implementation for loading
64828
+ * EC [Schema] instances from an iModelDb using ECSql queries.
64829
+ * @internal
64830
+ */
64831
+ class ECSqlSchemaLocater extends _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__.IncrementalSchemaLocater {
64832
+ /**
64833
+ * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.
64834
+ */
64835
+ get options() {
64836
+ return super.options;
64837
+ }
64838
+ /**
64839
+ * Initializes a new ECSqlSchemaLocater instance.
64840
+ * @param options The options used by this Schema locater.
64841
+ */
64842
+ constructor(options) {
64843
+ super(options);
64844
+ }
64845
+ /**
64846
+ * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined
64847
+ * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.
64848
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
64849
+ * @param context The [[SchemaContext]] to use for resolving references.
64850
+ * @internal
64851
+ */
64852
+ async getSchemaJson(schemaKey, context) {
64853
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
64854
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
64855
+ // to fetch the whole schema json.
64856
+ if (!await this.supportPartialSchemaLoading(context))
64857
+ return this.getSchemaProps(schemaKey);
64858
+ const start = Date.now();
64859
+ const schemaProps = this.options.useMultipleQueries
64860
+ ? await this.getFullSchemaMultipleQueries(schemaKey, context)
64861
+ : await this.getFullSchema(schemaKey, context);
64862
+ this.options.performanceLogger?.logSchema(start, schemaKey.name);
64863
+ return schemaProps;
64864
+ }
64865
+ ;
64866
+ /**
64867
+ * Gets the [[SchemaProps]] without schemaItems.
64868
+ */
64869
+ /**
64870
+ * Gets the [[SchemaProps]] without schemaItems for the given schema name.
64871
+ * @param schemaName The name of the Schema.
64872
+ * @param context The [[SchemaContext]] to use for resolving references.
64873
+ * @returns
64874
+ * @internal
64875
+ */
64876
+ async getSchemaNoItems(schemaName, context) {
64877
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });
64878
+ const schemaRow = schemaRows[0];
64879
+ if (schemaRow === undefined)
64880
+ return undefined;
64881
+ const schema = JSON.parse(schemaRow.schema);
64882
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
64883
+ }
64884
+ /**
64885
+ * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
64886
+ * @param context The schema context to lookup the meta schema.
64887
+ * @returns true if the context has a supported meta schema version, false otherwise.
64888
+ */
64889
+ async supportPartialSchemaLoading(context) {
64890
+ const metaSchemaKey = new _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey("ECDbMeta", 4, 0, 3);
64891
+ const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_0__.SchemaMatchType.LatestWriteCompatible);
64892
+ return metaSchemaInfo !== undefined;
64893
+ }
64894
+ ;
64895
+ /**
64896
+ * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.
64897
+ * @param schemaName The name of the Schema.
64898
+ * @param context The [[SchemaContext]] to which the schema belongs.
64899
+ * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
64900
+ * @internal
64901
+ */
64902
+ async getEntities(schema, context, queryOverride) {
64903
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.entityQuery;
64904
+ return this.querySchemaItem(context, schema, query, "EntityClass");
64905
+ }
64906
+ /**
64907
+ * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
64908
+ * @param schemaName The name of the Schema.
64909
+ * @param context The SchemaContext to which the schema belongs.
64910
+ * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
64911
+ * @internal
64912
+ */
64913
+ async getMixins(schema, context, queryOverride) {
64914
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.mixinQuery;
64915
+ return this.querySchemaItem(context, schema, query, "Mixin");
64916
+ }
64917
+ /**
64918
+ * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
64919
+ * @param schemaName The name of the Schema.
64920
+ * @param context The SchemaContext to which the schema belongs.
64921
+ * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
64922
+ * @internal
64923
+ */
64924
+ async getRelationships(schema, context, queryOverride) {
64925
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.relationshipClassQuery;
64926
+ return this.querySchemaItem(context, schema, query, "RelationshipClass");
64927
+ }
64928
+ /**
64929
+ * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
64930
+ * @param schemaName The name of the Schema.
64931
+ * @param context The SchemaContext to which the schema belongs.
64932
+ * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
64933
+ * @internal
64934
+ */
64935
+ async getCustomAttributeClasses(schema, context, queryOverride) {
64936
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.customAttributeQuery;
64937
+ return this.querySchemaItem(context, schema, query, "CustomAttributeClass");
64938
+ }
64939
+ /**
64940
+ * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
64941
+ * @param schemaName The name of the Schema.
64942
+ * @param context The SchemaContext to which the schema belongs.
64943
+ * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
64944
+ * @internal
64945
+ */
64946
+ async getStructs(schema, context, queryOverride) {
64947
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.structQuery;
64948
+ return this.querySchemaItem(context, schema, query, "StructClass");
64949
+ }
64950
+ /**
64951
+ * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
64952
+ * @param schema The name of the Schema.
64953
+ * @param context The SchemaContext to which the schema belongs.
64954
+ * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
64955
+ * @internal
64956
+ */
64957
+ async getKindOfQuantities(schema, context) {
64958
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.kindOfQuantity(true), "KindOfQuantity");
64959
+ }
64960
+ /**
64961
+ * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
64962
+ * @param schema The name of the Schema.
64963
+ * @param context The SchemaContext to which the schema belongs.
64964
+ * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
64965
+ * @internal
64966
+ */
64967
+ async getPropertyCategories(schema, context) {
64968
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.propertyCategory(true), "PropertyCategory");
64969
+ }
64970
+ /**
64971
+ * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
64972
+ * @param schema The name of the Schema.
64973
+ * @param context The SchemaContext to which the schema belongs.
64974
+ * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
64975
+ * @internal
64976
+ */
64977
+ async getEnumerations(schema, context) {
64978
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.enumeration(true), "Enumeration");
64979
+ }
64980
+ /**
64981
+ * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
64982
+ * @param schema The name of the Schema.
64983
+ * @param context The SchemaContext to which the schema belongs.
64984
+ * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
64985
+ * @internal
64986
+ */
64987
+ async getUnits(schema, context) {
64988
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unit(true), "Unit");
64989
+ }
64990
+ /**
64991
+ * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
64992
+ * @param schema The name of the Schema.
64993
+ * @param context The SchemaContext to which the schema belongs.
64994
+ * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
64995
+ * @internal
64996
+ */
64997
+ async getInvertedUnits(schema, context) {
64998
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.invertedUnit(true), "InvertedUnit");
64999
+ }
65000
+ /**
65001
+ * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
65002
+ * @param schema The name of the Schema.
65003
+ * @param context The SchemaContext to which the schema belongs.
65004
+ * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
65005
+ * @internal
65006
+ */
65007
+ async getConstants(schema, context) {
65008
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.constant(true), "Constant");
65009
+ }
65010
+ /**
65011
+ * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
65012
+ * @param schema The name of the Schema.
65013
+ * @param context The SchemaContext to which the schema belongs.
65014
+ * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
65015
+ * @internal
65016
+ */
65017
+ async getUnitSystems(schema, context) {
65018
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unitSystem(true), "UnitSystem");
65019
+ }
65020
+ /**
65021
+ * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
65022
+ * @param schema The name of the Schema.
65023
+ * @param context The SchemaContext to which the schema belongs.
65024
+ * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
65025
+ * @internal
65026
+ */
65027
+ async getPhenomenon(schema, context) {
65028
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.phenomenon(true), "Phenomenon");
65029
+ }
65030
+ /**
65031
+ * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
65032
+ * @param schema The name of the Schema.
65033
+ * @param context The SchemaContext to which the schema belongs.
65034
+ * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
65035
+ * @internal
65036
+ */
65037
+ async getFormats(schema, context) {
65038
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.format(true), "Format");
65039
+ }
65040
+ /**
65041
+ * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
65042
+ * @internal
65043
+ */
65044
+ async loadSchemaInfos() {
65045
+ const schemaRows = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaInfoQuery);
65046
+ return schemaRows.map((schemaRow) => ({
65047
+ alias: schemaRow.alias,
65048
+ schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),
65049
+ references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),
65050
+ }));
65051
+ }
65052
+ /**
65053
+ * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
65054
+ * can be included in the initial fetch.
65055
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
65056
+ * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
65057
+ * @internal
65058
+ */
65059
+ async getSchemaPartials(schemaKey, context) {
65060
+ const [schemaRow] = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaStubQuery, {
65061
+ parameters: { schemaName: schemaKey.name },
65062
+ limit: 1
65063
+ });
65064
+ if (!schemaRow)
65065
+ return undefined;
65066
+ const schemaPartials = [];
65067
+ const addSchema = async (key) => {
65068
+ const stub = await this.createSchemaProps(key, context);
65069
+ schemaPartials.push(stub);
65070
+ if (stub.references) {
65071
+ for (const referenceProps of stub.references) {
65072
+ if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {
65073
+ await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));
65074
+ }
65075
+ }
65076
+ }
65077
+ return stub;
65078
+ };
65079
+ const addItems = async (schemaName, itemInfo) => {
65080
+ let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);
65081
+ if (!schemaStub) {
65082
+ schemaStub = await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaName}.0.0.0`));
65083
+ }
65084
+ if (!schemaStub.items) {
65085
+ Object.assign(schemaStub, { items: {} });
65086
+ }
65087
+ const existingItem = schemaStub.items[itemInfo.name] || {};
65088
+ Object.assign(schemaStub.items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
65089
+ };
65090
+ const reviver = (_key, value) => {
65091
+ if (value === null) {
65092
+ return undefined;
65093
+ }
65094
+ return value;
65095
+ };
65096
+ await addSchema(schemaKey);
65097
+ await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);
65098
+ return schemaPartials;
65099
+ }
65100
+ async querySchemaItem(context, schemaName, query, schemaType) {
65101
+ const start = Date.now();
65102
+ const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
65103
+ this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);
65104
+ if (itemRows.length === 0)
65105
+ return [];
65106
+ const items = itemRows.map((itemRow) => {
65107
+ return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
65108
+ });
65109
+ return await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseSchemaItems(items, schemaName, context) ?? [];
65110
+ }
65111
+ async getFullSchema(schemaKey, context) {
65112
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
65113
+ const schemaRow = schemaRows[0];
65114
+ if (schemaRow === undefined)
65115
+ return undefined;
65116
+ // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.
65117
+ const schema = JSON.parse(schemaRow.schema);
65118
+ if (schema.items) {
65119
+ schema.items = schema.items.map((itemRow) => { return itemRow.item; });
65120
+ }
65121
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
65122
+ }
65123
+ async getFullSchemaMultipleQueries(schemaKey, context) {
65124
+ const schema = await this.getSchemaNoItems(schemaKey.name, context);
65125
+ if (!schema)
65126
+ return undefined;
65127
+ schema.items = {};
65128
+ await Promise.all([
65129
+ this.getEntities(schemaKey.name, context),
65130
+ this.getMixins(schemaKey.name, context),
65131
+ this.getStructs(schemaKey.name, context),
65132
+ this.getRelationships(schemaKey.name, context),
65133
+ this.getCustomAttributeClasses(schemaKey.name, context),
65134
+ this.getKindOfQuantities(schemaKey.name, context),
65135
+ this.getPropertyCategories(schemaKey.name, context),
65136
+ this.getEnumerations(schemaKey.name, context),
65137
+ this.getUnits(schemaKey.name, context),
65138
+ this.getInvertedUnits(schemaKey.name, context),
65139
+ this.getUnitSystems(schemaKey.name, context),
65140
+ this.getConstants(schemaKey.name, context),
65141
+ this.getPhenomenon(schemaKey.name, context),
65142
+ this.getFormats(schemaKey.name, context)
65143
+ ]).then((itemResults) => {
65144
+ const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));
65145
+ flatItemList.forEach((schemaItem) => {
65146
+ schema.items[schemaItem.name] = schemaItem;
65147
+ });
65148
+ });
65149
+ return schema;
65150
+ }
65151
+ }
65152
+ function parseSchemaReference(referenceName) {
65153
+ return { schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(referenceName) };
65154
+ }
65155
+ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandler) {
65156
+ if (!itemRows || itemRows.length === 0) {
65157
+ return;
65158
+ }
65159
+ const parseBaseClasses = async (baseClasses) => {
65160
+ if (!baseClasses || baseClasses.length < 2)
65161
+ return;
65162
+ for (let index = baseClasses.length - 1; index >= 0;) {
65163
+ const currentItem = baseClasses[index--];
65164
+ const baseClassItem = baseClasses[index];
65165
+ const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
65166
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(currentItem, currentItem.schema, context);
65167
+ await addItemsHandler(currentItem.schema, {
65168
+ ...schemaItem,
65169
+ name: schemaItem.name,
65170
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
65171
+ baseClass: baseClassName,
65172
+ });
65173
+ }
65174
+ };
65175
+ for (const itemRow of itemRows) {
65176
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(itemRow, schemaName, context);
65177
+ await addItemsHandler(schemaName, {
65178
+ ...schemaItem,
65179
+ name: schemaItem.name,
65180
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
65181
+ mixins: itemRow.mixins
65182
+ ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
65183
+ : undefined,
65184
+ });
65185
+ await parseBaseClasses(itemRow.baseClasses);
65186
+ for (const mixinRow of itemRow.mixins || []) {
65187
+ const mixinItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(mixinRow, mixinRow.schema, context);
65188
+ await addItemsHandler(mixinRow.schema, {
65189
+ ...mixinItem,
65190
+ name: mixinItem.name,
65191
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(mixinItem.schemaItemType),
65192
+ });
65193
+ await parseBaseClasses(mixinRow.baseClasses);
65194
+ }
65195
+ }
65196
+ }
65197
+
65198
+
65199
+ /***/ }),
65200
+
65201
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js":
65202
+ /*!************************************************************************************!*\
65203
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js ***!
65204
+ \************************************************************************************/
65205
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65206
+
65207
+ "use strict";
65208
+ __webpack_require__.r(__webpack_exports__);
65209
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65210
+ /* harmony export */ FullSchemaQueries: () => (/* binding */ FullSchemaQueries)
65211
+ /* harmony export */ });
65212
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
65213
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
65214
+ /*---------------------------------------------------------------------------------------------
65215
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
65216
+ * See LICENSE.md in the project root for license terms and full copyright notice.
65217
+ *--------------------------------------------------------------------------------------------*/
65218
+
65219
+
65220
+ /**
65221
+ * Queries that return full Schema JSON data are found here. Shared SELECTS and
65222
+ * WITH clauses are broken down into individual variables.
65223
+ */
65224
+ const propertyType = (alias) => {
65225
+ return `
65226
+ CASE
65227
+ WHEN [${alias}].[Kind] = 0 THEN 'PrimitiveProperty'
65228
+ WHEN [${alias}].[Kind] = 1 THEN 'StructProperty'
65229
+ WHEN [${alias}].[Kind] = 2 THEN 'PrimitiveArrayProperty'
65230
+ WHEN [${alias}].[Kind] = 3 THEN 'StructArrayProperty'
65231
+ WHEN [${alias}].[Kind] = 4 THEN 'NavigationProperty'
65232
+ ELSE NULL
65233
+ END
65234
+ `;
65235
+ };
65236
+ const navigationDirection = (alias) => {
65237
+ return `
65238
+ CASE
65239
+ WHEN [${alias}].[NavigationDirection] = 1 THEN 'Forward'
65240
+ WHEN [${alias}].[NavigationDirection] = 2 THEN 'Backward'
65241
+ ELSE NULL
65242
+ END
65243
+ `;
65244
+ };
65245
+ const schemaCustomAttribute = (alias) => {
65246
+ return `
65247
+ SELECT
65248
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65249
+ FROM [meta].[CustomAttribute] [ca]
65250
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 1
65251
+ ORDER BY [ca].[Ordinal]
65252
+ `;
65253
+ };
65254
+ /**
65255
+ * Selects customAttribute data for each class type.
65256
+ */
65257
+ const classCustomAttribute = (alias) => {
65258
+ return `
65259
+ SELECT
65260
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65261
+ FROM [meta].[CustomAttribute] [ca]
65262
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 30
65263
+ ORDER BY [ca].[Ordinal]
65264
+ `;
65265
+ };
65266
+ const propertyCustomAttribute = (alias) => {
65267
+ return `
65268
+ SELECT
65269
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65270
+ FROM [meta].[CustomAttribute] [ca]
65271
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 992
65272
+ ORDER BY [ca].[Ordinal]
65273
+ `;
65274
+ };
65275
+ /**
65276
+ * Selects base class data for each class type.
65277
+ */
65278
+ const selectBaseClasses = `
65279
+ SELECT
65280
+ ec_classname([baseClass].[ECInstanceId], 's.c')
65281
+ FROM
65282
+ [meta].[ECClassDef] [baseClass]
65283
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
65284
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
65285
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
65286
+ LIMIT 1
65287
+ `;
65288
+ /**
65289
+ * Selects class property data for each class type. ClassProperties
65290
+ * is a common table expression (CTE or WITH clause) defined below.
65291
+ */
65292
+ const selectProperties = `
65293
+ SELECT
65294
+ json_group_array(json([classProperties].[property]))
65295
+ FROM
65296
+ [ClassProperties] [classProperties]
65297
+ WHERE
65298
+ [classProperties].[ClassId] = [class].[ECInstanceId]
65299
+ `;
65300
+ /**
65301
+ * A CTE used to select AppliesTo from IsMixin CustomAttributes for a given Mixin.
65302
+ */
65303
+ const withAppliesTo = `
65304
+ AppliesToCTE AS (
65305
+ SELECT
65306
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
65307
+ [appliesToSchema].[name] as [AppliesToSchema],
65308
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
65309
+ FROM [meta].[CustomAttribute] [ca]
65310
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
65311
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
65312
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
65313
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
65314
+ WHERE [ca].[ContainerType] = 30
65315
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
65316
+ )
65317
+ `;
65318
+ /**
65319
+ * A CTE used to select Schema reference data for a given Schema.
65320
+ */
65321
+ const withSchemaReferences = `
65322
+ SchemaReferences as (
65323
+ SELECT
65324
+ [ref].[SourceECInstanceId] as [SchemaId],
65325
+ json_object(
65326
+ 'name', [Name],
65327
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor]))
65328
+ ) as [reference]
65329
+ FROM
65330
+ [meta].[ECSchemaDef] as [refSchema]
65331
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
65332
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
65333
+ )
65334
+ `;
65335
+ /**
65336
+ * A CTE used to select Relationship constraints for a given RelationshipClass.
65337
+ */
65338
+ const withRelationshipConstraints = `
65339
+ ClassRelationshipConstraints as (
65340
+ SELECT
65341
+ [rhc].[SourceECInstanceId] as [ClassId],
65342
+ [constraintDef].[ECInstanceId] as [ConstraintId],
65343
+ [RelationshipEnd],
65344
+ CONCAT('(', [MultiplicityLowerLimit], '..', IIF([MultiplicityUpperLimit] IS NULL, '*', [MultiplicityUpperLimit]), ')') as [Multiplicity],
65345
+ [IsPolyMorphic],
65346
+ [RoleLabel],
65347
+ IIF([constraintDef].[AbstractConstraintClass] IS NOT NULL, ec_classname([constraintDef].[AbstractConstraintClass].[Id], 's.c'), null) as [AbstractConstraint],
65348
+ IIF ([rchc].[TargetECInstanceId] IS NOT NULL, JSON_GROUP_ARRAY(ec_classname([rchc].[TargetECInstanceId], 's.c')), null) as [ConstraintClasses]
65349
+ FROM
65350
+ [meta].[ECRelationshipConstraintDef] [constraintDef]
65351
+ JOIN [meta].[RelationshipHasConstraints] [rhc]
65352
+ ON [rhc].[TargetECInstanceId] = [constraintDef].[ECInstanceId]
65353
+ JOIN [meta].[RelationshipConstraintHasClasses] [rchc]
65354
+ ON [rchc].[SourceECInstanceId] = [constraintDef].[ECInstanceId]
65355
+ GROUP BY [constraintDef].[ECInstanceId]
65356
+ )
65357
+ `;
65358
+ /**
65359
+ * A CTE used to select Class property data for a given Class.
65360
+ */
65361
+ const withClassProperties = `
65362
+ ClassProperties as (
65363
+ SELECT
65364
+ [cop].[SourceECInstanceId] as [ClassId],
65365
+ json_object(
65366
+ 'name', [pd].[Name],
65367
+ 'label', [pd].[DisplayLabel],
65368
+ 'description', [pd].[Description],
65369
+ 'isReadOnly', IIF([pd].[IsReadOnly] = 1, json('true'), NULL),
65370
+ 'priority', [pd].[Priority],
65371
+ 'category', IIF([categoryDef].[Name] IS NULL, NULL, CONCAT([categorySchemaDef].[Name], '.', [categoryDef].[Name])),
65372
+ 'kindOfQuantity', IIF([koqDef].[Name] IS NULL, NULL, CONCAT([koqSchemaDef].[Name], '.', [koqDef].[Name])),
65373
+ 'typeName',
65374
+ CASE
65375
+ WHEN [pd].[Kind] = 0 OR [pd].[Kind] = 2 Then
65376
+ CASE
65377
+ WHEN [enumDef].[Name] IS NOT NULL Then CONCAT([enumSchemaDef].[Name], '.', [enumDef].[Name])
65378
+ WHEN [pd].[PrimitiveType] = 257 Then 'binary'
65379
+ WHEN [pd].[PrimitiveType] = 513 Then 'boolean'
65380
+ WHEN [pd].[PrimitiveType] = 769 Then 'dateTime'
65381
+ WHEN [pd].[PrimitiveType] = 1025 Then 'double'
65382
+ WHEN [pd].[PrimitiveType] = 1281 Then 'int'
65383
+ WHEN [pd].[PrimitiveType] = 1537 Then 'long'
65384
+ WHEN [pd].[PrimitiveType] = 1793 Then 'point2d'
65385
+ WHEN [pd].[PrimitiveType] = 2049 Then 'point3d'
65386
+ WHEN [pd].[PrimitiveType] = 2305 Then 'string'
65387
+ WHEN [pd].[PrimitiveType] = 2561 Then 'Bentley.Geometry.Common.IGeometry'
65388
+ ELSE null
65389
+ END
65390
+ WHEN [pd].[Kind] = 1 OR [pd].[Kind] = 3 Then
65391
+ CONCAT([structSchemaDef].[Name], '.', [structDef].[Name])
65392
+ ELSE null
65393
+ END,
65394
+ 'type', ${propertyType("pd")},
65395
+ 'minLength', [pd].[PrimitiveTypeMinLength],
65396
+ 'maxLength', [pd].[PrimitiveTypeMaxLength],
65397
+ 'minValue', [pd].[PrimitiveTypeMinValue],
65398
+ 'maxValue', [pd].[PrimitiveTypeMaxValue],
65399
+ 'extendedTypeName', [pd].[ExtendedTypeName],
65400
+ 'minOccurs', [pd].[ArrayMinOccurs],
65401
+ 'maxOccurs', [pd].[ArrayMaxOccurs],
65402
+ 'direction', ${navigationDirection("pd")},
65403
+ 'relationshipName', IIF([navRelDef].[Name] IS NULL, NULL, CONCAT([navSchemaDef].[Name], '.', [navRelDef].[Name])),
65404
+ 'customAttributes', (${propertyCustomAttribute("pd")})
65405
+ ) as [property]
65406
+ FROM
65407
+ [meta].[ECPropertyDef] as [pd]
65408
+ JOIN [meta].[ClassOwnsLocalProperties] [cop]
65409
+ ON cop.[TargetECInstanceId] = [pd].[ECInstanceId]
65410
+ LEFT JOIN [meta].[ECEnumerationDef] [enumDef]
65411
+ ON [enumDef].[ECInstanceId] = [pd].[Enumeration].[Id]
65412
+ LEFT JOIN [meta].[ECSchemaDef] enumSchemaDef
65413
+ ON [enumSchemaDef].[ECInstanceId] = [enumDef].[Schema].[Id]
65414
+ LEFT JOIN [meta].[PropertyCategoryDef] [categoryDef]
65415
+ ON [categoryDef].[ECInstanceId] = [pd].[Category].[Id]
65416
+ LEFT JOIN [meta].[ECSchemaDef] [categorySchemaDef]
65417
+ ON [categorySchemaDef].[ECInstanceId] = [categoryDef].[Schema].[Id]
65418
+ LEFT JOIN [meta].[KindOfQuantityDef] [koqDef]
65419
+ ON [koqDef].[ECInstanceId] = [pd].[KindOfQuantity].[Id]
65420
+ LEFT JOIN [meta].[ECSchemaDef] [koqSchemaDef]
65421
+ ON [koqSchemaDef].[ECInstanceId] = [koqDef].[Schema].[Id]
65422
+ LEFT JOIN [meta].[ECClassDef] [structDef]
65423
+ ON structDef.[ECInstanceId] = [pd].[StructClass].[Id]
65424
+ LEFT JOIN [meta].[ECSchemaDef] [structSchemaDef]
65425
+ ON [structSchemaDef].[ECInstanceId] = [structDef].[Schema].[Id]
65426
+ LEFT JOIN [meta].[ECClassDef] [navRelDef]
65427
+ ON [navRelDef].[ECInstanceId] = [pd].[NavigationRelationshipClass].[Id]
65428
+ LEFT JOIN [meta].[ECSchemaDef] [navSchemaDef]
65429
+ ON [navSchemaDef].[ECInstanceId] = [navRelDef].[Schema].[Id]
65430
+ )
65431
+ `;
65432
+ /**
65433
+ * Query that provides EntityClass data and is shared by two cases:
65434
+ * 1. A single query to return a full schema.
65435
+ * 2. When querying a full schema with multiple schema item queries or
65436
+ * when just querying for Entity classes.
65437
+ */
65438
+ const baseEntityQuery = `
65439
+ SELECT
65440
+ [sd].[Name] as [schema],
65441
+ json_object (
65442
+ 'schemaItemType', 'EntityClass',
65443
+ 'name', [class].[Name],
65444
+ 'label', [class].[DisplayLabel],
65445
+ 'description', [class].[Description],
65446
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
65447
+ 'baseClass', (
65448
+ ${selectBaseClasses}
65449
+ ),
65450
+ 'mixins', (
65451
+ SELECT
65452
+ json_group_array(
65453
+ ec_classname([baseClass].[ECInstanceId], 's.c')
65454
+ )
65455
+ FROM
65456
+ [meta].[ECClassDef] [baseClass]
65457
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
65458
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
65459
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
65460
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
65461
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
65462
+ ),
65463
+ 'customAttributes', (${classCustomAttribute("class")}),
65464
+ 'properties', (
65465
+ ${selectProperties}
65466
+ )
65467
+ ) AS [item]
65468
+ FROM [meta].[ECClassDef] [class]
65469
+ JOIN
65470
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
65471
+ WHERE [class].[Type] = 0 AND
65472
+ [sd].[Name] = :schemaName
65473
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
65474
+ AND [ca].[CustomAttributeClass].Id Is ([CoreCA].[IsMixin]))
65475
+ `;
65476
+ /**
65477
+ * EntityClass query used to when querying for EntityClass data only. Not used
65478
+ * for full Schema load via single query.
65479
+ */
65480
+ const entityQuery = `
65481
+ WITH
65482
+ ${withClassProperties}
65483
+ ${baseEntityQuery}
65484
+ `;
65485
+ /**
65486
+ * Query that provides Mixin data and is shared by two cases:
65487
+ * 1. A single query to return a full schema.
65488
+ * 2. When querying a full schema with multiple schema item queries or
65489
+ * when just querying for Mixin classes.
65490
+ */
65491
+ const baseMixinQuery = `
65492
+ SELECT
65493
+ [sd].[Name] as [schema],
65494
+ json_object (
65495
+ 'schemaItemType', 'Mixin',
65496
+ 'name', [class].[Name],
65497
+ 'label', [class].[DisplayLabel],
65498
+ 'description', [class].[Description],
65499
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
65500
+ 'baseClass', (
65501
+ ${selectBaseClasses}
65502
+ ),
65503
+ 'appliesTo', (
65504
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
65505
+ FROM [AppliesToCTE] [atCTE]
65506
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
65507
+ ),
65508
+ 'customAttributes', (
65509
+ SELECT
65510
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65511
+ FROM [meta].[CustomAttribute] [ca]
65512
+ WHERE [ca].[ContainerId] = [class].[ECInstanceId] AND [ca].[ContainerType] = 30
65513
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') <> 'IsMixin'
65514
+ ),
65515
+ 'properties', (
65516
+ SELECT
65517
+ json_group_array(json([classProperties].[property]))
65518
+ FROM
65519
+ [ClassProperties] [classProperties]
65520
+ WHERE
65521
+ [classProperties].[ClassId] = [class].[ECInstanceId]
65522
+ )
65523
+ ) AS [item]
65524
+ FROM [meta].[ECClassDef] [class]
65525
+ JOIN
65526
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
65527
+ WHERE [class].[Type] = 0 AND
65528
+ [sd].[Name] = :schemaName
65529
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
65530
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
65531
+ `;
65532
+ /**
65533
+ * Mixin query used to when querying for Mixin data only. Not used
65534
+ * for full Schema load via single query.
65535
+ */
65536
+ const mixinQuery = `
65537
+ WITH
65538
+ ${withAppliesTo},
65539
+ ${withClassProperties}
65540
+ ${baseMixinQuery}
65541
+ `;
65542
+ /**
65543
+ * Query that provides RelationshipClass data and is shared by two cases:
65544
+ * 1. A single query to return a full schema.
65545
+ * 2. When querying a full schema with multiple schema item queries or
65546
+ * when just querying for Relationship classes.
65547
+ */
65548
+ const baseRelationshipClassQuery = `
65549
+ SELECT
65550
+ [sd].Name as schema,
65551
+ json_object (
65552
+ 'schemaItemType', 'RelationshipClass',
65553
+ 'name', [class].[Name],
65554
+ 'label', [class].[DisplayLabel],
65555
+ 'description', [class].[Description],
65556
+ 'strength', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strength)("class")},
65557
+ 'strengthDirection', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strengthDirection)("class")},
65558
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
65559
+ 'baseClass', (
65560
+ ${selectBaseClasses}
65561
+ ),
65562
+ 'customAttributes', (${classCustomAttribute("class")}),
65563
+ 'properties', (
65564
+ ${selectProperties}
65565
+ ),
65566
+ 'source', (
65567
+ SELECT
65568
+ json_object (
65569
+ 'multiplicity', [sourceConst].[Multiplicity],
65570
+ 'roleLabel', [sourceConst].[RoleLabel],
65571
+ 'polymorphic', IIF([sourceConst].[IsPolyMorphic] = 1, json('true'), json('false')),
65572
+ 'abstractConstraint', [sourceConst].[AbstractConstraint],
65573
+ 'constraintClasses', json([sourceConst].[ConstraintClasses]),
65574
+ 'customAttributes', (
65575
+ SELECT
65576
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65577
+ FROM [meta].[CustomAttribute] [ca]
65578
+ WHERE [ca].[ContainerId] = [sourceConst].[ConstraintId] AND [ca].[ContainerType] = 1024
65579
+ ORDER BY [ca].[Ordinal]
65580
+ )
65581
+ )
65582
+ FROM
65583
+ [ClassRelationshipConstraints] [sourceConst]
65584
+ WHERE [sourceConst].[relationshipEnd] = 0
65585
+ AND [sourceConst].[ClassId] = [class].[ECInstanceId]
65586
+ ),
65587
+ 'target', (
65588
+ SELECT
65589
+ json_object (
65590
+ 'multiplicity', [targetConst].[Multiplicity],
65591
+ 'roleLabel', [targetConst].[RoleLabel],
65592
+ 'polymorphic', IIF([targetConst].[IsPolyMorphic] = 1, json('true'), json('false')),
65593
+ 'abstractConstraint', [targetConst].[AbstractConstraint],
65594
+ 'constraintClasses', json([targetConst].[ConstraintClasses]),
65595
+ 'customAttributes', (
65596
+ SELECT
65597
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
65598
+ FROM [meta].[CustomAttribute] [ca]
65599
+ WHERE [ca].[ContainerId] = [targetConst].[ConstraintId] AND [ca].[ContainerType] = 2048
65600
+ ORDER BY [ca].[Ordinal]
65601
+ )
65602
+ )
65603
+ FROM
65604
+ [ClassRelationshipConstraints] [targetConst]
65605
+ WHERE [targetConst].[relationshipEnd] = 1
65606
+ AND [targetConst].[ClassId] = [class].[ECInstanceId]
65607
+ )
65608
+ ) AS [item]
65609
+ FROM [meta].[ECClassDef] [class]
65610
+ JOIN
65611
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
65612
+ WHERE [class].[Type] = 1 AND
65613
+ [sd].[Name] = :schemaName
65614
+ `;
65615
+ /**
65616
+ * RelationshipClass query used to when querying for RelationshipClass data only. Not used
65617
+ * for full Schema load via single query.
65618
+ */
65619
+ const relationshipClassQuery = `
65620
+ WITH
65621
+ ${withClassProperties},
65622
+ ${withRelationshipConstraints}
65623
+ ${baseRelationshipClassQuery}
65624
+ `;
65625
+ /**
65626
+ * Query that provides StructClass data and is shared by two cases:
65627
+ * 1. A single query to return a full schema.
65628
+ * 2. When querying a full schema with multiple schema item queries or
65629
+ * when just querying for Struct classes.
65630
+ */
65631
+ const baseStructQuery = `
65632
+ SELECT
65633
+ [sd].Name as schema,
65634
+ json_object (
65635
+ 'schemaItemType', 'StructClass',
65636
+ 'name', [class].[Name],
65637
+ 'label', [class].[DisplayLabel],
65638
+ 'description', [class].[Description],
65639
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
65640
+ 'baseClass', (
65641
+ ${selectBaseClasses}
65642
+ ),
65643
+ 'customAttributes', (${classCustomAttribute("class")}),
65644
+ 'properties', (
65645
+ ${selectProperties}
65646
+ )
65647
+ ) AS item
65648
+ FROM [meta].[ECClassDef] [class]
65649
+ JOIN
65650
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
65651
+ WHERE [class].[Type] = 2 AND
65652
+ [sd].[Name] = :schemaName
65653
+ `;
65654
+ /**
65655
+ * StructClass query used to when querying for StructClass data only. Not used
65656
+ * for full Schema load via single query.
65657
+ */
65658
+ const structQuery = `
65659
+ WITH
65660
+ ${withClassProperties}
65661
+ ${baseStructQuery}
65662
+ `;
65663
+ /**
65664
+ * Query that provides CustomAttributeClass data and is shared by two cases:
65665
+ * 1. A single query to return a full schema.
65666
+ * 2. When querying a full schema with multiple schema item queries or
65667
+ * when just querying for CustomAttribute classes.
65668
+ */
65669
+ const baseCustomAttributeQuery = `
65670
+ SELECT
65671
+ [sd].Name as schema,
65672
+ json_object (
65673
+ 'schemaItemType', 'CustomAttributeClass',
65674
+ 'name', [class].[Name],
65675
+ 'label', [class].[DisplayLabel],
65676
+ 'description', [class].[Description],
65677
+ 'appliesTo', [class].[CustomAttributeContainerType],
65678
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
65679
+ 'baseClass', (
65680
+ ${selectBaseClasses}
65681
+ ),
65682
+ 'customAttributes', (${classCustomAttribute("class")}),
65683
+ 'properties', (
65684
+ ${selectProperties}
65685
+ )
65686
+ ) AS [item]
65687
+ FROM [meta].[ECClassDef] [class]
65688
+ JOIN
65689
+ [meta].[ECSchemaDef] sd ON [sd].[ECInstanceId] = [class].[Schema].[Id]
65690
+ WHERE [class].[Type] = 3 AND
65691
+ [sd].[Name] = :schemaName
65692
+ `;
65693
+ /**
65694
+ * CustomAttributeClass query used to when querying for CustomAttributeClass data only. Not used
65695
+ * for full Schema load via single query.
65696
+ */
65697
+ const customAttributeQuery = `
65698
+ WITH
65699
+ ${withClassProperties}
65700
+ ${baseCustomAttributeQuery}
65701
+ `;
65702
+ /**
65703
+ * Used by full schema load query via single query. Allows
65704
+ * all SchemaItemTypes to be queried at once.
65705
+ */
65706
+ const withSchemaItems = `
65707
+ SchemaItems AS (
65708
+ ${baseEntityQuery}
65709
+ UNION ALL
65710
+ ${baseRelationshipClassQuery}
65711
+ UNION ALL
65712
+ ${baseStructQuery}
65713
+ UNION ALL
65714
+ ${baseMixinQuery}
65715
+ UNION ALL
65716
+ ${baseCustomAttributeQuery}
65717
+ UNION ALL
65718
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity(true)}
65719
+ UNION ALL
65720
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration(true)}
65721
+ UNION ALL
65722
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory(true)}
65723
+ UNION ALL
65724
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit(true)}
65725
+ UNION ALL
65726
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit(true)}
65727
+ UNION ALL
65728
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem(true)}
65729
+ UNION ALL
65730
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant(true)}
65731
+ UNION ALL
65732
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon(true)}
65733
+ UNION ALL
65734
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format(true)}
65735
+ )
65736
+ `;
65737
+ /**
65738
+ * Query for Schema data without SchemaItems
65739
+ */
65740
+ const schemaNoItemsQuery = `
65741
+ WITH
65742
+ ${withSchemaReferences}
65743
+ SELECT
65744
+ json_object (
65745
+ 'name', [schemaDef].[Name],
65746
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
65747
+ 'alias', [schemaDef].[Alias],
65748
+ 'label', [schemaDef].[DisplayLabel],
65749
+ 'description', [schemaDef].[Description],
65750
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
65751
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
65752
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
65753
+ 'references', (
65754
+ SELECT
65755
+ json_group_array(json([schemaReferences].[reference]))
65756
+ FROM
65757
+ [SchemaReferences] [schemaReferences]
65758
+ WHERE
65759
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
65760
+ )
65761
+ ) as [schema]
65762
+ FROM
65763
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
65764
+ `;
65765
+ /**
65766
+ * Query to load a full Schema via a single query.
65767
+ */
65768
+ const schemaQuery = `
65769
+ WITH
65770
+ ${withAppliesTo},
65771
+ ${withSchemaReferences},
65772
+ ${withClassProperties},
65773
+ ${withRelationshipConstraints},
65774
+ ${withSchemaItems}
65775
+ SELECT
65776
+ json_object (
65777
+ 'name', [schemaDef].[Name],
65778
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
65779
+ 'alias', [schemaDef].[Alias],
65780
+ 'label', [schemaDef].[DisplayLabel],
65781
+ 'description', [schemaDef].[Description],
65782
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
65783
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
65784
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
65785
+ 'references', (
65786
+ SELECT
65787
+ json_group_array(json([schemaReferences].[reference]))
65788
+ FROM
65789
+ [SchemaReferences] [schemaReferences]
65790
+ WHERE
65791
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
65792
+ ),
65793
+ 'items', (
65794
+ SELECT
65795
+ json_group_array(json(json_object(
65796
+ 'item', json([items].[item])
65797
+ )))
65798
+ FROM
65799
+ [SchemaItems] [items]
65800
+ )
65801
+ ) as [schema]
65802
+ FROM
65803
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
65804
+ `;
65805
+ /**
65806
+ * Queries for loading full Schema JSON.
65807
+ * @internal
65808
+ */
65809
+ // eslint-disable-next-line @typescript-eslint/naming-convention
65810
+ const FullSchemaQueries = {
65811
+ schemaQuery,
65812
+ schemaNoItemsQuery,
65813
+ entityQuery,
65814
+ relationshipClassQuery,
65815
+ mixinQuery,
65816
+ structQuery,
65817
+ customAttributeQuery
65818
+ };
65819
+
65820
+
65821
+ /***/ }),
65822
+
65823
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js":
65824
+ /*!*******************************************************************************************!*\
65825
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js ***!
65826
+ \*******************************************************************************************/
65827
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65828
+
65829
+ "use strict";
65830
+ __webpack_require__.r(__webpack_exports__);
65831
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
65832
+ /* harmony export */ IncrementalSchemaLocater: () => (/* binding */ IncrementalSchemaLocater)
65833
+ /* harmony export */ });
65834
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
65835
+ /* harmony import */ var _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/SchemaGraphUtil */ "../../core/ecschema-metadata/lib/esm/Deserialization/SchemaGraphUtil.js");
65836
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
65837
+ /* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Exception */ "../../core/ecschema-metadata/lib/esm/Exception.js");
65838
+ /* harmony import */ var _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/Schema */ "../../core/ecschema-metadata/lib/esm/Metadata/Schema.js");
65839
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
65840
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
65841
+ /* harmony import */ var _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./IncrementalSchemaReader */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js");
65842
+ /*---------------------------------------------------------------------------------------------
65843
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
65844
+ * See LICENSE.md in the project root for license terms and full copyright notice.
65845
+ *--------------------------------------------------------------------------------------------*/
65846
+
65847
+
65848
+
65849
+
65850
+
65851
+
65852
+
65853
+
65854
+ /**
65855
+ * A [[ISchemaLocater]] implementation for locating and retrieving EC [[Schema]]
65856
+ * objects incrementally instead of the full schema and it's references at once. This is useful for large schemas that
65857
+ * take a long time to load, but clients need a rough skeleton of the schema as fast as possible.
65858
+ *
65859
+ * The IncrementalSchemaLocater is a locater around the [[IncrementalSchemaLocater]] to be used in a
65860
+ * [[SchemaContext]].
65861
+ * @internal
65862
+ */
65863
+ class IncrementalSchemaLocater {
65864
+ _options;
65865
+ _schemaInfoCache;
65866
+ /**
65867
+ * Initializes a new instance of the IncrementalSchemaLocater class.
65868
+ * @param options The [[SchemaLocaterOptions]] that control the loading of the schema.
65869
+ */
65870
+ constructor(options) {
65871
+ this._options = options || {};
65872
+ this._schemaInfoCache = new SchemaInfoCache(async (context) => {
65873
+ return this.loadSchemaInfos(context);
65874
+ });
65875
+ }
65876
+ /** Gets the options how the schema locater load the schemas. */
65877
+ get options() {
65878
+ return this._options;
65879
+ }
65880
+ /**
65881
+ * Gets the [[SchemaInfo]] which matches the provided SchemaKey. The SchemaInfo may be returned
65882
+ * before the schema is fully loaded. May return the entire Schema so long as it is completely loaded as it satisfies
65883
+ * the SchemaInfo interface.
65884
+ * @param schemaKey The [[SchemaKey]] to look up.
65885
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
65886
+ * @param context The [[SchemaContext]] for loading schema references.
65887
+ */
65888
+ async getSchemaInfo(schemaKey, matchType, context) {
65889
+ return this._schemaInfoCache.lookup(schemaKey, matchType, context);
65890
+ }
65891
+ /**
65892
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
65893
+ * For schemas that may have references, construct and call through a SchemaContext instead.
65894
+ * @param schemaKey The [[SchemaKey]] to look up.
65895
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
65896
+ * @param context The [[SchemaContext]] for loading schema references.
65897
+ */
65898
+ async getSchema(schemaKey, matchType, context) {
65899
+ const schemaInfo = await this.getSchemaInfo(schemaKey, matchType, context);
65900
+ return schemaInfo
65901
+ ? this.loadSchema(schemaInfo, context)
65902
+ : undefined;
65903
+ }
65904
+ /**
65905
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
65906
+ * For schemas that may have references, construct and call through a SchemaContext instead.
65907
+ * NOT IMPLEMENTED IN THIS LOCATER - ALWAYS RETURNS UNDEFINED.
65908
+ * @param schemaKey The [[SchemaKey]] to look up.
65909
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
65910
+ * @param context The [[SchemaContext]] for loading schema references.
65911
+ * @returns Incremental schema loading does not work synchronously, this will always return undefined.
65912
+ */
65913
+ getSchemaSync(_schemaKey, _matchType, _context) {
65914
+ return undefined;
65915
+ }
65916
+ /**
65917
+ * Start loading the schema for the given schema info incrementally. The schema is returned
65918
+ * as soon as the schema stub is loaded while the schema fully resolves in the background. It should
65919
+ * only be called by the IncrementalSchemaLocater if a schema has not been loaded or started to
65920
+ * load yet.
65921
+ * @param schemaInfo The schema info of the schema to load.
65922
+ * @param schemaContext The schema context to load the schema into.
65923
+ */
65924
+ async loadSchema(schemaInfo, schemaContext) {
65925
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
65926
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
65927
+ // to fetch the whole schema json.
65928
+ if (!await this.supportPartialSchemaLoading(schemaContext)) {
65929
+ const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);
65930
+ return _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema.fromJson(schemaJson, schemaContext);
65931
+ }
65932
+ // Fetches the schema partials for the given schema key. The first item in the array is the
65933
+ // actual schema props of the schema to load, the following items are schema props of referenced
65934
+ // schema items that are needed to resolve the schema properly.
65935
+ const schemaPartials = await this.getSchemaPartials(schemaInfo.schemaKey, schemaContext);
65936
+ if (schemaPartials === undefined)
65937
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_3__.ECSchemaStatus.UnableToLocateSchema, `Could not locate the schema, ${schemaInfo.schemaKey.name}.${schemaInfo.schemaKey.version.toString()}`);
65938
+ // Sort the partials in dependency order to ensure referenced schemas exist in the schema context
65939
+ // when they get requested. Otherwise the context would call this method again and for referenced
65940
+ // schemas, we would not want to request the whole schema props.
65941
+ const sortedPartials = await this.sortSchemaPartials(schemaPartials, schemaContext);
65942
+ for (const schemaProps of sortedPartials) {
65943
+ await this.startLoadingPartialSchema(schemaProps, schemaContext);
65944
+ }
65945
+ const schema = await schemaContext.getCachedSchema(schemaInfo.schemaKey);
65946
+ if (!schema)
65947
+ throw new Error(`Schema ${schemaInfo.schemaKey.name} could not be found.`);
65948
+ return schema;
65949
+ }
65950
+ /**
65951
+ * Creates a SchemaProps object by loading the Schema information from the given SchemaContext.
65952
+ * @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.
65953
+ * @param schemaContext The SchemaContext holding the Schema.
65954
+ * @returns The SchemaProps object.
65955
+ */
65956
+ async createSchemaProps(schemaKey, schemaContext) {
65957
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
65958
+ if (!schemaInfo)
65959
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
65960
+ const schemaProps = {
65961
+ $schema: _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
65962
+ name: schemaKey.name,
65963
+ alias: schemaInfo.alias,
65964
+ version: schemaInfo.schemaKey.version.toString(),
65965
+ references: [],
65966
+ items: {}
65967
+ };
65968
+ if (!schemaProps.references)
65969
+ throw new Error(`Schema references is undefined for the Schema ${schemaInfo.schemaKey.name}`);
65970
+ schemaInfo.references.forEach((ref) => {
65971
+ schemaProps.references.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });
65972
+ });
65973
+ return schemaProps;
65974
+ }
65975
+ async startLoadingPartialSchema(schemaProps, schemaContext) {
65976
+ if (schemaContext.schemaExists(_SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`))) {
65977
+ return;
65978
+ }
65979
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__.SchemaLoadingController();
65980
+ const schemaReader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schemaContext, true);
65981
+ const schema = new _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema(schemaContext);
65982
+ schema.setLoadingController(controller);
65983
+ await schemaReader.readSchema(schema, schemaProps);
65984
+ if (!this._options.loadPartialSchemaOnly)
65985
+ controller.start(this.startLoadingFullSchema(schema));
65986
+ }
65987
+ async loadFullSchema(schema) {
65988
+ const fullSchemaProps = await this.getSchemaJson(schema.schemaKey, schema.context);
65989
+ const reader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schema.context, false);
65990
+ await reader.readSchema(schema, fullSchemaProps, false);
65991
+ }
65992
+ async startLoadingFullSchema(schema) {
65993
+ if (!schema.loadingController)
65994
+ return;
65995
+ // If the schema is already resolved, return it directly.
65996
+ if (schema.loadingController.isComplete || schema.loadingController.inProgress) {
65997
+ return;
65998
+ }
65999
+ // Since the schema relies on it's references, they get triggered to be resolved
66000
+ // first by recursively calling this method. After all references has been resolved
66001
+ // the schema itself gets resolved.
66002
+ await Promise.all(schema.references.map(async (referenceSchema) => {
66003
+ if (referenceSchema.loadingController && referenceSchema.loadingController.inProgress)
66004
+ return referenceSchema.loadingController.wait();
66005
+ else
66006
+ return this.startLoadingFullSchema(referenceSchema);
66007
+ }));
66008
+ return this.loadFullSchema(schema);
66009
+ }
66010
+ async sortSchemaPartials(schemaPartials, schemaContext) {
66011
+ const schemaInfos = [];
66012
+ for (const schemaProps of schemaPartials) {
66013
+ const schemaKey = _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`);
66014
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
66015
+ if (!schemaInfo)
66016
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
66017
+ schemaInfos.push({ ...schemaInfo, props: schemaProps });
66018
+ }
66019
+ const orderedSchemaInfos = _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__.SchemaGraphUtil.buildDependencyOrderedSchemaInfoList(schemaInfos);
66020
+ return orderedSchemaInfos.map((schemaInfo) => schemaInfo.props);
66021
+ }
66022
+ }
66023
+ /**
66024
+ * Helper class to manage schema infos for a schema context.
66025
+ */
66026
+ class SchemaInfoCache {
66027
+ _schemaInfoCache;
66028
+ _schemaInfoLoader;
66029
+ constructor(schemaInfoLoader) {
66030
+ this._schemaInfoCache = new WeakMap();
66031
+ this._schemaInfoLoader = schemaInfoLoader;
66032
+ }
66033
+ async getSchemasByContext(context) {
66034
+ if (!this._schemaInfoCache.has(context)) {
66035
+ const schemaInfos = await this._schemaInfoLoader(context);
66036
+ this._schemaInfoCache.set(context, Array.from(schemaInfos));
66037
+ }
66038
+ return this._schemaInfoCache.get(context);
66039
+ }
66040
+ async lookup(schemaKey, matchType, context) {
66041
+ const contextSchemaInfos = await this.getSchemasByContext(context);
66042
+ return contextSchemaInfos
66043
+ ? contextSchemaInfos.find((schemaInfo) => schemaInfo.schemaKey.matches(schemaKey, matchType))
66044
+ : undefined;
66045
+ }
66046
+ remove(schemaKey, context) {
66047
+ const contextSchemaInfos = this._schemaInfoCache.get(context);
66048
+ if (!contextSchemaInfos)
66049
+ return;
66050
+ const index = contextSchemaInfos.findIndex((schemaInfo) => schemaInfo.schemaKey.name === schemaKey.name);
66051
+ if (index !== -1) {
66052
+ contextSchemaInfos.splice(index, 1);
66053
+ }
66054
+ }
66055
+ }
66056
+
66057
+
66058
+ /***/ }),
66059
+
66060
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js":
66061
+ /*!******************************************************************************************!*\
66062
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js ***!
66063
+ \******************************************************************************************/
66064
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66065
+
66066
+ "use strict";
66067
+ __webpack_require__.r(__webpack_exports__);
66068
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66069
+ /* harmony export */ IncrementalSchemaReader: () => (/* binding */ IncrementalSchemaReader)
66070
+ /* harmony export */ });
66071
+ /* harmony import */ var _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Deserialization/Helper */ "../../core/ecschema-metadata/lib/esm/Deserialization/Helper.js");
66072
+ /* harmony import */ var _Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/JsonParser */ "../../core/ecschema-metadata/lib/esm/Deserialization/JsonParser.js");
66073
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
66074
+ /* harmony import */ var _Metadata_Class__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Metadata/Class */ "../../core/ecschema-metadata/lib/esm/Metadata/Class.js");
66075
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
66076
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
66077
+
66078
+
66079
+
66080
+
66081
+
66082
+
66083
+ /**
66084
+ * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]
66085
+ * but overrides a few methods to support the incremental schema loading case.
66086
+ * @internal
66087
+ */
66088
+ class IncrementalSchemaReader extends _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__.SchemaReadHelper {
66089
+ _incremental;
66090
+ /**
66091
+ * Initializes a new [[IncrementalSchemaReader]] instance.
66092
+ * @param schemaContext The [[SchemaContext]] used to load the schemas.
66093
+ * @param incremental Indicates that the Schema should be read incrementally.
66094
+ * Pass false to load the full schema without an incremental/partial load.
66095
+ */
66096
+ constructor(schemaContext, incremental) {
66097
+ super(_Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__.JsonParser, schemaContext);
66098
+ this._incremental = incremental;
66099
+ }
66100
+ /**
66101
+ * Indicates that a given [[SchemaItem]] has been fully loaded.
66102
+ * @param schemaItem The SchemaItem to check.
66103
+ * @returns True if the item has been loaded, false if still in progress.
66104
+ */
66105
+ isSchemaItemLoaded(schemaItem) {
66106
+ return schemaItem !== undefined
66107
+ && schemaItem.loadingController !== undefined
66108
+ && schemaItem.loadingController.isComplete;
66109
+ }
66110
+ /**
66111
+ * Starts loading the [[SchemaItem]] identified by the given name and itemType.
66112
+ * @param schema The [[Schema]] that contains the SchemaItem.
66113
+ * @param name The name of the SchemaItem to load.
66114
+ * @param itemType The SchemaItem type name of the item to load.
66115
+ * @param schemaItemObject The object accepting the SchemaItem data.
66116
+ * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.
66117
+ */
66118
+ async loadSchemaItem(schema, name, itemType, schemaItemObject) {
66119
+ const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);
66120
+ // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.
66121
+ // The fromJSON method of the actual class instances may complain about missing properties in the props, so
66122
+ // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.
66123
+ if (this._incremental && schemaItemObject && schemaItem) {
66124
+ if (schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity) {
66125
+ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__.SchemaItem.prototype.fromJSONSync.call(schemaItem, schemaItemObject);
66126
+ }
66127
+ else {
66128
+ schemaItem.fromJSONSync(schemaItemObject);
66129
+ }
66130
+ }
66131
+ this.schemaItemLoading(schemaItem);
66132
+ return schemaItem;
66133
+ }
66134
+ schemaItemLoading(schemaItem) {
66135
+ if (schemaItem === undefined)
66136
+ return;
66137
+ if (schemaItem.loadingController === undefined) {
66138
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__.SchemaLoadingController();
66139
+ schemaItem.setLoadingController(controller);
66140
+ }
66141
+ if (_Metadata_Class__WEBPACK_IMPORTED_MODULE_3__.ECClass.isECClass(schemaItem)
66142
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity
66143
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.Format)
66144
+ schemaItem.loadingController.isComplete = !this._incremental;
66145
+ else
66146
+ schemaItem.loadingController.isComplete = true;
66147
+ }
66148
+ }
66149
+
66150
+
66151
+ /***/ }),
66152
+
66153
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js":
66154
+ /*!************************************************************************************!*\
66155
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js ***!
66156
+ \************************************************************************************/
66157
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66158
+
66159
+ "use strict";
66160
+ __webpack_require__.r(__webpack_exports__);
66161
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66162
+ /* harmony export */ KindOfQuantityParser: () => (/* binding */ KindOfQuantityParser),
66163
+ /* harmony export */ SchemaItemParser: () => (/* binding */ SchemaItemParser)
66164
+ /* harmony export */ });
66165
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
66166
+ /* harmony import */ var _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/OverrideFormat */ "../../core/ecschema-metadata/lib/esm/Metadata/OverrideFormat.js");
66167
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
66168
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
66169
+ /*---------------------------------------------------------------------------------------------
66170
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
66171
+ * See LICENSE.md in the project root for license terms and full copyright notice.
66172
+ *--------------------------------------------------------------------------------------------*/
66173
+
66174
+
66175
+
66176
+
66177
+ /**
66178
+ * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.
66179
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb
66180
+ * is in a different format than is required for a SchemaItemProps JSON object.
66181
+ * @internal
66182
+ */
66183
+ class SchemaItemParser {
66184
+ _schema;
66185
+ _context;
66186
+ /**
66187
+ * Initializes a new SchemaItemParser.
66188
+ * @param schemaName The name the Schema containing the SchemaItems.
66189
+ * @param context The SchemaContext containing the Schema.
66190
+ */
66191
+ constructor(schemaName, context) {
66192
+ this._schema = schemaName;
66193
+ this._context = context;
66194
+ }
66195
+ /**
66196
+ * Parses the given SchemaItemProps JSON returned from an ECSql query.
66197
+ * @param data The SchemaItemProps JSON as returned from an iModelDb.
66198
+ * @returns The corrected SchemaItemProps Json.
66199
+ */
66200
+ async parse(data) {
66201
+ const props = data;
66202
+ props.schemaItemType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(data.schemaItemType);
66203
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_3__.parseCustomAttribute)(attr); }) : undefined;
66204
+ if (!props.customAttributes || props.customAttributes.length === 0)
66205
+ delete props.customAttributes;
66206
+ return props;
66207
+ }
66208
+ /**
66209
+ * Helper method to resolve the SchemaItem's full name from the given rawTypeName.
66210
+ * If the SchemaItem is defined in the same Schema from which it is referenced,
66211
+ * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,
66212
+ * the rawTypeName will have the schema alias ('bis:PhysicalElement').
66213
+ * @param rawTypeName The name or aliased name of the SchemaItem.
66214
+ * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'
66215
+ */
66216
+ async getQualifiedTypeName(rawTypeName) {
66217
+ const nameParts = rawTypeName.split(":");
66218
+ if (nameParts.length !== 2) {
66219
+ const [schemaName, itemName] = _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__.SchemaItem.parseFullName(rawTypeName);
66220
+ if (!schemaName || schemaName === '')
66221
+ return `${this._schema}.${itemName}`;
66222
+ return rawTypeName;
66223
+ }
66224
+ const resolvedName = await this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());
66225
+ if (!resolvedName)
66226
+ throw new Error(`No valid schema found for alias '${nameParts[0]}'`);
66227
+ return `${resolvedName}.${nameParts[1]}`;
66228
+ }
66229
+ async resolveNameFromAlias(alias) {
66230
+ for (const schema of this._context.getKnownSchemas()) {
66231
+ if (schema.alias === alias)
66232
+ return schema.schemaKey.name;
66233
+ }
66234
+ return undefined;
66235
+ }
66236
+ }
66237
+ /**
66238
+ * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.
66239
+ * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from
66240
+ * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.
66241
+ * @internal
66242
+ */
66243
+ class KindOfQuantityParser extends SchemaItemParser {
66244
+ /**
66245
+ * Parses the given KindOfQuantityProps JSON returned from an ECSql query.
66246
+ * @param data The KindOfQuantityProps JSON as returned from an iModelDb.
66247
+ * @returns The corrected KindOfQuantityProps Json.
66248
+ */
66249
+ async parse(data) {
66250
+ const mutableProps = await super.parse(data);
66251
+ if (mutableProps.persistenceUnit) {
66252
+ mutableProps.persistenceUnit = await this.getQualifiedTypeName(mutableProps.persistenceUnit);
66253
+ }
66254
+ mutableProps.presentationUnits = await this.parsePresentationUnits(mutableProps);
66255
+ return mutableProps;
66256
+ }
66257
+ async parsePresentationUnits(props) {
66258
+ const presentationUnits = [];
66259
+ if (!props.presentationUnits)
66260
+ return [];
66261
+ for (const presentationUnit of props.presentationUnits) {
66262
+ const presFormatOverride = _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__.OverrideFormat.parseFormatString(presentationUnit);
66263
+ const formatString = await this.createOverrideFormatString(presFormatOverride);
66264
+ presentationUnits.push(formatString);
66265
+ }
66266
+ ;
66267
+ return presentationUnits;
66268
+ }
66269
+ async createOverrideFormatString(overrideFormatProps) {
66270
+ let formatFullName = await this.getQualifiedTypeName(overrideFormatProps.name);
66271
+ if (overrideFormatProps.precision)
66272
+ formatFullName += `(${overrideFormatProps.precision.toString()})`;
66273
+ if (undefined === overrideFormatProps.unitAndLabels)
66274
+ return formatFullName;
66275
+ for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {
66276
+ const unitFullName = await this.getQualifiedTypeName(unit);
66277
+ if (undefined === unitLabel)
66278
+ formatFullName += `[${unitFullName}]`;
66279
+ else
66280
+ formatFullName += `[${unitFullName}|${unitLabel}]`;
66281
+ }
66282
+ return formatFullName;
66283
+ }
66284
+ }
66285
+
66286
+
66287
+ /***/ }),
66288
+
66289
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js":
66290
+ /*!************************************************************************************!*\
66291
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js ***!
66292
+ \************************************************************************************/
66293
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66294
+
66295
+ "use strict";
66296
+ __webpack_require__.r(__webpack_exports__);
66297
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66298
+ /* harmony export */ SchemaItemQueries: () => (/* binding */ SchemaItemQueries)
66299
+ /* harmony export */ });
66300
+ /*---------------------------------------------------------------------------------------------
66301
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
66302
+ * See LICENSE.md in the project root for license terms and full copyright notice.
66303
+ *--------------------------------------------------------------------------------------------*/
66304
+ /************************************************************************************
66305
+ * All SchemaItem queries for each SchemaItemType are defined here. These queries
66306
+ * are shared for both 'partial schema' and 'full schema' queries.
66307
+ ***********************************************************************************/
66308
+ /**
66309
+ * Query for SchemaItemType KindOfQuantity data.
66310
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66311
+ */
66312
+ const kindOfQuantity = (singleSchema) => `
66313
+ SELECT
66314
+ [koq].[Schema].[Id] AS [SchemaId],
66315
+ json_object (
66316
+ 'schemaItemType', 'KindOfQuantity',
66317
+ 'name', [koq].[Name],
66318
+ 'label', [koq].[DisplayLabel],
66319
+ 'description', [koq].[Description]
66320
+ ${singleSchema ? `
66321
+ ,'relativeError', [koq].[RelativeError],
66322
+ 'persistenceUnit', [koq].[PersistenceUnit],
66323
+ 'presentationUnits', (
66324
+ SELECT json_group_array(js."value")
66325
+ FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js
66326
+ WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]
66327
+ ) ` : ""}
66328
+ ) as [item]
66329
+ FROM
66330
+ [meta].[KindOfQuantityDef] [koq]
66331
+ ${singleSchema ? `
66332
+ JOIN
66333
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]
66334
+ WHERE [schema].[Name] = :schemaName
66335
+ ` : ""}
66336
+ `;
66337
+ /**
66338
+ * Query for SchemaItemType PropertyCategory data.
66339
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66340
+ */
66341
+ const propertyCategory = (singleSchema) => `
66342
+ SELECT
66343
+ [pc].[Schema].[Id] AS [SchemaId],
66344
+ json_object (
66345
+ 'schemaItemType', 'PropertyCategory',
66346
+ 'name', [pc].[Name],
66347
+ 'label', [pc].[DisplayLabel],
66348
+ 'description', [pc].[Description],
66349
+ 'priority', [pc].[Priority]
66350
+ ) as [item]
66351
+ FROM
66352
+ [meta].[PropertyCategoryDef] [pc]
66353
+ ${singleSchema ? `
66354
+ JOIN
66355
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]
66356
+ WHERE [schema].[Name] = :schemaName
66357
+ ` : ""}
66358
+ `;
66359
+ /**
66360
+ * Query for SchemaItemType Enumeration data.
66361
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66362
+ */
66363
+ const enumeration = (singleSchema) => `
66364
+ SELECT
66365
+ [ed].[Schema].[Id] AS [SchemaId],
66366
+ json_object (
66367
+ 'schemaItemType', 'Enumeration',
66368
+ 'name', [ed].[Name],
66369
+ 'label', [ed].[DisplayLabel],
66370
+ 'description', [ed].[Description],
66371
+ 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),
66372
+ 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),
66373
+ 'enumerators', (
66374
+ SELECT json_group_array(json(json_object(
66375
+ 'name', json_extract(js."value", '$.Name'),
66376
+ 'value', IFNULL(json_extract(js."value", '$.StringValue'), (json_extract(js."value", '$.IntValue'))),
66377
+ 'label', json_extract(js."value", '$.DisplayLabel'),
66378
+ 'description', json_extract(js."value", '$.Description')
66379
+ )))
66380
+ FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js
66381
+ WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]
66382
+ )
66383
+ ) as [item]
66384
+ FROM
66385
+ [meta].[ECEnumerationDef] [ed]
66386
+ ${singleSchema ? `
66387
+ JOIN
66388
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]
66389
+ WHERE [schema].[Name] = :schemaName` : ""}
66390
+ `;
66391
+ /**
66392
+ * Query for SchemaItemType Unit data.
66393
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66394
+ */
66395
+ const unit = (singleSchema) => `
66396
+ SELECT
66397
+ [ud].[Schema].[Id] AS [SchemaId],
66398
+ json_object (
66399
+ 'schemaItemType', 'Unit',
66400
+ 'name', [ud].[Name],
66401
+ 'label', [ud].[DisplayLabel],
66402
+ 'description', [ud].[Description],
66403
+ 'definition', [ud].[Definition],
66404
+ 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),
66405
+ 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),
66406
+ 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),
66407
+ 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),
66408
+ 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])
66409
+ ) as item
66410
+ FROM
66411
+ [meta].[UnitDef] [ud]
66412
+ ${singleSchema ? `
66413
+ JOIN
66414
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
66415
+ JOIN [meta].[UnitSystemDef] [usd]
66416
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
66417
+ JOIN [meta].[ECSchemaDef] [uss]
66418
+ ON [uss].[ECInstanceId] = [usd].[Schema].[Id]
66419
+ JOIN [meta].[PhenomenonDef] [pd]
66420
+ ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]
66421
+ JOIN [meta].[ECSchemaDef] [ps]
66422
+ ON [ps].[ECInstanceId] = [pd].[Schema].[Id]
66423
+ WHERE
66424
+ ${singleSchema ? `
66425
+ [schema].[Name] = :schemaName AND` : ""}
66426
+ [ud].[IsConstant] = 0 AND
66427
+ [ud].[InvertingUnit] IS NULL
66428
+ `;
66429
+ /**
66430
+ * Query for SchemaItemType InvertedUnit data.
66431
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66432
+ */
66433
+ const invertedUnit = (singleSchema) => `
66434
+ SELECT
66435
+ [ud].[Schema].[Id] AS [SchemaId],
66436
+ json_object (
66437
+ 'schemaItemType', 'InvertedUnit',
66438
+ 'name', [ud].[Name],
66439
+ 'label', [ud].[DisplayLabel],
66440
+ 'description', [ud].[Description],
66441
+ 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),
66442
+ 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))
66443
+ ) as [item]
66444
+ FROM
66445
+ [meta].[UnitDef] [ud]
66446
+ ${singleSchema ? `
66447
+ JOIN
66448
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
66449
+ JOIN [meta].[UnitSystemDef] [usd]
66450
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
66451
+ JOIN [meta].[ECSchemaDef] [systemSchema]
66452
+ ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]
66453
+ LEFT JOIN [meta].[UnitDef] [iud]
66454
+ ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]
66455
+ LEFT JOIN [meta].[ECSchemaDef] [ius]
66456
+ ON [ius].[ECInstanceId] = [iud].[Schema].[Id]
66457
+ WHERE
66458
+ ${singleSchema ? `
66459
+ [schema].[Name] = :schemaName AND` : ""}
66460
+ [ud].[IsConstant] = 0 AND
66461
+ [ud].[InvertingUnit] IS NOT NULL
66462
+ `;
66463
+ /**
66464
+ * Query for SchemaItemType Constant data.
66465
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66466
+ */
66467
+ const constant = (singleSchema) => `
66468
+ SELECT
66469
+ [cd].[Schema].[Id] AS [SchemaId],
66470
+ json_object(
66471
+ 'schemaItemType', 'Constant',
66472
+ 'name', [cd].[Name],
66473
+ 'label', [cd].[DisplayLabel],
66474
+ 'description', [cd].[Description],
66475
+ 'definition', [cd].[Definition],
66476
+ 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),
66477
+ 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),
66478
+ 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])
66479
+ ) as item
66480
+ FROM
66481
+ [meta].[UnitDef] [cd]
66482
+ ${singleSchema ? `
66483
+ JOIN
66484
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : ""}
66485
+ JOIN [meta].[PhenomenonDef] [phenomDef]
66486
+ ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]
66487
+ JOIN [meta].[ECSchemaDef] [phenomSchema]
66488
+ ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]
66489
+ WHERE
66490
+ ${singleSchema ? `
66491
+ [schema].[Name] = :schemaName AND` : ""}
66492
+ [cd].[IsConstant] = 1
66493
+ `;
66494
+ /**
66495
+ * Query for SchemaItemType UnitSystem data.
66496
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66497
+ */
66498
+ const unitSystem = (singleSchema) => `
66499
+ SELECT
66500
+ [us].[Schema].[Id] AS [SchemaId],
66501
+ json_object (
66502
+ 'schemaItemType', 'UnitSystem',
66503
+ 'name', [us].[Name],
66504
+ 'label', [us].[DisplayLabel],
66505
+ 'description', [us].[Description]
66506
+ ) as [item]
66507
+ FROM
66508
+ [meta].[UnitSystemDef] [us]
66509
+ ${singleSchema ? `
66510
+ JOIN
66511
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]
66512
+ WHERE [schema].[Name] = :schemaName` : ""}
66513
+ `;
66514
+ /**
66515
+ * Query for SchemaItemType Phenomenon data.
66516
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66517
+ */
66518
+ const phenomenon = (singleSchema) => `
66519
+ SELECT
66520
+ [pd].[Schema].[Id] AS [SchemaId],
66521
+ json_object(
66522
+ 'schemaItemType', 'Phenomenon',
66523
+ 'name', [pd].[Name],
66524
+ 'label', [pd].[DisplayLabel],
66525
+ 'description', [pd].[Description],
66526
+ 'definition', [pd].[Definition]
66527
+ ) as [item]
66528
+ FROM
66529
+ [meta].[PhenomenonDef] [pd]
66530
+ ${singleSchema ? `
66531
+ JOIN
66532
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]
66533
+ WHERE [schema].[Name] = :schemaName` : ""}
66534
+ `;
66535
+ /**
66536
+ * Query for SchemaItemType Format data.
66537
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
66538
+ */
66539
+ const format = (singleSchema) => `
66540
+ SELECT
66541
+ [fd].[Schema].[Id] AS [SchemaId],
66542
+ json_object(
66543
+ 'schemaItemType', 'Format',
66544
+ 'name', [fd].[Name],
66545
+ 'label', [fd].[DisplayLabel],
66546
+ 'description', [fd].[Description],
66547
+ 'type', json_extract([fd].[NumericSpec], '$.type'),
66548
+ 'precision', json_extract([fd].[NumericSpec], '$.precision'),
66549
+ 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),
66550
+ 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),
66551
+ 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),
66552
+ 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),
66553
+ 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),
66554
+ 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),
66555
+ 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),
66556
+ 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),
66557
+ 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),
66558
+ 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')
66559
+ ${singleSchema ? `
66560
+ ,'composite', (
66561
+ SELECT
66562
+ json_object(
66563
+ 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),
66564
+ 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),
66565
+ 'units', (
66566
+ SELECT json_group_array(json(json_object(
66567
+ 'name', CONCAT([sd].[Name], '.', [ud].[Name]),
66568
+ 'label', [fud].[Label]
66569
+ )))
66570
+ FROM [meta].[FormatDef] [fd2]
66571
+ LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]
66572
+ LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]
66573
+ INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]
66574
+ WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]
66575
+ )
66576
+ )
66577
+ FROM [meta].[FormatDef] [fd1]
66578
+ WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL
66579
+ )` : ""}
66580
+ ) AS item
66581
+ FROM
66582
+ [meta].[FormatDef] [fd]
66583
+ ${singleSchema ? `
66584
+ JOIN
66585
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]
66586
+ WHERE [schema].[Name] = :schemaName` : ""}
66587
+ `;
66588
+ /**
66589
+ * Queries for each SchemaItemType
66590
+ * @internal
66591
+ */
66592
+ // eslint-disable-next-line @typescript-eslint/naming-convention
66593
+ const SchemaItemQueries = {
66594
+ kindOfQuantity,
66595
+ propertyCategory,
66596
+ enumeration,
66597
+ unit,
66598
+ invertedUnit,
66599
+ constant,
66600
+ unitSystem,
66601
+ phenomenon,
66602
+ format
66603
+ };
66604
+
66605
+
66606
+ /***/ }),
66607
+
66608
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js":
66609
+ /*!*******************************************************************************!*\
66610
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js ***!
66611
+ \*******************************************************************************/
66612
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66613
+
66614
+ "use strict";
66615
+ __webpack_require__.r(__webpack_exports__);
66616
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66617
+ /* harmony export */ SchemaParser: () => (/* binding */ SchemaParser),
66618
+ /* harmony export */ parseCustomAttribute: () => (/* binding */ parseCustomAttribute)
66619
+ /* harmony export */ });
66620
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
66621
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
66622
+ /* harmony import */ var _ClassParsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ClassParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js");
66623
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
66624
+ /*---------------------------------------------------------------------------------------------
66625
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
66626
+ * See LICENSE.md in the project root for license terms and full copyright notice.
66627
+ *--------------------------------------------------------------------------------------------*/
66628
+
66629
+
66630
+
66631
+
66632
+ function clean(_key, value) {
66633
+ return value === null ? undefined : value;
66634
+ }
66635
+ /**
66636
+ * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
66637
+ * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)
66638
+ * returned from the iModelDb is in a different format than is required for a given Schema or
66639
+ * SchemaItemProps JSON object.
66640
+ * @internal
66641
+ */
66642
+ class SchemaParser {
66643
+ /**
66644
+ * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps
66645
+ * JSON object.
66646
+ * @param schema The SchemaProps JSON object to parse.
66647
+ * @param context The SchemaContext that will contain the schema and it's references.
66648
+ * @returns The corrected SchemaProps JSON.
66649
+ */
66650
+ static async parse(schema, context) {
66651
+ const props = schema;
66652
+ props.$schema = _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
66653
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return parseCustomAttribute(attr); }) : undefined;
66654
+ props.label = props.label === null ? undefined : props.label;
66655
+ props.description = props.description === null ? undefined : props.description;
66656
+ if (props.items) {
66657
+ props.items = await this.parseItems(props.items, props.name, context);
66658
+ }
66659
+ if (!props.customAttributes || props.customAttributes.length === 0)
66660
+ delete props.customAttributes;
66661
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
66662
+ return cleaned;
66663
+ }
66664
+ /**
66665
+ * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.
66666
+ * @param schemaItems The SchemaItemProps array returned from an iModelDb.
66667
+ * @param schemaName The name of the Schema to which the SchemaItemProps belong.
66668
+ * @param context The SchemaContext containing the Schema.
66669
+ * @returns The corrected SchemaItemProps.
66670
+ */
66671
+ static async parseSchemaItems(schemaItems, schemaName, context) {
66672
+ const items = [];
66673
+ for (const item of schemaItems) {
66674
+ const props = await this.parseItem(item, schemaName, context);
66675
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
66676
+ items.push(cleaned);
66677
+ }
66678
+ return items.length > 0 ? items : undefined;
66679
+ }
66680
+ static async parseItems(schemaItemProps, schemaName, context) {
66681
+ const items = {};
66682
+ for (const itemProps of schemaItemProps) {
66683
+ const props = await this.parseItem(itemProps, schemaName, context);
66684
+ items[props.name] = props;
66685
+ delete props.name;
66686
+ }
66687
+ return Object.keys(items).length > 0 ? items : undefined;
66688
+ }
66689
+ static async parseItem(props, schemaName, context) {
66690
+ const schemaItem = "string" === typeof (props) ? JSON.parse(props) : props;
66691
+ const type = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(schemaItem.schemaItemType);
66692
+ switch (type) {
66693
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
66694
+ const koqParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.KindOfQuantityParser(schemaName, context);
66695
+ return koqParser.parse(schemaItem);
66696
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
66697
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
66698
+ const classParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.ClassParser(schemaName, context);
66699
+ return classParser.parse(schemaItem);
66700
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
66701
+ const relationshipParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.RelationshipClassParser(schemaName, context);
66702
+ return relationshipParser.parse(schemaItem);
66703
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
66704
+ const mixinParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.MixinParser(schemaName, context);
66705
+ return mixinParser.parse(schemaItem);
66706
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
66707
+ const caParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.CustomAttributeClassParser(schemaName, context);
66708
+ return caParser.parse(schemaItem);
66709
+ default:
66710
+ const itemParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.SchemaItemParser(schemaName, context);
66711
+ return itemParser.parse(schemaItem);
66712
+ }
66713
+ }
66714
+ }
66715
+ /**
66716
+ * Utility method to parse CustomAttribute data retrieved from a ECSql query.
66717
+ * @param customAttribute CustomAttribute data as retrieved from an iModel query.
66718
+ * @returns The CustomAttribute instance.
66719
+ * @internal
66720
+ */
66721
+ function parseCustomAttribute(customAttribute) {
66722
+ return {
66723
+ ...customAttribute[customAttribute.ecClass],
66724
+ className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,
66725
+ };
66726
+ }
66727
+
66728
+
66729
+ /***/ }),
66730
+
66731
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js":
66732
+ /*!************************************************************************************!*\
66733
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js ***!
66734
+ \************************************************************************************/
66735
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
66736
+
66737
+ "use strict";
66738
+ __webpack_require__.r(__webpack_exports__);
66739
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
66740
+ /* harmony export */ ecsqlQueries: () => (/* binding */ ecsqlQueries),
66741
+ /* harmony export */ modifier: () => (/* binding */ modifier),
66742
+ /* harmony export */ strength: () => (/* binding */ strength),
66743
+ /* harmony export */ strengthDirection: () => (/* binding */ strengthDirection)
66744
+ /* harmony export */ });
66745
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
66746
+ /*---------------------------------------------------------------------------------------------
66747
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
66748
+ * See LICENSE.md in the project root for license terms and full copyright notice.
66749
+ *--------------------------------------------------------------------------------------------*/
66750
+
66751
+ const modifier = (alias) => {
66752
+ return `
66753
+ CASE
66754
+ WHEN [${alias}].[modifier] = 0 THEN 'None'
66755
+ WHEN [${alias}].[modifier] = 1 THEN 'Abstract'
66756
+ WHEN [${alias}].[modifier] = 2 THEN 'Sealed'
66757
+ ELSE NULL
66758
+ END
66759
+ `;
66760
+ };
66761
+ const strength = (alias) => {
66762
+ return `
66763
+ CASE
66764
+ WHEN [${alias}].[RelationshipStrength] = 0 THEN 'Referencing'
66765
+ WHEN [${alias}].[RelationshipStrength] = 1 THEN 'Holding'
66766
+ WHEN [${alias}].[RelationshipStrength] = 2 THEN 'Embedding'
66767
+ ELSE NULL
66768
+ END
66769
+ `;
66770
+ };
66771
+ const strengthDirection = (alias) => {
66772
+ return `
66773
+ CASE
66774
+ WHEN [${alias}].[RelationshipStrengthDirection] = 1 THEN 'Forward'
66775
+ WHEN [${alias}].[RelationshipStrengthDirection] = 2 THEN 'Backward'
66776
+ ELSE NULL
66777
+ END
66778
+ `;
66779
+ };
66780
+ const withAppliesTo = `
66781
+ AppliesToCTE AS (
66782
+ SELECT
66783
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
66784
+ [appliesToSchema].[name] as [AppliesToSchema],
66785
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
66786
+ FROM [meta].[CustomAttribute] [ca]
66787
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
66788
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
66789
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
66790
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
66791
+ WHERE [ca].[ContainerType] = 30
66792
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
66793
+ )
66794
+ `;
66795
+ const withSchemaReferences = `
66796
+ SchemaReferences AS (
66797
+ SELECT
66798
+ [ref].[SourceECInstanceId] AS [SchemaId],
66799
+ CONCAT([Name],'.',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [fullName]
66800
+ FROM
66801
+ [meta].[ECSchemaDef] AS [refSchema]
66802
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
66803
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
66804
+ )
66805
+ `;
66806
+ const customAttributeQuery = `
66807
+ SELECT
66808
+ [Schema].[Id] AS [SchemaId],
66809
+ json_object(
66810
+ 'name', [class].[Name],
66811
+ 'schemaItemType', 'CustomAttributeClass',
66812
+ 'modifier', ${modifier("class")},
66813
+ 'label', [class].[DisplayLabel],
66814
+ 'description', [class].[Description],
66815
+ 'appliesTo', [class].[CustomAttributeContainerType],
66816
+ 'baseClasses', (
66817
+ SELECT
66818
+ json_group_array(json(json_object(
66819
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66820
+ 'name', [baseClass].[Name],
66821
+ 'schemaItemType', 'CustomAttributeClass',
66822
+ 'modifier', ${modifier("baseClass")},
66823
+ 'label', [baseClass].[DisplayLabel],
66824
+ 'description', [baseClass].[Description],
66825
+ 'appliesTo', [baseClass].[CustomAttributeContainerType]
66826
+ )))
66827
+ FROM
66828
+ [meta].[ECClassDef] [baseClass]
66829
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
66830
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
66831
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
66832
+ )
66833
+ ) AS [item]
66834
+ FROM [meta].[ECClassDef] [class]
66835
+ WHERE [class].[Type] = 3
66836
+ `;
66837
+ const structQuery = `
66838
+ SELECT
66839
+ [Schema].[Id] AS [SchemaId],
66840
+ json_object(
66841
+ 'name', [class].[Name],
66842
+ 'schemaItemType', 'StructClass',
66843
+ 'modifier', ${modifier("class")},
66844
+ 'label', [class].[DisplayLabel],
66845
+ 'description', [class].[Description],
66846
+ 'baseClasses', (
66847
+ SELECT
66848
+ json_group_array(json(json_object(
66849
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66850
+ 'name', [baseClass].[Name],
66851
+ 'schemaItemType', 'StructClass',
66852
+ 'modifier', ${modifier("baseClass")},
66853
+ 'label', [baseClass].[DisplayLabel],
66854
+ 'description', [baseClass].[Description]
66855
+ )))
66856
+ FROM
66857
+ [meta].[ECClassDef] [baseClass]
66858
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
66859
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
66860
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
66861
+ )
66862
+ ) AS [item]
66863
+ FROM [meta].[ECClassDef] [class]
66864
+ WHERE [class].[Type] = 2
66865
+ `;
66866
+ const relationshipQuery = `
66867
+ SELECT
66868
+ [Schema].[Id] AS [SchemaId],
66869
+ json_object(
66870
+ 'name', [class].[Name],
66871
+ 'schemaItemType', 'RelationshipClass',
66872
+ 'modifier', ${modifier("class")},
66873
+ 'label', [class].[DisplayLabel],
66874
+ 'description', [class].[Description],
66875
+ 'strength', ${strength("class")},
66876
+ 'strengthDirection', ${strengthDirection("class")},
66877
+ 'baseClasses', (
66878
+ SELECT
66879
+ json_group_array(json(json_object(
66880
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66881
+ 'name', [baseClass].[Name],
66882
+ 'schemaItemType', 'RelationshipClass',
66883
+ 'modifier', ${modifier("baseClass")},
66884
+ 'label', [baseClass].[DisplayLabel],
66885
+ 'description', [baseClass].[Description],
66886
+ 'strength', ${strength("baseClass")},
66887
+ 'strengthDirection', ${strengthDirection("baseClass")}
66888
+ )))
66889
+ FROM
66890
+ [meta].[ECClassDef] [baseClass]
66891
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
66892
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
66893
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
66894
+ )
66895
+ ) AS [item]
66896
+ FROM [meta].[ECClassDef] [class]
66897
+ WHERE [class].[Type] = 1
66898
+ `;
66899
+ const entityQuery = `
66900
+ SELECT
66901
+ [Schema].[Id] AS [SchemaId],
66902
+ json_object(
66903
+ 'name', [class].[Name],
66904
+ 'schemaItemType', 'EntityClass',
66905
+ 'modifier', ${modifier("class")},
66906
+ 'label', [class].[DisplayLabel],
66907
+ 'description', [class].[Description],
66908
+ 'baseClasses', (
66909
+ SELECT
66910
+ json_group_array(json(json_object(
66911
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66912
+ 'name', [baseClass].[Name],
66913
+ 'schemaItemType', 'EntityClass',
66914
+ 'modifier', ${modifier("baseClass")},
66915
+ 'label', [baseClass].[DisplayLabel],
66916
+ 'description', [baseClass].[Description]
66917
+ )))
66918
+ FROM
66919
+ [meta].[ECClassDef] [baseClass]
66920
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
66921
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
66922
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
66923
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
66924
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
66925
+ ),
66926
+ 'mixins', (
66927
+ SELECT
66928
+ json_group_array(json(json_object(
66929
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66930
+ 'name', [baseClass].[Name],
66931
+ 'schemaItemType', 'Mixin',
66932
+ 'modifier', ${modifier("baseClass")},
66933
+ 'label', [baseClass].[DisplayLabel],
66934
+ 'description', [baseClass].[Description],
66935
+ 'appliesTo', (
66936
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
66937
+ FROM [AppliesToCTE] [atCTE]
66938
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
66939
+ ),
66940
+ 'baseClasses', (
66941
+ SELECT
66942
+ json_group_array(json(json_object(
66943
+ 'schema', ec_classname([mixinBaseClass].[ECInstanceId], 's'),
66944
+ 'name', [mixinBaseClass].[Name],
66945
+ 'schemaItemType', 'Mixin',
66946
+ 'modifier', ${modifier("mixinBaseClass")},
66947
+ 'label', [mixinBaseClass].[DisplayLabel],
66948
+ 'description', [mixinBaseClass].[Description],
66949
+ 'appliesTo', (
66950
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
66951
+ FROM [AppliesToCTE] [atCTE]
66952
+ WHERE [atCTE].[AppliesToId] = [mixinBaseClass].[ECInstanceId]
66953
+ )
66954
+ )))
66955
+ FROM
66956
+ [meta].[ECClassDef] [mixinBaseClass]
66957
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [mixinBaseClassMap]
66958
+ ON [mixinBaseClassMap].[TargetECInstanceId] = [mixinBaseClass].[ECInstanceId]
66959
+ WHERE [mixinBaseClassMap].[SourceECInstanceId] = [baseClass].[ECInstanceId]
66960
+ )
66961
+ )))
66962
+ FROM
66963
+ [meta].[ECClassDef] [baseClass]
66964
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
66965
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
66966
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
66967
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
66968
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
66969
+ )
66970
+ ) AS [item]
66971
+ FROM [meta].[ECClassDef] [class]
66972
+ WHERE [class].[Type] = 0
66973
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
66974
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
66975
+ `;
66976
+ const mixinQuery = `
66977
+ SELECT
66978
+ [Schema].[Id] AS [SchemaId],
66979
+ json_object(
66980
+ 'name', [class].[Name],
66981
+ 'schemaItemType', 'Mixin',
66982
+ 'modifier', ${modifier("class")},
66983
+ 'label', [class].[DisplayLabel],
66984
+ 'description', [class].[Description],
66985
+ 'appliesTo', (
66986
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
66987
+ FROM [AppliesToCTE] [atCTE]
66988
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
66989
+ ),
66990
+ 'baseClasses', (
66991
+ SELECT
66992
+ json_group_array(json(json_object(
66993
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
66994
+ 'name', [baseClass].[Name],
66995
+ 'schemaItemType', 'Mixin',
66996
+ 'modifier', ${modifier("baseClass")},
66997
+ 'label', [baseClass].[DisplayLabel],
66998
+ 'description', [baseClass].[Description],
66999
+ 'appliesTo', (
67000
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
67001
+ FROM [AppliesToCTE] [atCTE]
67002
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
67003
+ )
67004
+ )))
67005
+ FROM
67006
+ [meta].[ECClassDef] [baseClass]
67007
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
67008
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
67009
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
67010
+ )
67011
+ ) AS [item]
67012
+ FROM [meta].[ECClassDef] [class]
67013
+ WHERE [class].[Type] = 0 AND EXISTS (SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
67014
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
67015
+ `;
67016
+ const withSchemaItems = `
67017
+ SchemaItems AS (
67018
+ ${customAttributeQuery}
67019
+ UNION ALL
67020
+ ${structQuery}
67021
+ UNION ALL
67022
+ ${relationshipQuery}
67023
+ UNION ALL
67024
+ ${entityQuery}
67025
+ UNION ALL
67026
+ ${mixinQuery}
67027
+ UNION ALL
67028
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration()}
67029
+ UNION ALL
67030
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity()}
67031
+ UNION ALL
67032
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory()}
67033
+ UNION ALL
67034
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit()}
67035
+ UNION ALL
67036
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit()}
67037
+ UNION ALL
67038
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant()}
67039
+ UNION ALL
67040
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon()}
67041
+ UNION ALL
67042
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem()}
67043
+ UNION ALL
67044
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format()}
67045
+ )
67046
+ `;
67047
+ const schemaStubQuery = `
67048
+ WITH
67049
+ ${withSchemaReferences},
67050
+ ${withAppliesTo},
67051
+ ${withSchemaItems}
67052
+ SELECT
67053
+ [Name] as [name],
67054
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
67055
+ [Alias] as [alias],
67056
+ [DisplayLabel] as [displayLabel],
67057
+ [Description] as [description],
67058
+ (
67059
+ SELECT
67060
+ json_group_array([schemaReferences].[fullName])
67061
+ FROM
67062
+ [SchemaReferences] [schemaReferences]
67063
+ WHERE
67064
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
67065
+ ) AS [references],
67066
+ (
67067
+ SELECT
67068
+ json_group_array(json([items].[item]))
67069
+ FROM
67070
+ [SchemaItems] [items]
67071
+ WHERE
67072
+ [items].[SchemaId] = [schemaDef].[ECInstanceId]
67073
+ ) AS [items]
67074
+ FROM
67075
+ [meta].[ECSchemaDef] [schemaDef]
67076
+ WHERE [Name] = :schemaName
67077
+ `;
67078
+ const schemaInfoQuery = `
67079
+ WITH
67080
+ ${withSchemaReferences}
67081
+ SELECT
67082
+ [Name] as [name],
67083
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
67084
+ [Alias] as [alias],
67085
+ (
67086
+ SELECT
67087
+ json_group_array([schemaReferences].[fullName])
67088
+ FROM
67089
+ [SchemaReferences] [schemaReferences]
67090
+ WHERE
67091
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
67092
+ ) AS [references]
67093
+ FROM
67094
+ [meta].[ECSchemaDef] [schemaDef]
67095
+ `;
67096
+ /**
67097
+ * Partial Schema queries.
67098
+ * @internal
67099
+ */
67100
+ const ecsqlQueries = {
67101
+ schemaStubQuery,
67102
+ schemaInfoQuery,
67103
+ };
67104
+
67105
+
64632
67106
  /***/ }),
64633
67107
 
64634
67108
  /***/ "../../core/ecschema-metadata/lib/esm/Interfaces.js":
@@ -64955,6 +67429,7 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
64955
67429
  else
64956
67430
  correctType = structType;
64957
67431
  if (!correctType)
67432
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
64958
67433
  throw new _Exception__WEBPACK_IMPORTED_MODULE_4__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_4__.ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
64959
67434
  return correctType;
64960
67435
  }
@@ -64974,6 +67449,7 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
64974
67449
  else
64975
67450
  correctType = structType;
64976
67451
  if (!correctType)
67452
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
64977
67453
  throw new _Exception__WEBPACK_IMPORTED_MODULE_4__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_4__.ECSchemaStatus.InvalidType, `The provided Struct type, ${structType}, is not a valid StructClass.`);
64978
67454
  return correctType;
64979
67455
  }
@@ -68818,6 +71294,7 @@ class Schema {
68818
71294
  _customAttributes;
68819
71295
  _originalECSpecMajorVersion;
68820
71296
  _originalECSpecMinorVersion;
71297
+ _loadingController;
68821
71298
  /** @internal */
68822
71299
  constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
68823
71300
  this._schemaKey = (typeof (nameOrKey) === "string") ? new _SchemaKey__WEBPACK_IMPORTED_MODULE_6__.SchemaKey(nameOrKey, new _SchemaKey__WEBPACK_IMPORTED_MODULE_6__.ECVersion(readVer, writeVer, minorVer)) : nameOrKey;
@@ -68883,6 +71360,14 @@ class Schema {
68883
71360
  get schema() { return this; }
68884
71361
  /** Returns the schema context this schema is within. */
68885
71362
  get context() { return this._context; }
71363
+ /**
71364
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
71365
+ * loaded incrementally.
71366
+ * @internal
71367
+ */
71368
+ get loadingController() {
71369
+ return this._loadingController;
71370
+ }
68886
71371
  /**
68887
71372
  * Returns a SchemaItemKey given the item name and the schema it belongs to
68888
71373
  * @param fullName fully qualified name {Schema name}.{Item Name}
@@ -69508,6 +71993,10 @@ class Schema {
69508
71993
  }
69509
71994
  this._alias = alias;
69510
71995
  }
71996
+ /** @internal */
71997
+ setLoadingController(controller) {
71998
+ this._loadingController = controller;
71999
+ }
69511
72000
  }
69512
72001
  /**
69513
72002
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
@@ -69561,6 +72050,7 @@ class SchemaItem {
69561
72050
  _key;
69562
72051
  _description;
69563
72052
  _label;
72053
+ _loadingController;
69564
72054
  /** @internal */
69565
72055
  constructor(schema, name) {
69566
72056
  this._key = new _SchemaKey__WEBPACK_IMPORTED_MODULE_3__.SchemaItemKey(name, schema.schemaKey);
@@ -69571,6 +72061,14 @@ class SchemaItem {
69571
72061
  get key() { return this._key; }
69572
72062
  get label() { return this._label; }
69573
72063
  get description() { return this._description; }
72064
+ /**
72065
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
72066
+ * loaded incrementally.
72067
+ * @internal
72068
+ */
72069
+ get loadingController() {
72070
+ return this._loadingController;
72071
+ }
69574
72072
  // Proposal: Create protected setter methods for description and label? For UnitSystems as an example, where using createFromProps isn't that necessary and can just use basic create().
69575
72073
  /**
69576
72074
  * Save this SchemaItem's properties to an object for serializing to JSON.
@@ -69676,6 +72174,10 @@ class SchemaItem {
69676
72174
  setDescription(description) {
69677
72175
  this._description = description;
69678
72176
  }
72177
+ /** @internal */
72178
+ setLoadingController(controller) {
72179
+ this._loadingController = controller;
72180
+ }
69679
72181
  }
69680
72182
 
69681
72183
 
@@ -71830,6 +74332,7 @@ __webpack_require__.r(__webpack_exports__);
71830
74332
  /* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
71831
74333
  /* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
71832
74334
  /* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
74335
+ /* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
71833
74336
  /* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
71834
74337
  /* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
71835
74338
  /* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
@@ -71837,6 +74340,7 @@ __webpack_require__.r(__webpack_exports__);
71837
74340
  /* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
71838
74341
  /* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
71839
74342
  /* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
74343
+ /* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
71840
74344
  /* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
71841
74345
  /* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
71842
74346
  /* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
@@ -71859,7 +74363,7 @@ __webpack_require__.r(__webpack_exports__);
71859
74363
  /* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
71860
74364
  /* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
71861
74365
  /* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.SchemaFormatsProvider),
71862
- /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_39__.SchemaGraph),
74366
+ /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
71863
74367
  /* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
71864
74368
  /* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
71865
74369
  /* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
@@ -71940,7 +74444,9 @@ __webpack_require__.r(__webpack_exports__);
71940
74444
  /* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
71941
74445
  /* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
71942
74446
  /* harmony import */ var _SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./SchemaFormatsProvider */ "../../core/ecschema-metadata/lib/esm/SchemaFormatsProvider.js");
71943
- /* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
74447
+ /* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
74448
+ /* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
74449
+ /* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
71944
74450
  /*---------------------------------------------------------------------------------------------
71945
74451
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
71946
74452
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -71982,6 +74488,8 @@ __webpack_require__.r(__webpack_exports__);
71982
74488
 
71983
74489
 
71984
74490
 
74491
+
74492
+
71985
74493
 
71986
74494
 
71987
74495
 
@@ -72124,6 +74632,81 @@ class SchemaGraph {
72124
74632
  }
72125
74633
 
72126
74634
 
74635
+ /***/ }),
74636
+
74637
+ /***/ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js":
74638
+ /*!*****************************************************************************!*\
74639
+ !*** ../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js ***!
74640
+ \*****************************************************************************/
74641
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
74642
+
74643
+ "use strict";
74644
+ __webpack_require__.r(__webpack_exports__);
74645
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
74646
+ /* harmony export */ SchemaLoadingController: () => (/* binding */ SchemaLoadingController)
74647
+ /* harmony export */ });
74648
+ /*---------------------------------------------------------------------------------------------
74649
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
74650
+ * See LICENSE.md in the project root for license terms and full copyright notice.
74651
+ *--------------------------------------------------------------------------------------------*/
74652
+ /**
74653
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
74654
+ * class is set in Schema and SchemaItem instances.
74655
+ * @internal
74656
+ */
74657
+ class SchemaLoadingController {
74658
+ _complete;
74659
+ _inProgress;
74660
+ _promise;
74661
+ /**
74662
+ * Indicates of the Schema or SchemaItem has been fully loaded.
74663
+ */
74664
+ get isComplete() {
74665
+ return this._complete;
74666
+ }
74667
+ /**
74668
+ * Marks that a Schema or SchemaItem has been fully loaded.
74669
+ */
74670
+ set isComplete(value) {
74671
+ this._complete = value;
74672
+ }
74673
+ /**
74674
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
74675
+ */
74676
+ get inProgress() {
74677
+ return this._inProgress;
74678
+ }
74679
+ /**
74680
+ * Initializes a new SchemaLoadingController instance.
74681
+ */
74682
+ constructor() {
74683
+ this._complete = false;
74684
+ this._inProgress = false;
74685
+ }
74686
+ /**
74687
+ * Call this method when starting to load a Schema or SchemaItem
74688
+ * @param promise The promise used to update the controller state when the promise is resolved.
74689
+ */
74690
+ start(promise) {
74691
+ this._inProgress = true;
74692
+ void promise.then(() => {
74693
+ this._complete = true;
74694
+ this._inProgress = false;
74695
+ });
74696
+ this._promise = promise;
74697
+ }
74698
+ /**
74699
+ * Waits on the Promise given in SchemaLoadingController.start().
74700
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
74701
+ */
74702
+ async wait() {
74703
+ if (!this._promise)
74704
+ throw new Error("LoadingController 'start' must be called before 'wait'");
74705
+ return this._promise;
74706
+ }
74707
+ }
74708
+
74709
+
72127
74710
  /***/ }),
72128
74711
 
72129
74712
  /***/ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js":
@@ -72272,6 +74855,74 @@ class ECSchemaRpcLocater {
72272
74855
  }
72273
74856
 
72274
74857
 
74858
+ /***/ }),
74859
+
74860
+ /***/ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js":
74861
+ /*!*****************************************************************************!*\
74862
+ !*** ../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js ***!
74863
+ \*****************************************************************************/
74864
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
74865
+
74866
+ "use strict";
74867
+ __webpack_require__.r(__webpack_exports__);
74868
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
74869
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* binding */ RpcIncrementalSchemaLocater)
74870
+ /* harmony export */ });
74871
+ /* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
74872
+ /* harmony import */ var _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/ecschema-metadata */ "../../core/ecschema-metadata/lib/esm/ecschema-metadata.js");
74873
+ /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
74874
+ /*---------------------------------------------------------------------------------------------
74875
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
74876
+ * See LICENSE.md in the project root for license terms and full copyright notice.
74877
+ *--------------------------------------------------------------------------------------------*/
74878
+
74879
+
74880
+
74881
+ /**
74882
+ * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.
74883
+ * @beta
74884
+ */
74885
+ class RpcIncrementalSchemaLocater extends _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__.ECSqlSchemaLocater {
74886
+ _iModelProps;
74887
+ /**
74888
+ * Initializes a new instance of the RpcIncrementalSchemaLocater class.
74889
+ */
74890
+ constructor(iModelProps, options) {
74891
+ super(options);
74892
+ this._iModelProps = iModelProps;
74893
+ }
74894
+ /**
74895
+ * Executes the given ECSql query and returns the resulting rows.
74896
+ * @param query The ECSql query to execute.
74897
+ * @param options Optional arguments to control the query result.
74898
+ * @returns A promise that resolves to the resulting rows.
74899
+ */
74900
+ async executeQuery(query, options) {
74901
+ const ecSqlQueryClient = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.IModelReadRpcInterface.getClient();
74902
+ const queryExecutor = {
74903
+ execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),
74904
+ };
74905
+ const queryOptions = {
74906
+ limit: { count: options?.limit },
74907
+ rowFormat: _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryRowFormat.UseECSqlPropertyNames,
74908
+ };
74909
+ const queryParameters = options && options.parameters ? _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryBinder.from(options.parameters) : undefined;
74910
+ const queryReader = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ECSqlReader(queryExecutor, query, queryParameters, queryOptions);
74911
+ return queryReader.toArray();
74912
+ }
74913
+ /**
74914
+ * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).
74915
+ * This is the full schema json with all elements that are defined in the schema.
74916
+ * @param schemaKey The schema key of the schema to be resolved.
74917
+ */
74918
+ async getSchemaProps(schemaKey) {
74919
+ const rpcSchemaClient = _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__.ECSchemaRpcInterface.getClient();
74920
+ return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);
74921
+ }
74922
+ ;
74923
+ }
74924
+
74925
+
72275
74926
  /***/ }),
72276
74927
 
72277
74928
  /***/ "../../core/ecschema-rpc/common/lib/esm/ecschema-rpc-interface.js":
@@ -72284,10 +74935,12 @@ class ECSchemaRpcLocater {
72284
74935
  __webpack_require__.r(__webpack_exports__);
72285
74936
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
72286
74937
  /* harmony export */ ECSchemaRpcInterface: () => (/* reexport safe */ _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__.ECSchemaRpcInterface),
72287
- /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater)
74938
+ /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater),
74939
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* reexport safe */ _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__.RpcIncrementalSchemaLocater)
72288
74940
  /* harmony export */ });
72289
74941
  /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
72290
74942
  /* harmony import */ var _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ECSchemaRpcLocater */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcLocater.js");
74943
+ /* harmony import */ var _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RpcIncrementalSchemaLocater */ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js");
72291
74944
  /*---------------------------------------------------------------------------------------------
72292
74945
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
72293
74946
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -72296,6 +74949,7 @@ __webpack_require__.r(__webpack_exports__);
72296
74949
 
72297
74950
 
72298
74951
 
74952
+
72299
74953
  /***/ }),
72300
74954
 
72301
74955
  /***/ "../../core/frontend/lib/esm/AccuDraw.js":
@@ -80352,6 +83006,7 @@ class SectionAttachment {
80352
83006
  is3d: true,
80353
83007
  scale: { x: 1, y: 1 },
80354
83008
  },
83009
+ contours: view.getDisplayStyle3d().settings.contours
80355
83010
  };
80356
83011
  this._viewFlagOverrides = { ...view.viewFlags, lighting: false, shadows: false };
80357
83012
  // Save off the original frustum (potentially adjusted by viewport).
@@ -111746,7 +114401,7 @@ class BatchUniforms {
111746
114401
  this._sensors.bindTexture(uniform);
111747
114402
  }
111748
114403
  get wantContourLines() {
111749
- const contours = this._target.plan.contours;
114404
+ const contours = this._target.currentBranch.contourLine;
111750
114405
  return undefined !== contours && contours.displayContours && contours.groups.length > 0;
111751
114406
  }
111752
114407
  bindContourLUT(uniform) {
@@ -111878,6 +114533,7 @@ class BranchStack {
111878
114533
  viewFlags: new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ViewFlags(),
111879
114534
  transform: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createIdentity(),
111880
114535
  edgeSettings: _EdgeSettings__WEBPACK_IMPORTED_MODULE_5__.EdgeSettings.create(undefined),
114536
+ contourLine: undefined,
111881
114537
  is3d: true,
111882
114538
  symbologyOverrides: new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_3__.FeatureSymbology.Overrides(),
111883
114539
  });
@@ -111906,9 +114562,9 @@ class BranchStack {
111906
114562
  this._stack.pop();
111907
114563
  }
111908
114564
  }
111909
- changeRenderPlan(vf, is3d, hline) {
114565
+ changeRenderPlan(vf, is3d, hline, contour) {
111910
114566
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(1 === this.length);
111911
- this.top.changeRenderPlan(vf, is3d, hline);
114567
+ this.top.changeRenderPlan(vf, is3d, hline, contour);
111912
114568
  }
111913
114569
  setSymbologyOverrides(ovrs) {
111914
114570
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(1 === this.length);
@@ -111971,16 +114627,18 @@ class BranchState {
111971
114627
  get inSectionDrawingAttachment() { return this._opts.inSectionDrawingAttachment; }
111972
114628
  get groupNodeId() { return this._opts.groupNodeId; }
111973
114629
  get disableClipStyle() { return this._opts.disableClipStyle; }
114630
+ get contourLine() { return this._opts.contourLine; }
111974
114631
  get symbologyOverrides() {
111975
114632
  return this._opts.symbologyOverrides;
111976
114633
  }
111977
114634
  set symbologyOverrides(ovrs) {
111978
114635
  this._opts.symbologyOverrides = ovrs;
111979
114636
  }
111980
- changeRenderPlan(viewFlags, is3d, hline) {
114637
+ changeRenderPlan(viewFlags, is3d, hline, contour) {
111981
114638
  this.viewFlags = viewFlags;
111982
114639
  this._opts.is3d = is3d;
111983
114640
  this.edgeSettings.init(hline);
114641
+ this._opts.contourLine = contour;
111984
114642
  }
111985
114643
  /** Create a BranchState from a Branch. Any properties not explicitly specified by the new Branch are inherited from the previous BranchState. */
111986
114644
  static fromBranch(prev, branch) {
@@ -112005,6 +114663,7 @@ class BranchState {
112005
114663
  inSectionDrawingAttachment: branch.inSectionDrawingAttachment ?? prev.inSectionDrawingAttachment,
112006
114664
  groupNodeId: branch.branch.groupNodeId ?? prev.groupNodeId,
112007
114665
  disableClipStyle: branch.disableClipStyle ?? prev.disableClipStyle,
114666
+ contourLine: branch.contourLine ?? prev.contourLine,
112008
114667
  });
112009
114668
  }
112010
114669
  getFeatureAppearance(overrides, elemLo, elemHi, subcatLo, subcatHi, geomClass, modelLo, modelHi, type, animationNodeId) {
@@ -112167,8 +114826,8 @@ class BranchUniforms {
112167
114826
  this._viewClipEnabled = false;
112168
114827
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)((this._target.isReadPixelsInProgress ? 2 : 1) === this._stack.length);
112169
114828
  }
112170
- changeRenderPlan(vf, is3d, hline) {
112171
- this._stack.changeRenderPlan(vf, is3d, hline);
114829
+ changeRenderPlan(vf, is3d, hline, contourLine) {
114830
+ this._stack.changeRenderPlan(vf, is3d, hline, contourLine);
112172
114831
  }
112173
114832
  updateViewClip(clip, style) {
112174
114833
  this.clipStack.setViewClip(clip, style);
@@ -113930,12 +116589,11 @@ class ContourUniforms {
113930
116589
  this._contourDefs[startNdx + offset + 1] = majorIntervalCount < 1.0 ? 1.0 : majorIntervalCount;
113931
116590
  }
113932
116591
  update(target) {
113933
- const plan = target.plan;
113934
- if (this.contourDisplay && plan.contours && this.contourDisplay.equals(plan.contours)) {
116592
+ if (this.contourDisplay && target.currentContours && this.contourDisplay.equals(target.currentContours)) {
113935
116593
  return;
113936
116594
  }
113937
116595
  (0,_Sync__WEBPACK_IMPORTED_MODULE_1__.desync)(this);
113938
- this._contourDisplay = plan.contours;
116596
+ this._contourDisplay = target.currentContours;
113939
116597
  if (undefined === this.contourDisplay)
113940
116598
  return;
113941
116599
  /* uniform packing for contourDefs:
@@ -114025,14 +116683,14 @@ class Contours {
114025
116683
  return target === this.target && this._numFeatures === map.numFeatures;
114026
116684
  }
114027
116685
  matchesSubCategories() {
114028
- if (this._contours === undefined && this.target.plan.contours === undefined)
116686
+ if (this._contours === undefined && this.target.currentContours === undefined)
114029
116687
  return true;
114030
- if (this._contours === undefined || this.target.plan.contours === undefined)
116688
+ if (this._contours === undefined || this.target.currentContours === undefined)
114031
116689
  return false;
114032
- if (this._contours.groups.length !== this.target.plan.contours.groups.length)
116690
+ if (this._contours.groups.length !== this.target.currentContours.groups.length)
114033
116691
  return false;
114034
116692
  for (let index = 0, len = this._contours.groups.length; index < len && index < _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.ContourDisplay.maxContourGroups; ++index) {
114035
- if (!this._contours.groups[index].subCategoriesEqual(this.target.plan.contours.groups[index]))
116693
+ if (!this._contours.groups[index].subCategoriesEqual(this.target.currentContours.groups[index]))
114036
116694
  return false;
114037
116695
  }
114038
116696
  return true;
@@ -114046,14 +116704,14 @@ class Contours {
114046
116704
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(width * height * 8 >= this._numFeatures);
114047
116705
  const data = new Uint8Array(width * height * 4);
114048
116706
  const creator = new _Texture__WEBPACK_IMPORTED_MODULE_5__.Texture2DDataUpdater(data);
114049
- this.buildLookupTable(creator, map, this.target.plan.contours);
116707
+ this.buildLookupTable(creator, map, this.target.currentContours);
114050
116708
  this._lut = _Texture__WEBPACK_IMPORTED_MODULE_5__.TextureHandle.createForData(width, height, data, true, _GL__WEBPACK_IMPORTED_MODULE_2__.GL.Texture.WrapMode.ClampToEdge);
114051
116709
  this._lutWidth = width;
114052
116710
  }
114053
116711
  _update(map, lut) {
114054
116712
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(this._numFeatures === map.numFeatures);
114055
116713
  const updater = new _Texture__WEBPACK_IMPORTED_MODULE_5__.Texture2DDataUpdater(lut.dataBytes);
114056
- this.buildLookupTable(updater, map, this.target.plan.contours);
116714
+ this.buildLookupTable(updater, map, this.target.currentContours);
114057
116715
  lut.update(updater);
114058
116716
  }
114059
116717
  buildLookupTable(data, map, contours) {
@@ -114091,7 +116749,7 @@ class Contours {
114091
116749
  constructor(target, options) {
114092
116750
  this.target = target;
114093
116751
  this._options = options;
114094
- this._contours = target.plan.contours;
116752
+ this._contours = target.currentContours;
114095
116753
  }
114096
116754
  static createFromTarget(target, options) {
114097
116755
  return new Contours(target, options);
@@ -114108,7 +116766,7 @@ class Contours {
114108
116766
  update(features) {
114109
116767
  if (this.matchesSubCategories())
114110
116768
  return;
114111
- this._contours = this.target.plan.contours;
116769
+ this._contours = this.target.currentContours;
114112
116770
  // _lut can be undefined if context was lost, (gl.createTexture returns null)
114113
116771
  if (this._lut) {
114114
116772
  this._update(features, this._lut);
@@ -116873,6 +119531,7 @@ class Branch extends Graphic {
116873
119531
  inSectionDrawingAttachment;
116874
119532
  disableClipStyle;
116875
119533
  transformFromExternalIModel;
119534
+ contourLine;
116876
119535
  constructor(branch, localToWorld, viewFlags, opts) {
116877
119536
  super();
116878
119537
  this.branch = branch;
@@ -116889,6 +119548,7 @@ class Branch extends Graphic {
116889
119548
  this.inSectionDrawingAttachment = opts.inSectionDrawingAttachment;
116890
119549
  this.disableClipStyle = opts.disableClipStyle;
116891
119550
  this.transformFromExternalIModel = opts.transformFromIModel;
119551
+ this.contourLine = opts.contours;
116892
119552
  if (opts.hline)
116893
119553
  this.edgeSettings = _EdgeSettings__WEBPACK_IMPORTED_MODULE_6__.EdgeSettings.create(opts.hline);
116894
119554
  if (opts.classifierOrDrape instanceof _PlanarClassifier__WEBPACK_IMPORTED_MODULE_8__.PlanarClassifier)
@@ -123869,7 +126529,7 @@ class Compositor extends SceneCompositor {
123869
126529
  }
123870
126530
  readContours(rect) {
123871
126531
  // Are we actually drawing any contours? If not, don't bother reading an array of all zeroes off the GPU.
123872
- const contours = this.target.plan.contours;
126532
+ const contours = this.target.currentContours;
123873
126533
  if (!contours || !contours.displayContours || contours.groups.length === 0) {
123874
126534
  return undefined;
123875
126535
  }
@@ -124047,6 +126707,7 @@ class Compositor extends SceneCompositor {
124047
126707
  iModel: top.iModel,
124048
126708
  is3d: top.is3d,
124049
126709
  edgeSettings: top.edgeSettings,
126710
+ contourLine: top.contourLine,
124050
126711
  });
124051
126712
  this._vcSetStencilRenderState = new _RenderState__WEBPACK_IMPORTED_MODULE_14__.RenderState();
124052
126713
  this._vcCopyZRenderState = new _RenderState__WEBPACK_IMPORTED_MODULE_14__.RenderState();
@@ -128519,6 +131180,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
128519
131180
  const drape = this.currentTextureDrape;
128520
131181
  return undefined === drape ? this.currentPlanarClassifier : drape;
128521
131182
  }
131183
+ get currentContours() { return this.currentBranch.contourLine; }
128522
131184
  modelToView(modelPt, result) {
128523
131185
  return this.uniforms.branch.modelViewMatrix.multiplyPoint3dQuietNormalize(modelPt, result);
128524
131186
  }
@@ -128729,7 +131391,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
128729
131391
  this._wantAmbientOcclusion = false;
128730
131392
  vf = vf.with("ambientOcclusion", false);
128731
131393
  }
128732
- this.uniforms.branch.changeRenderPlan(vf, plan.is3d, plan.hline);
131394
+ this.uniforms.branch.changeRenderPlan(vf, plan.is3d, plan.hline, plan.contours);
128733
131395
  this.changeFrustum(plan.frustum, plan.fraction, plan.is3d);
128734
131396
  this.uniforms.thematic.update(this);
128735
131397
  this.uniforms.contours.update(this);
@@ -129028,6 +131690,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
129028
131690
  edgeSettings: top.edgeSettings,
129029
131691
  transform: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createIdentity(),
129030
131692
  clipVolume: top.clipVolume,
131693
+ contourLine: top.contourLine,
129031
131694
  });
129032
131695
  this.pushState(state);
129033
131696
  // Repopulate the command list, omitting non-pickable decorations and putting transparent stuff into the opaque passes.
@@ -182721,7 +185384,7 @@ class Geometry {
182721
185384
  static largeCoordinateResult = 1.0e13;
182722
185385
  /**
182723
185386
  * Numeric value that may considered infinite for metric coordinates.
182724
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[largeCoordinateResult]].
185387
+ * @deprecated in 4.9.0 - will not be removed until after 2026-06-13. Use [[largeCoordinateResult]].
182725
185388
  * * This coordinate should be used only as a placeholder indicating "at infinity" -- computing actual
182726
185389
  * points at this coordinate invites numerical problems.
182727
185390
  */
@@ -182732,7 +185395,7 @@ class Geometry {
182732
185395
  }
182733
185396
  /**
182734
185397
  * Test if the absolute value of x is at least [[largeCoordinateResult]].
182735
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[isLargeCoordinateResult]].
185398
+ * @deprecated in 4.9.0 - will not be removed until after 2026-06-13. Use [[isLargeCoordinateResult]].
182736
185399
  */
182737
185400
  static isHugeCoordinate(x) {
182738
185401
  return Geometry.isLargeCoordinateResult(x);
@@ -183699,7 +186362,7 @@ class Geometry {
183699
186362
  /**
183700
186363
  * Clone an array whose members have type `T`, which implements the clone method.
183701
186364
  * * If the clone method returns `undefined`, then `undefined` is forced into the cloned array.
183702
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use cloneArray.
186365
+ * @deprecated in 4.4.0 - will not be removed until after 2026-06-13. Use cloneArray.
183703
186366
  */
183704
186367
  // eslint-disable-next-line @typescript-eslint/no-deprecated
183705
186368
  static cloneMembers(array) {
@@ -184125,7 +186788,7 @@ class BSpline1dNd {
184125
186788
  * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
184126
186789
  * which has been expanded to act as a normal bspline.
184127
186790
  * @returns true if `degree` leading and trailing polygon blocks match.
184128
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use `testClosablePolygon` instead.
186791
+ * @deprecated in 4.2.1 - will not be removed until after 2026-06-13. Use `testClosablePolygon` instead.
184129
186792
  */
184130
186793
  testCloseablePolygon(mode) {
184131
186794
  return this.testClosablePolygon(mode);
@@ -186425,7 +189088,7 @@ var UVSelect;
186425
189088
  UVSelect[UVSelect["uDirection"] = 0] = "uDirection";
186426
189089
  /**
186427
189090
  * index of v direction
186428
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use vDirection instead.
189091
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use vDirection instead.
186429
189092
  */
186430
189093
  UVSelect[UVSelect["VDirection"] = 1] = "VDirection";
186431
189094
  /** index of v direction */
@@ -186652,7 +189315,7 @@ class BSpline2dNd extends _curve_GeometryQuery__WEBPACK_IMPORTED_MODULE_0__.Geom
186652
189315
  }
186653
189316
  /**
186654
189317
  * sum poles by the weights in the basisBuffer, using poles for given span
186655
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use sumPoleBufferDerivativesForSpan instead.
189318
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use sumPoleBufferDerivativesForSpan instead.
186656
189319
  */
186657
189320
  sumpoleBufferDerivativesForSpan(spanIndexU, spanIndexV) {
186658
189321
  return this.sumPoleBufferDerivativesForSpan(spanIndexU, spanIndexV);
@@ -200012,7 +202675,7 @@ class CurveLocationDetailPair {
200012
202675
  }
200013
202676
  /**
200014
202677
  * Data bundle for a pair of arrays of CurveLocationDetail structures.
200015
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use CurveLocationDetailPair[] instead.
202678
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use CurveLocationDetailPair[] instead.
200016
202679
  * @public
200017
202680
  */
200018
202681
  class CurveLocationDetailArrayPair {
@@ -207998,7 +210661,7 @@ class StrokeOptions {
207998
210661
  maxEdgeLength;
207999
210662
  /**
208000
210663
  * Caller expects convex facets.
208001
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].
210664
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].
208002
210665
  */
208003
210666
  needConvexFacets;
208004
210667
  /** Minimum strokes on a primitive. */
@@ -222266,7 +224929,7 @@ class GrowableXYArray extends _IndexedXYCollection__WEBPACK_IMPORTED_MODULE_0__.
222266
224929
  return result;
222267
224930
  }
222268
224931
  /** Restructure MultiLineStringDataVariant as array of GrowableXYZArray
222269
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Moved to GrowableXYZArray class.
224932
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Moved to GrowableXYZArray class.
222270
224933
  */
222271
224934
  static createArrayOfGrowableXYZArray(data) {
222272
224935
  return _GrowableXYZArray__WEBPACK_IMPORTED_MODULE_1__.GrowableXYZArray.createArrayOfGrowableXYZArray(data);
@@ -240960,7 +243623,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
240960
243623
  * extract 4 consecutive numbers from a Float64Array into a Point4d.
240961
243624
  * @param data buffer of numbers
240962
243625
  * @param xIndex first index for x,y,z,w sequence. Assumed to be a valid index!
240963
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use createFromPacked instead.
243626
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use createFromPacked instead.
240964
243627
  */
240965
243628
  static createFromPackedXYZW(data, xIndex = 0, result) {
240966
243629
  return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);
@@ -250288,7 +252951,7 @@ class IndexedPolyface extends Polyface {
250288
252951
  }
250289
252952
  /**
250290
252953
  * Clean up the open facet.
250291
- * @deprecated in 4.x - will not be removed until after 2026-06-13. To remove nebulous "open facet" concept from the API. Call [[PolyfaceData.trimAllIndexArrays]]
252954
+ * @deprecated in 4.5.0 - will not be removed until after 2026-06-13. To remove nebulous "open facet" concept from the API. Call [[PolyfaceData.trimAllIndexArrays]]
250292
252955
  * instead.
250293
252956
  */
250294
252957
  cleanupOpenFacet() {
@@ -250438,7 +253101,7 @@ class IndexedPolyface extends Polyface {
250438
253101
  }
250439
253102
  /**
250440
253103
  * Given the index of a facet, return the data pertaining to the face it is a part of.
250441
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.
253104
+ * @deprecated in 4.5.0 - will not be removed until after 2026-06-13. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.
250442
253105
  */
250443
253106
  getFaceDataByFacetIndex(facetIndex) {
250444
253107
  return this.data.face[this._facetToFaceData[facetIndex]];
@@ -251660,7 +254323,7 @@ class PolyfaceBuilder extends _geometry3d_GeometryHandler__WEBPACK_IMPORTED_MODU
251660
254323
  * Apply stroke counts to curve primitives.
251661
254324
  * * Recursively visit all children of data.
251662
254325
  * * At each primitive, invoke `computeStrokeCountForOptions` method with options from the builder.
251663
- * @deprecated in 4.x - will not be removed until after 2026-06-13. This method does nothing and is unneeded.
254326
+ * @deprecated in 4.8.0 - will not be removed until after 2026-06-13. This method does nothing and is unneeded.
251664
254327
  */
251665
254328
  applyStrokeCountsToCurvePrimitives(data) {
251666
254329
  const options = this._options;
@@ -253699,7 +256362,7 @@ class PolyfaceData {
253699
256362
  }
253700
256363
  /**
253701
256364
  * Resize all data arrays to the specified `length`.
253702
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Because name is misleading. Call [[PolyfaceData.resizeAllArrays]] instead.
256365
+ * @deprecated in 4.5.0 - will not be removed until after 2026-06-13. Because name is misleading. Call [[PolyfaceData.resizeAllArrays]] instead.
253703
256366
  */
253704
256367
  resizeAllDataArrays(length) {
253705
256368
  if (length > this.point.length) {
@@ -255271,7 +257934,7 @@ class PolyfaceQuery {
255271
257934
  });
255272
257935
  return builder.claimPolyface(true);
255273
257936
  }
255274
- /** @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[sweepLineStringToFacetsXYReturnSweptFacets]] instead. */
257937
+ /** @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[sweepLineStringToFacetsXYReturnSweptFacets]] instead. */
255275
257938
  static sweepLinestringToFacetsXYreturnSweptFacets(linestringPoints, polyface) {
255276
257939
  return this.sweepLineStringToFacetsXYReturnSweptFacets(linestringPoints, polyface);
255277
257940
  }
@@ -255374,7 +258037,7 @@ class PolyfaceQuery {
255374
258037
  * * Return collected line segments.
255375
258038
  * * This calls [[sweepLineStringToFacets]] with options created by
255376
258039
  * `const options = SweepLineStringToFacetsOptions.create(Vector3d.unitZ(), Angle.createSmallAngle(), false, true, true, true);`
255377
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
258040
+ * @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
255378
258041
  */
255379
258042
  static sweepLinestringToFacetsXYReturnLines(linestringPoints, polyface) {
255380
258043
  const options = SweepLineStringToFacetsOptions.create(_geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_1__.Vector3d.unitZ(), _geometry3d_Angle__WEBPACK_IMPORTED_MODULE_2__.Angle.createSmallAngle(), false, true, true, true);
@@ -255384,7 +258047,7 @@ class PolyfaceQuery {
255384
258047
  * Find segments (within the linestring) which project to facets.
255385
258048
  * * Return chains.
255386
258049
  * * This calls [[sweepLineStringToFacets]] with default options.
255387
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
258050
+ * @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
255388
258051
  */
255389
258052
  static sweepLinestringToFacetsXYReturnChains(linestringPoints, polyface) {
255390
258053
  return PolyfaceQuery.sweepLineStringToFacets(linestringPoints, polyface);
@@ -269181,7 +271844,7 @@ class Sample {
269181
271844
  return points;
269182
271845
  }
269183
271846
  // cspell:word creat
269184
- /** @deprecated in 4.x - will not be removed until after 2026-06-13. Use createVerticalStaggerPolygon instead. */
271847
+ /** @deprecated in 4.0.0 - will not be removed until after 2026-06-13. Use createVerticalStaggerPolygon instead. */
269185
271848
  static creatVerticalStaggerPolygon(dy1, dy2, dy3, dy4, ax, ay, dx1, dx4) {
269186
271849
  return this.createVerticalStaggerPolygon(dy1, dy2, dy3, dy4, ax, ay, dx1, dx4);
269187
271850
  }
@@ -298784,7 +301447,7 @@ class QuantityConstants {
298784
301447
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
298785
301448
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = ",";
298786
301449
  const matches = (12345.6789).toLocaleString().match(/12(.*)345/);
298787
- if (matches && matches.length > 0)
301450
+ if (matches && matches.length > 1 && matches[1] !== "")
298788
301451
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];
298789
301452
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
298790
301453
  }
@@ -302784,7 +305447,7 @@ class UiAdmin {
302784
305447
  /** Get the cursor X and Y position. */
302785
305448
  get cursorPosition() { return { x: 0, y: 0 }; }
302786
305449
  /** Create a PointProps object.
302787
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation.
305450
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation.
302788
305451
  */
302789
305452
  createXAndY(x, y) { return { x, y }; }
302790
305453
  /** Determines if focus is set to Home */
@@ -303087,7 +305750,7 @@ __webpack_require__.r(__webpack_exports__);
303087
305750
  /**
303088
305751
  * Class that define Standard Content Layouts that can be used to specify how the content is arranged in a frontstage.
303089
305752
  * @public
303090
- * @deprecated in 4.10.x - will not be removed until after 2026-06-13. Use `StandardContentLayouts` from `@itwin/appui-react`.
305753
+ * @deprecated in 4.10.0 - will not be removed until after 2026-06-13. Use `StandardContentLayouts` from `@itwin/appui-react`.
303091
305754
  */
303092
305755
  class StandardContentLayouts {
303093
305756
  static singleView = {
@@ -304746,14 +307409,15 @@ __webpack_require__.r(__webpack_exports__);
304746
307409
 
304747
307410
  /** UiSync Event class.
304748
307411
  * @public
304749
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Use [[UiSyncEvent]] from @itwin/appui-react.
307412
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use [[UiSyncEvent]] from @itwin/appui-react.
304750
307413
  */
307414
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
304751
307415
  class UiSyncEvent extends _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BeUiEvent {
304752
307416
  }
304753
307417
  /** This class is used to send eventIds to interested UI components so the component can determine if it needs
304754
307418
  * to refresh its display by calling setState on itself.
304755
307419
  * @public
304756
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Use [[SyncUiEventDispatcher]] from @itwin/appui-react.
307420
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use [[SyncUiEventDispatcher]] from @itwin/appui-react.
304757
307421
  */
304758
307422
  class UiEventDispatcher {
304759
307423
  _syncEventTimerId;
@@ -315117,7 +317781,7 @@ var loadLanguages = instance.loadLanguages;
315117
317781
  /***/ ((module) => {
315118
317782
 
315119
317783
  "use strict";
315120
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.1.0-dev.59","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/eslint-plugin":"5.0.0-dev.1","@types/chai-as-promised":"^7","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.13.0","glob":"^10.3.12","playwright":"~1.47.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","typemoq":"^2.1.0","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/cloud-agnostic-core":"^2.2.4","@itwin/object-storage-core":"^2.3.0","@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
317784
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.1.0-dev.61","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/eslint-plugin":"5.2.2-dev.2","@types/chai-as-promised":"^7","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^10.3.12","playwright":"~1.47.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","typemoq":"^2.1.0","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/cloud-agnostic-core":"^2.2.4","@itwin/object-storage-core":"^2.3.0","@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^3.1.6","@loaders.gl/draco":"^3.1.6","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
315121
317785
 
315122
317786
  /***/ })
315123
317787