@itwin/rpcinterface-full-stack-tests 4.0.0-dev.103 → 4.0.0-dev.105

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.
@@ -61828,40 +61828,82 @@ exports.ECStringConstants = ECStringConstants;
61828
61828
  * See LICENSE.md in the project root for license terms and full copyright notice.
61829
61829
  *--------------------------------------------------------------------------------------------*/
61830
61830
  Object.defineProperty(exports, "__esModule", ({ value: true }));
61831
- exports.SchemaContext = exports.SchemaCache = exports.SchemaMap = void 0;
61831
+ exports.SchemaContext = exports.SchemaCache = void 0;
61832
61832
  const ECObjects_1 = __webpack_require__(/*! ./ECObjects */ "../../core/ecschema-metadata/lib/cjs/ECObjects.js");
61833
61833
  const Exception_1 = __webpack_require__(/*! ./Exception */ "../../core/ecschema-metadata/lib/cjs/Exception.js");
61834
61834
  /**
61835
- * @beta
61835
+ * @internal
61836
61836
  */
61837
61837
  class SchemaMap extends Array {
61838
61838
  }
61839
- exports.SchemaMap = SchemaMap;
61840
61839
  /**
61841
- * @beta
61840
+ * @internal
61842
61841
  */
61843
61842
  class SchemaCache {
61844
61843
  constructor() {
61845
61844
  this._schema = new SchemaMap();
61846
61845
  }
61847
61846
  get count() { return this._schema.length; }
61847
+ loadedSchemaExists(schemaKey) {
61848
+ return undefined !== this._schema.find((entry) => entry.schemaInfo.schemaKey.matches(schemaKey, ECObjects_1.SchemaMatchType.Latest) && !entry.schemaPromise);
61849
+ }
61850
+ schemaPromiseExists(schemaKey) {
61851
+ return undefined !== this._schema.find((entry) => entry.schemaInfo.schemaKey.matches(schemaKey, ECObjects_1.SchemaMatchType.Latest) && undefined !== entry.schemaPromise);
61852
+ }
61853
+ findEntry(schemaKey, matchType) {
61854
+ return this._schema.find((entry) => entry.schemaInfo.schemaKey.matches(schemaKey, matchType));
61855
+ }
61856
+ removeSchemaPromise(schemaKey) {
61857
+ const entry = this.findEntry(schemaKey, ECObjects_1.SchemaMatchType.Latest);
61858
+ if (entry)
61859
+ entry.schemaPromise = undefined;
61860
+ }
61861
+ removeEntry(schemaKey) {
61862
+ this._schema = this._schema.filter((entry) => !entry.schemaInfo.schemaKey.matches(schemaKey));
61863
+ }
61864
+ /**
61865
+ * Returns true if the schema exists in either the schema cache or the promise cache. SchemaMatchType.Latest used.
61866
+ * @param schemaKey The key to search for.
61867
+ */
61868
+ schemaExists(schemaKey) {
61869
+ return this.loadedSchemaExists(schemaKey) || this.schemaPromiseExists(schemaKey);
61870
+ }
61871
+ /**
61872
+ * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.
61873
+ * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache
61874
+ * @param schemaInfo An object with the schema key for the schema being loaded and it's references
61875
+ * @param schema The partially loaded schema that the promise will fulfill
61876
+ * @param schemaPromise The schema promise to add to the cache.
61877
+ */
61878
+ async addSchemaPromise(schemaInfo, schema, schemaPromise) {
61879
+ if (this.schemaExists(schemaInfo.schemaKey))
61880
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schemaPromise.toString()}, already exists within this cache.`);
61881
+ this._schema.push({ schemaInfo, schema, schemaPromise });
61882
+ // This promise is cached and will be awaited when the user requests the full schema.
61883
+ // If the promise competes successfully before the user requests the schema it will be removed from the cache
61884
+ // If it fails it will remain in the cache until the user awaits it and handles the error
61885
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
61886
+ schemaPromise.then(() => {
61887
+ this.removeSchemaPromise(schemaInfo.schemaKey);
61888
+ });
61889
+ }
61848
61890
  /**
61849
61891
  * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
61850
61892
  * @param schema The schema to add to the cache.
61851
61893
  */
61852
61894
  async addSchema(schema) {
61853
- if (await this.getSchema(schema.schemaKey))
61895
+ if (this.schemaExists(schema.schemaKey))
61854
61896
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
61855
- this._schema.push(schema);
61897
+ this._schema.push({ schemaInfo: schema, schema });
61856
61898
  }
61857
61899
  /**
61858
61900
  * Adds a schema to the cache. Does not allow for duplicate schemas, checks using SchemaMatchType.Latest.
61859
61901
  * @param schema The schema to add to the cache.
61860
61902
  */
61861
61903
  addSchemaSync(schema) {
61862
- if (this.getSchemaSync(schema.schemaKey))
61904
+ if (this.schemaExists(schema.schemaKey))
61863
61905
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.DuplicateSchema, `The schema, ${schema.schemaKey.toString()}, already exists within this cache.`);
61864
- this._schema.push(schema);
61906
+ this._schema.push({ schemaInfo: schema, schema });
61865
61907
  }
61866
61908
  /**
61867
61909
  * Gets the schema which matches the provided SchemaKey.
@@ -61871,46 +61913,69 @@ class SchemaCache {
61871
61913
  async getSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
61872
61914
  if (this.count === 0)
61873
61915
  return undefined;
61874
- const findFunc = (schema) => {
61875
- return schema.schemaKey.matches(schemaKey, matchType);
61876
- };
61877
- const foundSchema = this._schema.find(findFunc);
61878
- if (!foundSchema)
61916
+ const entry = this.findEntry(schemaKey, matchType);
61917
+ if (!entry)
61879
61918
  return undefined;
61880
- return foundSchema;
61919
+ if (entry.schemaPromise) {
61920
+ try {
61921
+ const schema = await entry.schemaPromise;
61922
+ return schema;
61923
+ }
61924
+ catch (e) {
61925
+ this.removeEntry(schemaKey);
61926
+ throw e;
61927
+ }
61928
+ }
61929
+ return entry.schema;
61881
61930
  }
61882
61931
  /**
61883
- *
61884
- * @param schemaKey
61885
- * @param matchType
61932
+ * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
61933
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
61934
+ * @param matchType The match type to use when locating the schema
61935
+ */
61936
+ async getSchemaInfo(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
61937
+ if (this.count === 0)
61938
+ return undefined;
61939
+ const entry = this.findEntry(schemaKey, matchType);
61940
+ if (entry)
61941
+ return entry.schemaInfo;
61942
+ return undefined;
61943
+ }
61944
+ /**
61945
+ * Gets the schema which matches the provided SchemaKey. If the schema is partially loaded an exception will be thrown.
61946
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
61947
+ * @param matchType The match type to use when locating the schema
61886
61948
  */
61887
61949
  getSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
61888
61950
  if (this.count === 0)
61889
61951
  return undefined;
61890
- const findFunc = (schema) => {
61891
- return schema.schemaKey.matches(schemaKey, matchType);
61892
- };
61893
- const foundSchema = this._schema.find(findFunc);
61894
- if (!foundSchema)
61895
- return foundSchema;
61896
- return foundSchema;
61952
+ const entry = this.findEntry(schemaKey, matchType);
61953
+ if (entry) {
61954
+ if (entry.schemaPromise) {
61955
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLoadSchema, `The Schema ${schemaKey.toString()} is partially loaded so cannot be loaded synchronously.`);
61956
+ }
61957
+ return entry.schema;
61958
+ }
61959
+ return undefined;
61897
61960
  }
61898
61961
  /**
61899
- * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema
61962
+ * Generator function that can iterate through each schema in _schema SchemaMap and items for each Schema.
61963
+ * Does not include schema items from schemas that are not completely loaded yet.
61900
61964
  */
61901
61965
  *getSchemaItems() {
61902
- for (const schema of this._schema) {
61903
- for (const schemaItem of schema.getItems()) {
61966
+ for (const entry of this._schema) {
61967
+ for (const schemaItem of entry.schema.getItems()) {
61904
61968
  yield schemaItem;
61905
61969
  }
61906
61970
  }
61907
61971
  }
61908
61972
  /**
61909
61973
  * Gets all the schemas from the schema cache.
61974
+ * Does not include schemas from schemas that are not completely loaded yet.
61910
61975
  * @returns An array of Schema objects.
61911
61976
  */
61912
61977
  getAllSchemas() {
61913
- return this._schema;
61978
+ return this._schema.map((entry) => entry.schema);
61914
61979
  }
61915
61980
  }
61916
61981
  exports.SchemaCache = SchemaCache;
@@ -61932,7 +61997,7 @@ class SchemaContext {
61932
61997
  this._locaters.push(locater);
61933
61998
  }
61934
61999
  /**
61935
- * Adds the schema to this context
62000
+ * Adds the schema to this context. Use addSchemaPromise instead when asynchronously loading schemas.
61936
62001
  * @param schema The schema to add to this context
61937
62002
  */
61938
62003
  async addSchema(schema) {
@@ -61948,6 +62013,7 @@ class SchemaContext {
61948
62013
  /**
61949
62014
  * Adds the given SchemaItem to the the SchemaContext by locating the schema, with the best match of SchemaMatchType.Exact, and
61950
62015
  * @param schemaItem The SchemaItem to add
62016
+ * @deprecated in 4.0 use ecschema-editing package
61951
62017
  */
61952
62018
  async addSchemaItem(schemaItem) {
61953
62019
  const schema = await this.getSchema(schemaItem.key.schemaKey, ECObjects_1.SchemaMatchType.Exact);
@@ -61955,6 +62021,24 @@ class SchemaContext {
61955
62021
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Unable to add the schema item ${schemaItem.name} to the schema ${schemaItem.key.schemaKey.toString()} because the schema could not be located.`);
61956
62022
  schema.addItem(schemaItem);
