@itwin/core-backend 5.0.0-dev.117 → 5.0.0-dev.119

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 (169) hide show
  1. package/lib/cjs/BackendHubAccess.d.ts +1 -1
  2. package/lib/cjs/BackendHubAccess.js +1 -1
  3. package/lib/cjs/BackendHubAccess.js.map +1 -1
  4. package/lib/cjs/Category.d.ts +4 -4
  5. package/lib/cjs/Category.js +4 -4
  6. package/lib/cjs/Category.js.map +1 -1
  7. package/lib/cjs/ClassRegistry.d.ts +1 -1
  8. package/lib/cjs/ClassRegistry.js +1 -1
  9. package/lib/cjs/ClassRegistry.js.map +1 -1
  10. package/lib/cjs/CodeSpecs.d.ts +1 -1
  11. package/lib/cjs/CodeSpecs.js +1 -1
  12. package/lib/cjs/CodeSpecs.js.map +1 -1
  13. package/lib/cjs/DisplayStyle.d.ts +4 -4
  14. package/lib/cjs/DisplayStyle.js +3 -3
  15. package/lib/cjs/DisplayStyle.js.map +1 -1
  16. package/lib/cjs/ECDb.d.ts +4 -4
  17. package/lib/cjs/ECDb.d.ts.map +1 -1
  18. package/lib/cjs/ECDb.js +4 -4
  19. package/lib/cjs/ECDb.js.map +1 -1
  20. package/lib/cjs/ECSqlStatement.d.ts +6 -6
  21. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  22. package/lib/cjs/ECSqlStatement.js +4 -4
  23. package/lib/cjs/ECSqlStatement.js.map +1 -1
  24. package/lib/cjs/Element.d.ts +51 -51
  25. package/lib/cjs/Element.js +51 -51
  26. package/lib/cjs/Element.js.map +1 -1
  27. package/lib/cjs/ElementAspect.d.ts +8 -8
  28. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  29. package/lib/cjs/ElementAspect.js +8 -8
  30. package/lib/cjs/ElementAspect.js.map +1 -1
  31. package/lib/cjs/Entity.d.ts +3 -3
  32. package/lib/cjs/Entity.js +2 -2
  33. package/lib/cjs/Entity.js.map +1 -1
  34. package/lib/cjs/IModelDb.d.ts +17 -17
  35. package/lib/cjs/IModelDb.d.ts.map +1 -1
  36. package/lib/cjs/IModelDb.js +18 -17
  37. package/lib/cjs/IModelDb.js.map +1 -1
  38. package/lib/cjs/IModelElementCloneContext.d.ts +1 -1
  39. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  40. package/lib/cjs/IModelElementCloneContext.js +1 -1
  41. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  42. package/lib/cjs/IModelHost.d.ts +2 -2
  43. package/lib/cjs/IModelHost.js +2 -2
  44. package/lib/cjs/IModelHost.js.map +1 -1
  45. package/lib/cjs/Material.d.ts +1 -1
  46. package/lib/cjs/Material.js +1 -1
  47. package/lib/cjs/Material.js.map +1 -1
  48. package/lib/cjs/Model.d.ts +22 -22
  49. package/lib/cjs/Model.js +22 -22
  50. package/lib/cjs/Model.js.map +1 -1
  51. package/lib/cjs/SQLiteDb.d.ts +1 -1
  52. package/lib/cjs/SQLiteDb.js +1 -1
  53. package/lib/cjs/SQLiteDb.js.map +1 -1
  54. package/lib/cjs/SqliteStatement.d.ts +1 -1
  55. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  56. package/lib/cjs/SqliteStatement.js +1 -1
  57. package/lib/cjs/SqliteStatement.js.map +1 -1
  58. package/lib/cjs/TextAnnotationElement.d.ts +2 -2
  59. package/lib/cjs/TextAnnotationElement.js +2 -2
  60. package/lib/cjs/TextAnnotationElement.js.map +1 -1
  61. package/lib/cjs/Texture.d.ts +1 -1
  62. package/lib/cjs/Texture.js +1 -1
  63. package/lib/cjs/Texture.js.map +1 -1
  64. package/lib/cjs/TxnManager.d.ts +4 -4
  65. package/lib/cjs/TxnManager.js +1 -1
  66. package/lib/cjs/TxnManager.js.map +1 -1
  67. package/lib/cjs/ViewDefinition.d.ts +14 -14
  68. package/lib/cjs/ViewDefinition.js +14 -14
  69. package/lib/cjs/ViewDefinition.js.map +1 -1
  70. package/lib/cjs/core-backend.d.ts.map +1 -1
  71. package/lib/cjs/core-backend.js +20 -0
  72. package/lib/cjs/core-backend.js.map +1 -1
  73. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  74. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +1 -1
  75. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  76. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  77. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  78. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  79. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  80. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  81. package/lib/esm/BackendHubAccess.d.ts +1 -1
  82. package/lib/esm/BackendHubAccess.js +1 -1
  83. package/lib/esm/BackendHubAccess.js.map +1 -1
  84. package/lib/esm/Category.d.ts +4 -4
  85. package/lib/esm/Category.js +4 -4
  86. package/lib/esm/Category.js.map +1 -1
  87. package/lib/esm/ClassRegistry.d.ts +1 -1
  88. package/lib/esm/ClassRegistry.js +1 -1
  89. package/lib/esm/ClassRegistry.js.map +1 -1
  90. package/lib/esm/CodeSpecs.d.ts +1 -1
  91. package/lib/esm/CodeSpecs.js +1 -1
  92. package/lib/esm/CodeSpecs.js.map +1 -1
  93. package/lib/esm/DisplayStyle.d.ts +4 -4
  94. package/lib/esm/DisplayStyle.js +3 -3
  95. package/lib/esm/DisplayStyle.js.map +1 -1
  96. package/lib/esm/ECDb.d.ts +4 -4
  97. package/lib/esm/ECDb.d.ts.map +1 -1
  98. package/lib/esm/ECDb.js +4 -4
  99. package/lib/esm/ECDb.js.map +1 -1
  100. package/lib/esm/ECSqlStatement.d.ts +6 -6
  101. package/lib/esm/ECSqlStatement.d.ts.map +1 -1
  102. package/lib/esm/ECSqlStatement.js +4 -4
  103. package/lib/esm/ECSqlStatement.js.map +1 -1
  104. package/lib/esm/Element.d.ts +51 -51
  105. package/lib/esm/Element.js +51 -51
  106. package/lib/esm/Element.js.map +1 -1
  107. package/lib/esm/ElementAspect.d.ts +8 -8
  108. package/lib/esm/ElementAspect.d.ts.map +1 -1
  109. package/lib/esm/ElementAspect.js +8 -8
  110. package/lib/esm/ElementAspect.js.map +1 -1
  111. package/lib/esm/Entity.d.ts +3 -3
  112. package/lib/esm/Entity.js +2 -2
  113. package/lib/esm/Entity.js.map +1 -1
  114. package/lib/esm/IModelDb.d.ts +17 -17
  115. package/lib/esm/IModelDb.d.ts.map +1 -1
  116. package/lib/esm/IModelDb.js +18 -17
  117. package/lib/esm/IModelDb.js.map +1 -1
  118. package/lib/esm/IModelElementCloneContext.d.ts +1 -1
  119. package/lib/esm/IModelElementCloneContext.d.ts.map +1 -1
  120. package/lib/esm/IModelElementCloneContext.js +1 -1
  121. package/lib/esm/IModelElementCloneContext.js.map +1 -1
  122. package/lib/esm/IModelHost.d.ts +2 -2
  123. package/lib/esm/IModelHost.js +2 -2
  124. package/lib/esm/IModelHost.js.map +1 -1
  125. package/lib/esm/Material.d.ts +1 -1
  126. package/lib/esm/Material.js +1 -1
  127. package/lib/esm/Material.js.map +1 -1
  128. package/lib/esm/Model.d.ts +22 -22
  129. package/lib/esm/Model.js +22 -22
  130. package/lib/esm/Model.js.map +1 -1
  131. package/lib/esm/SQLiteDb.d.ts +1 -1
  132. package/lib/esm/SQLiteDb.js +1 -1
  133. package/lib/esm/SQLiteDb.js.map +1 -1
  134. package/lib/esm/SqliteStatement.d.ts +1 -1
  135. package/lib/esm/SqliteStatement.d.ts.map +1 -1
  136. package/lib/esm/SqliteStatement.js +1 -1
  137. package/lib/esm/SqliteStatement.js.map +1 -1
  138. package/lib/esm/TextAnnotationElement.d.ts +2 -2
  139. package/lib/esm/TextAnnotationElement.js +2 -2
  140. package/lib/esm/TextAnnotationElement.js.map +1 -1
  141. package/lib/esm/Texture.d.ts +1 -1
  142. package/lib/esm/Texture.js +1 -1
  143. package/lib/esm/Texture.js.map +1 -1
  144. package/lib/esm/TxnManager.d.ts +4 -4
  145. package/lib/esm/TxnManager.js +1 -1
  146. package/lib/esm/TxnManager.js.map +1 -1
  147. package/lib/esm/ViewDefinition.d.ts +14 -14
  148. package/lib/esm/ViewDefinition.js +14 -14
  149. package/lib/esm/ViewDefinition.js.map +1 -1
  150. package/lib/esm/core-backend.d.ts.map +1 -1
  151. package/lib/esm/core-backend.js +20 -0
  152. package/lib/esm/core-backend.js.map +1 -1
  153. package/lib/esm/rpc-impl/IModelReadRpcImpl.d.ts +1 -1
  154. package/lib/esm/rpc-impl/IModelReadRpcImpl.js +1 -1
  155. package/lib/esm/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  156. package/lib/esm/rpc-impl/RpcBriefcaseUtility.d.ts +2 -2
  157. package/lib/esm/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  158. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.d.ts +1 -1
  159. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js +1 -1
  160. package/lib/esm/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  161. package/lib/esm/test/TestUtils.d.ts +1 -1
  162. package/lib/esm/test/TestUtils.d.ts.map +1 -1
  163. package/lib/esm/test/TestUtils.js +1 -1
  164. package/lib/esm/test/TestUtils.js.map +1 -1
  165. package/lib/esm/test/imodel/IModel.test.js +28 -1
  166. package/lib/esm/test/imodel/IModel.test.js.map +1 -1
  167. package/lib/esm/test/standalone/GeometryStream.test.js +49 -1
  168. package/lib/esm/test/standalone/GeometryStream.test.js.map +1 -1
  169. package/package.json +12 -12
