@itwin/core-backend 3.5.0-dev.8 → 3.6.0-dev.3

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 (140) hide show
  1. package/CHANGELOG.md +92 -1
  2. package/lib/cjs/BriefcaseManager.d.ts +7 -2
  3. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  4. package/lib/cjs/BriefcaseManager.js +11 -3
  5. package/lib/cjs/BriefcaseManager.js.map +1 -1
  6. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  7. package/lib/cjs/ChangeSummaryManager.js +2 -0
  8. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  9. package/lib/cjs/ClassRegistry.d.ts +8 -0
  10. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  11. package/lib/cjs/ClassRegistry.js +47 -13
  12. package/lib/cjs/ClassRegistry.js.map +1 -1
  13. package/lib/cjs/CloudSqlite.d.ts +1 -0
  14. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  15. package/lib/cjs/CloudSqlite.js +1 -0
  16. package/lib/cjs/CloudSqlite.js.map +1 -1
  17. package/lib/cjs/ConcurrentQuery.d.ts +3 -1
  18. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -1
  19. package/lib/cjs/ConcurrentQuery.js +6 -0
  20. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  21. package/lib/cjs/CustomViewState3dCreator.d.ts +3 -14
  22. package/lib/cjs/CustomViewState3dCreator.d.ts.map +1 -1
  23. package/lib/cjs/CustomViewState3dCreator.js +11 -43
  24. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  25. package/lib/cjs/DisplayStyle.d.ts +9 -9
  26. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  27. package/lib/cjs/DisplayStyle.js +12 -12
  28. package/lib/cjs/DisplayStyle.js.map +1 -1
  29. package/lib/cjs/Element.d.ts +23 -30
  30. package/lib/cjs/Element.d.ts.map +1 -1
  31. package/lib/cjs/Element.js +42 -46
  32. package/lib/cjs/Element.js.map +1 -1
  33. package/lib/cjs/ElementAspect.d.ts +24 -4
  34. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  35. package/lib/cjs/ElementAspect.js +35 -2
  36. package/lib/cjs/ElementAspect.js.map +1 -1
  37. package/lib/cjs/Entity.d.ts +31 -1
  38. package/lib/cjs/Entity.d.ts.map +1 -1
  39. package/lib/cjs/Entity.js +52 -0
  40. package/lib/cjs/Entity.js.map +1 -1
  41. package/lib/cjs/EntityReferences.d.ts +50 -0
  42. package/lib/cjs/EntityReferences.d.ts.map +1 -0
  43. package/lib/cjs/EntityReferences.js +96 -0
  44. package/lib/cjs/EntityReferences.js.map +1 -0
  45. package/lib/cjs/ExternalSource.d.ts +3 -1
  46. package/lib/cjs/ExternalSource.d.ts.map +1 -1
  47. package/lib/cjs/ExternalSource.js +6 -0
  48. package/lib/cjs/ExternalSource.js.map +1 -1
  49. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  50. package/lib/cjs/GeoCoordConfig.js +10 -7
  51. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  52. package/lib/cjs/HubMock.d.ts +1 -0
  53. package/lib/cjs/HubMock.d.ts.map +1 -1
  54. package/lib/cjs/HubMock.js +34 -2
  55. package/lib/cjs/HubMock.js.map +1 -1
  56. package/lib/cjs/IModelCloneContext.d.ts +5 -82
  57. package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
  58. package/lib/cjs/IModelCloneContext.js +7 -142
  59. package/lib/cjs/IModelCloneContext.js.map +1 -1
  60. package/lib/cjs/IModelDb.d.ts +21 -2
  61. package/lib/cjs/IModelDb.d.ts.map +1 -1
  62. package/lib/cjs/IModelDb.js +64 -14
  63. package/lib/cjs/IModelDb.js.map +1 -1
  64. package/lib/cjs/IModelElementCloneContext.d.ts +90 -0
  65. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -0
  66. package/lib/cjs/IModelElementCloneContext.js +160 -0
  67. package/lib/cjs/IModelElementCloneContext.js.map +1 -0
  68. package/lib/cjs/IModelHost.d.ts +9 -0
  69. package/lib/cjs/IModelHost.d.ts.map +1 -1
  70. package/lib/cjs/IModelHost.js +9 -2
  71. package/lib/cjs/IModelHost.js.map +1 -1
  72. package/lib/cjs/IpcHost.d.ts +6 -0
  73. package/lib/cjs/IpcHost.d.ts.map +1 -1
  74. package/lib/cjs/IpcHost.js +47 -3
  75. package/lib/cjs/IpcHost.js.map +1 -1
  76. package/lib/cjs/Model.d.ts +8 -2
  77. package/lib/cjs/Model.d.ts.map +1 -1
  78. package/lib/cjs/Model.js +15 -1
  79. package/lib/cjs/Model.js.map +1 -1
  80. package/lib/cjs/NativeHost.d.ts.map +1 -1
  81. package/lib/cjs/NativeHost.js +10 -15
  82. package/lib/cjs/NativeHost.js.map +1 -1
  83. package/lib/cjs/PromiseMemoizer.d.ts +4 -4
  84. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
  85. package/lib/cjs/PromiseMemoizer.js +44 -44
  86. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  87. package/lib/cjs/Relationship.d.ts +18 -2
  88. package/lib/cjs/Relationship.d.ts.map +1 -1
  89. package/lib/cjs/Relationship.js +30 -1
  90. package/lib/cjs/Relationship.js.map +1 -1
  91. package/lib/cjs/RpcBackend.d.ts +0 -23
  92. package/lib/cjs/RpcBackend.d.ts.map +1 -1
  93. package/lib/cjs/RpcBackend.js +13 -108
  94. package/lib/cjs/RpcBackend.js.map +1 -1
  95. package/lib/cjs/SqliteStatement.d.ts +81 -4
  96. package/lib/cjs/SqliteStatement.d.ts.map +1 -1
  97. package/lib/cjs/SqliteStatement.js +163 -25
  98. package/lib/cjs/SqliteStatement.js.map +1 -1
  99. package/lib/cjs/ViewDefinition.d.ts +14 -10
  100. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  101. package/lib/cjs/ViewDefinition.js +31 -20
  102. package/lib/cjs/ViewDefinition.js.map +1 -1
  103. package/lib/cjs/ViewStateHydrator.js +2 -2
  104. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  105. package/lib/cjs/core-backend.d.ts +4 -2
  106. package/lib/cjs/core-backend.d.ts.map +1 -1
  107. package/lib/cjs/core-backend.js +4 -2
  108. package/lib/cjs/core-backend.js.map +1 -1
  109. package/lib/cjs/rpc/multipart.d.ts +12 -0
  110. package/lib/cjs/rpc/multipart.d.ts.map +1 -0
  111. package/lib/cjs/rpc/multipart.js +71 -0
  112. package/lib/cjs/rpc/multipart.js.map +1 -0
  113. package/lib/cjs/rpc/tracing.d.ts +29 -0
  114. package/lib/cjs/rpc/tracing.d.ts.map +1 -0
  115. package/lib/cjs/rpc/tracing.js +74 -0
  116. package/lib/cjs/rpc/tracing.js.map +1 -0
  117. package/lib/cjs/rpc/web/logging.d.ts +10 -0
  118. package/lib/cjs/rpc/web/logging.d.ts.map +1 -0
  119. package/lib/cjs/rpc/web/logging.js +43 -0
  120. package/lib/cjs/rpc/web/logging.js.map +1 -0
  121. package/lib/cjs/rpc/web/request.d.ts +7 -0
  122. package/lib/cjs/rpc/web/request.d.ts.map +1 -0
  123. package/lib/cjs/rpc/web/request.js +74 -0
  124. package/lib/cjs/rpc/web/request.js.map +1 -0
  125. package/lib/cjs/rpc/web/response.d.ts +7 -0
  126. package/lib/cjs/rpc/web/response.d.ts.map +1 -0
  127. package/lib/cjs/rpc/web/response.js +106 -0
  128. package/lib/cjs/rpc/web/response.js.map +1 -0
  129. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +4 -2
  130. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  131. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +80 -51
  132. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  133. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  134. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +13 -15
  135. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  136. package/lib/cjs/workspace/Workspace.d.ts +1 -1
  137. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  138. package/lib/cjs/workspace/Workspace.js +2 -2
  139. package/lib/cjs/workspace/Workspace.js.map +1 -1
  140. package/package.json +14 -14
