@itwin/core-backend 3.0.0-dev.100

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 (245) hide show
  1. package/CHANGELOG.md +1525 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +11 -0
  4. package/lib/cjs/AliCloudStorageService.d.ts +12 -0
  5. package/lib/cjs/AliCloudStorageService.d.ts.map +1 -0
  6. package/lib/cjs/AliCloudStorageService.js +70 -0
  7. package/lib/cjs/AliCloudStorageService.js.map +1 -0
  8. package/lib/cjs/BackendHubAccess.d.ts +208 -0
  9. package/lib/cjs/BackendHubAccess.d.ts.map +1 -0
  10. package/lib/cjs/BackendHubAccess.js +42 -0
  11. package/lib/cjs/BackendHubAccess.js.map +1 -0
  12. package/lib/cjs/BackendLoggerCategory.d.ts +83 -0
  13. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -0
  14. package/lib/cjs/BackendLoggerCategory.js +91 -0
  15. package/lib/cjs/BackendLoggerCategory.js.map +1 -0
  16. package/lib/cjs/BisCoreSchema.d.ts +22 -0
  17. package/lib/cjs/BisCoreSchema.d.ts.map +1 -0
  18. package/lib/cjs/BisCoreSchema.js +61 -0
  19. package/lib/cjs/BisCoreSchema.js.map +1 -0
  20. package/lib/cjs/BriefcaseManager.d.ts +167 -0
  21. package/lib/cjs/BriefcaseManager.d.ts.map +1 -0
  22. package/lib/cjs/BriefcaseManager.js +406 -0
  23. package/lib/cjs/BriefcaseManager.js.map +1 -0
  24. package/lib/cjs/Category.d.ts +154 -0
  25. package/lib/cjs/Category.d.ts.map +1 -0
  26. package/lib/cjs/Category.js +244 -0
  27. package/lib/cjs/Category.js.map +1 -0
  28. package/lib/cjs/ChangeSummaryManager.d.ts +188 -0
  29. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -0
  30. package/lib/cjs/ChangeSummaryManager.js +444 -0
  31. package/lib/cjs/ChangeSummaryManager.js.map +1 -0
  32. package/lib/cjs/ChangedElementsDb.d.ts +97 -0
  33. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -0
  34. package/lib/cjs/ChangedElementsDb.js +166 -0
  35. package/lib/cjs/ChangedElementsDb.js.map +1 -0
  36. package/lib/cjs/ChangedElementsManager.d.ts +40 -0
  37. package/lib/cjs/ChangedElementsManager.d.ts.map +1 -0
  38. package/lib/cjs/ChangedElementsManager.js +89 -0
  39. package/lib/cjs/ChangedElementsManager.js.map +1 -0
  40. package/lib/cjs/CheckpointManager.d.ts +101 -0
  41. package/lib/cjs/CheckpointManager.d.ts.map +1 -0
  42. package/lib/cjs/CheckpointManager.js +257 -0
  43. package/lib/cjs/CheckpointManager.js.map +1 -0
  44. package/lib/cjs/ClassRegistry.d.ts +72 -0
  45. package/lib/cjs/ClassRegistry.d.ts.map +1 -0
  46. package/lib/cjs/ClassRegistry.js +154 -0
  47. package/lib/cjs/ClassRegistry.js.map +1 -0
  48. package/lib/cjs/CloudStorageBackend.d.ts +46 -0
  49. package/lib/cjs/CloudStorageBackend.d.ts.map +1 -0
  50. package/lib/cjs/CloudStorageBackend.js +157 -0
  51. package/lib/cjs/CloudStorageBackend.js.map +1 -0
  52. package/lib/cjs/CodeSpecs.d.ts +51 -0
  53. package/lib/cjs/CodeSpecs.d.ts.map +1 -0
  54. package/lib/cjs/CodeSpecs.js +113 -0
  55. package/lib/cjs/CodeSpecs.js.map +1 -0
  56. package/lib/cjs/ConcurrentQuery.d.ts +12 -0
  57. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -0
  58. package/lib/cjs/ConcurrentQuery.js +24 -0
  59. package/lib/cjs/ConcurrentQuery.js.map +1 -0
  60. package/lib/cjs/DevTools.d.ts +72 -0
  61. package/lib/cjs/DevTools.d.ts.map +1 -0
  62. package/lib/cjs/DevTools.js +155 -0
  63. package/lib/cjs/DevTools.js.map +1 -0
  64. package/lib/cjs/DisplayStyle.d.ts +107 -0
  65. package/lib/cjs/DisplayStyle.d.ts.map +1 -0
  66. package/lib/cjs/DisplayStyle.js +292 -0
  67. package/lib/cjs/DisplayStyle.js.map +1 -0
  68. package/lib/cjs/ECDb.d.ts +196 -0
  69. package/lib/cjs/ECDb.d.ts.map +1 -0
  70. package/lib/cjs/ECDb.js +354 -0
  71. package/lib/cjs/ECDb.js.map +1 -0
  72. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -0
  73. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -0
  74. package/lib/cjs/ECSchemaXmlContext.js +36 -0
  75. package/lib/cjs/ECSchemaXmlContext.js.map +1 -0
  76. package/lib/cjs/ECSqlStatement.d.ts +467 -0
  77. package/lib/cjs/ECSqlStatement.d.ts.map +1 -0
  78. package/lib/cjs/ECSqlStatement.js +783 -0
  79. package/lib/cjs/ECSqlStatement.js.map +1 -0
  80. package/lib/cjs/Element.d.ts +1082 -0
  81. package/lib/cjs/Element.d.ts.map +1 -0
  82. package/lib/cjs/Element.js +1392 -0
  83. package/lib/cjs/Element.js.map +1 -0
  84. package/lib/cjs/ElementAspect.d.ts +157 -0
  85. package/lib/cjs/ElementAspect.d.ts.map +1 -0
  86. package/lib/cjs/ElementAspect.js +179 -0
  87. package/lib/cjs/ElementAspect.js.map +1 -0
  88. package/lib/cjs/ElementGraphics.d.ts +10 -0
  89. package/lib/cjs/ElementGraphics.d.ts.map +1 -0
  90. package/lib/cjs/ElementGraphics.js +42 -0
  91. package/lib/cjs/ElementGraphics.js.map +1 -0
  92. package/lib/cjs/Entity.d.ts +57 -0
  93. package/lib/cjs/Entity.d.ts.map +1 -0
  94. package/lib/cjs/Entity.js +63 -0
  95. package/lib/cjs/Entity.js.map +1 -0
  96. package/lib/cjs/ExportGraphics.d.ts +302 -0
  97. package/lib/cjs/ExportGraphics.d.ts.map +1 -0
  98. package/lib/cjs/ExportGraphics.js +206 -0
  99. package/lib/cjs/ExportGraphics.js.map +1 -0
  100. package/lib/cjs/ExternalSource.d.ts +95 -0
  101. package/lib/cjs/ExternalSource.d.ts.map +1 -0
  102. package/lib/cjs/ExternalSource.js +126 -0
  103. package/lib/cjs/ExternalSource.js.map +1 -0
  104. package/lib/cjs/GeometrySummary.d.ts +5 -0
  105. package/lib/cjs/GeometrySummary.d.ts.map +1 -0
  106. package/lib/cjs/GeometrySummary.js +378 -0
  107. package/lib/cjs/GeometrySummary.js.map +1 -0
  108. package/lib/cjs/IModelCloneContext.d.ts +74 -0
  109. package/lib/cjs/IModelCloneContext.d.ts.map +1 -0
  110. package/lib/cjs/IModelCloneContext.js +130 -0
  111. package/lib/cjs/IModelCloneContext.js.map +1 -0
  112. package/lib/cjs/IModelDb.d.ts +1107 -0
  113. package/lib/cjs/IModelDb.d.ts.map +1 -0
  114. package/lib/cjs/IModelDb.js +2161 -0
  115. package/lib/cjs/IModelDb.js.map +1 -0
  116. package/lib/cjs/IModelHost.d.ts +284 -0
  117. package/lib/cjs/IModelHost.d.ts.map +1 -0
  118. package/lib/cjs/IModelHost.js +411 -0
  119. package/lib/cjs/IModelHost.js.map +1 -0
  120. package/lib/cjs/IModelJsFs.d.ts +63 -0
  121. package/lib/cjs/IModelJsFs.d.ts.map +1 -0
  122. package/lib/cjs/IModelJsFs.js +141 -0
  123. package/lib/cjs/IModelJsFs.js.map +1 -0
  124. package/lib/cjs/IModelSchemaLoader.d.ts +26 -0
  125. package/lib/cjs/IModelSchemaLoader.d.ts.map +1 -0
  126. package/lib/cjs/IModelSchemaLoader.js +95 -0
  127. package/lib/cjs/IModelSchemaLoader.js.map +1 -0
  128. package/lib/cjs/IpcHost.d.ts +99 -0
  129. package/lib/cjs/IpcHost.d.ts.map +1 -0
  130. package/lib/cjs/IpcHost.js +234 -0
  131. package/lib/cjs/IpcHost.js.map +1 -0
  132. package/lib/cjs/LineStyle.d.ts +312 -0
  133. package/lib/cjs/LineStyle.d.ts.map +1 -0
  134. package/lib/cjs/LineStyle.js +296 -0
  135. package/lib/cjs/LineStyle.js.map +1 -0
  136. package/lib/cjs/LocalhostIpcHost.d.ts +19 -0
  137. package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -0
  138. package/lib/cjs/LocalhostIpcHost.js +52 -0
  139. package/lib/cjs/LocalhostIpcHost.js.map +1 -0
  140. package/lib/cjs/Material.d.ts +102 -0
  141. package/lib/cjs/Material.d.ts.map +1 -0
  142. package/lib/cjs/Material.js +146 -0
  143. package/lib/cjs/Material.js.map +1 -0
  144. package/lib/cjs/Model.d.ts +387 -0
  145. package/lib/cjs/Model.d.ts.map +1 -0
  146. package/lib/cjs/Model.js +469 -0
  147. package/lib/cjs/Model.js.map +1 -0
  148. package/lib/cjs/NativeAppStorage.d.ts +52 -0
  149. package/lib/cjs/NativeAppStorage.d.ts.map +1 -0
  150. package/lib/cjs/NativeAppStorage.js +203 -0
  151. package/lib/cjs/NativeAppStorage.js.map +1 -0
  152. package/lib/cjs/NativeHost.d.ts +71 -0
  153. package/lib/cjs/NativeHost.d.ts.map +1 -0
  154. package/lib/cjs/NativeHost.js +221 -0
  155. package/lib/cjs/NativeHost.js.map +1 -0
  156. package/lib/cjs/NavigationRelationship.d.ts +157 -0
  157. package/lib/cjs/NavigationRelationship.d.ts.map +1 -0
  158. package/lib/cjs/NavigationRelationship.js +226 -0
  159. package/lib/cjs/NavigationRelationship.js.map +1 -0
  160. package/lib/cjs/PromiseMemoizer.d.ts +52 -0
  161. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -0
  162. package/lib/cjs/PromiseMemoizer.js +93 -0
  163. package/lib/cjs/PromiseMemoizer.js.map +1 -0
  164. package/lib/cjs/Relationship.d.ts +400 -0
  165. package/lib/cjs/Relationship.d.ts.map +1 -0
  166. package/lib/cjs/Relationship.js +460 -0
  167. package/lib/cjs/Relationship.js.map +1 -0
  168. package/lib/cjs/RpcBackend.d.ts +23 -0
  169. package/lib/cjs/RpcBackend.d.ts.map +1 -0
  170. package/lib/cjs/RpcBackend.js +94 -0
  171. package/lib/cjs/RpcBackend.js.map +1 -0
  172. package/lib/cjs/SQLiteDb.d.ts +66 -0
  173. package/lib/cjs/SQLiteDb.d.ts.map +1 -0
  174. package/lib/cjs/SQLiteDb.js +140 -0
  175. package/lib/cjs/SQLiteDb.js.map +1 -0
  176. package/lib/cjs/Schema.d.ts +56 -0
  177. package/lib/cjs/Schema.d.ts.map +1 -0
  178. package/lib/cjs/Schema.js +84 -0
  179. package/lib/cjs/Schema.js.map +1 -0
  180. package/lib/cjs/ServerBasedLocks.d.ts +64 -0
  181. package/lib/cjs/ServerBasedLocks.d.ts.map +1 -0
  182. package/lib/cjs/ServerBasedLocks.js +177 -0
  183. package/lib/cjs/ServerBasedLocks.js.map +1 -0
  184. package/lib/cjs/SqliteStatement.d.ts +264 -0
  185. package/lib/cjs/SqliteStatement.d.ts.map +1 -0
  186. package/lib/cjs/SqliteStatement.js +417 -0
  187. package/lib/cjs/SqliteStatement.js.map +1 -0
  188. package/lib/cjs/Texture.d.ts +59 -0
  189. package/lib/cjs/Texture.d.ts.map +1 -0
  190. package/lib/cjs/Texture.js +83 -0
  191. package/lib/cjs/Texture.js.map +1 -0
  192. package/lib/cjs/TxnManager.d.ts +203 -0
  193. package/lib/cjs/TxnManager.d.ts.map +1 -0
  194. package/lib/cjs/TxnManager.js +354 -0
  195. package/lib/cjs/TxnManager.js.map +1 -0
  196. package/lib/cjs/ViewDefinition.d.ts +432 -0
  197. package/lib/cjs/ViewDefinition.d.ts.map +1 -0
  198. package/lib/cjs/ViewDefinition.js +623 -0
  199. package/lib/cjs/ViewDefinition.js.map +1 -0
  200. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -0
  201. package/lib/cjs/core-backend.d.ts +162 -0
  202. package/lib/cjs/core-backend.d.ts.map +1 -0
  203. package/lib/cjs/core-backend.js +181 -0
  204. package/lib/cjs/core-backend.js.map +1 -0
  205. package/lib/cjs/domains/FunctionalElements.d.ts +102 -0
  206. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -0
  207. package/lib/cjs/domains/FunctionalElements.js +146 -0
  208. package/lib/cjs/domains/FunctionalElements.js.map +1 -0
  209. package/lib/cjs/domains/FunctionalSchema.d.ts +14 -0
  210. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -0
  211. package/lib/cjs/domains/FunctionalSchema.js +41 -0
  212. package/lib/cjs/domains/FunctionalSchema.js.map +1 -0
  213. package/lib/cjs/domains/GenericElements.d.ts +178 -0
  214. package/lib/cjs/domains/GenericElements.d.ts.map +1 -0
  215. package/lib/cjs/domains/GenericElements.js +264 -0
  216. package/lib/cjs/domains/GenericElements.js.map +1 -0
  217. package/lib/cjs/domains/GenericSchema.d.ts +11 -0
  218. package/lib/cjs/domains/GenericSchema.d.ts.map +1 -0
  219. package/lib/cjs/domains/GenericSchema.js +29 -0
  220. package/lib/cjs/domains/GenericSchema.js.map +1 -0
  221. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +16 -0
  222. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts.map +1 -0
  223. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +33 -0
  224. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -0
  225. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +40 -0
  226. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -0
  227. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +207 -0
  228. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -0
  229. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +21 -0
  230. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -0
  231. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +193 -0
  232. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -0
  233. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +37 -0
  234. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -0
  235. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +162 -0
  236. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -0
  237. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +17 -0
  238. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts.map +1 -0
  239. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +44 -0
  240. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -0
  241. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +16 -0
  242. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts.map +1 -0
  243. package/lib/cjs/rpc-impl/WipRpcImpl.js +35 -0
  244. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -0
  245. package/package.json +101 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA2D;AAC3D,oDAAiE;AACjE,qCAAkC;AAElC,qCAA2C;AAC3C,6DAA0D;AAE1D;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GAAQ,IAAI,OAAO,CAAC,GAAG,YAAY,yBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,KAAK,2BAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/H,gBAAgB;IACT,MAAM,CAAC,yBAAyB,CAAC,SAAiB,IAAiB,OAAO,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjK,gBAAgB;IACT,MAAM,CAAC,QAAQ,CAAC,WAA0B,EAAE,MAAqB;QACtE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E,IAAI,IAAI,CAAC,SAAS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Aa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,eAAe,CAAC,aAAqB,IAAI,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH;;;;OAIG;IACI,MAAM,CAAC,qBAAqB,CAAC,MAAqB;QACvD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AApIH,sCAqIC;AApIyB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAsIvE;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","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 { IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, IModelError } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\nimport { IModelSchemaLoader } from \"./IModelSchemaLoader\";\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = undefined !== new IModelSchemaLoader(iModel).getSchema(domain).customAttributes?.get(\"BisCore.SchemaHasBehavior\");\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n // this method relies on the caller having previously created/registered all superclasses\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n const generatedClass = class extends superclass { public static override get className() { return className; } };\r\n // the above line creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => { throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
