@itwin/rpcinterface-full-stack-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.
@@ -60476,6 +60476,7 @@ var PrimitiveTypeCode;
60476
60476
  * @beta
60477
60477
  * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use the `Property` class from @itwin/ecschema-metadata` instead.
60478
60478
  */
60479
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
60479
60480
  class PropertyMetaData {
60480
60481
  primitiveType;
60481
60482
  structName;
@@ -60561,6 +60562,7 @@ class PropertyMetaData {
60561
60562
  * @beta
60562
60563
  * @deprecated in 5.0 - will not be removed until after 2026-06-13. Use `EntityClass` class from `@itwin/ecschema-metadata` instead.
60563
60564
  */
60565
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
60564
60566
  class EntityMetaData {
60565
60567
  /** The Id of the class in the [[IModelDb]] from which the metadata was obtained. */
60566
60568
  classId;
@@ -84636,7 +84638,7 @@ class IModelReadRpcInterface extends _RpcInterface__WEBPACK_IMPORTED_MODULE_0__.
84636
84638
  async getViewStateData(_iModelToken, _viewDefinitionId, _options) { return this.forward(arguments); }
84637
84639
  async readFontJson(_iModelToken) { return this.forward(arguments); } // eslint-disable-line @typescript-eslint/no-deprecated
84638
84640
  async getToolTipMessage(_iModelToken, _elementId) { return this.forward(arguments); }
84639
- /** @deprecated in 3.x - might be removed in next major version. Use ViewStore apis. */
84641
+ /** @deprecated in 3.3.0 - might be removed in next major version. Use ViewStore apis. */
84640
84642
  async getViewThumbnail(_iModelToken, _viewId) { return this.forward(arguments); }
84641
84643
  async getDefaultViewId(_iModelToken) { return this.forward(arguments); }
84642
84644
  async getCustomViewState3dData(_iModelToken, _options) { return this.forward(arguments); }
@@ -90622,8 +90624,11 @@ class SchemaReadHelper {
90622
90624
  * calling getCachedSchema on the context.
90623
90625
  * @param schema The Schema to populate
90624
90626
  * @param rawSchema The serialized data to use to populate the Schema.
90627
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
90628
+ * The default is true. If false, the schema loading will not begin asynchronously in the background because the
90629
+ * schema promise must be added to the context. In this case, only the SchemaInfo is returned.
90625
90630
  */
90626
- async readSchemaInfo(schema, rawSchema) {
90631
+ async readSchemaInfo(schema, rawSchema, addSchemaToCache = true) {
90627
90632
  // Ensure context matches schema context
90628
90633
  if (schema.context) {
90629
90634
  if (this._context !== schema.context)
@@ -90636,15 +90641,15 @@ class SchemaReadHelper {
90636
90641
  // Loads all of the properties on the Schema object
90637
90642
  await schema.fromJSON(this._parser.parseSchema());
90638
90643
  this._schema = schema;
90639
- const schemaInfoReferences = [];
90640
- const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaInfoReferences };
90644
+ const schemaReferences = [];
90645
+ const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaReferences };
90641
90646
  for (const reference of this._parser.getReferences()) {
90642
90647
  const refKey = new _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey(reference.name, _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.ECVersion.fromString(reference.version));
90643
- schemaInfoReferences.push({ schemaKey: refKey });
90648
+ schemaReferences.push({ schemaKey: refKey });
90644
90649
  }
90645
90650
  this._schemaInfo = schemaInfo;
90646
90651
  // Need to add this schema to the context to be able to locate schemaItems within the context.
90647
- if (!this._context.schemaExists(schema.schemaKey)) {
90652
+ if (addSchemaToCache && !this._context.schemaExists(schema.schemaKey)) {
90648
90653
  await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));
90649
90654
  }
90650
90655
  return schemaInfo;
@@ -90653,33 +90658,53 @@ class SchemaReadHelper {
90653
90658
  * Populates the given Schema from a serialized representation.
90654
90659
  * @param schema The Schema to populate
90655
90660
  * @param rawSchema The serialized data to use to populate the Schema.
90661
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
90662
+ * The default is true. If false, the schema will be loaded directly by this method and not from the context's schema cache.
90656
90663
  */
90657
- async readSchema(schema, rawSchema) {
90664
+ async readSchema(schema, rawSchema, addSchemaToCache = true) {
90658
90665
  if (!this._schemaInfo) {
90659
- await this.readSchemaInfo(schema, rawSchema);
90666
+ await this.readSchemaInfo(schema, rawSchema, addSchemaToCache);
90667
+ }
90668
+ // If not adding schema to cache (occurs in readSchemaInfo), we must load the schema here
90669
+ if (!addSchemaToCache) {
90670
+ const loadedSchema = await this.loadSchema(this._schemaInfo, schema);
90671
+ if (undefined === loadedSchema)
90672
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
90673
+ return loadedSchema;
90660
90674
  }
90661
90675
  const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.Latest);
90662
90676
  if (undefined === cachedSchema)
90663
90677
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
90664
90678
  return cachedSchema;
90665
90679
  }
90680
+ /**
90681
+ * Called when a SchemaItem has been successfully loaded by the Helper. The default implementation simply
90682
+ * checks if the schema item is undefined. An implementation of the helper may choose to partially load
90683
+ * a schema item in which case this method would indicate if the item has been fully loaded.
90684
+ * @param schemaItem The SchemaItem to check.
90685
+ * @returns True if the SchemaItem has been fully loaded, false otherwise.
90686
+ */
90687
+ isSchemaItemLoaded(schemaItem) {
90688
+ return schemaItem !== undefined;
90689
+ }
90666
90690
  /* Finish loading the rest of the schema */
90667
90691
  async loadSchema(schemaInfo, schema) {
90668
90692
  // Verify that there are no schema reference cycles, this will start schema loading by loading their headers
90669
90693
  (await _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_8__.SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();
90670
90694
  for (const reference of schemaInfo.references) {
90671
- await this.loadSchemaReference(schemaInfo, reference.schemaKey);
90695
+ await this.loadSchemaReference(schema, reference.schemaKey);
90672
90696
  }
90673
90697
  if (this._visitorHelper)
90674
90698
  await this._visitorHelper.visitSchema(schema, false);
90675
90699
  // Load all schema items
90676
90700
  for (const [itemName, itemType, rawItem] of this._parser.getItems()) {
90677
- // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,
90701
+ // Make sure the item has not already been loaded. No need to check the SchemaContext because all SchemaItems are added to a Schema,
90678
90702
  // which would be found when adding to the context.
90679
- if (await schema.getItem(itemName) !== undefined)
90703
+ const schemaItem = await schema.getItem(itemName);
90704
+ if (this.isSchemaItemLoaded(schemaItem))
90680
90705
  continue;
90681
90706
  const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);
90682
- if (loadedItem && this._visitorHelper) {
90707
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
90683
90708
  await this._visitorHelper.visitSchemaPart(loadedItem);
90684
90709
  }
90685
90710
  }
@@ -90710,12 +90735,8 @@ class SchemaReadHelper {
90710
90735
  this._visitorHelper.visitSchemaSync(schema, false);
90711
90736
  // Load all schema items
90712
90737
  for (const [itemName, itemType, rawItem] of this._parser.getItems()) {
90713
- // Make sure the item has not already been read. No need to check the SchemaContext because all SchemaItems are added to a Schema,
90714
- // which would be found when adding to the context.
90715
- if (schema.getItemSync(itemName) !== undefined)
90716
- continue;
90717
90738
  const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);
90718
- if (loadedItem && this._visitorHelper) {
90739
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
90719
90740
  this._visitorHelper.visitSchemaPartSync(loadedItem);
90720
90741
  }
90721
90742
  }
@@ -90728,12 +90749,14 @@ class SchemaReadHelper {
90728
90749
  * Ensures that the schema references can be located and adds them to the schema.
90729
90750
  * @param ref The object to read the SchemaReference's props from.
90730
90751
  */
90731
- async loadSchemaReference(schemaInfo, refKey) {
90752
+ async loadSchemaReference(schema, refKey) {
90732
90753
  const refSchema = await this._context.getSchema(refKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.LatestWriteCompatible);
90733
90754
  if (undefined === refSchema)
90734
- 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}`);
90735
- await this._schema.addReference(refSchema);
90736
- const results = this.validateSchemaReferences(this._schema);
90755
+ 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}`);
90756
+ if (schema.references.find((ref) => ref.schemaKey.matches(refSchema.schemaKey)))
90757
+ return refSchema;
90758
+ await schema.addReference(refSchema);
90759
+ const results = this.validateSchemaReferences(schema);
90737
90760
  let errorMessage = "";
90738
90761
  for (const result of results) {
90739
90762
  errorMessage += `${result}\r\n`;
@@ -90741,6 +90764,7 @@ class SchemaReadHelper {
90741
90764
  if (errorMessage) {
90742
90765
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `${errorMessage}`);
90743
90766
  }
90767
+ return refSchema;
90744
90768
  }
90745
90769
  /**
90746
90770
  * Ensures that the schema references can be located and adds them to the schema.
@@ -90790,73 +90814,97 @@ class SchemaReadHelper {
90790
90814
  * @param schemaItemObject The Object to populate the SchemaItem with.
90791
90815
  */
90792
90816
  async loadSchemaItem(schema, name, itemType, schemaItemObject) {
90793
- let schemaItem;
90817
+ let schemaItem = await schema.getItem(name);
90818
+ if (this.isSchemaItemLoaded(schemaItem)) {
90819
+ return schemaItem;
90820
+ }
90794
90821
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
90795
90822
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
90796
- schemaItem = await schema.createEntityClass(name);
90797
- await this.loadEntityClass(schemaItem, schemaItemObject);
90823
+ schemaItem = schemaItem || await schema.createEntityClass(name);
90824
+ schemaItemObject && await this.loadEntityClass(schemaItem, schemaItemObject);
90798
90825
  break;
90799
90826
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
90800
- schemaItem = await schema.createStructClass(name);
90801
- const structProps = this._parser.parseStructClass(schemaItemObject);
90802
- await this.loadClass(schemaItem, structProps, schemaItemObject);
90827
+ schemaItem = schemaItem || await schema.createStructClass(name);
90828
+ const structProps = schemaItemObject && this._parser.parseStructClass(schemaItemObject);
90829
+ structProps && await this.loadClass(schemaItem, structProps, schemaItemObject);
90803
90830
  break;
90804
90831
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
90805
- schemaItem = await schema.createMixinClass(name);
90806
- await this.loadMixin(schemaItem, schemaItemObject);
90832
+ schemaItem = schemaItem || await schema.createMixinClass(name);
90833
+ schemaItemObject && await this.loadMixin(schemaItem, schemaItemObject);
90807
90834
  break;
90808
90835
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
90809
- schemaItem = await schema.createCustomAttributeClass(name);
90810
- const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);
90811
- await this.loadClass(schemaItem, caClassProps, schemaItemObject);
90836
+ schemaItem = schemaItem || await schema.createCustomAttributeClass(name);
90837
+ const caClassProps = schemaItemObject && this._parser.parseCustomAttributeClass(schemaItemObject);
90838
+ caClassProps && await this.loadClass(schemaItem, caClassProps, schemaItemObject);
90812
90839
  break;
90813
90840
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
90814
- schemaItem = await schema.createRelationshipClass(name);
90815
- await this.loadRelationshipClass(schemaItem, schemaItemObject);
90841
+ schemaItem = schemaItem || await schema.createRelationshipClass(name);
90842
+ schemaItemObject && await this.loadRelationshipClass(schemaItem, schemaItemObject);
90816
90843
  break;
90817
90844
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
90818
- schemaItem = await schema.createKindOfQuantity(name);
90819
- await this.loadKindOfQuantity(schemaItem, schemaItemObject);
90845
+ schemaItem = schemaItem || await schema.createKindOfQuantity(name);
90846
+ schemaItemObject && await this.loadKindOfQuantity(schemaItem, schemaItemObject);
90820
90847
  break;
90821
90848
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
90822
- schemaItem = await schema.createUnit(name);
90823
- await this.loadUnit(schemaItem, schemaItemObject);
90849
+ schemaItem = schemaItem || await schema.createUnit(name);
90850
+ schemaItemObject && await this.loadUnit(schemaItem, schemaItemObject);
90824
90851
  break;
90825
90852
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
90826
- schemaItem = await schema.createConstant(name);
90827
- await this.loadConstant(schemaItem, schemaItemObject);
90853
+ schemaItem = schemaItem || await schema.createConstant(name);
90854
+ schemaItemObject && await this.loadConstant(schemaItem, schemaItemObject);
90828
90855
  break;
90829
90856
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
90830
- schemaItem = await schema.createInvertedUnit(name);
90831
- await this.loadInvertedUnit(schemaItem, schemaItemObject);
90857
+ schemaItem = schemaItem || await schema.createInvertedUnit(name);
90858
+ schemaItemObject && await this.loadInvertedUnit(schemaItem, schemaItemObject);
90832
90859
  break;
90833
90860
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
90834
- schemaItem = await schema.createFormat(name);
90835
- await this.loadFormat(schemaItem, schemaItemObject);
90861
+ schemaItem = schemaItem || await schema.createFormat(name);
90862
+ schemaItemObject && await this.loadFormat(schemaItem, schemaItemObject);
90836
90863
  break;
90837
90864
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Phenomenon:
90838
- schemaItem = await schema.createPhenomenon(name);
90839
- const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);
90840
- await schemaItem.fromJSON(phenomenonProps);
90865
+ schemaItem = schemaItem || await schema.createPhenomenon(name);
90866
+ const phenomenonProps = schemaItemObject && this._parser.parsePhenomenon(schemaItemObject);
90867
+ phenomenonProps && await schemaItem.fromJSON(phenomenonProps);
90841
90868
  break;
90842
90869
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
90843
- schemaItem = await schema.createUnitSystem(name);
90844
- await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
90870
+ schemaItem = schemaItem || await schema.createUnitSystem(name);
90871
+ schemaItemObject && await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
90845
90872
  break;
90846
90873
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.PropertyCategory:
90847
- schemaItem = await schema.createPropertyCategory(name);
90848
- const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);
90849
- await schemaItem.fromJSON(propertyCategoryProps);
90874
+ schemaItem = schemaItem || await schema.createPropertyCategory(name);
90875
+ const propertyCategoryProps = schemaItemObject && this._parser.parsePropertyCategory(schemaItemObject);
90876
+ propertyCategoryProps && schemaItemObject && await schemaItem.fromJSON(propertyCategoryProps);
90850
90877
  break;
90851
90878
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Enumeration:
90852
- schemaItem = await schema.createEnumeration(name);
90853
- const enumerationProps = this._parser.parseEnumeration(schemaItemObject);
90854
- await schemaItem.fromJSON(enumerationProps);
90879
+ schemaItem = schemaItem || await schema.createEnumeration(name);
90880
+ const enumerationProps = schemaItemObject && this._parser.parseEnumeration(schemaItemObject);
90881
+ enumerationProps && await schemaItem.fromJSON(enumerationProps);
90855
90882
  break;
90856
90883
  // 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
90857
90884
  }
90858
90885
  return schemaItem;
90859
90886
  }
90887
+ /**
90888
+ * Load the customAttribute class dependencies for a set of CustomAttribute objects and add
90889
+ * them to a given custom attribute container.
90890
+ * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
90891
+ * @param customAttributes An iterable set of parsed CustomAttribute objects.
90892
+ */
90893
+ async loadCustomAttributes(container, caProviders) {
90894
+ for (const providerTuple of caProviders) {
90895
+ // First tuple entry is the CA class name.
90896
+ const caClass = await this.findSchemaItem(providerTuple[0]);
90897
+ // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
90898
+ if (caClass && caClass.key.schemaName !== container.schema.name &&
90899
+ !container.schema.getReferenceSync(caClass.key.schemaName)) {
90900
+ 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`);
90901
+ }
90902
+ // Second tuple entry ia a function that provides the CA instance.
90903
+ const provider = providerTuple[1];
90904
+ const customAttribute = provider(caClass);
90905
+ container.addCustomAttribute(customAttribute);
90906
+ }
90907
+ }
90860
90908
  /**
90861
90909
  * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
90862
90910
  * @param schema The Schema the SchemaItem to.
@@ -90865,66 +90913,69 @@ class SchemaReadHelper {
90865
90913
  * @param schemaItemObject The Object to populate the SchemaItem with.
90866
90914
  */
90867
90915
  loadSchemaItemSync(schema, name, itemType, schemaItemObject) {
90868
- let schemaItem;
90916
+ let schemaItem = schema.getItemSync(name);
90917
+ if (this.isSchemaItemLoaded(schemaItem)) {
90918
+ return schemaItem;
90919
+ }
90869
90920
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
90870
90921
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
90871
- schemaItem = schema.createEntityClassSync(name);
90922
+ schemaItem = schemaItem || schema.createEntityClassSync(name);
90872
90923
  this.loadEntityClassSync(schemaItem, schemaItemObject);
90873
90924
  break;
90874
90925
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
90875
- schemaItem = schema.createStructClassSync(name);
90926
+ schemaItem = schemaItem || schema.createStructClassSync(name);
90876
90927
  const structProps = this._parser.parseStructClass(schemaItemObject);
90877
90928
  this.loadClassSync(schemaItem, structProps, schemaItemObject);
90878
90929
  break;
90879
90930
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
90880
- schemaItem = schema.createMixinClassSync(name);
90931
+ schemaItem = schemaItem || schema.createMixinClassSync(name);
90881
90932
  this.loadMixinSync(schemaItem, schemaItemObject);
90882
90933
  break;
90883
90934
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
90884
- schemaItem = schema.createCustomAttributeClassSync(name);
90935
+ schemaItem = schemaItem || schema.createCustomAttributeClassSync(name);
90885
90936
  const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);
90886
90937
  this.loadClassSync(schemaItem, caClassProps, schemaItemObject);
90887
90938
  break;
90888
90939
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
90889
- schemaItem = schema.createRelationshipClassSync(name);
90940
+ schemaItem = schemaItem || schema.createRelationshipClassSync(name);
90890
90941
  this.loadRelationshipClassSync(schemaItem, schemaItemObject);
90891
90942
  break;
90892
90943
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
90893
- schemaItem = schema.createKindOfQuantitySync(name);
90944
+ schemaItem = schemaItem || schema.createKindOfQuantitySync(name);
90894
90945
  this.loadKindOfQuantitySync(schemaItem, schemaItemObject);
90895
90946
  break;
90896
90947
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
90897
- schemaItem = schema.createUnitSync(name);
90948
+ schemaItem = schemaItem || schema.createUnitSync(name);
90898
90949
  this.loadUnitSync(schemaItem, schemaItemObject);
90899
90950
  break;
90900
90951
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
90901
- schemaItem = schema.createConstantSync(name);
90952
+ schemaItem = schemaItem || schema.createConstantSync(name);
90902
90953
  this.loadConstantSync(schemaItem, schemaItemObject);
90903
90954
  break;
90904
90955
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
90905
- schemaItem = schema.createInvertedUnitSync(name);
90956
+ schemaItem = schemaItem || schema.createInvertedUnitSync(name);
90906
90957
  this.loadInvertedUnitSync(schemaItem, schemaItemObject);
90907
90958
  break;
90908
90959
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
90909
- schemaItem = schema.createFormatSync(name);
90960
+ schemaItem = schemaItem || schema.createFormatSync(name);
90910
90961
  this.loadFormatSync(schemaItem, schemaItemObject);
90911
90962
  break;
90912
90963
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Phenomenon:
90913
- schemaItem = schema.createPhenomenonSync(name);
90964
+ schemaItem = schemaItem || schema.createPhenomenonSync(name);
90914
90965
  const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);
90915
90966
  schemaItem.fromJSONSync(phenomenonProps);
90916
90967
  break;
90917
90968
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
90918
- schemaItem = schema.createUnitSystemSync(name);
90969
+ schemaItem = schemaItem || schema.createUnitSystemSync(name);
90919
90970
  schemaItem.fromJSONSync(this._parser.parseUnitSystem(schemaItemObject));
90920
90971
  break;
90921
90972
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.PropertyCategory:
90922
- schemaItem = schema.createPropertyCategorySync(name);
90973
+ schemaItem = schemaItem || schema.createPropertyCategorySync(name);
90923
90974
  const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);