@@ -128,8 +128,7 @@ class ExternalSourceAspect extends ElementMultiAspect {
128
128
  }
129
129
  /** @internal */
130
130
  static get className() { return "ExternalSourceAspect"; }
131
- /** Look up the ElementId of the element that contains an aspect with the specified Scope, Kind, and Identifier
132
- */
131
+ /** @deprecated findAllBySource */
133
132
  static findBySource(iModelDb, scope, kind, identifier) {
134
133
  const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
135
134
  let elementId;
@@ -145,6 +144,31 @@ class ExternalSourceAspect extends ElementMultiAspect {
145
144
  });
146
145
  return { elementId, aspectId };
147
146
  }
147
+ /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.
148
+ * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.
149
+ * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.
150
+ * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.
151
+ * Therefore, the result array could have more than one entry with the same elementId.
152
+ * Aspects are never shared. Each aspect has its own unique ECInstanceId.
153
+ * @param iModelDb The iModel to query
154
+ * @param scope The scope of the ExternalSourceAspects to find
155
+ * @param kind The kind of the ExternalSourceAspects to find
156
+ * @param identifier The identifier of the ExternalSourceAspects to find
157
+ * @returns the query results
158
+ */
159
+ static findAllBySource(iModelDb, scope, kind, identifier) {
160
+ const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;
161
+ const found = [];
162
+ iModelDb.withPreparedStatement(sql, (statement) => {
163
+ statement.bindId("scope", scope);
164
+ statement.bindString("kind", kind);
165
+ statement.bindString("identifier", identifier);
166
+ while (core_bentley_1.DbResult.BE_SQLITE_ROW === statement.step()) {
167
+ found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });
168
+ }
169
+ });
170
+ return found;
171
+ }
148
172
  /** @internal */
149
173
  toJSON() {
150
174
  const val = super.toJSON();
@@ -157,6 +181,15 @@ class ExternalSourceAspect extends ElementMultiAspect {
157
181
  val.jsonProperties = this.jsonProperties;
158
182
  return val;
159
183
  }
184
+ /** @internal */
185
+ collectReferenceConcreteIds(referenceIds) {
186
+ super.collectReferenceConcreteIds(referenceIds);
187
+ if (this.scope)
188
+ referenceIds.addElement(this.scope.id);
189
+ referenceIds.addElement(this.element.id);
190
+ if (this.source)
191
+ referenceIds.addElement(this.source.id);
192
+ }
160
193
  }
161
194
  exports.ExternalSourceAspect = ExternalSourceAspect;
162
195
  /** @public */
@@ -1 +1 @@
1
- {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA2H;AAC3H,qCAAkC;AAGlC,sDAA2D;AAwB3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAKvC,gBAAgB;IAChB,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IARD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAS1E,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,M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AdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(_arg: OnAspectIdArg): void { }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n\r\n /** The owner of the channel */\r\n public owner: string;\r\n\r\n /** @internal */\r\n constructor(props: ChannelRootAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.owner = props.owner;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ChannelRootAspectProps {\r\n const val = super.toJSON() as ChannelRootAspectProps;\r\n val.owner = this.owner;\r\n return val;\r\n }\r\n\r\n /** Insert a ChannelRootAspect on the specified element. */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, ownerDescription: string) {\r\n const props: ChannelRootAspectProps = {\r\n classFullName: ChannelRootAspect.classFullName,\r\n element: { id: ownerId },\r\n owner: ownerDescription,\r\n };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source. */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process. */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** Look up the ElementId of the element that contains an aspect with the specified Scope, Kind, and Identifier\r\n */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AAwB3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAKvC,gBAAgB;IAChB,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IARD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAS1E,gBAAgB;IACA,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAsB,IAAU,CAAC;IAE3D;;;OAGG;IACO,MAAM,CAAC,UAAU,CAAC,IAAsB,IAAU,CAAC;IAE7D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAsB,IAAU,CAAC;IAE3D;;;OAGG;IACO,MAAM,CAAC,SAAS,CAAC,IAAsB,IAAU,CAAC;IAE5D;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,IAAmB,IAAU,CAAC;IAExD;;;OAGG;IACO,MAAM,CAAC,SAAS,CAAC,IAAmB,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IAAI,CAAC,QAAQ,CAAC;QAC7B,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QACzC,OAAO,GAAG,CAAC;IACb,CAAC;IAED,gBAAgB;IACG,2BAA2B,CAAC,YAAgC;QAC7E,KAAK,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAChD,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAtGD,oDAsGC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(_arg: OnAspectIdArg): void { }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/** A ChannelRootAspect identifies an Element as the root of a *channel* which is a subset of the overall iModel hierarchy that is independently maintained.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.10\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n\r\n /** The owner of the channel */\r\n public owner: string;\r\n\r\n /** @internal */\r\n constructor(props: ChannelRootAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.owner = props.owner;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ChannelRootAspectProps {\r\n const val = super.toJSON() as ChannelRootAspectProps;\r\n val.owner = this.owner;\r\n return val;\r\n }\r\n\r\n /** Insert a ChannelRootAspect on the specified element. */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, ownerDescription: string) {\r\n const props: ChannelRootAspectProps = {\r\n classFullName: ChannelRootAspect.classFullName,\r\n element: { id: ownerId },\r\n owner: ownerDescription,\r\n };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\r\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\r\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\r\n */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process. */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** @internal */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** @deprecated findAllBySource */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\r\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\r\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\r\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\r\n * Therefore, the result array could have more than one entry with the same elementId.\r\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\r\n * @param iModelDb The iModel to query\r\n * @param scope The scope of the ExternalSourceAspects to find\r\n * @param kind The kind of the ExternalSourceAspects to find\r\n * @param identifier The identifier of the ExternalSourceAspects to find\r\n * @returns the query results\r\n */\r\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\r\n }\r\n });\r\n return found;\r\n }\r\n\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n\r\n /** @internal */\r\n protected override collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceConcreteIds(referenceIds);\r\n if (this.scope)\r\n referenceIds.addElement(this.scope.id);\r\n referenceIds.addElement(this.element.id);\r\n if (this.source)\r\n referenceIds.addElement(this.source.id);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module Schema
3
3
  */
4
4
  import { Id64String } from "@itwin/core-bentley";
5
- import { EntityProps, PropertyCallback } from "@itwin/core-common";
5
+ import { EntityProps, EntityReferenceSet, PropertyCallback } from "@itwin/core-common";
6
6
  import { IModelDb } from "./IModelDb";
7
7
  import { Schema } from "./Schema";
8
8
  /** Represents an entity in an [[IModelDb]] such as an [[Element]], [[Model]], or [[Relationship]].
@@ -67,6 +67,36 @@ export declare class Entity {
67
67
  * @internal
68
68
  */
69
69
  static get isGeneratedClass(): boolean;
