@itwin/ecschema-metadata 5.14.0-dev.8 → 5.15.0-dev.1

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/lib/cjs/ECName.d.ts +4 -0
  3. package/lib/cjs/ECName.d.ts.map +1 -1
  4. package/lib/cjs/ECName.js +9 -1
  5. package/lib/cjs/ECName.js.map +1 -1
  6. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts +13 -5
  7. package/lib/cjs/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
  8. package/lib/cjs/Formatting/FormatSetFormatsProvider.js +65 -22
  9. package/lib/cjs/Formatting/FormatSetFormatsProvider.js.map +1 -1
  10. package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts +15 -6
  11. package/lib/cjs/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
  12. package/lib/cjs/Formatting/SchemaFormatsProvider.js +163 -44
  13. package/lib/cjs/Formatting/SchemaFormatsProvider.js.map +1 -1
  14. package/lib/cjs/SchemaView/SchemaManifest.d.ts +11 -14
  15. package/lib/cjs/SchemaView/SchemaManifest.d.ts.map +1 -1
  16. package/lib/cjs/SchemaView/SchemaManifest.js +8 -11
  17. package/lib/cjs/SchemaView/SchemaManifest.js.map +1 -1
  18. package/lib/cjs/SchemaView/SchemaView.d.ts +14 -5
  19. package/lib/cjs/SchemaView/SchemaView.d.ts.map +1 -1
  20. package/lib/cjs/SchemaView/SchemaView.js +22 -12
  21. package/lib/cjs/SchemaView/SchemaView.js.map +1 -1
  22. package/lib/cjs/SchemaView/SchemaViewManager.d.ts +22 -17
  23. package/lib/cjs/SchemaView/SchemaViewManager.d.ts.map +1 -1
  24. package/lib/cjs/SchemaView/SchemaViewManager.js +11 -11
  25. package/lib/cjs/SchemaView/SchemaViewManager.js.map +1 -1
  26. package/lib/esm/ECName.d.ts +4 -0
  27. package/lib/esm/ECName.d.ts.map +1 -1
  28. package/lib/esm/ECName.js +9 -1
  29. package/lib/esm/ECName.js.map +1 -1
  30. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts +13 -5
  31. package/lib/esm/Formatting/FormatSetFormatsProvider.d.ts.map +1 -1
  32. package/lib/esm/Formatting/FormatSetFormatsProvider.js +65 -22
  33. package/lib/esm/Formatting/FormatSetFormatsProvider.js.map +1 -1
  34. package/lib/esm/Formatting/SchemaFormatsProvider.d.ts +15 -6
  35. package/lib/esm/Formatting/SchemaFormatsProvider.d.ts.map +1 -1
  36. package/lib/esm/Formatting/SchemaFormatsProvider.js +163 -44
  37. package/lib/esm/Formatting/SchemaFormatsProvider.js.map +1 -1
  38. package/lib/esm/SchemaView/SchemaManifest.d.ts +11 -14
  39. package/lib/esm/SchemaView/SchemaManifest.d.ts.map +1 -1
  40. package/lib/esm/SchemaView/SchemaManifest.js +8 -11
  41. package/lib/esm/SchemaView/SchemaManifest.js.map +1 -1
  42. package/lib/esm/SchemaView/SchemaView.d.ts +14 -5
  43. package/lib/esm/SchemaView/SchemaView.d.ts.map +1 -1
  44. package/lib/esm/SchemaView/SchemaView.js +22 -12
  45. package/lib/esm/SchemaView/SchemaView.js.map +1 -1
  46. package/lib/esm/SchemaView/SchemaViewManager.d.ts +22 -17
  47. package/lib/esm/SchemaView/SchemaViewManager.d.ts.map +1 -1
  48. package/lib/esm/SchemaView/SchemaViewManager.js +11 -11
  49. package/lib/esm/SchemaView/SchemaViewManager.js.map +1 -1
  50. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaViewManager.js","sourceRoot":"","sources":["../../../src/SchemaView/SchemaViewManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA8D1C;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IACX,aAAa,CAAyB;IAEvD;wEACoE;IAC5D,YAAY,CAAmC;IAEvD,qGAAqG;IAC7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,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAC7K,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { SchemaManifest } from \"./SchemaManifest\";\r\nimport { SchemaView } from \"./SchemaView\";\r\n\r\n/** One schema-view blob with its cache-invalidation token, as fetched by a\r\n * {@link SchemaViewDataProvider}. Full and fragment blobs share this shape.\r\n * @internal\r\n */\r\nexport interface SchemaViewBlob {\r\n /** The binary schema metadata (the `data` column of `PRAGMA schema_view` / `schema_view_fragment`). */\r\n readonly data: Uint8Array;\r\n /** Schema-identity hash of the iModel's whole schema set (the `schemaToken` column). Empty string when unavailable. */\r\n readonly schemaToken: string;\r\n}\r\n\r\n/** The data source a {@link SchemaViewManager} loads schema-view data from, implemented by the hosts\r\n * that own the query APIs: `IModelDb` on the backend and `IModelConnection` on the frontend. The\r\n * manager deals only in schema names, blobs and the manifest; everything transport-specific - pragma\r\n * strings, format-version pinning - belongs to the provider.\r\n * @internal\r\n */\r\nexport interface SchemaViewDataProvider {\r\n /** Fetch the blob containing every schema in the iModel (`PRAGMA schema_view`). */\r\n fetchFullBlob(): Promise<SchemaViewBlob>;\r\n\r\n /** Fetch one blob containing exactly the given schemas (`PRAGMA schema_view_fragment`). The\r\n * requested set is always dependency-closed - the manager computes the reference closure from the\r\n * manifest before calling. */\r\n fetchFragmentBlob(schemaNames: readonly string[]): Promise<SchemaViewBlob>;\r\n\r\n /** Fetch the reference graph of every schema in the iModel, built from ECDbMeta\r\n * (`meta.ECSchemaDef` + `meta.SchemaHasSchemaReferences`; see {@link SchemaManifest.fromRows}). */\r\n fetchManifest(): Promise<SchemaManifest>;\r\n\r\n /** Fetch the current schema-identity token (`PRAGMA checksum(schema_token)`). */\r\n fetchSchemaToken(): Promise<string>;\r\n}\r\n\r\n/** Options for `getSchemaView` (see `IModelDb.getSchemaView` / `IModelConnection.getSchemaView`,\r\n * which delegate to {@link SchemaViewManager.getSchemaView}).\r\n * @beta\r\n */\r\nexport interface GetSchemaViewArgs {\r\n /** When provided, return a view loaded with at least these schemas plus their references, instead\r\n * of every schema in the iModel.\r\n *\r\n * The view accumulates: one instance is reused across calls, so a later request - with different\r\n * schemas or with no filter at all - merges the still-missing schemas into the same view and\r\n * everything requested earlier stays available. It resets when the iModel's schemas change.\r\n *\r\n * Names the iModel does not contain are ignored. Omitting this option loads all schemas, identical\r\n * to calling `getSchemaView()` with no arguments.\r\n */\r\n readonly schemas?: readonly string[];\r\n\r\n /** When `true`, discard whatever is currently loaded and rebuild the view from scratch before\r\n * returning it. The previously returned view instance (if any) is marked outdated. Like every other\r\n * request this is serialized behind any in-flight load, so it never leaves the view in an invalid\r\n * intermediate state.\r\n * @internal\r\n */\r\n readonly forceReload?: boolean;\r\n}\r\n\r\n/** Owns the lifetime of one iModel's {@link (SchemaView:class)}: lazy loading, incremental (filtered)\r\n * hydration, serialization of concurrent requests, and invalidation. Hosts (`IModelDb`,\r\n * `IModelConnection`) hold one instance and delegate to it; all data access goes through the\r\n * host-implemented {@link SchemaViewDataProvider}.\r\n * @internal\r\n */\r\nexport class SchemaViewManager {\r\n private readonly _dataProvider: SchemaViewDataProvider;\r\n\r\n /** The single accumulating view, held as a promise so all requests chain onto it and never overlap.\r\n * Undefined (or resolving to undefined) means nothing is loaded. */\r\n private _viewPromise?: Promise<SchemaView | undefined>;\r\n\r\n /** Reference graph for incremental loading; undefined when the view is (or will be) fully loaded. */\r\n private _manifest?: SchemaManifest;\r\n\r\n /** Schema-identity token the manifest - and thus every fragment merged under it - belongs to. */\r\n private _manifestToken?: string;\r\n\r\n /** Lower-cased names already merged into the view (incremental mode only). */\r\n private readonly _loadedSchemaNames = new Set<string>();\r\n\r\n public constructor(dataProvider: SchemaViewDataProvider) {\r\n this._dataProvider = dataProvider;\r\n }\r\n\r\n /** Get the schema view, loading whatever the request needs that is not present yet. See\r\n * {@link GetSchemaViewArgs} for filtering and reload semantics; hosts document the full\r\n * user-facing contract on their `getSchemaView` methods.\r\n */\r\n public async getSchemaView(args?: GetSchemaViewArgs): Promise<SchemaView> {\r\n const previous = this._viewPromise;\r\n const next = this._loadSchemaView(previous, args?.schemas, args?.forceReload === true);\r\n this._viewPromise = next;\r\n return next;\r\n }\r\n\r\n /** Throw away the current schema view. Called by the host when schemas may have changed (e.g.\r\n * `IModelDb.clearCaches` after a schema import). Chains behind any in-flight load and marks the\r\n * discarded view outdated; the next getSchemaView starts over.\r\n */\r\n public reset(): void {\r\n if (this._viewPromise) {\r\n this._viewPromise = this._viewPromise.then(\r\n (view) => { view?.markOutdated(); this._resetIncrementalState(); return undefined; },\r\n () => { this._resetIncrementalState(); return undefined; },\r\n );\r\n }\r\n }\r\n\r\n /** Check whether the iModel's schemas have changed since the current view was built, and discard\r\n * the view only if they have. For hosts that *cannot* determine whether an operation actually\r\n * modified schemas - e.g. `BriefcaseConnection.pullChanges` on the frontend, whose IPC response\r\n * carries only the new changeset id, not the applied changesets' types. Discarding after every\r\n * such operation would reload unnecessarily in the common case where schemas are unchanged, so\r\n * this compares the cheap schema-identity token instead.\r\n * @note If the token cannot be fetched, the view is discarded rather than risking stale metadata.\r\n */\r\n public async invalidateIfChanged(): Promise<void> {\r\n const previous = this._viewPromise;\r\n if (previous === undefined)\r\n return;\r\n // Queue the check on the same chain as loading, so a getSchemaView arriving while the token is\r\n // in flight cannot swap in a new promise for the same stale view and hide the schema change.\r\n const next = this._invalidateIfChanged(previous);\r\n this._viewPromise = next;\r\n await next;\r\n }\r\n\r\n /** Serialized body of {@link SchemaViewManager.invalidateIfChanged}. Resolves to the view to keep,\r\n * or to `undefined` when it was discarded and the next getSchemaView has to start over.\r\n */\r\n private async _invalidateIfChanged(previous: Promise<SchemaView | undefined>): Promise<SchemaView | undefined> {\r\n let existing: SchemaView | undefined;\r\n try {\r\n existing = await previous;\r\n } catch {\r\n return undefined;\r\n }\r\n if (existing === undefined)\r\n return undefined;\r\n // A view without a token (e.g. built directly from a SchemaViewBuilder) cannot be verified by\r\n // token; views loaded through this manager always carry one.\r\n if (existing.schemaToken === \"\")\r\n return existing;\r\n\r\n try {\r\n if (await this._dataProvider.fetchSchemaToken() === existing.schemaToken)\r\n return existing;\r\n } catch {\r\n // Cannot verify the cached view: drop it rather than risk stale metadata.\r\n }\r\n existing.markOutdated();\r\n this._resetIncrementalState();\r\n return undefined;\r\n }\r\n\r\n /** Serialized body of {@link SchemaViewManager.getSchemaView}. On failure it resets and rejects,\r\n * so the next call starts over.\r\n */\r\n private async _loadSchemaView(previous: Promise<SchemaView | undefined> | undefined, schemas: readonly string[] | undefined, forceReload: boolean): Promise<SchemaView> {\r\n let currentView: SchemaView | undefined;\r\n if (previous !== undefined) {\r\n try {\r\n currentView = await previous;\r\n } catch {\r\n currentView = undefined; // the failed load already reset; start over\r\n }\r\n }\r\n\r\n if (forceReload) {\r\n currentView?.markOutdated();\r\n currentView = undefined;\r\n this._resetIncrementalState();\r\n }\r\n\r\n try {\r\n return await this._ensureSchemasLoaded(currentView, schemas);\r\n } catch (err) {\r\n // A failed merge may have left the view partially extended - discard everything.\r\n currentView?.markOutdated();\r\n this._resetIncrementalState();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Clear the incremental schema-view bookkeeping. */\r\n private _resetIncrementalState(): void {\r\n this._manifest = undefined;\r\n this._manifestToken = undefined;\r\n this._loadedSchemaNames.clear();\r\n }\r\n\r\n /** Ensures the requested schemas (or all schemas, when no filter is given) are present in\r\n * `currentView` (or a freshly created view) and returns it. The first load fixes the strategy:\r\n * no filter fetches everything as one full blob; a filter fetches fragments and keeps the\r\n * manifest and loaded-name set so later calls extend the same view. Once every schema is loaded\r\n * the incremental state is dropped, collapsing back to full mode.\r\n */\r\n private async _ensureSchemasLoaded(currentView: SchemaView | undefined, schemas: readonly string[] | undefined, isRetry = false): Promise<SchemaView> {\r\n const isFirstLoad = currentView === undefined;\r\n // No manifest means everything is loaded; in incremental mode a filtered request is satisfied as\r\n // soon as every requested name is present.\r\n if (!isFirstLoad &&\r\n (this._manifest === undefined ||\r\n (schemas !== undefined && schemas.every((name) => this._loadedSchemaNames.has(name.toLowerCase())))))\r\n return currentView;\r\n\r\n if (isFirstLoad && schemas === undefined) {\r\n const blob = await this._dataProvider.fetchFullBlob();\r\n const schemaView = SchemaView.fromBinary(blob.data, blob.schemaToken);\r\n this._resetIncrementalState();\r\n return schemaView;\r\n }\r\n\r\n if (this._manifest === undefined) {\r\n // Token first: any schema change after this point shows up as a token mismatch below.\r\n this._manifestToken = await this._dataProvider.fetchSchemaToken();\r\n this._manifest = await this._dataProvider.fetchManifest();\r\n }\r\n const manifest = this._manifest;\r\n\r\n const requested = schemas ?? manifest.getAvailableSchemaNames();\r\n const namesToLoad = manifest.getSchemaClosure(requested).filter((name) => !this._loadedSchemaNames.has(name.toLowerCase()));\r\n const husk = currentView ?? SchemaView.createMergeable(this._manifestToken);\r\n if (namesToLoad.length > 0) {\r\n const blob = await this._dataProvider.fetchFragmentBlob(namesToLoad);\r\n if (blob.schemaToken !== this._manifestToken) {\r\n // Schemas changed between the manifest and fragment fetches. Everything loaded so far\r\n // belongs to the old revision - discard it and start over, once.\r\n currentView?.markOutdated();\r\n this._resetIncrementalState();\r\n if (isRetry)\r\n throw new Error(\"The iModel's schemas changed while the schema view was loading.\");\r\n return this._ensureSchemasLoaded(undefined, schemas, true);\r\n }\r\n husk.mergeFragment(blob.data);\r\n // Record the whole closure as loaded, including *excluded* schemas (e.g. CoreCustomAttributes)\r\n // the writer emits no rows for, so later requests prune them instead of re-fetching.\r\n for (const name of namesToLoad)\r\n this._loadedSchemaNames.add(name.toLowerCase());\r\n }\r\n // Once every schema is loaded, collapse back to full mode (the size check is just a fast path).\r\n if (schemas === undefined || (this._loadedSchemaNames.size >= manifest.schemaCount && manifest.entries.every((entry) => this._loadedSchemaNames.has(entry.name.toLowerCase()))))\r\n this._resetIncrementalState();\r\n return husk;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SchemaViewManager.js","sourceRoot":"","sources":["../../../src/SchemaView/SchemaViewManager.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AA+D1C;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAiB;IACX,aAAa,CAAyB;IAEvD;wEACoE;IAC5D,YAAY,CAAmC;IAEvD,qGAAqG;IAC7F,SAAS,CAAkB;IAEnC,iGAAiG;IACzF,cAAc,CAAU;IAEhC,8EAA8E;IAC7D,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;IAExD,YAAmB,YAAoC;QACrD,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,aAAa,CAAC,IAAwB;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC,CAAC;QACvF,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,KAAK;QACV,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CACxC,CAAC,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,YAAY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IAAI,OAAO;oBACT,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBACrF,OAAO,IAAI,CAAC,oBAAoB,CAAC,SAAS,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;YAC7D,CAAC;YACD,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9B,+FAA+F;YAC/F,qFAAqF;YACrF,KAAK,MAAM,IAAI,IAAI,WAAW;gBAC5B,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACpD,CAAC;QACD,gGAAgG;QAChG,IAAI,OAAO,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,IAAI,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YAC7K,IAAI,CAAC,sBAAsB,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { SchemaManifest } from \"./SchemaManifest\";\r\nimport { SchemaView } from \"./SchemaView\";\r\n\r\n/** One schema-view blob with its cache-invalidation token, as fetched by a\r\n * {@link SchemaViewDataProvider}. Full and fragment blobs share this shape.\r\n * @beta\r\n */\r\nexport interface SchemaViewBlob {\r\n /** The binary schema metadata (the `data` column of `PRAGMA schema_view` / `schema_view_fragment`). */\r\n readonly data: Uint8Array;\r\n /** Schema-identity hash of the iModel's whole schema set (the `schemaToken` column). */\r\n readonly schemaToken: string;\r\n}\r\n\r\n/** The data source a {@link SchemaViewManager} loads schema-view data from. Implement this interface\r\n * to load schema metadata through your own query API, without an `IModelDb` or `IModelConnection`.\r\n * The manager deals only in schema names, blobs and the manifest; everything transport-specific -\r\n * pragma strings, format-version pinning - belongs to the provider.\r\n * @beta\r\n */\r\nexport interface SchemaViewDataProvider {\r\n /** Fetch the blob containing every schema in the iModel (`PRAGMA schema_view`). */\r\n fetchFullBlob(): Promise<SchemaViewBlob>;\r\n\r\n /** Fetch one blob containing exactly the given schemas (`PRAGMA schema_view_fragment`), subject\r\n * to SchemaView's schema exclusions. The manager computes the reference closure and omits schemas\r\n * already loaded, so references may target schemas in this blob or in previously fetched blobs.\r\n * Use {@link schemaViewFormatVersion} to pin the format: `PRAGMA schema_view_fragment('v<N>;name,name,...')`. */\r\n fetchFragmentBlob(schemaNames: readonly string[]): Promise<SchemaViewBlob>;\r\n\r\n /** Fetch the reference graph of every schema in the iModel, built from ECDbMeta\r\n * (`meta.ECSchemaDef` + `meta.SchemaHasSchemaReferences`; see {@link SchemaManifest.fromRows}). */\r\n fetchManifest(): Promise<SchemaManifest>;\r\n\r\n /** Fetch the current schema-identity token (`PRAGMA checksum(schema_token)`). */\r\n fetchSchemaToken(): Promise<string>;\r\n}\r\n\r\n/** Options for `getSchemaView` (see `IModelDb.getSchemaView` / `IModelConnection.getSchemaView`,\r\n * which delegate to {@link SchemaViewManager.getSchemaView}).\r\n * @beta\r\n */\r\nexport interface GetSchemaViewArgs {\r\n /** When provided, return a view loaded with at least these schemas plus their references, instead\r\n * of every schema in the iModel.\r\n *\r\n * The view accumulates: one instance is reused across calls, so a later request - with different\r\n * schemas or with no filter at all - merges the still-missing schemas into the same view and\r\n * everything requested earlier stays available. It resets when the iModel's schemas change.\r\n *\r\n * Names the iModel does not contain are ignored. Omitting this option loads all schemas, identical\r\n * to calling `getSchemaView()` with no arguments.\r\n */\r\n readonly schemas?: readonly string[];\r\n\r\n /** When `true`, discard whatever is currently loaded and rebuild the view from scratch before\r\n * returning it. The previously returned view instance (if any) is marked outdated. Like every other\r\n * request this is serialized behind any in-flight load, so it never leaves the view in an invalid\r\n * intermediate state.\r\n * @internal\r\n */\r\n readonly forceReload?: boolean;\r\n}\r\n\r\n/** Owns the lifetime of one iModel's {@link (SchemaView:class)}: lazy loading, incremental (filtered)\r\n * loading, serialization of concurrent requests, and invalidation. All data access goes through the\r\n * supplied {@link SchemaViewDataProvider}.\r\n *\r\n * Keep one manager per iModel connection. Calls to {@link SchemaViewManager.getSchemaView} reuse\r\n * one accumulating view until it is invalidated. The manager does not monitor schema changes;\r\n * call {@link SchemaViewManager.reset} after a known change, or await\r\n * {@link SchemaViewManager.invalidateIfChanged} after an operation that may have changed schemas.\r\n * @beta\r\n */\r\nexport class SchemaViewManager {\r\n private readonly _dataProvider: SchemaViewDataProvider;\r\n\r\n /** The single accumulating view, held as a promise so all requests chain onto it and never overlap.\r\n * Undefined (or resolving to undefined) means nothing is loaded. */\r\n private _viewPromise?: Promise<SchemaView | undefined>;\r\n\r\n /** Reference graph for incremental loading; undefined when the view is (or will be) fully loaded. */\r\n private _manifest?: SchemaManifest;\r\n\r\n /** Schema-identity token the manifest - and thus every fragment merged under it - belongs to. */\r\n private _manifestToken?: string;\r\n\r\n /** Lower-cased names already merged into the view (incremental mode only). */\r\n private readonly _loadedSchemaNames = new Set<string>();\r\n\r\n public constructor(dataProvider: SchemaViewDataProvider) {\r\n this._dataProvider = dataProvider;\r\n }\r\n\r\n /** Get the schema view, loading the requested schemas and their references that are not present\r\n * yet. Omitting the schema filter loads every schema. Calls accumulate into the same view until\r\n * it is invalidated. See {@link GetSchemaViewArgs} for filtering semantics.\r\n */\r\n public async getSchemaView(args?: GetSchemaViewArgs): Promise<SchemaView> {\r\n const previous = this._viewPromise;\r\n const next = this._loadSchemaView(previous, args?.schemas, args?.forceReload === true);\r\n this._viewPromise = next;\r\n return next;\r\n }\r\n\r\n /** Throw away the current schema view. Called by the host when schemas may have changed (e.g.\r\n * `IModelDb.clearCaches` after a schema import). Chains behind any in-flight load and marks the\r\n * discarded view outdated; the next getSchemaView starts over.\r\n */\r\n public reset(): void {\r\n if (this._viewPromise) {\r\n this._viewPromise = this._viewPromise.then(\r\n (view) => { view?.markOutdated(); this._resetIncrementalState(); return undefined; },\r\n () => { this._resetIncrementalState(); return undefined; },\r\n );\r\n }\r\n }\r\n\r\n /** Check whether the iModel's schemas have changed since the current view was built, and discard\r\n * the view only if they have. For hosts that *cannot* determine whether an operation actually\r\n * modified schemas - e.g. `BriefcaseConnection.pullChanges` on the frontend, whose IPC response\r\n * carries only the new changeset id, not the applied changesets' types. Discarding after every\r\n * such operation would reload unnecessarily in the common case where schemas are unchanged, so\r\n * this compares the cheap schema-identity token instead.\r\n * @note If the token cannot be fetched, the view is discarded rather than risking stale metadata.\r\n */\r\n public async invalidateIfChanged(): Promise<void> {\r\n const previous = this._viewPromise;\r\n if (previous === undefined)\r\n return;\r\n // Queue the check on the same chain as loading, so a getSchemaView arriving while the token is\r\n // in flight cannot swap in a new promise for the same stale view and hide the schema change.\r\n const next = this._invalidateIfChanged(previous);\r\n this._viewPromise = next;\r\n await next;\r\n }\r\n\r\n /** Serialized body of {@link SchemaViewManager.invalidateIfChanged}. Resolves to the view to keep,\r\n * or to `undefined` when it was discarded and the next getSchemaView has to start over.\r\n */\r\n private async _invalidateIfChanged(previous: Promise<SchemaView | undefined>): Promise<SchemaView | undefined> {\r\n let existing: SchemaView | undefined;\r\n try {\r\n existing = await previous;\r\n } catch {\r\n return undefined;\r\n }\r\n if (existing === undefined)\r\n return undefined;\r\n\r\n try {\r\n if (await this._dataProvider.fetchSchemaToken() === existing.schemaToken)\r\n return existing;\r\n } catch {\r\n // Cannot verify the cached view: drop it rather than risk stale metadata.\r\n }\r\n existing.markOutdated();\r\n this._resetIncrementalState();\r\n return undefined;\r\n }\r\n\r\n /** Serialized body of {@link SchemaViewManager.getSchemaView}. On failure it resets and rejects,\r\n * so the next call starts over.\r\n */\r\n private async _loadSchemaView(previous: Promise<SchemaView | undefined> | undefined, schemas: readonly string[] | undefined, forceReload: boolean): Promise<SchemaView> {\r\n let currentView: SchemaView | undefined;\r\n if (previous !== undefined) {\r\n try {\r\n currentView = await previous;\r\n } catch {\r\n currentView = undefined; // the failed load already reset; start over\r\n }\r\n }\r\n\r\n if (forceReload) {\r\n currentView?.markOutdated();\r\n currentView = undefined;\r\n this._resetIncrementalState();\r\n }\r\n\r\n try {\r\n return await this._ensureSchemasLoaded(currentView, schemas);\r\n } catch (err) {\r\n // A failed merge may have left the view partially extended - discard everything.\r\n currentView?.markOutdated();\r\n this._resetIncrementalState();\r\n throw err;\r\n }\r\n }\r\n\r\n /** Clear the incremental schema-view bookkeeping. */\r\n private _resetIncrementalState(): void {\r\n this._manifest = undefined;\r\n this._manifestToken = undefined;\r\n this._loadedSchemaNames.clear();\r\n }\r\n\r\n /** Ensures the requested schemas (or all schemas, when no filter is given) are present in\r\n * `currentView` (or a freshly created view) and returns it. The first load fixes the strategy:\r\n * no filter fetches everything as one full blob; a filter fetches fragments and keeps the\r\n * manifest and loaded-name set so later calls extend the same view. Once every schema is loaded\r\n * the incremental state is dropped, collapsing back to full mode.\r\n */\r\n private async _ensureSchemasLoaded(currentView: SchemaView | undefined, schemas: readonly string[] | undefined, isRetry = false): Promise<SchemaView> {\r\n const isFirstLoad = currentView === undefined;\r\n // No manifest means everything is loaded; in incremental mode a filtered request is satisfied as\r\n // soon as every requested name is present.\r\n if (!isFirstLoad &&\r\n (this._manifest === undefined ||\r\n (schemas !== undefined && schemas.every((name) => this._loadedSchemaNames.has(name.toLowerCase())))))\r\n return currentView;\r\n\r\n if (isFirstLoad && schemas === undefined) {\r\n const blob = await this._dataProvider.fetchFullBlob();\r\n const schemaView = SchemaView.fromBinary(blob.data, blob.schemaToken);\r\n this._resetIncrementalState();\r\n return schemaView;\r\n }\r\n\r\n if (this._manifest === undefined) {\r\n // Token first: any schema change after this point shows up as a token mismatch below.\r\n this._manifestToken = await this._dataProvider.fetchSchemaToken();\r\n this._manifest = await this._dataProvider.fetchManifest();\r\n }\r\n const manifest = this._manifest;\r\n\r\n const requested = schemas ?? manifest.getAvailableSchemaNames();\r\n const namesToLoad = manifest.getSchemaClosure(requested).filter((name) => !this._loadedSchemaNames.has(name.toLowerCase()));\r\n const husk = currentView ?? SchemaView.createMergeable(this._manifestToken);\r\n if (namesToLoad.length > 0) {\r\n const blob = await this._dataProvider.fetchFragmentBlob(namesToLoad);\r\n if (blob.schemaToken !== this._manifestToken) {\r\n // Schemas changed between the manifest and fragment fetches. Everything loaded so far\r\n // belongs to the old revision - discard it and start over, once.\r\n currentView?.markOutdated();\r\n this._resetIncrementalState();\r\n if (isRetry)\r\n throw new Error(\"The iModel's schemas changed while the schema view was loading.\");\r\n return this._ensureSchemasLoaded(undefined, schemas, true);\r\n }\r\n husk.mergeFragment(blob.data);\r\n // Record the whole closure as loaded, including *excluded* schemas (e.g. CoreCustomAttributes)\r\n // the writer emits no rows for, so later requests prune them instead of re-fetching.\r\n for (const name of namesToLoad)\r\n this._loadedSchemaNames.add(name.toLowerCase());\r\n }\r\n // Once every schema is loaded, collapse back to full mode (the size check is just a fast path).\r\n if (schemas === undefined || (this._loadedSchemaNames.size >= manifest.schemaCount && manifest.entries.every((entry) => this._loadedSchemaNames.has(entry.name.toLowerCase()))))\r\n this._resetIncrementalState();\r\n return husk;\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/ecschema-metadata",
3
- "version": "5.14.0-dev.8",
3
+ "version": "5.15.0-dev.1",
4
4
  "description": "ECObjects core concepts in typescript",
5
5
  "license": "MIT",
6
6
  "main": "lib/cjs/ecschema-metadata.js",
@@ -41,13 +41,13 @@
41
41
  "rimraf": "^6.0.1",
42
42
  "typescript": "~5.6.2",
43
43
  "vitest": "^4.1.10",
44
- "@itwin/build-tools": "5.14.0-dev.8",
45
- "@itwin/core-quantity": "5.14.0-dev.8",
46
- "@itwin/core-bentley": "5.14.0-dev.8"
44
+ "@itwin/core-bentley": "5.15.0-dev.1",
45
+ "@itwin/build-tools": "5.15.0-dev.1",
46
+ "@itwin/core-quantity": "5.15.0-dev.1"
47
47
  },
48
48
  "peerDependencies": {
49
- "@itwin/core-bentley": "5.14.0-dev.8",
50
- "@itwin/core-quantity": "5.14.0-dev.8"
49
+ "@itwin/core-bentley": "5.15.0-dev.1",
50
+ "@itwin/core-quantity": "5.15.0-dev.1"
51
51
  },
52
52
  "scripts": {
53
53
  "build": "npm run -s build:cjs && npm run -s build:esm",