90924
90975
  schemaItem.fromJSONSync(propertyCategoryProps);
90925
90976
  break;
90926
90977
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Enumeration:
90927
- schemaItem = schema.createEnumerationSync(name);
90978
+ schemaItem = schemaItem || schema.createEnumerationSync(name);
90928
90979
  const enumerationProps = this._parser.parseEnumeration(schemaItemObject);
90929
90980
  schemaItem.fromJSONSync(enumerationProps);
90930
90981
  break;
@@ -90972,7 +91023,7 @@ class SchemaReadHelper {
90972
91023
  const foundItem = this._parser.findItem(itemName);
90973
91024
  if (foundItem) {
90974
91025
  schemaItem = await this.loadSchemaItem(this._schema, ...foundItem);
90975
- if (!skipVisitor && schemaItem && this._visitorHelper) {
91026
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
90976
91027
  await this._visitorHelper.visitSchemaPart(schemaItem);
90977
91028
  }
90978
91029
  if (loadCallBack && schemaItem)
@@ -91005,7 +91056,7 @@ class SchemaReadHelper {
91005
91056
  const foundItem = this._parser.findItem(itemName);
91006
91057
  if (foundItem) {
91007
91058
  schemaItem = this.loadSchemaItemSync(this._schema, ...foundItem);
91008
- if (!skipVisitor && schemaItem && this._visitorHelper) {
91059
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
91009
91060
  this._visitorHelper.visitSchemaPartSync(schemaItem);
91010
91061
  }
91011
91062
  if (loadCallBack && schemaItem)
@@ -91155,7 +91206,7 @@ class SchemaReadHelper {
91155
91206
  */
91156
91207
  async loadClass(classObj, classProps, rawClass) {
91157
91208
  const baseClassLoaded = async (baseClass) => {
91158
- if (this._visitorHelper)
91209
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
91159
91210
  await this._visitorHelper.visitSchemaPart(baseClass);
91160
91211
  };
91161
91212
  // Load base class first
@@ -91178,7 +91229,7 @@ class SchemaReadHelper {
91178
91229
  */
91179
91230
  loadClassSync(classObj, classProps, rawClass) {
91180
91231
  const baseClassLoaded = async (baseClass) => {
91181
- if (this._visitorHelper)
91232
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
91182
91233
  this._visitorHelper.visitSchemaPartSync(baseClass);
91183
91234
  };
91184
91235
  // Load base class first
@@ -91229,7 +91280,7 @@ class SchemaReadHelper {
91229
91280
  async loadMixin(mixin, rawMixin) {
91230
91281
  const mixinProps = this._parser.parseMixin(rawMixin);
91231
91282
  const appliesToLoaded = async (appliesToClass) => {
91232
- if (this._visitorHelper)
91283
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
91233
91284
  await this._visitorHelper.visitSchemaPart(appliesToClass);
91234
91285
  };
91235
91286
  await this.findSchemaItem(mixinProps.appliesTo, true, appliesToLoaded);
@@ -91243,7 +91294,7 @@ class SchemaReadHelper {
91243
91294
  loadMixinSync(mixin, rawMixin) {
91244
91295
  const mixinProps = this._parser.parseMixin(rawMixin);
91245
91296
  const appliesToLoaded = async (appliesToClass) => {
91246
- if (this._visitorHelper)
91297
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
91247
91298
  await this._visitorHelper.visitSchemaPart(appliesToClass);
91248
91299
  };
91249
91300
  this.findSchemaItemSync(mixinProps.appliesTo, true, appliesToLoaded);
@@ -91439,27 +91490,6 @@ class SchemaReadHelper {
91439
91490
  propertyObj.fromJSONSync(props);
91440
91491
  this.loadCustomAttributesSync(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));
91441
91492
  }
91442
- /**
91443
- * Load the customAttribute class dependencies for a set of CustomAttribute objects and add
91444
- * them to a given custom attribute container.
91445
- * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
91446
- * @param customAttributes An iterable set of parsed CustomAttribute objects.
91447
- */
91448
- async loadCustomAttributes(container, caProviders) {
91449
- for (const providerTuple of caProviders) {
91450
- // First tuple entry is the CA class name.
91451
- const caClass = await this.findSchemaItem(providerTuple[0]);
91452
- // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
91453
- if (caClass && caClass.key.schemaName !== container.schema.name &&
91454
- !container.schema.getReferenceSync(caClass.key.schemaName)) {
91455
- 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`);
91456
- }
91457
- // Second tuple entry ia a function that provides the CA instance.
91458
- const provider = providerTuple[1];
91459
- const customAttribute = provider(caClass);
91460
- container.addCustomAttribute(customAttribute);
91461
- }
91462
- }
91463
91493
  /**
91464
91494
  * Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.
91465
91495
  * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
@@ -92813,8 +92843,8 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
92813
92843
  }
92814
92844
  }
92815
92845
  parsePrimitiveProperty(xmlElement) {
92816
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
92817
92846
  const typeName = this.getPropertyTypeName(xmlElement);
92847
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
92818
92848
  const primitivePropertyProps = { ...propertyProps, typeName };
92819
92849
  return primitivePropertyProps;
92820
92850
  }
@@ -92826,7 +92856,7 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
92826
92856
  }
92827
92857
  parsePrimitiveArrayProperty(xmlElement) {
92828
92858
  const typeName = this.getPropertyTypeName(xmlElement);
92829
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
92859
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
92830
92860
  const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);
92831
92861
  return {
92832
92862
  ...propertyProps,
@@ -93101,14 +93131,23 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
93101
93131
  return rawTypeName;
93102
93132
  return this.getQualifiedTypeName(rawTypeName);
93103
93133
  }
93104
- getPrimitiveOrEnumPropertyBaseProps(xmlElement) {
93134
+ getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName) {
93135
+ const primitiveType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parsePrimitiveType)(typeName);
93105
93136
  const propertyProps = this.getPropertyProps(xmlElement);
93106
93137
  const propName = propertyProps.name;
93107
93138
  const extendedTypeName = this.getOptionalAttribute(xmlElement, "extendedTypeName");
93108
93139
  const minLength = this.getOptionalIntAttribute(xmlElement, "minimumLength", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumLength' attribute. It should be a numeric value.`);
93109
93140
  const maxLength = this.getOptionalIntAttribute(xmlElement, "maximumLength", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumLength' attribute. It should be a numeric value.`);
93110
- const minValue = this.getOptionalIntAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
93111
- const maxValue = this.getOptionalIntAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
93141
+ let minValue;
93142
+ let maxValue;
93143
+ if (primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Double || primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Long) {
93144
+ minValue = this.getOptionalFloatAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
93145
+ maxValue = this.getOptionalFloatAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
93146
+ }
93147
+ else {
93148
+ minValue = this.getOptionalIntAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
93149
+ maxValue = this.getOptionalIntAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
93150
+ }
93112
93151
  return {
93113
93152
  ...propertyProps,
93114
93153
  extendedTypeName,
@@ -94264,6 +94303,2441 @@ class ECSchemaError extends _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Ben
94264
94303
  }
94265
94304
 
94266
94305
 
94306
+ /***/ }),
94307
+
94308
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js":
94309
+ /*!*******************************************************************************!*\
94310
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js ***!
94311
+ \*******************************************************************************/
94312
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94313
+
94314
+ "use strict";
94315
+ __webpack_require__.r(__webpack_exports__);
94316
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94317
+ /* harmony export */ ClassParser: () => (/* binding */ ClassParser),
94318
+ /* harmony export */ CustomAttributeClassParser: () => (/* binding */ CustomAttributeClassParser),
94319
+ /* harmony export */ MixinParser: () => (/* binding */ MixinParser),
94320
+ /* harmony export */ RelationshipClassParser: () => (/* binding */ RelationshipClassParser)
94321
+ /* harmony export */ });
94322
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
94323
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
94324
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
94325
+ /*---------------------------------------------------------------------------------------------
94326
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94327
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94328
+ *--------------------------------------------------------------------------------------------*/
94329
+
94330
+
94331
+
94332
+ /**
94333
+ * Parses ClassProps JSON returned from an ECSql query and returns the correct ClassProps JSON.
94334
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the
94335
+ * iModelDb is in a different format than is required for a ClassProps JSON object.
94336
+ * @internal
94337
+ */
94338
+ class ClassParser extends _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__.SchemaItemParser {
94339
+ /**
94340
+ * Parses the given ClassProps JSON returned from an ECSql query.
94341
+ * @param data The ClassProps JSON as returned from an iModelDb.
94342
+ * @returns The corrected ClassProps Json.
94343
+ */
94344
+ async parse(data) {
94345
+ const props = await super.parse(data);
94346
+ if (props.properties) {
94347
+ if (props.properties.length === 0)
94348
+ delete props.properties;
94349
+ else
94350
+ this.parseProperties(props.properties);
94351
+ }
94352
+ return props;
94353
+ }
94354
+ parseProperties(propertyProps) {
94355
+ for (const props of propertyProps) {
94356
+ props.customAttributes = props.customAttributes && props.customAttributes.length > 0 ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94357
+ if (!props.customAttributes)
94358
+ delete props.customAttributes;
94359
+ }
94360
+ }
94361
+ }
94362
+ /**
94363
+ * Parses the given MixinProps JSON returned from an ECSql query.
94364
+ * @param data The MixinProps JSON as returned from an iModelDb.
94365
+ * @returns The corrected MixinProps Json.
94366
+ * @internal
94367
+ */
94368
+ class MixinParser extends ClassParser {
94369
+ /**
94370
+ * Parses the given MixinProps JSON returned from an ECSql query.
94371
+ * @param data The MixinProps JSON as returned from an iModelDb.
94372
+ * @returns The corrected MixinProps Json.
94373
+ */
94374
+ async parse(data) {
94375
+ const props = await super.parse(data);
94376
+ if (!props.customAttributes)
94377
+ delete props.customAttributes;
94378
+ return props;
94379
+ }
94380
+ }
94381
+ /**
94382
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
94383
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
94384
+ * @returns The corrected CustomAttributeClassProps Json.
94385
+ * @internal
94386
+ */
94387
+ class CustomAttributeClassParser extends ClassParser {
94388
+ /**
94389
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
94390
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
94391
+ * @returns The corrected CustomAttributeClassProps Json.
94392
+ */
94393
+ async parse(data) {
94394
+ const props = await super.parse(data);
94395
+ 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];
94396
+ return props;
94397
+ }
94398
+ }
94399
+ /**
94400
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
94401
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
94402
+ * @returns The corrected RelationshipClassProps Json.
94403
+ * @internal
94404
+ */
94405
+ class RelationshipClassParser extends ClassParser {
94406
+ /**
94407
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
94408
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
94409
+ * @returns The corrected RelationshipClassProps Json.
94410
+ */
94411
+ async parse(data) {
94412
+ const props = await super.parse(data);
94413
+ const source = props.source;
94414
+ const target = props.target;
94415
+ if (source) {
94416
+ source.customAttributes = source.customAttributes ? source.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94417
+ if (!source.customAttributes)
94418
+ delete source.customAttributes;
94419
+ }
94420
+ if (target) {
94421
+ target.customAttributes = target.customAttributes ? target.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94422
+ if (!target.customAttributes)
94423
+ delete target.customAttributes;
94424
+ }
94425
+ return props;
94426
+ }
94427
+ }
94428
+
94429
+
94430
+ /***/ }),
94431
+
94432
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js":
94433
+ /*!*************************************************************************************!*\
94434
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js ***!
94435
+ \*************************************************************************************/
94436
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94437
+
94438
+ "use strict";
94439
+ __webpack_require__.r(__webpack_exports__);
94440
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94441
+ /* harmony export */ ECSqlSchemaLocater: () => (/* binding */ ECSqlSchemaLocater)
94442
+ /* harmony export */ });
94443
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
94444
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
94445
+ /* harmony import */ var _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FullSchemaQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js");
94446
+ /* harmony import */ var _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
94447
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
94448
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
94449
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
94450
+ /*---------------------------------------------------------------------------------------------
94451
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94452
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94453
+ *--------------------------------------------------------------------------------------------*/
94454
+
94455
+
94456
+
94457
+
94458
+
94459
+
94460
+
94461
+ /**
94462
+ * An abstract [[IncrementalSchemaLocater]] implementation for loading
94463
+ * EC [Schema] instances from an iModelDb using ECSql queries.
94464
+ * @internal
94465
+ */
94466
+ class ECSqlSchemaLocater extends _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__.IncrementalSchemaLocater {
94467
+ /**
94468
+ * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.
94469
+ */
94470
+ get options() {
94471
+ return super.options;
94472
+ }
94473
+ /**
94474
+ * Initializes a new ECSqlSchemaLocater instance.
94475
+ * @param options The options used by this Schema locater.
94476
+ */
94477
+ constructor(options) {
94478
+ super(options);
94479
+ }
94480
+ /**
94481
+ * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined
94482
+ * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.
94483
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
94484
+ * @param context The [[SchemaContext]] to use for resolving references.
94485
+ * @internal
94486
+ */
94487
+ async getSchemaJson(schemaKey, context) {
94488
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
94489
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
94490
+ // to fetch the whole schema json.
94491
+ if (!await this.supportPartialSchemaLoading(context))
94492
+ return this.getSchemaProps(schemaKey);
94493
+ const start = Date.now();
94494
+ const schemaProps = this.options.useMultipleQueries
94495
+ ? await this.getFullSchemaMultipleQueries(schemaKey, context)
94496
+ : await this.getFullSchema(schemaKey, context);
94497
+ this.options.performanceLogger?.logSchema(start, schemaKey.name);
94498
+ return schemaProps;
94499
+ }
94500
+ ;
94501
+ /**
94502
+ * Gets the [[SchemaProps]] without schemaItems.
94503
+ */
94504
+ /**
94505
+ * Gets the [[SchemaProps]] without schemaItems for the given schema name.
94506
+ * @param schemaName The name of the Schema.
94507
+ * @param context The [[SchemaContext]] to use for resolving references.
94508
+ * @returns
94509
+ * @internal
94510
+ */
94511
+ async getSchemaNoItems(schemaName, context) {
94512
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });
94513
+ const schemaRow = schemaRows[0];
94514
+ if (schemaRow === undefined)
94515
+ return undefined;
94516
+ const schema = JSON.parse(schemaRow.schema);
94517
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
94518
+ }
94519
+ /**
94520
+ * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
94521
+ * @param context The schema context to lookup the meta schema.
94522
+ * @returns true if the context has a supported meta schema version, false otherwise.
94523
+ */
94524
+ async supportPartialSchemaLoading(context) {
94525
+ const metaSchemaKey = new _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey("ECDbMeta", 4, 0, 3);
94526
+ const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_0__.SchemaMatchType.LatestWriteCompatible);
94527
+ return metaSchemaInfo !== undefined;
94528
+ }
94529
+ ;
94530
+ /**
94531
+ * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.
94532
+ * @param schemaName The name of the Schema.
94533
+ * @param context The [[SchemaContext]] to which the schema belongs.
94534
+ * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
94535
+ * @internal
94536
+ */
94537
+ async getEntities(schema, context, queryOverride) {
94538
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.entityQuery;
94539
+ return this.querySchemaItem(context, schema, query, "EntityClass");
94540
+ }
94541
+ /**
94542
+ * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
94543
+ * @param schemaName The name of the Schema.
94544
+ * @param context The SchemaContext to which the schema belongs.
94545
+ * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
94546
+ * @internal
94547
+ */
94548
+ async getMixins(schema, context, queryOverride) {
94549
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.mixinQuery;
94550
+ return this.querySchemaItem(context, schema, query, "Mixin");
94551
+ }
94552
+ /**
94553
+ * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
94554
+ * @param schemaName The name of the Schema.
94555
+ * @param context The SchemaContext to which the schema belongs.
94556
+ * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
94557
+ * @internal
94558
+ */
94559
+ async getRelationships(schema, context, queryOverride) {
94560
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.relationshipClassQuery;
94561
+ return this.querySchemaItem(context, schema, query, "RelationshipClass");
94562
+ }
94563
+ /**
94564
+ * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
94565
+ * @param schemaName The name of the Schema.
94566
+ * @param context The SchemaContext to which the schema belongs.
94567
+ * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
94568
+ * @internal
94569
+ */
94570
+ async getCustomAttributeClasses(schema, context, queryOverride) {
94571
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.customAttributeQuery;
94572
+ return this.querySchemaItem(context, schema, query, "CustomAttributeClass");
94573
+ }
94574
+ /**
94575
+ * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
94576
+ * @param schemaName The name of the Schema.
94577
+ * @param context The SchemaContext to which the schema belongs.
94578
+ * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
94579
+ * @internal
94580
+ */
94581
+ async getStructs(schema, context, queryOverride) {
94582
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.structQuery;
94583
+ return this.querySchemaItem(context, schema, query, "StructClass");
94584
+ }
94585
+ /**
94586
+ * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
94587
+ * @param schema The name of the Schema.
94588
+ * @param context The SchemaContext to which the schema belongs.
94589
+ * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
94590
+ * @internal
94591
+ */
94592
+ async getKindOfQuantities(schema, context) {
94593
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.kindOfQuantity(true), "KindOfQuantity");
94594
+ }
94595
+ /**
94596
+ * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
94597
+ * @param schema The name of the Schema.
94598
+ * @param context The SchemaContext to which the schema belongs.
94599
+ * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
94600
+ * @internal
94601
+ */
94602
+ async getPropertyCategories(schema, context) {
94603
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.propertyCategory(true), "PropertyCategory");
94604
+ }
94605
+ /**
94606
+ * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
94607
+ * @param schema The name of the Schema.
94608
+ * @param context The SchemaContext to which the schema belongs.
94609
+ * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
94610
+ * @internal
94611
+ */
94612
+ async getEnumerations(schema, context) {
94613
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.enumeration(true), "Enumeration");
94614
+ }
94615
+ /**
94616
+ * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
94617
+ * @param schema The name of the Schema.
94618
+ * @param context The SchemaContext to which the schema belongs.
94619
+ * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
94620
+ * @internal
94621
+ */
94622
+ async getUnits(schema, context) {
94623
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unit(true), "Unit");
94624
+ }
94625
+ /**
94626
+ * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
94627
+ * @param schema The name of the Schema.
94628
+ * @param context The SchemaContext to which the schema belongs.
94629
+ * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
94630
+ * @internal
94631
+ */
94632
+ async getInvertedUnits(schema, context) {
94633
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.invertedUnit(true), "InvertedUnit");
94634
+ }
94635
+ /**
94636
+ * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
94637
+ * @param schema The name of the Schema.
94638
+ * @param context The SchemaContext to which the schema belongs.
94639
+ * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
94640
+ * @internal
94641
+ */
94642
+ async getConstants(schema, context) {
94643
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.constant(true), "Constant");
94644
+ }
94645
+ /**
94646
+ * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
94647
+ * @param schema The name of the Schema.
94648
+ * @param context The SchemaContext to which the schema belongs.
94649
+ * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
94650
+ * @internal
94651
+ */
94652
+ async getUnitSystems(schema, context) {
94653
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unitSystem(true), "UnitSystem");
94654
+ }
94655
+ /**
94656
+ * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
94657
+ * @param schema The name of the Schema.
94658
+ * @param context The SchemaContext to which the schema belongs.
94659
+ * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
94660
+ * @internal
94661
+ */
94662
+ async getPhenomenon(schema, context) {
94663
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.phenomenon(true), "Phenomenon");
94664
+ }
94665
+ /**
94666
+ * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
94667
+ * @param schema The name of the Schema.
94668
+ * @param context The SchemaContext to which the schema belongs.
94669
+ * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
94670
+ * @internal
94671
+ */
94672
+ async getFormats(schema, context) {
94673
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.format(true), "Format");
94674
+ }
94675
+ /**
94676
+ * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
94677
+ * @internal
94678
+ */
94679
+ async loadSchemaInfos() {
94680
+ const schemaRows = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaInfoQuery);
94681
+ return schemaRows.map((schemaRow) => ({
94682
+ alias: schemaRow.alias,
94683
+ schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),
94684
+ references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),
94685
+ }));
94686
+ }
94687
+ /**
94688
+ * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
94689
+ * can be included in the initial fetch.
94690
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
94691
+ * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
94692
+ * @internal
94693
+ */
94694
+ async getSchemaPartials(schemaKey, context) {
94695
+ const [schemaRow] = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaStubQuery, {
94696
+ parameters: { schemaName: schemaKey.name },
94697
+ limit: 1
94698
+ });
94699
+ if (!schemaRow)
94700
+ return undefined;
94701
+ const schemaPartials = [];
94702
+ const addSchema = async (key) => {
94703
+ const stub = await this.createSchemaProps(key, context);
94704
+ schemaPartials.push(stub);
94705
+ if (stub.references) {
94706
+ for (const referenceProps of stub.references) {
94707
+ if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {
94708
+ await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));
94709
+ }
94710
+ }
94711
+ }
94712
+ return stub;
94713
+ };
94714
+ const addItems = async (schemaName, itemInfo) => {
94715
+ let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);
94716
+ if (!schemaStub) {
94717
+ schemaStub = await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaName}.0.0.0`));
94718
+ }
94719
+ if (!schemaStub.items) {
94720
+ Object.assign(schemaStub, { items: {} });
94721
+ }
94722
+ const existingItem = schemaStub.items[itemInfo.name] || {};
94723
+ Object.assign(schemaStub.items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
94724
+ };
94725
+ const reviver = (_key, value) => {
94726
+ if (value === null) {
94727
+ return undefined;
94728
+ }
94729
+ return value;
94730
+ };
94731
+ await addSchema(schemaKey);
94732
+ await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);
94733
+ return schemaPartials;
94734
+ }
94735
+ async querySchemaItem(context, schemaName, query, schemaType) {
94736
+ const start = Date.now();
94737
+ const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
94738
+ this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);
94739
+ if (itemRows.length === 0)
94740
+ return [];
94741
+ const items = itemRows.map((itemRow) => {
94742
+ return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
94743
+ });
94744
+ return await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseSchemaItems(items, schemaName, context) ?? [];
94745
+ }
94746
+ async getFullSchema(schemaKey, context) {
94747
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
94748
+ const schemaRow = schemaRows[0];
94749
+ if (schemaRow === undefined)
94750
+ return undefined;
94751
+ // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.
94752
+ const schema = JSON.parse(schemaRow.schema);
94753
+ if (schema.items) {
94754
+ schema.items = schema.items.map((itemRow) => { return itemRow.item; });
94755
+ }
94756
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
94757
+ }
94758
+ async getFullSchemaMultipleQueries(schemaKey, context) {
94759
+ const schema = await this.getSchemaNoItems(schemaKey.name, context);
94760
+ if (!schema)
94761
+ return undefined;
94762
+ schema.items = {};
94763
+ await Promise.all([
94764
+ this.getEntities(schemaKey.name, context),
94765
+ this.getMixins(schemaKey.name, context),
94766
+ this.getStructs(schemaKey.name, context),
94767
+ this.getRelationships(schemaKey.name, context),
94768
+ this.getCustomAttributeClasses(schemaKey.name, context),
94769
+ this.getKindOfQuantities(schemaKey.name, context),
94770
+ this.getPropertyCategories(schemaKey.name, context),
94771
+ this.getEnumerations(schemaKey.name, context),
94772
+ this.getUnits(schemaKey.name, context),
94773
+ this.getInvertedUnits(schemaKey.name, context),
94774
+ this.getUnitSystems(schemaKey.name, context),
94775
+ this.getConstants(schemaKey.name, context),
94776
+ this.getPhenomenon(schemaKey.name, context),
94777
+ this.getFormats(schemaKey.name, context)
94778
+ ]).then((itemResults) => {
94779
+ const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));
94780
+ flatItemList.forEach((schemaItem) => {
94781
+ schema.items[schemaItem.name] = schemaItem;
94782
+ });
94783
+ });
94784
+ return schema;
94785
+ }
94786
+ }
94787
+ function parseSchemaReference(referenceName) {
94788
+ return { schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(referenceName) };
94789
+ }
94790
+ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandler) {
94791
+ if (!itemRows || itemRows.length === 0) {
94792
+ return;
94793
+ }
94794
+ const parseBaseClasses = async (baseClasses) => {
94795
+ if (!baseClasses || baseClasses.length < 2)
94796
+ return;
94797
+ for (let index = baseClasses.length - 1; index >= 0;) {
94798
+ const currentItem = baseClasses[index--];
94799
+ const baseClassItem = baseClasses[index];
94800
+ const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
94801
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(currentItem, currentItem.schema, context);
94802
+ await addItemsHandler(currentItem.schema, {
94803
+ ...schemaItem,
94804
+ name: schemaItem.name,
94805
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
94806
+ baseClass: baseClassName,
94807
+ });
94808
+ }
94809
+ };
94810
+ for (const itemRow of itemRows) {
94811
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(itemRow, schemaName, context);
94812
+ await addItemsHandler(schemaName, {
94813
+ ...schemaItem,
94814
+ name: schemaItem.name,
94815
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
94816
+ mixins: itemRow.mixins
94817
+ ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
94818
+ : undefined,
94819
+ });
94820
+ await parseBaseClasses(itemRow.baseClasses);
94821
+ for (const mixinRow of itemRow.mixins || []) {
94822
+ const mixinItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(mixinRow, mixinRow.schema, context);
94823
+ await addItemsHandler(mixinRow.schema, {
94824
+ ...mixinItem,
94825
+ name: mixinItem.name,
94826
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(mixinItem.schemaItemType),
94827
+ });
94828
+ await parseBaseClasses(mixinRow.baseClasses);
94829
+ }
94830
+ }
94831
+ }
94832
+
94833
+
94834
+ /***/ }),
94835
+
94836
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js":
94837
+ /*!************************************************************************************!*\
94838
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js ***!
94839
+ \************************************************************************************/
94840
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94841
+
94842
+ "use strict";
94843
+ __webpack_require__.r(__webpack_exports__);
94844
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94845
+ /* harmony export */ FullSchemaQueries: () => (/* binding */ FullSchemaQueries)
94846
+ /* harmony export */ });
94847
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
94848
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
94849
+ /*---------------------------------------------------------------------------------------------
94850
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94851
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94852
+ *--------------------------------------------------------------------------------------------*/
94853
+
94854
+
94855
+ /**
94856
+ * Queries that return full Schema JSON data are found here. Shared SELECTS and
94857
+ * WITH clauses are broken down into individual variables.
94858
+ */
94859
+ const propertyType = (alias) => {
94860
+ return `
94861
+ CASE
94862
+ WHEN [${alias}].[Kind] = 0 THEN 'PrimitiveProperty'
94863
+ WHEN [${alias}].[Kind] = 1 THEN 'StructProperty'
94864
+ WHEN [${alias}].[Kind] = 2 THEN 'PrimitiveArrayProperty'
94865
+ WHEN [${alias}].[Kind] = 3 THEN 'StructArrayProperty'
94866
+ WHEN [${alias}].[Kind] = 4 THEN 'NavigationProperty'
94867
+ ELSE NULL
94868
+ END
94869
+ `;
94870
+ };
94871
+ const navigationDirection = (alias) => {
94872
+ return `
94873
+ CASE
94874
+ WHEN [${alias}].[NavigationDirection] = 1 THEN 'Forward'
94875
+ WHEN [${alias}].[NavigationDirection] = 2 THEN 'Backward'
94876
+ ELSE NULL
94877
+ END
94878
+ `;
94879
+ };
94880
+ const schemaCustomAttribute = (alias) => {
94881
+ return `
94882
+ SELECT
94883
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94884
+ FROM [meta].[CustomAttribute] [ca]
94885
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 1
94886
+ ORDER BY [ca].[Ordinal]
94887
+ `;
94888
+ };
94889
+ /**
94890
+ * Selects customAttribute data for each class type.
94891
+ */
94892
+ const classCustomAttribute = (alias) => {
94893
+ return `
94894
+ SELECT
94895
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94896
+ FROM [meta].[CustomAttribute] [ca]
94897
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 30
94898
+ ORDER BY [ca].[Ordinal]
94899
+ `;
94900
+ };
94901
+ const propertyCustomAttribute = (alias) => {
94902
+ return `
94903
+ SELECT
94904
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94905
+ FROM [meta].[CustomAttribute] [ca]
94906
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 992
94907
+ ORDER BY [ca].[Ordinal]
94908
+ `;
94909
+ };
94910
+ /**
94911
+ * Selects base class data for each class type.
94912
+ */
94913
+ const selectBaseClasses = `
94914
+ SELECT
94915
+ ec_classname([baseClass].[ECInstanceId], 's.c')
94916
+ FROM
94917
+ [meta].[ECClassDef] [baseClass]
94918
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
94919
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
94920
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
94921
+ LIMIT 1
94922
+ `;
94923
+ /**
94924
+ * Selects class property data for each class type. ClassProperties
94925
+ * is a common table expression (CTE or WITH clause) defined below.
94926
+ */
94927
+ const selectProperties = `
94928
+ SELECT
94929
+ json_group_array(json([classProperties].[property]))
94930
+ FROM
94931
+ [ClassProperties] [classProperties]
94932
+ WHERE
94933
+ [classProperties].[ClassId] = [class].[ECInstanceId]
94934
+ `;
94935
+ /**
94936
+ * A CTE used to select AppliesTo from IsMixin CustomAttributes for a given Mixin.
94937
+ */
94938
+ const withAppliesTo = `
94939
+ AppliesToCTE AS (
94940
+ SELECT
94941
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
94942
+ [appliesToSchema].[name] as [AppliesToSchema],
94943
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
94944
+ FROM [meta].[CustomAttribute] [ca]
94945
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
94946
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
94947
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
94948
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
94949
+ WHERE [ca].[ContainerType] = 30
94950
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
94951
+ )
94952
+ `;
94953
+ /**
94954
+ * A CTE used to select Schema reference data for a given Schema.
94955
+ */
94956
+ const withSchemaReferences = `
94957
+ SchemaReferences as (
94958
+ SELECT
94959
+ [ref].[SourceECInstanceId] as [SchemaId],
94960
+ json_object(
94961
+ 'name', [Name],
94962
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor]))
94963
+ ) as [reference]
94964
+ FROM
94965
+ [meta].[ECSchemaDef] as [refSchema]
94966
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
94967
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
94968
+ )
94969
+ `;
94970
+ /**
94971
+ * A CTE used to select Relationship constraints for a given RelationshipClass.
94972
+ */
94973
+ const withRelationshipConstraints = `
94974
+ ClassRelationshipConstraints as (
94975
+ SELECT
94976
+ [rhc].[SourceECInstanceId] as [ClassId],
94977
+ [constraintDef].[ECInstanceId] as [ConstraintId],
94978
+ [RelationshipEnd],
94979
+ CONCAT('(', [MultiplicityLowerLimit], '..', IIF([MultiplicityUpperLimit] IS NULL, '*', [MultiplicityUpperLimit]), ')') as [Multiplicity],
94980
+ [IsPolyMorphic],
94981
+ [RoleLabel],
94982
+ IIF([constraintDef].[AbstractConstraintClass] IS NOT NULL, ec_classname([constraintDef].[AbstractConstraintClass].[Id], 's.c'), null) as [AbstractConstraint],
94983
+ IIF ([rchc].[TargetECInstanceId] IS NOT NULL, JSON_GROUP_ARRAY(ec_classname([rchc].[TargetECInstanceId], 's.c')), null) as [ConstraintClasses]
94984
+ FROM
94985
+ [meta].[ECRelationshipConstraintDef] [constraintDef]
94986
+ JOIN [meta].[RelationshipHasConstraints] [rhc]
94987
+ ON [rhc].[TargetECInstanceId] = [constraintDef].[ECInstanceId]
94988
+ JOIN [meta].[RelationshipConstraintHasClasses] [rchc]
94989
+ ON [rchc].[SourceECInstanceId] = [constraintDef].[ECInstanceId]
94990
+ GROUP BY [constraintDef].[ECInstanceId]
94991
+ )
94992
+ `;
94993
+ /**
94994
+ * A CTE used to select Class property data for a given Class.
94995
+ */
94996
+ const withClassProperties = `
94997
+ ClassProperties as (
94998
+ SELECT
94999
+ [cop].[SourceECInstanceId] as [ClassId],
95000
+ json_object(
95001
+ 'name', [pd].[Name],
95002
+ 'label', [pd].[DisplayLabel],
95003
+ 'description', [pd].[Description],
95004
+ 'isReadOnly', IIF([pd].[IsReadOnly] = 1, json('true'), NULL),
95005
+ 'priority', [pd].[Priority],
95006
+ 'category', IIF([categoryDef].[Name] IS NULL, NULL, CONCAT([categorySchemaDef].[Name], '.', [categoryDef].[Name])),
95007
+ 'kindOfQuantity', IIF([koqDef].[Name] IS NULL, NULL, CONCAT([koqSchemaDef].[Name], '.', [koqDef].[Name])),
95008
+ 'typeName',
95009
+ CASE
95010
+ WHEN [pd].[Kind] = 0 OR [pd].[Kind] = 2 Then
95011
+ CASE
95012
+ WHEN [enumDef].[Name] IS NOT NULL Then CONCAT([enumSchemaDef].[Name], '.', [enumDef].[Name])
95013
+ WHEN [pd].[PrimitiveType] = 257 Then 'binary'
95014
+ WHEN [pd].[PrimitiveType] = 513 Then 'boolean'
95015
+ WHEN [pd].[PrimitiveType] = 769 Then 'dateTime'
95016
+ WHEN [pd].[PrimitiveType] = 1025 Then 'double'
95017
+ WHEN [pd].[PrimitiveType] = 1281 Then 'int'
95018
+ WHEN [pd].[PrimitiveType] = 1537 Then 'long'
95019
+ WHEN [pd].[PrimitiveType] = 1793 Then 'point2d'
95020
+ WHEN [pd].[PrimitiveType] = 2049 Then 'point3d'
95021
+ WHEN [pd].[PrimitiveType] = 2305 Then 'string'
95022
+ WHEN [pd].[PrimitiveType] = 2561 Then 'Bentley.Geometry.Common.IGeometry'
95023
+ ELSE null
95024
+ END
95025
+ WHEN [pd].[Kind] = 1 OR [pd].[Kind] = 3 Then
95026
+ CONCAT([structSchemaDef].[Name], '.', [structDef].[Name])
95027
+ ELSE null
95028
+ END,
95029
+ 'type', ${propertyType("pd")},
95030
+ 'minLength', [pd].[PrimitiveTypeMinLength],
95031
+ 'maxLength', [pd].[PrimitiveTypeMaxLength],
95032
+ 'minValue', [pd].[PrimitiveTypeMinValue],
95033
+ 'maxValue', [pd].[PrimitiveTypeMaxValue],
95034
+ 'extendedTypeName', [pd].[ExtendedTypeName],
95035
+ 'minOccurs', [pd].[ArrayMinOccurs],
95036
+ 'maxOccurs', [pd].[ArrayMaxOccurs],
95037
+ 'direction', ${navigationDirection("pd")},
95038
+ 'relationshipName', IIF([navRelDef].[Name] IS NULL, NULL, CONCAT([navSchemaDef].[Name], '.', [navRelDef].[Name])),
95039
+ 'customAttributes', (${propertyCustomAttribute("pd")})
95040
+ ) as [property]
95041
+ FROM
95042
+ [meta].[ECPropertyDef] as [pd]
95043
+ JOIN [meta].[ClassOwnsLocalProperties] [cop]
95044
+ ON cop.[TargetECInstanceId] = [pd].[ECInstanceId]
95045
+ LEFT JOIN [meta].[ECEnumerationDef] [enumDef]
95046
+ ON [enumDef].[ECInstanceId] = [pd].[Enumeration].[Id]
95047
+ LEFT JOIN [meta].[ECSchemaDef] enumSchemaDef
95048
+ ON [enumSchemaDef].[ECInstanceId] = [enumDef].[Schema].[Id]
95049
+ LEFT JOIN [meta].[PropertyCategoryDef] [categoryDef]
95050
+ ON [categoryDef].[ECInstanceId] = [pd].[Category].[Id]
95051
+ LEFT JOIN [meta].[ECSchemaDef] [categorySchemaDef]
95052
+ ON [categorySchemaDef].[ECInstanceId] = [categoryDef].[Schema].[Id]
95053
+ LEFT JOIN [meta].[KindOfQuantityDef] [koqDef]
95054
+ ON [koqDef].[ECInstanceId] = [pd].[KindOfQuantity].[Id]
95055
+ LEFT JOIN [meta].[ECSchemaDef] [koqSchemaDef]
95056
+ ON [koqSchemaDef].[ECInstanceId] = [koqDef].[Schema].[Id]
95057
+ LEFT JOIN [meta].[ECClassDef] [structDef]
95058
+ ON structDef.[ECInstanceId] = [pd].[StructClass].[Id]
95059
+ LEFT JOIN [meta].[ECSchemaDef] [structSchemaDef]
95060
+ ON [structSchemaDef].[ECInstanceId] = [structDef].[Schema].[Id]
95061
+ LEFT JOIN [meta].[ECClassDef] [navRelDef]
95062
+ ON [navRelDef].[ECInstanceId] = [pd].[NavigationRelationshipClass].[Id]
95063
+ LEFT JOIN [meta].[ECSchemaDef] [navSchemaDef]
95064
+ ON [navSchemaDef].[ECInstanceId] = [navRelDef].[Schema].[Id]
95065
+ )
95066
+ `;
95067
+ /**
95068
+ * Query that provides EntityClass data and is shared by two cases:
95069
+ * 1. A single query to return a full schema.
95070
+ * 2. When querying a full schema with multiple schema item queries or
95071
+ * when just querying for Entity classes.
95072
+ */
95073
+ const baseEntityQuery = `
95074
+ SELECT
95075
+ [sd].[Name] as [schema],
95076
+ json_object (
95077
+ 'schemaItemType', 'EntityClass',
95078
+ 'name', [class].[Name],
95079
+ 'label', [class].[DisplayLabel],
95080
+ 'description', [class].[Description],
95081
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95082
+ 'baseClass', (
95083
+ ${selectBaseClasses}
95084
+ ),
95085
+ 'mixins', (
95086
+ SELECT
95087
+ json_group_array(
95088
+ ec_classname([baseClass].[ECInstanceId], 's.c')
95089
+ )
95090
+ FROM
95091
+ [meta].[ECClassDef] [baseClass]
95092
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
95093
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
95094
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
95095
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
95096
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
95097
+ ),
95098
+ 'customAttributes', (${classCustomAttribute("class")}),
95099
+ 'properties', (
95100
+ ${selectProperties}
95101
+ )
95102
+ ) AS [item]
95103
+ FROM [meta].[ECClassDef] [class]
95104
+ JOIN
95105
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95106
+ WHERE [class].[Type] = 0 AND
95107
+ [sd].[Name] = :schemaName
95108
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
95109
+ AND [ca].[CustomAttributeClass].Id Is ([CoreCA].[IsMixin]))
95110
+ `;
95111
+ /**
95112
+ * EntityClass query used to when querying for EntityClass data only. Not used
95113
+ * for full Schema load via single query.
95114
+ */
95115
+ const entityQuery = `
95116
+ WITH
95117
+ ${withClassProperties}
95118
+ ${baseEntityQuery}
95119
+ `;
95120
+ /**
95121
+ * Query that provides Mixin data and is shared by two cases:
95122
+ * 1. A single query to return a full schema.
95123
+ * 2. When querying a full schema with multiple schema item queries or
95124
+ * when just querying for Mixin classes.
95125
+ */
95126
+ const baseMixinQuery = `
95127
+ SELECT
95128
+ [sd].[Name] as [schema],
95129
+ json_object (
95130
+ 'schemaItemType', 'Mixin',
95131
+ 'name', [class].[Name],
95132
+ 'label', [class].[DisplayLabel],
95133
+ 'description', [class].[Description],
95134
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95135
+ 'baseClass', (
95136
+ ${selectBaseClasses}
95137
+ ),
95138
+ 'appliesTo', (
95139
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
95140
+ FROM [AppliesToCTE] [atCTE]
95141
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
95142
+ ),
95143
+ 'customAttributes', (
95144
+ SELECT
95145
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95146
+ FROM [meta].[CustomAttribute] [ca]
95147
+ WHERE [ca].[ContainerId] = [class].[ECInstanceId] AND [ca].[ContainerType] = 30
95148
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') <> 'IsMixin'
95149
+ ),
95150
+ 'properties', (
95151
+ SELECT
95152
+ json_group_array(json([classProperties].[property]))
95153
+ FROM
95154
+ [ClassProperties] [classProperties]
95155
+ WHERE
95156
+ [classProperties].[ClassId] = [class].[ECInstanceId]
95157
+ )
95158
+ ) AS [item]
95159
+ FROM [meta].[ECClassDef] [class]
95160
+ JOIN
95161
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95162
+ WHERE [class].[Type] = 0 AND
95163
+ [sd].[Name] = :schemaName
95164
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
95165
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
95166
+ `;
95167
+ /**
95168
+ * Mixin query used to when querying for Mixin data only. Not used
95169
+ * for full Schema load via single query.
95170
+ */
95171
+ const mixinQuery = `
95172
+ WITH
95173
+ ${withAppliesTo},
95174
+ ${withClassProperties}
95175
+ ${baseMixinQuery}
95176
+ `;
95177
+ /**
95178
+ * Query that provides RelationshipClass data and is shared by two cases:
95179
+ * 1. A single query to return a full schema.
95180
+ * 2. When querying a full schema with multiple schema item queries or
95181
+ * when just querying for Relationship classes.
95182
+ */
95183
+ const baseRelationshipClassQuery = `
95184
+ SELECT
95185
+ [sd].Name as schema,
95186
+ json_object (
95187
+ 'schemaItemType', 'RelationshipClass',
95188
+ 'name', [class].[Name],
95189
+ 'label', [class].[DisplayLabel],
95190
+ 'description', [class].[Description],
95191
+ 'strength', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strength)("class")},
95192
+ 'strengthDirection', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strengthDirection)("class")},
95193
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95194
+ 'baseClass', (
95195
+ ${selectBaseClasses}
95196
+ ),
95197
+ 'customAttributes', (${classCustomAttribute("class")}),
95198
+ 'properties', (
95199
+ ${selectProperties}
95200
+ ),
95201
+ 'source', (
95202
+ SELECT
95203
+ json_object (
95204
+ 'multiplicity', [sourceConst].[Multiplicity],
95205
+ 'roleLabel', [sourceConst].[RoleLabel],
95206
+ 'polymorphic', IIF([sourceConst].[IsPolyMorphic] = 1, json('true'), json('false')),
95207
+ 'abstractConstraint', [sourceConst].[AbstractConstraint],
95208
+ 'constraintClasses', json([sourceConst].[ConstraintClasses]),
95209
+ 'customAttributes', (
95210
+ SELECT
95211
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95212
+ FROM [meta].[CustomAttribute] [ca]
95213
+ WHERE [ca].[ContainerId] = [sourceConst].[ConstraintId] AND [ca].[ContainerType] = 1024
95214
+ ORDER BY [ca].[Ordinal]
95215
+ )
95216
+ )
95217
+ FROM
95218
+ [ClassRelationshipConstraints] [sourceConst]
95219
+ WHERE [sourceConst].[relationshipEnd] = 0
95220
+ AND [sourceConst].[ClassId] = [class].[ECInstanceId]
95221
+ ),
95222
+ 'target', (
95223
+ SELECT
95224
+ json_object (
95225
+ 'multiplicity', [targetConst].[Multiplicity],
95226
+ 'roleLabel', [targetConst].[RoleLabel],
95227
+ 'polymorphic', IIF([targetConst].[IsPolyMorphic] = 1, json('true'), json('false')),
95228
+ 'abstractConstraint', [targetConst].[AbstractConstraint],
95229
+ 'constraintClasses', json([targetConst].[ConstraintClasses]),
95230
+ 'customAttributes', (
95231
+ SELECT
95232
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95233
+ FROM [meta].[CustomAttribute] [ca]
95234
+ WHERE [ca].[ContainerId] = [targetConst].[ConstraintId] AND [ca].[ContainerType] = 2048
95235
+ ORDER BY [ca].[Ordinal]
95236
+ )
95237
+ )
95238
+ FROM
95239
+ [ClassRelationshipConstraints] [targetConst]
95240
+ WHERE [targetConst].[relationshipEnd] = 1
95241
+ AND [targetConst].[ClassId] = [class].[ECInstanceId]
95242
+ )
95243
+ ) AS [item]
95244
+ FROM [meta].[ECClassDef] [class]
95245
+ JOIN
95246
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95247
+ WHERE [class].[Type] = 1 AND
95248
+ [sd].[Name] = :schemaName
95249
+ `;
95250
+ /**
95251
+ * RelationshipClass query used to when querying for RelationshipClass data only. Not used
95252
+ * for full Schema load via single query.
95253
+ */
95254
+ const relationshipClassQuery = `
95255
+ WITH
95256
+ ${withClassProperties},
95257
+ ${withRelationshipConstraints}
95258
+ ${baseRelationshipClassQuery}
95259
+ `;
95260
+ /**
95261
+ * Query that provides StructClass data and is shared by two cases:
95262
+ * 1. A single query to return a full schema.
95263
+ * 2. When querying a full schema with multiple schema item queries or
95264
+ * when just querying for Struct classes.
95265
+ */
95266
+ const baseStructQuery = `
95267
+ SELECT
95268
+ [sd].Name as schema,
95269
+ json_object (
95270
+ 'schemaItemType', 'StructClass',
95271
+ 'name', [class].[Name],
95272
+ 'label', [class].[DisplayLabel],
95273
+ 'description', [class].[Description],
95274
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95275
+ 'baseClass', (
95276
+ ${selectBaseClasses}
95277
+ ),
95278
+ 'customAttributes', (${classCustomAttribute("class")}),
95279
+ 'properties', (
95280
+ ${selectProperties}
95281
+ )
95282
+ ) AS item
95283
+ FROM [meta].[ECClassDef] [class]
95284
+ JOIN
95285
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95286
+ WHERE [class].[Type] = 2 AND
95287
+ [sd].[Name] = :schemaName
95288
+ `;
95289
+ /**
95290
+ * StructClass query used to when querying for StructClass data only. Not used
95291
+ * for full Schema load via single query.
95292
+ */
95293
+ const structQuery = `
95294
+ WITH
95295
+ ${withClassProperties}
95296
+ ${baseStructQuery}
95297
+ `;
95298
+ /**
95299
+ * Query that provides CustomAttributeClass data and is shared by two cases:
95300
+ * 1. A single query to return a full schema.
95301
+ * 2. When querying a full schema with multiple schema item queries or
95302
+ * when just querying for CustomAttribute classes.
95303
+ */
95304
+ const baseCustomAttributeQuery = `
95305
+ SELECT
95306
+ [sd].Name as schema,
95307
+ json_object (
95308
+ 'schemaItemType', 'CustomAttributeClass',
95309
+ 'name', [class].[Name],
95310
+ 'label', [class].[DisplayLabel],
95311
+ 'description', [class].[Description],
95312
+ 'appliesTo', [class].[CustomAttributeContainerType],
95313
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95314
+ 'baseClass', (
95315
+ ${selectBaseClasses}
95316
+ ),
95317
+ 'customAttributes', (${classCustomAttribute("class")}),
95318
+ 'properties', (
95319
+ ${selectProperties}
95320
+ )
95321
+ ) AS [item]
95322
+ FROM [meta].[ECClassDef] [class]
95323
+ JOIN
95324
+ [meta].[ECSchemaDef] sd ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95325
+ WHERE [class].[Type] = 3 AND
95326
+ [sd].[Name] = :schemaName
95327
+ `;
95328
+ /**
95329
+ * CustomAttributeClass query used to when querying for CustomAttributeClass data only. Not used
95330
+ * for full Schema load via single query.
95331
+ */
95332
+ const customAttributeQuery = `
95333
+ WITH
95334
+ ${withClassProperties}
95335
+ ${baseCustomAttributeQuery}
95336
+ `;
95337
+ /**
95338
+ * Used by full schema load query via single query. Allows
95339
+ * all SchemaItemTypes to be queried at once.
95340
+ */
95341
+ const withSchemaItems = `
95342
+ SchemaItems AS (
95343
+ ${baseEntityQuery}
95344
+ UNION ALL
95345
+ ${baseRelationshipClassQuery}
95346
+ UNION ALL
95347
+ ${baseStructQuery}
95348
+ UNION ALL
95349
+ ${baseMixinQuery}
95350
+ UNION ALL
95351
+ ${baseCustomAttributeQuery}
95352
+ UNION ALL
95353
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity(true)}
95354
+ UNION ALL
95355
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration(true)}
95356
+ UNION ALL
95357
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory(true)}
95358
+ UNION ALL
95359
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit(true)}
95360
+ UNION ALL
95361
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit(true)}
95362
+ UNION ALL
95363
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem(true)}
95364
+ UNION ALL
95365
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant(true)}
95366
+ UNION ALL
95367
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon(true)}
95368
+ UNION ALL
95369
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format(true)}
95370
+ )
95371
+ `;
95372
+ /**
95373
+ * Query for Schema data without SchemaItems
95374
+ */
95375
+ const schemaNoItemsQuery = `
95376
+ WITH
95377
+ ${withSchemaReferences}
95378
+ SELECT
95379
+ json_object (
95380
+ 'name', [schemaDef].[Name],
95381
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
95382
+ 'alias', [schemaDef].[Alias],
95383
+ 'label', [schemaDef].[DisplayLabel],
95384
+ 'description', [schemaDef].[Description],
95385
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
95386
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
95387
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
95388
+ 'references', (
95389
+ SELECT
95390
+ json_group_array(json([schemaReferences].[reference]))
95391
+ FROM
95392
+ [SchemaReferences] [schemaReferences]
95393
+ WHERE
95394
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
95395
+ )
95396
+ ) as [schema]
95397
+ FROM
95398
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
95399
+ `;
95400
+ /**
95401
+ * Query to load a full Schema via a single query.
95402
+ */
95403
+ const schemaQuery = `
95404
+ WITH
95405
+ ${withAppliesTo},
95406
+ ${withSchemaReferences},
95407
+ ${withClassProperties},
95408
+ ${withRelationshipConstraints},
95409
+ ${withSchemaItems}
95410
+ SELECT
95411
+ json_object (
95412
+ 'name', [schemaDef].[Name],
95413
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
95414
+ 'alias', [schemaDef].[Alias],
95415
+ 'label', [schemaDef].[DisplayLabel],
95416
+ 'description', [schemaDef].[Description],
95417
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
95418
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
95419
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
95420
+ 'references', (
95421
+ SELECT
95422
+ json_group_array(json([schemaReferences].[reference]))
95423
+ FROM
95424
+ [SchemaReferences] [schemaReferences]
95425
+ WHERE
95426
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
95427
+ ),
95428
+ 'items', (
95429
+ SELECT
95430
+ json_group_array(json(json_object(
95431
+ 'item', json([items].[item])
95432
+ )))
95433
+ FROM
95434
+ [SchemaItems] [items]
95435
+ )
95436
+ ) as [schema]
95437
+ FROM
95438
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
95439
+ `;
95440
+ /**
95441
+ * Queries for loading full Schema JSON.
95442
+ * @internal
95443
+ */
95444
+ // eslint-disable-next-line @typescript-eslint/naming-convention
95445
+ const FullSchemaQueries = {
95446
+ schemaQuery,
95447
+ schemaNoItemsQuery,
95448
+ entityQuery,
95449
+ relationshipClassQuery,
95450
+ mixinQuery,
95451
+ structQuery,
95452
+ customAttributeQuery
95453
+ };
95454
+
95455
+
95456
+ /***/ }),
95457
+
95458
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js":
95459
+ /*!*******************************************************************************************!*\
95460
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js ***!
95461
+ \*******************************************************************************************/
95462
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95463
+
95464
+ "use strict";
95465
+ __webpack_require__.r(__webpack_exports__);
95466
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95467
+ /* harmony export */ IncrementalSchemaLocater: () => (/* binding */ IncrementalSchemaLocater)
95468
+ /* harmony export */ });
95469
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
95470
+ /* harmony import */ var _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/SchemaGraphUtil */ "../../core/ecschema-metadata/lib/esm/Deserialization/SchemaGraphUtil.js");
95471
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95472
+ /* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Exception */ "../../core/ecschema-metadata/lib/esm/Exception.js");
95473
+ /* harmony import */ var _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/Schema */ "../../core/ecschema-metadata/lib/esm/Metadata/Schema.js");
95474
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
95475
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
95476
+ /* harmony import */ var _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./IncrementalSchemaReader */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js");
95477
+ /*---------------------------------------------------------------------------------------------
95478
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95479
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95480
+ *--------------------------------------------------------------------------------------------*/
95481
+
95482
+
95483
+
95484
+
95485
+
95486
+
95487
+
95488
+
95489
+ /**
95490
+ * A [[ISchemaLocater]] implementation for locating and retrieving EC [[Schema]]
95491
+ * objects incrementally instead of the full schema and it's references at once. This is useful for large schemas that
95492
+ * take a long time to load, but clients need a rough skeleton of the schema as fast as possible.
95493
+ *
95494
+ * The IncrementalSchemaLocater is a locater around the [[IncrementalSchemaLocater]] to be used in a
95495
+ * [[SchemaContext]].
95496
+ * @internal
95497
+ */
95498
+ class IncrementalSchemaLocater {
95499
+ _options;
95500
+ _schemaInfoCache;
95501
+ /**
95502
+ * Initializes a new instance of the IncrementalSchemaLocater class.
95503
+ * @param options The [[SchemaLocaterOptions]] that control the loading of the schema.
95504
+ */
95505
+ constructor(options) {
95506
+ this._options = options || {};
95507
+ this._schemaInfoCache = new SchemaInfoCache(async (context) => {
95508
+ return this.loadSchemaInfos(context);
95509
+ });
95510
+ }
95511
+ /** Gets the options how the schema locater load the schemas. */
95512
+ get options() {
95513
+ return this._options;
95514
+ }
95515
+ /**
95516
+ * Gets the [[SchemaInfo]] which matches the provided SchemaKey. The SchemaInfo may be returned
95517
+ * before the schema is fully loaded. May return the entire Schema so long as it is completely loaded as it satisfies
95518
+ * the SchemaInfo interface.
95519
+ * @param schemaKey The [[SchemaKey]] to look up.
95520
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95521
+ * @param context The [[SchemaContext]] for loading schema references.
95522
+ */
95523
+ async getSchemaInfo(schemaKey, matchType, context) {
95524
+ return this._schemaInfoCache.lookup(schemaKey, matchType, context);
95525
+ }
95526
+ /**
95527
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
95528
+ * For schemas that may have references, construct and call through a SchemaContext instead.
95529
+ * @param schemaKey The [[SchemaKey]] to look up.
95530
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95531
+ * @param context The [[SchemaContext]] for loading schema references.
95532
+ */
95533
+ async getSchema(schemaKey, matchType, context) {
95534
+ const schemaInfo = await this.getSchemaInfo(schemaKey, matchType, context);
95535
+ return schemaInfo
95536
+ ? this.loadSchema(schemaInfo, context)
95537
+ : undefined;
95538
+ }
95539
+ /**
95540
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
95541
+ * For schemas that may have references, construct and call through a SchemaContext instead.
95542
+ * NOT IMPLEMENTED IN THIS LOCATER - ALWAYS RETURNS UNDEFINED.
95543
+ * @param schemaKey The [[SchemaKey]] to look up.
95544
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95545
+ * @param context The [[SchemaContext]] for loading schema references.
95546
+ * @returns Incremental schema loading does not work synchronously, this will always return undefined.
95547
+ */
95548
+ getSchemaSync(_schemaKey, _matchType, _context) {
95549
+ return undefined;
95550
+ }
95551
+ /**
95552
+ * Start loading the schema for the given schema info incrementally. The schema is returned
95553
+ * as soon as the schema stub is loaded while the schema fully resolves in the background. It should
95554
+ * only be called by the IncrementalSchemaLocater if a schema has not been loaded or started to
95555
+ * load yet.
95556
+ * @param schemaInfo The schema info of the schema to load.
95557
+ * @param schemaContext The schema context to load the schema into.
95558
+ */
95559
+ async loadSchema(schemaInfo, schemaContext) {
95560
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
95561
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
95562
+ // to fetch the whole schema json.
95563
+ if (!await this.supportPartialSchemaLoading(schemaContext)) {
95564
+ const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);
95565
+ return _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema.fromJson(schemaJson, schemaContext);
95566
+ }
95567
+ // Fetches the schema partials for the given schema key. The first item in the array is the
95568
+ // actual schema props of the schema to load, the following items are schema props of referenced
95569
+ // schema items that are needed to resolve the schema properly.
95570
+ const schemaPartials = await this.getSchemaPartials(schemaInfo.schemaKey, schemaContext);
95571
+ if (schemaPartials === undefined)
95572
+ 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()}`);
95573
+ // Sort the partials in dependency order to ensure referenced schemas exist in the schema context
95574
+ // when they get requested. Otherwise the context would call this method again and for referenced
95575
+ // schemas, we would not want to request the whole schema props.
95576
+ const sortedPartials = await this.sortSchemaPartials(schemaPartials, schemaContext);
95577
+ for (const schemaProps of sortedPartials) {
95578
+ await this.startLoadingPartialSchema(schemaProps, schemaContext);
95579
+ }
95580
+ const schema = await schemaContext.getCachedSchema(schemaInfo.schemaKey);
95581
+ if (!schema)
95582
+ throw new Error(`Schema ${schemaInfo.schemaKey.name} could not be found.`);
95583
+ return schema;
95584
+ }
95585
+ /**
95586
+ * Creates a SchemaProps object by loading the Schema information from the given SchemaContext.
95587
+ * @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.
95588
+ * @param schemaContext The SchemaContext holding the Schema.
95589
+ * @returns The SchemaProps object.
95590
+ */
95591
+ async createSchemaProps(schemaKey, schemaContext) {
95592
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
95593
+ if (!schemaInfo)
95594
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
95595
+ const schemaProps = {
95596
+ $schema: _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
95597
+ name: schemaKey.name,
95598
+ alias: schemaInfo.alias,
95599
+ version: schemaInfo.schemaKey.version.toString(),
95600
+ references: [],
95601
+ items: {}
95602
+ };
95603
+ if (!schemaProps.references)
95604
+ throw new Error(`Schema references is undefined for the Schema ${schemaInfo.schemaKey.name}`);
95605
+ schemaInfo.references.forEach((ref) => {
95606
+ schemaProps.references.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });
95607
+ });
95608
+ return schemaProps;
95609
+ }
95610
+ async startLoadingPartialSchema(schemaProps, schemaContext) {
95611
+ if (schemaContext.schemaExists(_SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`))) {
95612
+ return;
95613
+ }
95614
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__.SchemaLoadingController();
95615
+ const schemaReader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schemaContext, true);
95616
+ const schema = new _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema(schemaContext);
95617
+ schema.setLoadingController(controller);
95618
+ await schemaReader.readSchema(schema, schemaProps);
95619
+ if (!this._options.loadPartialSchemaOnly)
95620
+ controller.start(this.startLoadingFullSchema(schema));
95621
+ }
95622
+ async loadFullSchema(schema) {
95623
+ const fullSchemaProps = await this.getSchemaJson(schema.schemaKey, schema.context);
95624
+ const reader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schema.context, false);
95625
+ await reader.readSchema(schema, fullSchemaProps, false);
95626
+ }
95627
+ async startLoadingFullSchema(schema) {
95628
+ if (!schema.loadingController)
95629
+ return;
95630
+ // If the schema is already resolved, return it directly.
95631
+ if (schema.loadingController.isComplete || schema.loadingController.inProgress) {
95632
+ return;
95633
+ }
95634
+ // Since the schema relies on it's references, they get triggered to be resolved
95635
+ // first by recursively calling this method. After all references has been resolved
95636
+ // the schema itself gets resolved.
95637
+ await Promise.all(schema.references.map(async (referenceSchema) => {
95638
+ if (referenceSchema.loadingController && referenceSchema.loadingController.inProgress)
95639
+ return referenceSchema.loadingController.wait();
95640
+ else
95641
+ return this.startLoadingFullSchema(referenceSchema);
95642
+ }));
95643
+ return this.loadFullSchema(schema);
95644
+ }
95645
+ async sortSchemaPartials(schemaPartials, schemaContext) {
95646
+ const schemaInfos = [];
95647
+ for (const schemaProps of schemaPartials) {
95648
+ const schemaKey = _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`);
95649
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
95650
+ if (!schemaInfo)
95651
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
95652
+ schemaInfos.push({ ...schemaInfo, props: schemaProps });
95653
+ }
95654
+ const orderedSchemaInfos = _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__.SchemaGraphUtil.buildDependencyOrderedSchemaInfoList(schemaInfos);
95655
+ return orderedSchemaInfos.map((schemaInfo) => schemaInfo.props);
95656
+ }
95657
+ }
95658
+ /**
95659
+ * Helper class to manage schema infos for a schema context.
95660
+ */
95661
+ class SchemaInfoCache {
95662
+ _schemaInfoCache;
95663
+ _schemaInfoLoader;
95664
+ constructor(schemaInfoLoader) {
95665
+ this._schemaInfoCache = new WeakMap();
95666
+ this._schemaInfoLoader = schemaInfoLoader;
95667
+ }
95668
+ async getSchemasByContext(context) {
95669
+ if (!this._schemaInfoCache.has(context)) {
95670
+ const schemaInfos = await this._schemaInfoLoader(context);
95671
+ this._schemaInfoCache.set(context, Array.from(schemaInfos));
95672
+ }
95673
+ return this._schemaInfoCache.get(context);
95674
+ }
95675
+ async lookup(schemaKey, matchType, context) {
95676
+ const contextSchemaInfos = await this.getSchemasByContext(context);
95677
+ return contextSchemaInfos
95678
+ ? contextSchemaInfos.find((schemaInfo) => schemaInfo.schemaKey.matches(schemaKey, matchType))
95679
+ : undefined;
95680
+ }
95681
+ remove(schemaKey, context) {
95682
+ const contextSchemaInfos = this._schemaInfoCache.get(context);
95683
+ if (!contextSchemaInfos)
95684
+ return;
95685
+ const index = contextSchemaInfos.findIndex((schemaInfo) => schemaInfo.schemaKey.name === schemaKey.name);
95686
+ if (index !== -1) {
95687
+ contextSchemaInfos.splice(index, 1);
95688
+ }
95689
+ }
95690
+ }
95691
+
95692
+
95693
+ /***/ }),
95694
+
95695
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js":
95696
+ /*!******************************************************************************************!*\
95697
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js ***!
95698
+ \******************************************************************************************/
95699
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95700
+
95701
+ "use strict";
95702
+ __webpack_require__.r(__webpack_exports__);
95703
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95704
+ /* harmony export */ IncrementalSchemaReader: () => (/* binding */ IncrementalSchemaReader)
95705
+ /* harmony export */ });
95706
+ /* harmony import */ var _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Deserialization/Helper */ "../../core/ecschema-metadata/lib/esm/Deserialization/Helper.js");
95707
+ /* harmony import */ var _Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/JsonParser */ "../../core/ecschema-metadata/lib/esm/Deserialization/JsonParser.js");
95708
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95709
+ /* harmony import */ var _Metadata_Class__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Metadata/Class */ "../../core/ecschema-metadata/lib/esm/Metadata/Class.js");
95710
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
95711
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
95712
+
95713
+
95714
+
95715
+
95716
+
95717
+
95718
+ /**
95719
+ * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]
95720
+ * but overrides a few methods to support the incremental schema loading case.
95721
+ * @internal
95722
+ */
95723
+ class IncrementalSchemaReader extends _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__.SchemaReadHelper {
95724
+ _incremental;
95725
+ /**
95726
+ * Initializes a new [[IncrementalSchemaReader]] instance.
95727
+ * @param schemaContext The [[SchemaContext]] used to load the schemas.
95728
+ * @param incremental Indicates that the Schema should be read incrementally.
95729
+ * Pass false to load the full schema without an incremental/partial load.
95730
+ */
95731
+ constructor(schemaContext, incremental) {
95732
+ super(_Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__.JsonParser, schemaContext);
95733
+ this._incremental = incremental;
95734
+ }
95735
+ /**
95736
+ * Indicates that a given [[SchemaItem]] has been fully loaded.
95737
+ * @param schemaItem The SchemaItem to check.
95738
+ * @returns True if the item has been loaded, false if still in progress.
95739
+ */
95740
+ isSchemaItemLoaded(schemaItem) {
95741
+ return schemaItem !== undefined
95742
+ && schemaItem.loadingController !== undefined
95743
+ && schemaItem.loadingController.isComplete;
95744
+ }
95745
+ /**
95746
+ * Starts loading the [[SchemaItem]] identified by the given name and itemType.
95747
+ * @param schema The [[Schema]] that contains the SchemaItem.
95748
+ * @param name The name of the SchemaItem to load.
95749
+ * @param itemType The SchemaItem type name of the item to load.
95750
+ * @param schemaItemObject The object accepting the SchemaItem data.
95751
+ * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.
95752
+ */
95753
+ async loadSchemaItem(schema, name, itemType, schemaItemObject) {
95754
+ const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);
95755
+ // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.
95756
+ // The fromJSON method of the actual class instances may complain about missing properties in the props, so
95757
+ // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.
95758
+ if (this._incremental && schemaItemObject && schemaItem) {
95759
+ if (schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity) {
95760
+ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__.SchemaItem.prototype.fromJSONSync.call(schemaItem, schemaItemObject);
95761
+ }
95762
+ else {
95763
+ schemaItem.fromJSONSync(schemaItemObject);
95764
+ }
95765
+ }
95766
+ this.schemaItemLoading(schemaItem);
95767
+ return schemaItem;
95768
+ }
95769
+ schemaItemLoading(schemaItem) {
95770
+ if (schemaItem === undefined)
95771
+ return;
95772
+ if (schemaItem.loadingController === undefined) {
95773
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__.SchemaLoadingController();
95774
+ schemaItem.setLoadingController(controller);
95775
+ }
95776
+ if (_Metadata_Class__WEBPACK_IMPORTED_MODULE_3__.ECClass.isECClass(schemaItem)
95777
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity
95778
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.Format)
95779
+ schemaItem.loadingController.isComplete = !this._incremental;
95780
+ else
95781
+ schemaItem.loadingController.isComplete = true;
95782
+ }
95783
+ }
95784
+
95785
+
95786
+ /***/ }),
95787
+
95788
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js":
95789
+ /*!************************************************************************************!*\
95790
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js ***!
95791
+ \************************************************************************************/
95792
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95793
+
95794
+ "use strict";
95795
+ __webpack_require__.r(__webpack_exports__);
95796
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95797
+ /* harmony export */ KindOfQuantityParser: () => (/* binding */ KindOfQuantityParser),
95798
+ /* harmony export */ SchemaItemParser: () => (/* binding */ SchemaItemParser)
95799
+ /* harmony export */ });
95800
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95801
+ /* harmony import */ var _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/OverrideFormat */ "../../core/ecschema-metadata/lib/esm/Metadata/OverrideFormat.js");
95802
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
95803
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
95804
+ /*---------------------------------------------------------------------------------------------
95805
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95806
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95807
+ *--------------------------------------------------------------------------------------------*/
95808
+
95809
+
95810
+
95811
+
95812
+ /**
95813
+ * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.
95814
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb
95815
+ * is in a different format than is required for a SchemaItemProps JSON object.
95816
+ * @internal
95817
+ */
95818
+ class SchemaItemParser {
95819
+ _schema;
95820
+ _context;
95821
+ /**
95822
+ * Initializes a new SchemaItemParser.
95823
+ * @param schemaName The name the Schema containing the SchemaItems.
95824
+ * @param context The SchemaContext containing the Schema.
95825
+ */
95826
+ constructor(schemaName, context) {
95827
+ this._schema = schemaName;
95828
+ this._context = context;
95829
+ }
95830
+ /**
95831
+ * Parses the given SchemaItemProps JSON returned from an ECSql query.
95832
+ * @param data The SchemaItemProps JSON as returned from an iModelDb.
95833
+ * @returns The corrected SchemaItemProps Json.
95834
+ */
95835
+ async parse(data) {
95836
+ const props = data;
95837
+ props.schemaItemType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(data.schemaItemType);
95838
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_3__.parseCustomAttribute)(attr); }) : undefined;
95839
+ if (!props.customAttributes || props.customAttributes.length === 0)
95840
+ delete props.customAttributes;
95841
+ return props;
95842
+ }
95843
+ /**
95844
+ * Helper method to resolve the SchemaItem's full name from the given rawTypeName.
95845
+ * If the SchemaItem is defined in the same Schema from which it is referenced,
95846
+ * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,
95847
+ * the rawTypeName will have the schema alias ('bis:PhysicalElement').
95848
+ * @param rawTypeName The name or aliased name of the SchemaItem.
95849
+ * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'
95850
+ */
95851
+ async getQualifiedTypeName(rawTypeName) {
95852
+ const nameParts = rawTypeName.split(":");
95853
+ if (nameParts.length !== 2) {
95854
+ const [schemaName, itemName] = _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__.SchemaItem.parseFullName(rawTypeName);
95855
+ if (!schemaName || schemaName === '')
95856
+ return `${this._schema}.${itemName}`;
95857
+ return rawTypeName;
95858
+ }
95859
+ const resolvedName = await this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());
95860
+ if (!resolvedName)
95861
+ throw new Error(`No valid schema found for alias '${nameParts[0]}'`);
95862
+ return `${resolvedName}.${nameParts[1]}`;
95863
+ }
95864
+ async resolveNameFromAlias(alias) {
95865
+ for (const schema of this._context.getKnownSchemas()) {
95866
+ if (schema.alias === alias)
95867
+ return schema.schemaKey.name;
95868
+ }
95869
+ return undefined;
95870
+ }
95871
+ }
95872
+ /**
95873
+ * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.
95874
+ * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from
95875
+ * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.
95876
+ * @internal
95877
+ */
95878
+ class KindOfQuantityParser extends SchemaItemParser {
95879
+ /**
95880
+ * Parses the given KindOfQuantityProps JSON returned from an ECSql query.
95881
+ * @param data The KindOfQuantityProps JSON as returned from an iModelDb.
95882
+ * @returns The corrected KindOfQuantityProps Json.
95883
+ */
95884
+ async parse(data) {
95885
+ const mutableProps = await super.parse(data);
95886
+ if (mutableProps.persistenceUnit) {
95887
+ mutableProps.persistenceUnit = await this.getQualifiedTypeName(mutableProps.persistenceUnit);
95888
+ }
95889
+ mutableProps.presentationUnits = await this.parsePresentationUnits(mutableProps);
95890
+ return mutableProps;
95891
+ }
95892
+ async parsePresentationUnits(props) {
95893
+ const presentationUnits = [];
95894
+ if (!props.presentationUnits)
95895
+ return [];
95896
+ for (const presentationUnit of props.presentationUnits) {
95897
+ const presFormatOverride = _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__.OverrideFormat.parseFormatString(presentationUnit);
95898
+ const formatString = await this.createOverrideFormatString(presFormatOverride);
95899
+ presentationUnits.push(formatString);
95900
+ }
95901
+ ;
95902
+ return presentationUnits;
95903
+ }
95904
+ async createOverrideFormatString(overrideFormatProps) {
95905
+ let formatFullName = await this.getQualifiedTypeName(overrideFormatProps.name);
95906
+ if (overrideFormatProps.precision)
95907
+ formatFullName += `(${overrideFormatProps.precision.toString()})`;
95908
+ if (undefined === overrideFormatProps.unitAndLabels)
95909
+ return formatFullName;
95910
+ for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {
95911
+ const unitFullName = await this.getQualifiedTypeName(unit);
95912
+ if (undefined === unitLabel)
95913
+ formatFullName += `[${unitFullName}]`;
95914
+ else
95915
+ formatFullName += `[${unitFullName}|${unitLabel}]`;
95916
+ }
95917
+ return formatFullName;
95918
+ }
95919
+ }
95920
+
95921
+
95922
+ /***/ }),
95923
+
95924
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js":
95925
+ /*!************************************************************************************!*\
95926
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js ***!
95927
+ \************************************************************************************/
95928
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95929
+
95930
+ "use strict";
95931
+ __webpack_require__.r(__webpack_exports__);
95932
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95933
+ /* harmony export */ SchemaItemQueries: () => (/* binding */ SchemaItemQueries)
95934
+ /* harmony export */ });
95935
+ /*---------------------------------------------------------------------------------------------
95936
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95937
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95938
+ *--------------------------------------------------------------------------------------------*/
95939
+ /************************************************************************************
95940
+ * All SchemaItem queries for each SchemaItemType are defined here. These queries
95941
+ * are shared for both 'partial schema' and 'full schema' queries.
95942
+ ***********************************************************************************/
95943
+ /**
95944
+ * Query for SchemaItemType KindOfQuantity data.
95945
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95946
+ */
95947
+ const kindOfQuantity = (singleSchema) => `
95948
+ SELECT
95949
+ [koq].[Schema].[Id] AS [SchemaId],
95950
+ json_object (
95951
+ 'schemaItemType', 'KindOfQuantity',
95952
+ 'name', [koq].[Name],
95953
+ 'label', [koq].[DisplayLabel],
95954
+ 'description', [koq].[Description]
95955
+ ${singleSchema ? `
95956
+ ,'relativeError', [koq].[RelativeError],
95957
+ 'persistenceUnit', [koq].[PersistenceUnit],
95958
+ 'presentationUnits', (
95959
+ SELECT json_group_array(js."value")
95960
+ FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js
95961
+ WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]
95962
+ ) ` : ""}
95963
+ ) as [item]
95964
+ FROM
95965
+ [meta].[KindOfQuantityDef] [koq]
95966
+ ${singleSchema ? `
95967
+ JOIN
95968
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]
95969
+ WHERE [schema].[Name] = :schemaName
95970
+ ` : ""}
95971
+ `;
95972
+ /**
95973
+ * Query for SchemaItemType PropertyCategory data.
95974
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95975
+ */
95976
+ const propertyCategory = (singleSchema) => `
95977
+ SELECT
95978
+ [pc].[Schema].[Id] AS [SchemaId],
95979
+ json_object (
95980
+ 'schemaItemType', 'PropertyCategory',
95981
+ 'name', [pc].[Name],
95982
+ 'label', [pc].[DisplayLabel],
95983
+ 'description', [pc].[Description],
95984
+ 'priority', [pc].[Priority]
95985
+ ) as [item]
95986
+ FROM
95987
+ [meta].[PropertyCategoryDef] [pc]
95988
+ ${singleSchema ? `
95989
+ JOIN
95990
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]
95991
+ WHERE [schema].[Name] = :schemaName
95992
+ ` : ""}
95993
+ `;
95994
+ /**
95995
+ * Query for SchemaItemType Enumeration data.
95996
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95997
+ */
95998
+ const enumeration = (singleSchema) => `
95999
+ SELECT
96000
+ [ed].[Schema].[Id] AS [SchemaId],
96001
+ json_object (
96002
+ 'schemaItemType', 'Enumeration',
96003
+ 'name', [ed].[Name],
96004
+ 'label', [ed].[DisplayLabel],
96005
+ 'description', [ed].[Description],
96006
+ 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),
96007
+ 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),
96008
+ 'enumerators', (
96009
+ SELECT json_group_array(json(json_object(
96010
+ 'name', json_extract(js."value", '$.Name'),
96011
+ 'value', IFNULL(json_extract(js."value", '$.StringValue'), (json_extract(js."value", '$.IntValue'))),
96012
+ 'label', json_extract(js."value", '$.DisplayLabel'),
96013
+ 'description', json_extract(js."value", '$.Description')
96014
+ )))
96015
+ FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js
96016
+ WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]
96017
+ )
96018
+ ) as [item]
96019
+ FROM
96020
+ [meta].[ECEnumerationDef] [ed]
96021
+ ${singleSchema ? `
96022
+ JOIN
96023
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]
96024
+ WHERE [schema].[Name] = :schemaName` : ""}
96025
+ `;
96026
+ /**
96027
+ * Query for SchemaItemType Unit data.
96028
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96029
+ */
96030
+ const unit = (singleSchema) => `
96031
+ SELECT
96032
+ [ud].[Schema].[Id] AS [SchemaId],
96033
+ json_object (
96034
+ 'schemaItemType', 'Unit',
96035
+ 'name', [ud].[Name],
96036
+ 'label', [ud].[DisplayLabel],
96037
+ 'description', [ud].[Description],
96038
+ 'definition', [ud].[Definition],
96039
+ 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),
96040
+ 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),
96041
+ 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),
96042
+ 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),
96043
+ 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])
96044
+ ) as item
96045
+ FROM
96046
+ [meta].[UnitDef] [ud]
96047
+ ${singleSchema ? `
96048
+ JOIN
96049
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
96050
+ JOIN [meta].[UnitSystemDef] [usd]
96051
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
96052
+ JOIN [meta].[ECSchemaDef] [uss]
96053
+ ON [uss].[ECInstanceId] = [usd].[Schema].[Id]
96054
+ JOIN [meta].[PhenomenonDef] [pd]
96055
+ ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]
96056
+ JOIN [meta].[ECSchemaDef] [ps]
96057
+ ON [ps].[ECInstanceId] = [pd].[Schema].[Id]
96058
+ WHERE
96059
+ ${singleSchema ? `
96060
+ [schema].[Name] = :schemaName AND` : ""}
96061
+ [ud].[IsConstant] = 0 AND
96062
+ [ud].[InvertingUnit] IS NULL
96063
+ `;
96064
+ /**
96065
+ * Query for SchemaItemType InvertedUnit data.
96066
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96067
+ */
96068
+ const invertedUnit = (singleSchema) => `
96069
+ SELECT
96070
+ [ud].[Schema].[Id] AS [SchemaId],
96071
+ json_object (
96072
+ 'schemaItemType', 'InvertedUnit',
96073
+ 'name', [ud].[Name],
96074
+ 'label', [ud].[DisplayLabel],
96075
+ 'description', [ud].[Description],
96076
+ 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),
96077
+ 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))
96078
+ ) as [item]
96079
+ FROM
96080
+ [meta].[UnitDef] [ud]
96081
+ ${singleSchema ? `
96082
+ JOIN
96083
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
96084
+ JOIN [meta].[UnitSystemDef] [usd]
96085
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
96086
+ JOIN [meta].[ECSchemaDef] [systemSchema]
96087
+ ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]
96088
+ LEFT JOIN [meta].[UnitDef] [iud]
96089
+ ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]
96090
+ LEFT JOIN [meta].[ECSchemaDef] [ius]
96091
+ ON [ius].[ECInstanceId] = [iud].[Schema].[Id]
96092
+ WHERE
96093
+ ${singleSchema ? `
96094
+ [schema].[Name] = :schemaName AND` : ""}
96095
+ [ud].[IsConstant] = 0 AND
96096
+ [ud].[InvertingUnit] IS NOT NULL
96097
+ `;
96098
+ /**
96099
+ * Query for SchemaItemType Constant data.
96100
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96101
+ */
96102
+ const constant = (singleSchema) => `
96103
+ SELECT
96104
+ [cd].[Schema].[Id] AS [SchemaId],
96105
+ json_object(
96106
+ 'schemaItemType', 'Constant',
96107
+ 'name', [cd].[Name],
96108
+ 'label', [cd].[DisplayLabel],
96109
+ 'description', [cd].[Description],
96110
+ 'definition', [cd].[Definition],
96111
+ 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),
96112
+ 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),
96113
+ 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])
96114
+ ) as item
96115
+ FROM
96116
+ [meta].[UnitDef] [cd]
96117
+ ${singleSchema ? `
96118
+ JOIN
96119
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : ""}
96120
+ JOIN [meta].[PhenomenonDef] [phenomDef]
96121
+ ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]
96122
+ JOIN [meta].[ECSchemaDef] [phenomSchema]
96123
+ ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]
96124
+ WHERE
96125
+ ${singleSchema ? `
96126
+ [schema].[Name] = :schemaName AND` : ""}
96127
+ [cd].[IsConstant] = 1
96128
+ `;
96129
+ /**
96130
+ * Query for SchemaItemType UnitSystem data.
96131
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96132
+ */
96133
+ const unitSystem = (singleSchema) => `
96134
+ SELECT
96135
+ [us].[Schema].[Id] AS [SchemaId],
96136
+ json_object (
96137
+ 'schemaItemType', 'UnitSystem',
96138
+ 'name', [us].[Name],
96139
+ 'label', [us].[DisplayLabel],
96140
+ 'description', [us].[Description]
96141
+ ) as [item]
96142
+ FROM
96143
+ [meta].[UnitSystemDef] [us]
96144
+ ${singleSchema ? `
96145
+ JOIN
96146
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]
96147
+ WHERE [schema].[Name] = :schemaName` : ""}
96148
+ `;
96149
+ /**
96150
+ * Query for SchemaItemType Phenomenon data.
96151
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96152
+ */
96153
+ const phenomenon = (singleSchema) => `
96154
+ SELECT
96155
+ [pd].[Schema].[Id] AS [SchemaId],
96156
+ json_object(
96157
+ 'schemaItemType', 'Phenomenon',
96158
+ 'name', [pd].[Name],
96159
+ 'label', [pd].[DisplayLabel],
96160
+ 'description', [pd].[Description],
96161
+ 'definition', [pd].[Definition]
96162
+ ) as [item]
96163
+ FROM
96164
+ [meta].[PhenomenonDef] [pd]
96165
+ ${singleSchema ? `
96166
+ JOIN
96167
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]
96168
+ WHERE [schema].[Name] = :schemaName` : ""}
96169
+ `;
96170
+ /**
96171
+ * Query for SchemaItemType Format data.
96172
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96173
+ */
96174
+ const format = (singleSchema) => `
96175
+ SELECT
96176
+ [fd].[Schema].[Id] AS [SchemaId],
96177
+ json_object(
96178
+ 'schemaItemType', 'Format',
96179
+ 'name', [fd].[Name],
96180
+ 'label', [fd].[DisplayLabel],
96181
+ 'description', [fd].[Description],
96182
+ 'type', json_extract([fd].[NumericSpec], '$.type'),
96183
+ 'precision', json_extract([fd].[NumericSpec], '$.precision'),
96184
+ 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),
96185
+ 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),
96186
+ 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),
96187
+ 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),
96188
+ 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),
96189
+ 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),
96190
+ 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),
96191
+ 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),
96192
+ 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),
96193
+ 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')
96194
+ ${singleSchema ? `
96195
+ ,'composite', (
96196
+ SELECT
96197
+ json_object(
96198
+ 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),
96199
+ 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),
96200
+ 'units', (
96201
+ SELECT json_group_array(json(json_object(
96202
+ 'name', CONCAT([sd].[Name], '.', [ud].[Name]),
96203
+ 'label', [fud].[Label]
96204
+ )))
96205
+ FROM [meta].[FormatDef] [fd2]
96206
+ LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]
96207
+ LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]
96208
+ INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]
96209
+ WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]
96210
+ )
96211
+ )
96212
+ FROM [meta].[FormatDef] [fd1]
96213
+ WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL
96214
+ )` : ""}
96215
+ ) AS item
96216
+ FROM
96217
+ [meta].[FormatDef] [fd]
96218
+ ${singleSchema ? `
96219
+ JOIN
96220
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]
96221
+ WHERE [schema].[Name] = :schemaName` : ""}
96222
+ `;
96223
+ /**
96224
+ * Queries for each SchemaItemType
96225
+ * @internal
96226
+ */
96227
+ // eslint-disable-next-line @typescript-eslint/naming-convention
96228
+ const SchemaItemQueries = {
96229
+ kindOfQuantity,
96230
+ propertyCategory,
96231
+ enumeration,
96232
+ unit,
96233
+ invertedUnit,
96234
+ constant,
96235
+ unitSystem,
96236
+ phenomenon,
96237
+ format
96238
+ };
96239
+
96240
+
96241
+ /***/ }),
96242
+
96243
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js":
96244
+ /*!*******************************************************************************!*\
96245
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js ***!
96246
+ \*******************************************************************************/
96247
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
96248
+
96249
+ "use strict";
96250
+ __webpack_require__.r(__webpack_exports__);
96251
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
96252
+ /* harmony export */ SchemaParser: () => (/* binding */ SchemaParser),
96253
+ /* harmony export */ parseCustomAttribute: () => (/* binding */ parseCustomAttribute)
96254
+ /* harmony export */ });
96255
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
96256
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
96257
+ /* harmony import */ var _ClassParsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ClassParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js");
96258
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
96259
+ /*---------------------------------------------------------------------------------------------
96260
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
96261
+ * See LICENSE.md in the project root for license terms and full copyright notice.
96262
+ *--------------------------------------------------------------------------------------------*/
96263
+
96264
+
96265
+
96266
+
96267
+ function clean(_key, value) {
96268
+ return value === null ? undefined : value;
96269
+ }
96270
+ /**
96271
+ * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
96272
+ * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)
96273
+ * returned from the iModelDb is in a different format than is required for a given Schema or
96274
+ * SchemaItemProps JSON object.
96275
+ * @internal
96276
+ */
96277
+ class SchemaParser {
96278
+ /**
96279
+ * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps
96280
+ * JSON object.
96281
+ * @param schema The SchemaProps JSON object to parse.
96282
+ * @param context The SchemaContext that will contain the schema and it's references.
96283
+ * @returns The corrected SchemaProps JSON.
96284
+ */
96285
+ static async parse(schema, context) {
96286
+ const props = schema;
96287
+ props.$schema = _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
96288
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return parseCustomAttribute(attr); }) : undefined;
96289
+ props.label = props.label === null ? undefined : props.label;
96290
+ props.description = props.description === null ? undefined : props.description;
96291
+ if (props.items) {
96292
+ props.items = await this.parseItems(props.items, props.name, context);
96293
+ }
96294
+ if (!props.customAttributes || props.customAttributes.length === 0)
96295
+ delete props.customAttributes;
96296
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
96297
+ return cleaned;
96298
+ }
96299
+ /**
96300
+ * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.
96301
+ * @param schemaItems The SchemaItemProps array returned from an iModelDb.
96302
+ * @param schemaName The name of the Schema to which the SchemaItemProps belong.
96303
+ * @param context The SchemaContext containing the Schema.
96304
+ * @returns The corrected SchemaItemProps.
96305
+ */
96306
+ static async parseSchemaItems(schemaItems, schemaName, context) {
96307
+ const items = [];
96308
+ for (const item of schemaItems) {
96309
+ const props = await this.parseItem(item, schemaName, context);
96310
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
96311
+ items.push(cleaned);
96312
+ }
96313
+ return items.length > 0 ? items : undefined;
96314
+ }
96315
+ static async parseItems(schemaItemProps, schemaName, context) {
96316
+ const items = {};
96317
+ for (const itemProps of schemaItemProps) {
96318
+ const props = await this.parseItem(itemProps, schemaName, context);
96319
+ items[props.name] = props;
96320
+ delete props.name;
96321
+ }
96322
+ return Object.keys(items).length > 0 ? items : undefined;
96323
+ }
96324
+ static async parseItem(props, schemaName, context) {
96325
+ const schemaItem = "string" === typeof (props) ? JSON.parse(props) : props;
96326
+ const type = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(schemaItem.schemaItemType);
96327
+ switch (type) {
96328
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
96329
+ const koqParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.KindOfQuantityParser(schemaName, context);
96330
+ return koqParser.parse(schemaItem);
96331
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
96332
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
96333
+ const classParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.ClassParser(schemaName, context);
96334
+ return classParser.parse(schemaItem);
96335
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
96336
+ const relationshipParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.RelationshipClassParser(schemaName, context);
96337
+ return relationshipParser.parse(schemaItem);
96338
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
96339
+ const mixinParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.MixinParser(schemaName, context);
96340
+ return mixinParser.parse(schemaItem);
96341
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
96342
+ const caParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.CustomAttributeClassParser(schemaName, context);
96343
+ return caParser.parse(schemaItem);
96344
+ default:
96345
+ const itemParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.SchemaItemParser(schemaName, context);
96346
+ return itemParser.parse(schemaItem);
96347
+ }
96348
+ }
96349
+ }
96350
+ /**
96351
+ * Utility method to parse CustomAttribute data retrieved from a ECSql query.
96352
+ * @param customAttribute CustomAttribute data as retrieved from an iModel query.
96353
+ * @returns The CustomAttribute instance.
96354
+ * @internal
96355
+ */
96356
+ function parseCustomAttribute(customAttribute) {
96357
+ return {
96358
+ ...customAttribute[customAttribute.ecClass],
96359
+ className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,
96360
+ };
96361
+ }
96362
+
96363
+
96364
+ /***/ }),
96365
+
96366
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js":
96367
+ /*!************************************************************************************!*\
96368
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js ***!
96369
+ \************************************************************************************/
96370
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
96371
+
96372
+ "use strict";
96373
+ __webpack_require__.r(__webpack_exports__);
96374
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
96375
+ /* harmony export */ ecsqlQueries: () => (/* binding */ ecsqlQueries),
96376
+ /* harmony export */ modifier: () => (/* binding */ modifier),
96377
+ /* harmony export */ strength: () => (/* binding */ strength),
96378
+ /* harmony export */ strengthDirection: () => (/* binding */ strengthDirection)
96379
+ /* harmony export */ });
96380
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
96381
+ /*---------------------------------------------------------------------------------------------
96382
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
96383
+ * See LICENSE.md in the project root for license terms and full copyright notice.
96384
+ *--------------------------------------------------------------------------------------------*/
96385
+
96386
+ const modifier = (alias) => {
96387
+ return `
96388
+ CASE
96389
+ WHEN [${alias}].[modifier] = 0 THEN 'None'
96390
+ WHEN [${alias}].[modifier] = 1 THEN 'Abstract'
96391
+ WHEN [${alias}].[modifier] = 2 THEN 'Sealed'
96392
+ ELSE NULL
96393
+ END
96394
+ `;
96395
+ };
96396
+ const strength = (alias) => {
96397
+ return `
96398
+ CASE
96399
+ WHEN [${alias}].[RelationshipStrength] = 0 THEN 'Referencing'
96400
+ WHEN [${alias}].[RelationshipStrength] = 1 THEN 'Holding'
96401
+ WHEN [${alias}].[RelationshipStrength] = 2 THEN 'Embedding'
96402
+ ELSE NULL
96403
+ END
96404
+ `;
96405
+ };
96406
+ const strengthDirection = (alias) => {
96407
+ return `
96408
+ CASE
96409
+ WHEN [${alias}].[RelationshipStrengthDirection] = 1 THEN 'Forward'
96410
+ WHEN [${alias}].[RelationshipStrengthDirection] = 2 THEN 'Backward'
96411
+ ELSE NULL
96412
+ END
96413
+ `;
96414
+ };
96415
+ const withAppliesTo = `
96416
+ AppliesToCTE AS (
96417
+ SELECT
96418
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
96419
+ [appliesToSchema].[name] as [AppliesToSchema],
96420
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
96421
+ FROM [meta].[CustomAttribute] [ca]
96422
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
96423
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
96424
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
96425
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
96426
+ WHERE [ca].[ContainerType] = 30
96427
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
96428
+ )
96429
+ `;
96430
+ const withSchemaReferences = `
96431
+ SchemaReferences AS (
96432
+ SELECT
96433
+ [ref].[SourceECInstanceId] AS [SchemaId],
96434
+ CONCAT([Name],'.',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [fullName]
96435
+ FROM
96436
+ [meta].[ECSchemaDef] AS [refSchema]
96437
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
96438
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
96439
+ )
96440
+ `;
96441
+ const customAttributeQuery = `
96442
+ SELECT
96443
+ [Schema].[Id] AS [SchemaId],
96444
+ json_object(
96445
+ 'name', [class].[Name],
96446
+ 'schemaItemType', 'CustomAttributeClass',
96447
+ 'modifier', ${modifier("class")},
96448
+ 'label', [class].[DisplayLabel],
96449
+ 'description', [class].[Description],
96450
+ 'appliesTo', [class].[CustomAttributeContainerType],
96451
+ 'baseClasses', (
96452
+ SELECT
96453
+ json_group_array(json(json_object(
96454
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96455
+ 'name', [baseClass].[Name],
96456
+ 'schemaItemType', 'CustomAttributeClass',
96457
+ 'modifier', ${modifier("baseClass")},
96458
+ 'label', [baseClass].[DisplayLabel],
96459
+ 'description', [baseClass].[Description],
96460
+ 'appliesTo', [baseClass].[CustomAttributeContainerType]
96461
+ )))
96462
+ FROM
96463
+ [meta].[ECClassDef] [baseClass]
96464
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96465
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96466
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96467
+ )
96468
+ ) AS [item]
96469
+ FROM [meta].[ECClassDef] [class]
96470
+ WHERE [class].[Type] = 3
96471
+ `;
96472
+ const structQuery = `
96473
+ SELECT
96474
+ [Schema].[Id] AS [SchemaId],
96475
+ json_object(
96476
+ 'name', [class].[Name],
96477
+ 'schemaItemType', 'StructClass',
96478
+ 'modifier', ${modifier("class")},
96479
+ 'label', [class].[DisplayLabel],
96480
+ 'description', [class].[Description],
96481
+ 'baseClasses', (
96482
+ SELECT
96483
+ json_group_array(json(json_object(
96484
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96485
+ 'name', [baseClass].[Name],
96486
+ 'schemaItemType', 'StructClass',
96487
+ 'modifier', ${modifier("baseClass")},
96488
+ 'label', [baseClass].[DisplayLabel],
96489
+ 'description', [baseClass].[Description]
96490
+ )))
96491
+ FROM
96492
+ [meta].[ECClassDef] [baseClass]
96493
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96494
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96495
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96496
+ )
96497
+ ) AS [item]
96498
+ FROM [meta].[ECClassDef] [class]
96499
+ WHERE [class].[Type] = 2
96500
+ `;
96501
+ const relationshipQuery = `
96502
+ SELECT
96503
+ [Schema].[Id] AS [SchemaId],
96504
+ json_object(
96505
+ 'name', [class].[Name],
96506
+ 'schemaItemType', 'RelationshipClass',
96507
+ 'modifier', ${modifier("class")},
96508
+ 'label', [class].[DisplayLabel],
96509
+ 'description', [class].[Description],
96510
+ 'strength', ${strength("class")},
96511
+ 'strengthDirection', ${strengthDirection("class")},
96512
+ 'baseClasses', (
96513
+ SELECT
96514
+ json_group_array(json(json_object(
96515
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96516
+ 'name', [baseClass].[Name],
96517
+ 'schemaItemType', 'RelationshipClass',
96518
+ 'modifier', ${modifier("baseClass")},
96519
+ 'label', [baseClass].[DisplayLabel],
96520
+ 'description', [baseClass].[Description],
96521
+ 'strength', ${strength("baseClass")},
96522
+ 'strengthDirection', ${strengthDirection("baseClass")}
96523
+ )))
96524
+ FROM
96525
+ [meta].[ECClassDef] [baseClass]
96526
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96527
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96528
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96529
+ )
96530
+ ) AS [item]
96531
+ FROM [meta].[ECClassDef] [class]
96532
+ WHERE [class].[Type] = 1
96533
+ `;
96534
+ const entityQuery = `
96535
+ SELECT
96536
+ [Schema].[Id] AS [SchemaId],
96537
+ json_object(
96538
+ 'name', [class].[Name],
96539
+ 'schemaItemType', 'EntityClass',
96540
+ 'modifier', ${modifier("class")},
96541
+ 'label', [class].[DisplayLabel],
96542
+ 'description', [class].[Description],
96543
+ 'baseClasses', (
96544
+ SELECT
96545
+ json_group_array(json(json_object(
96546
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96547
+ 'name', [baseClass].[Name],
96548
+ 'schemaItemType', 'EntityClass',
96549
+ 'modifier', ${modifier("baseClass")},
96550
+ 'label', [baseClass].[DisplayLabel],
96551
+ 'description', [baseClass].[Description]
96552
+ )))
96553
+ FROM
96554
+ [meta].[ECClassDef] [baseClass]
96555
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96556
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96557
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96558
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
96559
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96560
+ ),
96561
+ 'mixins', (
96562
+ SELECT
96563
+ json_group_array(json(json_object(
96564
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96565
+ 'name', [baseClass].[Name],
96566
+ 'schemaItemType', 'Mixin',
96567
+ 'modifier', ${modifier("baseClass")},
96568
+ 'label', [baseClass].[DisplayLabel],
96569
+ 'description', [baseClass].[Description],
96570
+ 'appliesTo', (
96571
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96572
+ FROM [AppliesToCTE] [atCTE]
96573
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
96574
+ ),
96575
+ 'baseClasses', (
96576
+ SELECT
96577
+ json_group_array(json(json_object(
96578
+ 'schema', ec_classname([mixinBaseClass].[ECInstanceId], 's'),
96579
+ 'name', [mixinBaseClass].[Name],
96580
+ 'schemaItemType', 'Mixin',
96581
+ 'modifier', ${modifier("mixinBaseClass")},
96582
+ 'label', [mixinBaseClass].[DisplayLabel],
96583
+ 'description', [mixinBaseClass].[Description],
96584
+ 'appliesTo', (
96585
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96586
+ FROM [AppliesToCTE] [atCTE]
96587
+ WHERE [atCTE].[AppliesToId] = [mixinBaseClass].[ECInstanceId]
96588
+ )
96589
+ )))
96590
+ FROM
96591
+ [meta].[ECClassDef] [mixinBaseClass]
96592
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [mixinBaseClassMap]
96593
+ ON [mixinBaseClassMap].[TargetECInstanceId] = [mixinBaseClass].[ECInstanceId]
96594
+ WHERE [mixinBaseClassMap].[SourceECInstanceId] = [baseClass].[ECInstanceId]
96595
+ )
96596
+ )))
96597
+ FROM
96598
+ [meta].[ECClassDef] [baseClass]
96599
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
96600
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96601
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96602
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
96603
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96604
+ )
96605
+ ) AS [item]
96606
+ FROM [meta].[ECClassDef] [class]
96607
+ WHERE [class].[Type] = 0
96608
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
96609
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96610
+ `;
96611
+ const mixinQuery = `
96612
+ SELECT
96613
+ [Schema].[Id] AS [SchemaId],
96614
+ json_object(
96615
+ 'name', [class].[Name],
96616
+ 'schemaItemType', 'Mixin',
96617
+ 'modifier', ${modifier("class")},
96618
+ 'label', [class].[DisplayLabel],
96619
+ 'description', [class].[Description],
96620
+ 'appliesTo', (
96621
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96622
+ FROM [AppliesToCTE] [atCTE]
96623
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
96624
+ ),
96625
+ 'baseClasses', (
96626
+ SELECT
96627
+ json_group_array(json(json_object(
96628
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96629
+ 'name', [baseClass].[Name],
96630
+ 'schemaItemType', 'Mixin',
96631
+ 'modifier', ${modifier("baseClass")},
96632
+ 'label', [baseClass].[DisplayLabel],
96633
+ 'description', [baseClass].[Description],
96634
+ 'appliesTo', (
96635
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96636
+ FROM [AppliesToCTE] [atCTE]
96637
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
96638
+ )
96639
+ )))
96640
+ FROM
96641
+ [meta].[ECClassDef] [baseClass]
96642
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96643
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96644
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96645
+ )
96646
+ ) AS [item]
96647
+ FROM [meta].[ECClassDef] [class]
96648
+ WHERE [class].[Type] = 0 AND EXISTS (SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
96649
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96650
+ `;
96651
+ const withSchemaItems = `
96652
+ SchemaItems AS (
96653
+ ${customAttributeQuery}
96654
+ UNION ALL
96655
+ ${structQuery}
96656
+ UNION ALL
96657
+ ${relationshipQuery}
96658
+ UNION ALL
96659
+ ${entityQuery}
96660
+ UNION ALL
96661
+ ${mixinQuery}
96662
+ UNION ALL
96663
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration()}
96664
+ UNION ALL
96665
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity()}
96666
+ UNION ALL
96667
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory()}
96668
+ UNION ALL
96669
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit()}
96670
+ UNION ALL
96671
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit()}
96672
+ UNION ALL
96673
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant()}
96674
+ UNION ALL
96675
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon()}
96676
+ UNION ALL
96677
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem()}
96678
+ UNION ALL
96679
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format()}
96680
+ )
96681
+ `;
96682
+ const schemaStubQuery = `
96683
+ WITH
96684
+ ${withSchemaReferences},
96685
+ ${withAppliesTo},
96686
+ ${withSchemaItems}
96687
+ SELECT
96688
+ [Name] as [name],
96689
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
96690
+ [Alias] as [alias],
96691
+ [DisplayLabel] as [displayLabel],
96692
+ [Description] as [description],
96693
+ (
96694
+ SELECT
96695
+ json_group_array([schemaReferences].[fullName])
96696
+ FROM
96697
+ [SchemaReferences] [schemaReferences]
96698
+ WHERE
96699
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
96700
+ ) AS [references],
96701
+ (
96702
+ SELECT
96703
+ json_group_array(json([items].[item]))
96704
+ FROM
96705
+ [SchemaItems] [items]
96706
+ WHERE
96707
+ [items].[SchemaId] = [schemaDef].[ECInstanceId]
96708
+ ) AS [items]
96709
+ FROM
96710
+ [meta].[ECSchemaDef] [schemaDef]
96711
+ WHERE [Name] = :schemaName
96712
+ `;
96713
+ const schemaInfoQuery = `
96714
+ WITH
96715
+ ${withSchemaReferences}
96716
+ SELECT
96717
+ [Name] as [name],
96718
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
96719
+ [Alias] as [alias],
96720
+ (
96721
+ SELECT
96722
+ json_group_array([schemaReferences].[fullName])
96723
+ FROM
96724
+ [SchemaReferences] [schemaReferences]
96725
+ WHERE
96726
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
96727
+ ) AS [references]
96728
+ FROM
96729
+ [meta].[ECSchemaDef] [schemaDef]
96730
+ `;
96731
+ /**
96732
+ * Partial Schema queries.
96733
+ * @internal
96734
+ */
96735
+ const ecsqlQueries = {
96736
+ schemaStubQuery,
96737
+ schemaInfoQuery,
96738
+ };
96739
+
96740
+
94267
96741
  /***/ }),
94268
96742
 
94269
96743
  /***/ "../../core/ecschema-metadata/lib/esm/Interfaces.js":
@@ -94590,6 +97064,7 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
94590
97064
  else
94591
97065
  correctType = structType;
94592
97066
  if (!correctType)
97067
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
94593
97068
  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.`);