70
+ /** Get the Ids of this element's *references*. A *reference* is an element that this element references.
71
+ * This is important for cloning operations but can be useful in other situations as well.
72
+ * @note In the next breaking change, the behavior of this function will change to return a EntityReferenceSet
73
+ * which does not iterate plain Id64s, see [EntityReferenceSet]($backend).
74
+ * @see collectReferenceIds
75
+ * @beta
76
+ */
77
+ getReferenceIds(): Set<Id64String>;
78
+ /** This is the intended and future behavior of [[getReferenceIds]].
79
+ * In the next breaking change it will replace getReferenceIds, and is already used by the transformer
80
+ * @internal
81
+ */
82
+ getReferenceConcreteIds(): EntityReferenceSet;
83
+ /** Collect the Ids of this entity's *references* at this level of the class hierarchy.
84
+ * A *reference* is any entity referenced by this entity's EC Data
85
+ * This is important for cloning operations but can be useful in other situations as well.
86
+ * @param _referenceIds The Id64Set to populate with reference Ids.
87
+ * @note In the next breaking change, the behavior of this function will change to require a EntityReferenceSet argument,
88
+ * which does not accept plain Id64s, see EntityReferenceSet.
89
+ * @note In order to clone/transform an entity, all referenced elements must have been previously cloned and remapped within the [IModelCloneContext]($backend).
90
+ * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.
91
+ * @see getReferenceIds
92
+ * @beta
93
+ */
94
+ protected collectReferenceIds(referenceIds: Set<Id64String>): void;
95
+ /** This is the intended and future behavior of [[getReferenceIds]], and is used in the transformer already.
96
+ * In the next breaking change it will replace getReferenceIds
97
+ * @internal
98
+ */
99
+ protected collectReferenceConcreteIds(_referenceIds: EntityReferenceSet): void;
70
100
  }
71
101
  /** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.
72
102
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAQ,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAoB,MAAM,o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IAAI,GAAG,CAAC,UAAU,CAAC;IAMzC;;;OAGG;IACI,uBAAuB,IAAI,kBAAkB;IAMpD;;;;;;;;;;OAUG;IACH,SAAS,CAAC,mBAAmB,CAAC,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI;IAYlE;;;OAGG;IACH,SAAS,CAAC,2BAA2B,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI;CAG/E;AAED;;GAEG;AACH,oBAAY,eAAe,CAAC,CAAC,IAAI,QAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,CAAA;CAAE,CAAC"}
package/lib/cjs/Entity.js CHANGED
@@ -9,6 +9,7 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Entity = void 0;
11
11
  const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
12
13
  const IModelDb_1 = require("./IModelDb");
13
14
  /** Represents an entity in an [[IModelDb]] such as an [[Element]], [[Model]], or [[Relationship]].
14
15
  * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).
@@ -78,6 +79,57 @@ class Entity {
78
79
  * @internal
79
80
  */
80
81
  static get isGeneratedClass() { return false; }
82
+ // NOTE: will also consider using generated collectReferences everywhere and a separate collectJsonPropertyReferenceIds
83
+ /** Get the Ids of this element's *references*. A *reference* is an element that this element references.
84
+ * This is important for cloning operations but can be useful in other situations as well.
85
+ * @note In the next breaking change, the behavior of this function will change to return a EntityReferenceSet
86
+ * which does not iterate plain Id64s, see [EntityReferenceSet]($backend).
87
+ * @see collectReferenceIds
88
+ * @beta
89
+ */
90
+ getReferenceIds() {
91
+ const referenceIds = new Set();
92
+ this.collectReferenceIds(referenceIds); // eslint-disable-line deprecation/deprecation
93
+ return referenceIds;
94
+ }
95
+ /** This is the intended and future behavior of [[getReferenceIds]].
96
+ * In the next breaking change it will replace getReferenceIds, and is already used by the transformer
97
+ * @internal
98
+ */
99
+ getReferenceConcreteIds() {
100
+ const referenceIds = new core_common_1.EntityReferenceSet();
101
+ this.collectReferenceConcreteIds(referenceIds);
102
+ return referenceIds;
103
+ }
104
+ /** Collect the Ids of this entity's *references* at this level of the class hierarchy.
105
+ * A *reference* is any entity referenced by this entity's EC Data
106
+ * This is important for cloning operations but can be useful in other situations as well.
107
+ * @param _referenceIds The Id64Set to populate with reference Ids.
108
+ * @note In the next breaking change, the behavior of this function will change to require a EntityReferenceSet argument,
109
+ * which does not accept plain Id64s, see EntityReferenceSet.
110
+ * @note In order to clone/transform an entity, all referenced elements must have been previously cloned and remapped within the [IModelCloneContext]($backend).
111
+ * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.
112
+ * @see getReferenceIds
113
+ * @beta
114
+ */
115
+ collectReferenceIds(referenceIds) {
116
+ const concreteEntityIds = this.getReferenceConcreteIds();
117
+ for (const entity of concreteEntityIds) {
118
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/naming-convention
119
+ const EntityReferences = require("./EntityReferences").EntityReferences;
120
+ // the old [[collectReferenceIds]] only supported elements/models, and the id spaces can overlap so dont include anything else
121
+ if (EntityReferences.isElement(entity) || EntityReferences.isModel(entity)) {
122
+ referenceIds.add(EntityReferences.toId64(entity));
123
+ }
124
+ }
125
+ }
126
+ /** This is the intended and future behavior of [[getReferenceIds]], and is used in the transformer already.
127
+ * In the next breaking change it will replace getReferenceIds
128
+ * @internal
129
+ */
130
+ collectReferenceConcreteIds(_referenceIds) {
131
+ return; // no references by default
132
+ }
81
133
  }
82
134
  exports.Entity = Entity;
83
135
  //# sourceMappingURL=Entity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AAErE,yCAAsC;AAGtC;;;;GAIG;AACH,MAAa,MAAM;IAmCjB,gBAAgB;IAChB,YAAY,KAAkB,EAAE,MAAgB;QAnChD;;WAEG;QACa,uBAAkB,GA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AAyB,IAAI,IAAI,mBAAQ,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC;IAEvK,4EAA4E;IACrE,MAAM,KAAK,aAAa,KAAa,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEnG,6EAA6E;IAC7E,IAAW,aAAa,KAAa,OAAO,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC;IAEvE,gBAAgB;IACT,MAAM,KAAK,mBAAmB,KAAe,OAAO,EAAE,CAAC,CAAC,CAAC;IAEhE;;;;;OAKG;IACI,MAAM,CAAC,EAAE,CAAC,UAAyB,IAAa,OAAO,IAAA,2BAAY,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAE/F;;;OAGG;IACI,MAAM,KAAK,gBAAgB,KAAK,OAAO,KAAK,CAAC,CAAC,CAAC;CACvD;AApFD,wBAoFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { Id64, Id64String, isSubclassOf } from \"@itwin/core-bentley\";\r\nimport { EntityProps, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/** Represents an entity in an [[IModelDb]] such as an [[Element]], [[Model]], or [[Relationship]].\r\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\r\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\r\n * @public\r\n */\r\nexport class Entity {\r\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\r\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\r\n */\r\n public readonly isInstanceOfEntity: true = true;\r\n /** The Schema that defines this class. */\r\n public static schema: typeof Schema;\r\n\r\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\r\n\r\n /** The name of the BIS class associated with this class.\r\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\r\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\r\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\r\n */\r\n public static get className(): string { return \"Entity\"; }\r\n\r\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\r\n * This property makes such code slightly less tedious to read and write.\r\n * @internal\r\n */\r\n public get asAny(): any { return this; }\r\n\r\n /** The name of the BIS Schema that defines this class */\r\n public get schemaName(): string { return this._ctor.schema.schemaName; }\r\n\r\n /** The name of the BIS class associated with this class. */\r\n public get className(): string { return this._ctor.className; }\r\n\r\n /** The [[IModelDb]] that contains this Entity */\r\n public iModel: IModelDb;\r\n\r\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\r\n public id: Id64String;\r\n\r\n /** @internal */\r\n constructor(props: EntityProps, iModel: IModelDb) {\r\n this.iModel = iModel;\r\n this.id = Id64.fromJSON(props.id);\r\n // copy all auto-handled properties from input to the object being constructed\r\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\r\n }\r\n\r\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\r\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\r\n */\r\n public toJSON(): EntityProps {\r\n const val: any = {};\r\n val.classFullName = this.classFullName;\r\n if (Id64.isValid(this.id))\r\n val.id = this.id;\r\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\r\n return val;\r\n }\r\n\r\n /** Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n */\r\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) { IModelDb.forEachMetaData(this.iModel, this.classFullName, true, func, includeCustom); }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\r\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\r\n public get classFullName(): string { return this._ctor.classFullName; }\r\n\r\n /** @internal */\r\n public static get protectedOperations(): string[] { return []; }\r\n\r\n /** return whether this Entity class is a subclass of another Entity class\r\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\r\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\r\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\r\n * typescript's restriction on the `this` type in static methods\r\n */\r\n public static is(otherClass: typeof Entity): boolean { return isSubclassOf(this, otherClass); }\r\n\r\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\r\n * ClassRegistry overrides this when generating a class\r\n * @internal\r\n */\r\n public static get isGeneratedClass() { return false; }\r\n}\r\n\r\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\r\n * @public\r\n */\r\nexport type EntityClassType<T> = Function & { prototype: T };\r\n"]}