61957
62023
  }
62024
+ /**
62025
+ * Returns true if the schema is already in the context. SchemaMatchType.Latest is used to find a match.
62026
+ * @param schemaKey
62027
+ */
62028
+ schemaExists(schemaKey) {
62029
+ return this._knownSchemas.schemaExists(schemaKey);
62030
+ }
62031
+ /**
62032
+ * Adds a promise to load the schema to the cache. Does not allow for duplicate schemas in the cache of schemas or cache of promises, checks using SchemaMatchType.Latest.
62033
+ * When the promise completes the schema will be added to the schema cache and the promise will be removed from the promise cache.
62034
+ * Use this method over addSchema when asynchronously loading schemas
62035
+ * @param schemaInfo An object with the schema key for the schema being loaded and it's references
62036
+ * @param schema The partially loaded schema that the promise will fulfill
62037
+ * @param schemaPromise The schema promise to add to the cache.
62038
+ */
62039
+ async addSchemaPromise(schemaInfo, schema, schemaPromise) {
62040
+ return this._knownSchemas.addSchemaPromise(schemaInfo, schema, schemaPromise);
62041
+ }
61958
62042
  /**
61959
62043
  *
61960
62044
  * @param schemaKey
@@ -61968,6 +62052,20 @@ class SchemaContext {
61968
62052
  }
61969
62053
  return undefined;
61970
62054
  }
62055
+ /**
62056
+ * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
62057
+ * The fully loaded schema can be gotten later from the context using the getCachedSchema method.
62058
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
62059
+ * @param matchType The match type to use when locating the schema
62060
+ */
62061
+ async getSchemaInfo(schemaKey, matchType) {
62062
+ for (const locater of this._locaters) {
62063
+ const schemaInfo = await locater.getSchemaInfo(schemaKey, matchType, this);
62064
+ if (undefined !== schemaInfo)
62065
+ return schemaInfo;
62066
+ }
62067
+ return undefined;
62068
+ }
61971
62069
  /**
61972
62070
  *
61973
62071
  * @param schemaKey
@@ -61983,42 +62081,62 @@ class SchemaContext {
61983
62081
  }
61984
62082
  /**
61985
62083
  * Attempts to get a Schema from the context's cache.
62084
+ * Will await a partially loaded schema then return when it is completely loaded.
61986
62085
  * @param schemaKey The SchemaKey to identify the Schema.
61987
62086
  * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
61988
62087
  * @internal
61989
62088
  */
