@itwin/rpcinterface-full-stack-tests 5.12.0-dev.16 → 5.12.0-dev.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/backend/BackendInit.js.map +1 -1
- package/lib/common/Settings.js +12 -12
- package/lib/common/Settings.js.map +1 -1
- package/lib/common/SideChannels.js.map +1 -1
- package/lib/dist/bundled-tests.js +808 -358
- package/lib/dist/bundled-tests.js.map +1 -1
- package/lib/frontend/DevToolsRpc.test.js.map +1 -1
- package/lib/frontend/Elements.test.js.map +1 -1
- package/lib/frontend/IModel.test.js.map +1 -1
- package/lib/frontend/IModelConnection.test.js.map +1 -1
- package/lib/frontend/Models.test.js.map +1 -1
- package/lib/frontend/PresentationRpc.test.js.map +1 -1
- package/lib/frontend/Views.test.js.map +1 -1
- package/lib/frontend/setup/IModelSession.js.map +1 -1
- package/lib/frontend/setup/TestContext.js.map +1 -1
- package/lib/frontend/workflows/BasicScenarios.test.js.map +1 -1
- package/package.json +16 -16
|
@@ -95582,20 +95582,160 @@ class SchemaPartVisitorDelegate {
|
|
|
95582
95582
|
|
|
95583
95583
|
/***/ },
|
|
95584
95584
|
|
|
95585
|
-
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView.js"
|
|
95586
|
-
|
|
95587
|
-
!*** ../../core/ecschema-metadata/lib/esm/SchemaView.js ***!
|
|
95588
|
-
|
|
95585
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaManifest.js"
|
|
95586
|
+
/*!*************************************************************************!*\
|
|
95587
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaManifest.js ***!
|
|
95588
|
+
\*************************************************************************/
|
|
95589
95589
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
95590
95590
|
|
|
95591
95591
|
"use strict";
|
|
95592
95592
|
__webpack_require__.r(__webpack_exports__);
|
|
95593
95593
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
95594
|
-
/* harmony export */
|
|
95595
|
-
/* harmony export */ SchemaViewBuilder: () => (/* binding */ SchemaViewBuilder)
|
|
95594
|
+
/* harmony export */ SchemaManifest: () => (/* binding */ SchemaManifest)
|
|
95596
95595
|
/* harmony export */ });
|
|
95597
|
-
|
|
95598
|
-
|
|
95596
|
+
/*---------------------------------------------------------------------------------------------
|
|
95597
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
95598
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
95599
|
+
*--------------------------------------------------------------------------------------------*/
|
|
95600
|
+
/** @packageDocumentation
|
|
95601
|
+
* @module Schema
|
|
95602
|
+
*/
|
|
95603
|
+
/** The reference graph of every schema in one iModel - names, versions and reference edges, without
|
|
95604
|
+
* any schema data. A {@link (SchemaView:class)} husk loads it up front to answer which schemas exist
|
|
95605
|
+
* and which dependency-ordered set it must load to satisfy a request.
|
|
95606
|
+
*
|
|
95607
|
+
* A `SchemaViewDataProvider` builds the manifest from ECDbMeta rows via {@link SchemaManifest.fromRows}.
|
|
95608
|
+
* The entries are a flat array with no iModel or platform dependency; even the largest iModels hold
|
|
95609
|
+
* on the order of a hundred schemas, so the closure and topological walks are plain recursion.
|
|
95610
|
+
* @note The manifest does not track which schemas are already loaded. `SchemaViewManager` does that
|
|
95611
|
+
* and filters the result of {@link SchemaManifest.getSchemaClosure} itself.
|
|
95612
|
+
* @internal
|
|
95613
|
+
*/
|
|
95614
|
+
class SchemaManifest {
|
|
95615
|
+
_entries;
|
|
95616
|
+
_byLowerName;
|
|
95617
|
+
/** Wraps a set of entries whose references are already wired to one another. */
|
|
95618
|
+
constructor(entries) {
|
|
95619
|
+
this._entries = entries;
|
|
95620
|
+
const byLowerName = new Map();
|
|
95621
|
+
for (const entry of entries)
|
|
95622
|
+
byLowerName.set(entry.name.toLowerCase(), entry);
|
|
95623
|
+
this._byLowerName = byLowerName;
|
|
95624
|
+
}
|
|
95625
|
+
/** Build a manifest from raw ECDbMeta query rows, so a `SchemaViewDataProvider` only has to run
|
|
95626
|
+
* the two queries and hand the rows over. Reference rows whose endpoints are unknown or
|
|
95627
|
+
* self-referential are skipped; that cannot happen for a well-formed iModel.
|
|
95628
|
+
* @internal
|
|
95629
|
+
*/
|
|
95630
|
+
static fromRows(schemaRows, referenceRows) {
|
|
95631
|
+
const entries = [];
|
|
95632
|
+
const entryByECInstanceId = new Map();
|
|
95633
|
+
for (const row of schemaRows) {
|
|
95634
|
+
const entry = {
|
|
95635
|
+
name: row.name,
|
|
95636
|
+
readVersion: row.versionMajor,
|
|
95637
|
+
writeVersion: row.versionWrite,
|
|
95638
|
+
minorVersion: row.versionMinor,
|
|
95639
|
+
references: [],
|
|
95640
|
+
};
|
|
95641
|
+
entries.push(entry);
|
|
95642
|
+
entryByECInstanceId.set(row.ecInstanceId, entry);
|
|
95643
|
+
}
|
|
95644
|
+
for (const row of referenceRows) {
|
|
95645
|
+
const source = entryByECInstanceId.get(row.sourceECInstanceId);
|
|
95646
|
+
const target = entryByECInstanceId.get(row.targetECInstanceId);
|
|
95647
|
+
if (source === undefined || target === undefined || source === target || source.references.includes(target))
|
|
95648
|
+
continue;
|
|
95649
|
+
source.references.push(target);
|
|
95650
|
+
}
|
|
95651
|
+
return new SchemaManifest(entries);
|
|
95652
|
+
}
|
|
95653
|
+
/** The number of schemas in the iModel. */
|
|
95654
|
+
get schemaCount() { return this._entries.length; }
|
|
95655
|
+
/** The names of every schema in the iModel, in manifest order. */
|
|
95656
|
+
getAvailableSchemaNames() {
|
|
95657
|
+
return this._entries.map((entry) => entry.name);
|
|
95658
|
+
}
|
|
95659
|
+
get entries() {
|
|
95660
|
+
return this._entries;
|
|
95661
|
+
}
|
|
95662
|
+
/** The entry for a schema by name (case-insensitive), or `undefined` if the iModel has no such schema. */
|
|
95663
|
+
findByName(name) {
|
|
95664
|
+
return this._byLowerName.get(name.toLowerCase());
|
|
95665
|
+
}
|
|
95666
|
+
/** The transitive reference closure of the requested schemas, as a flat, duplicate-free list of
|
|
95667
|
+
* names: the full set that must be present to use them. The order is unspecified - run
|
|
95668
|
+
* {@link SchemaManifest.sortInDependencyOrder} on the result when a load order is needed.
|
|
95669
|
+
* @note Requested names the iModel does not contain are ignored; check
|
|
95670
|
+
* {@link SchemaManifest.findByName} first to detect them.
|
|
95671
|
+
*/
|
|
95672
|
+
getSchemaClosure(requestedNames) {
|
|
95673
|
+
const result = [];
|
|
95674
|
+
const visited = new Set();
|
|
95675
|
+
const visit = (entry) => {
|
|
95676
|
+
if (visited.has(entry))
|
|
95677
|
+
return;
|
|
95678
|
+
visited.add(entry);
|
|
95679
|
+
result.push(entry.name);
|
|
95680
|
+
for (const reference of entry.references)
|
|
95681
|
+
visit(reference);
|
|
95682
|
+
};
|
|
95683
|
+
for (const name of requestedNames) {
|
|
95684
|
+
const entry = this._byLowerName.get(name.toLowerCase());
|
|
95685
|
+
if (entry !== undefined)
|
|
95686
|
+
visit(entry);
|
|
95687
|
+
}
|
|
95688
|
+
return result;
|
|
95689
|
+
}
|
|
95690
|
+
/** Orders the given schema names so each appears after every schema it references, directly or
|
|
95691
|
+
* transitively. References through schemas not in `schemaNames` are still honored, so the order is
|
|
95692
|
+
* correct even when an intermediate schema is left out. Names the iModel does not contain are
|
|
95693
|
+
* ignored, and reference cycles - which EC forbids - are broken arbitrarily rather than looping.
|
|
95694
|
+
* @internal
|
|
95695
|
+
*/
|
|
95696
|
+
sortInDependencyOrder(schemaNames) {
|
|
95697
|
+
const requested = new Set();
|
|
95698
|
+
for (const name of schemaNames) {
|
|
95699
|
+
const entry = this._byLowerName.get(name.toLowerCase());
|
|
95700
|
+
if (entry !== undefined)
|
|
95701
|
+
requested.add(entry);
|
|
95702
|
+
}
|
|
95703
|
+
const result = [];
|
|
95704
|
+
const visited = new Set();
|
|
95705
|
+
const visiting = new Set();
|
|
95706
|
+
const visit = (entry) => {
|
|
95707
|
+
if (visited.has(entry) || visiting.has(entry))
|
|
95708
|
+
return;
|
|
95709
|
+
visiting.add(entry);
|
|
95710
|
+
for (const reference of entry.references)
|
|
95711
|
+
visit(reference);
|
|
95712
|
+
visiting.delete(entry);
|
|
95713
|
+
visited.add(entry);
|
|
95714
|
+
if (requested.has(entry))
|
|
95715
|
+
result.push(entry.name);
|
|
95716
|
+
};
|
|
95717
|
+
for (const entry of requested)
|
|
95718
|
+
visit(entry);
|
|
95719
|
+
return result;
|
|
95720
|
+
}
|
|
95721
|
+
}
|
|
95722
|
+
|
|
95723
|
+
|
|
95724
|
+
/***/ },
|
|
95725
|
+
|
|
95726
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaView.js"
|
|
95727
|
+
/*!*********************************************************************!*\
|
|
95728
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaView.js ***!
|
|
95729
|
+
\*********************************************************************/
|
|
95730
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
95731
|
+
|
|
95732
|
+
"use strict";
|
|
95733
|
+
__webpack_require__.r(__webpack_exports__);
|
|
95734
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
95735
|
+
/* harmony export */ SchemaView: () => (/* binding */ SchemaView)
|
|
95736
|
+
/* harmony export */ });
|
|
95737
|
+
/* harmony import */ var _SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaViewInterfaces */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewInterfaces.js");
|
|
95738
|
+
/* harmony import */ var _SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaViewBinaryReader */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBinaryReader.js");
|
|
95599
95739
|
/*---------------------------------------------------------------------------------------------
|
|
95600
95740
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
95601
95741
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -95626,16 +95766,21 @@ class SchemaView {
|
|
|
95626
95766
|
[_storage];
|
|
95627
95767
|
_schemaToken;
|
|
95628
95768
|
_outdated = false;
|
|
95769
|
+
/** When present, this view is a *husk*: it retains the live builder and cross-reference maps, so
|
|
95770
|
+
* `mergeFragment` can append further fragment blobs. Undefined for one-shot views from `fromBinary`. */
|
|
95771
|
+
_mergeContext;
|
|
95629
95772
|
/** @internal */
|
|
95630
|
-
constructor(data, schemaToken) {
|
|
95773
|
+
constructor(data, schemaToken, mergeContext) {
|
|
95631
95774
|
this[_storage] = {
|
|
95632
95775
|
...data,
|
|
95633
95776
|
transitiveBaseCache: new Map(),
|
|
95634
95777
|
derivedClassMap: undefined,
|
|
95635
95778
|
};
|
|
95636
95779
|
this._schemaToken = schemaToken ?? "";
|
|
95780
|
+
this._mergeContext = mergeContext;
|
|
95637
95781
|
}
|
|
95638
|
-
/**
|
|
95782
|
+
/** Cache-invalidation token identifying the schemas this view was built from: a hash of every
|
|
95783
|
+
* schema's name and version (see `PRAGMA checksum(schema_token)`), not of their full contents.
|
|
95639
95784
|
* Empty string if not set (e.g., when built from a builder without a token).
|
|
95640
95785
|
* @beta
|
|
95641
95786
|
*/
|
|
@@ -95699,17 +95844,37 @@ class SchemaView {
|
|
|
95699
95844
|
}
|
|
95700
95845
|
/** Parse a binary blob into a SchemaView. Synchronous.
|
|
95701
95846
|
* @param blob - The binary blob from `PRAGMA schema_view`.
|
|
95702
|
-
* @param schemaToken - Optional
|
|
95847
|
+
* @param schemaToken - Optional cache-invalidation token (schema name+version hash; see `PRAGMA checksum(schema_token)`).
|
|
95703
95848
|
* @beta
|
|
95704
95849
|
*/
|
|
95705
95850
|
static fromBinary(blob, schemaToken) {
|
|
95706
95851
|
return (0,_SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_1__.parseSchemaViewBlob)(blob, schemaToken);
|
|
95707
95852
|
}
|
|
95708
|
-
/**
|
|
95853
|
+
/** Create an empty, *mergeable* view (a "husk"). It contains no schemas until `mergeFragment` is
|
|
95854
|
+
* called. Each merged fragment is appended into the same instance, so flyweights and cached
|
|
95855
|
+
* cross-references obtained earlier stay valid - indices are append-only and never reordered.
|
|
95856
|
+
* @note Fragments must be merged in dependency order: a fragment may only reference schemas from
|
|
95857
|
+
* fragments already merged.
|
|
95858
|
+
* @internal
|
|
95859
|
+
*/
|
|
95860
|
+
static createMergeable(schemaToken) {
|
|
95861
|
+
const ctx = new _SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_1__.SchemaViewMergeContext();
|
|
95862
|
+
return new SchemaView(ctx.builder.assembleData(), schemaToken, ctx);
|
|
95863
|
+
}
|
|
95864
|
+
/** Merge one fragment blob into this view. Only valid on a view created via `createMergeable`.
|
|
95865
|
+
* Synchronous. Any flyweight or cached index obtained before the call remains valid.
|
|
95866
|
+
* @note If the merge throws (e.g. on a malformed blob), the view may be left partially extended
|
|
95867
|
+
* and must be discarded by the host.
|
|
95709
95868
|
* @internal
|
|
95710
95869
|
*/
|
|
95711
|
-
|
|
95712
|
-
|
|
95870
|
+
mergeFragment(blob) {
|
|
95871
|
+
if (this._mergeContext === undefined)
|
|
95872
|
+
throw new Error("SchemaView is not mergeable: create it via SchemaView.createMergeable to merge fragments.");
|
|
95873
|
+
this._mergeContext.mergeBlob(blob);
|
|
95874
|
+
// A new fragment can add subclasses to an already-present base class, so the derived-class map
|
|
95875
|
+
// must be rebuilt. transitiveBaseCache stays valid: a class's ancestors are always merged
|
|
95876
|
+
// before it (dependency order), so an append never adds an ancestor to an already-cached class.
|
|
95877
|
+
this[_storage].derivedClassMap = undefined;
|
|
95713
95878
|
}
|
|
95714
95879
|
// --- Internal helpers used by view objects ---
|
|
95715
95880
|
/** Resolve a qualified "SchemaName:ItemName" (or dot-separated) to an index using the given
|
|
@@ -96604,215 +96769,26 @@ class SchemaView {
|
|
|
96604
96769
|
}
|
|
96605
96770
|
SchemaView.RelConstraint = RelConstraint;
|
|
96606
96771
|
})(SchemaView || (SchemaView = {}));
|
|
96607
|
-
// =====================================================================================
|
|
96608
|
-
// SchemaViewBuilder
|
|
96609
|
-
// =====================================================================================
|
|
96610
|
-
/** Builder for constructing an immutable `SchemaView`.
|
|
96611
|
-
*
|
|
96612
|
-
* Collects data during binary blob parsing, then freezes it into a view.
|
|
96613
|
-
* Handles string interning and property definition deduplication.
|
|
96614
|
-
*
|
|
96615
|
-
* Consumers should not use this directly - read views via `IModelDb.getSchemaView`
|
|
96616
|
-
* / `IModelConnection.getSchemaView` (or `SchemaView.fromBinary` if you have a raw blob).
|
|
96617
|
-
* @internal
|
|
96618
|
-
*/
|
|
96619
|
-
class SchemaViewBuilder {
|
|
96620
|
-
_strings = [""]; // SID 0 = empty string
|
|
96621
|
-
_lowerStrings = [""];
|
|
96622
|
-
_stringMap = new Map(); // original value -> SID
|
|
96623
|
-
_schemas = [];
|
|
96624
|
-
_classes = [];
|
|
96625
|
-
_classMixins = [];
|
|
96626
|
-
_propDefs = [];
|
|
96627
|
-
_propertyRefs = [];
|
|
96628
|
-
_relConstraints = [];
|
|
96629
|
-
_constraintClassRefs = [];
|
|
96630
|
-
_enumerations = [];
|
|
96631
|
-
_enumerators = [];
|
|
96632
|
-
_koqs = [];
|
|
96633
|
-
_propCategories = [];
|
|
96634
|
-
// For PropertyDef dedup
|
|
96635
|
-
_propDefMap = new Map(); // signature string -> defIdx
|
|
96636
|
-
/** Intern a string, returning its SID. Empty/undefined strings return 0.
|
|
96637
|
-
* Interning is case-sensitive - "MyLabel" and "MYLABEL" get distinct SIDs.
|
|
96638
|
-
* The `lowerStrings` array provides case-insensitive lookup without mutating display values.
|
|
96639
|
-
*/
|
|
96640
|
-
internString(value) {
|
|
96641
|
-
if (value === undefined || value === "")
|
|
96642
|
-
return 0;
|
|
96643
|
-
const existing = this._stringMap.get(value);
|
|
96644
|
-
if (existing !== undefined)
|
|
96645
|
-
return existing;
|
|
96646
|
-
const sid = this._strings.length;
|
|
96647
|
-
this._strings.push(value);
|
|
96648
|
-
this._lowerStrings.push(value.toLowerCase());
|
|
96649
|
-
this._stringMap.set(value, sid);
|
|
96650
|
-
return sid;
|
|
96651
|
-
}
|
|
96652
|
-
/** Add a schema. Returns its index. */
|
|
96653
|
-
addSchema(data) {
|
|
96654
|
-
const idx = this._schemas.length;
|
|
96655
|
-
this._schemas.push(data);
|
|
96656
|
-
return idx;
|
|
96657
|
-
}
|
|
96658
|
-
/** Add a class. Returns its index. Must be called after the owning schema. */
|
|
96659
|
-
addClass(data) {
|
|
96660
|
-
const idx = this._classes.length;
|
|
96661
|
-
this._classes.push(data);
|
|
96662
|
-
return idx;
|
|
96663
|
-
}
|
|
96664
|
-
/** Add a property definition with deduplication. Returns the def index (possibly existing). */
|
|
96665
|
-
addPropertyDef(data) {
|
|
96666
|
-
const sig = this._propDefSignature(data);
|
|
96667
|
-
const existing = this._propDefMap.get(sig);
|
|
96668
|
-
if (existing !== undefined)
|
|
96669
|
-
return existing;
|
|
96670
|
-
const idx = this._propDefs.length;
|
|
96671
|
-
this._propDefs.push(data);
|
|
96672
|
-
this._propDefMap.set(sig, idx);
|
|
96673
|
-
return idx;
|
|
96674
|
-
}
|
|
96675
|
-
/** Append a property reference to the flat refs array. */
|
|
96676
|
-
addPropertyRef(ref) {
|
|
96677
|
-
this._propertyRefs.push(ref);
|
|
96678
|
-
}
|
|
96679
|
-
/** Add an enumeration. Returns its index. */
|
|
96680
|
-
addEnumeration(data) {
|
|
96681
|
-
const idx = this._enumerations.length;
|
|
96682
|
-
this._enumerations.push(data);
|
|
96683
|
-
return idx;
|
|
96684
|
-
}
|
|
96685
|
-
/** Append an enumerator to the flat enumerators array. */
|
|
96686
|
-
addEnumerator(data) {
|
|
96687
|
-
this._enumerators.push(data);
|
|
96688
|
-
}
|
|
96689
|
-
/** Add a KindOfQuantity. Returns its index. */
|
|
96690
|
-
addKoq(data) {
|
|
96691
|
-
const idx = this._koqs.length;
|
|
96692
|
-
this._koqs.push(data);
|
|
96693
|
-
return idx;
|
|
96694
|
-
}
|
|
96695
|
-
/** Add a PropertyCategory. Returns its index. */
|
|
96696
|
-
addPropertyCategory(data) {
|
|
96697
|
-
const idx = this._propCategories.length;
|
|
96698
|
-
this._propCategories.push(data);
|
|
96699
|
-
return idx;
|
|
96700
|
-
}
|
|
96701
|
-
/** Add a relationship constraint. Returns its index. */
|
|
96702
|
-
addRelConstraint(data) {
|
|
96703
|
-
const idx = this._relConstraints.length;
|
|
96704
|
-
this._relConstraints.push(data);
|
|
96705
|
-
return idx;
|
|
96706
|
-
}
|
|
96707
|
-
/** Append a constraint class reference to the flat array. */
|
|
96708
|
-
addConstraintClassRef(classIdx) {
|
|
96709
|
-
this._constraintClassRefs.push(classIdx);
|
|
96710
|
-
}
|
|
96711
|
-
/** Append a mixin class reference to the flat array. */
|
|
96712
|
-
addClassMixin(classIdx) {
|
|
96713
|
-
this._classMixins.push(classIdx);
|
|
96714
|
-
}
|
|
96715
|
-
/** The current count of property refs (used to set ownPropStart on ClassData). */
|
|
96716
|
-
get propertyRefCount() { return this._propertyRefs.length; }
|
|
96717
|
-
/** The current count of enumerators (used to set enumeratorStart on EnumerationData). */
|
|
96718
|
-
get enumeratorCount() { return this._enumerators.length; }
|
|
96719
|
-
/** The current count of constraint class refs (used to set classRefStart). */
|
|
96720
|
-
get constraintClassRefCount() { return this._constraintClassRefs.length; }
|
|
96721
|
-
/** The current count of class mixins (used to set mixinStartIdx). */
|
|
96722
|
-
get classMixinCount() { return this._classMixins.length; }
|
|
96723
|
-
/** Get a string by SID. @internal */
|
|
96724
|
-
getString(sid) { return this._strings[sid]; }
|
|
96725
|
-
/** Replace class data at the given index (used during deferred cross-ref resolution). @internal */
|
|
96726
|
-
updateClass(classIdx, data) { this._classes[classIdx] = data; }
|
|
96727
|
-
/** Update range fields on a schema (used after all items for a schema are collected). @internal */
|
|
96728
|
-
updateSchemaRanges(schemaIdx, ranges) {
|
|
96729
|
-
const s = this._schemas[schemaIdx];
|
|
96730
|
-
this._schemas[schemaIdx] = { ...s, ...ranges };
|
|
96731
|
-
}
|
|
96732
|
-
/** Freeze all data and produce an immutable SchemaView. */
|
|
96733
|
-
build(schemaToken) {
|
|
96734
|
-
const schemaByName = new Map();
|
|
96735
|
-
const schemaByAlias = new Map();
|
|
96736
|
-
const classByName = new Map();
|
|
96737
|
-
const enumByName = new Map();
|
|
96738
|
-
const koqByName = new Map();
|
|
96739
|
-
const catByName = new Map();
|
|
96740
|
-
// Build schema lookup maps
|
|
96741
|
-
for (let i = 0; i < this._schemas.length; i++) {
|
|
96742
|
-
const s = this._schemas[i];
|
|
96743
|
-
schemaByName.set(this._lowerStrings[s.nameStringIdx], i);
|
|
96744
|
-
if (s.aliasStringIdx !== 0)
|
|
96745
|
-
schemaByAlias.set(this._lowerStrings[s.aliasStringIdx], i);
|
|
96746
|
-
// Build class-by-name map for this schema
|
|
96747
|
-
const classMap = new Map();
|
|
96748
|
-
for (let c = s.classRangeStart; c < s.classRangeStart + s.classCount; c++)
|
|
96749
|
-
classMap.set(this._lowerStrings[this._classes[c].nameStringIdx], c);
|
|
96750
|
-
classByName.set(i, classMap);
|
|
96751
|
-
// Build enum-by-name map for this schema
|
|
96752
|
-
const eMap = new Map();
|
|
96753
|
-
for (let e = s.enumRangeStart; e < s.enumRangeStart + s.enumCount; e++)
|
|
96754
|
-
eMap.set(this._lowerStrings[this._enumerations[e].nameStringIdx], e);
|
|
96755
|
-
enumByName.set(i, eMap);
|
|
96756
|
-
// Build koq-by-name map for this schema
|
|
96757
|
-
const kMap = new Map();
|
|
96758
|
-
for (let k = s.koqRangeStart; k < s.koqRangeStart + s.koqCount; k++)
|
|
96759
|
-
kMap.set(this._lowerStrings[this._koqs[k].nameStringIdx], k);
|
|
96760
|
-
koqByName.set(i, kMap);
|
|
96761
|
-
// Build category-by-name map for this schema
|
|
96762
|
-
const cMap = new Map();
|
|
96763
|
-
for (let p = s.catRangeStart; p < s.catRangeStart + s.catCount; p++)
|
|
96764
|
-
cMap.set(this._lowerStrings[this._propCategories[p].nameStringIdx], p);
|
|
96765
|
-
catByName.set(i, cMap);
|
|
96766
|
-
}
|
|
96767
|
-
return new SchemaView({
|
|
96768
|
-
strings: this._strings,
|
|
96769
|
-
lowerStrings: this._lowerStrings,
|
|
96770
|
-
schemas: this._schemas,
|
|
96771
|
-
classes: this._classes,
|
|
96772
|
-
classMixins: this._classMixins,
|
|
96773
|
-
propDefs: this._propDefs,
|
|
96774
|
-
propertyRefs: this._propertyRefs,
|
|
96775
|
-
relConstraints: this._relConstraints,
|
|
96776
|
-
constraintClassRefs: this._constraintClassRefs,
|
|
96777
|
-
enumerations: this._enumerations,
|
|
96778
|
-
enumerators: this._enumerators,
|
|
96779
|
-
koqs: this._koqs,
|
|
96780
|
-
propCategories: this._propCategories,
|
|
96781
|
-
schemaByName,
|
|
96782
|
-
schemaByAlias,
|
|
96783
|
-
classByName,
|
|
96784
|
-
enumByName,
|
|
96785
|
-
koqByName,
|
|
96786
|
-
catByName,
|
|
96787
|
-
}, schemaToken);
|
|
96788
|
-
}
|
|
96789
|
-
/** Produce a dedup signature for a PropertyDef. Label and priority are excluded because
|
|
96790
|
-
* they are per-PropertyRef overrides, not part of the structural definition.
|
|
96791
|
-
* Uses SIDs (not lowercase strings) for name/description so that case-preserving names
|
|
96792
|
-
* stay distinct - matching the C++ writer's dedup behavior. */
|
|
96793
|
-
_propDefSignature(def) {
|
|
96794
|
-
return `${def.nameStringIdx}|${def.kind}|${def.primitiveType}|${def.extTypeStringIdx}|${def.enumIdx}|${def.koqIdx}|${def.structClassIdx}|${def.navRelClassIdx}|${def.navDirection}|${def.categoryIdx}|${def.isReadOnly ? 1 : 0}|${def.isHidden ? 1 : 0}|${def.arrayMinOccurs}|${def.arrayMaxOccurs}|${def.descriptionStringIdx}`;
|
|
96795
|
-
}
|
|
96796
|
-
}
|
|
96797
96772
|
|
|
96798
96773
|
|
|
96799
96774
|
/***/ },
|
|
96800
96775
|
|
|
96801
|
-
/***/ "../../core/ecschema-metadata/lib/esm/SchemaViewBinaryReader.js"
|
|
96802
|
-
|
|
96803
|
-
!*** ../../core/ecschema-metadata/lib/esm/SchemaViewBinaryReader.js ***!
|
|
96804
|
-
|
|
96776
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBinaryReader.js"
|
|
96777
|
+
/*!*********************************************************************************!*\
|
|
96778
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBinaryReader.js ***!
|
|
96779
|
+
\*********************************************************************************/
|
|
96805
96780
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
96806
96781
|
|
|
96807
96782
|
"use strict";
|
|
96808
96783
|
__webpack_require__.r(__webpack_exports__);
|
|
96809
96784
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
96785
|
+
/* harmony export */ SchemaViewMergeContext: () => (/* binding */ SchemaViewMergeContext),
|
|
96810
96786
|
/* harmony export */ parseSchemaViewBlob: () => (/* binding */ parseSchemaViewBlob)
|
|
96811
96787
|
/* harmony export */ });
|
|
96812
96788
|
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
96813
|
-
/* harmony import */ var
|
|
96814
|
-
/* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*!
|
|
96815
|
-
/* harmony import */ var _SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaViewInterfaces */ "../../core/ecschema-metadata/lib/esm/SchemaViewInterfaces.js");
|
|
96789
|
+
/* harmony import */ var _SchemaViewBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./SchemaViewBuilder */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBuilder.js");
|
|
96790
|
+
/* harmony import */ var _ECObjects__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../ECObjects */ "../../core/ecschema-metadata/lib/esm/ECObjects.js");
|
|
96791
|
+
/* harmony import */ var _SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./SchemaViewInterfaces */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewInterfaces.js");
|
|
96816
96792
|
/*---------------------------------------------------------------------------------------------
|
|
96817
96793
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
96818
96794
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -96913,7 +96889,34 @@ function expectTag(reader, expected) {
|
|
|
96913
96889
|
if (tag !== expected)
|
|
96914
96890
|
throw new Error(`Expected tag 0x${expected.toString(16)} but found 0x${tag.toString(16)} at offset ${reader.pos - 1}`);
|
|
96915
96891
|
}
|
|
96916
|
-
/**
|
|
96892
|
+
/** Reusable parse/merge context for SchemaView blobs. Holds the live `SchemaViewBuilder` plus the
|
|
96893
|
+
* cross-reference maps that must persist across fragment merges. Each `mergeBlob` appends one blob's
|
|
96894
|
+
* schemas into the shared builder and resolves cross-references - including cross-fragment ones -
|
|
96895
|
+
* against the accumulated maps. A whole-iModel blob is the degenerate case of a single fragment.
|
|
96896
|
+
* @note Fragments must be merged in dependency order, so a fragment only references schemas already
|
|
96897
|
+
* merged by an earlier one (or excluded schemas, which resolve to "not present").
|
|
96898
|
+
* @internal
|
|
96899
|
+
*/
|
|
96900
|
+
class SchemaViewMergeContext {
|
|
96901
|
+
builder = new _SchemaViewBuilder__WEBPACK_IMPORTED_MODULE_1__.SchemaViewBuilder();
|
|
96902
|
+
// Cross-reference maps. Persist across fragments: a row id / name from a later fragment resolves
|
|
96903
|
+
// against a class, enum, koq, or category merged by an earlier fragment.
|
|
96904
|
+
schemaECIdToIdx = new Map();
|
|
96905
|
+
enumRowIdToIdx = new Map();
|
|
96906
|
+
koqRowIdToIdx = new Map();
|
|
96907
|
+
catRowIdToIdx = new Map();
|
|
96908
|
+
classRowIdToIdx = new Map();
|
|
96909
|
+
// "schemaname:classname" (both lowercased) -> global class index. Resolves base/mixin/constraint
|
|
96910
|
+
// refs, which the blob encodes as schema+class name pairs, across fragment boundaries.
|
|
96911
|
+
classResolver = new Map();
|
|
96912
|
+
// global schemaIdx -> schema name, for building resolver keys and dangling-ref diagnostics.
|
|
96913
|
+
schemaNames = [];
|
|
96914
|
+
/** Parse one fragment blob and append its schemas into the shared builder. Synchronous. */
|
|
96915
|
+
mergeBlob(data) {
|
|
96916
|
+
mergeFragmentBlob(this, data);
|
|
96917
|
+
}
|
|
96918
|
+
}
|
|
96919
|
+
/** Parse a schema view blob (binary format) into a fresh `SchemaView`.
|
|
96917
96920
|
*
|
|
96918
96921
|
* Layout: Header, PropertyDefTable, SchemaTable, EnumTable, KoQTable, PropCatTable, ClassTable, StringTable.
|
|
96919
96922
|
* Each table is count-prefixed. Schema items carry their schema's ecInstanceId for ownership resolution.
|
|
@@ -96924,6 +96927,16 @@ function expectTag(reader, expected) {
|
|
|
96924
96927
|
* @internal
|
|
96925
96928
|
*/
|
|
96926
96929
|
function parseSchemaViewBlob(data, schemaToken) {
|
|
96930
|
+
const ctx = new SchemaViewMergeContext();
|
|
96931
|
+
ctx.mergeBlob(data);
|
|
96932
|
+
return ctx.builder.build(schemaToken);
|
|
96933
|
+
}
|
|
96934
|
+
/** Parse one fragment blob and append it into the context's builder, resolving cross-references
|
|
96935
|
+
* against the context's accumulated global maps. Per-fragment scratch state stays local; everything
|
|
96936
|
+
* that must outlive the fragment lives on `ctx`.
|
|
96937
|
+
*/
|
|
96938
|
+
function mergeFragmentBlob(ctx, data) {
|
|
96939
|
+
const builder = ctx.builder;
|
|
96927
96940
|
const reader = new BinaryReader(data);
|
|
96928
96941
|
// Header: magic(4) + version(1) + stringTableOffset(4)
|
|
96929
96942
|
const magic = reader.readU32();
|
|
@@ -96934,16 +96947,10 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
96934
96947
|
throw new Error(`Unsupported schema view format version: ${version}, expected ${_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_3__.schemaViewFormatVersion}`);
|
|
96935
96948
|
const stOffset = reader.readU32();
|
|
96936
96949
|
reader.parseStringTable(stOffset);
|
|
96937
|
-
|
|
96938
|
-
|
|
96939
|
-
const schemaEcIdToIdx =
|
|
96940
|
-
|
|
96941
|
-
const koqRowIdToIdx = new Map();
|
|
96942
|
-
const catRowIdToIdx = new Map();
|
|
96943
|
-
const classRowIdToIdx = new Map();
|
|
96944
|
-
// Per-schema metadata for name-based class resolution
|
|
96945
|
-
const schemaInfos = [];
|
|
96946
|
-
// Per-schema item range tracking (indexed by schemaIdx)
|
|
96950
|
+
// Global index of the first schema this fragment adds. Local schema index = global - base.
|
|
96951
|
+
const schemaBaseIdx = builder.schemaCount;
|
|
96952
|
+
const { schemaECIdToIdx: schemaEcIdToIdx, enumRowIdToIdx, koqRowIdToIdx, catRowIdToIdx, classRowIdToIdx, classResolver } = ctx;
|
|
96953
|
+
// Per-schema item range tracking, indexed by LOCAL schema index (0-based within this fragment).
|
|
96947
96954
|
const schemaEnumStarts = [];
|
|
96948
96955
|
const schemaEnumCounts = [];
|
|
96949
96956
|
const schemaKoqStarts = [];
|
|
@@ -96952,14 +96959,14 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
96952
96959
|
const schemaCatCounts = [];
|
|
96953
96960
|
const schemaClassStarts = [];
|
|
96954
96961
|
const schemaClassCounts = [];
|
|
96955
|
-
// Deferred class data for cross-reference resolution
|
|
96962
|
+
// Deferred class data for cross-reference resolution (local to this fragment).
|
|
96956
96963
|
const pendingClasses = [];
|
|
96957
96964
|
// ---- PropertyDefTable ----
|
|
96958
96965
|
expectTag(reader, Tag.PropertyDefTable);
|
|
96959
96966
|
const defCount = reader.readU32();
|
|
96960
|
-
// Each PreParsedDef
|
|
96961
|
-
//
|
|
96962
|
-
reader.validateCount(defCount,
|
|
96967
|
+
// Each PreParsedDef is a fixed 46 bytes (10x u32 + 1x u16 + 4x u8). The bound is deliberately
|
|
96968
|
+
// about half that, so a valid blob never trips the check.
|
|
96969
|
+
reader.validateCount(defCount, 23, "PropertyDefTable");
|
|
96963
96970
|
const preParsedDefs = new Array(defCount);
|
|
96964
96971
|
for (let i = 0; i < defCount; i++) {
|
|
96965
96972
|
preParsedDefs[i] = {
|
|
@@ -96983,7 +96990,8 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
96983
96990
|
// ---- SchemaTable ----
|
|
96984
96991
|
expectTag(reader, Tag.SchemaTable);
|
|
96985
96992
|
const schemaCount = reader.readU32();
|
|
96986
|
-
|
|
96993
|
+
// Fixed 27 bytes per record (4x SRef + 3x u16 + u32 + u8).
|
|
96994
|
+
reader.validateCount(schemaCount, 13, "SchemaTable");
|
|
96987
96995
|
for (let i = 0; i < schemaCount; i++) {
|
|
96988
96996
|
const name = reader.readSRef();
|
|
96989
96997
|
const vRead = reader.readU16();
|
|
@@ -97010,7 +97018,7 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97010
97018
|
isHidden,
|
|
97011
97019
|
});
|
|
97012
97020
|
schemaEcIdToIdx.set(ecInstanceId, schemaIdx);
|
|
97013
|
-
|
|
97021
|
+
ctx.schemaNames[schemaIdx] = name;
|
|
97014
97022
|
schemaEnumStarts.push(0);
|
|
97015
97023
|
schemaEnumCounts.push(0);
|
|
97016
97024
|
schemaKoqStarts.push(0);
|
|
@@ -97020,25 +97028,31 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97020
97028
|
schemaClassStarts.push(0);
|
|
97021
97029
|
schemaClassCounts.push(0);
|
|
97022
97030
|
}
|
|
97023
|
-
/** Track an item's schema ownership and update range counters.
|
|
97031
|
+
/** Track an item's schema ownership and update its owning schema's range counters. `globalIdx`
|
|
97032
|
+
* is the item's global index in the builder; `starts`/`counts` are indexed by LOCAL schema index.
|
|
97033
|
+
* An item must be owned by a schema in its own fragment, so a foreign owner is a malformed blob. */
|
|
97024
97034
|
function trackItem(schemaEcId, globalIdx, starts, counts) {
|
|
97025
97035
|
const schemaIdx = schemaEcIdToIdx.get(schemaEcId);
|
|
97026
97036
|
if (schemaIdx === undefined)
|
|
97027
97037
|
throw new Error(`SchemaView blob: unknown schema ecInstanceId ${schemaEcId}`);
|
|
97028
|
-
|
|
97029
|
-
|
|
97030
|
-
|
|
97038
|
+
const localIdx = schemaIdx - schemaBaseIdx;
|
|
97039
|
+
if (localIdx < 0 || localIdx >= schemaCount)
|
|
97040
|
+
throw new Error(`SchemaView fragment: item references schema ecInstanceId ${schemaEcId} not present in this fragment`);
|
|
97041
|
+
if (counts[localIdx] === 0)
|
|
97042
|
+
starts[localIdx] = globalIdx;
|
|
97043
|
+
counts[localIdx]++;
|
|
97031
97044
|
return schemaIdx;
|
|
97032
97045
|
}
|
|
97033
97046
|
// ---- EnumTable ----
|
|
97034
97047
|
expectTag(reader, Tag.EnumTable);
|
|
97035
97048
|
const enumTotalCount = reader.readU32();
|
|
97036
|
-
|
|
97049
|
+
// Fixed 27 bytes per record (4x SRef + 2x u32 + u16 + u8); enumerators live inside a JSON SRef.
|
|
97050
|
+
reader.validateCount(enumTotalCount, 13, "EnumTable");
|
|
97037
97051
|
for (let i = 0; i < enumTotalCount; i++) {
|
|
97038
97052
|
const schemaEcId = reader.readU32();
|
|
97039
|
-
const schemaIdx = trackItem(schemaEcId,
|
|
97053
|
+
const schemaIdx = trackItem(schemaEcId, builder.enumerationCount, schemaEnumStarts, schemaEnumCounts);
|
|
97040
97054
|
const eName = reader.readSRef();
|
|
97041
|
-
const ePrimType = reader.
|
|
97055
|
+
const ePrimType = reader.readU16();
|
|
97042
97056
|
const eIsStrict = reader.readU8() !== 0;
|
|
97043
97057
|
const eLabel = reader.readSRef();
|
|
97044
97058
|
const eDesc = reader.readSRef();
|
|
@@ -97082,10 +97096,11 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97082
97096
|
// ---- KoQTable ----
|
|
97083
97097
|
expectTag(reader, Tag.KoQTable);
|
|
97084
97098
|
const koqTotalCount = reader.readU32();
|
|
97085
|
-
|
|
97099
|
+
// Fixed 36 bytes per record (6x SRef + f64 + u32).
|
|
97100
|
+
reader.validateCount(koqTotalCount, 18, "KoQTable");
|
|
97086
97101
|
for (let i = 0; i < koqTotalCount; i++) {
|
|
97087
97102
|
const schemaEcId = reader.readU32();
|
|
97088
|
-
const schemaIdx = trackItem(schemaEcId,
|
|
97103
|
+
const schemaIdx = trackItem(schemaEcId, builder.koqCount, schemaKoqStarts, schemaKoqCounts);
|
|
97089
97104
|
const kName = reader.readSRef();
|
|
97090
97105
|
const kLabel = reader.readSRef();
|
|
97091
97106
|
const kDesc = reader.readSRef();
|
|
@@ -97108,10 +97123,11 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97108
97123
|
// ---- PropCatTable ----
|
|
97109
97124
|
expectTag(reader, Tag.PropCatTable);
|
|
97110
97125
|
const catTotalCount = reader.readU32();
|
|
97111
|
-
|
|
97126
|
+
// Fixed 24 bytes per record (4x SRef + i32 + u32).
|
|
97127
|
+
reader.validateCount(catTotalCount, 12, "PropCatTable");
|
|
97112
97128
|
for (let i = 0; i < catTotalCount; i++) {
|
|
97113
97129
|
const schemaEcId = reader.readU32();
|
|
97114
|
-
const schemaIdx = trackItem(schemaEcId,
|
|
97130
|
+
const schemaIdx = trackItem(schemaEcId, builder.propCategoryCount, schemaCatStarts, schemaCatCounts);
|
|
97115
97131
|
const pcName = reader.readSRef();
|
|
97116
97132
|
const pcLabel = reader.readSRef();
|
|
97117
97133
|
const pcDesc = reader.readSRef();
|
|
@@ -97130,11 +97146,13 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97130
97146
|
// ---- ClassTable ----
|
|
97131
97147
|
expectTag(reader, Tag.ClassTable);
|
|
97132
97148
|
const classTotalCount = reader.readU32();
|
|
97133
|
-
|
|
97149
|
+
// Minimum 27 bytes per record (3x SRef + 3x u8 + u32 + 2x u16 count prefixes); records grow with
|
|
97150
|
+
// relationship strength/direction and the base-class, prop-ref, and constraint sub-lists.
|
|
97151
|
+
reader.validateCount(classTotalCount, 13, "ClassTable");
|
|
97134
97152
|
for (let i = 0; i < classTotalCount; i++) {
|
|
97135
97153
|
const schemaEcId = reader.readU32();
|
|
97136
|
-
const schemaIdx = trackItem(schemaEcId,
|
|
97137
|
-
const
|
|
97154
|
+
const schemaIdx = trackItem(schemaEcId, builder.classCount, schemaClassStarts, schemaClassCounts);
|
|
97155
|
+
const schemaName = ctx.schemaNames[schemaIdx];
|
|
97138
97156
|
const cName = reader.readSRef();
|
|
97139
97157
|
const cType = reader.readU8();
|
|
97140
97158
|
const cModifier = reader.readU8();
|
|
@@ -97224,7 +97242,7 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97224
97242
|
targetConstraintIdx: -1,
|
|
97225
97243
|
isHidden: cIsHidden,
|
|
97226
97244
|
});
|
|
97227
|
-
|
|
97245
|
+
classResolver.set(`${schemaName.toLowerCase()}:${cName.toLowerCase()}`, classIdx);
|
|
97228
97246
|
classRowIdToIdx.set(cEcInstanceId, classIdx);
|
|
97229
97247
|
pendingClasses.push({
|
|
97230
97248
|
schemaIdx,
|
|
@@ -97240,13 +97258,14 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97240
97258
|
baseClasses,
|
|
97241
97259
|
propRefs,
|
|
97242
97260
|
constraints,
|
|
97243
|
-
schemaName
|
|
97261
|
+
schemaName,
|
|
97244
97262
|
isHidden: cIsHidden,
|
|
97245
97263
|
});
|
|
97246
97264
|
}
|
|
97247
97265
|
// ---- Finalize per-schema item ranges ----
|
|
97266
|
+
// Local index i maps to global schema index schemaBaseIdx + i; range starts are already global.
|
|
97248
97267
|
for (let i = 0; i < schemaCount; i++) {
|
|
97249
|
-
builder.updateSchemaRanges(i, {
|
|
97268
|
+
builder.updateSchemaRanges(schemaBaseIdx + i, {
|
|
97250
97269
|
classRangeStart: schemaClassStarts[i] ?? 0,
|
|
97251
97270
|
classCount: schemaClassCounts[i] ?? 0,
|
|
97252
97271
|
enumRangeStart: schemaEnumStarts[i] ?? 0,
|
|
@@ -97257,12 +97276,6 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97257
97276
|
catCount: schemaCatCounts[i] ?? 0,
|
|
97258
97277
|
});
|
|
97259
97278
|
}
|
|
97260
|
-
// Build a global name resolver: "SchemaName:ClassName" -> classIdx
|
|
97261
|
-
const classResolver = new Map();
|
|
97262
|
-
for (const s of schemaInfos) {
|
|
97263
|
-
for (const [lowerName, idx] of s.classNameToIdx)
|
|
97264
|
-
classResolver.set(`${s.name.toLowerCase()}:${lowerName}`, idx);
|
|
97265
|
-
}
|
|
97266
97279
|
// Resolve pre-parsed defs to PropertyDef objects. Maps preParsedDef index -> builder defIdx.
|
|
97267
97280
|
const danglingRefs = [];
|
|
97268
97281
|
const resolvedDefMap = new Map();
|
|
@@ -97417,16 +97430,259 @@ function parseSchemaViewBlob(data, schemaToken) {
|
|
|
97417
97430
|
const lines = danglingRefs.length <= cap ? danglingRefs : [...danglingRefs.slice(0, cap), `... and ${danglingRefs.length - cap} more`];
|
|
97418
97431
|
_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Logger.logWarning("ecschema-metadata.SchemaView", `${danglingRefs.length} unresolved cross-reference(s) in schema view blob (likely from excluded schemas):\n ${lines.join("\n ")}`);
|
|
97419
97432
|
}
|
|
97420
|
-
|
|
97433
|
+
// Bring the builder's lookup maps up to date for the schemas this fragment added. Their item
|
|
97434
|
+
// ranges were finalized above, so the per-schema name maps build correctly.
|
|
97435
|
+
builder.extendLookupMaps();
|
|
97421
97436
|
}
|
|
97422
97437
|
|
|
97423
97438
|
|
|
97424
97439
|
/***/ },
|
|
97425
97440
|
|
|
97426
|
-
/***/ "../../core/ecschema-metadata/lib/esm/
|
|
97427
|
-
|
|
97428
|
-
!*** ../../core/ecschema-metadata/lib/esm/
|
|
97429
|
-
|
|
97441
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBuilder.js"
|
|
97442
|
+
/*!****************************************************************************!*\
|
|
97443
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBuilder.js ***!
|
|
97444
|
+
\****************************************************************************/
|
|
97445
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
97446
|
+
|
|
97447
|
+
"use strict";
|
|
97448
|
+
__webpack_require__.r(__webpack_exports__);
|
|
97449
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
97450
|
+
/* harmony export */ SchemaViewBuilder: () => (/* binding */ SchemaViewBuilder)
|
|
97451
|
+
/* harmony export */ });
|
|
97452
|
+
/* harmony import */ var _SchemaView__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaView */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaView.js");
|
|
97453
|
+
/*---------------------------------------------------------------------------------------------
|
|
97454
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
97455
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
97456
|
+
*--------------------------------------------------------------------------------------------*/
|
|
97457
|
+
/** @packageDocumentation
|
|
97458
|
+
* @module Schema
|
|
97459
|
+
*/
|
|
97460
|
+
|
|
97461
|
+
/** Builder for constructing an immutable `SchemaView`.
|
|
97462
|
+
*
|
|
97463
|
+
* Collects data during binary blob parsing, then freezes it into a view.
|
|
97464
|
+
* Handles string interning and property definition deduplication.
|
|
97465
|
+
*
|
|
97466
|
+
* Consumers should not use this directly - read views via `IModelDb.getSchemaView`
|
|
97467
|
+
* / `IModelConnection.getSchemaView` (or `SchemaView.fromBinary` if you have a raw blob).
|
|
97468
|
+
* @internal
|
|
97469
|
+
*/
|
|
97470
|
+
class SchemaViewBuilder {
|
|
97471
|
+
_strings = [""]; // SID 0 = empty string
|
|
97472
|
+
_lowerStrings = [""];
|
|
97473
|
+
_stringMap = new Map(); // original value -> SID
|
|
97474
|
+
_schemas = [];
|
|
97475
|
+
_classes = [];
|
|
97476
|
+
_classMixins = [];
|
|
97477
|
+
_propDefs = [];
|
|
97478
|
+
_propertyRefs = [];
|
|
97479
|
+
_relConstraints = [];
|
|
97480
|
+
_constraintClassRefs = [];
|
|
97481
|
+
_enumerations = [];
|
|
97482
|
+
_enumerators = [];
|
|
97483
|
+
_koqs = [];
|
|
97484
|
+
_propCategories = [];
|
|
97485
|
+
// For PropertyDef dedup
|
|
97486
|
+
_propDefMap = new Map(); // signature string -> defIdx
|
|
97487
|
+
// Lookup maps - owned by the builder so a husk can share and extend them across fragment merges.
|
|
97488
|
+
// `build()` and each merge call `extendLookupMaps()`; the view receives these same Map objects
|
|
97489
|
+
// via `assembleData()`, so in-place growth is visible.
|
|
97490
|
+
_schemaByName = new Map();
|
|
97491
|
+
_schemaByAlias = new Map();
|
|
97492
|
+
_classByName = new Map();
|
|
97493
|
+
_enumByName = new Map();
|
|
97494
|
+
_koqByName = new Map();
|
|
97495
|
+
_catByName = new Map();
|
|
97496
|
+
_lookupMapsBuiltUpto = 0; // number of schemas whose lookup entries are already built
|
|
97497
|
+
/** Intern a string, returning its SID. Empty/undefined strings return 0.
|
|
97498
|
+
* Interning is case-sensitive - "MyLabel" and "MYLABEL" get distinct SIDs.
|
|
97499
|
+
* The `lowerStrings` array provides case-insensitive lookup without mutating display values.
|
|
97500
|
+
*/
|
|
97501
|
+
internString(value) {
|
|
97502
|
+
if (value === undefined || value === "")
|
|
97503
|
+
return 0;
|
|
97504
|
+
const existing = this._stringMap.get(value);
|
|
97505
|
+
if (existing !== undefined)
|
|
97506
|
+
return existing;
|
|
97507
|
+
const sid = this._strings.length;
|
|
97508
|
+
this._strings.push(value);
|
|
97509
|
+
this._lowerStrings.push(value.toLowerCase());
|
|
97510
|
+
this._stringMap.set(value, sid);
|
|
97511
|
+
return sid;
|
|
97512
|
+
}
|
|
97513
|
+
/** Add a schema. Returns its index. */
|
|
97514
|
+
addSchema(data) {
|
|
97515
|
+
const idx = this._schemas.length;
|
|
97516
|
+
this._schemas.push(data);
|
|
97517
|
+
return idx;
|
|
97518
|
+
}
|
|
97519
|
+
/** Add a class. Returns its index. Must be called after the owning schema. */
|
|
97520
|
+
addClass(data) {
|
|
97521
|
+
const idx = this._classes.length;
|
|
97522
|
+
this._classes.push(data);
|
|
97523
|
+
return idx;
|
|
97524
|
+
}
|
|
97525
|
+
/** Add a property definition with deduplication. Returns the def index (possibly existing). */
|
|
97526
|
+
addPropertyDef(data) {
|
|
97527
|
+
const sig = this._propDefSignature(data);
|
|
97528
|
+
const existing = this._propDefMap.get(sig);
|
|
97529
|
+
if (existing !== undefined)
|
|
97530
|
+
return existing;
|
|
97531
|
+
const idx = this._propDefs.length;
|
|
97532
|
+
this._propDefs.push(data);
|
|
97533
|
+
this._propDefMap.set(sig, idx);
|
|
97534
|
+
return idx;
|
|
97535
|
+
}
|
|
97536
|
+
/** Append a property reference to the flat refs array. */
|
|
97537
|
+
addPropertyRef(ref) {
|
|
97538
|
+
this._propertyRefs.push(ref);
|
|
97539
|
+
}
|
|
97540
|
+
/** Add an enumeration. Returns its index. */
|
|
97541
|
+
addEnumeration(data) {
|
|
97542
|
+
const idx = this._enumerations.length;
|
|
97543
|
+
this._enumerations.push(data);
|
|
97544
|
+
return idx;
|
|
97545
|
+
}
|
|
97546
|
+
/** Append an enumerator to the flat enumerators array. */
|
|
97547
|
+
addEnumerator(data) {
|
|
97548
|
+
this._enumerators.push(data);
|
|
97549
|
+
}
|
|
97550
|
+
/** Add a KindOfQuantity. Returns its index. */
|
|
97551
|
+
addKoq(data) {
|
|
97552
|
+
const idx = this._koqs.length;
|
|
97553
|
+
this._koqs.push(data);
|
|
97554
|
+
return idx;
|
|
97555
|
+
}
|
|
97556
|
+
/** Add a PropertyCategory. Returns its index. */
|
|
97557
|
+
addPropertyCategory(data) {
|
|
97558
|
+
const idx = this._propCategories.length;
|
|
97559
|
+
this._propCategories.push(data);
|
|
97560
|
+
return idx;
|
|
97561
|
+
}
|
|
97562
|
+
/** Add a relationship constraint. Returns its index. */
|
|
97563
|
+
addRelConstraint(data) {
|
|
97564
|
+
const idx = this._relConstraints.length;
|
|
97565
|
+
this._relConstraints.push(data);
|
|
97566
|
+
return idx;
|
|
97567
|
+
}
|
|
97568
|
+
/** Append a constraint class reference to the flat array. */
|
|
97569
|
+
addConstraintClassRef(classIdx) {
|
|
97570
|
+
this._constraintClassRefs.push(classIdx);
|
|
97571
|
+
}
|
|
97572
|
+
/** Append a mixin class reference to the flat array. */
|
|
97573
|
+
addClassMixin(classIdx) {
|
|
97574
|
+
this._classMixins.push(classIdx);
|
|
97575
|
+
}
|
|
97576
|
+
/** The current count of property refs (used to set ownPropStart on ClassData). */
|
|
97577
|
+
get propertyRefCount() { return this._propertyRefs.length; }
|
|
97578
|
+
/** The current count of enumerators (used to set enumeratorStart on EnumerationData). */
|
|
97579
|
+
get enumeratorCount() { return this._enumerators.length; }
|
|
97580
|
+
/** The current count of constraint class refs (used to set classRefStart). */
|
|
97581
|
+
get constraintClassRefCount() { return this._constraintClassRefs.length; }
|
|
97582
|
+
/** The current count of class mixins (used to set mixinStartIdx). */
|
|
97583
|
+
get classMixinCount() { return this._classMixins.length; }
|
|
97584
|
+
// The counts below are the base indices fragment merging uses to translate a fragment's local
|
|
97585
|
+
// indices into global ones.
|
|
97586
|
+
/** The current count of schemas. @internal */
|
|
97587
|
+
get schemaCount() { return this._schemas.length; }
|
|
97588
|
+
/** The current count of classes. @internal */
|
|
97589
|
+
get classCount() { return this._classes.length; }
|
|
97590
|
+
/** The current count of enumerations. @internal */
|
|
97591
|
+
get enumerationCount() { return this._enumerations.length; }
|
|
97592
|
+
/** The current count of KindOfQuantities. @internal */
|
|
97593
|
+
get koqCount() { return this._koqs.length; }
|
|
97594
|
+
/** The current count of property categories. @internal */
|
|
97595
|
+
get propCategoryCount() { return this._propCategories.length; }
|
|
97596
|
+
/** Get a string by SID. @internal */
|
|
97597
|
+
getString(sid) { return this._strings[sid]; }
|
|
97598
|
+
/** Replace class data at the given index (used during deferred cross-ref resolution). @internal */
|
|
97599
|
+
updateClass(classIdx, data) { this._classes[classIdx] = data; }
|
|
97600
|
+
/** Update range fields on a schema (used after all items for a schema are collected). @internal */
|
|
97601
|
+
updateSchemaRanges(schemaIdx, ranges) {
|
|
97602
|
+
const s = this._schemas[schemaIdx];
|
|
97603
|
+
this._schemas[schemaIdx] = { ...s, ...ranges };
|
|
97604
|
+
}
|
|
97605
|
+
/** Freeze all data and produce an immutable SchemaView. */
|
|
97606
|
+
build(schemaToken) {
|
|
97607
|
+
this.extendLookupMaps();
|
|
97608
|
+
return new _SchemaView__WEBPACK_IMPORTED_MODULE_0__.SchemaView(this.assembleData(), schemaToken);
|
|
97609
|
+
}
|
|
97610
|
+
/** Build lookup-map entries for any schemas added since the last call. Idempotent and
|
|
97611
|
+
* append-only, so it is safe to call after each fragment merge. A schema's item ranges must
|
|
97612
|
+
* already be finalized (via `updateSchemaRanges`) before it is processed.
|
|
97613
|
+
* @internal */
|
|
97614
|
+
extendLookupMaps() {
|
|
97615
|
+
for (let i = this._lookupMapsBuiltUpto; i < this._schemas.length; i++) {
|
|
97616
|
+
const s = this._schemas[i];
|
|
97617
|
+
this._schemaByName.set(this._lowerStrings[s.nameStringIdx], i);
|
|
97618
|
+
if (s.aliasStringIdx !== 0)
|
|
97619
|
+
this._schemaByAlias.set(this._lowerStrings[s.aliasStringIdx], i);
|
|
97620
|
+
// Build class-by-name map for this schema
|
|
97621
|
+
const classMap = new Map();
|
|
97622
|
+
for (let c = s.classRangeStart; c < s.classRangeStart + s.classCount; c++)
|
|
97623
|
+
classMap.set(this._lowerStrings[this._classes[c].nameStringIdx], c);
|
|
97624
|
+
this._classByName.set(i, classMap);
|
|
97625
|
+
// Build enum-by-name map for this schema
|
|
97626
|
+
const eMap = new Map();
|
|
97627
|
+
for (let e = s.enumRangeStart; e < s.enumRangeStart + s.enumCount; e++)
|
|
97628
|
+
eMap.set(this._lowerStrings[this._enumerations[e].nameStringIdx], e);
|
|
97629
|
+
this._enumByName.set(i, eMap);
|
|
97630
|
+
// Build koq-by-name map for this schema
|
|
97631
|
+
const kMap = new Map();
|
|
97632
|
+
for (let k = s.koqRangeStart; k < s.koqRangeStart + s.koqCount; k++)
|
|
97633
|
+
kMap.set(this._lowerStrings[this._koqs[k].nameStringIdx], k);
|
|
97634
|
+
this._koqByName.set(i, kMap);
|
|
97635
|
+
// Build category-by-name map for this schema
|
|
97636
|
+
const cMap = new Map();
|
|
97637
|
+
for (let p = s.catRangeStart; p < s.catRangeStart + s.catCount; p++)
|
|
97638
|
+
cMap.set(this._lowerStrings[this._propCategories[p].nameStringIdx], p);
|
|
97639
|
+
this._catByName.set(i, cMap);
|
|
97640
|
+
}
|
|
97641
|
+
this._lookupMapsBuiltUpto = this._schemas.length;
|
|
97642
|
+
}
|
|
97643
|
+
/** Assemble a {@link SchemaViewData} bag that references this builder's live arrays and lookup
|
|
97644
|
+
* maps. Continued building - fragment merges that append to the arrays and extend the maps in
|
|
97645
|
+
* place - is visible through the shared references, so a husk holding this data sees merged
|
|
97646
|
+
* schemas without rebuilding. @internal */
|
|
97647
|
+
assembleData() {
|
|
97648
|
+
return {
|
|
97649
|
+
strings: this._strings,
|
|
97650
|
+
lowerStrings: this._lowerStrings,
|
|
97651
|
+
schemas: this._schemas,
|
|
97652
|
+
classes: this._classes,
|
|
97653
|
+
classMixins: this._classMixins,
|
|
97654
|
+
propDefs: this._propDefs,
|
|
97655
|
+
propertyRefs: this._propertyRefs,
|
|
97656
|
+
relConstraints: this._relConstraints,
|
|
97657
|
+
constraintClassRefs: this._constraintClassRefs,
|
|
97658
|
+
enumerations: this._enumerations,
|
|
97659
|
+
enumerators: this._enumerators,
|
|
97660
|
+
koqs: this._koqs,
|
|
97661
|
+
propCategories: this._propCategories,
|
|
97662
|
+
schemaByName: this._schemaByName,
|
|
97663
|
+
schemaByAlias: this._schemaByAlias,
|
|
97664
|
+
classByName: this._classByName,
|
|
97665
|
+
enumByName: this._enumByName,
|
|
97666
|
+
koqByName: this._koqByName,
|
|
97667
|
+
catByName: this._catByName,
|
|
97668
|
+
};
|
|
97669
|
+
}
|
|
97670
|
+
/** Produce a dedup signature for a PropertyDef. Label and priority are excluded because
|
|
97671
|
+
* they are per-PropertyRef overrides, not part of the structural definition.
|
|
97672
|
+
* Uses SIDs (not lowercase strings) for name/description so that case-preserving names
|
|
97673
|
+
* stay distinct - matching the C++ writer's dedup behavior. */
|
|
97674
|
+
_propDefSignature(def) {
|
|
97675
|
+
return `${def.nameStringIdx}|${def.kind}|${def.primitiveType}|${def.extTypeStringIdx}|${def.enumIdx}|${def.koqIdx}|${def.structClassIdx}|${def.navRelClassIdx}|${def.navDirection}|${def.categoryIdx}|${def.isReadOnly ? 1 : 0}|${def.isHidden ? 1 : 0}|${def.arrayMinOccurs}|${def.arrayMaxOccurs}|${def.descriptionStringIdx}`;
|
|
97676
|
+
}
|
|
97677
|
+
}
|
|
97678
|
+
|
|
97679
|
+
|
|
97680
|
+
/***/ },
|
|
97681
|
+
|
|
97682
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewInterfaces.js"
|
|
97683
|
+
/*!*******************************************************************************!*\
|
|
97684
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewInterfaces.js ***!
|
|
97685
|
+
\*******************************************************************************/
|
|
97430
97686
|
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
97431
97687
|
|
|
97432
97688
|
"use strict";
|
|
@@ -97505,6 +97761,201 @@ var SchemaViewPrimitiveType;
|
|
|
97505
97761
|
})(SchemaViewPrimitiveType || (SchemaViewPrimitiveType = {}));
|
|
97506
97762
|
|
|
97507
97763
|
|
|
97764
|
+
/***/ },
|
|
97765
|
+
|
|
97766
|
+
/***/ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewManager.js"
|
|
97767
|
+
/*!****************************************************************************!*\
|
|
97768
|
+
!*** ../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewManager.js ***!
|
|
97769
|
+
\****************************************************************************/
|
|
97770
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
97771
|
+
|
|
97772
|
+
"use strict";
|
|
97773
|
+
__webpack_require__.r(__webpack_exports__);
|
|
97774
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
97775
|
+
/* harmony export */ SchemaViewManager: () => (/* binding */ SchemaViewManager)
|
|
97776
|
+
/* harmony export */ });
|
|
97777
|
+
/* harmony import */ var _SchemaView__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SchemaView */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaView.js");
|
|
97778
|
+
/*---------------------------------------------------------------------------------------------
|
|
97779
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
97780
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
97781
|
+
*--------------------------------------------------------------------------------------------*/
|
|
97782
|
+
/** @packageDocumentation
|
|
97783
|
+
* @module Schema
|
|
97784
|
+
*/
|
|
97785
|
+
|
|
97786
|
+
/** Owns the lifetime of one iModel's {@link (SchemaView:class)}: lazy loading, incremental (filtered)
|
|
97787
|
+
* hydration, serialization of concurrent requests, and invalidation. Hosts (`IModelDb`,
|
|
97788
|
+
* `IModelConnection`) hold one instance and delegate to it; all data access goes through the
|
|
97789
|
+
* host-implemented {@link SchemaViewDataProvider}.
|
|
97790
|
+
* @internal
|
|
97791
|
+
*/
|
|
97792
|
+
class SchemaViewManager {
|
|
97793
|
+
_dataProvider;
|
|
97794
|
+
/** The single accumulating view, held as a promise so all requests chain onto it and never overlap.
|
|
97795
|
+
* Undefined (or resolving to undefined) means nothing is loaded. */
|
|
97796
|
+
_viewPromise;
|
|
97797
|
+
/** Reference graph for incremental loading; undefined when the view is (or will be) fully loaded. */
|
|
97798
|
+
_manifest;
|
|
97799
|
+
/** Schema-identity token the manifest - and thus every fragment merged under it - belongs to. */
|
|
97800
|
+
_manifestToken;
|
|
97801
|
+
/** Lower-cased names already merged into the view (incremental mode only). */
|
|
97802
|
+
_loadedSchemaNames = new Set();
|
|
97803
|
+
constructor(dataProvider) {
|
|
97804
|
+
this._dataProvider = dataProvider;
|
|
97805
|
+
}
|
|
97806
|
+
/** Get the schema view, loading whatever the request needs that is not present yet. See
|
|
97807
|
+
* {@link GetSchemaViewArgs} for filtering and reload semantics; hosts document the full
|
|
97808
|
+
* user-facing contract on their `getSchemaView` methods.
|
|
97809
|
+
*/
|
|
97810
|
+
async getSchemaView(args) {
|
|
97811
|
+
const previous = this._viewPromise;
|
|
97812
|
+
const next = this._loadSchemaView(previous, args?.schemas, args?.forceReload === true);
|
|
97813
|
+
this._viewPromise = next;
|
|
97814
|
+
return next;
|
|
97815
|
+
}
|
|
97816
|
+
/** Throw away the current schema view. Called by the host when schemas may have changed (e.g.
|
|
97817
|
+
* `IModelDb.clearCaches` after a schema import). Chains behind any in-flight load and marks the
|
|
97818
|
+
* discarded view outdated; the next getSchemaView starts over.
|
|
97819
|
+
*/
|
|
97820
|
+
reset() {
|
|
97821
|
+
if (this._viewPromise) {
|
|
97822
|
+
this._viewPromise = this._viewPromise.then((view) => { view?.markOutdated(); this._resetIncrementalState(); return undefined; }, () => { this._resetIncrementalState(); return undefined; });
|
|
97823
|
+
}
|
|
97824
|
+
}
|
|
97825
|
+
/** Check whether the iModel's schemas have changed since the current view was built, and discard
|
|
97826
|
+
* the view only if they have. For hosts that *cannot* determine whether an operation actually
|
|
97827
|
+
* modified schemas - e.g. `BriefcaseConnection.pullChanges` on the frontend, whose IPC response
|
|
97828
|
+
* carries only the new changeset id, not the applied changesets' types. Discarding after every
|
|
97829
|
+
* such operation would reload unnecessarily in the common case where schemas are unchanged, so
|
|
97830
|
+
* this compares the cheap schema-identity token instead.
|
|
97831
|
+
* @note If the token cannot be fetched, the view is discarded rather than risking stale metadata.
|
|
97832
|
+
*/
|
|
97833
|
+
async invalidateIfChanged() {
|
|
97834
|
+
const previous = this._viewPromise;
|
|
97835
|
+
if (previous === undefined)
|
|
97836
|
+
return;
|
|
97837
|
+
// Queue the check on the same chain as loading, so a getSchemaView arriving while the token is
|
|
97838
|
+
// in flight cannot swap in a new promise for the same stale view and hide the schema change.
|
|
97839
|
+
const next = this._invalidateIfChanged(previous);
|
|
97840
|
+
this._viewPromise = next;
|
|
97841
|
+
await next;
|
|
97842
|
+
}
|
|
97843
|
+
/** Serialized body of {@link SchemaViewManager.invalidateIfChanged}. Resolves to the view to keep,
|
|
97844
|
+
* or to `undefined` when it was discarded and the next getSchemaView has to start over.
|
|
97845
|
+
*/
|
|
97846
|
+
async _invalidateIfChanged(previous) {
|
|
97847
|
+
let existing;
|
|
97848
|
+
try {
|
|
97849
|
+
existing = await previous;
|
|
97850
|
+
}
|
|
97851
|
+
catch {
|
|
97852
|
+
return undefined;
|
|
97853
|
+
}
|
|
97854
|
+
if (existing === undefined)
|
|
97855
|
+
return undefined;
|
|
97856
|
+
// A view without a token (e.g. built directly from a SchemaViewBuilder) cannot be verified by
|
|
97857
|
+
// token; views loaded through this manager always carry one.
|
|
97858
|
+
if (existing.schemaToken === "")
|
|
97859
|
+
return existing;
|
|
97860
|
+
try {
|
|
97861
|
+
if (await this._dataProvider.fetchSchemaToken() === existing.schemaToken)
|
|
97862
|
+
return existing;
|
|
97863
|
+
}
|
|
97864
|
+
catch {
|
|
97865
|
+
// Cannot verify the cached view: drop it rather than risk stale metadata.
|
|
97866
|
+
}
|
|
97867
|
+
existing.markOutdated();
|
|
97868
|
+
this._resetIncrementalState();
|
|
97869
|
+
return undefined;
|
|
97870
|
+
}
|
|
97871
|
+
/** Serialized body of {@link SchemaViewManager.getSchemaView}. On failure it resets and rejects,
|
|
97872
|
+
* so the next call starts over.
|
|
97873
|
+
*/
|
|
97874
|
+
async _loadSchemaView(previous, schemas, forceReload) {
|
|
97875
|
+
let currentView;
|
|
97876
|
+
if (previous !== undefined) {
|
|
97877
|
+
try {
|
|
97878
|
+
currentView = await previous;
|
|
97879
|
+
}
|
|
97880
|
+
catch {
|
|
97881
|
+
currentView = undefined; // the failed load already reset; start over
|
|
97882
|
+
}
|
|
97883
|
+
}
|
|
97884
|
+
if (forceReload) {
|
|
97885
|
+
currentView?.markOutdated();
|
|
97886
|
+
currentView = undefined;
|
|
97887
|
+
this._resetIncrementalState();
|
|
97888
|
+
}
|
|
97889
|
+
try {
|
|
97890
|
+
return await this._ensureSchemasLoaded(currentView, schemas);
|
|
97891
|
+
}
|
|
97892
|
+
catch (err) {
|
|
97893
|
+
// A failed merge may have left the view partially extended - discard everything.
|
|
97894
|
+
currentView?.markOutdated();
|
|
97895
|
+
this._resetIncrementalState();
|
|
97896
|
+
throw err;
|
|
97897
|
+
}
|
|
97898
|
+
}
|
|
97899
|
+
/** Clear the incremental schema-view bookkeeping. */
|
|
97900
|
+
_resetIncrementalState() {
|
|
97901
|
+
this._manifest = undefined;
|
|
97902
|
+
this._manifestToken = undefined;
|
|
97903
|
+
this._loadedSchemaNames.clear();
|
|
97904
|
+
}
|
|
97905
|
+
/** Ensures the requested schemas (or all schemas, when no filter is given) are present in
|
|
97906
|
+
* `currentView` (or a freshly created view) and returns it. The first load fixes the strategy:
|
|
97907
|
+
* no filter fetches everything as one full blob; a filter fetches fragments and keeps the
|
|
97908
|
+
* manifest and loaded-name set so later calls extend the same view. Once every schema is loaded
|
|
97909
|
+
* the incremental state is dropped, collapsing back to full mode.
|
|
97910
|
+
*/
|
|
97911
|
+
async _ensureSchemasLoaded(currentView, schemas, isRetry = false) {
|
|
97912
|
+
const isFirstLoad = currentView === undefined;
|
|
97913
|
+
// No manifest means everything is loaded; in incremental mode a filtered request is satisfied as
|
|
97914
|
+
// soon as every requested name is present.
|
|
97915
|
+
if (!isFirstLoad &&
|
|
97916
|
+
(this._manifest === undefined ||
|
|
97917
|
+
(schemas !== undefined && schemas.every((name) => this._loadedSchemaNames.has(name.toLowerCase())))))
|
|
97918
|
+
return currentView;
|
|
97919
|
+
if (isFirstLoad && schemas === undefined) {
|
|
97920
|
+
const blob = await this._dataProvider.fetchFullBlob();
|
|
97921
|
+
const schemaView = _SchemaView__WEBPACK_IMPORTED_MODULE_0__.SchemaView.fromBinary(blob.data, blob.schemaToken);
|
|
97922
|
+
this._resetIncrementalState();
|
|
97923
|
+
return schemaView;
|
|
97924
|
+
}
|
|
97925
|
+
if (this._manifest === undefined) {
|
|
97926
|
+
// Token first: any schema change after this point shows up as a token mismatch below.
|
|
97927
|
+
this._manifestToken = await this._dataProvider.fetchSchemaToken();
|
|
97928
|
+
this._manifest = await this._dataProvider.fetchManifest();
|
|
97929
|
+
}
|
|
97930
|
+
const manifest = this._manifest;
|
|
97931
|
+
const requested = schemas ?? manifest.getAvailableSchemaNames();
|
|
97932
|
+
const namesToLoad = manifest.getSchemaClosure(requested).filter((name) => !this._loadedSchemaNames.has(name.toLowerCase()));
|
|
97933
|
+
const husk = currentView ?? _SchemaView__WEBPACK_IMPORTED_MODULE_0__.SchemaView.createMergeable(this._manifestToken);
|
|
97934
|
+
if (namesToLoad.length > 0) {
|
|
97935
|
+
const blob = await this._dataProvider.fetchFragmentBlob(namesToLoad);
|
|
97936
|
+
if (blob.schemaToken !== this._manifestToken) {
|
|
97937
|
+
// Schemas changed between the manifest and fragment fetches. Everything loaded so far
|
|
97938
|
+
// belongs to the old revision - discard it and start over, once.
|
|
97939
|
+
currentView?.markOutdated();
|
|
97940
|
+
this._resetIncrementalState();
|
|
97941
|
+
if (isRetry)
|
|
97942
|
+
throw new Error("The iModel's schemas changed while the schema view was loading.");
|
|
97943
|
+
return this._ensureSchemasLoaded(undefined, schemas, true);
|
|
97944
|
+
}
|
|
97945
|
+
husk.mergeFragment(blob.data);
|
|
97946
|
+
// Record the whole closure as loaded, including *excluded* schemas (e.g. CoreCustomAttributes)
|
|
97947
|
+
// the writer emits no rows for, so later requests prune them instead of re-fetching.
|
|
97948
|
+
for (const name of namesToLoad)
|
|
97949
|
+
this._loadedSchemaNames.add(name.toLowerCase());
|
|
97950
|
+
}
|
|
97951
|
+
// Once every schema is loaded, collapse back to full mode (the size check is just a fast path).
|
|
97952
|
+
if (schemas === undefined || (this._loadedSchemaNames.size >= manifest.schemaCount && manifest.entries.every((entry) => this._loadedSchemaNames.has(entry.name.toLowerCase()))))
|
|
97953
|
+
this._resetIncrementalState();
|
|
97954
|
+
return husk;
|
|
97955
|
+
}
|
|
97956
|
+
}
|
|
97957
|
+
|
|
97958
|
+
|
|
97508
97959
|
/***/ },
|
|
97509
97960
|
|
|
97510
97961
|
/***/ "../../core/ecschema-metadata/lib/esm/UnitConversion/UnitConverter.js"
|
|
@@ -98215,8 +98666,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98215
98666
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
98216
98667
|
/* harmony export */ AbstractSchemaItemType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.AbstractSchemaItemType),
|
|
98217
98668
|
/* harmony export */ ArrayProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.ArrayProperty),
|
|
98218
|
-
/* harmony export */ ClassModifier: () => (/* reexport safe */
|
|
98219
|
-
/* harmony export */ ClassType: () => (/* reexport safe */
|
|
98669
|
+
/* harmony export */ ClassModifier: () => (/* reexport safe */ _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__.ClassModifier),
|
|
98670
|
+
/* harmony export */ ClassType: () => (/* reexport safe */ _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__.ClassType),
|
|
98220
98671
|
/* harmony export */ Constant: () => (/* reexport safe */ _Metadata_Constant__WEBPACK_IMPORTED_MODULE_12__.Constant),
|
|
98221
98672
|
/* harmony export */ CustomAttributeClass: () => (/* reexport safe */ _Metadata_CustomAttributeClass__WEBPACK_IMPORTED_MODULE_13__.CustomAttributeClass),
|
|
98222
98673
|
/* harmony export */ CustomAttributeContainerType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.CustomAttributeContainerType),
|
|
@@ -98240,7 +98691,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98240
98691
|
/* harmony export */ IncrementalSchemaLocater: () => (/* reexport safe */ _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__.IncrementalSchemaLocater),
|
|
98241
98692
|
/* harmony export */ InvertedUnit: () => (/* reexport safe */ _Metadata_InvertedUnit__WEBPACK_IMPORTED_MODULE_17__.InvertedUnit),
|
|
98242
98693
|
/* harmony export */ KindOfQuantity: () => (/* reexport safe */ _Metadata_KindOfQuantity__WEBPACK_IMPORTED_MODULE_18__.KindOfQuantity),
|
|
98243
|
-
/* harmony export */ LocalizationProvider: () => (/* reexport safe */
|
|
98694
|
+
/* harmony export */ LocalizationProvider: () => (/* reexport safe */ _Localization_LocalizationProvider__WEBPACK_IMPORTED_MODULE_49__.LocalizationProvider),
|
|
98244
98695
|
/* harmony export */ Mixin: () => (/* reexport safe */ _Metadata_Mixin__WEBPACK_IMPORTED_MODULE_19__.Mixin),
|
|
98245
98696
|
/* harmony export */ NavigationProperty: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.NavigationProperty),
|
|
98246
98697
|
/* harmony export */ OverrideFormat: () => (/* reexport safe */ _Metadata_OverrideFormat__WEBPACK_IMPORTED_MODULE_20__.OverrideFormat),
|
|
@@ -98251,7 +98702,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98251
98702
|
/* harmony export */ PrimitiveType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.PrimitiveType),
|
|
98252
98703
|
/* harmony export */ Property: () => (/* reexport safe */ _Metadata_Property__WEBPACK_IMPORTED_MODULE_22__.Property),
|
|
98253
98704
|
/* harmony export */ PropertyCategory: () => (/* reexport safe */ _Metadata_PropertyCategory__WEBPACK_IMPORTED_MODULE_23__.PropertyCategory),
|
|
98254
|
-
/* harmony export */ PropertyKind: () => (/* reexport safe */
|
|
98705
|
+
/* harmony export */ PropertyKind: () => (/* reexport safe */ _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__.PropertyKind),
|
|
98255
98706
|
/* harmony export */ PropertyType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.PropertyType),
|
|
98256
98707
|
/* harmony export */ PropertyTypeUtils: () => (/* reexport safe */ _PropertyTypes__WEBPACK_IMPORTED_MODULE_29__.PropertyTypeUtils),
|
|
98257
98708
|
/* harmony export */ RelationshipClass: () => (/* reexport safe */ _Metadata_RelationshipClass__WEBPACK_IMPORTED_MODULE_24__.RelationshipClass),
|
|
@@ -98270,14 +98721,17 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98270
98721
|
/* harmony export */ SchemaJsonLocater: () => (/* reexport safe */ _SchemaJsonLocater__WEBPACK_IMPORTED_MODULE_30__.SchemaJsonLocater),
|
|
98271
98722
|
/* harmony export */ SchemaKey: () => (/* reexport safe */ _SchemaKey__WEBPACK_IMPORTED_MODULE_31__.SchemaKey),
|
|
98272
98723
|
/* harmony export */ SchemaLoader: () => (/* reexport safe */ _SchemaLoader__WEBPACK_IMPORTED_MODULE_32__.SchemaLoader),
|
|
98273
|
-
/* harmony export */ SchemaLocalization: () => (/* reexport safe */
|
|
98724
|
+
/* harmony export */ SchemaLocalization: () => (/* reexport safe */ _Localization_SchemaLocalization__WEBPACK_IMPORTED_MODULE_50__.SchemaLocalization),
|
|
98725
|
+
/* harmony export */ SchemaManifest: () => (/* reexport safe */ _SchemaView_SchemaManifest__WEBPACK_IMPORTED_MODULE_46__.SchemaManifest),
|
|
98274
98726
|
/* harmony export */ SchemaMatchType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.SchemaMatchType),
|
|
98275
98727
|
/* harmony export */ SchemaPartVisitorDelegate: () => (/* reexport safe */ _SchemaPartVisitorDelegate__WEBPACK_IMPORTED_MODULE_36__.SchemaPartVisitorDelegate),
|
|
98276
98728
|
/* harmony export */ SchemaReadHelper: () => (/* reexport safe */ _Deserialization_Helper__WEBPACK_IMPORTED_MODULE_5__.SchemaReadHelper),
|
|
98277
98729
|
/* harmony export */ SchemaUnitProvider: () => (/* reexport safe */ _UnitProvider_SchemaUnitProvider__WEBPACK_IMPORTED_MODULE_34__.SchemaUnitProvider),
|
|
98278
|
-
/* harmony export */ SchemaView: () => (/* reexport safe */
|
|
98279
|
-
/* harmony export */ SchemaViewBuilder: () => (/* reexport safe */
|
|
98280
|
-
/* harmony export */
|
|
98730
|
+
/* harmony export */ SchemaView: () => (/* reexport safe */ _SchemaView_SchemaView__WEBPACK_IMPORTED_MODULE_43__.SchemaView),
|
|
98731
|
+
/* harmony export */ SchemaViewBuilder: () => (/* reexport safe */ _SchemaView_SchemaViewBuilder__WEBPACK_IMPORTED_MODULE_44__.SchemaViewBuilder),
|
|
98732
|
+
/* harmony export */ SchemaViewManager: () => (/* reexport safe */ _SchemaView_SchemaViewManager__WEBPACK_IMPORTED_MODULE_47__.SchemaViewManager),
|
|
98733
|
+
/* harmony export */ SchemaViewMergeContext: () => (/* reexport safe */ _SchemaView_SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_42__.SchemaViewMergeContext),
|
|
98734
|
+
/* harmony export */ SchemaViewPrimitiveType: () => (/* reexport safe */ _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__.SchemaViewPrimitiveType),
|
|
98281
98735
|
/* harmony export */ SchemaWalker: () => (/* reexport safe */ _Validation_SchemaWalker__WEBPACK_IMPORTED_MODULE_35__.SchemaWalker),
|
|
98282
98736
|
/* harmony export */ StrengthDirection: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthDirection),
|
|
98283
98737
|
/* harmony export */ StrengthType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.StrengthType),
|
|
@@ -98297,7 +98751,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98297
98751
|
/* harmony export */ parsePrimitiveType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.parsePrimitiveType),
|
|
98298
98752
|
/* harmony export */ parseRelationshipEnd: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.parseRelationshipEnd),
|
|
98299
98753
|
/* harmony export */ parseSchemaItemType: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.parseSchemaItemType),
|
|
98300
|
-
/* harmony export */ parseSchemaViewBlob: () => (/* reexport safe */
|
|
98754
|
+
/* harmony export */ parseSchemaViewBlob: () => (/* reexport safe */ _SchemaView_SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_42__.parseSchemaViewBlob),
|
|
98301
98755
|
/* harmony export */ parseStrength: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.parseStrength),
|
|
98302
98756
|
/* harmony export */ parseStrengthDirection: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.parseStrengthDirection),
|
|
98303
98757
|
/* harmony export */ primitiveTypeToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.primitiveTypeToString),
|
|
@@ -98305,7 +98759,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98305
98759
|
/* harmony export */ relationshipEndToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.relationshipEndToString),
|
|
98306
98760
|
/* harmony export */ schemaItemTypeToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.schemaItemTypeToString),
|
|
98307
98761
|
/* harmony export */ schemaItemTypeToXmlString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.schemaItemTypeToXmlString),
|
|
98308
|
-
/* harmony export */ schemaViewFormatVersion: () => (/* reexport safe */
|
|
98762
|
+
/* harmony export */ schemaViewFormatVersion: () => (/* reexport safe */ _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__.schemaViewFormatVersion),
|
|
98309
98763
|
/* harmony export */ strengthDirectionToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.strengthDirectionToString),
|
|
98310
98764
|
/* harmony export */ strengthToString: () => (/* reexport safe */ _ECObjects__WEBPACK_IMPORTED_MODULE_8__.strengthToString)
|
|
98311
98765
|
/* harmony export */ });
|
|
@@ -98351,12 +98805,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98351
98805
|
/* harmony import */ var _IncrementalLoading_ECSqlSchemaLocater__WEBPACK_IMPORTED_MODULE_39__ = __webpack_require__(/*! ./IncrementalLoading/ECSqlSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/ECSqlSchemaLocater.js");
|
|
98352
98806
|
/* harmony import */ var _IncrementalLoading_IncrementalSchemaLocater__WEBPACK_IMPORTED_MODULE_40__ = __webpack_require__(/*! ./IncrementalLoading/IncrementalSchemaLocater */ "../../core/ecschema-metadata/lib/esm/IncrementalLoading/IncrementalSchemaLocater.js");
|
|
98353
98807
|
/* harmony import */ var _utils_SchemaGraph__WEBPACK_IMPORTED_MODULE_41__ = __webpack_require__(/*! ./utils/SchemaGraph */ "../../core/ecschema-metadata/lib/esm/utils/SchemaGraph.js");
|
|
98354
|
-
/* harmony import */ var
|
|
98355
|
-
/* harmony import */ var
|
|
98356
|
-
/* harmony import */ var
|
|
98357
|
-
/* harmony import */ var
|
|
98358
|
-
/* harmony import */ var
|
|
98359
|
-
/* harmony import */ var
|
|
98808
|
+
/* harmony import */ var _SchemaView_SchemaViewBinaryReader__WEBPACK_IMPORTED_MODULE_42__ = __webpack_require__(/*! ./SchemaView/SchemaViewBinaryReader */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBinaryReader.js");
|
|
98809
|
+
/* harmony import */ var _SchemaView_SchemaView__WEBPACK_IMPORTED_MODULE_43__ = __webpack_require__(/*! ./SchemaView/SchemaView */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaView.js");
|
|
98810
|
+
/* harmony import */ var _SchemaView_SchemaViewBuilder__WEBPACK_IMPORTED_MODULE_44__ = __webpack_require__(/*! ./SchemaView/SchemaViewBuilder */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewBuilder.js");
|
|
98811
|
+
/* harmony import */ var _SchemaView_SchemaViewInterfaces__WEBPACK_IMPORTED_MODULE_45__ = __webpack_require__(/*! ./SchemaView/SchemaViewInterfaces */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewInterfaces.js");
|
|
98812
|
+
/* harmony import */ var _SchemaView_SchemaManifest__WEBPACK_IMPORTED_MODULE_46__ = __webpack_require__(/*! ./SchemaView/SchemaManifest */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaManifest.js");
|
|
98813
|
+
/* harmony import */ var _SchemaView_SchemaViewManager__WEBPACK_IMPORTED_MODULE_47__ = __webpack_require__(/*! ./SchemaView/SchemaViewManager */ "../../core/ecschema-metadata/lib/esm/SchemaView/SchemaViewManager.js");
|
|
98814
|
+
/* harmony import */ var _Localization_LocalizationTypes__WEBPACK_IMPORTED_MODULE_48__ = __webpack_require__(/*! ./Localization/LocalizationTypes */ "../../core/ecschema-metadata/lib/esm/Localization/LocalizationTypes.js");
|
|
98815
|
+
/* harmony import */ var _Localization_LocalizationProvider__WEBPACK_IMPORTED_MODULE_49__ = __webpack_require__(/*! ./Localization/LocalizationProvider */ "../../core/ecschema-metadata/lib/esm/Localization/LocalizationProvider.js");
|
|
98816
|
+
/* harmony import */ var _Localization_SchemaLocalization__WEBPACK_IMPORTED_MODULE_50__ = __webpack_require__(/*! ./Localization/SchemaLocalization */ "../../core/ecschema-metadata/lib/esm/Localization/SchemaLocalization.js");
|
|
98360
98817
|
/*---------------------------------------------------------------------------------------------
|
|
98361
98818
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
98362
98819
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -98405,6 +98862,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
98405
98862
|
|
|
98406
98863
|
|
|
98407
98864
|
|
|
98865
|
+
|
|
98866
|
+
|
|
98867
|
+
|
|
98408
98868
|
|
|
98409
98869
|
|
|
98410
98870
|
|
|
@@ -104872,7 +105332,7 @@ class BriefcaseConnection extends _IModelConnection__WEBPACK_IMPORTED_MODULE_5__
|
|
|
104872
105332
|
*/
|
|
104873
105333
|
async pushChanges(description) {
|
|
104874
105334
|
this.requireTimeline();
|
|
104875
|
-
return _IpcApp__WEBPACK_IMPORTED_MODULE_6__.IpcApp.appFunctionIpc.pushChanges(this.key, description);
|
|
105335
|
+
return this.changeset = await _IpcApp__WEBPACK_IMPORTED_MODULE_6__.IpcApp.appFunctionIpc.pushChanges(this.key, description);
|
|
104876
105336
|
}
|
|
104877
105337
|
/** The current graphical editing scope, if one is in progress.
|
|
104878
105338
|
* @see [[enterEditingScope]] to begin graphical editing.
|
|
@@ -111669,7 +112129,9 @@ class IModelConnection extends _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.I
|
|
|
111669
112129
|
*/
|
|
111670
112130
|
fontMap; // eslint-disable-line @typescript-eslint/no-deprecated
|
|
111671
112131
|
_schemaContext;
|
|
111672
|
-
|
|
112132
|
+
// Created lazily on the first getSchemaView call. Owns the SchemaView's lifetime and does all its
|
|
112133
|
+
// data access through the SchemaViewDataProvider implemented below.
|
|
112134
|
+
_schemaViewManager;
|
|
111673
112135
|
/** Load the FontMap for this IModelConnection.
|
|
111674
112136
|
* @returns Returns a Promise<FontMap> that is fulfilled when the FontMap member of this IModelConnection is valid.
|
|
111675
112137
|
* @deprecated in 5.0.0 - might be removed in next major version. If you need font Ids on the front-end for some reason, write an Ipc method that queries [IModelDb.fonts]($backend).
|
|
@@ -112097,33 +112559,23 @@ class IModelConnection extends _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.I
|
|
|
112097
112559
|
}
|
|
112098
112560
|
/** Get the schema view for this iModel. The view is built lazily on
|
|
112099
112561
|
* first call by fetching compact binary schema data via `PRAGMA schema_view` through
|
|
112100
|
-
* the existing queryRows RPC (ConcurrentQuery).
|
|
112101
|
-
* Multiple concurrent callers share a single in-flight fetch.
|
|
112562
|
+
* the existing queryRows RPC (ConcurrentQuery).
|
|
112102
112563
|
*
|
|
112103
112564
|
* The returned `SchemaView` is a lightweight, read-only, synchronous API for
|
|
112104
112565
|
* navigating schema metadata - classes, properties, relationships, enumerations, etc.
|
|
112105
112566
|
* It is the recommended default for runtime read-only metadata access and is significantly
|
|
112106
112567
|
* faster and lower-memory than [[schemaContext]]. Use [[schemaContext]] for custom-attribute
|
|
112107
112568
|
* deserialization or anywhere you need the full ecschema-metadata object graph.
|
|
112569
|
+
*
|
|
112570
|
+
* Every call shares one accumulating view instance and concurrent calls are serialized, so a
|
|
112571
|
+
* caller never observes a partially loaded view. The instance is discarded once the connection
|
|
112572
|
+
* detects that schemas changed, for example after [[BriefcaseConnection.pullChanges]]; the next
|
|
112573
|
+
* call builds a new one. See [GetSchemaViewArgs]($ecschema-metadata) for the arguments.
|
|
112108
112574
|
* @beta
|
|
112109
112575
|
*/
|
|
112110
|
-
async getSchemaView() {
|
|
112111
|
-
|
|
112112
|
-
|
|
112113
|
-
if (!ctx.isOutdated)
|
|
112114
|
-
return ctx;
|
|
112115
|
-
}
|
|
112116
|
-
// Capture the in-flight promise locally so the rejection handler only clears
|
|
112117
|
-
// `_schemasPromise` if it still points at this build. A concurrent invalidation +
|
|
112118
|
-
// re-fetch could otherwise replace the field before our fetch fails, and a naive
|
|
112119
|
-
// `_schemasPromise = undefined` would clobber that newer reference.
|
|
112120
|
-
const inflight = this._fetchSchemas();
|
|
112121
|
-
this._schemasPromise = inflight;
|
|
112122
|
-
inflight.catch(() => {
|
|
112123
|
-
if (this._schemasPromise === inflight)
|
|
112124
|
-
this._schemasPromise = undefined;
|
|
112125
|
-
});
|
|
112126
|
-
return inflight;
|
|
112576
|
+
async getSchemaView(args) {
|
|
112577
|
+
this._schemaViewManager ??= new _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_14__.SchemaViewManager(this._createSchemaViewDataProvider());
|
|
112578
|
+
return this._schemaViewManager.getSchemaView(args);
|
|
112127
112579
|
}
|
|
112128
112580
|
/**
|
|
112129
112581
|
* Checks whether the iModel's schemas have changed since the current cached [[SchemaView]] was
|
|
@@ -112135,7 +112587,7 @@ class IModelConnection extends _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.I
|
|
|
112135
112587
|
* returns only the new changeset id, not the list of applied changesets with their types.
|
|
112136
112588
|
* Unconditionally discarding the cached [[SchemaView]] after every such operation would cause
|
|
112137
112589
|
* unnecessary reloads in the common case where schemas are unchanged. This method avoids that
|
|
112138
|
-
* cost by fetching a lightweight schema
|
|
112590
|
+
* cost by fetching a lightweight schema token via `PRAGMA checksum(schema_token)` and
|
|
112139
112591
|
* comparing it against the token stored in the cached view. Only when the token differs is the
|
|
112140
112592
|
* cache discarded.
|
|
112141
112593
|
*
|
|
@@ -112144,61 +112596,59 @@ class IModelConnection extends _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.I
|
|
|
112144
112596
|
* @internal
|
|
112145
112597
|
*/
|
|
112146
112598
|
async invalidateSchemaViewIfChanged() {
|
|
112147
|
-
|
|
112148
|
-
|
|
112149
|
-
|
|
112150
|
-
|
|
112151
|
-
|
|
112152
|
-
|
|
112153
|
-
|
|
112154
|
-
|
|
112155
|
-
|
|
112156
|
-
|
|
112157
|
-
|
|
112158
|
-
|
|
112159
|
-
|
|
112160
|
-
|
|
112161
|
-
|
|
112162
|
-
|
|
112163
|
-
|
|
112164
|
-
|
|
112165
|
-
|
|
112166
|
-
|
|
112167
|
-
|
|
112168
|
-
|
|
112169
|
-
|
|
112170
|
-
|
|
112171
|
-
|
|
112172
|
-
|
|
112173
|
-
|
|
112174
|
-
|
|
112175
|
-
|
|
112176
|
-
|
|
112177
|
-
|
|
112178
|
-
|
|
112179
|
-
|
|
112180
|
-
|
|
112181
|
-
|
|
112182
|
-
|
|
112183
|
-
|
|
112184
|
-
|
|
112185
|
-
|
|
112186
|
-
async
|
|
112187
|
-
//
|
|
112188
|
-
//
|
|
112189
|
-
//
|
|
112190
|
-
//
|
|
112191
|
-
|
|
112192
|
-
// don't support OFFSET-based pagination.
|
|
112193
|
-
const reader = this.createQueryReader(`PRAGMA schema_view(${_itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_14__.schemaViewFormatVersion})`);
|
|
112599
|
+
await this._schemaViewManager?.invalidateIfChanged();
|
|
112600
|
+
}
|
|
112601
|
+
/** The [SchemaViewDataProvider]($ecschema-metadata) backing this iModel's [[getSchemaView]]: the
|
|
112602
|
+
* transport-specific half of schema-view loading, issued through the queryRows RPC
|
|
112603
|
+
* (ConcurrentQuery). The frontend *pins* the blob format version in both pragmas, because the
|
|
112604
|
+
* backend it talks to can be older or newer; the pin makes it return a blob this code can parse,
|
|
112605
|
+
* or fail cleanly.
|
|
112606
|
+
*/
|
|
112607
|
+
_createSchemaViewDataProvider() {
|
|
112608
|
+
return {
|
|
112609
|
+
fetchFullBlob: async () => this._fetchSchemaBlob(`PRAGMA schema_view(${_itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_14__.schemaViewFormatVersion})`),
|
|
112610
|
+
// Names are ECNames, so a comma can never occur in one. Native re-validates each token as an
|
|
112611
|
+
// ECName and fails the pragma on an unknown name. The `v<N>;` prefix pins the format version.
|
|
112612
|
+
fetchFragmentBlob: async (schemaNames) => this._fetchSchemaBlob(`PRAGMA schema_view_fragment('v${_itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_14__.schemaViewFormatVersion};${schemaNames.join(",")}')`),
|
|
112613
|
+
fetchManifest: async () => {
|
|
112614
|
+
const schemaRows = [];
|
|
112615
|
+
const schemaSql = "SELECT ECInstanceId, Name, VersionMajor, VersionWrite, VersionMinor FROM meta.ECSchemaDef";
|
|
112616
|
+
for await (const row of this.createQueryReader(schemaSql)) {
|
|
112617
|
+
// ECInstanceId arrives as a hex Id64String. `ec_` metadata rowids carry no briefcase
|
|
112618
|
+
// prefix, so the local id is the full value.
|
|
112619
|
+
schemaRows.push({ ecInstanceId: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.getLocalId(row[0]), name: row[1], versionMajor: row[2], versionWrite: row[3], versionMinor: row[4] });
|
|
112620
|
+
}
|
|
112621
|
+
const referenceRows = [];
|
|
112622
|
+
const referenceSql = "SELECT SourceECInstanceId, TargetECInstanceId FROM meta.SchemaHasSchemaReferences";
|
|
112623
|
+
for await (const row of this.createQueryReader(referenceSql))
|
|
112624
|
+
referenceRows.push({ sourceECInstanceId: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.getLocalId(row[0]), targetECInstanceId: _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.Id64.getLocalId(row[1]) });
|
|
112625
|
+
return _itwin_ecschema_metadata__WEBPACK_IMPORTED_MODULE_14__.SchemaManifest.fromRows(schemaRows, referenceRows);
|
|
112626
|
+
},
|
|
112627
|
+
fetchSchemaToken: async () => {
|
|
112628
|
+
const reader = this.createQueryReader("PRAGMA checksum(schema_token)");
|
|
112629
|
+
const result = await reader.next();
|
|
112630
|
+
if (result.done)
|
|
112631
|
+
throw new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.IModelError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.BadRequest, "PRAGMA checksum(schema_token) returned no rows");
|
|
112632
|
+
return result.value.sha3_256;
|
|
112633
|
+
},
|
|
112634
|
+
};
|
|
112635
|
+
}
|
|
112636
|
+
/** Fetch one schema-view blob (full or fragment). Both `PRAGMA schema_view` and
|
|
112637
|
+
* `PRAGMA schema_view_fragment` return a single row with the same columns. */
|
|
112638
|
+
async _fetchSchemaBlob(pragma) {
|
|
112639
|
+
// Only call reader.next() once - do NOT use `for await` on PRAGMA results. ConcurrentQuery wraps
|
|
112640
|
+
// regular ECSQL in LIMIT/OFFSET for pagination but skips this for PRAGMAs; if the serialized
|
|
112641
|
+
// result exceeds the memory threshold, the response is marked "Partial", and a `for await` loop
|
|
112642
|
+
// would re-issue the same PRAGMA forever since PRAGMAs don't support OFFSET-based pagination.
|
|
112643
|
+
const reader = this.createQueryReader(pragma);
|
|
112194
112644
|
const result = await reader.next();
|
|
112195
112645
|
if (result.done)
|
|
112196
|
-
throw new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.IModelError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.BadRequest,
|
|
112646
|
+
throw new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.IModelError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.BadRequest, `${pragma} returned no rows`);
|
|
112197
112647
|
const data = result.value.data;
|
|
112198
112648
|
const token = result.value.schemaToken;
|
|
112199
112649
|
if (data === undefined || data === null)
|
|
112200
|
-
throw new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.IModelError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.BadRequest,
|
|
112201
|
-
return
|
|
112650
|
+
throw new _itwin_core_common__WEBPACK_IMPORTED_MODULE_1__.IModelError(_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.IModelStatus.BadRequest, `${pragma} returned null data column`);
|
|
112651
|
+
return { data, schemaToken: token ?? "" };
|
|
112202
112652
|
}
|
|
112203
112653
|
}
|
|
112204
112654
|
/** A connection that exists without an iModel. Useful for connecting to Reality Data services.
|
|
@@ -341465,18 +341915,18 @@ class Settings {
|
|
|
341465
341915
|
}
|
|
341466
341916
|
}
|
|
341467
341917
|
toString() {
|
|
341468
|
-
return `Configurations:
|
|
341469
|
-
backend location: ${this.Backend.location},
|
|
341470
|
-
backend name: ${this.Backend.name},
|
|
341471
|
-
backend version: ${this.Backend.version},
|
|
341472
|
-
oidc client id: ${this.oidcClientId},
|
|
341473
|
-
oidc scopes: ${this.oidcScopes},
|
|
341474
|
-
applicationId: ${this.gprid},
|
|
341475
|
-
log level: ${this.logLevel},
|
|
341476
|
-
testing iModelTileRpcTests: ${this.runiModelTileRpcTests},
|
|
341477
|
-
testing PresentationRpcTest: ${this.runPresentationRpcTests},
|
|
341478
|
-
testing iModelReadRpcTests: ${this.runiModelReadRpcTests},
|
|
341479
|
-
testing DevToolsRpcTests: ${this.runDevToolsRpcTests},
|
|
341918
|
+
return `Configurations:
|
|
341919
|
+
backend location: ${this.Backend.location},
|
|
341920
|
+
backend name: ${this.Backend.name},
|
|
341921
|
+
backend version: ${this.Backend.version},
|
|
341922
|
+
oidc client id: ${this.oidcClientId},
|
|
341923
|
+
oidc scopes: ${this.oidcScopes},
|
|
341924
|
+
applicationId: ${this.gprid},
|
|
341925
|
+
log level: ${this.logLevel},
|
|
341926
|
+
testing iModelTileRpcTests: ${this.runiModelTileRpcTests},
|
|
341927
|
+
testing PresentationRpcTest: ${this.runPresentationRpcTests},
|
|
341928
|
+
testing iModelReadRpcTests: ${this.runiModelReadRpcTests},
|
|
341929
|
+
testing DevToolsRpcTests: ${this.runDevToolsRpcTests},
|
|
341480
341930
|
testing iModelWriteRpcTests: ${this.runiModelWriteRpcTests}`;
|
|
341481
341931
|
}
|
|
341482
341932
|
}
|
|
@@ -341701,7 +342151,7 @@ class TestContext {
|
|
|
341701
342151
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
341702
342152
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
341703
342153
|
await core_frontend_1.NoRenderApp.startup({
|
|
341704
|
-
applicationVersion: "5.12.0-dev.
|
|
342154
|
+
applicationVersion: "5.12.0-dev.18",
|
|
341705
342155
|
applicationId: this.settings.gprid,
|
|
341706
342156
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
341707
342157
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -366538,7 +366988,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
366538
366988
|
(module) {
|
|
366539
366989
|
|
|
366540
366990
|
"use strict";
|
|
366541
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.12.0-dev.
|
|
366991
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.12.0-dev.18","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 && npm run -s copy:draco","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","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./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 && npm run -s extract","extract":"betools extract --fileExt=ts --extractFrom=./src/test/example-code --recursive --out=../../generated-docs/extract","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@bentley/aec-units-schema":"^1.0.3","@bentley/formats-schema":"^1.0.0","@bentley/units-schema":"^1.0.10","@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/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"^6.0.0","@types/chai-as-promised":"^7","@types/draco3d":"^1.4.10","@types/node":"~20.17.0","@types/sinon":"^17.0.2","@vitest/browser-playwright":"^4.1.10","@vitest/coverage-v8":"^4.1.10","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^13.0.6","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","vitest":"^4.1.10","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/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"~4.3.4","@loaders.gl/draco":"~4.3.4","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
|
|
366542
366992
|
|
|
366543
366993
|
/***/ },
|
|
366544
366994
|
|