@itwin/rpcinterface-full-stack-tests 5.1.0-dev.58 → 5.1.0-dev.60

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.
@@ -90622,8 +90622,11 @@ class SchemaReadHelper {
90622
90622
  * calling getCachedSchema on the context.
90623
90623
  * @param schema The Schema to populate
90624
90624
  * @param rawSchema The serialized data to use to populate the Schema.
90625
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
90626
+ * The default is true. If false, the schema loading will not begin asynchronously in the background because the
90627
+ * schema promise must be added to the context. In this case, only the SchemaInfo is returned.
90625
90628
  */
90626
- async readSchemaInfo(schema, rawSchema) {
90629
+ async readSchemaInfo(schema, rawSchema, addSchemaToCache = true) {
90627
90630
  // Ensure context matches schema context
90628
90631
  if (schema.context) {
90629
90632
  if (this._context !== schema.context)
@@ -90636,15 +90639,15 @@ class SchemaReadHelper {
90636
90639
  // Loads all of the properties on the Schema object
90637
90640
  await schema.fromJSON(this._parser.parseSchema());
90638
90641
  this._schema = schema;
90639
- const schemaInfoReferences = [];
90640
- const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaInfoReferences };
90642
+ const schemaReferences = [];
90643
+ const schemaInfo = { schemaKey: schema.schemaKey, alias: schema.alias, references: schemaReferences };
90641
90644
  for (const reference of this._parser.getReferences()) {
90642
90645
  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 });
90646
+ schemaReferences.push({ schemaKey: refKey });
90644
90647
  }
90645
90648
  this._schemaInfo = schemaInfo;
90646
90649
  // Need to add this schema to the context to be able to locate schemaItems within the context.
90647
- if (!this._context.schemaExists(schema.schemaKey)) {
90650
+ if (addSchemaToCache && !this._context.schemaExists(schema.schemaKey)) {
90648
90651
  await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));
90649
90652
  }
90650
90653
  return schemaInfo;
@@ -90653,33 +90656,53 @@ class SchemaReadHelper {
90653
90656
  * Populates the given Schema from a serialized representation.
90654
90657
  * @param schema The Schema to populate
90655
90658
  * @param rawSchema The serialized data to use to populate the Schema.
90659
+ * @param addSchemaToCache Optional parameter that indicates if the schema should be added to the SchemaContext.
90660
+ * The default is true. If false, the schema will be loaded directly by this method and not from the context's schema cache.
90656
90661
  */
90657
- async readSchema(schema, rawSchema) {
90662
+ async readSchema(schema, rawSchema, addSchemaToCache = true) {
90658
90663
  if (!this._schemaInfo) {
90659
- await this.readSchemaInfo(schema, rawSchema);
90664
+ await this.readSchemaInfo(schema, rawSchema, addSchemaToCache);
90665
+ }
90666
+ // If not adding schema to cache (occurs in readSchemaInfo), we must load the schema here
90667
+ if (!addSchemaToCache) {
90668
+ const loadedSchema = await this.loadSchema(this._schemaInfo, schema);
90669
+ if (undefined === loadedSchema)
90670
+ throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
90671
+ return loadedSchema;
90660
90672
  }
90661
90673
  const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.Latest);
90662
90674
  if (undefined === cachedSchema)
90663
90675
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
90664
90676
  return cachedSchema;
90665
90677
  }
90678
+ /**
90679
+ * Called when a SchemaItem has been successfully loaded by the Helper. The default implementation simply
90680
+ * checks if the schema item is undefined. An implementation of the helper may choose to partially load
90681
+ * a schema item in which case this method would indicate if the item has been fully loaded.
90682
+ * @param schemaItem The SchemaItem to check.
90683
+ * @returns True if the SchemaItem has been fully loaded, false otherwise.
90684
+ */
90685
+ isSchemaItemLoaded(schemaItem) {
90686
+ return schemaItem !== undefined;
90687
+ }
90666
90688
  /* Finish loading the rest of the schema */
90667
90689
  async loadSchema(schemaInfo, schema) {
90668
90690
  // Verify that there are no schema reference cycles, this will start schema loading by loading their headers
90669
90691
  (await _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_8__.SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();
90670
90692
  for (const reference of schemaInfo.references) {
90671
- await this.loadSchemaReference(schemaInfo, reference.schemaKey);
90693
+ await this.loadSchemaReference(schema, reference.schemaKey);
90672
90694
  }
90673
90695
  if (this._visitorHelper)
90674
90696
  await this._visitorHelper.visitSchema(schema, false);
90675
90697
  // Load all schema items
90676
90698
  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,
90699
+ // Make sure the item has not already been loaded. No need to check the SchemaContext because all SchemaItems are added to a Schema,
90678
90700
  // which would be found when adding to the context.
90679
- if (await schema.getItem(itemName) !== undefined)
90701
+ const schemaItem = await schema.getItem(itemName);
90702
+ if (this.isSchemaItemLoaded(schemaItem))
90680
90703
  continue;
90681
90704
  const loadedItem = await this.loadSchemaItem(schema, itemName, itemType, rawItem);
90682
- if (loadedItem && this._visitorHelper) {
90705
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
90683
90706
  await this._visitorHelper.visitSchemaPart(loadedItem);
90684
90707
  }
90685
90708
  }
@@ -90710,12 +90733,8 @@ class SchemaReadHelper {
90710
90733
  this._visitorHelper.visitSchemaSync(schema, false);
90711
90734
  // Load all schema items
90712
90735
  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
90736
  const loadedItem = this.loadSchemaItemSync(schema, itemName, itemType, rawItem);
90718
- if (loadedItem && this._visitorHelper) {
90737
+ if (this.isSchemaItemLoaded(loadedItem) && this._visitorHelper) {
90719
90738
  this._visitorHelper.visitSchemaPartSync(loadedItem);
90720
90739
  }
90721
90740
  }
@@ -90728,12 +90747,14 @@ class SchemaReadHelper {
90728
90747
  * Ensures that the schema references can be located and adds them to the schema.
90729
90748
  * @param ref The object to read the SchemaReference's props from.
90730
90749
  */
90731
- async loadSchemaReference(schemaInfo, refKey) {
90750
+ async loadSchemaReference(schema, refKey) {
90732
90751
  const refSchema = await this._context.getSchema(refKey, _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaMatchType.LatestWriteCompatible);
90733
90752
  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);
90753
+ 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}`);
90754
+ if (schema.references.find((ref) => ref.schemaKey.matches(refSchema.schemaKey)))
90755
+ return refSchema;
90756
+ await schema.addReference(refSchema);
90757
+ const results = this.validateSchemaReferences(schema);
90737
90758
  let errorMessage = "";
90738
90759
  for (const result of results) {
90739
90760
  errorMessage += `${result}\r\n`;
@@ -90741,6 +90762,7 @@ class SchemaReadHelper {
90741
90762
  if (errorMessage) {
90742
90763
  throw new _Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaError(_Exception__WEBPACK_IMPORTED_MODULE_2__.ECSchemaStatus.InvalidECJson, `${errorMessage}`);
90743
90764
  }
90765
+ return refSchema;
90744
90766
  }
90745
90767
  /**
90746
90768
  * Ensures that the schema references can be located and adds them to the schema.
@@ -90790,73 +90812,97 @@ class SchemaReadHelper {
90790
90812
  * @param schemaItemObject The Object to populate the SchemaItem with.
90791
90813
  */
90792
90814
  async loadSchemaItem(schema, name, itemType, schemaItemObject) {
90793
- let schemaItem;
90815
+ let schemaItem = await schema.getItem(name);
90816
+ if (this.isSchemaItemLoaded(schemaItem)) {
90817
+ return schemaItem;
90818
+ }
90794
90819
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
90795
90820
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
90796
- schemaItem = await schema.createEntityClass(name);
90797
- await this.loadEntityClass(schemaItem, schemaItemObject);
90821
+ schemaItem = schemaItem || await schema.createEntityClass(name);
90822
+ schemaItemObject && await this.loadEntityClass(schemaItem, schemaItemObject);
90798
90823
  break;
90799
90824
  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);
90825
+ schemaItem = schemaItem || await schema.createStructClass(name);
90826
+ const structProps = schemaItemObject && this._parser.parseStructClass(schemaItemObject);
90827
+ structProps && await this.loadClass(schemaItem, structProps, schemaItemObject);
90803
90828
  break;
90804
90829
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
90805
- schemaItem = await schema.createMixinClass(name);
90806
- await this.loadMixin(schemaItem, schemaItemObject);
90830
+ schemaItem = schemaItem || await schema.createMixinClass(name);
90831
+ schemaItemObject && await this.loadMixin(schemaItem, schemaItemObject);
90807
90832
  break;
90808
90833
  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);
90834
+ schemaItem = schemaItem || await schema.createCustomAttributeClass(name);
90835
+ const caClassProps = schemaItemObject && this._parser.parseCustomAttributeClass(schemaItemObject);
90836
+ caClassProps && await this.loadClass(schemaItem, caClassProps, schemaItemObject);
90812
90837
  break;
90813
90838
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
90814
- schemaItem = await schema.createRelationshipClass(name);
90815
- await this.loadRelationshipClass(schemaItem, schemaItemObject);
90839
+ schemaItem = schemaItem || await schema.createRelationshipClass(name);
90840
+ schemaItemObject && await this.loadRelationshipClass(schemaItem, schemaItemObject);
90816
90841
  break;
90817
90842
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
90818
- schemaItem = await schema.createKindOfQuantity(name);
90819
- await this.loadKindOfQuantity(schemaItem, schemaItemObject);
90843
+ schemaItem = schemaItem || await schema.createKindOfQuantity(name);
90844
+ schemaItemObject && await this.loadKindOfQuantity(schemaItem, schemaItemObject);
90820
90845
  break;
90821
90846
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
90822
- schemaItem = await schema.createUnit(name);
90823
- await this.loadUnit(schemaItem, schemaItemObject);
90847
+ schemaItem = schemaItem || await schema.createUnit(name);
90848
+ schemaItemObject && await this.loadUnit(schemaItem, schemaItemObject);
90824
90849
  break;
90825
90850
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
90826
- schemaItem = await schema.createConstant(name);
90827
- await this.loadConstant(schemaItem, schemaItemObject);
90851
+ schemaItem = schemaItem || await schema.createConstant(name);
90852
+ schemaItemObject && await this.loadConstant(schemaItem, schemaItemObject);
90828
90853
  break;
90829
90854
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
90830
- schemaItem = await schema.createInvertedUnit(name);
90831
- await this.loadInvertedUnit(schemaItem, schemaItemObject);
90855
+ schemaItem = schemaItem || await schema.createInvertedUnit(name);
90856
+ schemaItemObject && await this.loadInvertedUnit(schemaItem, schemaItemObject);
90832
90857
  break;
90833
90858
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
90834
- schemaItem = await schema.createFormat(name);
90835
- await this.loadFormat(schemaItem, schemaItemObject);
90859
+ schemaItem = schemaItem || await schema.createFormat(name);
90860
+ schemaItemObject && await this.loadFormat(schemaItem, schemaItemObject);
90836
90861
  break;
90837
90862
  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);
90863
+ schemaItem = schemaItem || await schema.createPhenomenon(name);
90864
+ const phenomenonProps = schemaItemObject && this._parser.parsePhenomenon(schemaItemObject);
90865
+ phenomenonProps && await schemaItem.fromJSON(phenomenonProps);
90841
90866
  break;
90842
90867
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
90843
- schemaItem = await schema.createUnitSystem(name);
90844
- await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
90868
+ schemaItem = schemaItem || await schema.createUnitSystem(name);
90869
+ schemaItemObject && await schemaItem.fromJSON(this._parser.parseUnitSystem(schemaItemObject));
90845
90870
  break;
90846
90871
  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);
90872
+ schemaItem = schemaItem || await schema.createPropertyCategory(name);
90873
+ const propertyCategoryProps = schemaItemObject && this._parser.parsePropertyCategory(schemaItemObject);
90874
+ propertyCategoryProps && schemaItemObject && await schemaItem.fromJSON(propertyCategoryProps);
90850
90875
  break;
90851
90876
  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);
90877
+ schemaItem = schemaItem || await schema.createEnumeration(name);
90878
+ const enumerationProps = schemaItemObject && this._parser.parseEnumeration(schemaItemObject);
90879
+ enumerationProps && await schemaItem.fromJSON(enumerationProps);
90855
90880
  break;
90856
90881
  // 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
90882
  }
90858
90883
  return schemaItem;
90859
90884
  }
90885
+ /**
90886
+ * Load the customAttribute class dependencies for a set of CustomAttribute objects and add
90887
+ * them to a given custom attribute container.
90888
+ * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
90889
+ * @param customAttributes An iterable set of parsed CustomAttribute objects.
90890
+ */
90891
+ async loadCustomAttributes(container, caProviders) {
90892
+ for (const providerTuple of caProviders) {
90893
+ // First tuple entry is the CA class name.
90894
+ const caClass = await this.findSchemaItem(providerTuple[0]);
90895
+ // If custom attribute exist within the context and is referenced, validate the reference is defined in the container's schema
90896
+ if (caClass && caClass.key.schemaName !== container.schema.name &&
90897
+ !container.schema.getReferenceSync(caClass.key.schemaName)) {
90898
+ 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`);
90899
+ }
90900
+ // Second tuple entry ia a function that provides the CA instance.
90901
+ const provider = providerTuple[1];
90902
+ const customAttribute = provider(caClass);
90903
+ container.addCustomAttribute(customAttribute);
90904
+ }
90905
+ }
90860
90906
  /**
90861
90907
  * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
90862
90908
  * @param schema The Schema the SchemaItem to.
@@ -90865,66 +90911,69 @@ class SchemaReadHelper {
90865
90911
  * @param schemaItemObject The Object to populate the SchemaItem with.
90866
90912
  */
90867
90913
  loadSchemaItemSync(schema, name, itemType, schemaItemObject) {
90868
- let schemaItem;
90914
+ let schemaItem = schema.getItemSync(name);
90915
+ if (this.isSchemaItemLoaded(schemaItem)) {
90916
+ return schemaItem;
90917
+ }
90869
90918
  switch ((0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(itemType)) {
90870
90919
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
90871
- schemaItem = schema.createEntityClassSync(name);
90920
+ schemaItem = schemaItem || schema.createEntityClassSync(name);
90872
90921
  this.loadEntityClassSync(schemaItem, schemaItemObject);
90873
90922
  break;
90874
90923
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
90875
- schemaItem = schema.createStructClassSync(name);
90924
+ schemaItem = schemaItem || schema.createStructClassSync(name);
90876
90925
  const structProps = this._parser.parseStructClass(schemaItemObject);
90877
90926
  this.loadClassSync(schemaItem, structProps, schemaItemObject);
90878
90927
  break;
90879
90928
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
90880
- schemaItem = schema.createMixinClassSync(name);
90929
+ schemaItem = schemaItem || schema.createMixinClassSync(name);
90881
90930
  this.loadMixinSync(schemaItem, schemaItemObject);
90882
90931
  break;
90883
90932
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
90884
- schemaItem = schema.createCustomAttributeClassSync(name);
90933
+ schemaItem = schemaItem || schema.createCustomAttributeClassSync(name);
90885
90934
  const caClassProps = this._parser.parseCustomAttributeClass(schemaItemObject);
90886
90935
  this.loadClassSync(schemaItem, caClassProps, schemaItemObject);
90887
90936
  break;
90888
90937
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
90889
- schemaItem = schema.createRelationshipClassSync(name);
90938
+ schemaItem = schemaItem || schema.createRelationshipClassSync(name);
90890
90939
  this.loadRelationshipClassSync(schemaItem, schemaItemObject);
90891
90940
  break;
90892
90941
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
90893
- schemaItem = schema.createKindOfQuantitySync(name);
90942
+ schemaItem = schemaItem || schema.createKindOfQuantitySync(name);
90894
90943
  this.loadKindOfQuantitySync(schemaItem, schemaItemObject);
90895
90944
  break;
90896
90945
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Unit:
90897
- schemaItem = schema.createUnitSync(name);
90946
+ schemaItem = schemaItem || schema.createUnitSync(name);
90898
90947
  this.loadUnitSync(schemaItem, schemaItemObject);
90899
90948
  break;
90900
90949
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Constant:
90901
- schemaItem = schema.createConstantSync(name);
90950
+ schemaItem = schemaItem || schema.createConstantSync(name);
90902
90951
  this.loadConstantSync(schemaItem, schemaItemObject);
90903
90952
  break;
90904
90953
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.InvertedUnit:
90905
- schemaItem = schema.createInvertedUnitSync(name);
90954
+ schemaItem = schemaItem || schema.createInvertedUnitSync(name);
90906
90955
  this.loadInvertedUnitSync(schemaItem, schemaItemObject);
90907
90956
  break;
90908
90957
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Format:
90909
- schemaItem = schema.createFormatSync(name);
90958
+ schemaItem = schemaItem || schema.createFormatSync(name);
90910
90959
  this.loadFormatSync(schemaItem, schemaItemObject);
90911
90960
  break;
90912
90961
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Phenomenon:
90913
- schemaItem = schema.createPhenomenonSync(name);
90962
+ schemaItem = schemaItem || schema.createPhenomenonSync(name);
90914
90963
  const phenomenonProps = this._parser.parsePhenomenon(schemaItemObject);
90915
90964
  schemaItem.fromJSONSync(phenomenonProps);
90916
90965
  break;
90917
90966
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.UnitSystem:
90918
- schemaItem = schema.createUnitSystemSync(name);
90967
+ schemaItem = schemaItem || schema.createUnitSystemSync(name);
90919
90968
  schemaItem.fromJSONSync(this._parser.parseUnitSystem(schemaItemObject));
90920
90969
  break;
90921
90970
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.PropertyCategory:
90922
- schemaItem = schema.createPropertyCategorySync(name);
90971
+ schemaItem = schemaItem || schema.createPropertyCategorySync(name);
90923
90972
  const propertyCategoryProps = this._parser.parsePropertyCategory(schemaItemObject);
90924
90973
  schemaItem.fromJSONSync(propertyCategoryProps);
90925
90974
  break;
90926
90975
  case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Enumeration:
90927
- schemaItem = schema.createEnumerationSync(name);
90976
+ schemaItem = schemaItem || schema.createEnumerationSync(name);
90928
90977
  const enumerationProps = this._parser.parseEnumeration(schemaItemObject);
90929
90978
  schemaItem.fromJSONSync(enumerationProps);
90930
90979
  break;
@@ -90972,7 +91021,7 @@ class SchemaReadHelper {
90972
91021
  const foundItem = this._parser.findItem(itemName);
90973
91022
  if (foundItem) {
90974
91023
  schemaItem = await this.loadSchemaItem(this._schema, ...foundItem);
90975
- if (!skipVisitor && schemaItem && this._visitorHelper) {
91024
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
90976
91025
  await this._visitorHelper.visitSchemaPart(schemaItem);
90977
91026
  }
90978
91027
  if (loadCallBack && schemaItem)
@@ -91005,7 +91054,7 @@ class SchemaReadHelper {
91005
91054
  const foundItem = this._parser.findItem(itemName);
91006
91055
  if (foundItem) {
91007
91056
  schemaItem = this.loadSchemaItemSync(this._schema, ...foundItem);
91008
- if (!skipVisitor && schemaItem && this._visitorHelper) {
91057
+ if (!skipVisitor && this.isSchemaItemLoaded(schemaItem) && this._visitorHelper) {
91009
91058
  this._visitorHelper.visitSchemaPartSync(schemaItem);
91010
91059
  }
91011
91060
  if (loadCallBack && schemaItem)
@@ -91155,7 +91204,7 @@ class SchemaReadHelper {
91155
91204
  */
91156
91205
  async loadClass(classObj, classProps, rawClass) {
91157
91206
  const baseClassLoaded = async (baseClass) => {
91158
- if (this._visitorHelper)
91207
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
91159
91208
  await this._visitorHelper.visitSchemaPart(baseClass);
91160
91209
  };
91161
91210
  // Load base class first
@@ -91178,7 +91227,7 @@ class SchemaReadHelper {
91178
91227
  */
91179
91228
  loadClassSync(classObj, classProps, rawClass) {
91180
91229
  const baseClassLoaded = async (baseClass) => {
91181
- if (this._visitorHelper)
91230
+ if (this._visitorHelper && this.isSchemaItemLoaded(baseClass))
91182
91231
  this._visitorHelper.visitSchemaPartSync(baseClass);
91183
91232
  };
91184
91233
  // Load base class first
@@ -91229,7 +91278,7 @@ class SchemaReadHelper {
91229
91278
  async loadMixin(mixin, rawMixin) {
91230
91279
  const mixinProps = this._parser.parseMixin(rawMixin);
91231
91280
  const appliesToLoaded = async (appliesToClass) => {
91232
- if (this._visitorHelper)
91281
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
91233
91282
  await this._visitorHelper.visitSchemaPart(appliesToClass);
91234
91283
  };
91235
91284
  await this.findSchemaItem(mixinProps.appliesTo, true, appliesToLoaded);
@@ -91243,7 +91292,7 @@ class SchemaReadHelper {
91243
91292
  loadMixinSync(mixin, rawMixin) {
91244
91293
  const mixinProps = this._parser.parseMixin(rawMixin);
91245
91294
  const appliesToLoaded = async (appliesToClass) => {
91246
- if (this._visitorHelper)
91295
+ if (this._visitorHelper && this.isSchemaItemLoaded(appliesToClass))
91247
91296
  await this._visitorHelper.visitSchemaPart(appliesToClass);
91248
91297
  };
91249
91298
  this.findSchemaItemSync(mixinProps.appliesTo, true, appliesToLoaded);
@@ -91439,27 +91488,6 @@ class SchemaReadHelper {
91439
91488
  propertyObj.fromJSONSync(props);
91440
91489
  this.loadCustomAttributesSync(propertyObj, this._parser.getPropertyCustomAttributeProviders(rawProperty));
91441
91490
  }
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
91491
  /**
91464
91492
  * Load the customAttribute class dependencies for a set of CustomAttribute objects and add them to a given custom attribute container.
91465
91493
  * @param container The CustomAttributeContainer that each CustomAttribute will be added to.
@@ -92813,8 +92841,8 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
92813
92841
  }
92814
92842
  }
92815
92843
  parsePrimitiveProperty(xmlElement) {
92816
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
92817
92844
  const typeName = this.getPropertyTypeName(xmlElement);
92845
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
92818
92846
  const primitivePropertyProps = { ...propertyProps, typeName };
92819
92847
  return primitivePropertyProps;
92820
92848
  }
@@ -92826,7 +92854,7 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
92826
92854
  }
92827
92855
  parsePrimitiveArrayProperty(xmlElement) {
92828
92856
  const typeName = this.getPropertyTypeName(xmlElement);
92829
- const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement);
92857
+ const propertyProps = this.getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName);
92830
92858
  const minAndMaxOccurs = this.getPropertyMinAndMaxOccurs(xmlElement);
92831
92859
  return {
92832
92860
  ...propertyProps,
@@ -93101,14 +93129,23 @@ class XmlParser extends _AbstractParser__WEBPACK_IMPORTED_MODULE_5__.AbstractPar
93101
93129
  return rawTypeName;
93102
93130
  return this.getQualifiedTypeName(rawTypeName);
93103
93131
  }
93104
- getPrimitiveOrEnumPropertyBaseProps(xmlElement) {
93132
+ getPrimitiveOrEnumPropertyBaseProps(xmlElement, typeName) {
93133
+ const primitiveType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parsePrimitiveType)(typeName);
93105
93134
  const propertyProps = this.getPropertyProps(xmlElement);
93106
93135
  const propName = propertyProps.name;
93107
93136
  const extendedTypeName = this.getOptionalAttribute(xmlElement, "extendedTypeName");
93108
93137
  const minLength = this.getOptionalIntAttribute(xmlElement, "minimumLength", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumLength' attribute. It should be a numeric value.`);
93109
93138
  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.`);
93139
+ let minValue;
93140
+ let maxValue;
93141
+ if (primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Double || primitiveType === _ECObjects__WEBPACK_IMPORTED_MODULE_1__.PrimitiveType.Long) {
93142
+ minValue = this.getOptionalFloatAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
93143
+ maxValue = this.getOptionalFloatAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
93144
+ }
93145
+ else {
93146
+ minValue = this.getOptionalIntAttribute(xmlElement, "minimumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'minimumValue' attribute. It should be a numeric value.`);
93147
+ maxValue = this.getOptionalIntAttribute(xmlElement, "maximumValue", `The ECProperty ${this._currentItemFullName}.${propName} has an invalid 'maximumValue' attribute. It should be a numeric value.`);
93148
+ }
93112
93149
  return {
93113
93150
  ...propertyProps,
93114
93151
  extendedTypeName,
@@ -94264,6 +94301,2441 @@ class ECSchemaError extends _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Ben
94264
94301
  }
94265
94302
 
94266
94303
 
94304
+ /***/ }),
94305
+
94306
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js":
94307
+ /*!*******************************************************************************!*\
94308
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js ***!
94309
+ \*******************************************************************************/
94310
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94311
+
94312
+ "use strict";
94313
+ __webpack_require__.r(__webpack_exports__);
94314
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94315
+ /* harmony export */ ClassParser: () => (/* binding */ ClassParser),
94316
+ /* harmony export */ CustomAttributeClassParser: () => (/* binding */ CustomAttributeClassParser),
94317
+ /* harmony export */ MixinParser: () => (/* binding */ MixinParser),
94318
+ /* harmony export */ RelationshipClassParser: () => (/* binding */ RelationshipClassParser)
94319
+ /* harmony export */ });
94320
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
94321
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
94322
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
94323
+ /*---------------------------------------------------------------------------------------------
94324
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94325
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94326
+ *--------------------------------------------------------------------------------------------*/
94327
+
94328
+
94329
+
94330
+ /**
94331
+ * Parses ClassProps JSON returned from an ECSql query and returns the correct ClassProps JSON.
94332
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the
94333
+ * iModelDb is in a different format than is required for a ClassProps JSON object.
94334
+ * @internal
94335
+ */
94336
+ class ClassParser extends _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_1__.SchemaItemParser {
94337
+ /**
94338
+ * Parses the given ClassProps JSON returned from an ECSql query.
94339
+ * @param data The ClassProps JSON as returned from an iModelDb.
94340
+ * @returns The corrected ClassProps Json.
94341
+ */
94342
+ async parse(data) {
94343
+ const props = await super.parse(data);
94344
+ if (props.properties) {
94345
+ if (props.properties.length === 0)
94346
+ delete props.properties;
94347
+ else
94348
+ this.parseProperties(props.properties);
94349
+ }
94350
+ return props;
94351
+ }
94352
+ parseProperties(propertyProps) {
94353
+ for (const props of propertyProps) {
94354
+ props.customAttributes = props.customAttributes && props.customAttributes.length > 0 ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94355
+ if (!props.customAttributes)
94356
+ delete props.customAttributes;
94357
+ }
94358
+ }
94359
+ }
94360
+ /**
94361
+ * Parses the given MixinProps JSON returned from an ECSql query.
94362
+ * @param data The MixinProps JSON as returned from an iModelDb.
94363
+ * @returns The corrected MixinProps Json.
94364
+ * @internal
94365
+ */
94366
+ class MixinParser extends ClassParser {
94367
+ /**
94368
+ * Parses the given MixinProps JSON returned from an ECSql query.
94369
+ * @param data The MixinProps JSON as returned from an iModelDb.
94370
+ * @returns The corrected MixinProps Json.
94371
+ */
94372
+ async parse(data) {
94373
+ const props = await super.parse(data);
94374
+ if (!props.customAttributes)
94375
+ delete props.customAttributes;
94376
+ return props;
94377
+ }
94378
+ }
94379
+ /**
94380
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
94381
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
94382
+ * @returns The corrected CustomAttributeClassProps Json.
94383
+ * @internal
94384
+ */
94385
+ class CustomAttributeClassParser extends ClassParser {
94386
+ /**
94387
+ * Parses the given CustomAttributeClassProps JSON returned from an ECSql query.
94388
+ * @param data The CustomAttributeClassProps JSON as returned from an iModelDb.
94389
+ * @returns The corrected CustomAttributeClassProps Json.
94390
+ */
94391
+ async parse(data) {
94392
+ const props = await super.parse(data);
94393
+ 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];
94394
+ return props;
94395
+ }
94396
+ }
94397
+ /**
94398
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
94399
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
94400
+ * @returns The corrected RelationshipClassProps Json.
94401
+ * @internal
94402
+ */
94403
+ class RelationshipClassParser extends ClassParser {
94404
+ /**
94405
+ * Parses the given RelationshipClassProps JSON returned from an ECSql query.
94406
+ * @param data The RelationshipClassProps JSON as returned from an iModelDb.
94407
+ * @returns The corrected RelationshipClassProps Json.
94408
+ */
94409
+ async parse(data) {
94410
+ const props = await super.parse(data);
94411
+ const source = props.source;
94412
+ const target = props.target;
94413
+ if (source) {
94414
+ source.customAttributes = source.customAttributes ? source.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94415
+ if (!source.customAttributes)
94416
+ delete source.customAttributes;
94417
+ }
94418
+ if (target) {
94419
+ target.customAttributes = target.customAttributes ? target.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_2__.parseCustomAttribute)(attr); }) : undefined;
94420
+ if (!target.customAttributes)
94421
+ delete target.customAttributes;
94422
+ }
94423
+ return props;
94424
+ }
94425
+ }
94426
+
94427
+
94428
+ /***/ }),
94429
+
94430
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js":
94431
+ /*!*************************************************************************************!*\
94432
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js ***!
94433
+ \*************************************************************************************/
94434
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94435
+
94436
+ "use strict";
94437
+ __webpack_require__.r(__webpack_exports__);
94438
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94439
+ /* harmony export */ ECSqlSchemaLocater: () => (/* binding */ ECSqlSchemaLocater)
94440
+ /* harmony export */ });
94441
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
94442
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
94443
+ /* harmony import */ var _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./FullSchemaQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js");
94444
+ /* harmony import */ var _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
94445
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
94446
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
94447
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
94448
+ /*---------------------------------------------------------------------------------------------
94449
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94450
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94451
+ *--------------------------------------------------------------------------------------------*/
94452
+
94453
+
94454
+
94455
+
94456
+
94457
+
94458
+
94459
+ /**
94460
+ * An abstract [[IncrementalSchemaLocater]] implementation for loading
94461
+ * EC [Schema] instances from an iModelDb using ECSql queries.
94462
+ * @internal
94463
+ */
94464
+ class ECSqlSchemaLocater extends _IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_3__.IncrementalSchemaLocater {
94465
+ /**
94466
+ * Gets the [[ECSqlSchemaLocaterOptions]] used by this locater.
94467
+ */
94468
+ get options() {
94469
+ return super.options;
94470
+ }
94471
+ /**
94472
+ * Initializes a new ECSqlSchemaLocater instance.
94473
+ * @param options The options used by this Schema locater.
94474
+ */
94475
+ constructor(options) {
94476
+ super(options);
94477
+ }
94478
+ /**
94479
+ * Gets the [[SchemaProps]] for the given schema key. This is the full schema json with all elements that are defined
94480
+ * in the schema. The schema locater calls this after the stub has been loaded to fully load the schema in the background.
94481
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
94482
+ * @param context The [[SchemaContext]] to use for resolving references.
94483
+ * @internal
94484
+ */
94485
+ async getSchemaJson(schemaKey, context) {
94486
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
94487
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
94488
+ // to fetch the whole schema json.
94489
+ if (!await this.supportPartialSchemaLoading(context))
94490
+ return this.getSchemaProps(schemaKey);
94491
+ const start = Date.now();
94492
+ const schemaProps = this.options.useMultipleQueries
94493
+ ? await this.getFullSchemaMultipleQueries(schemaKey, context)
94494
+ : await this.getFullSchema(schemaKey, context);
94495
+ this.options.performanceLogger?.logSchema(start, schemaKey.name);
94496
+ return schemaProps;
94497
+ }
94498
+ ;
94499
+ /**
94500
+ * Gets the [[SchemaProps]] without schemaItems.
94501
+ */
94502
+ /**
94503
+ * Gets the [[SchemaProps]] without schemaItems for the given schema name.
94504
+ * @param schemaName The name of the Schema.
94505
+ * @param context The [[SchemaContext]] to use for resolving references.
94506
+ * @returns
94507
+ * @internal
94508
+ */
94509
+ async getSchemaNoItems(schemaName, context) {
94510
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaNoItemsQuery, { parameters: { schemaName } });
94511
+ const schemaRow = schemaRows[0];
94512
+ if (schemaRow === undefined)
94513
+ return undefined;
94514
+ const schema = JSON.parse(schemaRow.schema);
94515
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
94516
+ }
94517
+ /**
94518
+ * Checks if the [[SchemaContext]] has the right Meta Schema version to support the incremental schema loading.
94519
+ * @param context The schema context to lookup the meta schema.
94520
+ * @returns true if the context has a supported meta schema version, false otherwise.
94521
+ */
94522
+ async supportPartialSchemaLoading(context) {
94523
+ const metaSchemaKey = new _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey("ECDbMeta", 4, 0, 3);
94524
+ const metaSchemaInfo = await context.getSchemaInfo(metaSchemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_0__.SchemaMatchType.LatestWriteCompatible);
94525
+ return metaSchemaInfo !== undefined;
94526
+ }
94527
+ ;
94528
+ /**
94529
+ * Gets all the Schema's Entity classes as [[EntityClassProps]] JSON objects.
94530
+ * @param schemaName The name of the Schema.
94531
+ * @param context The [[SchemaContext]] to which the schema belongs.
94532
+ * @returns A promise that resolves to a EntityClassProps array. Maybe empty of no entities are found.
94533
+ * @internal
94534
+ */
94535
+ async getEntities(schema, context, queryOverride) {
94536
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.entityQuery;
94537
+ return this.querySchemaItem(context, schema, query, "EntityClass");
94538
+ }
94539
+ /**
94540
+ * Gets all the Schema's Mixin classes as [[MixinProps]] JSON objects.
94541
+ * @param schemaName The name of the Schema.
94542
+ * @param context The SchemaContext to which the schema belongs.
94543
+ * @returns A promise that resolves to a MixinProps array. Maybe empty of no entities are found.
94544
+ * @internal
94545
+ */
94546
+ async getMixins(schema, context, queryOverride) {
94547
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.mixinQuery;
94548
+ return this.querySchemaItem(context, schema, query, "Mixin");
94549
+ }
94550
+ /**
94551
+ * Gets all the Schema's Relationship classes as [[RelationshipClassProps]] JSON objects.
94552
+ * @param schemaName The name of the Schema.
94553
+ * @param context The SchemaContext to which the schema belongs.
94554
+ * @returns A promise that resolves to a RelationshipClassProps array. Maybe empty if no items are found.
94555
+ * @internal
94556
+ */
94557
+ async getRelationships(schema, context, queryOverride) {
94558
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.relationshipClassQuery;
94559
+ return this.querySchemaItem(context, schema, query, "RelationshipClass");
94560
+ }
94561
+ /**
94562
+ * Gets all the Schema's CustomAttributeClass items as [[CustomAttributeClassProps]] JSON objects.
94563
+ * @param schemaName The name of the Schema.
94564
+ * @param context The SchemaContext to which the schema belongs.
94565
+ * @returns A promise that resolves to a CustomAttributeClassProps array. Maybe empty if not items are found.
94566
+ * @internal
94567
+ */
94568
+ async getCustomAttributeClasses(schema, context, queryOverride) {
94569
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.customAttributeQuery;
94570
+ return this.querySchemaItem(context, schema, query, "CustomAttributeClass");
94571
+ }
94572
+ /**
94573
+ * Gets all the Schema's StructClass items as [[StructClassProps]] JSON objects.
94574
+ * @param schemaName The name of the Schema.
94575
+ * @param context The SchemaContext to which the schema belongs.
94576
+ * @returns A promise that resolves to a StructClassProps array. Maybe empty if not items are found.
94577
+ * @internal
94578
+ */
94579
+ async getStructs(schema, context, queryOverride) {
94580
+ const query = queryOverride ?? _FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.structQuery;
94581
+ return this.querySchemaItem(context, schema, query, "StructClass");
94582
+ }
94583
+ /**
94584
+ * Gets all the Schema's KindOfQuantity items as [[KindOfQuantityProps]] JSON objects.
94585
+ * @param schema The name of the Schema.
94586
+ * @param context The SchemaContext to which the schema belongs.
94587
+ * @returns A promise that resolves to a KindOfQuantityProps array. Maybe empty if not items are found.
94588
+ * @internal
94589
+ */
94590
+ async getKindOfQuantities(schema, context) {
94591
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.kindOfQuantity(true), "KindOfQuantity");
94592
+ }
94593
+ /**
94594
+ * Gets all the Schema's PropertyCategory items as [[PropertyCategoryProps]] JSON objects.
94595
+ * @param schema The name of the Schema.
94596
+ * @param context The SchemaContext to which the schema belongs.
94597
+ * @returns A promise that resolves to a PropertyCategoryProps array. Maybe empty if not items are found.
94598
+ * @internal
94599
+ */
94600
+ async getPropertyCategories(schema, context) {
94601
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.propertyCategory(true), "PropertyCategory");
94602
+ }
94603
+ /**
94604
+ * Gets all the Schema's Enumeration items as [[EnumerationProps]] JSON objects.
94605
+ * @param schema The name of the Schema.
94606
+ * @param context The SchemaContext to which the schema belongs.
94607
+ * @returns A promise that resolves to a EnumerationProps array. Maybe empty if not items are found.
94608
+ * @internal
94609
+ */
94610
+ async getEnumerations(schema, context) {
94611
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.enumeration(true), "Enumeration");
94612
+ }
94613
+ /**
94614
+ * Gets all the Schema's Unit items as [[SchemaItemUnitProps]] JSON objects.
94615
+ * @param schema The name of the Schema.
94616
+ * @param context The SchemaContext to which the schema belongs.
94617
+ * @returns A promise that resolves to a SchemaItemUnitProps array. Maybe empty if not items are found.
94618
+ * @internal
94619
+ */
94620
+ async getUnits(schema, context) {
94621
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unit(true), "Unit");
94622
+ }
94623
+ /**
94624
+ * Gets all the Schema's InvertedUnit items as [[InvertedUnitProps]] JSON objects.
94625
+ * @param schema The name of the Schema.
94626
+ * @param context The SchemaContext to which the schema belongs.
94627
+ * @returns A promise that resolves to a InvertedUnitProps array. Maybe empty if not items are found.
94628
+ * @internal
94629
+ */
94630
+ async getInvertedUnits(schema, context) {
94631
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.invertedUnit(true), "InvertedUnit");
94632
+ }
94633
+ /**
94634
+ * Gets all the Schema's Constant items as [[ConstantProps]] JSON objects.
94635
+ * @param schema The name of the Schema.
94636
+ * @param context The SchemaContext to which the schema belongs.
94637
+ * @returns A promise that resolves to a ConstantProps array. Maybe empty if not items are found.
94638
+ * @internal
94639
+ */
94640
+ async getConstants(schema, context) {
94641
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.constant(true), "Constant");
94642
+ }
94643
+ /**
94644
+ * Gets all the Schema's UnitSystem items as [[UnitSystemProps]] JSON objects.
94645
+ * @param schema The name of the Schema.
94646
+ * @param context The SchemaContext to which the schema belongs.
94647
+ * @returns A promise that resolves to a UnitSystemProps array. Maybe empty if not items are found.
94648
+ * @internal
94649
+ */
94650
+ async getUnitSystems(schema, context) {
94651
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.unitSystem(true), "UnitSystem");
94652
+ }
94653
+ /**
94654
+ * Gets all the Schema's Phenomenon items as [[PhenomenonProps]] JSON objects.
94655
+ * @param schema The name of the Schema.
94656
+ * @param context The SchemaContext to which the schema belongs.
94657
+ * @returns A promise that resolves to a PhenomenonProps array. Maybe empty if not items are found.
94658
+ * @internal
94659
+ */
94660
+ async getPhenomenon(schema, context) {
94661
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.phenomenon(true), "Phenomenon");
94662
+ }
94663
+ /**
94664
+ * Gets all the Schema's Format items as [[SchemaItemFormatProps]] JSON objects.
94665
+ * @param schema The name of the Schema.
94666
+ * @param context The SchemaContext to which the schema belongs.
94667
+ * @returns A promise that resolves to a SchemaItemFormatProps array. Maybe empty if not items are found.
94668
+ * @internal
94669
+ */
94670
+ async getFormats(schema, context) {
94671
+ return this.querySchemaItem(context, schema, _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_4__.SchemaItemQueries.format(true), "Format");
94672
+ }
94673
+ /**
94674
+ * Gets [[SchemaInfo]] objects for all schemas including their direct schema references.
94675
+ * @internal
94676
+ */
94677
+ async loadSchemaInfos() {
94678
+ const schemaRows = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaInfoQuery);
94679
+ return schemaRows.map((schemaRow) => ({
94680
+ alias: schemaRow.alias,
94681
+ schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaRow.name}.${schemaRow.version}`),
94682
+ references: Array.from(JSON.parse(schemaRow.references), parseSchemaReference),
94683
+ }));
94684
+ }
94685
+ /**
94686
+ * Gets the [[SchemaProps]] to create the basic schema skeleton. Depending on which options are set, the schema items or class hierarchy
94687
+ * can be included in the initial fetch.
94688
+ * @param schemaKey The [[SchemaKey]] of the schema to be resolved.
94689
+ * @returns A promise that resolves to the schema partials, which is an array of [[SchemaProps]].
94690
+ * @internal
94691
+ */
94692
+ async getSchemaPartials(schemaKey, context) {
94693
+ const [schemaRow] = await this.executeQuery(_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_6__.ecsqlQueries.schemaStubQuery, {
94694
+ parameters: { schemaName: schemaKey.name },
94695
+ limit: 1
94696
+ });
94697
+ if (!schemaRow)
94698
+ return undefined;
94699
+ const schemaPartials = [];
94700
+ const addSchema = async (key) => {
94701
+ const stub = await this.createSchemaProps(key, context);
94702
+ schemaPartials.push(stub);
94703
+ if (stub.references) {
94704
+ for (const referenceProps of stub.references) {
94705
+ if (!schemaPartials.some((schema) => schema.name === referenceProps.name)) {
94706
+ await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${referenceProps.name}.${referenceProps.version}`));
94707
+ }
94708
+ }
94709
+ }
94710
+ return stub;
94711
+ };
94712
+ const addItems = async (schemaName, itemInfo) => {
94713
+ let schemaStub = schemaPartials.find((schema) => schema.name === schemaName);
94714
+ if (!schemaStub) {
94715
+ schemaStub = await addSchema(_SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(`${schemaName}.0.0.0`));
94716
+ }
94717
+ if (!schemaStub.items) {
94718
+ Object.assign(schemaStub, { items: {} });
94719
+ }
94720
+ const existingItem = schemaStub.items[itemInfo.name] || {};
94721
+ Object.assign(schemaStub.items, { [itemInfo.name]: Object.assign(existingItem, itemInfo) });
94722
+ };
94723
+ const reviver = (_key, value) => {
94724
+ if (value === null) {
94725
+ return undefined;
94726
+ }
94727
+ return value;
94728
+ };
94729
+ await addSchema(schemaKey);
94730
+ await parseSchemaItemStubs(schemaKey.name, context, JSON.parse(schemaRow.items, reviver), addItems);
94731
+ return schemaPartials;
94732
+ }
94733
+ async querySchemaItem(context, schemaName, query, schemaType) {
94734
+ const start = Date.now();
94735
+ const itemRows = await this.executeQuery(query, { parameters: { schemaName } });
94736
+ this.options.performanceLogger?.logSchemaItem(start, schemaName, schemaType, itemRows.length);
94737
+ if (itemRows.length === 0)
94738
+ return [];
94739
+ const items = itemRows.map((itemRow) => {
94740
+ return "string" === typeof itemRow.item ? JSON.parse(itemRow.item) : itemRow.item;
94741
+ });
94742
+ return await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseSchemaItems(items, schemaName, context) ?? [];
94743
+ }
94744
+ async getFullSchema(schemaKey, context) {
94745
+ const schemaRows = await this.executeQuery(_FullSchemaQueries__WEBPACK_IMPORTED_MODULE_2__.FullSchemaQueries.schemaQuery, { parameters: { schemaName: schemaKey.name } });
94746
+ const schemaRow = schemaRows[0];
94747
+ if (schemaRow === undefined)
94748
+ return undefined;
94749
+ // Map SchemaItemRow array, [{item: SchemaItemProps}], to array of SchemaItemProps.
94750
+ const schema = JSON.parse(schemaRow.schema);
94751
+ if (schema.items) {
94752
+ schema.items = schema.items.map((itemRow) => { return itemRow.item; });
94753
+ }
94754
+ return _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parse(schema, context);
94755
+ }
94756
+ async getFullSchemaMultipleQueries(schemaKey, context) {
94757
+ const schema = await this.getSchemaNoItems(schemaKey.name, context);
94758
+ if (!schema)
94759
+ return undefined;
94760
+ schema.items = {};
94761
+ await Promise.all([
94762
+ this.getEntities(schemaKey.name, context),
94763
+ this.getMixins(schemaKey.name, context),
94764
+ this.getStructs(schemaKey.name, context),
94765
+ this.getRelationships(schemaKey.name, context),
94766
+ this.getCustomAttributeClasses(schemaKey.name, context),
94767
+ this.getKindOfQuantities(schemaKey.name, context),
94768
+ this.getPropertyCategories(schemaKey.name, context),
94769
+ this.getEnumerations(schemaKey.name, context),
94770
+ this.getUnits(schemaKey.name, context),
94771
+ this.getInvertedUnits(schemaKey.name, context),
94772
+ this.getUnitSystems(schemaKey.name, context),
94773
+ this.getConstants(schemaKey.name, context),
94774
+ this.getPhenomenon(schemaKey.name, context),
94775
+ this.getFormats(schemaKey.name, context)
94776
+ ]).then((itemResults) => {
94777
+ const flatItemList = itemResults.reduce((acc, item) => acc.concat(item));
94778
+ flatItemList.forEach((schemaItem) => {
94779
+ schema.items[schemaItem.name] = schemaItem;
94780
+ });
94781
+ });
94782
+ return schema;
94783
+ }
94784
+ }
94785
+ function parseSchemaReference(referenceName) {
94786
+ return { schemaKey: _SchemaKey__WEBPACK_IMPORTED_MODULE_1__.SchemaKey.parseString(referenceName) };
94787
+ }
94788
+ async function parseSchemaItemStubs(schemaName, context, itemRows, addItemsHandler) {
94789
+ if (!itemRows || itemRows.length === 0) {
94790
+ return;
94791
+ }
94792
+ const parseBaseClasses = async (baseClasses) => {
94793
+ if (!baseClasses || baseClasses.length < 2)
94794
+ return;
94795
+ for (let index = baseClasses.length - 1; index >= 0;) {
94796
+ const currentItem = baseClasses[index--];
94797
+ const baseClassItem = baseClasses[index];
94798
+ const baseClassName = baseClassItem ? `${baseClassItem.schema}.${baseClassItem.name}` : undefined;
94799
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(currentItem, currentItem.schema, context);
94800
+ await addItemsHandler(currentItem.schema, {
94801
+ ...schemaItem,
94802
+ name: schemaItem.name,
94803
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
94804
+ baseClass: baseClassName,
94805
+ });
94806
+ }
94807
+ };
94808
+ for (const itemRow of itemRows) {
94809
+ const schemaItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(itemRow, schemaName, context);
94810
+ await addItemsHandler(schemaName, {
94811
+ ...schemaItem,
94812
+ name: schemaItem.name,
94813
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(schemaItem.schemaItemType),
94814
+ mixins: itemRow.mixins
94815
+ ? itemRow.mixins.map(mixin => { return `${mixin.schema}.${mixin.name}`; })
94816
+ : undefined,
94817
+ });
94818
+ await parseBaseClasses(itemRow.baseClasses);
94819
+ for (const mixinRow of itemRow.mixins || []) {
94820
+ const mixinItem = await _SchemaParser__WEBPACK_IMPORTED_MODULE_5__.SchemaParser.parseItem(mixinRow, mixinRow.schema, context);
94821
+ await addItemsHandler(mixinRow.schema, {
94822
+ ...mixinItem,
94823
+ name: mixinItem.name,
94824
+ schemaItemType: (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(mixinItem.schemaItemType),
94825
+ });
94826
+ await parseBaseClasses(mixinRow.baseClasses);
94827
+ }
94828
+ }
94829
+ }
94830
+
94831
+
94832
+ /***/ }),
94833
+
94834
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js":
94835
+ /*!************************************************************************************!*\
94836
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/FullSchemaQueries.js ***!
94837
+ \************************************************************************************/
94838
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
94839
+
94840
+ "use strict";
94841
+ __webpack_require__.r(__webpack_exports__);
94842
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
94843
+ /* harmony export */ FullSchemaQueries: () => (/* binding */ FullSchemaQueries)
94844
+ /* harmony export */ });
94845
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
94846
+ /* harmony import */ var _SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaStubQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js");
94847
+ /*---------------------------------------------------------------------------------------------
94848
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
94849
+ * See LICENSE.md in the project root for license terms and full copyright notice.
94850
+ *--------------------------------------------------------------------------------------------*/
94851
+
94852
+
94853
+ /**
94854
+ * Queries that return full Schema JSON data are found here. Shared SELECTS and
94855
+ * WITH clauses are broken down into individual variables.
94856
+ */
94857
+ const propertyType = (alias) => {
94858
+ return `
94859
+ CASE
94860
+ WHEN [${alias}].[Kind] = 0 THEN 'PrimitiveProperty'
94861
+ WHEN [${alias}].[Kind] = 1 THEN 'StructProperty'
94862
+ WHEN [${alias}].[Kind] = 2 THEN 'PrimitiveArrayProperty'
94863
+ WHEN [${alias}].[Kind] = 3 THEN 'StructArrayProperty'
94864
+ WHEN [${alias}].[Kind] = 4 THEN 'NavigationProperty'
94865
+ ELSE NULL
94866
+ END
94867
+ `;
94868
+ };
94869
+ const navigationDirection = (alias) => {
94870
+ return `
94871
+ CASE
94872
+ WHEN [${alias}].[NavigationDirection] = 1 THEN 'Forward'
94873
+ WHEN [${alias}].[NavigationDirection] = 2 THEN 'Backward'
94874
+ ELSE NULL
94875
+ END
94876
+ `;
94877
+ };
94878
+ const schemaCustomAttribute = (alias) => {
94879
+ return `
94880
+ SELECT
94881
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94882
+ FROM [meta].[CustomAttribute] [ca]
94883
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 1
94884
+ ORDER BY [ca].[Ordinal]
94885
+ `;
94886
+ };
94887
+ /**
94888
+ * Selects customAttribute data for each class type.
94889
+ */
94890
+ const classCustomAttribute = (alias) => {
94891
+ return `
94892
+ SELECT
94893
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94894
+ FROM [meta].[CustomAttribute] [ca]
94895
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 30
94896
+ ORDER BY [ca].[Ordinal]
94897
+ `;
94898
+ };
94899
+ const propertyCustomAttribute = (alias) => {
94900
+ return `
94901
+ SELECT
94902
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
94903
+ FROM [meta].[CustomAttribute] [ca]
94904
+ WHERE [ca].[ContainerId] = [${alias}].[ECInstanceId] AND [ca].[ContainerType] = 992
94905
+ ORDER BY [ca].[Ordinal]
94906
+ `;
94907
+ };
94908
+ /**
94909
+ * Selects base class data for each class type.
94910
+ */
94911
+ const selectBaseClasses = `
94912
+ SELECT
94913
+ ec_classname([baseClass].[ECInstanceId], 's.c')
94914
+ FROM
94915
+ [meta].[ECClassDef] [baseClass]
94916
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
94917
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
94918
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
94919
+ LIMIT 1
94920
+ `;
94921
+ /**
94922
+ * Selects class property data for each class type. ClassProperties
94923
+ * is a common table expression (CTE or WITH clause) defined below.
94924
+ */
94925
+ const selectProperties = `
94926
+ SELECT
94927
+ json_group_array(json([classProperties].[property]))
94928
+ FROM
94929
+ [ClassProperties] [classProperties]
94930
+ WHERE
94931
+ [classProperties].[ClassId] = [class].[ECInstanceId]
94932
+ `;
94933
+ /**
94934
+ * A CTE used to select AppliesTo from IsMixin CustomAttributes for a given Mixin.
94935
+ */
94936
+ const withAppliesTo = `
94937
+ AppliesToCTE AS (
94938
+ SELECT
94939
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
94940
+ [appliesToSchema].[name] as [AppliesToSchema],
94941
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
94942
+ FROM [meta].[CustomAttribute] [ca]
94943
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
94944
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
94945
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
94946
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
94947
+ WHERE [ca].[ContainerType] = 30
94948
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
94949
+ )
94950
+ `;
94951
+ /**
94952
+ * A CTE used to select Schema reference data for a given Schema.
94953
+ */
94954
+ const withSchemaReferences = `
94955
+ SchemaReferences as (
94956
+ SELECT
94957
+ [ref].[SourceECInstanceId] as [SchemaId],
94958
+ json_object(
94959
+ 'name', [Name],
94960
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor]))
94961
+ ) as [reference]
94962
+ FROM
94963
+ [meta].[ECSchemaDef] as [refSchema]
94964
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
94965
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
94966
+ )
94967
+ `;
94968
+ /**
94969
+ * A CTE used to select Relationship constraints for a given RelationshipClass.
94970
+ */
94971
+ const withRelationshipConstraints = `
94972
+ ClassRelationshipConstraints as (
94973
+ SELECT
94974
+ [rhc].[SourceECInstanceId] as [ClassId],
94975
+ [constraintDef].[ECInstanceId] as [ConstraintId],
94976
+ [RelationshipEnd],
94977
+ CONCAT('(', [MultiplicityLowerLimit], '..', IIF([MultiplicityUpperLimit] IS NULL, '*', [MultiplicityUpperLimit]), ')') as [Multiplicity],
94978
+ [IsPolyMorphic],
94979
+ [RoleLabel],
94980
+ IIF([constraintDef].[AbstractConstraintClass] IS NOT NULL, ec_classname([constraintDef].[AbstractConstraintClass].[Id], 's.c'), null) as [AbstractConstraint],
94981
+ IIF ([rchc].[TargetECInstanceId] IS NOT NULL, JSON_GROUP_ARRAY(ec_classname([rchc].[TargetECInstanceId], 's.c')), null) as [ConstraintClasses]
94982
+ FROM
94983
+ [meta].[ECRelationshipConstraintDef] [constraintDef]
94984
+ JOIN [meta].[RelationshipHasConstraints] [rhc]
94985
+ ON [rhc].[TargetECInstanceId] = [constraintDef].[ECInstanceId]
94986
+ JOIN [meta].[RelationshipConstraintHasClasses] [rchc]
94987
+ ON [rchc].[SourceECInstanceId] = [constraintDef].[ECInstanceId]
94988
+ GROUP BY [constraintDef].[ECInstanceId]
94989
+ )
94990
+ `;
94991
+ /**
94992
+ * A CTE used to select Class property data for a given Class.
94993
+ */
94994
+ const withClassProperties = `
94995
+ ClassProperties as (
94996
+ SELECT
94997
+ [cop].[SourceECInstanceId] as [ClassId],
94998
+ json_object(
94999
+ 'name', [pd].[Name],
95000
+ 'label', [pd].[DisplayLabel],
95001
+ 'description', [pd].[Description],
95002
+ 'isReadOnly', IIF([pd].[IsReadOnly] = 1, json('true'), NULL),
95003
+ 'priority', [pd].[Priority],
95004
+ 'category', IIF([categoryDef].[Name] IS NULL, NULL, CONCAT([categorySchemaDef].[Name], '.', [categoryDef].[Name])),
95005
+ 'kindOfQuantity', IIF([koqDef].[Name] IS NULL, NULL, CONCAT([koqSchemaDef].[Name], '.', [koqDef].[Name])),
95006
+ 'typeName',
95007
+ CASE
95008
+ WHEN [pd].[Kind] = 0 OR [pd].[Kind] = 2 Then
95009
+ CASE
95010
+ WHEN [enumDef].[Name] IS NOT NULL Then CONCAT([enumSchemaDef].[Name], '.', [enumDef].[Name])
95011
+ WHEN [pd].[PrimitiveType] = 257 Then 'binary'
95012
+ WHEN [pd].[PrimitiveType] = 513 Then 'boolean'
95013
+ WHEN [pd].[PrimitiveType] = 769 Then 'dateTime'
95014
+ WHEN [pd].[PrimitiveType] = 1025 Then 'double'
95015
+ WHEN [pd].[PrimitiveType] = 1281 Then 'int'
95016
+ WHEN [pd].[PrimitiveType] = 1537 Then 'long'
95017
+ WHEN [pd].[PrimitiveType] = 1793 Then 'point2d'
95018
+ WHEN [pd].[PrimitiveType] = 2049 Then 'point3d'
95019
+ WHEN [pd].[PrimitiveType] = 2305 Then 'string'
95020
+ WHEN [pd].[PrimitiveType] = 2561 Then 'Bentley.Geometry.Common.IGeometry'
95021
+ ELSE null
95022
+ END
95023
+ WHEN [pd].[Kind] = 1 OR [pd].[Kind] = 3 Then
95024
+ CONCAT([structSchemaDef].[Name], '.', [structDef].[Name])
95025
+ ELSE null
95026
+ END,
95027
+ 'type', ${propertyType("pd")},
95028
+ 'minLength', [pd].[PrimitiveTypeMinLength],
95029
+ 'maxLength', [pd].[PrimitiveTypeMaxLength],
95030
+ 'minValue', [pd].[PrimitiveTypeMinValue],
95031
+ 'maxValue', [pd].[PrimitiveTypeMaxValue],
95032
+ 'extendedTypeName', [pd].[ExtendedTypeName],
95033
+ 'minOccurs', [pd].[ArrayMinOccurs],
95034
+ 'maxOccurs', [pd].[ArrayMaxOccurs],
95035
+ 'direction', ${navigationDirection("pd")},
95036
+ 'relationshipName', IIF([navRelDef].[Name] IS NULL, NULL, CONCAT([navSchemaDef].[Name], '.', [navRelDef].[Name])),
95037
+ 'customAttributes', (${propertyCustomAttribute("pd")})
95038
+ ) as [property]
95039
+ FROM
95040
+ [meta].[ECPropertyDef] as [pd]
95041
+ JOIN [meta].[ClassOwnsLocalProperties] [cop]
95042
+ ON cop.[TargetECInstanceId] = [pd].[ECInstanceId]
95043
+ LEFT JOIN [meta].[ECEnumerationDef] [enumDef]
95044
+ ON [enumDef].[ECInstanceId] = [pd].[Enumeration].[Id]
95045
+ LEFT JOIN [meta].[ECSchemaDef] enumSchemaDef
95046
+ ON [enumSchemaDef].[ECInstanceId] = [enumDef].[Schema].[Id]
95047
+ LEFT JOIN [meta].[PropertyCategoryDef] [categoryDef]
95048
+ ON [categoryDef].[ECInstanceId] = [pd].[Category].[Id]
95049
+ LEFT JOIN [meta].[ECSchemaDef] [categorySchemaDef]
95050
+ ON [categorySchemaDef].[ECInstanceId] = [categoryDef].[Schema].[Id]
95051
+ LEFT JOIN [meta].[KindOfQuantityDef] [koqDef]
95052
+ ON [koqDef].[ECInstanceId] = [pd].[KindOfQuantity].[Id]
95053
+ LEFT JOIN [meta].[ECSchemaDef] [koqSchemaDef]
95054
+ ON [koqSchemaDef].[ECInstanceId] = [koqDef].[Schema].[Id]
95055
+ LEFT JOIN [meta].[ECClassDef] [structDef]
95056
+ ON structDef.[ECInstanceId] = [pd].[StructClass].[Id]
95057
+ LEFT JOIN [meta].[ECSchemaDef] [structSchemaDef]
95058
+ ON [structSchemaDef].[ECInstanceId] = [structDef].[Schema].[Id]
95059
+ LEFT JOIN [meta].[ECClassDef] [navRelDef]
95060
+ ON [navRelDef].[ECInstanceId] = [pd].[NavigationRelationshipClass].[Id]
95061
+ LEFT JOIN [meta].[ECSchemaDef] [navSchemaDef]
95062
+ ON [navSchemaDef].[ECInstanceId] = [navRelDef].[Schema].[Id]
95063
+ )
95064
+ `;
95065
+ /**
95066
+ * Query that provides EntityClass data and is shared by two cases:
95067
+ * 1. A single query to return a full schema.
95068
+ * 2. When querying a full schema with multiple schema item queries or
95069
+ * when just querying for Entity classes.
95070
+ */
95071
+ const baseEntityQuery = `
95072
+ SELECT
95073
+ [sd].[Name] as [schema],
95074
+ json_object (
95075
+ 'schemaItemType', 'EntityClass',
95076
+ 'name', [class].[Name],
95077
+ 'label', [class].[DisplayLabel],
95078
+ 'description', [class].[Description],
95079
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95080
+ 'baseClass', (
95081
+ ${selectBaseClasses}
95082
+ ),
95083
+ 'mixins', (
95084
+ SELECT
95085
+ json_group_array(
95086
+ ec_classname([baseClass].[ECInstanceId], 's.c')
95087
+ )
95088
+ FROM
95089
+ [meta].[ECClassDef] [baseClass]
95090
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
95091
+ ON [baseClassMap].[TargetECInstanceId] = [baseClass].[ECInstanceId]
95092
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
95093
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
95094
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
95095
+ ),
95096
+ 'customAttributes', (${classCustomAttribute("class")}),
95097
+ 'properties', (
95098
+ ${selectProperties}
95099
+ )
95100
+ ) AS [item]
95101
+ FROM [meta].[ECClassDef] [class]
95102
+ JOIN
95103
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95104
+ WHERE [class].[Type] = 0 AND
95105
+ [sd].[Name] = :schemaName
95106
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
95107
+ AND [ca].[CustomAttributeClass].Id Is ([CoreCA].[IsMixin]))
95108
+ `;
95109
+ /**
95110
+ * EntityClass query used to when querying for EntityClass data only. Not used
95111
+ * for full Schema load via single query.
95112
+ */
95113
+ const entityQuery = `
95114
+ WITH
95115
+ ${withClassProperties}
95116
+ ${baseEntityQuery}
95117
+ `;
95118
+ /**
95119
+ * Query that provides Mixin data and is shared by two cases:
95120
+ * 1. A single query to return a full schema.
95121
+ * 2. When querying a full schema with multiple schema item queries or
95122
+ * when just querying for Mixin classes.
95123
+ */
95124
+ const baseMixinQuery = `
95125
+ SELECT
95126
+ [sd].[Name] as [schema],
95127
+ json_object (
95128
+ 'schemaItemType', 'Mixin',
95129
+ 'name', [class].[Name],
95130
+ 'label', [class].[DisplayLabel],
95131
+ 'description', [class].[Description],
95132
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95133
+ 'baseClass', (
95134
+ ${selectBaseClasses}
95135
+ ),
95136
+ 'appliesTo', (
95137
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
95138
+ FROM [AppliesToCTE] [atCTE]
95139
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
95140
+ ),
95141
+ 'customAttributes', (
95142
+ SELECT
95143
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95144
+ FROM [meta].[CustomAttribute] [ca]
95145
+ WHERE [ca].[ContainerId] = [class].[ECInstanceId] AND [ca].[ContainerType] = 30
95146
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') <> 'IsMixin'
95147
+ ),
95148
+ 'properties', (
95149
+ SELECT
95150
+ json_group_array(json([classProperties].[property]))
95151
+ FROM
95152
+ [ClassProperties] [classProperties]
95153
+ WHERE
95154
+ [classProperties].[ClassId] = [class].[ECInstanceId]
95155
+ )
95156
+ ) AS [item]
95157
+ FROM [meta].[ECClassDef] [class]
95158
+ JOIN
95159
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95160
+ WHERE [class].[Type] = 0 AND
95161
+ [sd].[Name] = :schemaName
95162
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
95163
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
95164
+ `;
95165
+ /**
95166
+ * Mixin query used to when querying for Mixin data only. Not used
95167
+ * for full Schema load via single query.
95168
+ */
95169
+ const mixinQuery = `
95170
+ WITH
95171
+ ${withAppliesTo},
95172
+ ${withClassProperties}
95173
+ ${baseMixinQuery}
95174
+ `;
95175
+ /**
95176
+ * Query that provides RelationshipClass data and is shared by two cases:
95177
+ * 1. A single query to return a full schema.
95178
+ * 2. When querying a full schema with multiple schema item queries or
95179
+ * when just querying for Relationship classes.
95180
+ */
95181
+ const baseRelationshipClassQuery = `
95182
+ SELECT
95183
+ [sd].Name as schema,
95184
+ json_object (
95185
+ 'schemaItemType', 'RelationshipClass',
95186
+ 'name', [class].[Name],
95187
+ 'label', [class].[DisplayLabel],
95188
+ 'description', [class].[Description],
95189
+ 'strength', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strength)("class")},
95190
+ 'strengthDirection', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.strengthDirection)("class")},
95191
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95192
+ 'baseClass', (
95193
+ ${selectBaseClasses}
95194
+ ),
95195
+ 'customAttributes', (${classCustomAttribute("class")}),
95196
+ 'properties', (
95197
+ ${selectProperties}
95198
+ ),
95199
+ 'source', (
95200
+ SELECT
95201
+ json_object (
95202
+ 'multiplicity', [sourceConst].[Multiplicity],
95203
+ 'roleLabel', [sourceConst].[RoleLabel],
95204
+ 'polymorphic', IIF([sourceConst].[IsPolyMorphic] = 1, json('true'), json('false')),
95205
+ 'abstractConstraint', [sourceConst].[AbstractConstraint],
95206
+ 'constraintClasses', json([sourceConst].[ConstraintClasses]),
95207
+ 'customAttributes', (
95208
+ SELECT
95209
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95210
+ FROM [meta].[CustomAttribute] [ca]
95211
+ WHERE [ca].[ContainerId] = [sourceConst].[ConstraintId] AND [ca].[ContainerType] = 1024
95212
+ ORDER BY [ca].[Ordinal]
95213
+ )
95214
+ )
95215
+ FROM
95216
+ [ClassRelationshipConstraints] [sourceConst]
95217
+ WHERE [sourceConst].[relationshipEnd] = 0
95218
+ AND [sourceConst].[ClassId] = [class].[ECInstanceId]
95219
+ ),
95220
+ 'target', (
95221
+ SELECT
95222
+ json_object (
95223
+ 'multiplicity', [targetConst].[Multiplicity],
95224
+ 'roleLabel', [targetConst].[RoleLabel],
95225
+ 'polymorphic', IIF([targetConst].[IsPolyMorphic] = 1, json('true'), json('false')),
95226
+ 'abstractConstraint', [targetConst].[AbstractConstraint],
95227
+ 'constraintClasses', json([targetConst].[ConstraintClasses]),
95228
+ 'customAttributes', (
95229
+ SELECT
95230
+ json_group_array(json(XmlCAToJson([ca].[Class].[Id], [ca].[Instance])))
95231
+ FROM [meta].[CustomAttribute] [ca]
95232
+ WHERE [ca].[ContainerId] = [targetConst].[ConstraintId] AND [ca].[ContainerType] = 2048
95233
+ ORDER BY [ca].[Ordinal]
95234
+ )
95235
+ )
95236
+ FROM
95237
+ [ClassRelationshipConstraints] [targetConst]
95238
+ WHERE [targetConst].[relationshipEnd] = 1
95239
+ AND [targetConst].[ClassId] = [class].[ECInstanceId]
95240
+ )
95241
+ ) AS [item]
95242
+ FROM [meta].[ECClassDef] [class]
95243
+ JOIN
95244
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95245
+ WHERE [class].[Type] = 1 AND
95246
+ [sd].[Name] = :schemaName
95247
+ `;
95248
+ /**
95249
+ * RelationshipClass query used to when querying for RelationshipClass data only. Not used
95250
+ * for full Schema load via single query.
95251
+ */
95252
+ const relationshipClassQuery = `
95253
+ WITH
95254
+ ${withClassProperties},
95255
+ ${withRelationshipConstraints}
95256
+ ${baseRelationshipClassQuery}
95257
+ `;
95258
+ /**
95259
+ * Query that provides StructClass data and is shared by two cases:
95260
+ * 1. A single query to return a full schema.
95261
+ * 2. When querying a full schema with multiple schema item queries or
95262
+ * when just querying for Struct classes.
95263
+ */
95264
+ const baseStructQuery = `
95265
+ SELECT
95266
+ [sd].Name as schema,
95267
+ json_object (
95268
+ 'schemaItemType', 'StructClass',
95269
+ 'name', [class].[Name],
95270
+ 'label', [class].[DisplayLabel],
95271
+ 'description', [class].[Description],
95272
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95273
+ 'baseClass', (
95274
+ ${selectBaseClasses}
95275
+ ),
95276
+ 'customAttributes', (${classCustomAttribute("class")}),
95277
+ 'properties', (
95278
+ ${selectProperties}
95279
+ )
95280
+ ) AS item
95281
+ FROM [meta].[ECClassDef] [class]
95282
+ JOIN
95283
+ [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95284
+ WHERE [class].[Type] = 2 AND
95285
+ [sd].[Name] = :schemaName
95286
+ `;
95287
+ /**
95288
+ * StructClass query used to when querying for StructClass data only. Not used
95289
+ * for full Schema load via single query.
95290
+ */
95291
+ const structQuery = `
95292
+ WITH
95293
+ ${withClassProperties}
95294
+ ${baseStructQuery}
95295
+ `;
95296
+ /**
95297
+ * Query that provides CustomAttributeClass data and is shared by two cases:
95298
+ * 1. A single query to return a full schema.
95299
+ * 2. When querying a full schema with multiple schema item queries or
95300
+ * when just querying for CustomAttribute classes.
95301
+ */
95302
+ const baseCustomAttributeQuery = `
95303
+ SELECT
95304
+ [sd].Name as schema,
95305
+ json_object (
95306
+ 'schemaItemType', 'CustomAttributeClass',
95307
+ 'name', [class].[Name],
95308
+ 'label', [class].[DisplayLabel],
95309
+ 'description', [class].[Description],
95310
+ 'appliesTo', [class].[CustomAttributeContainerType],
95311
+ 'modifier', ${(0,_SchemaStubQueries__WEBPACK_IMPORTED_MODULE_1__.modifier)("class")},
95312
+ 'baseClass', (
95313
+ ${selectBaseClasses}
95314
+ ),
95315
+ 'customAttributes', (${classCustomAttribute("class")}),
95316
+ 'properties', (
95317
+ ${selectProperties}
95318
+ )
95319
+ ) AS [item]
95320
+ FROM [meta].[ECClassDef] [class]
95321
+ JOIN
95322
+ [meta].[ECSchemaDef] sd ON [sd].[ECInstanceId] = [class].[Schema].[Id]
95323
+ WHERE [class].[Type] = 3 AND
95324
+ [sd].[Name] = :schemaName
95325
+ `;
95326
+ /**
95327
+ * CustomAttributeClass query used to when querying for CustomAttributeClass data only. Not used
95328
+ * for full Schema load via single query.
95329
+ */
95330
+ const customAttributeQuery = `
95331
+ WITH
95332
+ ${withClassProperties}
95333
+ ${baseCustomAttributeQuery}
95334
+ `;
95335
+ /**
95336
+ * Used by full schema load query via single query. Allows
95337
+ * all SchemaItemTypes to be queried at once.
95338
+ */
95339
+ const withSchemaItems = `
95340
+ SchemaItems AS (
95341
+ ${baseEntityQuery}
95342
+ UNION ALL
95343
+ ${baseRelationshipClassQuery}
95344
+ UNION ALL
95345
+ ${baseStructQuery}
95346
+ UNION ALL
95347
+ ${baseMixinQuery}
95348
+ UNION ALL
95349
+ ${baseCustomAttributeQuery}
95350
+ UNION ALL
95351
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity(true)}
95352
+ UNION ALL
95353
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration(true)}
95354
+ UNION ALL
95355
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory(true)}
95356
+ UNION ALL
95357
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit(true)}
95358
+ UNION ALL
95359
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit(true)}
95360
+ UNION ALL
95361
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem(true)}
95362
+ UNION ALL
95363
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant(true)}
95364
+ UNION ALL
95365
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon(true)}
95366
+ UNION ALL
95367
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format(true)}
95368
+ )
95369
+ `;
95370
+ /**
95371
+ * Query for Schema data without SchemaItems
95372
+ */
95373
+ const schemaNoItemsQuery = `
95374
+ WITH
95375
+ ${withSchemaReferences}
95376
+ SELECT
95377
+ json_object (
95378
+ 'name', [schemaDef].[Name],
95379
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
95380
+ 'alias', [schemaDef].[Alias],
95381
+ 'label', [schemaDef].[DisplayLabel],
95382
+ 'description', [schemaDef].[Description],
95383
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
95384
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
95385
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
95386
+ 'references', (
95387
+ SELECT
95388
+ json_group_array(json([schemaReferences].[reference]))
95389
+ FROM
95390
+ [SchemaReferences] [schemaReferences]
95391
+ WHERE
95392
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
95393
+ )
95394
+ ) as [schema]
95395
+ FROM
95396
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
95397
+ `;
95398
+ /**
95399
+ * Query to load a full Schema via a single query.
95400
+ */
95401
+ const schemaQuery = `
95402
+ WITH
95403
+ ${withAppliesTo},
95404
+ ${withSchemaReferences},
95405
+ ${withClassProperties},
95406
+ ${withRelationshipConstraints},
95407
+ ${withSchemaItems}
95408
+ SELECT
95409
+ json_object (
95410
+ 'name', [schemaDef].[Name],
95411
+ 'version', CONCAT(printf('%02d', [VersionMajor]), '.', printf('%02d', [VersionWrite]), '.', printf('%02d', [VersionMinor])),
95412
+ 'alias', [schemaDef].[Alias],
95413
+ 'label', [schemaDef].[DisplayLabel],
95414
+ 'description', [schemaDef].[Description],
95415
+ 'ecSpecMajorVersion', [schemaDef].[OriginalECXmlVersionMajor],
95416
+ 'ecSpecMinorVersion', [schemaDef].[OriginalECXmlVersionMinor],
95417
+ 'customAttributes', (${schemaCustomAttribute("schemaDef")}),
95418
+ 'references', (
95419
+ SELECT
95420
+ json_group_array(json([schemaReferences].[reference]))
95421
+ FROM
95422
+ [SchemaReferences] [schemaReferences]
95423
+ WHERE
95424
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
95425
+ ),
95426
+ 'items', (
95427
+ SELECT
95428
+ json_group_array(json(json_object(
95429
+ 'item', json([items].[item])
95430
+ )))
95431
+ FROM
95432
+ [SchemaItems] [items]
95433
+ )
95434
+ ) as [schema]
95435
+ FROM
95436
+ [meta].[ECSchemaDef] [schemaDef] WHERE [Name] = :schemaName
95437
+ `;
95438
+ /**
95439
+ * Queries for loading full Schema JSON.
95440
+ * @internal
95441
+ */
95442
+ // eslint-disable-next-line @typescript-eslint/naming-convention
95443
+ const FullSchemaQueries = {
95444
+ schemaQuery,
95445
+ schemaNoItemsQuery,
95446
+ entityQuery,
95447
+ relationshipClassQuery,
95448
+ mixinQuery,
95449
+ structQuery,
95450
+ customAttributeQuery
95451
+ };
95452
+
95453
+
95454
+ /***/ }),
95455
+
95456
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js":
95457
+ /*!*******************************************************************************************!*\
95458
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js ***!
95459
+ \*******************************************************************************************/
95460
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95461
+
95462
+ "use strict";
95463
+ __webpack_require__.r(__webpack_exports__);
95464
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95465
+ /* harmony export */ IncrementalSchemaLocater: () => (/* binding */ IncrementalSchemaLocater)
95466
+ /* harmony export */ });
95467
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
95468
+ /* harmony import */ var _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/SchemaGraphUtil */ "../../core/ecschema-metadata/lib/esm/Deserialization/SchemaGraphUtil.js");
95469
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95470
+ /* harmony import */ var _Exception__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Exception */ "../../core/ecschema-metadata/lib/esm/Exception.js");
95471
+ /* harmony import */ var _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/Schema */ "../../core/ecschema-metadata/lib/esm/Metadata/Schema.js");
95472
+ /* harmony import */ var _SchemaKey__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../SchemaKey */ "../../core/ecschema-metadata/lib/esm/SchemaKey.js");
95473
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
95474
+ /* harmony import */ var _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./IncrementalSchemaReader */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js");
95475
+ /*---------------------------------------------------------------------------------------------
95476
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95477
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95478
+ *--------------------------------------------------------------------------------------------*/
95479
+
95480
+
95481
+
95482
+
95483
+
95484
+
95485
+
95486
+
95487
+ /**
95488
+ * A [[ISchemaLocater]] implementation for locating and retrieving EC [[Schema]]
95489
+ * objects incrementally instead of the full schema and it's references at once. This is useful for large schemas that
95490
+ * take a long time to load, but clients need a rough skeleton of the schema as fast as possible.
95491
+ *
95492
+ * The IncrementalSchemaLocater is a locater around the [[IncrementalSchemaLocater]] to be used in a
95493
+ * [[SchemaContext]].
95494
+ * @internal
95495
+ */
95496
+ class IncrementalSchemaLocater {
95497
+ _options;
95498
+ _schemaInfoCache;
95499
+ /**
95500
+ * Initializes a new instance of the IncrementalSchemaLocater class.
95501
+ * @param options The [[SchemaLocaterOptions]] that control the loading of the schema.
95502
+ */
95503
+ constructor(options) {
95504
+ this._options = options || {};
95505
+ this._schemaInfoCache = new SchemaInfoCache(async (context) => {
95506
+ return this.loadSchemaInfos(context);
95507
+ });
95508
+ }
95509
+ /** Gets the options how the schema locater load the schemas. */
95510
+ get options() {
95511
+ return this._options;
95512
+ }
95513
+ /**
95514
+ * Gets the [[SchemaInfo]] which matches the provided SchemaKey. The SchemaInfo may be returned
95515
+ * before the schema is fully loaded. May return the entire Schema so long as it is completely loaded as it satisfies
95516
+ * the SchemaInfo interface.
95517
+ * @param schemaKey The [[SchemaKey]] to look up.
95518
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95519
+ * @param context The [[SchemaContext]] for loading schema references.
95520
+ */
95521
+ async getSchemaInfo(schemaKey, matchType, context) {
95522
+ return this._schemaInfoCache.lookup(schemaKey, matchType, context);
95523
+ }
95524
+ /**
95525
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
95526
+ * For schemas that may have references, construct and call through a SchemaContext instead.
95527
+ * @param schemaKey The [[SchemaKey]] to look up.
95528
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95529
+ * @param context The [[SchemaContext]] for loading schema references.
95530
+ */
95531
+ async getSchema(schemaKey, matchType, context) {
95532
+ const schemaInfo = await this.getSchemaInfo(schemaKey, matchType, context);
95533
+ return schemaInfo
95534
+ ? this.loadSchema(schemaInfo, context)
95535
+ : undefined;
95536
+ }
95537
+ /**
95538
+ * Attempts to get a [[Schema]] from the locater. Yields undefined if no matching schema is found.
95539
+ * For schemas that may have references, construct and call through a SchemaContext instead.
95540
+ * NOT IMPLEMENTED IN THIS LOCATER - ALWAYS RETURNS UNDEFINED.
95541
+ * @param schemaKey The [[SchemaKey]] to look up.
95542
+ * @param matchType The [[SchemaMatchType]] to use against candidate schemas.
95543
+ * @param context The [[SchemaContext]] for loading schema references.
95544
+ * @returns Incremental schema loading does not work synchronously, this will always return undefined.
95545
+ */
95546
+ getSchemaSync(_schemaKey, _matchType, _context) {
95547
+ return undefined;
95548
+ }
95549
+ /**
95550
+ * Start loading the schema for the given schema info incrementally. The schema is returned
95551
+ * as soon as the schema stub is loaded while the schema fully resolves in the background. It should
95552
+ * only be called by the IncrementalSchemaLocater if a schema has not been loaded or started to
95553
+ * load yet.
95554
+ * @param schemaInfo The schema info of the schema to load.
95555
+ * @param schemaContext The schema context to load the schema into.
95556
+ */
95557
+ async loadSchema(schemaInfo, schemaContext) {
95558
+ // If the meta schema is an earlier version than 4.0.3, we can't use the ECSql query interface to get the schema
95559
+ // information required to load the schema entirely. In this case, we fallback to use the ECSchema RPC interface
95560
+ // to fetch the whole schema json.
95561
+ if (!await this.supportPartialSchemaLoading(schemaContext)) {
95562
+ const schemaJson = await this.getSchemaJson(schemaInfo.schemaKey, schemaContext);
95563
+ return _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema.fromJson(schemaJson, schemaContext);
95564
+ }
95565
+ // Fetches the schema partials for the given schema key. The first item in the array is the
95566
+ // actual schema props of the schema to load, the following items are schema props of referenced
95567
+ // schema items that are needed to resolve the schema properly.
95568
+ const schemaPartials = await this.getSchemaPartials(schemaInfo.schemaKey, schemaContext);
95569
+ if (schemaPartials === undefined)
95570
+ 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()}`);
95571
+ // Sort the partials in dependency order to ensure referenced schemas exist in the schema context
95572
+ // when they get requested. Otherwise the context would call this method again and for referenced
95573
+ // schemas, we would not want to request the whole schema props.
95574
+ const sortedPartials = await this.sortSchemaPartials(schemaPartials, schemaContext);
95575
+ for (const schemaProps of sortedPartials) {
95576
+ await this.startLoadingPartialSchema(schemaProps, schemaContext);
95577
+ }
95578
+ const schema = await schemaContext.getCachedSchema(schemaInfo.schemaKey);
95579
+ if (!schema)
95580
+ throw new Error(`Schema ${schemaInfo.schemaKey.name} could not be found.`);
95581
+ return schema;
95582
+ }
95583
+ /**
95584
+ * Creates a SchemaProps object by loading the Schema information from the given SchemaContext.
95585
+ * @param schemaKey The SchemaKey of the Schema whose props are to be retrieved.
95586
+ * @param schemaContext The SchemaContext holding the Schema.
95587
+ * @returns The SchemaProps object.
95588
+ */
95589
+ async createSchemaProps(schemaKey, schemaContext) {
95590
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
95591
+ if (!schemaInfo)
95592
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
95593
+ const schemaProps = {
95594
+ $schema: _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
95595
+ name: schemaKey.name,
95596
+ alias: schemaInfo.alias,
95597
+ version: schemaInfo.schemaKey.version.toString(),
95598
+ references: [],
95599
+ items: {}
95600
+ };
95601
+ if (!schemaProps.references)
95602
+ throw new Error(`Schema references is undefined for the Schema ${schemaInfo.schemaKey.name}`);
95603
+ schemaInfo.references.forEach((ref) => {
95604
+ schemaProps.references.push({ name: ref.schemaKey.name, version: ref.schemaKey.version.toString() });
95605
+ });
95606
+ return schemaProps;
95607
+ }
95608
+ async startLoadingPartialSchema(schemaProps, schemaContext) {
95609
+ if (schemaContext.schemaExists(_SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`))) {
95610
+ return;
95611
+ }
95612
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_6__.SchemaLoadingController();
95613
+ const schemaReader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schemaContext, true);
95614
+ const schema = new _Metadata_Schema__WEBPACK_IMPORTED_MODULE_4__.Schema(schemaContext);
95615
+ schema.setLoadingController(controller);
95616
+ await schemaReader.readSchema(schema, schemaProps);
95617
+ if (!this._options.loadPartialSchemaOnly)
95618
+ controller.start(this.startLoadingFullSchema(schema));
95619
+ }
95620
+ async loadFullSchema(schema) {
95621
+ const fullSchemaProps = await this.getSchemaJson(schema.schemaKey, schema.context);
95622
+ const reader = new _IncrementalSchemaReader__WEBPACK_IMPORTED_MODULE_7__.IncrementalSchemaReader(schema.context, false);
95623
+ await reader.readSchema(schema, fullSchemaProps, false);
95624
+ }
95625
+ async startLoadingFullSchema(schema) {
95626
+ if (!schema.loadingController)
95627
+ return;
95628
+ // If the schema is already resolved, return it directly.
95629
+ if (schema.loadingController.isComplete || schema.loadingController.inProgress) {
95630
+ return;
95631
+ }
95632
+ // Since the schema relies on it's references, they get triggered to be resolved
95633
+ // first by recursively calling this method. After all references has been resolved
95634
+ // the schema itself gets resolved.
95635
+ await Promise.all(schema.references.map(async (referenceSchema) => {
95636
+ if (referenceSchema.loadingController && referenceSchema.loadingController.inProgress)
95637
+ return referenceSchema.loadingController.wait();
95638
+ else
95639
+ return this.startLoadingFullSchema(referenceSchema);
95640
+ }));
95641
+ return this.loadFullSchema(schema);
95642
+ }
95643
+ async sortSchemaPartials(schemaPartials, schemaContext) {
95644
+ const schemaInfos = [];
95645
+ for (const schemaProps of schemaPartials) {
95646
+ const schemaKey = _SchemaKey__WEBPACK_IMPORTED_MODULE_5__.SchemaKey.parseString(`${schemaProps.name}.${schemaProps.version}`);
95647
+ const schemaInfo = await schemaContext.getSchemaInfo(schemaKey, _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaMatchType.Latest);
95648
+ if (!schemaInfo)
95649
+ throw new Error(`Schema ${schemaKey.name} could not be found.`);
95650
+ schemaInfos.push({ ...schemaInfo, props: schemaProps });
95651
+ }
95652
+ const orderedSchemaInfos = _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_1__.SchemaGraphUtil.buildDependencyOrderedSchemaInfoList(schemaInfos);
95653
+ return orderedSchemaInfos.map((schemaInfo) => schemaInfo.props);
95654
+ }
95655
+ }
95656
+ /**
95657
+ * Helper class to manage schema infos for a schema context.
95658
+ */
95659
+ class SchemaInfoCache {
95660
+ _schemaInfoCache;
95661
+ _schemaInfoLoader;
95662
+ constructor(schemaInfoLoader) {
95663
+ this._schemaInfoCache = new WeakMap();
95664
+ this._schemaInfoLoader = schemaInfoLoader;
95665
+ }
95666
+ async getSchemasByContext(context) {
95667
+ if (!this._schemaInfoCache.has(context)) {
95668
+ const schemaInfos = await this._schemaInfoLoader(context);
95669
+ this._schemaInfoCache.set(context, Array.from(schemaInfos));
95670
+ }
95671
+ return this._schemaInfoCache.get(context);
95672
+ }
95673
+ async lookup(schemaKey, matchType, context) {
95674
+ const contextSchemaInfos = await this.getSchemasByContext(context);
95675
+ return contextSchemaInfos
95676
+ ? contextSchemaInfos.find((schemaInfo) => schemaInfo.schemaKey.matches(schemaKey, matchType))
95677
+ : undefined;
95678
+ }
95679
+ remove(schemaKey, context) {
95680
+ const contextSchemaInfos = this._schemaInfoCache.get(context);
95681
+ if (!contextSchemaInfos)
95682
+ return;
95683
+ const index = contextSchemaInfos.findIndex((schemaInfo) => schemaInfo.schemaKey.name === schemaKey.name);
95684
+ if (index !== -1) {
95685
+ contextSchemaInfos.splice(index, 1);
95686
+ }
95687
+ }
95688
+ }
95689
+
95690
+
95691
+ /***/ }),
95692
+
95693
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js":
95694
+ /*!******************************************************************************************!*\
95695
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaReader.js ***!
95696
+ \******************************************************************************************/
95697
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95698
+
95699
+ "use strict";
95700
+ __webpack_require__.r(__webpack_exports__);
95701
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95702
+ /* harmony export */ IncrementalSchemaReader: () => (/* binding */ IncrementalSchemaReader)
95703
+ /* harmony export */ });
95704
+ /* harmony import */ var _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Deserialization/Helper */ "../../core/ecschema-metadata/lib/esm/Deserialization/Helper.js");
95705
+ /* harmony import */ var _Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Deserialization/JsonParser */ "../../core/ecschema-metadata/lib/esm/Deserialization/JsonParser.js");
95706
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95707
+ /* harmony import */ var _Metadata_Class__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Metadata/Class */ "../../core/ecschema-metadata/lib/esm/Metadata/Class.js");
95708
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
95709
+ /* harmony import */ var _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/SchemaLoadingController */ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js");
95710
+
95711
+
95712
+
95713
+
95714
+
95715
+
95716
+ /**
95717
+ * Internal helper class to read schema information incrementally. It's based on the [[SchemaReadHelper]]
95718
+ * but overrides a few methods to support the incremental schema loading case.
95719
+ * @internal
95720
+ */
95721
+ class IncrementalSchemaReader extends _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_0__.SchemaReadHelper {
95722
+ _incremental;
95723
+ /**
95724
+ * Initializes a new [[IncrementalSchemaReader]] instance.
95725
+ * @param schemaContext The [[SchemaContext]] used to load the schemas.
95726
+ * @param incremental Indicates that the Schema should be read incrementally.
95727
+ * Pass false to load the full schema without an incremental/partial load.
95728
+ */
95729
+ constructor(schemaContext, incremental) {
95730
+ super(_Deserialization_JsonParser__WEBPACK_IMPORTED_MODULE_1__.JsonParser, schemaContext);
95731
+ this._incremental = incremental;
95732
+ }
95733
+ /**
95734
+ * Indicates that a given [[SchemaItem]] has been fully loaded.
95735
+ * @param schemaItem The SchemaItem to check.
95736
+ * @returns True if the item has been loaded, false if still in progress.
95737
+ */
95738
+ isSchemaItemLoaded(schemaItem) {
95739
+ return schemaItem !== undefined
95740
+ && schemaItem.loadingController !== undefined
95741
+ && schemaItem.loadingController.isComplete;
95742
+ }
95743
+ /**
95744
+ * Starts loading the [[SchemaItem]] identified by the given name and itemType.
95745
+ * @param schema The [[Schema]] that contains the SchemaItem.
95746
+ * @param name The name of the SchemaItem to load.
95747
+ * @param itemType The SchemaItem type name of the item to load.
95748
+ * @param schemaItemObject The object accepting the SchemaItem data.
95749
+ * @returns A promise that resolves to the loaded SchemaItem instance. Can be undefined.
95750
+ */
95751
+ async loadSchemaItem(schema, name, itemType, schemaItemObject) {
95752
+ const schemaItem = await super.loadSchemaItem(schema, name, itemType, this._incremental ? undefined : schemaItemObject);
95753
+ // In incremental mode, we only load the stubs of the classes. These include the modifier and base classes.
95754
+ // The fromJSON method of the actual class instances may complain about missing properties in the props, so
95755
+ // calling the fromJSON on the ECClass ensures only the bare minimum is loaded.
95756
+ if (this._incremental && schemaItemObject && schemaItem) {
95757
+ if (schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity) {
95758
+ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_4__.SchemaItem.prototype.fromJSONSync.call(schemaItem, schemaItemObject);
95759
+ }
95760
+ else {
95761
+ schemaItem.fromJSONSync(schemaItemObject);
95762
+ }
95763
+ }
95764
+ this.schemaItemLoading(schemaItem);
95765
+ return schemaItem;
95766
+ }
95767
+ schemaItemLoading(schemaItem) {
95768
+ if (schemaItem === undefined)
95769
+ return;
95770
+ if (schemaItem.loadingController === undefined) {
95771
+ const controller = new _utils_SchemaLoadingController__WEBPACK_IMPORTED_MODULE_5__.SchemaLoadingController();
95772
+ schemaItem.setLoadingController(controller);
95773
+ }
95774
+ if (_Metadata_Class__WEBPACK_IMPORTED_MODULE_3__.ECClass.isECClass(schemaItem)
95775
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.KindOfQuantity
95776
+ || schemaItem.schemaItemType === _ECObjects__WEBPACK_IMPORTED_MODULE_2__.SchemaItemType.Format)
95777
+ schemaItem.loadingController.isComplete = !this._incremental;
95778
+ else
95779
+ schemaItem.loadingController.isComplete = true;
95780
+ }
95781
+ }
95782
+
95783
+
95784
+ /***/ }),
95785
+
95786
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js":
95787
+ /*!************************************************************************************!*\
95788
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js ***!
95789
+ \************************************************************************************/
95790
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95791
+
95792
+ "use strict";
95793
+ __webpack_require__.r(__webpack_exports__);
95794
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95795
+ /* harmony export */ KindOfQuantityParser: () => (/* binding */ KindOfQuantityParser),
95796
+ /* harmony export */ SchemaItemParser: () => (/* binding */ SchemaItemParser)
95797
+ /* harmony export */ });
95798
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
95799
+ /* harmony import */ var _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Metadata/OverrideFormat */ "../../core/ecschema-metadata/lib/esm/Metadata/OverrideFormat.js");
95800
+ /* harmony import */ var _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Metadata/SchemaItem */ "../../core/ecschema-metadata/lib/esm/Metadata/SchemaItem.js");
95801
+ /* harmony import */ var _SchemaParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaParser */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js");
95802
+ /*---------------------------------------------------------------------------------------------
95803
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95804
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95805
+ *--------------------------------------------------------------------------------------------*/
95806
+
95807
+
95808
+
95809
+
95810
+ /**
95811
+ * Parses SchemaItemProps JSON returned from an ECSql query and returns the correct SchemaItemProps JSON.
95812
+ * This is necessary as a small amount information (ie. CustomAttribute data) returned from the iModelDb
95813
+ * is in a different format than is required for a SchemaItemProps JSON object.
95814
+ * @internal
95815
+ */
95816
+ class SchemaItemParser {
95817
+ _schema;
95818
+ _context;
95819
+ /**
95820
+ * Initializes a new SchemaItemParser.
95821
+ * @param schemaName The name the Schema containing the SchemaItems.
95822
+ * @param context The SchemaContext containing the Schema.
95823
+ */
95824
+ constructor(schemaName, context) {
95825
+ this._schema = schemaName;
95826
+ this._context = context;
95827
+ }
95828
+ /**
95829
+ * Parses the given SchemaItemProps JSON returned from an ECSql query.
95830
+ * @param data The SchemaItemProps JSON as returned from an iModelDb.
95831
+ * @returns The corrected SchemaItemProps Json.
95832
+ */
95833
+ async parse(data) {
95834
+ const props = data;
95835
+ props.schemaItemType = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_0__.parseSchemaItemType)(data.schemaItemType);
95836
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return (0,_SchemaParser__WEBPACK_IMPORTED_MODULE_3__.parseCustomAttribute)(attr); }) : undefined;
95837
+ if (!props.customAttributes || props.customAttributes.length === 0)
95838
+ delete props.customAttributes;
95839
+ return props;
95840
+ }
95841
+ /**
95842
+ * Helper method to resolve the SchemaItem's full name from the given rawTypeName.
95843
+ * If the SchemaItem is defined in the same Schema from which it is referenced,
95844
+ * the rawTypeName will be SchemaItem name ('PhysicalElement'). Otherwise,
95845
+ * the rawTypeName will have the schema alias ('bis:PhysicalElement').
95846
+ * @param rawTypeName The name or aliased name of the SchemaItem.
95847
+ * @returns The full name of the SchemaItem, ie. 'BisCore.PhysicalElement'
95848
+ */
95849
+ async getQualifiedTypeName(rawTypeName) {
95850
+ const nameParts = rawTypeName.split(":");
95851
+ if (nameParts.length !== 2) {
95852
+ const [schemaName, itemName] = _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_2__.SchemaItem.parseFullName(rawTypeName);
95853
+ if (!schemaName || schemaName === '')
95854
+ return `${this._schema}.${itemName}`;
95855
+ return rawTypeName;
95856
+ }
95857
+ const resolvedName = await this.resolveNameFromAlias(nameParts[0].toLocaleLowerCase());
95858
+ if (!resolvedName)
95859
+ throw new Error(`No valid schema found for alias '${nameParts[0]}'`);
95860
+ return `${resolvedName}.${nameParts[1]}`;
95861
+ }
95862
+ async resolveNameFromAlias(alias) {
95863
+ for (const schema of this._context.getKnownSchemas()) {
95864
+ if (schema.alias === alias)
95865
+ return schema.schemaKey.name;
95866
+ }
95867
+ return undefined;
95868
+ }
95869
+ }
95870
+ /**
95871
+ * Parses KindOfQuantityProps JSON returned from an ECSql query and returns the correct KindOfQuantityProps JSON.
95872
+ * This is necessary as a small amount information (ie. unqualified type names of presentationUnits) returned from
95873
+ * the iModelDb is in a different format than is required for a KindOfQuantityProps JSON object.
95874
+ * @internal
95875
+ */
95876
+ class KindOfQuantityParser extends SchemaItemParser {
95877
+ /**
95878
+ * Parses the given KindOfQuantityProps JSON returned from an ECSql query.
95879
+ * @param data The KindOfQuantityProps JSON as returned from an iModelDb.
95880
+ * @returns The corrected KindOfQuantityProps Json.
95881
+ */
95882
+ async parse(data) {
95883
+ const mutableProps = await super.parse(data);
95884
+ if (mutableProps.persistenceUnit) {
95885
+ mutableProps.persistenceUnit = await this.getQualifiedTypeName(mutableProps.persistenceUnit);
95886
+ }
95887
+ mutableProps.presentationUnits = await this.parsePresentationUnits(mutableProps);
95888
+ return mutableProps;
95889
+ }
95890
+ async parsePresentationUnits(props) {
95891
+ const presentationUnits = [];
95892
+ if (!props.presentationUnits)
95893
+ return [];
95894
+ for (const presentationUnit of props.presentationUnits) {
95895
+ const presFormatOverride = _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_1__.OverrideFormat.parseFormatString(presentationUnit);
95896
+ const formatString = await this.createOverrideFormatString(presFormatOverride);
95897
+ presentationUnits.push(formatString);
95898
+ }
95899
+ ;
95900
+ return presentationUnits;
95901
+ }
95902
+ async createOverrideFormatString(overrideFormatProps) {
95903
+ let formatFullName = await this.getQualifiedTypeName(overrideFormatProps.name);
95904
+ if (overrideFormatProps.precision)
95905
+ formatFullName += `(${overrideFormatProps.precision.toString()})`;
95906
+ if (undefined === overrideFormatProps.unitAndLabels)
95907
+ return formatFullName;
95908
+ for (const [unit, unitLabel] of overrideFormatProps.unitAndLabels) {
95909
+ const unitFullName = await this.getQualifiedTypeName(unit);
95910
+ if (undefined === unitLabel)
95911
+ formatFullName += `[${unitFullName}]`;
95912
+ else
95913
+ formatFullName += `[${unitFullName}|${unitLabel}]`;
95914
+ }
95915
+ return formatFullName;
95916
+ }
95917
+ }
95918
+
95919
+
95920
+ /***/ }),
95921
+
95922
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js":
95923
+ /*!************************************************************************************!*\
95924
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js ***!
95925
+ \************************************************************************************/
95926
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
95927
+
95928
+ "use strict";
95929
+ __webpack_require__.r(__webpack_exports__);
95930
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
95931
+ /* harmony export */ SchemaItemQueries: () => (/* binding */ SchemaItemQueries)
95932
+ /* harmony export */ });
95933
+ /*---------------------------------------------------------------------------------------------
95934
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
95935
+ * See LICENSE.md in the project root for license terms and full copyright notice.
95936
+ *--------------------------------------------------------------------------------------------*/
95937
+ /************************************************************************************
95938
+ * All SchemaItem queries for each SchemaItemType are defined here. These queries
95939
+ * are shared for both 'partial schema' and 'full schema' queries.
95940
+ ***********************************************************************************/
95941
+ /**
95942
+ * Query for SchemaItemType KindOfQuantity data.
95943
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95944
+ */
95945
+ const kindOfQuantity = (singleSchema) => `
95946
+ SELECT
95947
+ [koq].[Schema].[Id] AS [SchemaId],
95948
+ json_object (
95949
+ 'schemaItemType', 'KindOfQuantity',
95950
+ 'name', [koq].[Name],
95951
+ 'label', [koq].[DisplayLabel],
95952
+ 'description', [koq].[Description]
95953
+ ${singleSchema ? `
95954
+ ,'relativeError', [koq].[RelativeError],
95955
+ 'persistenceUnit', [koq].[PersistenceUnit],
95956
+ 'presentationUnits', (
95957
+ SELECT json_group_array(js."value")
95958
+ FROM [meta].[KindOfQuantityDef] [koq1], json1.json_each([PresentationUnits]) js
95959
+ WHERE [koq1].[ECInstanceId] = [koq].[ECInstanceId]
95960
+ ) ` : ""}
95961
+ ) as [item]
95962
+ FROM
95963
+ [meta].[KindOfQuantityDef] [koq]
95964
+ ${singleSchema ? `
95965
+ JOIN
95966
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [koq].[Schema].[Id]
95967
+ WHERE [schema].[Name] = :schemaName
95968
+ ` : ""}
95969
+ `;
95970
+ /**
95971
+ * Query for SchemaItemType PropertyCategory data.
95972
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95973
+ */
95974
+ const propertyCategory = (singleSchema) => `
95975
+ SELECT
95976
+ [pc].[Schema].[Id] AS [SchemaId],
95977
+ json_object (
95978
+ 'schemaItemType', 'PropertyCategory',
95979
+ 'name', [pc].[Name],
95980
+ 'label', [pc].[DisplayLabel],
95981
+ 'description', [pc].[Description],
95982
+ 'priority', [pc].[Priority]
95983
+ ) as [item]
95984
+ FROM
95985
+ [meta].[PropertyCategoryDef] [pc]
95986
+ ${singleSchema ? `
95987
+ JOIN
95988
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pc].[Schema].[Id]
95989
+ WHERE [schema].[Name] = :schemaName
95990
+ ` : ""}
95991
+ `;
95992
+ /**
95993
+ * Query for SchemaItemType Enumeration data.
95994
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
95995
+ */
95996
+ const enumeration = (singleSchema) => `
95997
+ SELECT
95998
+ [ed].[Schema].[Id] AS [SchemaId],
95999
+ json_object (
96000
+ 'schemaItemType', 'Enumeration',
96001
+ 'name', [ed].[Name],
96002
+ 'label', [ed].[DisplayLabel],
96003
+ 'description', [ed].[Description],
96004
+ 'type', IIF([ed].[Type] = 1281, 'int', IIF([ed].[Type] = 2305, 'string', null)),
96005
+ 'isStrict', IIF([ed].[IsStrict] = 1, json('true'), json('false')),
96006
+ 'enumerators', (
96007
+ SELECT json_group_array(json(json_object(
96008
+ 'name', json_extract(js."value", '$.Name'),
96009
+ 'value', IFNULL(json_extract(js."value", '$.StringValue'), (json_extract(js."value", '$.IntValue'))),
96010
+ 'label', json_extract(js."value", '$.DisplayLabel'),
96011
+ 'description', json_extract(js."value", '$.Description')
96012
+ )))
96013
+ FROM [meta].[ECEnumerationDef] [enumerationDef], json1.json_each([EnumValues]) js
96014
+ WHERE [enumerationDef].[ECInstanceId] = [ed].[ECInstanceId]
96015
+ )
96016
+ ) as [item]
96017
+ FROM
96018
+ [meta].[ECEnumerationDef] [ed]
96019
+ ${singleSchema ? `
96020
+ JOIN
96021
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ed].[Schema].[Id]
96022
+ WHERE [schema].[Name] = :schemaName` : ""}
96023
+ `;
96024
+ /**
96025
+ * Query for SchemaItemType Unit data.
96026
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96027
+ */
96028
+ const unit = (singleSchema) => `
96029
+ SELECT
96030
+ [ud].[Schema].[Id] AS [SchemaId],
96031
+ json_object (
96032
+ 'schemaItemType', 'Unit',
96033
+ 'name', [ud].[Name],
96034
+ 'label', [ud].[DisplayLabel],
96035
+ 'description', [ud].[Description],
96036
+ 'definition', [ud].[Definition],
96037
+ 'numerator', IIF([ud].[Numerator] IS NULL, NULL, json(format('%.16g', [ud].[Numerator]))),
96038
+ 'denominator', IIF([ud].[Denominator] IS NULL, NULL, json(format('%.16g', [ud].[Denominator]))),
96039
+ 'offset', IIF([ud].[Offset] IS NULL, NULL, json(format('%!.15f', [ud].[Offset]))),
96040
+ 'unitSystem', CONCAT([uss].[Name],'.', [usd].[Name]),
96041
+ 'phenomenon', CONCAT([ps].[Name],'.', [pd].[Name])
96042
+ ) as item
96043
+ FROM
96044
+ [meta].[UnitDef] [ud]
96045
+ ${singleSchema ? `
96046
+ JOIN
96047
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
96048
+ JOIN [meta].[UnitSystemDef] [usd]
96049
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
96050
+ JOIN [meta].[ECSchemaDef] [uss]
96051
+ ON [uss].[ECInstanceId] = [usd].[Schema].[Id]
96052
+ JOIN [meta].[PhenomenonDef] [pd]
96053
+ ON [pd].[ECInstanceId] = [ud].[Phenomenon].[Id]
96054
+ JOIN [meta].[ECSchemaDef] [ps]
96055
+ ON [ps].[ECInstanceId] = [pd].[Schema].[Id]
96056
+ WHERE
96057
+ ${singleSchema ? `
96058
+ [schema].[Name] = :schemaName AND` : ""}
96059
+ [ud].[IsConstant] = 0 AND
96060
+ [ud].[InvertingUnit] IS NULL
96061
+ `;
96062
+ /**
96063
+ * Query for SchemaItemType InvertedUnit data.
96064
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96065
+ */
96066
+ const invertedUnit = (singleSchema) => `
96067
+ SELECT
96068
+ [ud].[Schema].[Id] AS [SchemaId],
96069
+ json_object (
96070
+ 'schemaItemType', 'InvertedUnit',
96071
+ 'name', [ud].[Name],
96072
+ 'label', [ud].[DisplayLabel],
96073
+ 'description', [ud].[Description],
96074
+ 'unitSystem', CONCAT([systemSchema].[Name],'.', [usd].[Name]),
96075
+ 'invertsUnit', IIF([iud].[Name] IS NULL, null, CONCAT([ius].[Name],'.', [iud].[Name]))
96076
+ ) as [item]
96077
+ FROM
96078
+ [meta].[UnitDef] [ud]
96079
+ ${singleSchema ? `
96080
+ JOIN
96081
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [ud].[Schema].[Id]` : ""}
96082
+ JOIN [meta].[UnitSystemDef] [usd]
96083
+ ON [usd].[ECInstanceId] = [ud].[UnitSystem].[Id]
96084
+ JOIN [meta].[ECSchemaDef] [systemSchema]
96085
+ ON [systemSchema].[ECInstanceId] = [usd].[Schema].[Id]
96086
+ LEFT JOIN [meta].[UnitDef] [iud]
96087
+ ON [iud].[ECInstanceId] = [ud].[InvertingUnit].[Id]
96088
+ LEFT JOIN [meta].[ECSchemaDef] [ius]
96089
+ ON [ius].[ECInstanceId] = [iud].[Schema].[Id]
96090
+ WHERE
96091
+ ${singleSchema ? `
96092
+ [schema].[Name] = :schemaName AND` : ""}
96093
+ [ud].[IsConstant] = 0 AND
96094
+ [ud].[InvertingUnit] IS NOT NULL
96095
+ `;
96096
+ /**
96097
+ * Query for SchemaItemType Constant data.
96098
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96099
+ */
96100
+ const constant = (singleSchema) => `
96101
+ SELECT
96102
+ [cd].[Schema].[Id] AS [SchemaId],
96103
+ json_object(
96104
+ 'schemaItemType', 'Constant',
96105
+ 'name', [cd].[Name],
96106
+ 'label', [cd].[DisplayLabel],
96107
+ 'description', [cd].[Description],
96108
+ 'definition', [cd].[Definition],
96109
+ 'numerator', IIF([cd].[Numerator] IS NULL, NULL, json(format('%.16g', [cd].[Numerator]))),
96110
+ 'denominator', IIF([cd].[Denominator] IS NULL, NULL, json(format('%.16g', [cd].[Denominator]))),
96111
+ 'phenomenon', CONCAT([phenomSchema].[Name],'.', [phenomDef].[Name])
96112
+ ) as item
96113
+ FROM
96114
+ [meta].[UnitDef] [cd]
96115
+ ${singleSchema ? `
96116
+ JOIN
96117
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [cd].[Schema].[Id]` : ""}
96118
+ JOIN [meta].[PhenomenonDef] [phenomDef]
96119
+ ON [phenomDef].[ECInstanceId] = [cd].[Phenomenon].[Id]
96120
+ JOIN [meta].[ECSchemaDef] [phenomSchema]
96121
+ ON [phenomSchema].[ECInstanceId] = [phenomDef].[Schema].[Id]
96122
+ WHERE
96123
+ ${singleSchema ? `
96124
+ [schema].[Name] = :schemaName AND` : ""}
96125
+ [cd].[IsConstant] = 1
96126
+ `;
96127
+ /**
96128
+ * Query for SchemaItemType UnitSystem data.
96129
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96130
+ */
96131
+ const unitSystem = (singleSchema) => `
96132
+ SELECT
96133
+ [us].[Schema].[Id] AS [SchemaId],
96134
+ json_object (
96135
+ 'schemaItemType', 'UnitSystem',
96136
+ 'name', [us].[Name],
96137
+ 'label', [us].[DisplayLabel],
96138
+ 'description', [us].[Description]
96139
+ ) as [item]
96140
+ FROM
96141
+ [meta].[UnitSystemDef] [us]
96142
+ ${singleSchema ? `
96143
+ JOIN
96144
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [us].[Schema].[Id]
96145
+ WHERE [schema].[Name] = :schemaName` : ""}
96146
+ `;
96147
+ /**
96148
+ * Query for SchemaItemType Phenomenon data.
96149
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96150
+ */
96151
+ const phenomenon = (singleSchema) => `
96152
+ SELECT
96153
+ [pd].[Schema].[Id] AS [SchemaId],
96154
+ json_object(
96155
+ 'schemaItemType', 'Phenomenon',
96156
+ 'name', [pd].[Name],
96157
+ 'label', [pd].[DisplayLabel],
96158
+ 'description', [pd].[Description],
96159
+ 'definition', [pd].[Definition]
96160
+ ) as [item]
96161
+ FROM
96162
+ [meta].[PhenomenonDef] [pd]
96163
+ ${singleSchema ? `
96164
+ JOIN
96165
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [pd].[Schema].[Id]
96166
+ WHERE [schema].[Name] = :schemaName` : ""}
96167
+ `;
96168
+ /**
96169
+ * Query for SchemaItemType Format data.
96170
+ * @param singleSchema Indicates if a filter and join for a single Schema should be applied.
96171
+ */
96172
+ const format = (singleSchema) => `
96173
+ SELECT
96174
+ [fd].[Schema].[Id] AS [SchemaId],
96175
+ json_object(
96176
+ 'schemaItemType', 'Format',
96177
+ 'name', [fd].[Name],
96178
+ 'label', [fd].[DisplayLabel],
96179
+ 'description', [fd].[Description],
96180
+ 'type', json_extract([fd].[NumericSpec], '$.type'),
96181
+ 'precision', json_extract([fd].[NumericSpec], '$.precision'),
96182
+ 'roundFactor', json_extract([fd].[NumericSpec], '$.roundFactor'),
96183
+ 'minWidth', json_extract([fd].[NumericSpec], '$.minWidth'),
96184
+ 'showSignOption', json_extract([fd].[NumericSpec], '$.showSignOption'),
96185
+ 'decimalSeparator', json_extract([fd].[NumericSpec], '$.decimalSeparator'),
96186
+ 'thousandSeparator', json_extract([fd].[NumericSpec], '$.thousandSeparator'),
96187
+ 'uomSeparator', json_extract([fd].[NumericSpec], '$.uomSeparator'),
96188
+ 'scientificType', json_extract([fd].[NumericSpec], '$.scientificType'),
96189
+ 'stationOffsetSize', json_extract([fd].[NumericSpec], '$.stationOffsetSize'),
96190
+ 'stationSeparator', json_extract([fd].[NumericSpec], '$.stationSeparator'),
96191
+ 'formatTraits', json_extract([fd].[NumericSpec], '$.formatTraits')
96192
+ ${singleSchema ? `
96193
+ ,'composite', (
96194
+ SELECT
96195
+ json_object(
96196
+ 'spacer', json_extract([fd1].[CompositeSpec], '$.spacer'),
96197
+ 'includeZero', json(IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 1, 'true', IIF(json_extract([fd1].[CompositeSpec], '$.includeZero') = 0, 'false', null))),
96198
+ 'units', (
96199
+ SELECT json_group_array(json(json_object(
96200
+ 'name', CONCAT([sd].[Name], '.', [ud].[Name]),
96201
+ 'label', [fud].[Label]
96202
+ )))
96203
+ FROM [meta].[FormatDef] [fd2]
96204
+ LEFT JOIN [meta].[FormatCompositeUnitDef] [fud] ON [fud].[Format].[Id] = [fd2].[ECInstanceId]
96205
+ LEFT JOIN [meta].[UnitDef] [ud] ON [ud].[ECInstanceId] = [fud].[Unit].[Id]
96206
+ INNER JOIN [meta].[ECSchemaDef] [sd] ON [sd].[ECInstanceId] = [ud].[Schema].[Id]
96207
+ WHERE [fd2].[ECInstanceId] = [fd1].[ECInstanceId]
96208
+ )
96209
+ )
96210
+ FROM [meta].[FormatDef] [fd1]
96211
+ WHERE [fd1].[ECInstanceId]= [fd].[ECInstanceId] AND [fd1].[CompositeSpec] IS NOT NULL
96212
+ )` : ""}
96213
+ ) AS item
96214
+ FROM
96215
+ [meta].[FormatDef] [fd]
96216
+ ${singleSchema ? `
96217
+ JOIN
96218
+ [meta].[ECSchemaDef] [schema] ON [schema].[ECInstanceId] = [fd].[Schema].[Id]
96219
+ WHERE [schema].[Name] = :schemaName` : ""}
96220
+ `;
96221
+ /**
96222
+ * Queries for each SchemaItemType
96223
+ * @internal
96224
+ */
96225
+ // eslint-disable-next-line @typescript-eslint/naming-convention
96226
+ const SchemaItemQueries = {
96227
+ kindOfQuantity,
96228
+ propertyCategory,
96229
+ enumeration,
96230
+ unit,
96231
+ invertedUnit,
96232
+ constant,
96233
+ unitSystem,
96234
+ phenomenon,
96235
+ format
96236
+ };
96237
+
96238
+
96239
+ /***/ }),
96240
+
96241
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js":
96242
+ /*!*******************************************************************************!*\
96243
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaParser.js ***!
96244
+ \*******************************************************************************/
96245
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
96246
+
96247
+ "use strict";
96248
+ __webpack_require__.r(__webpack_exports__);
96249
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
96250
+ /* harmony export */ SchemaParser: () => (/* binding */ SchemaParser),
96251
+ /* harmony export */ parseCustomAttribute: () => (/* binding */ parseCustomAttribute)
96252
+ /* harmony export */ });
96253
+ /* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Constants */ "../../core/ecschema-metadata/lib/esm/Constants.js");
96254
+ /* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
96255
+ /* harmony import */ var _ClassParsers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ClassParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ClassParsers.js");
96256
+ /* harmony import */ var _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaItemParsers */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemParsers.js");
96257
+ /*---------------------------------------------------------------------------------------------
96258
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
96259
+ * See LICENSE.md in the project root for license terms and full copyright notice.
96260
+ *--------------------------------------------------------------------------------------------*/
96261
+
96262
+
96263
+
96264
+
96265
+ function clean(_key, value) {
96266
+ return value === null ? undefined : value;
96267
+ }
96268
+ /**
96269
+ * Parses SchemaProps JSON returned from an ECSql query and returns the correct SchemaProps JSON object.
96270
+ * This is necessary as a small amount information (ie. CustomAttributes, unqualified type names, etc.)
96271
+ * returned from the iModelDb is in a different format than is required for a given Schema or
96272
+ * SchemaItemProps JSON object.
96273
+ * @internal
96274
+ */
96275
+ class SchemaParser {
96276
+ /**
96277
+ * Corrects the SchemaProps JSON returned from the query to a proper SchemaProps
96278
+ * JSON object.
96279
+ * @param schema The SchemaProps JSON object to parse.
96280
+ * @param context The SchemaContext that will contain the schema and it's references.
96281
+ * @returns The corrected SchemaProps JSON.
96282
+ */
96283
+ static async parse(schema, context) {
96284
+ const props = schema;
96285
+ props.$schema = _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris.SCHEMAURL3_2_JSON,
96286
+ props.customAttributes = props.customAttributes ? props.customAttributes.map((attr) => { return parseCustomAttribute(attr); }) : undefined;
96287
+ props.label = props.label === null ? undefined : props.label;
96288
+ props.description = props.description === null ? undefined : props.description;
96289
+ if (props.items) {
96290
+ props.items = await this.parseItems(props.items, props.name, context);
96291
+ }
96292
+ if (!props.customAttributes || props.customAttributes.length === 0)
96293
+ delete props.customAttributes;
96294
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
96295
+ return cleaned;
96296
+ }
96297
+ /**
96298
+ * Parse the given SchemaItemProps array, as returned from an ECSql query, and returns the corrected SchemaItemProps.
96299
+ * @param schemaItems The SchemaItemProps array returned from an iModelDb.
96300
+ * @param schemaName The name of the Schema to which the SchemaItemProps belong.
96301
+ * @param context The SchemaContext containing the Schema.
96302
+ * @returns The corrected SchemaItemProps.
96303
+ */
96304
+ static async parseSchemaItems(schemaItems, schemaName, context) {
96305
+ const items = [];
96306
+ for (const item of schemaItems) {
96307
+ const props = await this.parseItem(item, schemaName, context);
96308
+ const cleaned = JSON.parse(JSON.stringify(props, clean));
96309
+ items.push(cleaned);
96310
+ }
96311
+ return items.length > 0 ? items : undefined;
96312
+ }
96313
+ static async parseItems(schemaItemProps, schemaName, context) {
96314
+ const items = {};
96315
+ for (const itemProps of schemaItemProps) {
96316
+ const props = await this.parseItem(itemProps, schemaName, context);
96317
+ items[props.name] = props;
96318
+ delete props.name;
96319
+ }
96320
+ return Object.keys(items).length > 0 ? items : undefined;
96321
+ }
96322
+ static async parseItem(props, schemaName, context) {
96323
+ const schemaItem = "string" === typeof (props) ? JSON.parse(props) : props;
96324
+ const type = (0,_ECObjects__WEBPACK_IMPORTED_MODULE_1__.parseSchemaItemType)(schemaItem.schemaItemType);
96325
+ switch (type) {
96326
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.KindOfQuantity:
96327
+ const koqParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.KindOfQuantityParser(schemaName, context);
96328
+ return koqParser.parse(schemaItem);
96329
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.EntityClass:
96330
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.StructClass:
96331
+ const classParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.ClassParser(schemaName, context);
96332
+ return classParser.parse(schemaItem);
96333
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.RelationshipClass:
96334
+ const relationshipParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.RelationshipClassParser(schemaName, context);
96335
+ return relationshipParser.parse(schemaItem);
96336
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.Mixin:
96337
+ const mixinParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.MixinParser(schemaName, context);
96338
+ return mixinParser.parse(schemaItem);
96339
+ case _ECObjects__WEBPACK_IMPORTED_MODULE_1__.SchemaItemType.CustomAttributeClass:
96340
+ const caParser = new _ClassParsers__WEBPACK_IMPORTED_MODULE_2__.CustomAttributeClassParser(schemaName, context);
96341
+ return caParser.parse(schemaItem);
96342
+ default:
96343
+ const itemParser = new _SchemaItemParsers__WEBPACK_IMPORTED_MODULE_3__.SchemaItemParser(schemaName, context);
96344
+ return itemParser.parse(schemaItem);
96345
+ }
96346
+ }
96347
+ }
96348
+ /**
96349
+ * Utility method to parse CustomAttribute data retrieved from a ECSql query.
96350
+ * @param customAttribute CustomAttribute data as retrieved from an iModel query.
96351
+ * @returns The CustomAttribute instance.
96352
+ * @internal
96353
+ */
96354
+ function parseCustomAttribute(customAttribute) {
96355
+ return {
96356
+ ...customAttribute[customAttribute.ecClass],
96357
+ className: `${(customAttribute.ecSchema).split('.')[0]}.${customAttribute.ecClass}`,
96358
+ };
96359
+ }
96360
+
96361
+
96362
+ /***/ }),
96363
+
96364
+ /***/ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js":
96365
+ /*!************************************************************************************!*\
96366
+ !*** ../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaStubQueries.js ***!
96367
+ \************************************************************************************/
96368
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
96369
+
96370
+ "use strict";
96371
+ __webpack_require__.r(__webpack_exports__);
96372
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
96373
+ /* harmony export */ ecsqlQueries: () => (/* binding */ ecsqlQueries),
96374
+ /* harmony export */ modifier: () => (/* binding */ modifier),
96375
+ /* harmony export */ strength: () => (/* binding */ strength),
96376
+ /* harmony export */ strengthDirection: () => (/* binding */ strengthDirection)
96377
+ /* harmony export */ });
96378
+ /* harmony import */ var _SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaItemQueries */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/SchemaItemQueries.js");
96379
+ /*---------------------------------------------------------------------------------------------
96380
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
96381
+ * See LICENSE.md in the project root for license terms and full copyright notice.
96382
+ *--------------------------------------------------------------------------------------------*/
96383
+
96384
+ const modifier = (alias) => {
96385
+ return `
96386
+ CASE
96387
+ WHEN [${alias}].[modifier] = 0 THEN 'None'
96388
+ WHEN [${alias}].[modifier] = 1 THEN 'Abstract'
96389
+ WHEN [${alias}].[modifier] = 2 THEN 'Sealed'
96390
+ ELSE NULL
96391
+ END
96392
+ `;
96393
+ };
96394
+ const strength = (alias) => {
96395
+ return `
96396
+ CASE
96397
+ WHEN [${alias}].[RelationshipStrength] = 0 THEN 'Referencing'
96398
+ WHEN [${alias}].[RelationshipStrength] = 1 THEN 'Holding'
96399
+ WHEN [${alias}].[RelationshipStrength] = 2 THEN 'Embedding'
96400
+ ELSE NULL
96401
+ END
96402
+ `;
96403
+ };
96404
+ const strengthDirection = (alias) => {
96405
+ return `
96406
+ CASE
96407
+ WHEN [${alias}].[RelationshipStrengthDirection] = 1 THEN 'Forward'
96408
+ WHEN [${alias}].[RelationshipStrengthDirection] = 2 THEN 'Backward'
96409
+ ELSE NULL
96410
+ END
96411
+ `;
96412
+ };
96413
+ const withAppliesTo = `
96414
+ AppliesToCTE AS (
96415
+ SELECT
96416
+ [mixinAppliesTo].[ECInstanceId] AS [AppliesToId],
96417
+ [appliesToSchema].[name] as [AppliesToSchema],
96418
+ json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.IsMixin.AppliesToEntityClass') AS [AppliesTo]
96419
+ FROM [meta].[CustomAttribute] [ca]
96420
+ JOIN [meta].[ECClassDef] [mixinAppliesTo]
96421
+ ON [mixinAppliesTo].[ECInstanceId] = [ca].[ContainerId]
96422
+ JOIN [meta].[ECSchemaDef] [appliesToSchema]
96423
+ ON [appliesToSchema].[ECInstanceId] = [mixinAppliesTo].[Schema].[Id]
96424
+ WHERE [ca].[ContainerType] = 30
96425
+ AND json_extract(XmlCAToJson([ca].[Class].[Id], [ca].[Instance]), '$.ecClass') = 'IsMixin'
96426
+ )
96427
+ `;
96428
+ const withSchemaReferences = `
96429
+ SchemaReferences AS (
96430
+ SELECT
96431
+ [ref].[SourceECInstanceId] AS [SchemaId],
96432
+ CONCAT([Name],'.',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [fullName]
96433
+ FROM
96434
+ [meta].[ECSchemaDef] AS [refSchema]
96435
+ INNER JOIN [meta].[SchemaHasSchemaReferences] [ref]
96436
+ ON [ref].[TargetECInstanceId] = [refSchema].[ECInstanceId]
96437
+ )
96438
+ `;
96439
+ const customAttributeQuery = `
96440
+ SELECT
96441
+ [Schema].[Id] AS [SchemaId],
96442
+ json_object(
96443
+ 'name', [class].[Name],
96444
+ 'schemaItemType', 'CustomAttributeClass',
96445
+ 'modifier', ${modifier("class")},
96446
+ 'label', [class].[DisplayLabel],
96447
+ 'description', [class].[Description],
96448
+ 'appliesTo', [class].[CustomAttributeContainerType],
96449
+ 'baseClasses', (
96450
+ SELECT
96451
+ json_group_array(json(json_object(
96452
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96453
+ 'name', [baseClass].[Name],
96454
+ 'schemaItemType', 'CustomAttributeClass',
96455
+ 'modifier', ${modifier("baseClass")},
96456
+ 'label', [baseClass].[DisplayLabel],
96457
+ 'description', [baseClass].[Description],
96458
+ 'appliesTo', [baseClass].[CustomAttributeContainerType]
96459
+ )))
96460
+ FROM
96461
+ [meta].[ECClassDef] [baseClass]
96462
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96463
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96464
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96465
+ )
96466
+ ) AS [item]
96467
+ FROM [meta].[ECClassDef] [class]
96468
+ WHERE [class].[Type] = 3
96469
+ `;
96470
+ const structQuery = `
96471
+ SELECT
96472
+ [Schema].[Id] AS [SchemaId],
96473
+ json_object(
96474
+ 'name', [class].[Name],
96475
+ 'schemaItemType', 'StructClass',
96476
+ 'modifier', ${modifier("class")},
96477
+ 'label', [class].[DisplayLabel],
96478
+ 'description', [class].[Description],
96479
+ 'baseClasses', (
96480
+ SELECT
96481
+ json_group_array(json(json_object(
96482
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96483
+ 'name', [baseClass].[Name],
96484
+ 'schemaItemType', 'StructClass',
96485
+ 'modifier', ${modifier("baseClass")},
96486
+ 'label', [baseClass].[DisplayLabel],
96487
+ 'description', [baseClass].[Description]
96488
+ )))
96489
+ FROM
96490
+ [meta].[ECClassDef] [baseClass]
96491
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96492
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96493
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96494
+ )
96495
+ ) AS [item]
96496
+ FROM [meta].[ECClassDef] [class]
96497
+ WHERE [class].[Type] = 2
96498
+ `;
96499
+ const relationshipQuery = `
96500
+ SELECT
96501
+ [Schema].[Id] AS [SchemaId],
96502
+ json_object(
96503
+ 'name', [class].[Name],
96504
+ 'schemaItemType', 'RelationshipClass',
96505
+ 'modifier', ${modifier("class")},
96506
+ 'label', [class].[DisplayLabel],
96507
+ 'description', [class].[Description],
96508
+ 'strength', ${strength("class")},
96509
+ 'strengthDirection', ${strengthDirection("class")},
96510
+ 'baseClasses', (
96511
+ SELECT
96512
+ json_group_array(json(json_object(
96513
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96514
+ 'name', [baseClass].[Name],
96515
+ 'schemaItemType', 'RelationshipClass',
96516
+ 'modifier', ${modifier("baseClass")},
96517
+ 'label', [baseClass].[DisplayLabel],
96518
+ 'description', [baseClass].[Description],
96519
+ 'strength', ${strength("baseClass")},
96520
+ 'strengthDirection', ${strengthDirection("baseClass")}
96521
+ )))
96522
+ FROM
96523
+ [meta].[ECClassDef] [baseClass]
96524
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96525
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96526
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96527
+ )
96528
+ ) AS [item]
96529
+ FROM [meta].[ECClassDef] [class]
96530
+ WHERE [class].[Type] = 1
96531
+ `;
96532
+ const entityQuery = `
96533
+ SELECT
96534
+ [Schema].[Id] AS [SchemaId],
96535
+ json_object(
96536
+ 'name', [class].[Name],
96537
+ 'schemaItemType', 'EntityClass',
96538
+ 'modifier', ${modifier("class")},
96539
+ 'label', [class].[DisplayLabel],
96540
+ 'description', [class].[Description],
96541
+ 'baseClasses', (
96542
+ SELECT
96543
+ json_group_array(json(json_object(
96544
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96545
+ 'name', [baseClass].[Name],
96546
+ 'schemaItemType', 'EntityClass',
96547
+ 'modifier', ${modifier("baseClass")},
96548
+ 'label', [baseClass].[DisplayLabel],
96549
+ 'description', [baseClass].[Description]
96550
+ )))
96551
+ FROM
96552
+ [meta].[ECClassDef] [baseClass]
96553
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96554
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96555
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96556
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
96557
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96558
+ ),
96559
+ 'mixins', (
96560
+ SELECT
96561
+ json_group_array(json(json_object(
96562
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96563
+ 'name', [baseClass].[Name],
96564
+ 'schemaItemType', 'Mixin',
96565
+ 'modifier', ${modifier("baseClass")},
96566
+ 'label', [baseClass].[DisplayLabel],
96567
+ 'description', [baseClass].[Description],
96568
+ 'appliesTo', (
96569
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96570
+ FROM [AppliesToCTE] [atCTE]
96571
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
96572
+ ),
96573
+ 'baseClasses', (
96574
+ SELECT
96575
+ json_group_array(json(json_object(
96576
+ 'schema', ec_classname([mixinBaseClass].[ECInstanceId], 's'),
96577
+ 'name', [mixinBaseClass].[Name],
96578
+ 'schemaItemType', 'Mixin',
96579
+ 'modifier', ${modifier("mixinBaseClass")},
96580
+ 'label', [mixinBaseClass].[DisplayLabel],
96581
+ 'description', [mixinBaseClass].[Description],
96582
+ 'appliesTo', (
96583
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96584
+ FROM [AppliesToCTE] [atCTE]
96585
+ WHERE [atCTE].[AppliesToId] = [mixinBaseClass].[ECInstanceId]
96586
+ )
96587
+ )))
96588
+ FROM
96589
+ [meta].[ECClassDef] [mixinBaseClass]
96590
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [mixinBaseClassMap]
96591
+ ON [mixinBaseClassMap].[TargetECInstanceId] = [mixinBaseClass].[ECInstanceId]
96592
+ WHERE [mixinBaseClassMap].[SourceECInstanceId] = [baseClass].[ECInstanceId]
96593
+ )
96594
+ )))
96595
+ FROM
96596
+ [meta].[ECClassDef] [baseClass]
96597
+ INNER JOIN [meta].[ClassHasBaseClasses] [baseClassMap]
96598
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96599
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96600
+ AND EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [baseClass].[ECInstanceId] = [ca].[Class].[Id]
96601
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96602
+ )
96603
+ ) AS [item]
96604
+ FROM [meta].[ECClassDef] [class]
96605
+ WHERE [class].[Type] = 0
96606
+ AND NOT EXISTS(SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
96607
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96608
+ `;
96609
+ const mixinQuery = `
96610
+ SELECT
96611
+ [Schema].[Id] AS [SchemaId],
96612
+ json_object(
96613
+ 'name', [class].[Name],
96614
+ 'schemaItemType', 'Mixin',
96615
+ 'modifier', ${modifier("class")},
96616
+ 'label', [class].[DisplayLabel],
96617
+ 'description', [class].[Description],
96618
+ 'appliesTo', (
96619
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96620
+ FROM [AppliesToCTE] [atCTE]
96621
+ WHERE [atCTE].[AppliesToId] = [class].[ECInstanceId]
96622
+ ),
96623
+ 'baseClasses', (
96624
+ SELECT
96625
+ json_group_array(json(json_object(
96626
+ 'schema', ec_classname([baseClass].[ECInstanceId], 's'),
96627
+ 'name', [baseClass].[Name],
96628
+ 'schemaItemType', 'Mixin',
96629
+ 'modifier', ${modifier("baseClass")},
96630
+ 'label', [baseClass].[DisplayLabel],
96631
+ 'description', [baseClass].[Description],
96632
+ 'appliesTo', (
96633
+ SELECT IIF(instr([atCTE].[AppliesTo], ':') > 1, ec_classname(ec_classId([atCTE].[AppliesTo]), 's.c'), CONCAT([atCTE].[AppliesToSchema], '.', [atCTE].[AppliesTo]))
96634
+ FROM [AppliesToCTE] [atCTE]
96635
+ WHERE [atCTE].[AppliesToId] = [baseClass].[ECInstanceId]
96636
+ )
96637
+ )))
96638
+ FROM
96639
+ [meta].[ECClassDef] [baseClass]
96640
+ INNER JOIN [meta].[ClassHasAllBaseClasses] [baseClassMap]
96641
+ ON [baseClassMap].[TargetECInstanceId] = [baseclass].[ECInstanceId]
96642
+ WHERE [baseClassMap].[SourceECInstanceId] = [class].[ECInstanceId]
96643
+ )
96644
+ ) AS [item]
96645
+ FROM [meta].[ECClassDef] [class]
96646
+ WHERE [class].[Type] = 0 AND EXISTS (SELECT 1 FROM [meta].[ClassCustomAttribute] [ca] WHERE [class].[ECInstanceId] = [ca].[Class].[Id]
96647
+ AND [ca].[CustomAttributeClass].[Id] Is ([CoreCA].[IsMixin]))
96648
+ `;
96649
+ const withSchemaItems = `
96650
+ SchemaItems AS (
96651
+ ${customAttributeQuery}
96652
+ UNION ALL
96653
+ ${structQuery}
96654
+ UNION ALL
96655
+ ${relationshipQuery}
96656
+ UNION ALL
96657
+ ${entityQuery}
96658
+ UNION ALL
96659
+ ${mixinQuery}
96660
+ UNION ALL
96661
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.enumeration()}
96662
+ UNION ALL
96663
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.kindOfQuantity()}
96664
+ UNION ALL
96665
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.propertyCategory()}
96666
+ UNION ALL
96667
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unit()}
96668
+ UNION ALL
96669
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.invertedUnit()}
96670
+ UNION ALL
96671
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.constant()}
96672
+ UNION ALL
96673
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.phenomenon()}
96674
+ UNION ALL
96675
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.unitSystem()}
96676
+ UNION ALL
96677
+ ${_SchemaItemQueries__WEBPACK_IMPORTED_MODULE_0__.SchemaItemQueries.format()}
96678
+ )
96679
+ `;
96680
+ const schemaStubQuery = `
96681
+ WITH
96682
+ ${withSchemaReferences},
96683
+ ${withAppliesTo},
96684
+ ${withSchemaItems}
96685
+ SELECT
96686
+ [Name] as [name],
96687
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
96688
+ [Alias] as [alias],
96689
+ [DisplayLabel] as [displayLabel],
96690
+ [Description] as [description],
96691
+ (
96692
+ SELECT
96693
+ json_group_array([schemaReferences].[fullName])
96694
+ FROM
96695
+ [SchemaReferences] [schemaReferences]
96696
+ WHERE
96697
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
96698
+ ) AS [references],
96699
+ (
96700
+ SELECT
96701
+ json_group_array(json([items].[item]))
96702
+ FROM
96703
+ [SchemaItems] [items]
96704
+ WHERE
96705
+ [items].[SchemaId] = [schemaDef].[ECInstanceId]
96706
+ ) AS [items]
96707
+ FROM
96708
+ [meta].[ECSchemaDef] [schemaDef]
96709
+ WHERE [Name] = :schemaName
96710
+ `;
96711
+ const schemaInfoQuery = `
96712
+ WITH
96713
+ ${withSchemaReferences}
96714
+ SELECT
96715
+ [Name] as [name],
96716
+ CONCAT('',[VersionMajor],'.',[VersionWrite],'.',[VersionMinor]) AS [version],
96717
+ [Alias] as [alias],
96718
+ (
96719
+ SELECT
96720
+ json_group_array([schemaReferences].[fullName])
96721
+ FROM
96722
+ [SchemaReferences] [schemaReferences]
96723
+ WHERE
96724
+ [schemaReferences].[SchemaId] = [schemaDef].[ECInstanceId]
96725
+ ) AS [references]
96726
+ FROM
96727
+ [meta].[ECSchemaDef] [schemaDef]
96728
+ `;
96729
+ /**
96730
+ * Partial Schema queries.
96731
+ * @internal
96732
+ */
96733
+ const ecsqlQueries = {
96734
+ schemaStubQuery,
96735
+ schemaInfoQuery,
96736
+ };
96737
+
96738
+
94267
96739
  /***/ }),
94268
96740
 
94269
96741
  /***/ "../../core/ecschema-metadata/lib/esm/Interfaces.js":
@@ -98453,6 +100925,7 @@ class Schema {
98453
100925
  _customAttributes;
98454
100926
  _originalECSpecMajorVersion;
98455
100927
  _originalECSpecMinorVersion;
100928
+ _loadingController;
98456
100929
  /** @internal */
98457
100930
  constructor(context, nameOrKey, alias, readVer, writeVer, minorVer) {
98458
100931
  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 +100991,14 @@ class Schema {
98518
100991
  get schema() { return this; }
98519
100992
  /** Returns the schema context this schema is within. */
98520
100993
  get context() { return this._context; }
100994
+ /**
100995
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
100996
+ * loaded incrementally.
100997
+ * @internal
100998
+ */
100999
+ get loadingController() {
101000
+ return this._loadingController;
101001
+ }
98521
101002
  /**
98522
101003
  * Returns a SchemaItemKey given the item name and the schema it belongs to
98523
101004
  * @param fullName fully qualified name {Schema name}.{Item Name}
@@ -99143,6 +101624,10 @@ class Schema {
99143
101624
  }
99144
101625
  this._alias = alias;
99145
101626
  }
101627
+ /** @internal */
101628
+ setLoadingController(controller) {
101629
+ this._loadingController = controller;
101630
+ }
99146
101631
  }
99147
101632
  /**
99148
101633
  * Hackish approach that works like a "friend class" so we can access protected members without making them public.
@@ -99196,6 +101681,7 @@ class SchemaItem {
99196
101681
  _key;
99197
101682
  _description;
99198
101683
  _label;
101684
+ _loadingController;
99199
101685
  /** @internal */
99200
101686
  constructor(schema, name) {
99201
101687
  this._key = new _SchemaKey__WEBPACK_IMPORTED_MODULE_3__.SchemaItemKey(name, schema.schemaKey);
@@ -99206,6 +101692,14 @@ class SchemaItem {
99206
101692
  get key() { return this._key; }
99207
101693
  get label() { return this._label; }
99208
101694
  get description() { return this._description; }
101695
+ /**
101696
+ * Returns the SchemaLoadingController for this Schema. This would only be set if the schema is
101697
+ * loaded incrementally.
101698
+ * @internal
101699
+ */
101700
+ get loadingController() {
101701
+ return this._loadingController;
101702
+ }
99209
101703
  // 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
101704
  /**
99211
101705
  * Save this SchemaItem's properties to an object for serializing to JSON.
@@ -99311,6 +101805,10 @@ class SchemaItem {
99311
101805
  setDescription(description) {
99312
101806
  this._description = description;
99313
101807
  }
101808
+ /** @internal */
101809
+ setLoadingController(controller) {
101810
+ this._loadingController = controller;
101811
+ }
99314
101812
  }
99315
101813
 
99316
101814
 
@@ -101465,6 +103963,7 @@ __webpack_require__.r(__webpack_exports__);
101465
103963
  /* harmony export */ ECSchemaError: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaError),
101466
103964
  /* harmony export */ ECSchemaNamespaceUris: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECSchemaNamespaceUris),
101467
103965
  /* harmony export */ ECSchemaStatus: () => (/* reexport safe */ _Exception__WEBPACK_IMPORTED_MODULE_9__.ECSchemaStatus),
103966
+ /* harmony export */ ECSqlSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__.ECSqlSchemaLocater),
101468
103967
  /* harmony export */ ECStringConstants: () => (/* reexport safe */ _Constants__WEBPACK_IMPORTED_MODULE_0__.ECStringConstants),
101469
103968
  /* harmony export */ ECVersion: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.ECVersion),
101470
103969
  /* harmony export */ EntityClass: () => (/* reexport safe */ _Metadata_EntityClass__WEBPACK_IMPORTED_MODULE_14__.EntityClass),
@@ -101472,6 +103971,7 @@ __webpack_require__.r(__webpack_exports__);
101472
103971
  /* harmony export */ EnumerationArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationArrayProperty),
101473
103972
  /* harmony export */ EnumerationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.EnumerationProperty),
101474
103973
  /* harmony export */ Format: () => (/* reexport safe */ _Metadata_Format__WEBPACK_IMPORTED_MODULE_16__.Format),
103974
+ /* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
101475
103975
  /* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
101476
103976
  /* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
101477
103977
  /* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
@@ -101494,7 +103994,7 @@ __webpack_require__.r(__webpack_exports__);
101494
103994
  /* harmony export */ SchemaCache: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaCache),
101495
103995
  /* harmony export */ SchemaContext: () => (/* reexport safe */ _Context__WEBPACK_IMPORTED_MODULE_1__.SchemaContext),
101496
103996
  /* harmony export */ SchemaFormatsProvider: () => (/* reexport safe */ _SchemaFormatsProvider__WEBPACK_IMPORTED_MODULE_38__.SchemaFormatsProvider),
101497
- /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_39__.SchemaGraph),
103997
+ /* harmony export */ SchemaGraph: () => (/* reexport safe */ _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__.SchemaGraph),
101498
103998
  /* harmony export */ SchemaGraphUtil: () => (/* reexport safe */ _Deserialization_SchemaGraphUtil__WEBPACK_IMPORTED_MODULE_3__.SchemaGraphUtil),
101499
103999
  /* harmony export */ SchemaItem: () => (/* reexport safe */ _Metadata_SchemaItem__WEBPACK_IMPORTED_MODULE_26__.SchemaItem),
101500
104000
  /* harmony export */ SchemaItemKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaItemKey),
@@ -101575,7 +104075,9 @@ __webpack_require__.r(__webpack_exports__);
101575
104075
  /* harmony import */ var _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Validation/SchemaWalker */ "../../core/ecschema-metadata/lib/esm/Validation/SchemaWalker.js");
101576
104076
  /* harmony import */ var _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(/*! ./SchemaPartVisitorDelegate */ "../../core/ecschema-metadata/lib/esm/SchemaPartVisitorDelegate.js");
101577
104077
  /* 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");
104078
+ /* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
104079
+ /* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
104080
+ /* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
101579
104081
  /*---------------------------------------------------------------------------------------------
101580
104082
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
101581
104083
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -101617,6 +104119,8 @@ __webpack_require__.r(__webpack_exports__);
101617
104119
 
101618
104120
 
101619
104121
 
104122
+
104123
+
101620
104124
 
101621
104125
 
101622
104126
 
@@ -101759,6 +104263,81 @@ class SchemaGraph {
101759
104263
  }
101760
104264
 
101761
104265
 
104266
+ /***/ }),
104267
+
104268
+ /***/ "../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js":
104269
+ /*!*****************************************************************************!*\
104270
+ !*** ../../core/ecschema-metadata/lib/esm/utils/SchemaLoadingController.js ***!
104271
+ \*****************************************************************************/
104272
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
104273
+
104274
+ "use strict";
104275
+ __webpack_require__.r(__webpack_exports__);
104276
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
104277
+ /* harmony export */ SchemaLoadingController: () => (/* binding */ SchemaLoadingController)
104278
+ /* harmony export */ });
104279
+ /*---------------------------------------------------------------------------------------------
104280
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
104281
+ * See LICENSE.md in the project root for license terms and full copyright notice.
104282
+ *--------------------------------------------------------------------------------------------*/
104283
+ /**
104284
+ * Assists in tracking the loading progress of Schemas and SchemaItems. An instance of this
104285
+ * class is set in Schema and SchemaItem instances.
104286
+ * @internal
104287
+ */
104288
+ class SchemaLoadingController {
104289
+ _complete;
104290
+ _inProgress;
104291
+ _promise;
104292
+ /**
104293
+ * Indicates of the Schema or SchemaItem has been fully loaded.
104294
+ */
104295
+ get isComplete() {
104296
+ return this._complete;
104297
+ }
104298
+ /**
104299
+ * Marks that a Schema or SchemaItem has been fully loaded.
104300
+ */
104301
+ set isComplete(value) {
104302
+ this._complete = value;
104303
+ }
104304
+ /**
104305
+ * Indicates that the loading of a Schema or SchemaItem is still in progress
104306
+ */
104307
+ get inProgress() {
104308
+ return this._inProgress;
104309
+ }
104310
+ /**
104311
+ * Initializes a new SchemaLoadingController instance.
104312
+ */
104313
+ constructor() {
104314
+ this._complete = false;
104315
+ this._inProgress = false;
104316
+ }
104317
+ /**
104318
+ * Call this method when starting to load a Schema or SchemaItem
104319
+ * @param promise The promise used to update the controller state when the promise is resolved.
104320
+ */
104321
+ start(promise) {
104322
+ this._inProgress = true;
104323
+ void promise.then(() => {
104324
+ this._complete = true;
104325
+ this._inProgress = false;
104326
+ });
104327
+ this._promise = promise;
104328
+ }
104329
+ /**
104330
+ * Waits on the Promise given in SchemaLoadingController.start().
104331
+ * @returns A Promised that can be awaited while the Schema or SchemaItem is being loaded.
104332
+ */
104333
+ async wait() {
104334
+ if (!this._promise)
104335
+ throw new Error("LoadingController 'start' must be called before 'wait'");
104336
+ return this._promise;
104337
+ }
104338
+ }
104339
+
104340
+
101762
104341
  /***/ }),
101763
104342
 
101764
104343
  /***/ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js":
@@ -101907,6 +104486,74 @@ class ECSchemaRpcLocater {
101907
104486
  }
101908
104487
 
101909
104488
 
104489
+ /***/ }),
104490
+
104491
+ /***/ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js":
104492
+ /*!*****************************************************************************!*\
104493
+ !*** ../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js ***!
104494
+ \*****************************************************************************/
104495
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
104496
+
104497
+ "use strict";
104498
+ __webpack_require__.r(__webpack_exports__);
104499
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
104500
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* binding */ RpcIncrementalSchemaLocater)
104501
+ /* harmony export */ });
104502
+ /* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
104503
+ /* harmony import */ var _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/ecschema-metadata */ "../../core/ecschema-metadata/lib/esm/ecschema-metadata.js");
104504
+ /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
104505
+ /*---------------------------------------------------------------------------------------------
104506
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
104507
+ * See LICENSE.md in the project root for license terms and full copyright notice.
104508
+ *--------------------------------------------------------------------------------------------*/
104509
+
104510
+
104511
+
104512
+ /**
104513
+ * A [[ECSqlSchemaLocater]]($ecschema-metadata) implementation that uses the ECSchema RPC interfaces to load schemas incrementally.
104514
+ * @beta
104515
+ */
104516
+ class RpcIncrementalSchemaLocater extends _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_1__.ECSqlSchemaLocater {
104517
+ _iModelProps;
104518
+ /**
104519
+ * Initializes a new instance of the RpcIncrementalSchemaLocater class.
104520
+ */
104521
+ constructor(iModelProps, options) {
104522
+ super(options);
104523
+ this._iModelProps = iModelProps;
104524
+ }
104525
+ /**
104526
+ * Executes the given ECSql query and returns the resulting rows.
104527
+ * @param query The ECSql query to execute.
104528
+ * @param options Optional arguments to control the query result.
104529
+ * @returns A promise that resolves to the resulting rows.
104530
+ */
104531
+ async executeQuery(query, options) {
104532
+ const ecSqlQueryClient = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.IModelReadRpcInterface.getClient();
104533
+ const queryExecutor = {
104534
+ execute: async (request) => ecSqlQueryClient.queryRows(this._iModelProps, request),
104535
+ };
104536
+ const queryOptions = {
104537
+ limit: { count: options?.limit },
104538
+ rowFormat: _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryRowFormat.UseECSqlPropertyNames,
104539
+ };
104540
+ const queryParameters = options && options.parameters ? _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.QueryBinder.from(options.parameters) : undefined;
104541
+ const queryReader = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ECSqlReader(queryExecutor, query, queryParameters, queryOptions);
104542
+ return queryReader.toArray();
104543
+ }
104544
+ /**
104545
+ * Gets the [[SchemaProps]]($ecschema-metadata) for the given [[SchemaKey]]($ecschema-metadata).
104546
+ * This is the full schema json with all elements that are defined in the schema.
104547
+ * @param schemaKey The schema key of the schema to be resolved.
104548
+ */
104549
+ async getSchemaProps(schemaKey) {
104550
+ const rpcSchemaClient = _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_2__.ECSchemaRpcInterface.getClient();
104551
+ return rpcSchemaClient.getSchemaJSON(this._iModelProps, schemaKey.name);
104552
+ }
104553
+ ;
104554
+ }
104555
+
104556
+
101910
104557
  /***/ }),
101911
104558
 
101912
104559
  /***/ "../../core/ecschema-rpc/common/lib/esm/ecschema-rpc-interface.js":
@@ -101919,10 +104566,12 @@ class ECSchemaRpcLocater {
101919
104566
  __webpack_require__.r(__webpack_exports__);
101920
104567
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
101921
104568
  /* harmony export */ ECSchemaRpcInterface: () => (/* reexport safe */ _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__.ECSchemaRpcInterface),
101922
- /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater)
104569
+ /* harmony export */ ECSchemaRpcLocater: () => (/* reexport safe */ _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__.ECSchemaRpcLocater),
104570
+ /* harmony export */ RpcIncrementalSchemaLocater: () => (/* reexport safe */ _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__.RpcIncrementalSchemaLocater)
101923
104571
  /* harmony export */ });
101924
104572
  /* harmony import */ var _ECSchemaRpcInterface__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ECSchemaRpcInterface */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcInterface.js");
101925
104573
  /* harmony import */ var _ECSchemaRpcLocater__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ECSchemaRpcLocater */ "../../core/ecschema-rpc/common/lib/esm/ECSchemaRpcLocater.js");
104574
+ /* harmony import */ var _RpcIncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./RpcIncrementalSchemaLocater */ "../../core/ecschema-rpc/common/lib/esm/RpcIncrementalSchemaLocater.js");
101926
104575
  /*---------------------------------------------------------------------------------------------
101927
104576
  * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
101928
104577
  * See LICENSE.md in the project root for license terms and full copyright notice.
@@ -101931,6 +104580,7 @@ __webpack_require__.r(__webpack_exports__);
101931
104580
 
101932
104581
 
101933
104582
 
104583
+
101934
104584
  /***/ }),
101935
104585
 
101936
104586
  /***/ "../../core/frontend/lib/esm/AccuDraw.js":
@@ -328419,7 +331069,7 @@ class QuantityConstants {
328419
331069
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
328420
331070
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = ",";
328421
331071
  const matches = (12345.6789).toLocaleString().match(/12(.*)345/);
328422
- if (matches && matches.length > 0)
331072
+ if (matches && matches.length > 1 && matches[1] !== "")
328423
331073
  QuantityConstants._LOCALE_THOUSAND_SEPARATOR = matches[1];
328424
331074
  return QuantityConstants._LOCALE_THOUSAND_SEPARATOR;
328425
331075
  }
@@ -332205,7 +334855,7 @@ class TestContext {
332205
334855
  this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
332206
334856
  const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
332207
334857
  await core_frontend_1.NoRenderApp.startup({
332208
- applicationVersion: "5.1.0-dev.58",
334858
+ applicationVersion: "5.1.0-dev.60",
332209
334859
  applicationId: this.settings.gprid,
332210
334860
  authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
332211
334861
  hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
@@ -357292,7 +359942,7 @@ var loadLanguages = instance.loadLanguages;
357292
359942
  /***/ ((module) => {
357293
359943
 
357294
359944
  "use strict";
357295
- module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.1.0-dev.58","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"}}');
359945
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.1.0-dev.60","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"}}');
357296
359946
 
357297
359947
  /***/ }),
357298
359948