1
+ {"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AACrE,oDAAyG;AACzG,yCAAsC;AAGtC;;;;GAIG;AACH,MAAa,MAAM;IAmCjB,gBAAgB;IAChB,YAAY,KAAkB,EAAE,MAAgB;QAnChD;;WAEG;QACa,uBAAkB,GAAS,IAAI,CAAC;QAiC9C,IAAI,CAAC,MAAM,GAAG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C9H,IAAI,gBAAgB,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;gBAC1E,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;aACnD;SACF;IACH,CAAC;IAED;;;OAGG;IACO,2BAA2B,CAAC,aAAiC;QACrE,OAAO,CAAC,2BAA2B;IACrC,CAAC;CACF;AA3ID,wBA2IC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { Id64, Id64String, isSubclassOf } from \"@itwin/core-bentley\";\r\nimport { EntityProps, EntityReferenceSet, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/** Represents an entity in an [[IModelDb]] such as an [[Element]], [[Model]], or [[Relationship]].\r\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\r\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\r\n * @public\r\n */\r\nexport class Entity {\r\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\r\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\r\n */\r\n public readonly isInstanceOfEntity: true = true;\r\n /** The Schema that defines this class. */\r\n public static schema: typeof Schema;\r\n\r\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\r\n\r\n /** The name of the BIS class associated with this class.\r\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\r\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\r\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\r\n */\r\n public static get className(): string { return \"Entity\"; }\r\n\r\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\r\n * This property makes such code slightly less tedious to read and write.\r\n * @internal\r\n */\r\n public get asAny(): any { return this; }\r\n\r\n /** The name of the BIS Schema that defines this class */\r\n public get schemaName(): string { return this._ctor.schema.schemaName; }\r\n\r\n /** The name of the BIS class associated with this class. */\r\n public get className(): string { return this._ctor.className; }\r\n\r\n /** The [[IModelDb]] that contains this Entity */\r\n public iModel: IModelDb;\r\n\r\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\r\n public id: Id64String;\r\n\r\n /** @internal */\r\n constructor(props: EntityProps, iModel: IModelDb) {\r\n this.iModel = iModel;\r\n this.id = Id64.fromJSON(props.id);\r\n // copy all auto-handled properties from input to the object being constructed\r\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\r\n }\r\n\r\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\r\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\r\n */\r\n public toJSON(): EntityProps {\r\n const val: any = {};\r\n val.classFullName = this.classFullName;\r\n if (Id64.isValid(this.id))\r\n val.id = this.id;\r\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\r\n return val;\r\n }\r\n\r\n /** Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n */\r\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) { IModelDb.forEachMetaData(this.iModel, this.classFullName, true, func, includeCustom); }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\r\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\r\n public get classFullName(): string { return this._ctor.classFullName; }\r\n\r\n /** @internal */\r\n public static get protectedOperations(): string[] { return []; }\r\n\r\n /** return whether this Entity class is a subclass of another Entity class\r\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\r\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\r\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\r\n * typescript's restriction on the `this` type in static methods\r\n */\r\n public static is(otherClass: typeof Entity): boolean { return isSubclassOf(this, otherClass); }\r\n\r\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\r\n * ClassRegistry overrides this when generating a class\r\n * @internal\r\n */\r\n public static get isGeneratedClass() { return false; }\r\n\r\n // NOTE: will also consider using generated collectReferences everywhere and a separate collectJsonPropertyReferenceIds\r\n /** Get the Ids of this element's *references*. A *reference* is an element that this element references.\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @note In the next breaking change, the behavior of this function will change to return a EntityReferenceSet\r\n * which does not iterate plain Id64s, see [EntityReferenceSet]($backend).\r\n * @see collectReferenceIds\r\n * @beta\r\n */\r\n public getReferenceIds(): Set<Id64String> {\r\n const referenceIds = new Set<Id64String>();\r\n this.collectReferenceIds(referenceIds); // eslint-disable-line deprecation/deprecation\r\n return referenceIds;\r\n }\r\n\r\n /** This is the intended and future behavior of [[getReferenceIds]].\r\n * In the next breaking change it will replace getReferenceIds, and is already used by the transformer\r\n * @internal\r\n */\r\n public getReferenceConcreteIds(): EntityReferenceSet {\r\n const referenceIds = new EntityReferenceSet();\r\n this.collectReferenceConcreteIds(referenceIds);\r\n return referenceIds;\r\n }\r\n\r\n /** Collect the Ids of this entity's *references* at this level of the class hierarchy.\r\n * A *reference* is any entity referenced by this entity's EC Data\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @param _referenceIds The Id64Set to populate with reference Ids.\r\n * @note In the next breaking change, the behavior of this function will change to require a EntityReferenceSet argument,\r\n * which does not accept plain Id64s, see EntityReferenceSet.\r\n * @note In order to clone/transform an entity, all referenced elements must have been previously cloned and remapped within the [IModelCloneContext]($backend).\r\n * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.\r\n * @see getReferenceIds\r\n * @beta\r\n */\r\n protected collectReferenceIds(referenceIds: Set<Id64String>): void {\r\n const concreteEntityIds = this.getReferenceConcreteIds();\r\n for (const entity of concreteEntityIds) {\r\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/naming-convention\r\n const EntityReferences = (require(\"./EntityReferences\") as typeof import(\"./EntityReferences\")).EntityReferences;\r\n // the old [[collectReferenceIds]] only supported elements/models, and the id spaces can overlap so dont include anything else\r\n if (EntityReferences.isElement(entity) || EntityReferences.isModel(entity)) {\r\n referenceIds.add(EntityReferences.toId64(entity));\r\n }\r\n }\r\n }\r\n\r\n /** This is the intended and future behavior of [[getReferenceIds]], and is used in the transformer already.\r\n * In the next breaking change it will replace getReferenceIds\r\n * @internal\r\n */\r\n protected collectReferenceConcreteIds(_referenceIds: EntityReferenceSet): void {\r\n return; // no references by default\r\n }\r\n}\r\n\r\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\r\n * @public\r\n */\r\nexport type EntityClassType<T> = Function & { prototype: T };\r\n"]}
@@ -0,0 +1,50 @@
1
+ /** @packageDocumentation
2
+ * @module Schema
3
+ */
4
+ import { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from "@itwin/core-common";
5
+ import { Id64String } from "@itwin/core-bentley";
6
+ import type { Entity } from "./Entity";
7
+ import { Model } from "./Model";
8
+ import { Element } from "./Element";
9
+ import { ElementAspect } from "./ElementAspect";
10
+ import { Relationship, RelationshipProps } from "./Relationship";
11
+ /** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity
12
+ * other entity classes. In the future if there is a need
13
+ * to manage them this way, it can be added
14
+ * @alpha
15
+ */
16
+ export declare type ConcreteEntity = Element | Model | ElementAspect | Relationship;
17
+ /** Props for a [[ConcreteEntity]]
18
+ * @alpha
19
+ */
20
+ export declare type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;
21
+ /**
22
+ * Utilities for the [EntityReference]($common) type which is a kind of strings
23
+ * @alpha
24
+ */
25
+ export declare namespace EntityReferences {
26
+ function isModel(id: EntityReference): boolean;
27
+ function isElement(id: EntityReference): boolean;
28
+ function isElementAspect(id: EntityReference): boolean;
29
+ function isRelationship(id: EntityReference): boolean;
30
+ function toId64(id: EntityReference): string;
31
+ /** split a concrete entity id into its type and raw id */
32
+ function split(id: EntityReference): [ConcreteEntityTypes, Id64String];
33
+ /** used by the transformer to figure out where to check for the existence in a db of a concrete element id
34
+ * @internal
35
+ */
36
+ function isValid(id: EntityReference): boolean;
37
+ /** create the invalid id for a concrete entity type
38
+ * @internal
39
+ */
40
+ function makeInvalid(type: ConcreteEntityTypes): EntityReference;
41
+ /** create an EntityReference given an entity */
42
+ function from(entity: ConcreteEntity): EntityReference;
43
+ /** create an EntityReference given an id and a JavaScript class */
44
+ function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference;
45
+ /** Create an EntityReference quickly from an exact reference type and id */
46
+ function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference;
47
+ /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */
48
+ function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes;
49
+ }
50
+ //# sourceMappingURL=EntityReferences.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityReferences.d.ts","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACxH,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,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AAa,CAAC,WAAW,EAAE,OAAO,MAAM,GAAG,mBAAmB,CAW7E;CACF"}
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Schema
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.EntityReferences = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const core_bentley_1 = require("@itwin/core-bentley");
13
+ const Model_1 = require("./Model");
14
+ const Element_1 = require("./Element");
15
+ const ElementAspect_1 = require("./ElementAspect");
16
+ const Relationship_1 = require("./Relationship");
17
+ const assert = require("assert");
18
+ /**
19
+ * Utilities for the [EntityReference]($common) type which is a kind of strings
20
+ * @alpha
21
+ */
22
+ var EntityReferences;
23
+ (function (EntityReferences) {
24
+ function isModel(id) {
25
+ return id[0] === core_common_1.ConcreteEntityTypes.Model;
26
+ }
27
+ EntityReferences.isModel = isModel;
28
+ function isElement(id) {
29
+ return id[0] === core_common_1.ConcreteEntityTypes.Element;
30
+ }
31
+ EntityReferences.isElement = isElement;
32
+ function isElementAspect(id) {
33
+ return id[0] === core_common_1.ConcreteEntityTypes.ElementAspect;
34
+ }
35
+ EntityReferences.isElementAspect = isElementAspect;
36
+ function isRelationship(id) {
37
+ return id[0] === core_common_1.ConcreteEntityTypes.Relationship;
38
+ }
39
+ EntityReferences.isRelationship = isRelationship;
40
+ function toId64(id) {
41
+ return id.slice(1);
42
+ }
43
+ EntityReferences.toId64 = toId64;
44
+ /** split a concrete entity id into its type and raw id */
45
+ function split(id) {
46
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
47
+ return [id[0], id.slice(1)];
48
+ }
49
+ EntityReferences.split = split;
50
+ /** used by the transformer to figure out where to check for the existence in a db of a concrete element id
51
+ * @internal
52
+ */
53
+ function isValid(id) {
54
+ return core_bentley_1.Id64.isValid(toId64(id));
55
+ }
56
+ EntityReferences.isValid = isValid;
57
+ /** create the invalid id for a concrete entity type
58
+ * @internal
59
+ */
60
+ function makeInvalid(type) {
61
+ return `${type}${core_bentley_1.Id64.invalid}`;
62
+ }
63
+ EntityReferences.makeInvalid = makeInvalid;
64
+ /** create an EntityReference given an entity */
65
+ function from(entity) {
66
+ const type = typeFromClass(entity.constructor);
67
+ return `${type}${entity.id}`;
68
+ }
69
+ EntityReferences.from = from;
70
+ /** create an EntityReference given an id and a JavaScript class */
71
+ function fromClass(id, entityClass) {
72
+ const type = typeFromClass(entityClass);
73
+ return `${type}${id}`;
74
+ }
75
+ EntityReferences.fromClass = fromClass;
76
+ /** Create an EntityReference quickly from an exact reference type and id */
77
+ function fromEntityType(id, type) {
78
+ return `${type}${id}`;
79
+ }
80
+ EntityReferences.fromEntityType = fromEntityType;
81
+ /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */
82
+ function typeFromClass(entityClass) {
83
+ if (entityClass.is(Element_1.Element))
84
+ return core_common_1.ConcreteEntityTypes.Element;
85
+ else if (entityClass.is(ElementAspect_1.ElementAspect))
86
+ return core_common_1.ConcreteEntityTypes.ElementAspect;
87
+ else if (entityClass.is(Model_1.Model))
88
+ return core_common_1.ConcreteEntityTypes.Model;
89
+ else if (entityClass.is(Relationship_1.Relationship))
90
+ return core_common_1.ConcreteEntityTypes.Relationship;
91
+ else
92
+ assert(false, "unknown or abstract entity type passed to EntityReferences.from");
93
+ }
94
+ EntityReferences.typeFromClass = typeFromClass;
95
+ })(EntityReferences = exports.EntityReferences || (exports.EntityReferences = {}));
96
+ //# sourceMappingURL=EntityReferences.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityReferences.js","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAwH;AACxH,sDAAuD;AAEvD,mCAAgC;AA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mBAAI,CAAC,OAAO,EAAE,CAAC;IAClC,CAAC;IAFe,4BAAW,cAE1B,CAAA;IAED,gDAAgD;IAChD,SAAgB,IAAI,CAAC,MAAsB;QACzC,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,WAA4B,CAAC,CAAC;QAChE,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;IAC/B,CAAC;IAHe,qBAAI,OAGnB,CAAA;IAED,mEAAmE;IACnE,SAAgB,SAAS,CAAC,EAAc,EAAE,WAA0B;QAClE,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAHe,0BAAS,YAGxB,CAAA;IAED,4EAA4E;IAC5E,SAAgB,cAAc,CAAC,EAAc,EAAE,IAAyB;QACtE,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAFe,+BAAc,iBAE7B,CAAA;IAED,+FAA+F;IAC/F,SAAgB,aAAa,CAAC,WAA0B;QACtD,IAAI,WAAW,CAAC,EAAE,CAAC,iBAAO,CAAC;YACzB,OAAO,iCAAmB,CAAC,OAAO,CAAC;aAChC,IAAI,WAAW,CAAC,EAAE,CAAC,6BAAa,CAAC;YACpC,OAAO,iCAAmB,CAAC,aAAa,CAAC;aACtC,IAAI,WAAW,CAAC,EAAE,CAAC,aAAK,CAAC;YAC5B,OAAO,iCAAmB,CAAC,KAAK,CAAC;aAC9B,IAAI,WAAW,CAAC,EAAE,CAAC,2BAAY,CAAC;YACnC,OAAO,iCAAmB,CAAC,YAAY,CAAC;;YAExC,MAAM,CAAC,KAAK,EAAE,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAXe,8BAAa,gBAW5B,CAAA;AACH,CAAC,EAnEgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAmEhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from \"@itwin/core-common\";\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport type { Entity } from \"./Entity\";\r\nimport { Model } from \"./Model\";\r\nimport { Element } from \"./Element\";\r\nimport { ElementAspect } from \"./ElementAspect\";\r\nimport { Relationship, RelationshipProps } from \"./Relationship\";\r\nimport * as assert from \"assert\";\r\n\r\n/** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity\r\n * other entity classes. In the future if there is a need\r\n * to manage them this way, it can be added\r\n * @alpha\r\n */\r\nexport type ConcreteEntity = Element | Model | ElementAspect | Relationship;\r\n\r\n/** Props for a [[ConcreteEntity]]\r\n * @alpha\r\n */\r\nexport type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;\r\n\r\n/**\r\n * Utilities for the [EntityReference]($common) type which is a kind of strings\r\n * @alpha\r\n */\r\nexport namespace EntityReferences {\r\n export function isModel(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Model;\r\n }\r\n export function isElement(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Element;\r\n }\r\n export function isElementAspect(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.ElementAspect;\r\n }\r\n export function isRelationship(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Relationship;\r\n }\r\n export function toId64(id: EntityReference) {\r\n return id.slice(1);\r\n }\r\n\r\n /** split a concrete entity id into its type and raw id */\r\n export function split(id: EntityReference): [ConcreteEntityTypes, Id64String] {\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n return [id[0] as ConcreteEntityTypes, id.slice(1)];\r\n }\r\n\r\n /** used by the transformer to figure out where to check for the existence in a db of a concrete element id\r\n * @internal\r\n */\r\n export function isValid(id: EntityReference): boolean {\r\n return Id64.isValid(toId64(id));\r\n }\r\n\r\n /** create the invalid id for a concrete entity type\r\n * @internal\r\n */\r\n export function makeInvalid(type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${Id64.invalid}`;\r\n }\r\n\r\n /** create an EntityReference given an entity */\r\n export function from(entity: ConcreteEntity): EntityReference {\r\n const type = typeFromClass(entity.constructor as typeof Entity);\r\n return `${type}${entity.id}`;\r\n }\r\n\r\n /** create an EntityReference given an id and a JavaScript class */\r\n export function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference {\r\n const type = typeFromClass(entityClass);\r\n return `${type}${id}`;\r\n }\r\n\r\n /** Create an EntityReference quickly from an exact reference type and id */\r\n export function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${id}`;\r\n }\r\n\r\n /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */\r\n export function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes {\r\n if (entityClass.is(Element))\r\n return ConcreteEntityTypes.Element;\r\n else if (entityClass.is(ElementAspect))\r\n return ConcreteEntityTypes.ElementAspect;\r\n else if (entityClass.is(Model))\r\n return ConcreteEntityTypes.Model;\r\n else if (entityClass.is(Relationship))\r\n return ConcreteEntityTypes.Relationship;\r\n else\r\n assert(false, \"unknown or abstract entity type passed to EntityReferences.from\");\r\n }\r\n}\r\n"]}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { Id64String } from "@itwin/core-bentley";
5
5
  import { Point3d } from "@itwin/core-geometry";
6
- import { Code, ExternalSourceAttachmentProps, ExternalSourceAttachmentRole, ExternalSourceProps, SynchronizationConfigLinkProps } from "@itwin/core-common";
6
+ import { Code, EntityReferenceSet, ExternalSourceAttachmentProps, ExternalSourceAttachmentRole, ExternalSourceProps, SynchronizationConfigLinkProps } from "@itwin/core-common";
7
7
  import { InformationReferenceElement, UrlLink } from "./Element";
8
8
  import { IModelDb } from "./IModelDb";
9
9
  import { ExternalSourceAttachmentAttachesSource, ExternalSourceIsInRepository } from "./NavigationRelationship";
@@ -32,6 +32,8 @@ export declare class ExternalSource extends InformationReferenceElement {
32
32
  * @see [[ensureCodeSpec]]
33
33
  */
34
34
  static createCode(iModelDb: IModelDb, codeValue: string): Code;
35
+ /** @internal */
36
+ protected collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void;
35
37
  }
36
38
  /** Attachment of an ExternalSource
37
39
  * @note The associated ECClass was added to the BisCore schema in version 1.0.13
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalSource.d.ts","sourceRoot":"","sources":["../../src/ExternalSource.ts"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EACQ,IAAI,EAAiB,6BAA6B,EAAE,4BAA4B,EAAE,mBAAmB,EAClH,8BAA8B,EAC/B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,sCAAsC,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAEhH;;;GAGG;AACH,qBAAa,cAAe,SAAQ,2BAA2B;IAC7D,wDAAwD;IACjD,UAAU,CAAC,EAAE,4BAA4B,CAAC;IACjD,2EAA2E;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;IAC9B,8EAA8E;IACvE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACjC,gBAAgB;IAChB,WAA2B,SAAS,IAAI,MAAM,CAA6B;IAC3E,gBAAgB;gBACG,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ;IAK/D,gBAAgB;IACA,MAAM,IAAI,mBAAmB;IAG7C,wHAAwH;WAC1G,cAAc,CAAC,QAAQ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
  const codeSpec = iModelDb.codeSpecs.getByName(core_common_1.BisCodeSpec.externalSource);
49
49
  return new core_common_1.Code({ spec: codeSpec.id, scope: core_common_1.IModel.rootSubjectId, value: codeValue });
50
50
  }
51
+ /** @internal */
52
+ collectReferenceConcreteIds(referenceIds) {
53
+ super.collectReferenceConcreteIds(referenceIds);
54
+ if (this.repository)
55
+ referenceIds.addElement(this.repository.id);
56
+ }
51
57
  }