61990
62089
  async getCachedSchema(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
61991
- return this.getCachedSchemaSync(schemaKey, matchType);
62090
+ return this._knownSchemas.getSchema(schemaKey, matchType);
61992
62091
  }
61993
62092
  /**
61994
62093
  * Attempts to get a Schema from the context's cache.
62094
+ * Will return undefined if the cached schema is partially loaded. Use the async method to await partially loaded schemas.
61995
62095
  * @param schemaKey The SchemaKey to identify the Schema.
61996
62096
  * @param matchType The SchemaMatch type to use. Default is SchemaMatchType.Latest.
61997
62097
  * @internal
61998
62098
  */
61999
62099
  getCachedSchemaSync(schemaKey, matchType = ECObjects_1.SchemaMatchType.Latest) {
62000
- const schema = this._knownSchemas.getSchemaSync(schemaKey, matchType);
62001
- return schema;
62100
+ return this._knownSchemas.getSchemaSync(schemaKey, matchType);
62002
62101
  }
62102
+ /**
62103
+ * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
62104
+ * Will await a partially loaded schema then look in it for the requested item
62105
+ * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
62106
+ * @returns The requested schema item
62107
+ */
62003
62108
  async getSchemaItem(schemaItemKey) {
62004
62109
  const schema = await this.getSchema(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
62005
62110
  if (undefined === schema)
62006
62111
  return undefined;
62007
62112
  return schema.getItem(schemaItemKey.name);
62008
62113
  }
62114
+ /**
62115
+ * Gets the schema item from the specified schema if it exists in this [[SchemaContext]].
62116
+ * Will skip a partially loaded schema and return undefined if the item belongs to that schema. Use the async method to await partially loaded schemas.
62117
+ * @param schemaItemKey The SchemaItemKey identifying the item to return. SchemaMatchType.Latest is used to match the schema.
62118
+ * @returns The requested schema item
62119
+ */
62009
62120
  getSchemaItemSync(schemaItemKey) {
62010
62121
  const schema = this.getSchemaSync(schemaItemKey.schemaKey, ECObjects_1.SchemaMatchType.Latest);
62011
62122
  if (undefined === schema)
62012
62123
  return undefined;
62013
62124
  return schema.getItemSync(schemaItemKey.name);
62014
62125
  }
62126
+ /**
62127
+ * Iterates through the items of each schema known to the context. This includes schemas added to the
62128
+ * context using [[SchemaContext.addSchema]]. This does not include schemas that
62129
+ * can be located by an ISchemaLocater instance added to the context.
62130
+ * Does not include schema items from schemas that are not completely loaded yet.
62131
+ */
62015
62132
  getSchemaItems() {
62016
62133
  return this._knownSchemas.getSchemaItems();
62017
62134
  }
62018
62135
  /**
62019
62136
  * Gets all the Schemas known by the context. This includes schemas added to the
62020
62137
  * context using [[SchemaContext.addSchema]]. This does not include schemas that
62021
- * can be located by an ISchemaLocater instance added to the context.
62138
+ * can be located by an ISchemaLocater instance added to the context. Does not
62139
+ * include schemas that are partially loaded.
62022
62140
  * @returns An array of Schema objects.
62023
62141
  */
62024
62142
  getKnownSchemas() {
@@ -62188,11 +62306,13 @@ class SchemaReadHelper {
62188
62306
  this._parserType = parserType;
62189
62307
  }
62190
62308
  /**
62191
- * Populates the given Schema from a serialized representation.
62309
+ * Creates a complete SchemaInfo and starts parsing the schema from a serialized representation.
62310
+ * The info and schema promise will be registered with the SchemaContext. The complete schema can be retrieved by
62311
+ * calling getCachedSchema on the context.
62192
62312
  * @param schema The Schema to populate
62193
62313
  * @param rawSchema The serialized data to use to populate the Schema.
62194
62314
  */
62195
- async readSchema(schema, rawSchema) {
62315
+ async readSchemaInfo(schema, rawSchema) {
62196
62316
  // Ensure context matches schema context
62197
62317
  if (schema.context) {
62198
62318
  if (this._context !== schema.context)
@@ -62205,12 +62325,38 @@ class SchemaReadHelper {
62205
62325
  // Loads all of the properties on the Schema object
62206
62326
  await schema.fromJSON(this._parser.parseSchema());
62207
62327
  this._schema = schema;
62208
- // Need to add this schema to the context to be able to locate schemaItems within the context.
62209
- await this._context.addSchema(schema);
62210
- // Load schema references first
62211
- // Need to figure out if other schemas are present.
62328
+ const schemaInfo = { schemaKey: schema.schemaKey, references: [] };
62212
62329
  for (const reference of this._parser.getReferences()) {
62213
- await this.loadSchemaReference(reference);
62330
+ const refKey = new SchemaKey_1.SchemaKey(reference.name, SchemaKey_1.ECVersion.fromString(reference.version));
62331
+ schemaInfo.references.push({ schemaKey: refKey });
62332
+ }
62333
+ this._schemaInfo = schemaInfo;
62334
+ // Need to add this schema to the context to be able to locate schemaItems within the context.
62335
+ if (!this._context.schemaExists(schema.schemaKey)) {
62336
+ await this._context.addSchemaPromise(schemaInfo, schema, this.loadSchema(schemaInfo, schema));
62337
+ }
62338
+ return schemaInfo;
62339
+ }
62340
+ /**
62341
+ * Populates the given Schema from a serialized representation.
62342
+ * @param schema The Schema to populate
62343
+ * @param rawSchema The serialized data to use to populate the Schema.
62344
+ */
62345
+ async readSchema(schema, rawSchema) {
62346
+ if (!this._schemaInfo) {
62347
+ await this.readSchemaInfo(schema, rawSchema);
62348
+ }
62349
+ const cachedSchema = await this._context.getCachedSchema(this._schemaInfo.schemaKey, ECObjects_1.SchemaMatchType.Latest);
62350
+ if (undefined === cachedSchema)
62351
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLoadSchema, `Could not load schema ${schema.schemaKey.toString()}`);
62352
+ return cachedSchema;
62353
+ }
62354
+ /* Finish loading the rest of the schema */
62355
+ async loadSchema(schemaInfo, schema) {
62356
+ // Verify that there are no schema reference cycles, this will start schema loading by loading their headers
62357
+ (await SchemaGraph_1.SchemaGraph.generateGraph(schemaInfo, this._context)).throwIfCycles();
62358
+ for (const reference of schemaInfo.references) {
62359
+ await this.loadSchemaReference(schemaInfo, reference.schemaKey);
62214
62360
  }
62215
62361
  if (this._visitorHelper)
62216
62362
  await this._visitorHelper.visitSchema(schema, false);
@@ -62269,11 +62415,10 @@ class SchemaReadHelper {
62269
62415
  * Ensures that the schema references can be located and adds them to the schema.
62270
62416
  * @param ref The object to read the SchemaReference's props from.
62271
62417
  */
62272
- async loadSchemaReference(ref) {
62273
- const schemaKey = new SchemaKey_1.SchemaKey(ref.name, SchemaKey_1.ECVersion.fromString(ref.version));
62274
- const refSchema = await this._context.getSchema(schemaKey, ECObjects_1.SchemaMatchType.LatestWriteCompatible);
62418
+ async loadSchemaReference(schemaInfo, refKey) {
62419
+ const refSchema = await this._context.getSchema(refKey, ECObjects_1.SchemaMatchType.LatestWriteCompatible);
62275
62420
  if (undefined === refSchema)
62276
- throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema.schemaKey.name}`);
62421
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refKey.name}.${refKey.version.toString()}, of ${schemaInfo.schemaKey.name}`);
62277
62422
  await this._schema.addReference(refSchema);
62278
62423
  const results = this.validateSchemaReferences(this._schema);
62279
62424
  let errorMessage = "";
@@ -62294,6 +62439,7 @@ class SchemaReadHelper {
62294
62439
  if (!refSchema)
62295
62440
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${ref.name}.${ref.version}, of ${this._schema.schemaKey.name}`);
62296
62441
  this._schema.addReferenceSync(refSchema);
62442
+ SchemaGraph_1.SchemaGraph.generateGraphSync(this._schema).throwIfCycles();
62297
62443
  const results = this.validateSchemaReferences(this._schema);
62298
62444
  let errorMessage = "";
62299
62445
  for (const result of results) {
@@ -62322,12 +62468,6 @@ class SchemaReadHelper {
62322
62468
  aliases.set(schemaRef.alias, schemaRef);
62323
62469
  }
62324
62470
  }
62325
- const graph = new SchemaGraph_1.SchemaGraph(schema);
62326
- const cycles = graph.detectCycles();
62327
- if (cycles) {
62328
- const result = cycles.map((cycle) => `${cycle.schema.name} --> ${cycle.refSchema.name}`).join(", ");
62329
- yield `Schema '${schema.name}' has reference cycles: ${result}`;
62330
- }
62331
62471
  }
62332
62472
  /**
62333
62473
  * Given the schema item object, the anticipated type and the name a schema item is created and loaded into the schema provided.
@@ -62512,7 +62652,10 @@ class SchemaReadHelper {
62512
62652
  const isInThisSchema = (this._schema && this._schema.name.toLowerCase() === schemaName.toLowerCase());
62513
62653
  if (undefined === schemaName || 0 === schemaName.length)
62514
62654
  throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `The SchemaItem ${name} is invalid without a schema name`);
62515
- if (isInThisSchema && undefined === await this._schema.getItem(itemName)) {
62655
+ if (isInThisSchema) {
62656
+ schemaItem = await this._schema.getItem(itemName);
62657
+ if (schemaItem)
62658
+ return schemaItem;
62516
62659
  const foundItem = this._parser.findItem(itemName);
62517
62660
  if (foundItem) {
62518
62661
  schemaItem = await this.loadSchemaItem(this._schema, ...foundItem);
@@ -65586,6 +65729,7 @@ var ECObjectsStatus;
65586
65729
  ECObjectsStatus[ECObjectsStatus["InvalidSchemaComparisonArgument"] = 35077] = "InvalidSchemaComparisonArgument";
65587
65730
  ECObjectsStatus[ECObjectsStatus["InvalidSchemaAlias"] = 35078] = "InvalidSchemaAlias";
65588
65731
  ECObjectsStatus[ECObjectsStatus["InvalidSchemaKey"] = 35079] = "InvalidSchemaKey";
65732
+ ECObjectsStatus[ECObjectsStatus["UnableToLoadSchema"] = 35080] = "UnableToLoadSchema";
65589
65733
  })(ECObjectsStatus = exports.ECObjectsStatus || (exports.ECObjectsStatus = {}));
65590
65734
  /** @internal */
65591
65735
  class ECObjectsError extends core_bentley_1.BentleyError {
@@ -69211,6 +69355,9 @@ class Schema {
69211
69355
  schemaXml.appendChild(schemaMetadata);
69212
69356
  return schemaXml;
69213
69357
  }
69358
+ /**
69359
+ * Loads the schema header (name, version alias, label and description) from the input SchemaProps
69360
+ */
69214
69361
  fromJSONSync(schemaProps) {
69215
69362
  if (undefined === this._schemaKey) {
69216
69363
  const schemaName = schemaProps.name;
@@ -69236,9 +69383,22 @@ class Schema {
69236
69383
  if (undefined !== schemaProps.description)
69237
69384
  this._description = schemaProps.description;
69238
69385
  }
69386
+ /**
69387
+ * Loads the schema header (name, version alias, label and description) from the input SchemaProps
69388
+ */
69239
69389
  async fromJSON(schemaProps) {
69240
69390
  this.fromJSONSync(schemaProps);
69241
69391
  }
69392
+ /**
69393
+ * Completely loads the SchemaInfo from the input json and starts loading the entire schema. The complete schema can be retrieved from the
69394
+ * schema context using the getCachedSchema method
69395
+ */
69396
+ static async startLoadingFromJson(jsonObj, context) {
69397
+ const schema = new Schema(context);
69398
+ const reader = new Helper_1.SchemaReadHelper(JsonParser_1.JsonParser, context);
69399
+ const rawSchema = typeof jsonObj === "string" ? JSON.parse(jsonObj) : jsonObj;
69400
+ return reader.readSchemaInfo(schema, rawSchema);
69401
+ }
69242
69402
  static async fromJson(jsonObj, context) {
69243
69403
  let schema = new Schema(context);
69244
69404
  const reader = new Helper_1.SchemaReadHelper(JsonParser_1.JsonParser, context);
@@ -69246,6 +69406,9 @@ class Schema {
69246
69406
  schema = await reader.readSchema(schema, rawSchema);
69247
69407
  return schema;
69248
69408
  }
69409
+ /**
69410
+ * Completely loads the Schema from the input json. The schema is cached in the schema context.
69411
+ */
69249
69412
  static fromJsonSync(jsonObj, context) {
69250
69413
  let schema = new Schema(context);
69251
69414
  const reader = new Helper_1.SchemaReadHelper(JsonParser_1.JsonParser, context);
@@ -69771,6 +69934,14 @@ class SchemaJsonLocater {
69771
69934
  async getSchema(schemaKey, matchType, context) {
69772
69935
  return this.getSchemaSync(schemaKey, matchType, context);
69773
69936
  }
69937
+ /**
69938
+ * Gets the schema info which matches the provided SchemaKey. The schema info may be returned before the schema is fully loaded.
69939
+ * @param schemaKey The SchemaKey describing the schema to get from the cache.
69940
+ * @param matchType The match type to use when locating the schema
69941
+ */
69942
+ async getSchemaInfo(schemaKey, matchType, context) {
69943
+ return this.getSchema(schemaKey, matchType, context);
69944
+ }
69774
69945
  /** Get a schema by [SchemaKey] synchronously.
69775
69946
  * @param schemaKey The [SchemaKey] that identifies the schema.
69776
69947
  * * @param matchType The [SchemaMatchType] to used for comparing schema versions.
@@ -71267,7 +71438,7 @@ Object.defineProperty(exports, "SchemaGraph", ({ enumerable: true, get: function
71267
71438
  /*!*****************************************************************!*\
71268
71439
  !*** ../../core/ecschema-metadata/lib/cjs/utils/SchemaGraph.js ***!
71269
71440
  \*****************************************************************/
71270
- /***/ ((__unused_webpack_module, exports) => {
71441
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
71271
71442
 
71272
71443
  "use strict";
71273
71444
 
@@ -71277,22 +71448,32 @@ Object.defineProperty(exports, "SchemaGraph", ({ enumerable: true, get: function
71277
71448
  *--------------------------------------------------------------------------------------------*/
71278
71449
  Object.defineProperty(exports, "__esModule", ({ value: true }));
71279
71450
  exports.SchemaGraph = void 0;
71451
+ const ECObjects_1 = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/cjs/ECObjects.js");
71452
+ const Exception_1 = __webpack_require__(/*! ../Exception */ "../../core/ecschema-metadata/lib/cjs/Exception.js");
71280
71453
  /**
71281
71454
  * Utility class for detecting cyclic references in a Schema graph.
71282
- * @beta
71455
+ * @internal
71283
71456
  */
71284
71457
  class SchemaGraph {
71458
+ constructor() {
71459
+ this._schemas = [];
71460
+ }
71461
+ find(schemaKey) {
71462
+ return this._schemas.find((info) => info.schemaKey.matches(schemaKey, ECObjects_1.SchemaMatchType.Latest));
71463
+ }
71285
71464
  /**
71286
- * Initializes a new SchemaGraph instance.
71287
- * @param schema The schema to analyze.
71465
+ * Detected cyclic references in a schema and throw an exception if a cycle is found.
71288
71466
  */
71289
- constructor(schema) {
71290
- this._schemas = [];
71291
- this.populateGraph(schema);
71467
+ throwIfCycles() {
71468
+ const cycles = this.detectCycles();
71469
+ if (cycles) {
71470
+ const result = cycles.map((cycle) => `${cycle.schema.schemaKey.name} --> ${cycle.refSchema.schemaKey.name}`).join(", ");
71471
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.InvalidECJson, `Schema '${this._schemas[0].schemaKey.name}' has reference cycles: ${result}`);
71472
+ }
71292
71473
  }
71293
71474
  /**
71294
71475
  * Detected cyclic references in a schema.
71295
- * @returns True if a cycle is found.
71476
+ * @returns An array describing the cycle if there is a cycle or undefined if no cycles found.
71296
71477
  */
71297
71478
  detectCycles() {
71298
71479
  const visited = {};
@@ -71307,31 +71488,70 @@ class SchemaGraph {
71307
71488
  }
71308
71489
  detectCycleUtil(schema, visited, recStack, cycles) {
71309
71490
  let cycleFound = false;
71310
- if (!visited[schema.name]) {
71311
- visited[schema.name] = true;
71312
- recStack[schema.name] = true;
71313
- for (const refSchema of schema.references) {
71314
- if (!visited[refSchema.name] && this.detectCycleUtil(refSchema, visited, recStack, cycles)) {
71491
+ if (!visited[schema.schemaKey.name]) {
71492
+ visited[schema.schemaKey.name] = true;
71493
+ recStack[schema.schemaKey.name] = true;
71494
+ for (const refKey of schema.references) {
71495
+ const refSchema = this.find(refKey.schemaKey);
71496
+ if (undefined === refSchema)
71497
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLoadSchema, `Could not find the schema info for ref schema ${refKey.schemaKey.toString()} for schema ${schema.schemaKey.toString()}`);
71498
+ if (!visited[refKey.schemaKey.name] && this.detectCycleUtil(refSchema, visited, recStack, cycles)) {
71315
71499
  cycles.push({ schema, refSchema });
71316
71500
  cycleFound = true;
71317
71501
  }
71318
- else if (recStack[refSchema.name]) {
71502
+ else if (recStack[refKey.schemaKey.name]) {
71319
71503
  cycles.push({ schema, refSchema });
71320
71504
  cycleFound = true;
71321
71505
  }
71322
71506
  }
71323
71507
  }
71324
71508
  if (!cycleFound)
71325
- recStack[schema.name] = false;
71509
+ recStack[schema.schemaKey.name] = false;
71326
71510
  return cycleFound;
71327
71511
  }
71328
- populateGraph(schema) {
71329
- if (this._schemas.includes(schema))
71330
- return;
71331
- this._schemas.push(schema);
71332
- for (const refSchema of schema.references) {
71333
- this.populateGraph(refSchema);
71334
- }
71512
+ /**
71513
+ * Generates a SchemaGraph for the input schema using the context to find info on referenced schemas. Use the generateGraphSync if you have the fully loaded Schema.
71514
+ * @param schema The SchemaInfo to build the graph from
71515
+ * @param context The SchemaContext used to locate info on the referenced schemas
71516
+ * @returns A SchemaGraph that can be used to detect schema cycles
71517
+ */
71518
+ static async generateGraph(schema, context) {
71519
+ const graph = new SchemaGraph();
71520
+ const genGraph = async (s) => {
71521
+ if (graph.find(s.schemaKey))
71522
+ return;
71523
+ graph._schemas.push(s);
71524
+ for (const refSchema of s.references) {
71525
+ if (!graph.find(refSchema.schemaKey)) {
71526
+ const refInfo = await context.getSchemaInfo(refSchema.schemaKey, ECObjects_1.SchemaMatchType.LatestWriteCompatible);
71527
+ if (undefined === refInfo) {
71528
+ throw new Exception_1.ECObjectsError(Exception_1.ECObjectsStatus.UnableToLocateSchema, `Could not locate the referenced schema, ${refSchema.schemaKey.name}.${refSchema.schemaKey.version.toString()}, of ${s.schemaKey.name} when populating the graph for ${schema.schemaKey.name}`);
71529
+ }
71530
+ await genGraph(refInfo);
71531
+ }
71532
+ }
71533
+ };
71534
+ await genGraph(schema);
71535
+ return graph;
71536
+ }
71537
+ /**
71538
+ * Generates a SchemaGraph for the input schema. Use the generateGraph if you just have schema info.
71539
+ * @param schema The Schema to build the graph from.
71540
+ * @returns A SchemaGraph that can be used to detect schema cycles
71541
+ */
71542
+ static generateGraphSync(schema) {
71543
+ const graph = new SchemaGraph();
71544
+ const genGraph = (s) => {
71545
+ if (graph.find(s.schemaKey))
71546
+ return;
71547
+ graph._schemas.push(s);
71548
+ for (const refSchema of s.references) {
71549
+ if (!graph.find(refSchema.schemaKey))
71550
+ genGraph(refSchema);
71551
+ }
71552
+ };
71553
+ genGraph(schema);
71554
+ return graph;
71335
71555
  }
71336
71556
  }
71337
71557
  exports.SchemaGraph = SchemaGraph;
@@ -75148,9 +75368,13 @@ class AccuSnap {
75148
75368
  this.aSnapHits.removeCurrentHit();
75149
75369
  hit = await this.getAccuSnapDetail(this.aSnapHits, out);
75150
75370
  }
75371
+ if (!this._doSnapping)
75372
+ hit = undefined; // Snap no longer requested...
75151
75373
  }
75152
75374
  else if (this.isLocateEnabled) {
75153
75375
  hit = await this.findLocatableHit(ev, false, out); // get next AccuSnap path (or undefined)
75376
+ if (!this.isLocateEnabled)
75377
+ hit = undefined; // Hit no longer requested...
75154
75378
  }
75155
75379
  // set the current hit
75156
75380
  if (hit || this.currHit)
@@ -75171,9 +75395,13 @@ class AccuSnap {
75171
75395
  if (this._doSnapping) {
75172
75396
  out.snapStatus = this.findHits(ev);
75173
75397
  hit = (_ElementLocateManager__WEBPACK_IMPORTED_MODULE_2__.SnapStatus.Success !== out.snapStatus) ? undefined : await this.getAccuSnapDetail(this.aSnapHits, out);
75398
+ if (!this._doSnapping)
75399
+ hit = undefined; // Snap no longer requested...
75174
75400
  }
75175
75401
  else if (this.isLocateEnabled) {
75176
75402
  hit = await this.findLocatableHit(ev, true, out);
75403
+ if (!this.isLocateEnabled)
75404
+ hit = undefined; // Hit no longer requested...
75177
75405
  }
75178
75406
  }
75179
75407
  // set the current hit and display the sprite (based on snap's KeypointType)
@@ -274578,7 +274806,7 @@ class TestContext {
274578
274806
  this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
274579
274807
  const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
274580
274808
  await core_frontend_1.NoRenderApp.startup({
274581
- applicationVersion: "4.0.0-dev.103",
274809
+ applicationVersion: "4.0.0-dev.105",
274582
274810
  applicationId: this.settings.gprid,
274583
274811
  authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.adminUserAccessToken),
274584
274812
  hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
@@ -293952,7 +294180,7 @@ module.exports = JSON.parse('{"name":"axios","version":"0.21.4","description":"P
293952
294180
  /***/ ((module) => {
293953
294181
 
293954
294182
  "use strict";
293955
- module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"4.0.0-dev.103","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","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 ES2020 --outDir lib/esm","clean":"rimraf 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","docs":"betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/primitives,**/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-eslintrc -c \\"./node_modules/@itwin/eslint-plugin/dist/configs/extension-exports-config.js\\" \\"./src/**/*.ts\\" 1>&2","lint":"eslint -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run -s webpackTests && certa -r chrome","cover":"npm -s test","test:debug":"certa -r chrome --debug","webpackTests":"webpack --config ./src/test/utils/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:^4.0.0-dev.103","@itwin/core-bentley":"workspace:^4.0.0-dev.103","@itwin/core-common":"workspace:^4.0.0-dev.103","@itwin/core-geometry":"workspace:^4.0.0-dev.103","@itwin/core-orbitgt":"workspace:^4.0.0-dev.103","@itwin/core-quantity":"workspace:^4.0.0-dev.103"},"//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/certa":"workspace:*","@itwin/eslint-plugin":"^4.0.0-dev.33","@types/chai":"4.3.1","@types/chai-as-promised":"^7","@types/mocha":"^8.2.2","@types/node":"^18.11.5","@types/sinon":"^9.0.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","chai":"^4.1.2","chai-as-promised":"^7","cpx2":"^3.0.0","eslint":"^8.36.0","glob":"^7.1.2","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^3.0.2","sinon":"^9.0.2","source-map-loader":"^4.0.0","typescript":"~5.0.2","webpack":"^5.76.0"},"//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/object-storage-azure":"^1.5.0","@itwin/cloud-agnostic-core":"^1.5.0","@itwin/object-storage-core":"^1.5.0","@itwin/core-i18n":"workspace:*","@itwin/core-telemetry":"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","reflect-metadata":"0.1.13"},"nyc":{"extends":"./node_modules/@itwin/build-tools/.nycrc"},"eslintConfig":{"plugins":["@itwin"],"extends":"plugin:@itwin/itwinjs-recommended","rules":{"@itwin/no-internal-barrel-imports":["error",{"required-barrel-modules":["./src/tile/internal.ts"]}],"@itwin/public-extension-exports":["error",{"releaseTags":["public","preview"],"outputApiFile":false}]},"overrides":[{"files":["*.test.ts","*.test.tsx","**/test/**/*.ts"],"rules":{"@itwin/no-internal-barrel-imports":"off"}}]}}');
294183
+ module.exports = JSON.parse('{"name":"@itwin/core-frontend","version":"4.0.0-dev.105","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","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 ES2020 --outDir lib/esm","clean":"rimraf 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","docs":"betools docs --includes=../../generated-docs/extract --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/primitives,**/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-eslintrc -c \\"./node_modules/@itwin/eslint-plugin/dist/configs/extension-exports-config.js\\" \\"./src/**/*.ts\\" 1>&2","lint":"eslint -f visualstudio \\"./src/**/*.ts\\" 1>&2","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run -s webpackTests && certa -r chrome","cover":"npm -s test","test:debug":"certa -r chrome --debug","webpackTests":"webpack --config ./src/test/utils/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:^4.0.0-dev.105","@itwin/core-bentley":"workspace:^4.0.0-dev.105","@itwin/core-common":"workspace:^4.0.0-dev.105","@itwin/core-geometry":"workspace:^4.0.0-dev.105","@itwin/core-orbitgt":"workspace:^4.0.0-dev.105","@itwin/core-quantity":"workspace:^4.0.0-dev.105"},"//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/certa":"workspace:*","@itwin/eslint-plugin":"^4.0.0-dev.33","@types/chai":"4.3.1","@types/chai-as-promised":"^7","@types/mocha":"^8.2.2","@types/node":"^18.11.5","@types/sinon":"^9.0.0","babel-loader":"~8.2.5","babel-plugin-istanbul":"~6.1.1","chai":"^4.1.2","chai-as-promised":"^7","cpx2":"^3.0.0","eslint":"^8.36.0","glob":"^7.1.2","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^3.0.2","sinon":"^9.0.2","source-map-loader":"^4.0.0","typescript":"~5.0.2","webpack":"^5.76.0"},"//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/object-storage-azure":"^1.5.0","@itwin/cloud-agnostic-core":"^1.5.0","@itwin/object-storage-core":"^1.5.0","@itwin/core-i18n":"workspace:*","@itwin/core-telemetry":"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","reflect-metadata":"0.1.13"},"nyc":{"extends":"./node_modules/@itwin/build-tools/.nycrc"},"eslintConfig":{"plugins":["@itwin"],"extends":"plugin:@itwin/itwinjs-recommended","rules":{"@itwin/no-internal-barrel-imports":["error",{"required-barrel-modules":["./src/tile/internal.ts"]}],"@itwin/public-extension-exports":["error",{"releaseTags":["public","preview"],"outputApiFile":false}]},"overrides":[{"files":["*.test.ts","*.test.tsx","**/test/**/*.ts"],"rules":{"@itwin/no-internal-barrel-imports":"off"}}]}}');
293956
294184
 
293957
294185
  /***/ }),
293958
294186