@@ -20,7 +20,7 @@ export declare class LockConflict extends IModelError {
20
20
  briefcaseAlias: string, msg: "shared lock is held" | "exclusive lock is already held");
21
21
  }
22
22
  /** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements).
23
- * @deprecated in 4.7 Use [LockState]($common)
23
+ * @deprecated in 4.7 - will not be removed until after 2026-06-13. Use [LockState]($common)
24
24
  * @public
25
25
  */
26
26
  export declare enum LockState {
@@ -28,7 +28,7 @@ class LockConflict extends core_common_1.IModelError {
28
28
  }
29
29
  exports.LockConflict = LockConflict;
30
30
  /** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements).
31
- * @deprecated in 4.7 Use [LockState]($common)
31
+ * @deprecated in 4.7 - will not be removed until after 2026-06-13. Use [LockState]($common)
32
32
  * @public
33
33
  */
34
34
  var LockState;
@@ -1 +1 @@
1
- {"version":3,"file":"BackendHubAccess.js","sourceRoot":"","sources":["../../src/BackendHubAccess.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAI4B;AAI5B;;EAEE;AACF,MAAa,YAAa,SAAQ,yBAAW;IAGzB;IAEA;IAJlB;IACE,mCAAmC;IACnB,WAAwB;IACxC,sCAAsC;IACtB,cAAsB,EACtC,GAA6D;QAE7D,KAAK,CAAC,8BAAe,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QALxC,gBAAW,GAAX,WAAW,CAAa;QAExB,mBAAc,GAAd,cAAc,CAAQ;IAIxC,CAAC;CACF;AAVD,oCAUC;AAED;;;GAGG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAgC;IAChC,yCAAQ,CAAA;IACR,mJAAmJ;IACnJ,6CAAU,CAAA;IACV;;OAEG;IACH,mDAAa,CAAA;AACf,CAAC,EATW,SAAS,yBAAT,SAAS,QASpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HubAccess\n */\n\nimport { AccessToken, GuidString, Id64String, IModelHubStatus } from \"@itwin/core-bentley\";\nimport {\n BriefcaseId, ChangesetFileProps, ChangesetIdWithIndex, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange,\n LockState as CommonLockState, IModelError, IModelVersion,\n LocalDirName, LocalFileName,\n} from \"@itwin/core-common\";\nimport { CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\nimport type { TokenArg } from \"./IModelDb\";\n\n/** Exception thrown if lock cannot be acquired.\n * @beta\n*/\nexport class LockConflict extends IModelError {\n public constructor(\n /** Id of Briefcase holding lock */\n public readonly briefcaseId: BriefcaseId,\n /** Alias of Briefcase holding lock */\n public readonly briefcaseAlias: string,\n msg: \"shared lock is held\" | \"exclusive lock is already held\",\n ) {\n super(IModelHubStatus.LockOwnedByAnotherBriefcase, msg);\n }\n}\n\n/** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements).\n * @deprecated in 4.7 Use [LockState]($common)\n * @public\n */\nexport enum LockState {\n /** The element is not locked */\n None = 0,\n /** Holding a shared lock on an element blocks other users from acquiring the Exclusive lock it. More than one user may acquire the shared lock. */\n Shared = 1,\n /** A Lock that permits modifications to an element and blocks other users from making modifications to it.\n * Holding an exclusive lock on an \"owner\" (a model or a parent element), implicitly exclusively locks all its members.\n */\n Exclusive = 2,\n}\n\n/**\n * The properties to access a V2 checkpoint through a daemon.\n * @public\n */\nexport interface V2CheckpointAccessProps {\n /** blob store account name. */\n readonly accountName: string;\n /** AccessToken that grants access to the container. */\n readonly sasToken: AccessToken;\n /** The name of the iModel's blob store container holding all checkpoints. */\n readonly containerId: string;\n /** The name of the virtual file within the container, used for the checkpoint */\n readonly dbName: string;\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\n readonly storageType: string;\n}\n\n/**\n * Maps element Ids to their corresponding [LockState]($common)s.\n * @public\n */\nexport type LockMap = Map<Id64String, CommonLockState>;\n\n/**\n * The properties of a lock that may be obtained from a lock server.\n * @public\n */\nexport interface LockProps {\n /** The elementId for the lock */\n readonly id: Id64String;\n /** the lock state */\n readonly state: CommonLockState;\n}\n\n/**\n * Argument for cancelling and tracking download progress.\n * @public\n */\nexport interface DownloadProgressArg {\n /** Called to show progress during a download. If this function returns non-zero, the download is aborted. */\n progressCallback?: ProgressFunction;\n}\n\n/**\n * Argument for methods that must supply an iTwinId\n * @public\n */\nexport interface ITwinIdArg {\n readonly iTwinId: GuidString;\n}\n\n/**\n * Argument for methods that must supply an IModelId\n * @public\n */\nexport interface IModelIdArg extends TokenArg {\n readonly iModelId: GuidString;\n}\n\n/**\n * Argument for acquiring a new BriefcaseId\n * @public\n */\nexport interface AcquireNewBriefcaseIdArg extends IModelIdArg {\n /** A string to be reported to other users to identify this briefcase, for example in the case of conflicts or lock collisions. */\n readonly briefcaseAlias?: string;\n}\n\n/** Argument for methods that must supply an IModel name and iTwinId\n * @public\n */\nexport interface IModelNameArg extends TokenArg, ITwinIdArg {\n readonly iModelName: string;\n}\n\n/** Argument for methods that must supply an IModelId and a BriefcaseId\n * @public\n */\nexport interface BriefcaseIdArg extends IModelIdArg {\n readonly briefcaseId: BriefcaseId;\n}\n\n/** Argument for methods that must supply a briefcaseId and a changeset\n * @public\n */\nexport interface BriefcaseDbArg extends BriefcaseIdArg {\n readonly changeset: ChangesetIdWithIndex;\n}\n\n/** Argument for methods that must supply an IModelId and a changeset\n * @public\n */\nexport interface ChangesetArg extends IModelIdArg {\n readonly changeset: ChangesetIndexOrId;\n}\n\n/** Argument for downloading a changeset.\n * @public\n */\nexport interface DownloadChangesetArg extends ChangesetArg, DownloadProgressArg {\n /** Directory where the changeset should be downloaded. */\n targetDir: LocalDirName;\n}\n\n/** @internal */\nexport interface ChangesetIndexArg extends IModelIdArg {\n readonly changeset: ChangesetIdWithIndex;\n}\n\n/** Argument for methods that must supply an IModelId and a range of Changesets.\n * @public\n */\nexport interface ChangesetRangeArg extends IModelIdArg {\n /** the range of changesets desired. If is undefined, *all* changesets are returned. */\n readonly range?: ChangesetRange;\n}\n\n/** Argument for downloading a changeset range.\n * @public\n */\nexport interface DownloadChangesetRangeArg extends ChangesetRangeArg, DownloadProgressArg {\n /** Directory where the changesets should be downloaded. */\n targetDir: LocalDirName;\n}\n\n/**\n * Arguments to create a new iModel in iModelHub\n * @public\n */\nexport interface CreateNewIModelProps extends IModelNameArg {\n readonly description?: string;\n readonly version0?: LocalFileName;\n readonly noLocks?: true;\n}\n\n/**\n * Methods for accessing services of IModelHub from an iTwin.js backend.\n * Generally direct access to these methods should not be required, since higher-level apis are provided.\n * @public\n */\nexport interface BackendHubAccess {\n /** Download all the changesets in the specified range. */\n downloadChangesets: (arg: DownloadChangesetRangeArg) => Promise<ChangesetFileProps[]>;\n /** Download a single changeset. */\n downloadChangeset: (arg: DownloadChangesetArg) => Promise<ChangesetFileProps>;\n /** Query the changeset properties given a ChangesetIndex */\n queryChangeset: (arg: ChangesetArg) => Promise<ChangesetProps>;\n /** Query an array of changeset properties given a range of ChangesetIndexes */\n queryChangesets: (arg: ChangesetRangeArg) => Promise<ChangesetProps[]>;\n /** Push a changeset to iModelHub. Returns the newly pushed changeset's index */\n pushChangeset: (arg: IModelIdArg & { changesetProps: ChangesetFileProps }) => Promise<ChangesetIndex>;\n /** Get the ChangesetProps of the most recent changeset */\n getLatestChangeset: (arg: IModelIdArg) => Promise<ChangesetProps>;\n /** Get the ChangesetProps for an IModelVersion */\n getChangesetFromVersion: (arg: IModelIdArg & { version: IModelVersion }) => Promise<ChangesetProps>;\n /** Get the ChangesetProps for a named version */\n getChangesetFromNamedVersion: (arg: IModelIdArg & { versionName: string }) => Promise<ChangesetProps>;\n\n /** Acquire a new briefcaseId for the supplied iModelId\n * @note usually there should only be one briefcase per iModel per user.\n */\n acquireNewBriefcaseId: (arg: AcquireNewBriefcaseIdArg) => Promise<BriefcaseId>;\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\n releaseBriefcase: (arg: BriefcaseIdArg) => Promise<void>;\n\n /** get an array of the briefcases assigned to a user. */\n getMyBriefcaseIds: (arg: IModelIdArg) => Promise<BriefcaseId[]>;\n\n /** Get the access props for a V2 checkpoint. Returns undefined if no V2 checkpoint exists. */\n queryV2Checkpoint: (arg: CheckpointProps) => Promise<V2CheckpointAccessProps | undefined>;\n\n /**\n * acquire one or more locks. Throws if unsuccessful. If *any* lock cannot be obtained, no locks are acquired\n * @throws ConflictingLocksError if one or more requested locks are held by other briefcases.\n */\n acquireLocks: (arg: BriefcaseDbArg, locks: LockMap) => Promise<void>;\n\n /** Get the list of all held locks for a briefcase. This can be very expensive and is currently used only for tests. */\n queryAllLocks: (arg: BriefcaseDbArg) => Promise<LockProps[]>;\n\n /** Release all currently held locks */\n releaseAllLocks: (arg: BriefcaseDbArg) => Promise<void>;\n\n /** Get the iModelId of an iModel by name. Undefined if no iModel with that name exists. */\n queryIModelByName: (arg: IModelNameArg) => Promise<GuidString | undefined>;\n\n /** create a new iModel. Returns the Guid of the newly created iModel */\n createNewIModel: (arg: CreateNewIModelProps) => Promise<GuidString>;\n\n /** delete an iModel */\n deleteIModel: (arg: IModelIdArg & ITwinIdArg) => Promise<void>;\n}\n"]}
1
+ {"version":3,"file":"BackendHubAccess.js","sourceRoot":"","sources":["../../src/BackendHubAccess.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2F;AAC3F,oDAI4B;AAI5B;;EAEE;AACF,MAAa,YAAa,SAAQ,yBAAW;IAGzB;IAEA;IAJlB;IACE,mCAAmC;IACnB,WAAwB;IACxC,sCAAsC;IACtB,cAAsB,EACtC,GAA6D;QAE7D,KAAK,CAAC,8BAAe,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC;QALxC,gBAAW,GAAX,WAAW,CAAa;QAExB,mBAAc,GAAd,cAAc,CAAQ;IAIxC,CAAC;CACF;AAVD,oCAUC;AAED;;;GAGG;AACH,IAAY,SASX;AATD,WAAY,SAAS;IACnB,gCAAgC;IAChC,yCAAQ,CAAA;IACR,mJAAmJ;IACnJ,6CAAU,CAAA;IACV;;OAEG;IACH,mDAAa,CAAA;AACf,CAAC,EATW,SAAS,yBAAT,SAAS,QASpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HubAccess\n */\n\nimport { AccessToken, GuidString, Id64String, IModelHubStatus } from \"@itwin/core-bentley\";\nimport {\n BriefcaseId, ChangesetFileProps, ChangesetIdWithIndex, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange,\n LockState as CommonLockState, IModelError, IModelVersion,\n LocalDirName, LocalFileName,\n} from \"@itwin/core-common\";\nimport { CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\nimport type { TokenArg } from \"./IModelDb\";\n\n/** Exception thrown if lock cannot be acquired.\n * @beta\n*/\nexport class LockConflict extends IModelError {\n public constructor(\n /** Id of Briefcase holding lock */\n public readonly briefcaseId: BriefcaseId,\n /** Alias of Briefcase holding lock */\n public readonly briefcaseAlias: string,\n msg: \"shared lock is held\" | \"exclusive lock is already held\",\n ) {\n super(IModelHubStatus.LockOwnedByAnotherBriefcase, msg);\n }\n}\n\n/** The state of a lock. See [Acquiring locks on elements.]($docs/learning/backend/ConcurrencyControl.md#acquiring-locks-on-elements).\n * @deprecated in 4.7 - will not be removed until after 2026-06-13. Use [LockState]($common)\n * @public\n */\nexport enum LockState {\n /** The element is not locked */\n None = 0,\n /** Holding a shared lock on an element blocks other users from acquiring the Exclusive lock it. More than one user may acquire the shared lock. */\n Shared = 1,\n /** A Lock that permits modifications to an element and blocks other users from making modifications to it.\n * Holding an exclusive lock on an \"owner\" (a model or a parent element), implicitly exclusively locks all its members.\n */\n Exclusive = 2,\n}\n\n/**\n * The properties to access a V2 checkpoint through a daemon.\n * @public\n */\nexport interface V2CheckpointAccessProps {\n /** blob store account name. */\n readonly accountName: string;\n /** AccessToken that grants access to the container. */\n readonly sasToken: AccessToken;\n /** The name of the iModel's blob store container holding all checkpoints. */\n readonly containerId: string;\n /** The name of the virtual file within the container, used for the checkpoint */\n readonly dbName: string;\n /** blob storage module: e.g. \"azure\", \"google\", \"aws\". May also include URI style parameters. */\n readonly storageType: string;\n}\n\n/**\n * Maps element Ids to their corresponding [LockState]($common)s.\n * @public\n */\nexport type LockMap = Map<Id64String, CommonLockState>;\n\n/**\n * The properties of a lock that may be obtained from a lock server.\n * @public\n */\nexport interface LockProps {\n /** The elementId for the lock */\n readonly id: Id64String;\n /** the lock state */\n readonly state: CommonLockState;\n}\n\n/**\n * Argument for cancelling and tracking download progress.\n * @public\n */\nexport interface DownloadProgressArg {\n /** Called to show progress during a download. If this function returns non-zero, the download is aborted. */\n progressCallback?: ProgressFunction;\n}\n\n/**\n * Argument for methods that must supply an iTwinId\n * @public\n */\nexport interface ITwinIdArg {\n readonly iTwinId: GuidString;\n}\n\n/**\n * Argument for methods that must supply an IModelId\n * @public\n */\nexport interface IModelIdArg extends TokenArg {\n readonly iModelId: GuidString;\n}\n\n/**\n * Argument for acquiring a new BriefcaseId\n * @public\n */\nexport interface AcquireNewBriefcaseIdArg extends IModelIdArg {\n /** A string to be reported to other users to identify this briefcase, for example in the case of conflicts or lock collisions. */\n readonly briefcaseAlias?: string;\n}\n\n/** Argument for methods that must supply an IModel name and iTwinId\n * @public\n */\nexport interface IModelNameArg extends TokenArg, ITwinIdArg {\n readonly iModelName: string;\n}\n\n/** Argument for methods that must supply an IModelId and a BriefcaseId\n * @public\n */\nexport interface BriefcaseIdArg extends IModelIdArg {\n readonly briefcaseId: BriefcaseId;\n}\n\n/** Argument for methods that must supply a briefcaseId and a changeset\n * @public\n */\nexport interface BriefcaseDbArg extends BriefcaseIdArg {\n readonly changeset: ChangesetIdWithIndex;\n}\n\n/** Argument for methods that must supply an IModelId and a changeset\n * @public\n */\nexport interface ChangesetArg extends IModelIdArg {\n readonly changeset: ChangesetIndexOrId;\n}\n\n/** Argument for downloading a changeset.\n * @public\n */\nexport interface DownloadChangesetArg extends ChangesetArg, DownloadProgressArg {\n /** Directory where the changeset should be downloaded. */\n targetDir: LocalDirName;\n}\n\n/** @internal */\nexport interface ChangesetIndexArg extends IModelIdArg {\n readonly changeset: ChangesetIdWithIndex;\n}\n\n/** Argument for methods that must supply an IModelId and a range of Changesets.\n * @public\n */\nexport interface ChangesetRangeArg extends IModelIdArg {\n /** the range of changesets desired. If is undefined, *all* changesets are returned. */\n readonly range?: ChangesetRange;\n}\n\n/** Argument for downloading a changeset range.\n * @public\n */\nexport interface DownloadChangesetRangeArg extends ChangesetRangeArg, DownloadProgressArg {\n /** Directory where the changesets should be downloaded. */\n targetDir: LocalDirName;\n}\n\n/**\n * Arguments to create a new iModel in iModelHub\n * @public\n */\nexport interface CreateNewIModelProps extends IModelNameArg {\n readonly description?: string;\n readonly version0?: LocalFileName;\n readonly noLocks?: true;\n}\n\n/**\n * Methods for accessing services of IModelHub from an iTwin.js backend.\n * Generally direct access to these methods should not be required, since higher-level apis are provided.\n * @public\n */\nexport interface BackendHubAccess {\n /** Download all the changesets in the specified range. */\n downloadChangesets: (arg: DownloadChangesetRangeArg) => Promise<ChangesetFileProps[]>;\n /** Download a single changeset. */\n downloadChangeset: (arg: DownloadChangesetArg) => Promise<ChangesetFileProps>;\n /** Query the changeset properties given a ChangesetIndex */\n queryChangeset: (arg: ChangesetArg) => Promise<ChangesetProps>;\n /** Query an array of changeset properties given a range of ChangesetIndexes */\n queryChangesets: (arg: ChangesetRangeArg) => Promise<ChangesetProps[]>;\n /** Push a changeset to iModelHub. Returns the newly pushed changeset's index */\n pushChangeset: (arg: IModelIdArg & { changesetProps: ChangesetFileProps }) => Promise<ChangesetIndex>;\n /** Get the ChangesetProps of the most recent changeset */\n getLatestChangeset: (arg: IModelIdArg) => Promise<ChangesetProps>;\n /** Get the ChangesetProps for an IModelVersion */\n getChangesetFromVersion: (arg: IModelIdArg & { version: IModelVersion }) => Promise<ChangesetProps>;\n /** Get the ChangesetProps for a named version */\n getChangesetFromNamedVersion: (arg: IModelIdArg & { versionName: string }) => Promise<ChangesetProps>;\n\n /** Acquire a new briefcaseId for the supplied iModelId\n * @note usually there should only be one briefcase per iModel per user.\n */\n acquireNewBriefcaseId: (arg: AcquireNewBriefcaseIdArg) => Promise<BriefcaseId>;\n /** Release a briefcaseId. After this call it is illegal to generate changesets for the released briefcaseId. */\n releaseBriefcase: (arg: BriefcaseIdArg) => Promise<void>;\n\n /** get an array of the briefcases assigned to a user. */\n getMyBriefcaseIds: (arg: IModelIdArg) => Promise<BriefcaseId[]>;\n\n /** Get the access props for a V2 checkpoint. Returns undefined if no V2 checkpoint exists. */\n queryV2Checkpoint: (arg: CheckpointProps) => Promise<V2CheckpointAccessProps | undefined>;\n\n /**\n * acquire one or more locks. Throws if unsuccessful. If *any* lock cannot be obtained, no locks are acquired\n * @throws ConflictingLocksError if one or more requested locks are held by other briefcases.\n */\n acquireLocks: (arg: BriefcaseDbArg, locks: LockMap) => Promise<void>;\n\n /** Get the list of all held locks for a briefcase. This can be very expensive and is currently used only for tests. */\n queryAllLocks: (arg: BriefcaseDbArg) => Promise<LockProps[]>;\n\n /** Release all currently held locks */\n releaseAllLocks: (arg: BriefcaseDbArg) => Promise<void>;\n\n /** Get the iModelId of an iModel by name. Undefined if no iModel with that name exists. */\n queryIModelByName: (arg: IModelNameArg) => Promise<GuidString | undefined>;\n\n /** create a new iModel. Returns the Guid of the newly created iModel */\n createNewIModel: (arg: CreateNewIModelProps) => Promise<GuidString>;\n\n /** delete an iModel */\n deleteIModel: (arg: IModelIdArg & ITwinIdArg) => Promise<void>;\n}\n"]}
@@ -7,7 +7,7 @@ import { DefinitionElement } from "./Element";
7
7
  import { IModelDb } from "./IModelDb";
8
8
  import { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from "./Entity";
9
9
  /** Defines the appearance for graphics in Geometric elements
10
- * @public
10
+ * @public @preview
11
11
  */
12
12
  export declare class SubCategory extends DefinitionElement {
13
13
  static get className(): string;
@@ -69,7 +69,7 @@ export declare class SubCategory extends DefinitionElement {
69
69
  static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
70
70
  }
71
71
  /** A Category element is the target of the `category` member of [[GeometricElement]].
72
- * @public
72
+ * @public @preview
73
73
  */
74
74
  export declare class Category extends DefinitionElement {
75
75
  static get className(): string;
@@ -101,7 +101,7 @@ export declare class Category extends DefinitionElement {
101
101
  setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void;
102
102
  }
103
103
  /** Categorizes 2d GeometricElements.
104
- * @public
104
+ * @public @preview
105
105
  */
106
106
  export declare class DrawingCategory extends Category {
107
107
  static get className(): string;
@@ -136,7 +136,7 @@ export declare class DrawingCategory extends Category {
136
136
  static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String;
137
137
  }
138
138
  /** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).
139
- * @public
139
+ * @public @preview
140
140
  */
141
141
  export declare class SpatialCategory extends Category {
142
142
  static get className(): string;
@@ -14,7 +14,7 @@ const Element_1 = require("./Element");
14
14
  const IModelDb_1 = require("./IModelDb");
15
15
  const NavigationRelationship_1 = require("./NavigationRelationship");
16
16
  /** Defines the appearance for graphics in Geometric elements
17
- * @public
17
+ * @public @preview
18
18
  */
19
19
  class SubCategory extends Element_1.DefinitionElement {
20
20
  static get className() { return "SubCategory"; }
@@ -127,7 +127,7 @@ class SubCategory extends Element_1.DefinitionElement {
127
127
  }
128
128
  exports.SubCategory = SubCategory;
129
129
  /** A Category element is the target of the `category` member of [[GeometricElement]].
130
- * @public
130
+ * @public @preview
131
131
  */
132
132
  class Category extends Element_1.DefinitionElement {
133
133
  static get className() { return "Category"; }
@@ -191,7 +191,7 @@ class Category extends Element_1.DefinitionElement {
191
191
  }
192
192
  exports.Category = Category;
193
193
  /** Categorizes 2d GeometricElements.
194
- * @public
194
+ * @public @preview
195
195
  */
196
196
  class DrawingCategory extends Category {
197
197
  static get className() { return "DrawingCategory"; }
@@ -247,7 +247,7 @@ class DrawingCategory extends Category {
247
247
  }
248
248
  exports.DrawingCategory = DrawingCategory;
249
249
  /** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).
250
- * @public
250
+ * @public @preview
251
251
  */
252
252
  class SpatialCategory extends Category {
253
253
  static get className() { return "SpatialCategory"; }
@@ -1 +1 @@
1
- {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAC9C,yCAAsC;AACtC,qEAAqE;AAGrE;;GAEG;AACH,MAAa,WAAY,SAAQ,2BAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,mCAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,wBAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAmB,mBAAmB,GAA4B;QAChF,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE;QAChD,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE;KAChD,CAAC;IAEF;;;;OAIG;IACI,MAAM,CAAU,WAAW,CAAC,KAA4B;QAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,KAAK,CAAqB,CAAC;QAC7D,OAAO,CAAC,WA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AC;QACzF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY;QAClF,MAAM,aAAa,GAAkB;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF;AAvDD,0CAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public\n */\nexport class SubCategory extends DefinitionElement {\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * SubCategory custom HandledProps include 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"description\", source: \"Class\" },\n { propertyName: \"properties\", source: \"Class\" },\n ];\n\n /**\n * SubCategory deserializes 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\n const elProps = super.deserialize(props) as SubCategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n if (props.row.properties !== '') {\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\n } else {\n elProps.appearance = undefined;\n }\n return elProps;\n }\n\n /**\n * SubCategory serialize 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.description !== undefined) {\n inst.description = props.description;\n }\n if (props.appearance !== undefined) {\n inst.properties = JSON.stringify(props.appearance);\n }\n return inst;\n }\n\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory.toJSON());\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public\n */\nexport class Category extends DefinitionElement {\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n protected constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * Category custom HandledProps include 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"rank\", source: \"Class\" },\n { propertyName: \"description\", source: \"Class\" },\n ];\n\n /**\n * Category deserializes 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\n const elProps = super.deserialize(props) as CategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n elProps.rank = JsonUtils.asInt(props.row.rank);\n return elProps;\n }\n\n /**\n * Category serialize 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (undefined !== props.description) {\n inst.description = props.description;\n }\n inst.rank = props.rank;\n return inst;\n }\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat.toJSON());\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public\n */\nexport class DrawingCategory extends Category {\n public static override get className(): string { return \"DrawingCategory\"; }\n\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n category.id = elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public\n */\nexport class SpatialCategory extends Category {\n public static override get className(): string { return \"SpatialCategory\"; }\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n category.id = iModelDb.elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n"]}
1
+ {"version":3,"file":"Category.js","sourceRoot":"","sources":["../../src/Category.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,oDAE4B;AAC5B,uCAA8C;AAC9C,yCAAsC;AACtC,qEAAqE;AAGrE;;GAEG;AACH,MAAa,WAAY,SAAQ,2BAAiB;IACzC,MAAM,KAAc,SAAS,KAAa,OAAO,aAAa,CAAC,CAAC,CAAC;IACxE,qDAAqD;IAC9C,UAAU,CAAwB;IACzC,gDAAgD;IACzC,WAAW,CAAU;IAE5B,YAAsB,KAAuB,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,mCAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,WAAW,GAAG,wBAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC3D,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAmB,mBAAmB,GAA4B;QAChF,EAAE,YAAY,EAAE,aAAa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AO,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,YAA4B,EAAE,SAAiB;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,eAAe,CAAC,eAAe,EAAE,CAAC,CAAC;QACzF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY;QAClF,MAAM,aAAa,GAAkB;YACnC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC;YACxD,SAAS,EAAE,KAAK;SACjB,CAAC;QACF,OAAO,IAAI,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,MAAM,CAAC,QAAkB,EAAE,iBAA6B,EAAE,IAAY,EAAE,iBAAsE;QAC1J,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,iBAAiB,EAAE,IAAI,CAAC,CAAC;QAChE,QAAQ,CAAC,EAAE,GAAG,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACjE,QAAQ,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;CACF;AAvDD,0CAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\n\nimport { Id64, Id64String, JsonUtils } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec, CategoryProps, Code, CodeScopeProps, CodeSpec, ElementProps, Rank, SubCategoryAppearance, SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { DefinitionElement } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CategoryOwnsSubCategories } from \"./NavigationRelationship\";\nimport { CustomHandledProperty, DeserializeEntityArgs, ECSqlRow } from \"./Entity\";\n\n/** Defines the appearance for graphics in Geometric elements\n * @public @preview\n */\nexport class SubCategory extends DefinitionElement {\n public static override get className(): string { return \"SubCategory\"; }\n /** The Appearance parameters for this SubCategory */\n public appearance: SubCategoryAppearance;\n /** Optional description of this SubCategory. */\n public description?: string;\n\n protected constructor(props: SubCategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.appearance = new SubCategoryAppearance(props.appearance);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * SubCategory custom HandledProps include 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"description\", source: \"Class\" },\n { propertyName: \"properties\", source: \"Class\" },\n ];\n\n /**\n * SubCategory deserializes 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): SubCategoryProps {\n const elProps = super.deserialize(props) as SubCategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n if (props.row.properties !== '') {\n elProps.appearance = JSON.parse(props.row.properties) as SubCategoryAppearance.Props;\n } else {\n elProps.appearance = undefined;\n }\n return elProps;\n }\n\n /**\n * SubCategory serialize 'description' and 'properties'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: SubCategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (props.description !== undefined) {\n inst.description = props.description;\n }\n if (props.appearance !== undefined) {\n inst.properties = JSON.stringify(props.appearance);\n }\n return inst;\n }\n\n public override toJSON(): SubCategoryProps {\n const val = super.toJSON() as SubCategoryProps;\n val.appearance = this.appearance.toJSON();\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the SubCategory's name (its Code value). */\n public getSubCategoryName(): string { return this.code.value; }\n /** Get the Id of the SubCategory. */\n public getSubCategoryId(): Id64String { return this.id; }\n /** Get the Id of this SubCategory's parent Category. */\n public getCategoryId(): Id64String { return this.parent ? this.parent.id : Id64.invalid; }\n /** Check if this is the default SubCategory of its parent Category. */\n public get isDefaultSubCategory(): boolean { return IModelDb.getDefaultSubCategoryId(this.getCategoryId()) === this.getSubCategoryId(); }\n\n /** Create a Code for a SubCategory given a name that is meant to be unique within the scope of the specified parent Category.\n * @param iModel The IModel\n * @param parentCategoryId The Id of the parent Category that owns the SubCategory and provides the scope for its name.\n * @param codeValue The name of the SubCategory\n */\n public static createCode(iModel: IModelDb, parentCategoryId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.subCategory);\n return new Code({ spec: codeSpec.id, scope: parentCategoryId, value: codeValue });\n }\n\n /** Create a new SubCategory\n * @param iModelDb The iModel\n * @param parentCategoryId Create the new SubCategory as a child of this [[Category]]\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The newly constructed SubCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): SubCategory {\n if (appearance instanceof SubCategoryAppearance)\n appearance = appearance.toJSON();\n\n const parentCategory = iModelDb.elements.getElement<Category>(parentCategoryId);\n const subCategoryProps: SubCategoryProps = {\n classFullName: this.classFullName,\n model: parentCategory.model,\n parent: new CategoryOwnsSubCategories(parentCategoryId),\n code: this.createCode(iModelDb, parentCategoryId, name),\n appearance,\n };\n return new SubCategory(subCategoryProps, iModelDb);\n }\n\n /** Insert a new SubCategory\n * @param iModelDb Insert into this iModel\n * @param parentCategoryId Insert the new SubCategory as a child of this Category\n * @param name The name of the SubCategory\n * @param appearance The appearance settings to use for this SubCategory\n * @returns The Id of the newly inserted SubCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, parentCategoryId: Id64String, name: string, appearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const subCategory = this.create(iModelDb, parentCategoryId, name, appearance);\n return iModelDb.elements.insertElement(subCategory.toJSON());\n }\n}\n\n/** A Category element is the target of the `category` member of [[GeometricElement]].\n * @public @preview\n */\nexport class Category extends DefinitionElement {\n public static override get className(): string { return \"Category\"; }\n public rank: Rank = Rank.User;\n public description?: string;\n\n protected constructor(props: CategoryProps, iModel: IModelDb) {\n super(props, iModel);\n this.rank = JsonUtils.asInt(props.rank);\n this.description = JsonUtils.asString(props.description);\n }\n\n /**\n * Category custom HandledProps include 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n protected static override readonly _customHandledProps: CustomHandledProperty[] = [\n { propertyName: \"rank\", source: \"Class\" },\n { propertyName: \"description\", source: \"Class\" },\n ];\n\n /**\n * Category deserializes 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override deserialize(props: DeserializeEntityArgs): CategoryProps {\n const elProps = super.deserialize(props) as CategoryProps;\n elProps.description = JsonUtils.asString(props.row.description);\n elProps.rank = JsonUtils.asInt(props.row.rank);\n return elProps;\n }\n\n /**\n * Category serialize 'rank' and 'description'.\n * @inheritdoc\n * @beta\n */\n public static override serialize(props: CategoryProps, iModel: IModelDb): ECSqlRow {\n const inst = super.serialize(props, iModel);\n if (undefined !== props.description) {\n inst.description = props.description;\n }\n inst.rank = props.rank;\n return inst;\n }\n public override toJSON(): CategoryProps {\n const val = super.toJSON() as CategoryProps;\n val.rank = this.rank;\n if (this.description && this.description.length > 0)\n val.description = this.description;\n return val;\n }\n\n /** Get the Id of the default SubCategory for this Category. */\n public myDefaultSubCategoryId(): Id64String { return IModelDb.getDefaultSubCategoryId(this.id); }\n\n /** Set the appearance of the default SubCategory for this Category */\n public setDefaultAppearance(props: SubCategoryAppearance.Props | SubCategoryAppearance): void {\n if (props instanceof SubCategoryAppearance)\n props = props.toJSON();\n\n const subCat = this.iModel.elements.getElement<SubCategory>(this.myDefaultSubCategoryId());\n subCat.appearance = new SubCategoryAppearance(props);\n this.iModel.elements.updateElement(subCat.toJSON());\n }\n}\n\n/** Categorizes 2d GeometricElements.\n * @public @preview\n */\nexport class DrawingCategory extends Category {\n public static override get className(): string { return \"DrawingCategory\"; }\n\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by DrawingCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.drawingCategory; }\n\n /** Looks up the CategoryId of a DrawingCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = DrawingCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a DrawingCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the DrawingCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A drawing category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(DrawingCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new DrawingCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @returns The newly constructed DrawingCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): DrawingCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new DrawingCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new DrawingCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new DrawingCategory into this [[DefinitionModel]]\n * @param name The name of the DrawingCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this DrawingCategory\n * @returns The Id of the newly inserted DrawingCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n const elements = iModelDb.elements;\n category.id = elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n\n/** Categorizes SpatialElements. See [how to create a SpatialCategory]($docs/learning/backend/CreateElements.md#SpatialCategory).\n * @public @preview\n */\nexport class SpatialCategory extends Category {\n public static override get className(): string { return \"SpatialCategory\"; }\n protected constructor(opts: ElementProps, iModel: IModelDb) { super(opts, iModel); }\n\n /** Get the name of the CodeSpec that is used by SpatialCategory objects. */\n public static getCodeSpecName(): string { return BisCodeSpec.spatialCategory; }\n\n /** Looks up the CategoryId of a SpatialCategory by model and name */\n public static queryCategoryIdByName(iModel: IModelDb, scopeModelId: Id64String, categoryName: string): Id64String | undefined {\n const code: Code = SpatialCategory.createCode(iModel, scopeModelId, categoryName);\n return iModel.elements.queryElementIdByCode(code);\n }\n\n /** Create a Code for a SpatialCategory given a name that is meant to be unique within the scope of the specified DefinitionModel.\n * @param iModel The IModel\n * @param scopeModelId The Id of the DefinitionModel that contains the SpatialCategory and provides the scope for its name.\n * @param codeValue The name of the category\n * @return A spatial category Code\n */\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, codeValue: string): Code {\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(SpatialCategory.getCodeSpecName());\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n /** Create a new SpatialCategory\n * @param iModelDb The iModel\n * @param definitionModelId The [[DefinitionModel]]\n * @param name The name/CodeValue of the SpatialCategory\n * @returns The newly constructed SpatialCategory element.\n * @throws [[IModelError]] if unable to create the element.\n */\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, name: string): SpatialCategory {\n const categoryProps: CategoryProps = {\n classFullName: this.classFullName,\n model: definitionModelId,\n code: this.createCode(iModelDb, definitionModelId, name),\n isPrivate: false,\n };\n return new SpatialCategory(categoryProps, iModelDb);\n }\n\n /** Insert a new SpatialCategory\n * @param iModelDb Insert into this iModel\n * @param definitionModelId Insert the new SpatialCategory into this DefinitionModel\n * @param name The name of the SpatialCategory\n * @param defaultAppearance The appearance settings to use for the default SubCategory of this SpatialCategory\n * @returns The Id of the newly inserted SpatialCategory element.\n * @throws [[IModelError]] if unable to insert the element.\n */\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, name: string, defaultAppearance: SubCategoryAppearance.Props | SubCategoryAppearance): Id64String {\n const category = this.create(iModelDb, definitionModelId, name);\n category.id = iModelDb.elements.insertElement(category.toJSON());\n category.setDefaultAppearance(defaultAppearance);\n return category.id;\n }\n}\n"]}
@@ -107,7 +107,7 @@ export declare class ClassRegistry {
107
107
  * A cache that records the mapping between class names and class metadata.
108
108
  * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.
109
109
  * @internal
110
- * @deprecated in 5.0. Please use `schemaContext` from the `iModel` instead.
110
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.
111
111
  *
112
112
  * @example
113
113
  * @
@@ -289,7 +289,7 @@ exports.ClassRegistry = ClassRegistry;
289
289
  * A cache that records the mapping between class names and class metadata.
290
290
  * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.
291
291
  * @internal
292
- * @deprecated in 5.0. Please use `schemaContext` from the `iModel` instead.
292
+ * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.
293
293
  *
294
294
  * @example
295
295
  * @
@@ -1 +1 @@
1
- {"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AACjC,gDAA+C;AAE/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB,EAAE,WAA0B;QAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAqB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,gBAAgB;IACT,KAAK;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,gBAAgB;IACT,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAA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I,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,4DAA4D;IACrD,GAAG,CAAC,aAAqB,EAAE,QAAwB;QACxD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0. Please use `schemaContext` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName.ClassName\", EntityClass);\n * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName\", \"ClassName\", RelationshipClass);\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
1
+ {"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuF;AACvF,oDAAqG;AACrG,qCAAkC;AAElC,qCAA2C;AAC3C,yDAAsD;AACtD,iCAAiC;AACjC,gDAA+C;AAE/C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,gBAAgB;IACV,SAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE9D,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,gBAAgB;IACT,GAAG,CAAC,aAAqB,EAAE,WAA0B;QAC1D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,CAAC;IAC/D,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAqB;QACjC,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,gBAAgB;IACT,KAAK;QACV,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,gBAAgB;IACT,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC3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,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,4DAA4D;IACrD,GAAG,CAAC,aAAqB,EAAE,QAAwB;QACxD,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAxBD,4CAwBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { DbResult, Id64, Id64String, IModelStatus, Logger } from \"@itwin/core-bentley\";\nimport { EntityMetaData, EntityReferenceSet, IModelError, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { Schema, Schemas } from \"./Schema\";\nimport { EntityReferences } from \"./EntityReferences\";\nimport * as assert from \"assert\";\nimport { _nativeDb } from \"./internal/Symbols\";\n\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * @public\n */\nexport class EntityJsClassMap {\n private readonly _classMap = new Map<string, typeof Entity>();\n\n /** @internal */\n public has(classFullName: string): boolean {\n return this._classMap.has(classFullName.toLowerCase());\n }\n\n /** @internal */\n public get(classFullName: string): typeof Entity | undefined {\n return this._classMap.get(classFullName.toLowerCase());\n }\n\n /** @internal */\n public set(classFullName: string, entityClass: typeof Entity): void {\n this._classMap.set(classFullName.toLowerCase(), entityClass);\n }\n\n /** @internal */\n public delete(classFullName: string): boolean {\n return this._classMap.delete(classFullName.toLowerCase());\n }\n\n /** @internal */\n public clear(): void {\n this._classMap.clear();\n }\n\n /** @internal */\n public [Symbol.iterator](): IterableIterator<[string, typeof Entity]> {\n return this._classMap[Symbol.iterator]();\n }\n\n /**\n * Registers a single `entityClass` defined in the specified `schema`.\n * This method registers the class globally. To register a class for a specific iModel, use [[IModelDb.jsClassMap]].\n *\n * @param entityClass - The JavaScript class that implements the BIS [ECClass](@itwin/core-common) to be registered.\n * @param schema - The schema that contains the `entityClass`.\n *\n * @throws Error if the class is already registered.\n *\n * @public\n */\n public register(entityClass: typeof Entity, schema: typeof Schema): void {\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\n if (this.has(key)) {\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\n throw new Error(errMsg);\n }\n entityClass.schema = schema;\n this.set(key, entityClass);\n }\n}\n\n/** Maintains the mapping between the name of a BIS [ECClass]($ecschema-metadata) (in \"schema:class\" format) and the JavaScript [[Entity]] class that implements it.\n * Applications or modules that supply their own Entity subclasses should use [[registerModule]] or [[register]] at startup\n * to establish their mappings.\n * @public\n */\nexport class ClassRegistry {\n private static readonly _globalClassMap = new EntityJsClassMap();\n /** @internal */\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\n /** @internal */\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\n /** Register a single `entityClass` defined in the specified `schema`.\n * @see [[registerModule]] to register multiple classes.\n * @public\n */\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\n this._globalClassMap.register(entityClass, schema);\n }\n\n /** Generate a proxy Schema for a domain that has not been registered. */\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\n const hasBehavior = iModel.withPreparedSqliteStatement(`\n SELECT NULL FROM [ec_CustomAttribute] [c]\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\n stmt.bindString(1, domain);\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\n return stmt.step() === DbResult.BE_SQLITE_ROW;\n });\n\n const schemaClass = class extends Schema {\n public static override get schemaName() { return domain; }\n public static override get missingRequiredBehavior() { return hasBehavior; }\n };\n\n iModel.schemaMap.registerSchema(schemaClass); // register the class before we return it.\n return schemaClass;\n }\n\n /** First, finds the root BisCore entity class for an entity, by traversing base classes and mixin targets (AppliesTo).\n * Then, gets its metadata and returns that.\n * @param iModel - iModel containing the metadata for this type\n * @param ecTypeQualifier - a full name of an ECEntityClass to find the root of\n * @returns the qualified full name of an ECEntityClass\n * @internal public for testing only\n */\n public static getRootEntity(iModel: IModelDb, ecTypeQualifier: string): string {\n const [classSchema, className] = ecTypeQualifier.split(\".\");\n const schemaItemJson = iModel[_nativeDb].getSchemaItem(classSchema, className);\n if (schemaItemJson.error)\n throw new IModelError(schemaItemJson.error.status, `failed to get schema item '${ecTypeQualifier}'`);\n\n assert(undefined !== schemaItemJson.result);\n const schemaItem = JSON.parse(schemaItemJson.result);\n if (!(\"appliesTo\" in schemaItem) && schemaItem.baseClass === undefined) {\n return ecTypeQualifier;\n }\n\n // typescript doesn't understand that the inverse of the above condition is\n // (\"appliesTo\" in rootclassMetaData || rootClassMetaData.baseClass !== undefined)\n const parentItemQualifier = schemaItem.appliesTo ?? schemaItem.baseClass as string;\n return this.getRootEntity(iModel, parentItemQualifier);\n }\n\n /** Generate a JavaScript class from Entity metadata.\n * @param entityMetaData The Entity metadata that defines the class\n */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\n const name = entityMetaData.ecclass.split(\":\");\n const domainName = name[0];\n const className = name[1];\n\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\n\n // make sure schema exists\n let schema = iModel.schemaMap.get(domainName) ?? Schemas.getRegisteredSchema(domainName);\n if (undefined === schema)\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\n\n const superClassFullName = entityMetaData.baseClasses[0].toLowerCase();\n const superclass = iModel.jsClassMap.get(superClassFullName) ?? this._globalClassMap.get(superClassFullName);\n if (undefined === superclass)\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\n\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\n // be used to tell if there are any generated classes in the hierarchy\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\n let currentSuperclass = superclass;\n const MAX_ITERS = 1000;\n for (let i = 0; i < MAX_ITERS; ++i) {\n if (currentSuperclass.schema.schemaName === \"BisCore\")\n break;\n\n if (!currentSuperclass.isGeneratedClass) {\n generatedClassHasNonGeneratedNonCoreAncestor = true;\n break;\n }\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\n if (superclassMetaData === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\n if (maybeNextSuperclass === undefined)\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\n currentSuperclass = maybeNextSuperclass;\n }\n\n const generatedClass = class extends superclass {\n public static override get className() { return className; }\n private static [isGeneratedClassTag] = true;\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\n };\n\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\n\n // a class only gets an automatic `collectReferenceIds` implementation if:\n // - it is not in the `BisCore` schema\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\n if (!generatedClassHasNonGeneratedNonCoreAncestor) {\n const navigationProps = Object.entries(entityMetaData.properties)\n .filter(([_name, prop]) => prop.isNavigation)\n // eslint-disable-next-line @typescript-eslint/no-shadow\n .map(([name, prop]) => {\n assert(prop.relationshipClass);\n const maybeMetaData = iModel[_nativeDb].getSchemaItem(...prop.relationshipClass.split(\":\") as [string, string]);\n assert(maybeMetaData.result !== undefined, \"The nav props relationship metadata was not found\");\n const relMetaData = JSON.parse(maybeMetaData.result);\n const rootClassMetaData = ClassRegistry.getRootEntity(iModel, relMetaData.target.constraintClasses[0]);\n // root class must be in BisCore so should be loaded since biscore classes will never get this\n // generated implementation\n const normalizeClassName = (clsName: string) => clsName.replace(\".\", \":\");\n const rootClass = ClassRegistry.findRegisteredClass(normalizeClassName(rootClassMetaData));\n assert(rootClass, `The root class for ${prop.relationshipClass} was not in BisCore.`);\n return { name, concreteEntityType: EntityReferences.typeFromClass(rootClass) };\n });\n\n Object.defineProperty(\n generatedClass.prototype,\n \"collectReferenceIds\",\n {\n value(this: typeof generatedClass, referenceIds: EntityReferenceSet) {\n // eslint-disable-next-line @typescript-eslint/dot-notation\n const superImpl = superclass.prototype[\"collectReferenceIds\"];\n superImpl.call(this, referenceIds);\n for (const navProp of navigationProps) {\n const relatedElem: RelatedElement | undefined = (this as any)[navProp.name]; // cast to any since subclass can have any extensions\n if (!relatedElem || !Id64.isValid(relatedElem.id))\n continue;\n const referenceId = EntityReferences.fromEntityType(relatedElem.id, navProp.concreteEntityType);\n referenceIds.add(referenceId);\n }\n },\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\n writable: true,\n configurable: true,\n },\n );\n }\n\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\n if (schema.missingRequiredBehavior) {\n const throwError = () => {\n throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`);\n };\n\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\n }\n\n iModel.jsClassMap.register(generatedClass, schema); // register it before returning\n return generatedClass;\n }\n\n /** Register all of the classes found in the given module that derive from [[Entity]].\n * [[register]] will be invoked for each subclass of `Entity` exported by `moduleObj`.\n * @param moduleObj The module to search for subclasses of Entity\n * @param schema The schema that contains all of the [ECClass]($ecschema-metadata)es exported by `moduleObj`.\n */\n public static registerModule(moduleObj: any, schema: typeof Schema) {\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\n const thisClass = moduleObj[thisMember];\n if (thisClass.prototype instanceof Entity)\n this.register(thisClass, schema);\n }\n }\n\n /**\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\n */\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\n if (metadata === undefined || metadata.ecclass === undefined)\n throw this.makeMetaDataNotFoundError(classFullName);\n\n // Make sure we have all base classes registered.\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\n this.getClass(metadata.baseClasses[0], iModel);\n\n // Now we can generate the class from the classDef.\n return this.generateClassForEntity(metadata, iModel);\n }\n\n /** Find a registered class by classFullName.\n * @param classFullName class to find\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class or undefined\n */\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\n return this._globalClassMap.get(classFullName.toLowerCase());\n }\n\n /** Get the Entity class for the specified Entity className.\n * @param classFullName The full BIS class name of the Entity\n * @param iModel The IModel that contains the class definitions\n * @returns The Entity class\n */\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\n const key = classFullName.toLowerCase();\n return iModel.jsClassMap.get(key) ?? this._globalClassMap.get(key) ?? this.generateClass(key, iModel);\n }\n\n /** Unregister a class, by name, if one is already registered.\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\n * @param classFullName Name of the class to unregister\n * @return true if the class was unregistered\n * @internal\n */\n public static unregisterClass(classFullName: string) { return this._globalClassMap.delete(classFullName.toLowerCase()); }\n\n /** Unregister all classes from a schema.\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\n * @param schema Name of the schema to unregister\n * @internal\n */\n public static unregisterClassesFrom(schema: typeof Schema) {\n for (const entry of Array.from(this._globalClassMap)) {\n if (entry[1].schema === schema)\n this.unregisterClass(entry[0]);\n }\n }\n}\n\n/**\n * A cache that records the mapping between class names and class metadata.\n * @see [[IModelDb.classMetaDataRegistry]] to access the registry for a specific iModel.\n * @internal\n * @deprecated in 5.0 - will not be removed until after 2026-06-13. Please use `schemaContext` from the `iModel` instead.\n *\n * @example\n * @\n * Current Usage:\n * ```ts\n * const metaData: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(\"SchemaName:ClassName\");\n * ```\n *\n * Replacement:\n * ```ts\n * const entityMetaData: EntityClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName.ClassName\", EntityClass);\n * const relationshipMetaData: RelationshipClass | undefined = iModel.schemaContext.getSchemaItemSync(\"SchemaName\", \"ClassName\", RelationshipClass);\n * ```\n */\nexport class MetaDataRegistry {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _registry = new Map<string, EntityMetaData>();\n private _classIdToName = new Map<Id64String, string>();\n\n /** Get the specified Entity metadata */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public find(classFullName: string): EntityMetaData | undefined {\n return this._registry.get(classFullName.toLowerCase());\n }\n\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public findByClassId(classId: Id64String): EntityMetaData | undefined {\n const name = this._classIdToName.get(classId);\n return undefined !== name ? this.find(name) : undefined;\n }\n\n /** Add metadata to the cache */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public add(classFullName: string, metaData: EntityMetaData): void {\n const name = classFullName.toLowerCase();\n this._registry.set(name, metaData);\n this._classIdToName.set(metaData.classId, name);\n }\n}\n"]}
@@ -5,7 +5,7 @@ import { Id64String } from "@itwin/core-bentley";
5
5
  import { CodeScopeSpec, CodeSpec, CodeSpecProperties } from "@itwin/core-common";
6
6
  import { IModelDb } from "./IModelDb";
7
7
  /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
8
- * @public
8
+ * @public @preview
9
9
  */
10
10
  export declare class CodeSpecs {
11
11
  private static tableName;
@@ -11,7 +11,7 @@ exports.CodeSpecs = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
12
  const core_common_1 = require("@itwin/core-common");
13
13
  /** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]
14
- * @public
14
+ * @public @preview
15
15
  */
16
16
  class CodeSpecs {
17
17
  static tableName = "bis_CodeSpec";
@@ -1 +1 @@
1
- {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA8F;AAI9F;;GAEG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,CAAW;IAClB,gBAAgB,GAAe,EAAE,CAAC;IAE1C,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;YAC3B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAChF,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,OAAO,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,OAAO,EAAE;gBACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAxKH,8BAyKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\n codeSpecOrName.id = id;\n return id;\n }\n if (props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrName, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update\n * @throws if unable to update the codeSpec.\n */\n public updateProperties(codeSpec: CodeSpec): void {\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\n stmt.bindId(2, codeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6F;AAC7F,oDAA8F;AAI9F;;GAEG;AACH,MAAa,SAAS;IACZ,MAAM,CAAC,SAAS,GAAG,cAAc,CAAC;IAClC,OAAO,CAAW;IAClB,gBAAgB,GAAe,EAAE,CAAC;IAE1C,YAAY,MAAgB;QAC1B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC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tE,OAAO,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,mCAAmC,SAAS,CAAC,SAAS,aAAa,EAAE,CAAC,IAAI,EAAE,EAAE;YACpH,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;gBACjB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/G,CAAC,CAAC,CAAC;IACL,CAAC;;AAxKH,8BAyKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Codes\n */\n\nimport { BentleyError, DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { CodeScopeSpec, CodeSpec, CodeSpecProperties, IModelError } from \"@itwin/core-common\";\nimport { IModelDb } from \"./IModelDb\";\nimport { CodeService } from \"./CodeService\";\n\n/** Manages [CodeSpecs]($docs/BIS/guide/fundamentals/element-fundamentals.md#codespec) within an [[IModelDb]]\n * @public @preview\n */\nexport class CodeSpecs {\n private static tableName = \"bis_CodeSpec\";\n private _imodel: IModelDb;\n private _loadedCodeSpecs: CodeSpec[] = [];\n\n constructor(imodel: IModelDb) {\n this._imodel = imodel;\n if (imodel.isBriefcaseDb()) {\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\n }\n }\n\n private findByName(name: string): Id64String | undefined {\n return this._imodel.withSqliteStatement(`SELECT Id FROM ${CodeSpecs.tableName} WHERE Name=?`, (stmt) => {\n stmt.bindString(1, name);\n return stmt.nextRow() ? stmt.getValueId(0) : undefined;\n });\n }\n\n /** Look up the Id of the CodeSpec with the specified name. */\n public queryId(name: string): Id64String {\n const id = this.findByName(name);\n if (!id)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return id;\n }\n\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\n * @param codeSpecId The Id of the CodeSpec to load\n * @returns The CodeSpec with the specified Id\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\n */\n public getById(codeSpecId: Id64String): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\n if (found !== undefined)\n return found;\n\n // must load this codespec\n const loadedCodeSpec = this.load(codeSpecId);\n this._loadedCodeSpecs.push(loadedCodeSpec);\n return loadedCodeSpec;\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\n public hasId(codeSpecId: Id64String): boolean {\n try {\n return undefined !== this.getById(codeSpecId);\n } catch {\n return false;\n }\n }\n\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\n * @param name The name of the CodeSpec to load\n * @returns The CodeSpec with the specified name\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\n */\n public getByName(name: string): CodeSpec {\n // good chance it is already loaded - check there before running a query\n const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\n if (found !== undefined)\n return found;\n const codeSpecId = this.queryId(name);\n if (codeSpecId === undefined)\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\");\n return this.getById(codeSpecId);\n }\n\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\n public hasName(name: string): boolean {\n try {\n return undefined !== this.getByName(name);\n } catch {\n return false;\n }\n }\n\n private insertCodeSpec(specName: string, properties: CodeSpecProperties): Id64String {\n const iModel = this._imodel;\n const spec: CodeService.BisCodeSpecIndexProps = { name: specName.trim(), props: JSON.stringify(properties) };\n if (this.findByName(spec.name))\n throw new IModelError(IModelStatus.DuplicateName, \"CodeSpec already exists\");\n\n const internalCodes = iModel.codeService?.internalCodes;\n if (internalCodes) {\n // Since there is no lock on the codespec table, to add a codespec to an iModel it must first be reserved in the\n // internal code index via `internalCodes.reserveBisCodeSpecs` prior to calling this function.\n // This ensures that the Ids will be unique, and the property values consistent, even if more than one user\n // adds them without pushing their changes. The call to `verifyBisCodeSpec` will throw otherwise.\n internalCodes.reader.verifyBisCodeSpec(spec);\n } else {\n // If this iModel doesn't have an internal code index, we have no way of coordinating the Ids for CodeSpecs across multiple users.\n // Just look in this briefcase to find the currently highest used Id and hope for the best.\n spec.id = iModel.withSqliteStatement(`SELECT MAX(Id) FROM ${CodeSpecs.tableName}`, (stmt) => stmt.nextRow() ? stmt.getValueInteger(0) + 1 : 1);\n }\n\n const id = spec.id!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n iModel.withSqliteStatement(`INSERT INTO ${CodeSpecs.tableName}(Id,Name,JsonProperties) VALUES(?,?,?)`, (stmt) => {\n stmt.bindInteger(1, id);\n stmt.bindString(2, spec.name);\n stmt.bindString(3, spec.props);\n const rc = stmt.step();\n if (rc !== DbResult.BE_SQLITE_DONE)\n throw new BentleyError(rc, \"Error inserting codeSpec\");\n });\n\n return Id64.fromLocalAndBriefcaseIds(id, 0);\n }\n\n /** Add a new CodeSpec to the iModel.\n * @param codeSpec The CodeSpec to insert\n * @returns The Id of the persistent CodeSpec.\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\n * @throws IModelError if the insertion fails\n */\n public insert(codeSpec: CodeSpec): Id64String;\n\n /** Add a new CodeSpec to the IModelDb.\n * @param name The name for the new CodeSpec.\n * @param properties The properties or the CodeSpec. For backwards compatibility this may also be a `CodeScopeSpec.Type`.\n * @returns The Id of the persistent CodeSpec.\n * @throws IModelError if the insertion fails\n */\n public insert(name: string, properties: CodeSpecProperties | CodeScopeSpec.Type): Id64String;\n public insert(codeSpecOrName: CodeSpec | string, props?: CodeSpecProperties | CodeScopeSpec.Type): Id64String {\n if (codeSpecOrName instanceof CodeSpec) {\n const id = this.insertCodeSpec(codeSpecOrName.name, codeSpecOrName.properties);\n codeSpecOrName.id = id;\n return id;\n }\n if (props === undefined)\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\n\n if (typeof props === \"object\")\n return this.insertCodeSpec(codeSpecOrName, props);\n\n const spec = CodeSpec.create(this._imodel, codeSpecOrName, props);\n return this.insertCodeSpec(spec.name, spec.properties);\n }\n\n /** Update the Json properties of an existing CodeSpec.\n * @param codeSpec The codeSpec holding Json properties values to update\n * @throws if unable to update the codeSpec.\n */\n public updateProperties(codeSpec: CodeSpec): void {\n this._imodel.withSqliteStatement(`UPDATE ${CodeSpecs.tableName} SET JsonProperties=? WHERE Id=?`, (stmt) => {\n stmt.bindString(1, JSON.stringify(codeSpec.properties));\n stmt.bindId(2, codeSpec.id);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw new IModelError(IModelStatus.BadArg, \"error updating CodeSpec properties\");\n });\n }\n\n /** Load a CodeSpec from the iModel\n * @param id The persistent Id of the CodeSpec to load\n */\n public load(id: Id64String): CodeSpec {\n if (Id64.isInvalid(id))\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\n\n return this._imodel.withSqliteStatement(`SELECT Name,JsonProperties FROM ${CodeSpecs.tableName} WHERE Id=?`, (stmt) => {\n stmt.bindId(1, id);\n if (!stmt.nextRow())\n throw new IModelError(IModelStatus.InvalidId, \"CodeSpec not found\");\n\n return CodeSpec.createFromJson(this._imodel, id, stmt.getValueString(0), JSON.parse(stmt.getValueString(1)));\n });\n }\n}\n"]}
@@ -10,7 +10,7 @@ import { DeserializeEntityArgs, ECSqlRow } from "./Entity";
10
10
  /** A DisplayStyle defines the parameters for 'styling' the contents of a view.
11
11
  * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.
12
12
  * Many ViewDefinitions may share the same DisplayStyle.
13
- * @public
13
+ * @public @preview
14
14
  */
15
15
  export declare abstract class DisplayStyle extends DefinitionElement {
16
16
  static get className(): string;
@@ -32,7 +32,7 @@ export declare abstract class DisplayStyle extends DefinitionElement {
32
32
  loadScheduleScript(): RenderSchedule.ScriptReference | undefined;
33
33
  }
34
34
  /** A DisplayStyle for 2d views.
35
- * @public
35
+ * @public @preview
36
36
  */
37
37
  export declare class DisplayStyle2d extends DisplayStyle {
38
38
  static get className(): string;
@@ -62,7 +62,7 @@ export declare class DisplayStyle2d extends DisplayStyle {
62
62
  * - It extends the type of [DisplayStyleSettingsProps.backgroundColor]($common) to include [ColorDef]($common).
63
63
  * These idiosyncrasies will be addressed in a future version of core-backend.
64
64
  * @see [[DisplayStyle3d.create]].
65
- * @public
65
+ * @public @preview
66
66
  */
67
67
  export interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettingsProps, "backgroundColor" | "scheduleScript"> {
68
68
  /** If supplied, the [ViewFlags]($common) applied by the display style.
@@ -73,7 +73,7 @@ export interface DisplayStyleCreationOptions extends Omit<DisplayStyle3dSettings
73
73
  }
74
74
  /** A DisplayStyle for 3d views.
75
75
  * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).
76
- * @public
76
+ * @public @preview
77
77
  */
78
78
  export declare class DisplayStyle3d extends DisplayStyle {
79
79
  static get className(): string;
@@ -14,7 +14,7 @@ const Element_1 = require("./Element");
14
14
  /** A DisplayStyle defines the parameters for 'styling' the contents of a view.
15
15
  * Internally a DisplayStyle consists of a dictionary of several named 'styles' describing specific aspects of the display style as a whole.
16
16
  * Many ViewDefinitions may share the same DisplayStyle.
17
- * @public
17
+ * @public @preview
18
18
  */
19
19
  class DisplayStyle extends Element_1.DefinitionElement {
20
20
  static get className() { return "DisplayStyle"; }
@@ -136,7 +136,7 @@ class DisplayStyle extends Element_1.DefinitionElement {
136
136
  }
137
137
  exports.DisplayStyle = DisplayStyle;
138
138
  /** A DisplayStyle for 2d views.
139
- * @public
139
+ * @public @preview
140
140
  */
141
141
  class DisplayStyle2d extends DisplayStyle {
142
142
  static get className() { return "DisplayStyle2d"; }
@@ -184,7 +184,7 @@ class DisplayStyle2d extends DisplayStyle {
184
184
  exports.DisplayStyle2d = DisplayStyle2d;
185
185
  /** A DisplayStyle for 3d views.
186
186
  * See [how to create a DisplayStyle3d]$(docs/learning/backend/CreateElements.md#DisplayStyle3d).
187
- * @public
187
+ * @public @preview
188
188
  */
189
189
  class DisplayStyle3d extends DisplayStyle {
190
190
  static get className() { return "DisplayStyle3d"; }