52
58
  exports.ExternalSource = ExternalSource;
53
59
  /** Attachment of an ExternalSource
@@ -1 +1 @@
1
- {"version":3,"file":"ExternalSource.js","sourceRoot":"","sources":["../../src/ExternalSource.ts"],"names":[],"mappings":";AACA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA+C;AAC/C,oDAG4B;AAC5B,uCAAiE;AAEjE,qEAAgH;AAEhH;;;GAGG;AACH,MAAa,cAAe,SAAQ,qCAA2B;IAS7D,gBAAgB;IAChB,YAAmB,KAA0B,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,KAAK,CAAC,UAAU;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,qDAA4B,CAAC,4BAAc,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACpG,CAAC;IAPD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC;IAO3E,gBAAgB;IACA,MAAM;QACpB,OAAO,KAAK,CAAC,MAAM,EAAyB,CAAC,CAAC,sDAAsD;IACtG,CAAC;IACD,wHAAwH;IACjH,MAAM,CAAC,cAAc,CAAC,QAAkB;QAC7C,IAAI;YACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,cAAc,CAAC,CAAC;YAC1E,OAAO,QAAQ,CAAC,EAAE,CAAC;SACpB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,QAAQ,CAAC,SAAS,CAAC,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---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { Point3d } from \"@itwin/core-geometry\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeSpec, ExternalSourceAttachmentProps, ExternalSourceAttachmentRole, ExternalSourceProps, IModel, RelatedElement,\r\n SynchronizationConfigLinkProps,\r\n} from \"@itwin/core-common\";\r\nimport { InformationReferenceElement, UrlLink } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ExternalSourceAttachmentAttachesSource, ExternalSourceIsInRepository } from \"./NavigationRelationship\";\r\n\r\n/** An ExternalSource refers to an 'information container' found in a repository. In some cases, the container is the entire repository.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSource extends InformationReferenceElement {\r\n /** The repository that contains this ExternalSource. */\r\n public repository?: ExternalSourceIsInRepository;\r\n /** The name of the iModel Connecter that processed this ExternalSource. */\r\n public connectorName?: string;\r\n /** The version of the iModel Connecter that processed this ExternalSource. */\r\n public connectorVersion?: string;\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSource\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.repository)\r\n this.repository = new ExternalSourceIsInRepository(RelatedElement.idFromJson(props.repository));\r\n }\r\n /** @internal */\r\n public override toJSON(): ExternalSourceProps { // This override only specializes the return type\r\n return super.toJSON() as ExternalSourceProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n /** The [[CodeSpec]] for ExternalSource elements is not automatically created, so this method ensures that it exists. */\r\n public static ensureCodeSpec(iModelDb: IModelDb): Id64String {\r\n try {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSource);\r\n return codeSpec.id;\r\n } catch (e) {\r\n return iModelDb.codeSpecs.insert(BisCodeSpec.externalSource, CodeScopeSpec.Type.Repository);\r\n }\r\n }\r\n /** Create a Code for an ExternalSource element given a name that is meant to be unique within the scope of the iModel.\r\n * @param iModelDb The IModelDb\r\n * @param codeValue The ExternalSource name\r\n * @see [[ensureCodeSpec]]\r\n */\r\n public static createCode(iModelDb: IModelDb, codeValue: string): Code {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSource);\r\n return new Code({ spec: codeSpec.id, scope: IModel.rootSubjectId, value: codeValue });\r\n }\r\n}\r\n\r\n/** Attachment of an ExternalSource\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceAttachment extends InformationReferenceElement {\r\n /** The [[ExternalSource]] that is attached by this ExternalSourceAttachment. */\r\n public attaches?: ExternalSourceAttachmentAttachesSource;\r\n /** Specifies whether the attached [[ExternalSource]] provides context or models a part of the whole. */\r\n public role?: ExternalSourceAttachmentRole;\r\n /** The translation or offset in global coordinates of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public translation?: Point3d;\r\n /** The Yaw angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public yaw?: number;\r\n /** The Pitch angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public pitch?: number;\r\n /** The Roll angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public roll?: number;\r\n /** The scale of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public scale?: Point3d;\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAttachment\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceAttachmentProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.attaches)\r\n this.attaches = new ExternalSourceAttachmentAttachesSource(RelatedElement.idFromJson(props.attaches));\r\n\r\n if (props.translation)\r\n this.translation = Point3d.fromJSON(props.translation);\r\n\r\n if (props.scale)\r\n this.scale = Point3d.fromJSON(props.scale);\r\n }\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAttachmentProps { // This override only specializes the return type\r\n return super.toJSON() as ExternalSourceAttachmentProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n /** The [[CodeSpec]] for ExternalSourceAttachment elements is not automatically created, so this method ensures that it exists. */\r\n public static ensureCodeSpec(iModelDb: IModelDb): Id64String {\r\n try {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSourceAttachment);\r\n return codeSpec.id;\r\n } catch (e) {\r\n return iModelDb.codeSpecs.insert(BisCodeSpec.externalSourceAttachment, CodeScopeSpec.Type.ParentElement);\r\n }\r\n }\r\n /** Create a Code for an ExternalSourceAttachment element given a name that is meant to be unique within the scope of its parent [[ExternalSource]].\r\n * @param iModelDb The IModelDb\r\n * @param scopeElementId The parent ExternalSource\r\n * @param codeValue The ExternalSourceAttachment name\r\n * @see [[ensureCodeSpec]]\r\n */\r\n public static createCode(iModelDb: IModelDb, scopeElementId: Id64String, codeValue: string): Code {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSourceAttachment);\r\n return new Code({ spec: codeSpec.id, scope: scopeElementId, value: codeValue });\r\n }\r\n}\r\n\r\n/** A group of ExternalSources that are collectively a source of information for one or more elements.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceGroup extends ExternalSource {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceGroup\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** Link to the Configuration for an iModel Synchronization Job\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigLink extends UrlLink {\r\n /** Date/Time of last successful run of this synchronization configuration */\r\n public lastSuccessfulRun?: string;\r\n /** @internal */\r\n public static override get className(): string { return \"SynchronizationConfigLink\"; }\r\n /** @internal */\r\n public constructor(props: SynchronizationConfigLinkProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n /** @internal */\r\n public override toJSON(): SynchronizationConfigLinkProps { // This override only specializes the return type\r\n return super.toJSON() as SynchronizationConfigLinkProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n}\r\n\r\n"]}
1
+ {"version":3,"file":"ExternalSource.js","sourceRoot":"","sources":["../../src/ExternalSource.ts"],"names":[],"mappings":";AACA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,wDAA+C;AAC/C,oDAG4B;AAC5B,uCAAiE;AAEjE,qEAAgH;AAEhH;;;GAGG;AACH,MAAa,cAAe,SAAQ,qCAA2B;IAS7D,gBAAgB;IAChB,YAAmB,KAA0B,EAAE,MAAgB;QAC7D,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,KAAK,CAAC,UAAU;YAClB,IAAI,CAAC,UAAU,GAAG,IAAI,qDAA4B,CAAC,4BAAc,CAAC,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;IACpG,CAAC;IAPD,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC;IAO3E,gBAAgB;IACA,MAAM;QACpB,OAAO,KAAK,CAAC,MAAM,EAAyB,CAAC,CAAC,sDAAsD;IACtG,CAAC;IACD,wHAAwH;IACjH,MAAM,CAAC,cAAc,CAAC,QAAkB;QAC7C,IAAI;YACF,MAAM,QAAQ,GAAG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,cAAc,CAAC,CAAC;YAC1E,OAAO,QAAQ,CAAC,EAAE,CAAC;SACpB;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,yBAAW,CAAC,cAAc,EAAE,2BAAa,CAAC,I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AA2B,CAAC,CAAC,CAAC;IAKtF,gBAAgB;IACA,MAAM;QACpB,OAAO,KAAK,CAAC,MAAM,EAAoC,CAAC,CAAC,sDAAsD;IACjH,CAAC;CACF;AAbD,8DAaC","sourcesContent":["\r\n/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\n\r\nimport { Id64String } from \"@itwin/core-bentley\";\r\nimport { Point3d } from \"@itwin/core-geometry\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeSpec, EntityReferenceSet, ExternalSourceAttachmentProps, ExternalSourceAttachmentRole, ExternalSourceProps, IModel, RelatedElement,\r\n SynchronizationConfigLinkProps,\r\n} from \"@itwin/core-common\";\r\nimport { InformationReferenceElement, UrlLink } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ExternalSourceAttachmentAttachesSource, ExternalSourceIsInRepository } from \"./NavigationRelationship\";\r\n\r\n/** An ExternalSource refers to an 'information container' found in a repository. In some cases, the container is the entire repository.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSource extends InformationReferenceElement {\r\n /** The repository that contains this ExternalSource. */\r\n public repository?: ExternalSourceIsInRepository;\r\n /** The name of the iModel Connecter that processed this ExternalSource. */\r\n public connectorName?: string;\r\n /** The version of the iModel Connecter that processed this ExternalSource. */\r\n public connectorVersion?: string;\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSource\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.repository)\r\n this.repository = new ExternalSourceIsInRepository(RelatedElement.idFromJson(props.repository));\r\n }\r\n /** @internal */\r\n public override toJSON(): ExternalSourceProps { // This override only specializes the return type\r\n return super.toJSON() as ExternalSourceProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n /** The [[CodeSpec]] for ExternalSource elements is not automatically created, so this method ensures that it exists. */\r\n public static ensureCodeSpec(iModelDb: IModelDb): Id64String {\r\n try {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSource);\r\n return codeSpec.id;\r\n } catch (e) {\r\n return iModelDb.codeSpecs.insert(BisCodeSpec.externalSource, CodeScopeSpec.Type.Repository);\r\n }\r\n }\r\n /** Create a Code for an ExternalSource element given a name that is meant to be unique within the scope of the iModel.\r\n * @param iModelDb The IModelDb\r\n * @param codeValue The ExternalSource name\r\n * @see [[ensureCodeSpec]]\r\n */\r\n public static createCode(iModelDb: IModelDb, codeValue: string): Code {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSource);\r\n return new Code({ spec: codeSpec.id, scope: IModel.rootSubjectId, value: codeValue });\r\n }\r\n\r\n /** @internal */\r\n protected override collectReferenceConcreteIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceConcreteIds(referenceIds);\r\n if (this.repository)\r\n referenceIds.addElement(this.repository.id);\r\n }\r\n}\r\n\r\n/** Attachment of an ExternalSource\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceAttachment extends InformationReferenceElement {\r\n /** The [[ExternalSource]] that is attached by this ExternalSourceAttachment. */\r\n public attaches?: ExternalSourceAttachmentAttachesSource;\r\n /** Specifies whether the attached [[ExternalSource]] provides context or models a part of the whole. */\r\n public role?: ExternalSourceAttachmentRole;\r\n /** The translation or offset in global coordinates of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public translation?: Point3d;\r\n /** The Yaw angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public yaw?: number;\r\n /** The Pitch angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public pitch?: number;\r\n /** The Roll angle (in degrees) of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public roll?: number;\r\n /** The scale of the attached [[ExternalSource]] relative to the ExternalSource that attaches it. */\r\n public scale?: Point3d;\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceAttachment\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceAttachmentProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n if (props.attaches)\r\n this.attaches = new ExternalSourceAttachmentAttachesSource(RelatedElement.idFromJson(props.attaches));\r\n\r\n if (props.translation)\r\n this.translation = Point3d.fromJSON(props.translation);\r\n\r\n if (props.scale)\r\n this.scale = Point3d.fromJSON(props.scale);\r\n }\r\n /** @internal */\r\n public override toJSON(): ExternalSourceAttachmentProps { // This override only specializes the return type\r\n return super.toJSON() as ExternalSourceAttachmentProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n /** The [[CodeSpec]] for ExternalSourceAttachment elements is not automatically created, so this method ensures that it exists. */\r\n public static ensureCodeSpec(iModelDb: IModelDb): Id64String {\r\n try {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSourceAttachment);\r\n return codeSpec.id;\r\n } catch (e) {\r\n return iModelDb.codeSpecs.insert(BisCodeSpec.externalSourceAttachment, CodeScopeSpec.Type.ParentElement);\r\n }\r\n }\r\n /** Create a Code for an ExternalSourceAttachment element given a name that is meant to be unique within the scope of its parent [[ExternalSource]].\r\n * @param iModelDb The IModelDb\r\n * @param scopeElementId The parent ExternalSource\r\n * @param codeValue The ExternalSourceAttachment name\r\n * @see [[ensureCodeSpec]]\r\n */\r\n public static createCode(iModelDb: IModelDb, scopeElementId: Id64String, codeValue: string): Code {\r\n const codeSpec = iModelDb.codeSpecs.getByName(BisCodeSpec.externalSourceAttachment);\r\n return new Code({ spec: codeSpec.id, scope: scopeElementId, value: codeValue });\r\n }\r\n}\r\n\r\n/** A group of ExternalSources that are collectively a source of information for one or more elements.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class ExternalSourceGroup extends ExternalSource {\r\n /** @internal */\r\n public static override get className(): string { return \"ExternalSourceGroup\"; }\r\n /** @internal */\r\n public constructor(props: ExternalSourceProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n}\r\n\r\n/** Link to the Configuration for an iModel Synchronization Job\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.13\r\n * @beta\r\n */\r\nexport class SynchronizationConfigLink extends UrlLink {\r\n /** Date/Time of last successful run of this synchronization configuration */\r\n public lastSuccessfulRun?: string;\r\n /** @internal */\r\n public static override get className(): string { return \"SynchronizationConfigLink\"; }\r\n /** @internal */\r\n public constructor(props: SynchronizationConfigLinkProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n }\r\n /** @internal */\r\n public override toJSON(): SynchronizationConfigLinkProps { // This override only specializes the return type\r\n return super.toJSON() as SynchronizationConfigLinkProps; // Entity.toJSON takes care of auto-handled properties\r\n }\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"GeoCoordConfig.d.ts","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAUhD;;;GAGG;AACH,qBAAa,cAAc;IACzB,gFAAgF;IAChF,gBAAuB,UAAU,EAAE,WAAW,CAAC,aAAa,EAAE,CAAM;IAEpE,OAAO,CAAC,MAAM,CAAC,eAAe;IAyC9B,OAAO,CAAC,MAAM,CAAC,OAAO;IAYtB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAS;WAC3B,SAAS;WAKT,oBAAoB,IAAI,IAAI;WAO5B,aAAa,CAAC,QAAQ,EAAE,QAAQ;CAI/C"}
1
+ {"version":3,"file":"GeoCoordConfig.d.ts","sourceRoot":"","sources":["../../src/GeoCoordConfig.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAUhD;;;GAGG;AACH,qBAAa,cAAc;IACzB,gFAAgF;IAChF,gBAAuB,UAAU,EAAE,WAAW,CAAC,aAAa,EAAE,CAAM;IAEpE,OAAO,CAAC,MAAM,CAAC,eAAe;IA2C9B,OAAO,CAAC,MAAM,CAAC,OAAO;IAYtB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAS;WAC3B,SAAS;WAKT,oBAAoB,IAAI,IAAI;WAO5B,aAAa,CAAC,QAAQ,EAAE,QAAQ;CAI/C"}
@@ -21,12 +21,13 @@ class GeoCoordConfig {
21
21
  // override to disable loading GCS data from workspaces
22
22
  if (IModelHost_1.IModelHost.appWorkspace.settings.getBoolean("gcs/disableWorkspaces", false))
23
23
  return;
24
- const ws = IModelHost_1.IModelHost.appWorkspace;
25
- const dbProps = ws.resolveDatabase(gcsDbAlias);
26
- const containerProps = ws.resolveContainer(dbProps.containerName);
27
- const account = ws.resolveAccount(containerProps.accountName);
28
- containerProps.syncOnConnect = true;
24
+ let account;
25
+ let containerProps;
29
26
  try {
27
+ const ws = IModelHost_1.IModelHost.appWorkspace;
28
+ const dbProps = ws.resolveDatabase(gcsDbAlias);
29
+ containerProps = ws.resolveContainer(dbProps.containerName);
30
+ account = ws.resolveAccount(containerProps.accountName);
30
31
  const container = ws.getContainer(containerProps, account);
31
32
  const cloudContainer = container.cloudContainer;
32
33
  if (!(cloudContainer === null || cloudContainer === void 0 ? void 0 : cloudContainer.isConnected)) {
@@ -46,8 +47,10 @@ class GeoCoordConfig {
46
47
  this.prefetches.push(CloudSqlite_1.CloudSqlite.startCloudPrefetch(cloudContainer, gcsDbName));
47
48
  }
48
49
  catch (e) {
49
- core_bentley_1.Logger.logError(loggerCat, `Cannot load GCS workspace (${e.errorNumber}): ${core_bentley_1.BentleyError.getErrorMessage(e)},`
50
- + `container=${account.accessName}/${containerProps.containerId}, storage=${account.storageType}, public=${containerProps.isPublic}, cacheDir=${IModelHost_1.IModelHost.cacheDir}`);
50
+ let msg = `Cannot load GCS workspace (${e.errorNumber}): ${core_bentley_1.BentleyError.getErrorMessage(e)}`;
51
+ if (account && containerProps)
52
+ msg += `,container=${account.accessName}/${containerProps.containerId}, storage=${account.storageType}, public=${containerProps.isPublic}, cacheDir=${IModelHost_1.IModelHost.cacheDir}`;
53
+ core_bentley_1.Logger.logError(loggerCat, msg);
51
54
  }
52
55
  }
53
56
  static loadAll(settings, settingName) {