94594
97069
  return correctType;
94595
97070
  }
@@ -94609,6 +97084,7 @@ class ECClass extends _SchemaItem__WEBPACK_IMPORTED_MODULE_9__.SchemaItem {
94609
97084
  else
94610
97085
  correctType = structType;
94611
97086
  if (!correctType)
97087
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
94612
97088
  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.`);
94613
97089
  return correctType;
94614
97090
  }
@@ -98453,6 +100929,7 @@ class Schema {
98453
100929
  _customAttributes;
98454
100930
  _originalECSpecMajorVersion;
98455
100931
  _originalECSpecMinorVersion;
100932
+ _loadingController;
98456
100933
  /** @internal */
98457
100934
  constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
98458
100935
  this._schemaKey = (typeof (nameOrKey) === "string") ? new _SchemaKey__WEBPACK_IMPORTED_MODULE_6__.SchemaKey(nameOrKey, new _SchemaKey__WEBPACK_IMPORTED_MODULE_6__.ECVersion(readVer, writeVer, minorVer)) : nameOrKey;
@@ -98518,6 +100995,14 @@ class Schema {
98518
100995
  get schema() { return this; }
98519
100996
  /** Returns the schema context this schema is within. */
98520
100997
  get context() { return this._context; }
100998
+ /**
100999
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
101000
+ * loaded incrementally.
101001
+ * @internal
101002
+ */
101003
+ get loadingController() {
101004
+ return this._loadingController;
101005
+ }
98521
101006
  /**
98522
101007
  * Returns a SchemaItemKey given the item name and the schema it belongs to
98523
101008
  * @param fullName fully qualified name {Schema name}.{Item Name}
@@ -99143,6 +101628,10 @@ class Schema {
99143
101628
  }
99144
101629
  this._alias = alias;
99145
101630
  }
101631
+ /** @internal */
101632
+ setLoadingController(controller) {
101633
+ this._loadingController = controller;
101634
+ }
99146
101635
  }
99147
101636
  /**
99148
101637
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
@@ -99196,6 +101685,7 @@ class SchemaItem {
99196
101685
  _key;
99197
101686
  _description;
99198
101687
  _label;
101688
+ _loadingController;
99199
101689
  /** @internal */
99200
101690
  constructor(schema, name) {
99201
101691
  this._key = new _SchemaKey__WEBPACK_IMPORTED_MODULE_3__.SchemaItemKey(name, schema.schemaKey);
@@ -99206,6 +101696,14 @@ class SchemaItem {
99206
101696
  get key() { return this._key; }
99207
101697
  get label() { return this._label; }
99208
101698
  get description() { return this._description; }
101699
+ /**
101700
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
101701
+ * loaded incrementally.
101702
+ * @internal
101703
+ */
101704
+ get loadingController() {
101705
+ return this._loadingController;
101706
+ }
99209
101707
  // 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().
99210
101708
  /**
99211
101709
  * Save this SchemaItem's properties to an object for serializing to JSON.
@@ -99311,6 +101809,10 @@ class SchemaItem {
99311
101809
  setDescription(description) {
99312
101810
  this._description = description;
99313
101811
  }
101812
+ /** @internal */
101813
+ setLoadingController(controller) {
101814
+ this._loadingController = controller;
101815
+ }
99314
101816
  }
99315
101817
 
99316
101818
 
@@ -101465,6 +103967,7 @@ __webpack_require__.r(__webpack_exports__);
101465
103967
  /* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
101466
103968
  /* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
101467
103969
  /* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
103970
+ /* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
101468
103971
  /* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
101469
103972
  /* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
101470
103973
  /* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
@@ -101472,6 +103975,7 @@ __webpack_require__.r(__webpack_exports__);
101472
103975
  /* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
101473
103976
  /* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
101474
103977
  /* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
103978
+ /* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
101475
103979
  /* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
101476
103980
  /* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
101477
103981
  /* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
@@ -101494,7 +103998,7 @@ __webpack_require__.r(__webpack_exports__);
101494
103998
  /* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
101495
103999
  /* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
101496
104000
  /* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.SchemaFormatsProvider),
101497
- /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_39__.SchemaGraph),
104001
+ /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
101498
104002
  /* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
101499
104003
  /* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
101500
104004
  /* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
@@ -101575,7 +104079,9 @@ __webpack_require__.r(__webpack_exports__);
101575
104079
  /* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
101576
104080
  /* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
101577
104081
  /* harmony import */ var _SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(/*! ./SchemaFormatsProvider */ "../../core/ecschema-metadata/lib/esm/SchemaFormatsProvider.js");
101578
- /* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
104082
+ /* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
104083
+ /* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
104084
+ /* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
101579
104085
  /*---------------------------------------------------------------------------------------------
101580
104086
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
101581
104087
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -101617,6 +104123,8 @@ __webpack_require__.r(__webpack_exports__);
101617
104123
 
101618
104124
 
101619
104125
 
104126
+
104127
+
101620
104128
 
101621
104129
 
101622
104130
 
@@ -101759,6 +104267,81 @@ class SchemaGraph {
101759
104267
  }
101760
104268
 
101761
104269
 
104270
+ /***/ }),
104271
+
104272
+ /***/ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js":
104273
+ /*!*****************************************************************************!*\
104274
+ !*** ../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js ***!
104275
+ \*****************************************************************************/
104276
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
104277
+
104278
+ "use strict";
104279
+ __webpack_require__.r(__webpack_exports__);
104280
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
104281
+ /* harmony export */ SchemaLoadingController: () => (/* binding */ SchemaLoadingController)
104282
+ /* harmony export */ });
104283
+ /*---------------------------------------------------------------------------------------------
104284
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
104285
+ * See LICENSE.md in the project root for license terms and full copyright notice.
104286
+ *--------------------------------------------------------------------------------------------*/
104287
+ /**
104288
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
104289
+ * class is set in Schema and SchemaItem instances.
104290
+ * @internal
104291
+ */
104292
+ class SchemaLoadingController {
104293
+ _complete;
104294
+ _inProgress;
104295
+ _promise;
104296
+ /**
104297
+ * Indicates of the Schema or SchemaItem has been fully loaded.
104298
+ */
104299
+ get isComplete() {
104300
+ return this._complete;
104301
+ }
104302
+ /**
104303
+ * Marks that a Schema or SchemaItem has been fully loaded.
104304
+ */
104305
+ set isComplete(value) {
104306
+ this._complete = value;
104307
+ }
104308
+ /**
104309
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
104310
+ */
104311
+ get inProgress() {
104312
+ return this._inProgress;
104313
+ }
104314
+ /**
104315
+ * Initializes a new SchemaLoadingController instance.
104316
+ */
104317
+ constructor() {
104318
+ this._complete = false;
104319
+ this._inProgress = false;
104320
+ }
104321
+ /**
104322
+ * Call this method when starting to load a Schema or SchemaItem
104323
+ * @param promise The promise used to update the controller state when the promise is resolved.
104324
+ */
104325
+ start(promise) {
104326
+ this._inProgress = true;
104327
+ void promise.then(() => {
104328
+ this._complete = true;
104329
+ this._inProgress = false;
104330
+ });
104331
+ this._promise = promise;
104332
+ }
104333
+ /**
104334
+ * Waits on the Promise given in SchemaLoadingController.start().
104335
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
104336
+ */
104337
+ async wait() {
104338
+ if (!this._promise)
104339
+ throw new Error("LoadingController 'start' must be called before 'wait'");
104340
+ return this._promise;
104341
+ }
104342
+ }
104343
+
104344
+
101762
104345
  /***/ }),
101763
104346
 
101764
104347
  /***/ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js":
@@ -101907,6 +104490,74 @@ class ECSchemaRpcLocater {
101907
104490
  }
101908
104491
 
101909
104492
 
104493
+ /***/ }),
104494
+
104495
+ /***/ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js":
104496
+ /*!*****************************************************************************!*\
104497
+ !*** ../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js ***!
104498
+ \*****************************************************************************/
104499
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
104500
+
104501
+ "use strict";
104502
+ __webpack_require__.r(__webpack_exports__);
104503
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
104504
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* binding */ RpcIncrementalSchemaLocater)
104505
+ /* harmony export */ });
104506
+ /* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
104507
+ /* harmony import */ var _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/ecschema-metadata */ "../../core/ecschema-metadata/lib/esm/ecschema-metadata.js");
104508
+ /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
104509
+ /*---------------------------------------------------------------------------------------------
104510
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
104511
+ * See LICENSE.md in the project root for license terms and full copyright notice.
104512
+ *--------------------------------------------------------------------------------------------*/
104513
+
104514
+
104515
+
104516
+ /**
104517
+ * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.
104518
+ * @beta
104519
+ */
104520
+ class RpcIncrementalSchemaLocater extends _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__.ECSqlSchemaLocater {
104521
+ _iModelProps;
104522
+ /**
104523
+ * Initializes a new instance of the RpcIncrementalSchemaLocater class.
104524
+ */
104525
+ constructor(iModelProps, options) {
104526
+ super(options);
104527
+ this._iModelProps = iModelProps;
104528
+ }
104529
+ /**
104530
+ * Executes the given ECSql query and returns the resulting rows.
104531
+ * @param query The ECSql query to execute.
104532
+ * @param options Optional arguments to control the query result.
104533
+ * @returns A promise that resolves to the resulting rows.
104534
+ */
104535
+ async executeQuery(query, options) {
104536
+ const ecSqlQueryClient = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.IModelReadRpcInterface.getClient();
104537
+ const queryExecutor = {
104538
+ execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),
104539
+ };
104540
+ const queryOptions = {
104541
+ limit: { count: options?.limit },
104542
+ rowFormat: _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryRowFormat.UseECSqlPropertyNames,
104543
+ };
104544
+ const queryParameters = options && options.parameters ? _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryBinder.from(options.parameters) : undefined;
104545
+ const queryReader = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ECSqlReader(queryExecutor, query, queryParameters, queryOptions);
104546
+ return queryReader.toArray();
104547
+ }
104548
+ /**
104549
+ * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).
104550
+ * This is the full schema json with all elements that are defined in the schema.
104551
+ * @param schemaKey The schema key of the schema to be resolved.
104552
+ */
104553
+ async getSchemaProps(schemaKey) {
104554
+ const rpcSchemaClient = _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__.ECSchemaRpcInterface.getClient();
104555
+ return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);
104556
+ }
104557
+ ;
104558
+ }
104559
+
104560
+
101910
104561
  /***/ }),
101911
104562
 
101912
104563
  /***/ "../../core/ecschema-rpc/common/lib/esm/ecschema-rpc-interface.js":
@@ -101919,10 +104570,12 @@ class ECSchemaRpcLocater {
101919
104570
  __webpack_require__.r(__webpack_exports__);
101920
104571
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
101921
104572
  /* harmony export */ ECSchemaRpcInterface: () => (/* reexport safe */ _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__.ECSchemaRpcInterface),
101922
- /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater)
104573
+ /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater),
104574
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* reexport safe */ _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__.RpcIncrementalSchemaLocater)
101923
104575
  /* harmony export */ });
101924
104576
  /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
101925
104577
  /* harmony import */ var _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ECSchemaRpcLocater */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcLocater.js");
104578
+ /* harmony import */ var _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RpcIncrementalSchemaLocater */ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js");
101926
104579
  /*---------------------------------------------------------------------------------------------
101927
104580
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
101928
104581
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -101931,6 +104584,7 @@ __webpack_require__.r(__webpack_exports__);
101931
104584
 
101932
104585
 
101933
104586
 
104587
+
101934
104588
  /***/ }),
101935
104589
 
101936
104590
  /***/ "../../core/frontend/lib/esm/AccuDraw.js":
@@ -109987,6 +112641,7 @@ class SectionAttachment {
109987
112641
  is3d: true,
109988
112642
  scale: { x: 1, y: 1 },
109989
112643
  },
112644
+ contours: view.getDisplayStyle3d().settings.contours
109990
112645
  };
109991
112646
  this._viewFlagOverrides = { ...view.viewFlags, lighting: false, shadows: false };
109992
112647
  // Save off the original frustum (potentially adjusted by viewport).
@@ -141381,7 +144036,7 @@ class BatchUniforms {
141381
144036
  this._sensors.bindTexture(uniform);
141382
144037
  }
141383
144038
  get wantContourLines() {
141384
- const contours = this._target.plan.contours;
144039
+ const contours = this._target.currentBranch.contourLine;
141385
144040
  return undefined !== contours && contours.displayContours && contours.groups.length > 0;
141386
144041
  }
141387
144042
  bindContourLUT(uniform) {
@@ -141513,6 +144168,7 @@ class BranchStack {
141513
144168
  viewFlags: new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ViewFlags(),
141514
144169
  transform: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createIdentity(),
141515
144170
  edgeSettings: _EdgeSettings__WEBPACK_IMPORTED_MODULE_5__.EdgeSettings.create(undefined),
144171
+ contourLine: undefined,
141516
144172
  is3d: true,
141517
144173
  symbologyOverrides: new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_3__.FeatureSymbology.Overrides(),
141518
144174
  });
@@ -141541,9 +144197,9 @@ class BranchStack {
141541
144197
  this._stack.pop();
141542
144198
  }
141543
144199
  }
141544
- changeRenderPlan(vf, is3d, hline) {
144200
+ changeRenderPlan(vf, is3d, hline, contour) {
141545
144201
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(1 === this.length);
141546
- this.top.changeRenderPlan(vf, is3d, hline);
144202
+ this.top.changeRenderPlan(vf, is3d, hline, contour);
141547
144203
  }
141548
144204
  setSymbologyOverrides(ovrs) {
141549
144205
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(1 === this.length);
@@ -141606,16 +144262,18 @@ class BranchState {
141606
144262
  get inSectionDrawingAttachment() { return this._opts.inSectionDrawingAttachment; }
141607
144263
  get groupNodeId() { return this._opts.groupNodeId; }
141608
144264
  get disableClipStyle() { return this._opts.disableClipStyle; }
144265
+ get contourLine() { return this._opts.contourLine; }
141609
144266
  get symbologyOverrides() {
141610
144267
  return this._opts.symbologyOverrides;
141611
144268
  }
141612
144269
  set symbologyOverrides(ovrs) {
141613
144270
  this._opts.symbologyOverrides = ovrs;
141614
144271
  }
141615
- changeRenderPlan(viewFlags, is3d, hline) {
144272
+ changeRenderPlan(viewFlags, is3d, hline, contour) {
141616
144273
  this.viewFlags = viewFlags;
141617
144274
  this._opts.is3d = is3d;
141618
144275
  this.edgeSettings.init(hline);
144276
+ this._opts.contourLine = contour;
141619
144277
  }
141620
144278
  /** Create a BranchState from a Branch. Any properties not explicitly specified by the new Branch are inherited from the previous BranchState. */
141621
144279
  static fromBranch(prev, branch) {
@@ -141640,6 +144298,7 @@ class BranchState {
141640
144298
  inSectionDrawingAttachment: branch.inSectionDrawingAttachment ?? prev.inSectionDrawingAttachment,
141641
144299
  groupNodeId: branch.branch.groupNodeId ?? prev.groupNodeId,
141642
144300
  disableClipStyle: branch.disableClipStyle ?? prev.disableClipStyle,
144301
+ contourLine: branch.contourLine ?? prev.contourLine,
141643
144302
  });
141644
144303
  }
141645
144304
  getFeatureAppearance(overrides, elemLo, elemHi, subcatLo, subcatHi, geomClass, modelLo, modelHi, type, animationNodeId) {
@@ -141802,8 +144461,8 @@ class BranchUniforms {
141802
144461
  this._viewClipEnabled = false;
141803
144462
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)((this._target.isReadPixelsInProgress ? 2 : 1) === this._stack.length);
141804
144463
  }
141805
- changeRenderPlan(vf, is3d, hline) {
141806
- this._stack.changeRenderPlan(vf, is3d, hline);
144464
+ changeRenderPlan(vf, is3d, hline, contourLine) {
144465
+ this._stack.changeRenderPlan(vf, is3d, hline, contourLine);
141807
144466
  }
141808
144467
  updateViewClip(clip, style) {
141809
144468
  this.clipStack.setViewClip(clip, style);
@@ -143565,12 +146224,11 @@ class ContourUniforms {
143565
146224
  this._contourDefs[startNdx + offset + 1] = majorIntervalCount < 1.0 ? 1.0 : majorIntervalCount;
143566
146225
  }
143567
146226
  update(target) {
143568
- const plan = target.plan;
143569
- if (this.contourDisplay && plan.contours && this.contourDisplay.equals(plan.contours)) {
146227
+ if (this.contourDisplay && target.currentContours && this.contourDisplay.equals(target.currentContours)) {
143570
146228
  return;
143571
146229
  }
143572
146230
  (0,_Sync__WEBPACK_IMPORTED_MODULE_1__.desync)(this);
143573
- this._contourDisplay = plan.contours;
146231
+ this._contourDisplay = target.currentContours;
143574
146232
  if (undefined === this.contourDisplay)
143575
146233
  return;
143576
146234
  /* uniform packing for contourDefs:
@@ -143660,14 +146318,14 @@ class Contours {
143660
146318
  return target === this.target && this._numFeatures === map.numFeatures;
143661
146319
  }
143662
146320
  matchesSubCategories() {
143663
- if (this._contours === undefined && this.target.plan.contours === undefined)
146321
+ if (this._contours === undefined && this.target.currentContours === undefined)
143664
146322
  return true;
143665
- if (this._contours === undefined || this.target.plan.contours === undefined)
146323
+ if (this._contours === undefined || this.target.currentContours === undefined)
143666
146324
  return false;
143667
- if (this._contours.groups.length !== this.target.plan.contours.groups.length)
146325
+ if (this._contours.groups.length !== this.target.currentContours.groups.length)
143668
146326
  return false;
143669
146327
  for (let index = 0, len = this._contours.groups.length; index < len && index < _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.ContourDisplay.maxContourGroups; ++index) {
143670
- if (!this._contours.groups[index].subCategoriesEqual(this.target.plan.contours.groups[index]))
146328
+ if (!this._contours.groups[index].subCategoriesEqual(this.target.currentContours.groups[index]))
143671
146329
  return false;
143672
146330
  }
143673
146331
  return true;
@@ -143681,14 +146339,14 @@ class Contours {
143681
146339
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(width * height * 8 >= this._numFeatures);
143682
146340
  const data = new Uint8Array(width * height * 4);
143683
146341
  const creator = new _Texture__WEBPACK_IMPORTED_MODULE_5__.Texture2DDataUpdater(data);
143684
- this.buildLookupTable(creator, map, this.target.plan.contours);
146342
+ this.buildLookupTable(creator, map, this.target.currentContours);
143685
146343
  this._lut = _Texture__WEBPACK_IMPORTED_MODULE_5__.TextureHandle.createForData(width, height, data, true, _GL__WEBPACK_IMPORTED_MODULE_2__.GL.Texture.WrapMode.ClampToEdge);
143686
146344
  this._lutWidth = width;
143687
146345
  }
143688
146346
  _update(map, lut) {
143689
146347
  (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(this._numFeatures === map.numFeatures);
143690
146348
  const updater = new _Texture__WEBPACK_IMPORTED_MODULE_5__.Texture2DDataUpdater(lut.dataBytes);
143691
- this.buildLookupTable(updater, map, this.target.plan.contours);
146349
+ this.buildLookupTable(updater, map, this.target.currentContours);
143692
146350
  lut.update(updater);
143693
146351
  }
143694
146352
  buildLookupTable(data, map, contours) {
@@ -143726,7 +146384,7 @@ class Contours {
143726
146384
  constructor(target, options) {
143727
146385
  this.target = target;
143728
146386
  this._options = options;
143729
- this._contours = target.plan.contours;
146387
+ this._contours = target.currentContours;
143730
146388
  }
143731
146389
  static createFromTarget(target, options) {
143732
146390
  return new Contours(target, options);
@@ -143743,7 +146401,7 @@ class Contours {
143743
146401
  update(features) {
143744
146402
  if (this.matchesSubCategories())
143745
146403
  return;
143746
- this._contours = this.target.plan.contours;
146404
+ this._contours = this.target.currentContours;
143747
146405
  // _lut can be undefined if context was lost, (gl.createTexture returns null)
143748
146406
  if (this._lut) {
143749
146407
  this._update(features, this._lut);
@@ -146508,6 +149166,7 @@ class Branch extends Graphic {
146508
149166
  inSectionDrawingAttachment;
146509
149167
  disableClipStyle;
146510
149168
  transformFromExternalIModel;
149169
+ contourLine;
146511
149170
  constructor(branch, localToWorld, viewFlags, opts) {
146512
149171
  super();
146513
149172
  this.branch = branch;
@@ -146524,6 +149183,7 @@ class Branch extends Graphic {
146524
149183
  this.inSectionDrawingAttachment = opts.inSectionDrawingAttachment;
146525
149184
  this.disableClipStyle = opts.disableClipStyle;
146526
149185
  this.transformFromExternalIModel = opts.transformFromIModel;
149186
+ this.contourLine = opts.contours;
146527
149187
  if (opts.hline)
146528
149188
  this.edgeSettings = _EdgeSettings__WEBPACK_IMPORTED_MODULE_6__.EdgeSettings.create(opts.hline);
146529
149189
  if (opts.classifierOrDrape instanceof _PlanarClassifier__WEBPACK_IMPORTED_MODULE_8__.PlanarClassifier)
@@ -153504,7 +156164,7 @@ class Compositor extends SceneCompositor {
153504
156164
  }
153505
156165
  readContours(rect) {
153506
156166
  // Are we actually drawing any contours? If not, don't bother reading an array of all zeroes off the GPU.
153507
- const contours = this.target.plan.contours;
156167
+ const contours = this.target.currentContours;
153508
156168
  if (!contours || !contours.displayContours || contours.groups.length === 0) {
153509
156169
  return undefined;
153510
156170
  }
@@ -153682,6 +156342,7 @@ class Compositor extends SceneCompositor {
153682
156342
  iModel: top.iModel,
153683
156343
  is3d: top.is3d,
153684
156344
  edgeSettings: top.edgeSettings,
156345
+ contourLine: top.contourLine,
153685
156346
  });
153686
156347
  this._vcSetStencilRenderState = new _RenderState__WEBPACK_IMPORTED_MODULE_14__.RenderState();
153687
156348
  this._vcCopyZRenderState = new _RenderState__WEBPACK_IMPORTED_MODULE_14__.RenderState();
@@ -158154,6 +160815,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
158154
160815
  const drape = this.currentTextureDrape;
158155
160816
  return undefined === drape ? this.currentPlanarClassifier : drape;
158156
160817
  }
160818
+ get currentContours() { return this.currentBranch.contourLine; }
158157
160819
  modelToView(modelPt, result) {
158158
160820
  return this.uniforms.branch.modelViewMatrix.multiplyPoint3dQuietNormalize(modelPt, result);
158159
160821
  }
@@ -158364,7 +161026,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
158364
161026
  this._wantAmbientOcclusion = false;
158365
161027
  vf = vf.with("ambientOcclusion", false);
158366
161028
  }
158367
- this.uniforms.branch.changeRenderPlan(vf, plan.is3d, plan.hline);
161029
+ this.uniforms.branch.changeRenderPlan(vf, plan.is3d, plan.hline, plan.contours);
158368
161030
  this.changeFrustum(plan.frustum, plan.fraction, plan.is3d);
158369
161031
  this.uniforms.thematic.update(this);
158370
161032
  this.uniforms.contours.update(this);
@@ -158663,6 +161325,7 @@ class Target extends _render_RenderTarget__WEBPACK_IMPORTED_MODULE_7__.RenderTar
158663
161325
  edgeSettings: top.edgeSettings,
158664
161326
  transform: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createIdentity(),
158665
161327
  clipVolume: top.clipVolume,
161328
+ contourLine: top.contourLine,
158666
161329
  });
158667
161330
  this.pushState(state);
158668
161331
  // Repopulate the command list, omitting non-pickable decorations and putting transparent stuff into the opaque passes.
@@ -212356,7 +215019,7 @@ class Geometry {
212356
215019
  static largeCoordinateResult = 1.0e13;
212357
215020
  /**
212358
215021
  * Numeric value that may considered infinite for metric coordinates.
212359
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[largeCoordinateResult]].
215022
+ * @deprecated in 4.9.0 - will not be removed until after 2026-06-13. Use [[largeCoordinateResult]].
212360
215023
  * * This coordinate should be used only as a placeholder indicating "at infinity" -- computing actual
212361
215024
  * points at this coordinate invites numerical problems.
212362
215025
  */
@@ -212367,7 +215030,7 @@ class Geometry {
212367
215030
  }
212368
215031
  /**
212369
215032
  * Test if the absolute value of x is at least [[largeCoordinateResult]].
212370
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[isLargeCoordinateResult]].
215033
+ * @deprecated in 4.9.0 - will not be removed until after 2026-06-13. Use [[isLargeCoordinateResult]].
212371
215034
  */
212372
215035
  static isHugeCoordinate(x) {
212373
215036
  return Geometry.isLargeCoordinateResult(x);
@@ -213334,7 +215997,7 @@ class Geometry {
213334
215997
  /**
213335
215998
  * Clone an array whose members have type `T`, which implements the clone method.
213336
215999
  * * If the clone method returns `undefined`, then `undefined` is forced into the cloned array.
213337
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use cloneArray.
216000
+ * @deprecated in 4.4.0 - will not be removed until after 2026-06-13. Use cloneArray.
213338
216001
  */
213339
216002
  // eslint-disable-next-line @typescript-eslint/no-deprecated
213340
216003
  static cloneMembers(array) {
@@ -213760,7 +216423,7 @@ class BSpline1dNd {
213760
216423
  * Test if the leading and trailing polygon coordinates are replicated in the manner of a "closed" bspline polygon
213761
216424
  * which has been expanded to act as a normal bspline.
213762
216425
  * @returns true if `degree` leading and trailing polygon blocks match.
213763
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use `testClosablePolygon` instead.
216426
+ * @deprecated in 4.2.1 - will not be removed until after 2026-06-13. Use `testClosablePolygon` instead.
213764
216427
  */
213765
216428
  testCloseablePolygon(mode) {
213766
216429
  return this.testClosablePolygon(mode);
@@ -216060,7 +218723,7 @@ var UVSelect;
216060
218723
  UVSelect[UVSelect["uDirection"] = 0] = "uDirection";
216061
218724
  /**
216062
218725
  * index of v direction
216063
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use vDirection instead.
218726
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use vDirection instead.
216064
218727
  */
216065
218728
  UVSelect[UVSelect["VDirection"] = 1] = "VDirection";
216066
218729
  /** index of v direction */
@@ -216287,7 +218950,7 @@ class BSpline2dNd extends _curve_GeometryQuery__WEBPACK_IMPORTED_MODULE_0__.Geom
216287
218950
  }
216288
218951
  /**
216289
218952
  * sum poles by the weights in the basisBuffer, using poles for given span
216290
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use sumPoleBufferDerivativesForSpan instead.
218953
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use sumPoleBufferDerivativesForSpan instead.
216291
218954
  */
216292
218955
  sumpoleBufferDerivativesForSpan(spanIndexU, spanIndexV) {
216293
218956
  return this.sumPoleBufferDerivativesForSpan(spanIndexU, spanIndexV);
@@ -229647,7 +232310,7 @@ class CurveLocationDetailPair {
229647
232310
  }
229648
232311
  /**
229649
232312
  * Data bundle for a pair of arrays of CurveLocationDetail structures.
229650
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use CurveLocationDetailPair[] instead.
232313
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use CurveLocationDetailPair[] instead.
229651
232314
  * @public
229652
232315
  */
229653
232316
  class CurveLocationDetailArrayPair {
@@ -237633,7 +240296,7 @@ class StrokeOptions {
237633
240296
  maxEdgeLength;
237634
240297
  /**
237635
240298
  * Caller expects convex facets.
237636
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].
240299
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Never used. See [[shouldTriangulate]] and [[maximizeConvexFacets]].
237637
240300
  */
237638
240301
  needConvexFacets;
237639
240302
  /** Minimum strokes on a primitive. */
@@ -251901,7 +254564,7 @@ class GrowableXYArray extends _IndexedXYCollection__WEBPACK_IMPORTED_MODULE_0__.
251901
254564
  return result;
251902
254565
  }
251903
254566
  /** Restructure MultiLineStringDataVariant as array of GrowableXYZArray
251904
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Moved to GrowableXYZArray class.
254567
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Moved to GrowableXYZArray class.
251905
254568
  */
251906
254569
  static createArrayOfGrowableXYZArray(data) {
251907
254570
  return _GrowableXYZArray__WEBPACK_IMPORTED_MODULE_1__.GrowableXYZArray.createArrayOfGrowableXYZArray(data);
@@ -270595,7 +273258,7 @@ class Point4d extends _geometry3d_Plane3d__WEBPACK_IMPORTED_MODULE_0__.Plane3d {
270595
273258
  * extract 4 consecutive numbers from a Float64Array into a Point4d.
270596
273259
  * @param data buffer of numbers
270597
273260
  * @param xIndex first index for x,y,z,w sequence. Assumed to be a valid index!
270598
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use createFromPacked instead.
273261
+ * @deprecated in 4.3.0 - will not be removed until after 2026-06-13. Use createFromPacked instead.
270599
273262
  */
270600
273263
  static createFromPackedXYZW(data, xIndex = 0, result) {
270601
273264
  return Point4d.create(data[xIndex], data[xIndex + 1], data[xIndex + 2], data[xIndex + 3], result);
@@ -279923,7 +282586,7 @@ class IndexedPolyface extends Polyface {
279923
282586
  }
279924
282587
  /**
279925
282588
  * Clean up the open facet.
279926
- * @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]]
282589
+ * @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]]
279927
282590
  * instead.
279928
282591
  */
279929
282592
  cleanupOpenFacet() {
@@ -280073,7 +282736,7 @@ class IndexedPolyface extends Polyface {
280073
282736
  }
280074
282737
  /**
280075
282738
  * Given the index of a facet, return the data pertaining to the face it is a part of.
280076
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.
282739
+ * @deprecated in 4.5.0 - will not be removed until after 2026-06-13. Use [[IndexedPolyface.tryGetFaceData]], which verifies the index is in range.
280077
282740
  */
280078
282741
  getFaceDataByFacetIndex(facetIndex) {
280079
282742
  return this.data.face[this._facetToFaceData[facetIndex]];
@@ -281295,7 +283958,7 @@ class PolyfaceBuilder extends _geometry3d_GeometryHandler__WEBPACK_IMPORTED_MODU
281295
283958
  * Apply stroke counts to curve primitives.
281296
283959
  * * Recursively visit all children of data.
281297
283960
  * * At each primitive, invoke `computeStrokeCountForOptions` method with options from the builder.
281298
- * @deprecated in 4.x - will not be removed until after 2026-06-13. This method does nothing and is unneeded.
283961
+ * @deprecated in 4.8.0 - will not be removed until after 2026-06-13. This method does nothing and is unneeded.
281299
283962
  */
281300
283963
  applyStrokeCountsToCurvePrimitives(data) {
281301
283964
  const options = this._options;
@@ -283334,7 +285997,7 @@ class PolyfaceData {
283334
285997
  }
283335
285998
  /**
283336
285999
  * Resize all data arrays to the specified `length`.
283337
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Because name is misleading. Call [[PolyfaceData.resizeAllArrays]] instead.
286000
+ * @deprecated in 4.5.0 - will not be removed until after 2026-06-13. Because name is misleading. Call [[PolyfaceData.resizeAllArrays]] instead.
283338
286001
  */
283339
286002
  resizeAllDataArrays(length) {
283340
286003
  if (length > this.point.length) {
@@ -284906,7 +287569,7 @@ class PolyfaceQuery {
284906
287569
  });
284907
287570
  return builder.claimPolyface(true);
284908
287571
  }
284909
- /** @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[sweepLineStringToFacetsXYReturnSweptFacets]] instead. */
287572
+ /** @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[sweepLineStringToFacetsXYReturnSweptFacets]] instead. */
284910
287573
  static sweepLinestringToFacetsXYreturnSweptFacets(linestringPoints, polyface) {
284911
287574
  return this.sweepLineStringToFacetsXYReturnSweptFacets(linestringPoints, polyface);
284912
287575
  }
@@ -285009,7 +287672,7 @@ class PolyfaceQuery {
285009
287672
  * * Return collected line segments.
285010
287673
  * * This calls [[sweepLineStringToFacets]] with options created by
285011
287674
  * `const options = SweepLineStringToFacetsOptions.create(Vector3d.unitZ(), Angle.createSmallAngle(), false, true, true, true);`
285012
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
287675
+ * @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
285013
287676
  */
285014
287677
  static sweepLinestringToFacetsXYReturnLines(linestringPoints, polyface) {
285015
287678
  const options = SweepLineStringToFacetsOptions.create(_geometry3d_Point3dVector3d__WEBPACK_IMPORTED_MODULE_1__.Vector3d.unitZ(), _geometry3d_Angle__WEBPACK_IMPORTED_MODULE_2__.Angle.createSmallAngle(), false, true, true, true);
@@ -285019,7 +287682,7 @@ class PolyfaceQuery {
285019
287682
  * Find segments (within the linestring) which project to facets.
285020
287683
  * * Return chains.
285021
287684
  * * This calls [[sweepLineStringToFacets]] with default options.
285022
- * @deprecated in 4.x - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
287685
+ * @deprecated in 4.7.0 - will not be removed until after 2026-06-13. Use [[PolyfaceQuery.sweepLineStringToFacets]] to get further options.
285023
287686
  */
285024
287687
  static sweepLinestringToFacetsXYReturnChains(linestringPoints, polyface) {
285025
287688
  return PolyfaceQuery.sweepLineStringToFacets(linestringPoints, polyface);
@@ -298816,7 +301479,7 @@ class Sample {
298816
301479
  return points;
298817
301480
  }
298818
301481
  // cspell:word creat
298819
- /** @deprecated in 4.x - will not be removed until after 2026-06-13. Use createVerticalStaggerPolygon instead. */
301482
+ /** @deprecated in 4.0.0 - will not be removed until after 2026-06-13. Use createVerticalStaggerPolygon instead. */
298820
301483
  static creatVerticalStaggerPolygon(dy1, dy2, dy3, dy4, ax, ay, dx1, dx4) {
298821
301484
  return this.createVerticalStaggerPolygon(dy1, dy2, dy3, dy4, ax, ay, dx1, dx4);
298822
301485
  }
@@ -328419,7 +331082,7 @@ class QuantityConstants {
328419
331082
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
328420
331083
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = ",";
328421
331084
  const matches = (12345.6789).toLocaleString().match(/12(.*)345/);
328422
- if (matches && matches.length > 0)
331085
+ if (matches && matches.length > 1 && matches[1] !== "")
328423
331086
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];
328424
331087
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
328425
331088
  }
@@ -332205,7 +334868,7 @@ class TestContext {
332205
334868
  this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
332206
334869
  const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
332207
334870
  await core_frontend_1.NoRenderApp.startup({
332208
- applicationVersion: "5.1.0-dev.59",
334871
+ applicationVersion: "5.1.0-dev.61",
332209
334872
  applicationId: this.settings.gprid,
332210
334873
  authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
332211
334874
  hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
@@ -332486,7 +335149,7 @@ class UiAdmin {
332486
335149
  /** Get the cursor X and Y position. */
332487
335150
  get cursorPosition() { return { x: 0, y: 0 }; }
332488
335151
  /** Create a PointProps object.
332489
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation.
335152
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Please use @core/geometry [[XAndY]] or a custom implementation.
332490
335153
  */
332491
335154
  createXAndY(x, y) { return { x, y }; }
332492
335155
  /** Determines if focus is set to Home */
@@ -332789,7 +335452,7 @@ __webpack_require__.r(__webpack_exports__);
332789
335452
  /**
332790
335453
  * Class that define Standard Content Layouts that can be used to specify how the content is arranged in a frontstage.
332791
335454
  * @public
332792
- * @deprecated in 4.10.x - will not be removed until after 2026-06-13. Use `StandardContentLayouts` from `@itwin/appui-react`.
335455
+ * @deprecated in 4.10.0 - will not be removed until after 2026-06-13. Use `StandardContentLayouts` from `@itwin/appui-react`.
332793
335456
  */
332794
335457
  class StandardContentLayouts {
332795
335458
  static singleView = {
@@ -334448,14 +337111,15 @@ __webpack_require__.r(__webpack_exports__);
334448
337111
 
334449
337112
  /** UiSync Event class.
334450
337113
  * @public
334451
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Use [[UiSyncEvent]] from @itwin/appui-react.
337114
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use [[UiSyncEvent]] from @itwin/appui-react.
334452
337115
  */
337116
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
334453
337117
  class UiSyncEvent extends _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BeUiEvent {
334454
337118
  }
334455
337119
  /** This class is used to send eventIds to interested UI components so the component can determine if it needs
334456
337120
  * to refresh its display by calling setState on itself.
334457
337121
  * @public
334458
- * @deprecated in 4.2.x - will not be removed until after 2026-06-13. Use [[SyncUiEventDispatcher]] from @itwin/appui-react.
337122
+ * @deprecated in 4.2.0 - will not be removed until after 2026-06-13. Use [[SyncUiEventDispatcher]] from @itwin/appui-react.
334459
337123
  */
334460
337124
  class UiEventDispatcher {
334461
337125
  _syncEventTimerId;
@@ -338303,6 +340967,7 @@ class ElementPropertiesBuilder {
338303
340967
  processPrimitiveValue(props) {
338304
340968
  this._currentAppender.append(props.field.label, {
338305
340969
  type: "primitive",
340970
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string
338306
340971
  value: props.displayValue?.toString() ?? "",
338307
340972
  });
338308
340973
  }
@@ -357292,7 +359957,7 @@ var loadLanguages = instance.loadLanguages;
357292
359957
  /***/ ((module) => {
357293
359958
 
357294
359959
  "use strict";
357295
- 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"}}');
359960
+ 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"}}');
357296
359961
 
357297
359962
  /***/ }),
357298
359963