@@ -0,0 +1,46 @@
1
+ /// <reference types="node" />
2
+ import { Readable } from "stream";
3
+ import { CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, IModelRpcProps } from "@itwin/core-common";
4
+ /** @beta */
5
+ export interface CloudStorageServiceCredentials {
6
+ service: "azure" | "alicloud" | "external";
7
+ account: string;
8
+ accessKey: string;
9
+ }
10
+ /** @beta */
11
+ export interface CloudStorageUploadOptions {
12
+ type?: string;
13
+ cacheControl?: string;
14
+ contentEncoding?: "gzip";
15
+ }
16
+ /** @beta */
17
+ export declare abstract class CloudStorageService {
18
+ initialize(): void;
19
+ terminate(): void;
20
+ abstract id: CloudStorageProvider;
21
+ abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;
22
+ abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;
23
+ download(_name: string): Promise<Readable | undefined>;
24
+ protected makeDescriptor(id: CloudStorageContainerDescriptor): {
25
+ name: string;
26
+ provider: CloudStorageProvider;
27
+ };
28
+ }
29
+ /** @beta */
30
+ export declare class AzureBlobStorage extends CloudStorageService {
31
+ private _service;
32
+ private _credential;
33
+ constructor(credentials: CloudStorageServiceCredentials);
34
+ readonly id = CloudStorageProvider.Azure;
35
+ obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;
36
+ ensureContainer(name: string): Promise<void>;
37
+ upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;
38
+ }
39
+ /** @internal */
40
+ export declare class CloudStorageTileUploader {
41
+ private _activeUploads;
42
+ get activeUploads(): Iterable<Promise<void>>;
43
+ private uploadToCache;
44
+ cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void>;
45
+ }
46
+ //# sourceMappingURL=CloudStorageBackend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudStorageBackend.d.ts","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";AAIA,OAAO,EAAe,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAI/C,OAAO,EACU,+BAA+B,EAAE,wBAAwB,EAAE,oBAAoB,EAAsC,cAAc,EAEnJ,MAAM,oBAAoB,CAAC;AAI5B,YAAY;AACZ,MAAM,WAAW,8BAA8B;IAC7C,OAAO,EAAE,OAAO,GAAG,UAAU,GAAG,UAAU,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,YAAY;AACZ,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,YAAY;AACZ,8BAAsB,mBAAmB;IAChC,UAAU,IAAI,IAAI;IAClB,SAAS,IAAI,IAAI;IACxB,SAAgB,EAAE,EAAE,oBAAoB,CAAC;aACzB,kBAAkB,CAAC,EAAE,EAAE,+BAA+B,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,wBAAwB;aAClH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,yBAAyB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IACrI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,SAAS,CAAC;IAEnE,SAAS,CAAC,cAAc,CAAC,EAAE,EAAE,+BAA+B;;;;CAG7D;AAED,YAAY;AACZ,qBAAa,gBAAiB,SAAQ,mBAAmB;IACvD,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,WAAW,CAAmC;gBAEnC,WAAW,EAAE,8BAA8B;IAa9D,SAAgB,EAAE,8BAA8B;IAEzC,kBAAkB,CAAC,EAAE,EAAE,+BAA+B,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,wBAAwB;IAuB5G,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqB5C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,yBAAyB,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CA4ChJ;AAED,gBAAgB;AAChB,qBAAa,wBAAwB;IACnC,OAAO,CAAC,cAAc,CAAyC;IAE/D,IAAW,aAAa,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAElD;YAEa,aAAa;IAoBd,SAAS,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAevK"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CloudStorageTileUploader = exports.AzureBlobStorage = exports.CloudStorageService = void 0;
4
+ /*---------------------------------------------------------------------------------------------
5
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
6
+ * See LICENSE.md in the project root for license terms and full copyright notice.
7
+ *--------------------------------------------------------------------------------------------*/
8
+ const stream_1 = require("stream");
9
+ const zlib = require("zlib");
10
+ const Azure = require("@azure/storage-blob");
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const BackendLoggerCategory_1 = require("./BackendLoggerCategory");
14
+ const IModelHost_1 = require("./IModelHost");
15
+ /** @beta */
16
+ class CloudStorageService {
17
+ initialize() { }
18
+ terminate() { }
19
+ async download(_name) { return undefined; }
20
+ makeDescriptor(id) {
21
+ return { name: id.name, provider: this.id };
22
+ }
23
+ }
24
+ exports.CloudStorageService = CloudStorageService;
25
+ /** @beta */
26
+ class AzureBlobStorage extends CloudStorageService {
27
+ constructor(credentials) {
28
+ super();
29
+ this.id = core_common_1.CloudStorageProvider.Azure;
30
+ if (credentials.service !== "azure" || !credentials.account || !credentials.accessKey) {
31
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, "Invalid credentials for Azure blob storage.");
32
+ }
33
+ this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);
34
+ const options = {};
35
+ const pipeline = Azure.newPipeline(this._credential, options);
36
+ this._service = new Azure.BlobServiceClient(`https://${credentials.account}.blob.core.windows.net`, pipeline);
37
+ }
38
+ obtainContainerUrl(id, expiry, clientIp) {
39
+ const policy = {
40
+ containerName: id.name,
41
+ permissions: Azure.ContainerSASPermissions.parse("rl"),
42
+ expiresOn: expiry,
43
+ };
44
+ if (clientIp && clientIp !== "localhost" && clientIp !== "127.0.0.1" && clientIp !== "::1") {
45
+ policy.ipRange = { start: clientIp };
46
+ }
47
+ const token = Azure.generateBlobSASQueryParameters(policy, this._credential);
48
+ const url = {
49
+ descriptor: this.makeDescriptor(id),
50
+ valid: 0,
51
+ expires: expiry.getTime(),
52
+ url: `https://${this._credential.accountName}.blob.core.windows.net/${id.name}?${token.toString()}`,
53
+ };
54
+ return url;
55
+ }
56
+ async ensureContainer(name) {
57
+ try {
58
+ const container = this._service.getContainerClient(name);
59
+ await container.create();
60
+ return;
61
+ }
62
+ catch (maybeErr) {
63
+ try {
64
+ const err = maybeErr;
65
+ if (err.statusCode === 409 && err.code === "ContainerAlreadyExists") {
66
+ return;
67
+ }
68
+ }
69
+ catch { }
70
+ if (typeof (maybeErr) !== "undefined" && maybeErr) {
71
+ throw maybeErr;
72
+ }
73
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Unable to create container "${name}".`);
74
+ }
75
+ }
76
+ async upload(container, name, data, options, metadata) {
77
+ var _a, _b, _c;
78
+ try {
79
+ await this.ensureContainer(container);
80
+ const containerClient = this._service.getContainerClient(container);
81
+ const blocks = containerClient.getBlockBlobClient(name);
82
+ const blobHTTPHeaders = {
83
+ blobContentType: (_a = options === null || options === void 0 ? void 0 : options.type) !== null && _a !== void 0 ? _a : "application/octet-stream",
84
+ blobCacheControl: (_b = options === null || options === void 0 ? void 0 : options.cacheControl) !== null && _b !== void 0 ? _b : "private, max-age=31536000, immutable",
85
+ };
86
+ const blobOptions = metadata ?
87
+ {
88
+ blobHTTPHeaders,
89
+ metadata: { ...metadata },
90
+ } : {
91
+ blobHTTPHeaders,
92
+ };
93
+ const dataStream = new stream_1.PassThrough();
94
+ dataStream.end(data);
95
+ let source;
96
+ if (options && options.contentEncoding === "gzip") {
97
+ blobOptions.blobHTTPHeaders.blobContentEncoding = options.contentEncoding;
98
+ const compressor = zlib.createGzip();
99
+ source = dataStream.pipe(compressor);
100
+ }
101
+ else {
102
+ source = dataStream;
103
+ }
104
+ const blockSize = 100 * 1024 * 1024;
105
+ const concurrency = 1;
106
+ const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);
107
+ return (_c = result.etag) !== null && _c !== void 0 ? _c : "";
108
+ }
109
+ catch (maybeErr) {
110
+ if (typeof (maybeErr) !== "undefined" && maybeErr) {
111
+ throw maybeErr;
112
+ }
113
+ throw new core_common_1.IModelError(core_common_1.BentleyStatus.ERROR, `Unable to upload "${name}".`);
114
+ }
115
+ }
116
+ }
117
+ exports.AzureBlobStorage = AzureBlobStorage;
118
+ /** @internal */
119
+ class CloudStorageTileUploader {
120
+ constructor() {
121
+ this._activeUploads = new Map();
122
+ }
123
+ get activeUploads() {
124
+ return this._activeUploads.values();
125
+ }
126
+ async uploadToCache(id, content, containerKey, resourceKey, metadata) {
127
+ await new Promise((resolve) => setTimeout(resolve));
128
+ try {
129
+ const options = {};
130
+ if (IModelHost_1.IModelHost.compressCachedTiles) {
131
+ options.contentEncoding = "gzip";
132
+ }
133
+ const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost_1.IModelHost.compressCachedTiles };
134
+ const perfLogger = new core_bentley_1.PerfLogger("Uploading tile to external tile cache", () => perfInfo);
135
+ await IModelHost_1.IModelHost.tileCacheService.upload(containerKey, resourceKey, content, options, metadata);
136
+ perfLogger.dispose();
137
+ }
138
+ catch (err) {
139
+ core_bentley_1.Logger.logError(BackendLoggerCategory_1.BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));
140
+ }
141
+ this._activeUploads.delete(containerKey + resourceKey);
142
+ }
143
+ async cacheTile(tokenProps, treeId, contentId, content, guid, metadata) {
144
+ const id = { tokenProps, treeId, contentId, guid };
145
+ const cache = core_common_1.CloudStorageTileCache.getCache();
146
+ const containerKey = cache.formContainerName(id);
147
+ const resourceKey = cache.formResourceName(id);
148
+ const key = containerKey + resourceKey;
149
+ if (this._activeUploads.has(key))
150
+ return;
151
+ const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);
152
+ this._activeUploads.set(key, promise);
153
+ await promise;
154
+ }
155
+ }
156
+ exports.CloudStorageTileUploader = CloudStorageTileUploader;
157
+ //# sourceMappingURL=CloudStorageBackend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudStorageBackend.js","sourceRoot":"","sources":["../../src/CloudStorageBackend.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,mCAA+C;AAC/C,6BAA6B;AAC7B,6CAA6C;AAC7C,sDAAyD;AACzD,oDAG4B;AAC5B,mEAAgE;AAChE,6CAA0C;AAgB1C,YAAY;AACZ,MAAsB,mBAAmB;IAChC,UAAU,KAAW,C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ChG,UAAU,CAAC,OAAO,EAAE,CAAC;SACtB;QAAC,OAAO,GAAG,EAAE;YACZ,qBAAM,CAAC,QAAQ,CAAC,6CAAqB,CAAC,gBAAgB,EAAE,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;SACxH;QAED,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,GAAG,WAAW,CAAC,CAAC;IACzD,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAA0B,EAAE,MAAc,EAAE,SAAiB,EAAE,OAAmB,EAAE,IAAwB,EAAE,QAAiB;QACpJ,MAAM,EAAE,GAA0B,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAE1E,MAAM,KAAK,GAAG,mCAAqB,CAAC,QAAQ,EAAE,CAAC;QAC/C,MAAM,YAAY,GAAG,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACjD,MAAM,WAAW,GAAG,KAAK,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,YAAY,GAAG,WAAW,CAAC;QAEvC,IAAI,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC;YAC9B,OAAO;QAET,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,CAAC,CAAC;QACrF,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACtC,MAAM,OAAO,CAAC;IAChB,CAAC;CACF;AA1CD,4DA0CC","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\nimport { PassThrough, Readable } from \"stream\";\r\nimport * as zlib from \"zlib\";\r\nimport * as Azure from \"@azure/storage-blob\";\r\nimport { Logger, PerfLogger } from \"@itwin/core-bentley\";\r\nimport {\r\n BentleyStatus, CloudStorageContainerDescriptor, CloudStorageContainerUrl, CloudStorageProvider, CloudStorageTileCache, IModelError, IModelRpcProps,\r\n TileContentIdentifier,\r\n} from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/** @beta */\r\nexport interface CloudStorageServiceCredentials {\r\n service: \"azure\" | \"alicloud\" | \"external\";\r\n account: string;\r\n accessKey: string;\r\n}\r\n\r\n/** @beta */\r\nexport interface CloudStorageUploadOptions {\r\n type?: string;\r\n cacheControl?: string;\r\n contentEncoding?: \"gzip\";\r\n}\r\n\r\n/** @beta */\r\nexport abstract class CloudStorageService {\r\n public initialize(): void { }\r\n public terminate(): void { }\r\n public abstract id: CloudStorageProvider;\r\n public abstract obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl;\r\n public abstract upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string>;\r\n public async download(_name: string): Promise<Readable | undefined> { return undefined; }\r\n\r\n protected makeDescriptor(id: CloudStorageContainerDescriptor) {\r\n return { name: id.name, provider: this.id };\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport class AzureBlobStorage extends CloudStorageService {\r\n private _service: Azure.BlobServiceClient;\r\n private _credential: Azure.StorageSharedKeyCredential;\r\n\r\n public constructor(credentials: CloudStorageServiceCredentials) {\r\n super();\r\n\r\n if (credentials.service !== \"azure\" || !credentials.account || !credentials.accessKey) {\r\n throw new IModelError(BentleyStatus.ERROR, \"Invalid credentials for Azure blob storage.\");\r\n }\r\n\r\n this._credential = new Azure.StorageSharedKeyCredential(credentials.account, credentials.accessKey);\r\n const options: Azure.StoragePipelineOptions = {};\r\n const pipeline = Azure.newPipeline(this._credential, options);\r\n this._service = new Azure.BlobServiceClient(`https://${credentials.account}.blob.core.windows.net`, pipeline);\r\n }\r\n\r\n public readonly id = CloudStorageProvider.Azure;\r\n\r\n public obtainContainerUrl(id: CloudStorageContainerDescriptor, expiry: Date, clientIp?: string): CloudStorageContainerUrl {\r\n const policy: Azure.BlobSASSignatureValues = {\r\n containerName: id.name,\r\n permissions: Azure.ContainerSASPermissions.parse(\"rl\"),\r\n expiresOn: expiry,\r\n };\r\n\r\n if (clientIp && clientIp !== \"localhost\" && clientIp !== \"127.0.0.1\" && clientIp !== \"::1\") {\r\n policy.ipRange = { start: clientIp };\r\n }\r\n\r\n const token = Azure.generateBlobSASQueryParameters(policy, this._credential);\r\n\r\n const url: CloudStorageContainerUrl = {\r\n descriptor: this.makeDescriptor(id),\r\n valid: 0,\r\n expires: expiry.getTime(),\r\n url: `https://${this._credential.accountName}.blob.core.windows.net/${id.name}?${token.toString()}`,\r\n };\r\n\r\n return url;\r\n }\r\n\r\n public async ensureContainer(name: string): Promise<void> {\r\n try {\r\n const container = this._service.getContainerClient(name);\r\n await container.create();\r\n return;\r\n } catch (maybeErr) {\r\n try {\r\n const err = maybeErr as Azure.RestError;\r\n if (err.statusCode === 409 && err.code === \"ContainerAlreadyExists\") {\r\n return;\r\n }\r\n } catch { }\r\n\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to create container \"${name}\".`);\r\n }\r\n }\r\n\r\n public async upload(container: string, name: string, data: Uint8Array, options?: CloudStorageUploadOptions, metadata?: object): Promise<string> {\r\n try {\r\n await this.ensureContainer(container);\r\n\r\n const containerClient = this._service.getContainerClient(container);\r\n const blocks = containerClient.getBlockBlobClient(name);\r\n const blobHTTPHeaders = {\r\n blobContentType: options?.type ?? \"application/octet-stream\",\r\n blobCacheControl: options?.cacheControl ?? \"private, max-age=31536000, immutable\",\r\n };\r\n\r\n const blobOptions: Azure.BlockBlobUploadStreamOptions = metadata ?\r\n {\r\n blobHTTPHeaders,\r\n metadata: { ...metadata },\r\n } : {\r\n blobHTTPHeaders,\r\n };\r\n\r\n const dataStream = new PassThrough();\r\n dataStream.end(data);\r\n\r\n let source: Readable;\r\n\r\n if (options && options.contentEncoding === \"gzip\") {\r\n blobOptions.blobHTTPHeaders!.blobContentEncoding = options.contentEncoding;\r\n const compressor = zlib.createGzip();\r\n source = dataStream.pipe(compressor);\r\n } else {\r\n source = dataStream;\r\n }\r\n\r\n const blockSize = 100 * 1024 * 1024;\r\n const concurrency = 1;\r\n const result = await blocks.uploadStream(source, blockSize, concurrency, blobOptions);\r\n return result.etag ?? \"\";\r\n } catch (maybeErr) {\r\n if (typeof (maybeErr) !== \"undefined\" && maybeErr) {\r\n throw maybeErr;\r\n }\r\n\r\n throw new IModelError(BentleyStatus.ERROR, `Unable to upload \"${name}\".`);\r\n }\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport class CloudStorageTileUploader {\r\n private _activeUploads: Map<string, Promise<void>> = new Map();\r\n\r\n public get activeUploads(): Iterable<Promise<void>> {\r\n return this._activeUploads.values();\r\n }\r\n\r\n private async uploadToCache(id: TileContentIdentifier, content: Uint8Array, containerKey: string, resourceKey: string, metadata?: object,) {\r\n await new Promise((resolve) => setTimeout(resolve));\r\n\r\n try {\r\n const options: CloudStorageUploadOptions = {};\r\n if (IModelHost.compressCachedTiles) {\r\n options.contentEncoding = \"gzip\";\r\n }\r\n\r\n const perfInfo = { ...id.tokenProps, treeId: id.treeId, contentId: id.contentId, size: content.byteLength, compress: IModelHost.compressCachedTiles };\r\n const perfLogger = new PerfLogger(\"Uploading tile to external tile cache\", () => perfInfo);\r\n await IModelHost.tileCacheService.upload(containerKey, resourceKey, content, options, metadata);\r\n perfLogger.dispose();\r\n } catch (err) {\r\n Logger.logError(BackendLoggerCategory.IModelTileUpload, (err instanceof Error) ? err.toString() : JSON.stringify(err));\r\n }\r\n\r\n this._activeUploads.delete(containerKey + resourceKey);\r\n }\r\n\r\n public async cacheTile(tokenProps: IModelRpcProps, treeId: string, contentId: string, content: Uint8Array, guid: string | undefined, metadata?: object): Promise<void> {\r\n const id: TileContentIdentifier = { tokenProps, treeId, contentId, guid };\r\n\r\n const cache = CloudStorageTileCache.getCache();\r\n const containerKey = cache.formContainerName(id);\r\n const resourceKey = cache.formResourceName(id);\r\n const key = containerKey + resourceKey;\r\n\r\n if (this._activeUploads.has(key))\r\n return;\r\n\r\n const promise = this.uploadToCache(id, content, containerKey, resourceKey, metadata);\r\n this._activeUploads.set(key, promise);\r\n await promise;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,51 @@
1
+ /** @packageDocumentation
2
+ * @module Codes
3
+ */
4
+ import { Id64String } from "@itwin/core-bentley";
5
+ import { CodeScopeSpec, CodeSpec } from "@itwin/core-common";
6
+ import { IModelDb } from "./IModelDb";
7
+ /** Manages [CodeSpecs]($docs/BIS/intro/element-fundamentals.md#codespec) within an [[IModelDb]]
8
+ * @public
9
+ */
10
+ export declare class CodeSpecs {
11
+ private _imodel;
12
+ private _loadedCodeSpecs;
13
+ constructor(imodel: IModelDb);
14
+ /** Look up the Id of the CodeSpec with the specified name. */
15
+ queryId(name: string): Id64String;
16
+ /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.
17
+ * @param codeSpecId The Id of the CodeSpec to load
18
+ * @returns The CodeSpec with the specified Id
19
+ * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.
20
+ */
21
+ getById(codeSpecId: Id64String): CodeSpec;
22
+ /** Returns true if the IModelDb has a CodeSpec of the specified Id. */
23
+ hasId(codeSpecId: Id64String): boolean;
24
+ /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.
25
+ * @param name The name of the CodeSpec to load
26
+ * @returns The CodeSpec with the specified name
27
+ * @throws [[IModelError]] if no CodeSpec with the specified name could be found.
28
+ */
29
+ getByName(name: string): CodeSpec;
30
+ /** Returns true if the IModelDb has a CodeSpec of the specified name. */
31
+ hasName(name: string): boolean;
32
+ /** Add a new CodeSpec to the iModel.
33
+ * @param codeSpec The CodeSpec to insert
34
+ * @returns The Id of the persistent CodeSpec.
35
+ * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec
36
+ * @throws IModelError if the insertion fails
37
+ */
38
+ insert(codeSpec: CodeSpec): Id64String;
39
+ /** Add a new CodeSpec to the IModelDb.
40
+ * @param name The name for the new CodeSpec.
41
+ * @param scopeType The scope type
42
+ * @returns The Id of the persistent CodeSpec.
43
+ * @throws IModelError if the insertion fails
44
+ */
45
+ insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;
46
+ /** Load a CodeSpec from the iModel
47
+ * @param id The persistent Id of the CodeSpec to load
48
+ */
49
+ load(id: Id64String): CodeSpec;
50
+ }
51
+ //# sourceMappingURL=CodeSpecs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeSpecs.d.ts","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAkB,UAAU,EAAgB,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAe,MAAM,oBAAoB,CAAC;AAE1E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,OAAO,CAAW;IAC1B,OAAO,CAAC,gBAAgB,CAAkB;gBAE9B,MAAM,EAAE,QAAQ;IAO5B,8DAA8D;IACvD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IASxC;;;;OAIG;IACI,OAAO,CAAC,UAAU,EAAE,UAAU,GAAG,QAAQ;IAehD,uEAAuE;IAChE,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO;IAQ7C;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ;IAWxC,yEAAyE;IAClE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAQrC;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU;IAC7C;;;;;OAKG;IACI,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,IAAI,GAAG,UAAU;IAgBtE;;OAEG;IACI,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,QAAQ;CAatC"}
@@ -0,0 +1,113 @@
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 Codes
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.CodeSpecs = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ /** Manages [CodeSpecs]($docs/BIS/intro/element-fundamentals.md#codespec) within an [[IModelDb]]
14
+ * @public
15
+ */
16
+ class CodeSpecs {
17
+ constructor(imodel) {
18
+ this._loadedCodeSpecs = [];
19
+ this._imodel = imodel;
20
+ if (imodel.isBriefcaseDb()) {
21
+ imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);
22
+ }
23
+ }
24
+ /** Look up the Id of the CodeSpec with the specified name. */
25
+ queryId(name) {
26
+ return this._imodel.withPreparedStatement("SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name", (stmt) => {
27
+ stmt.bindString("name", name);
28
+ if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
29
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found", () => ({ name }));
30
+ return stmt.getValue(0).getId();
31
+ });
32
+ }
33
+ /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.
34
+ * @param codeSpecId The Id of the CodeSpec to load
35
+ * @returns The CodeSpec with the specified Id
36
+ * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.
37
+ */
38
+ getById(codeSpecId) {
39
+ if (core_bentley_1.Id64.isInvalid(codeSpecId))
40
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
41
+ // good chance it is already loaded - check there before running a query
42
+ const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);
43
+ if (found !== undefined)
44
+ return found;
45
+ // must load this codespec
46
+ const loadedCodeSpec = this.load(codeSpecId);
47
+ this._loadedCodeSpecs.push(loadedCodeSpec);
48
+ return loadedCodeSpec;
49
+ }
50
+ /** Returns true if the IModelDb has a CodeSpec of the specified Id. */
51
+ hasId(codeSpecId) {
52
+ try {
53
+ return undefined !== this.getById(codeSpecId);
54
+ }
55
+ catch (error) {
56
+ return false;
57
+ }
58
+ }
59
+ /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.
60
+ * @param name The name of the CodeSpec to load
61
+ * @returns The CodeSpec with the specified name
62
+ * @throws [[IModelError]] if no CodeSpec with the specified name could be found.
63
+ */
64
+ getByName(name) {
65
+ // good chance it is already loaded - check there before running a query
66
+ const found = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);
67
+ if (found !== undefined)
68
+ return found;
69
+ const codeSpecId = this.queryId(name);
70
+ if (codeSpecId === undefined)
71
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, "CodeSpec not found", () => ({ name }));
72
+ return this.getById(codeSpecId);
73
+ }
74
+ /** Returns true if the IModelDb has a CodeSpec of the specified name. */
75
+ hasName(name) {
76
+ try {
77
+ return undefined !== this.getByName(name);
78
+ }
79
+ catch (error) {
80
+ return false;
81
+ }
82
+ }
83
+ insert(codeSpecOrName, scopeType) {
84
+ if (codeSpecOrName instanceof core_common_1.CodeSpec) {
85
+ const codeSpec = codeSpecOrName;
86
+ const id = this._imodel.insertCodeSpec(codeSpec);
87
+ codeSpec.id = id;
88
+ return id;
89
+ }
90
+ if (typeof codeSpecOrName === "string") {
91
+ const name = codeSpecOrName;
92
+ if (scopeType)
93
+ return this._imodel.insertCodeSpec(core_common_1.CodeSpec.create(this._imodel, name, scopeType));
94
+ }
95
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadArg, "Invalid argument");
96
+ }
97
+ /** Load a CodeSpec from the iModel
98
+ * @param id The persistent Id of the CodeSpec to load
99
+ */
100
+ load(id) {
101
+ if (core_bentley_1.Id64.isInvalid(id))
102
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
103
+ return this._imodel.withPreparedStatement("SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?", (stmt) => {
104
+ stmt.bindId(1, id);
105
+ if (core_bentley_1.DbResult.BE_SQLITE_ROW !== stmt.step())
106
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.InvalidId, "Invalid codeSpecId");
107
+ const row = stmt.getRow();
108
+ return core_common_1.CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));
109
+ });
110
+ }
111
+ }
112
+ exports.CodeSpecs = CodeSpecs;
113
+ //# sourceMappingURL=CodeSpecs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeSpecs.js","sourceRoot":"","sources":["../../src/CodeSpecs.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA+E;AAC/E,oDAA0E;AAI1E;;GAEG;AACH,MAAa,SAAS;IAIpB,YAAY,MAAgB;QAFpB,qBAAgB,GAAe,EAAE,CAAC;QAGxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE;YAC1B,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,C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AS,CAAC,CAAC,CAAC;SACtF;QACD,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACjE,CAAC;IAED;;OAEG;IACI,IAAI,CAAC,EAAc;QACxB,IAAI,mBAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YACpB,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;QAEtE,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,uEAAuE,EAAE,CAAC,IAAoB,EAAE,EAAE;YAC1I,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACnB,IAAI,uBAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE;gBACxC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAEtE,MAAM,GAAG,GAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;YAC/B,OAAO,sBAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAC7F,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,8BAwHC","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 Codes\r\n */\r\n\r\nimport { DbResult, Id64, Id64String, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { CodeScopeSpec, CodeSpec, IModelError } from \"@itwin/core-common\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/** Manages [CodeSpecs]($docs/BIS/intro/element-fundamentals.md#codespec) within an [[IModelDb]]\r\n * @public\r\n */\r\nexport class CodeSpecs {\r\n private _imodel: IModelDb;\r\n private _loadedCodeSpecs: CodeSpec[] = [];\r\n\r\n constructor(imodel: IModelDb) {\r\n this._imodel = imodel;\r\n if (imodel.isBriefcaseDb()) {\r\n imodel.onChangesetApplied.addListener(() => this._loadedCodeSpecs.length = 0);\r\n }\r\n }\r\n\r\n /** Look up the Id of the CodeSpec with the specified name. */\r\n public queryId(name: string): Id64String {\r\n return this._imodel.withPreparedStatement(\"SELECT ECInstanceId FROM BisCore.CodeSpec WHERE Name=:name\", (stmt: ECSqlStatement) => {\r\n stmt.bindString(\"name\", name);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return stmt.getValue(0).getId();\r\n });\r\n }\r\n\r\n /** Look up a CodeSpec by Id. The CodeSpec will be loaded from the database if necessary.\r\n * @param codeSpecId The Id of the CodeSpec to load\r\n * @returns The CodeSpec with the specified Id\r\n * @throws [[IModelError]] if the Id is invalid or if no CodeSpec with that Id could be found.\r\n */\r\n public getById(codeSpecId: Id64String): CodeSpec {\r\n if (Id64.isInvalid(codeSpecId))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.id === codeSpecId);\r\n if (found !== undefined)\r\n return found;\r\n\r\n // must load this codespec\r\n const loadedCodeSpec = this.load(codeSpecId);\r\n this._loadedCodeSpecs.push(loadedCodeSpec);\r\n return loadedCodeSpec;\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified Id. */\r\n public hasId(codeSpecId: Id64String): boolean {\r\n try {\r\n return undefined !== this.getById(codeSpecId);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Look up a CodeSpec by name. The CodeSpec will be loaded from the database if necessary.\r\n * @param name The name of the CodeSpec to load\r\n * @returns The CodeSpec with the specified name\r\n * @throws [[IModelError]] if no CodeSpec with the specified name could be found.\r\n */\r\n public getByName(name: string): CodeSpec {\r\n // good chance it is already loaded - check there before running a query\r\n const found: CodeSpec | undefined = this._loadedCodeSpecs.find((codeSpec) => codeSpec.name === name);\r\n if (found !== undefined)\r\n return found;\r\n const codeSpecId = this.queryId(name);\r\n if (codeSpecId === undefined)\r\n throw new IModelError(IModelStatus.NotFound, \"CodeSpec not found\", () => ({ name }));\r\n return this.getById(codeSpecId);\r\n }\r\n\r\n /** Returns true if the IModelDb has a CodeSpec of the specified name. */\r\n public hasName(name: string): boolean {\r\n try {\r\n return undefined !== this.getByName(name);\r\n } catch (error) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Add a new CodeSpec to the iModel.\r\n * @param codeSpec The CodeSpec to insert\r\n * @returns The Id of the persistent CodeSpec.\r\n * @note If successful, this method will assign a valid CodeSpecId to the supplied CodeSpec\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(codeSpec: CodeSpec): Id64String;\r\n /** Add a new CodeSpec to the IModelDb.\r\n * @param name The name for the new CodeSpec.\r\n * @param scopeType The scope type\r\n * @returns The Id of the persistent CodeSpec.\r\n * @throws IModelError if the insertion fails\r\n */\r\n public insert(name: string, scopeType: CodeScopeSpec.Type): Id64String;\r\n public insert(codeSpecOrName: CodeSpec | string, scopeType?: CodeScopeSpec.Type): Id64String {\r\n if (codeSpecOrName instanceof CodeSpec) {\r\n const codeSpec = codeSpecOrName;\r\n const id: Id64String = this._imodel.insertCodeSpec(codeSpec);\r\n codeSpec.id = id;\r\n return id;\r\n }\r\n if (typeof codeSpecOrName === \"string\") {\r\n const name = codeSpecOrName;\r\n if (scopeType)\r\n return this._imodel.insertCodeSpec(CodeSpec.create(this._imodel, name, scopeType));\r\n }\r\n throw new IModelError(IModelStatus.BadArg, \"Invalid argument\");\r\n }\r\n\r\n /** Load a CodeSpec from the iModel\r\n * @param id The persistent Id of the CodeSpec to load\r\n */\r\n public load(id: Id64String): CodeSpec {\r\n if (Id64.isInvalid(id))\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n return this._imodel.withPreparedStatement(\"SELECT name,jsonProperties FROM BisCore.CodeSpec WHERE ECInstanceId=?\", (stmt: ECSqlStatement) => {\r\n stmt.bindId(1, id);\r\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\r\n throw new IModelError(IModelStatus.InvalidId, \"Invalid codeSpecId\");\r\n\r\n const row: any = stmt.getRow();\r\n return CodeSpec.createFromJson(this._imodel, id, row.name, JSON.parse(row.jsonProperties));\r\n });\r\n }\r\n}\r\n"]}
@@ -0,0 +1,12 @@
1
+ import { IModelJsNative } from "@bentley/imodeljs-native";
2
+ import { DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse } from "@itwin/core-common";
3
+ /** @internal */
4
+ export declare type OnResponse = (response: Response) => void;
5
+ /** @internal */
6
+ export declare class ConcurrentQuery {
7
+ /** @internal */
8
+ static executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse>;
9
+ /** @internal */
10
+ static executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse>;
11
+ }
12
+ //# sourceMappingURL=ConcurrentQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConcurrentQuery.d.ts","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEpG,gBAAgB;AAChB,oBAAY,UAAU,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;AAEtD,gBAAgB;AAChB,qBAAa,eAAe;IAC1B,gBAAgB;WACI,mBAAmB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAO5I,gBAAgB;WACI,kBAAkB,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,GAAG,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,cAAc,CAAC;CAO1I"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConcurrentQuery = void 0;
4
+ /** @internal */
5
+ class ConcurrentQuery {
6
+ /** @internal */
7
+ static async executeQueryRequest(conn, request) {
8
+ return new Promise((resolve) => {
9
+ conn.concurrentQueryExecute(request, (response) => {
10
+ resolve(response);
11
+ });
12
+ });
13
+ }
14
+ /** @internal */
15
+ static async executeBlobRequest(conn, request) {
16
+ return new Promise((resolve) => {
17
+ conn.concurrentQueryExecute(request, (response) => {
18
+ resolve(response);
19
+ });
20
+ });
21
+ }
22
+ }
23
+ exports.ConcurrentQuery = ConcurrentQuery;
24
+ //# sourceMappingURL=ConcurrentQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConcurrentQuery.js","sourceRoot":"","sources":["../../src/ConcurrentQuery.ts"],"names":[],"mappings":";;;AAUA,gBAAgB;AAChB,MAAa,eAAe;IAC1B,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,IAAgD,EAAE,OAAuB;QAC/G,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,EAAE;YAC9C,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA2B,CAAC,CAAC;YACvC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IACD,gBAAgB;IACT,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAgD,EAAE,OAAsB;QAC7G,OAAO,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YAC7C,IAAI,CAAC,sBAAsB,CAAC,OAAc,EAAE,CAAC,QAAa,EAAE,EAAE;gBAC5D,OAAO,CAAC,QAA0B,CAAC,CAAC;YACtC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAjBD,0CAiBC","sourcesContent":["import { IModelJsNative } from \"@bentley/imodeljs-native\";\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\nimport { DbBlobRequest, DbBlobResponse, DbQueryRequest, DbQueryResponse } from \"@itwin/core-common\";\r\n\r\n/** @internal */\r\nexport type OnResponse = (response: Response) => void;\r\n\r\n/** @internal */\r\nexport class ConcurrentQuery {\r\n /** @internal */\r\n public static async executeQueryRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbQueryRequest): Promise<DbQueryResponse> {\r\n return new Promise<DbQueryResponse>((resolve) => {\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbQueryResponse);\r\n });\r\n });\r\n }\r\n /** @internal */\r\n public static async executeBlobRequest(conn: IModelJsNative.ECDb | IModelJsNative.DgnDb, request: DbBlobRequest): Promise<DbBlobResponse> {\r\n return new Promise<DbBlobResponse>((resolve) => {\r\n conn.concurrentQueryExecute(request as any, (response: any) => {\r\n resolve(response as DbBlobResponse);\r\n });\r\n });\r\n }\r\n}\r\n"]}
@@ -0,0 +1,72 @@
1
+ /// <reference types="node" />
2
+ import * as os from "os";
3
+ import { LogLevel } from "@itwin/core-bentley";
4
+ /**
5
+ * Performance and Memory statistics of backend
6
+ * @internal
7
+ */
8
+ export interface DevToolsStats {
9
+ os: DevToolsOsStats;
10
+ process: DevToolsProcessStats;
11
+ }
12
+ /**
13
+ * OS stats of backend
14
+ * @internal
15
+ */
16
+ export interface DevToolsOsStats {
17
+ platform: NodeJS.Platform;
18
+ hostname: string;
19
+ totalmem: number;
20
+ freemem: number;
21
+ uptime: number;
22
+ cpus: os.CpuInfo[];
23
+ cpuUsage: number;
24
+ }
25
+ /**
26
+ * Process stats of backend
27
+ * @internal
28
+ */
29
+ export interface DevToolsProcessStats {
30
+ uptime: number;
31
+ pid: number;
32
+ ppid: number;
33
+ memoryUsage: NodeJS.MemoryUsage;
34
+ }
35
+ /** Utility to format the JSON created by DevTools.stats() to include the appropriate units
36
+ * @internal
37
+ */
38
+ export declare class DevToolsStatsFormatter {
39
+ private static readonly _megaByteProps;
40
+ private static readonly _percentProps;
41
+ private static readonly _mHzProps;
42
+ private static readonly _secondsProps;
43
+ /** Replacer that includes units - can be used with JSON.stringify() */
44
+ private static _replacer;
45
+ /** Converts the input stats to another JSON object with the appropriate units setup for various fields */
46
+ static toFormattedJson(stats: any): any;
47
+ }
48
+ /**
49
+ * Internal diagnostic utility
50
+ * @internal
51
+ */
52
+ export declare class DevTools {
53
+ /** Receives a ping and returns true */
54
+ static ping(): boolean;
55
+ private static hrtimeToMS;
56
+ private static bytesToMegaBytes;
57
+ private static evaluateCpuUsage;
58
+ private static evaluateCpus;
59
+ private static evaluateMemoryUsage;
60
+ private static evaluateProcessStats;
61
+ private static evaluateOsStats;
62
+ /** Returns JSON object with backend statistics */
63
+ static stats(): DevToolsStats;
64
+ /** Sets up a log level at the backend and returns the old log level */
65
+ static setLogLevel(inLoggerCategory: string, newLevel: LogLevel): LogLevel | undefined;
66
+ /** Obtains the backend application and iModel.js versions */
67
+ static versions(): {
68
+ application: string;
69
+ iModelJs: any;
70
+ };
71
+ }
72
+ //# sourceMappingURL=DevTools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DevTools.d.ts","sourceRoot":"","sources":["../../src/DevTools.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAA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