@itwin/core-backend 3.4.2 → 3.4.4

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 (229) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/AliCloudStorageService.d.ts +23 -23
  3. package/lib/cjs/AliCloudStorageService.js +71 -71
  4. package/lib/cjs/AliCloudStorageService.js.map +1 -1
  5. package/lib/cjs/BackendHubAccess.d.ts +224 -224
  6. package/lib/cjs/BackendHubAccess.js +41 -41
  7. package/lib/cjs/BackendHubAccess.js.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.d.ts +91 -91
  9. package/lib/cjs/BackendLoggerCategory.js +99 -99
  10. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  11. package/lib/cjs/BisCoreSchema.d.ts +21 -21
  12. package/lib/cjs/BisCoreSchema.js +60 -60
  13. package/lib/cjs/BisCoreSchema.js.map +1 -1
  14. package/lib/cjs/BriefcaseManager.d.ts +165 -165
  15. package/lib/cjs/BriefcaseManager.js +405 -405
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +153 -153
  18. package/lib/cjs/Category.js +243 -243
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts +187 -187
  21. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.js +445 -445
  23. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  24. package/lib/cjs/ChangedElementsDb.d.ts +99 -99
  25. package/lib/cjs/ChangedElementsDb.js +165 -165
  26. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  27. package/lib/cjs/ChangedElementsManager.d.ts +39 -39
  28. package/lib/cjs/ChangedElementsManager.js +88 -88
  29. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  30. package/lib/cjs/CheckpointManager.d.ts +120 -120
  31. package/lib/cjs/CheckpointManager.js +343 -343
  32. package/lib/cjs/CheckpointManager.js.map +1 -1
  33. package/lib/cjs/ClassRegistry.d.ts +79 -72
  34. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  35. package/lib/cjs/ClassRegistry.js +249 -243
  36. package/lib/cjs/ClassRegistry.js.map +1 -1
  37. package/lib/cjs/CloudSqlite.d.ts +349 -349
  38. package/lib/cjs/CloudSqlite.js +151 -151
  39. package/lib/cjs/CloudSqlite.js.map +1 -1
  40. package/lib/cjs/CloudStorageBackend.d.ts +58 -58
  41. package/lib/cjs/CloudStorageBackend.js +173 -173
  42. package/lib/cjs/CloudStorageBackend.js.map +1 -1
  43. package/lib/cjs/CodeService.d.ts +396 -396
  44. package/lib/cjs/CodeService.js +63 -63
  45. package/lib/cjs/CodeService.js.map +1 -1
  46. package/lib/cjs/CodeSpecs.d.ts +50 -50
  47. package/lib/cjs/CodeSpecs.js +112 -112
  48. package/lib/cjs/CodeSpecs.js.map +1 -1
  49. package/lib/cjs/ConcurrentQuery.d.ts +11 -11
  50. package/lib/cjs/ConcurrentQuery.js +30 -30
  51. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  52. package/lib/cjs/CustomViewState3dCreator.d.ts +21 -21
  53. package/lib/cjs/CustomViewState3dCreator.js +81 -81
  54. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  55. package/lib/cjs/DevTools.d.ts +71 -71
  56. package/lib/cjs/DevTools.js +154 -154
  57. package/lib/cjs/DevTools.js.map +1 -1
  58. package/lib/cjs/DisplayStyle.d.ts +106 -106
  59. package/lib/cjs/DisplayStyle.js +256 -256
  60. package/lib/cjs/DisplayStyle.js.map +1 -1
  61. package/lib/cjs/ECDb.d.ts +191 -191
  62. package/lib/cjs/ECDb.js +350 -350
  63. package/lib/cjs/ECDb.js.map +1 -1
  64. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -18
  65. package/lib/cjs/ECSchemaXmlContext.js +41 -41
  66. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  67. package/lib/cjs/ECSqlStatement.d.ts +466 -466
  68. package/lib/cjs/ECSqlStatement.js +791 -791
  69. package/lib/cjs/ECSqlStatement.js.map +1 -1
  70. package/lib/cjs/Element.d.ts +1120 -1120
  71. package/lib/cjs/Element.js +1438 -1438
  72. package/lib/cjs/Element.js.map +1 -1
  73. package/lib/cjs/ElementAspect.d.ts +161 -158
  74. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  75. package/lib/cjs/ElementAspect.js +187 -186
  76. package/lib/cjs/ElementAspect.js.map +1 -1
  77. package/lib/cjs/ElementGraphics.d.ts +9 -9
  78. package/lib/cjs/ElementGraphics.js +41 -41
  79. package/lib/cjs/ElementGraphics.js.map +1 -1
  80. package/lib/cjs/ElementTreeWalker.d.ts +162 -162
  81. package/lib/cjs/ElementTreeWalker.js +409 -409
  82. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  83. package/lib/cjs/Entity.d.ts +106 -106
  84. package/lib/cjs/Entity.js +134 -134
  85. package/lib/cjs/Entity.js.map +1 -1
  86. package/lib/cjs/EntityReferences.d.ts +45 -45
  87. package/lib/cjs/EntityReferences.js +91 -91
  88. package/lib/cjs/EntityReferences.js.map +1 -1
  89. package/lib/cjs/ExportGraphics.d.ts +317 -317
  90. package/lib/cjs/ExportGraphics.js +208 -208
  91. package/lib/cjs/ExportGraphics.js.map +1 -1
  92. package/lib/cjs/ExternalSource.d.ts +96 -96
  93. package/lib/cjs/ExternalSource.js +131 -131
  94. package/lib/cjs/ExternalSource.js.map +1 -1
  95. package/lib/cjs/GeoCoordConfig.d.ts +19 -19
  96. package/lib/cjs/GeoCoordConfig.js +82 -82
  97. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  98. package/lib/cjs/GeometrySummary.d.ts +4 -4
  99. package/lib/cjs/GeometrySummary.js +380 -380
  100. package/lib/cjs/GeometrySummary.js.map +1 -1
  101. package/lib/cjs/HubMock.d.ts +93 -93
  102. package/lib/cjs/HubMock.js +190 -190
  103. package/lib/cjs/HubMock.js.map +1 -1
  104. package/lib/cjs/IModelCloneContext.d.ts +89 -89
  105. package/lib/cjs/IModelCloneContext.js +159 -159
  106. package/lib/cjs/IModelCloneContext.js.map +1 -1
  107. package/lib/cjs/IModelDb.d.ts +1180 -1180
  108. package/lib/cjs/IModelDb.js +2371 -2371
  109. package/lib/cjs/IModelDb.js.map +1 -1
  110. package/lib/cjs/IModelHost.d.ts +361 -361
  111. package/lib/cjs/IModelHost.js +489 -489
  112. package/lib/cjs/IModelHost.js.map +1 -1
  113. package/lib/cjs/IModelJsFs.d.ts +62 -62
  114. package/lib/cjs/IModelJsFs.js +140 -140
  115. package/lib/cjs/IModelJsFs.js.map +1 -1
  116. package/lib/cjs/IpcHost.d.ts +98 -98
  117. package/lib/cjs/IpcHost.js +234 -234
  118. package/lib/cjs/IpcHost.js.map +1 -1
  119. package/lib/cjs/LineStyle.d.ts +311 -311
  120. package/lib/cjs/LineStyle.js +295 -295
  121. package/lib/cjs/LineStyle.js.map +1 -1
  122. package/lib/cjs/LocalHub.d.ts +162 -162
  123. package/lib/cjs/LocalHub.js +587 -587
  124. package/lib/cjs/LocalHub.js.map +1 -1
  125. package/lib/cjs/LocalhostIpcHost.d.ts +20 -20
  126. package/lib/cjs/LocalhostIpcHost.js +81 -81
  127. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  128. package/lib/cjs/Material.d.ts +103 -103
  129. package/lib/cjs/Material.js +147 -147
  130. package/lib/cjs/Material.js.map +1 -1
  131. package/lib/cjs/Model.d.ts +392 -392
  132. package/lib/cjs/Model.js +485 -485
  133. package/lib/cjs/Model.js.map +1 -1
  134. package/lib/cjs/NativeAppStorage.d.ts +51 -51
  135. package/lib/cjs/NativeAppStorage.js +202 -202
  136. package/lib/cjs/NativeAppStorage.js.map +1 -1
  137. package/lib/cjs/NativeHost.d.ts +52 -52
  138. package/lib/cjs/NativeHost.js +168 -168
  139. package/lib/cjs/NativeHost.js.map +1 -1
  140. package/lib/cjs/NavigationRelationship.d.ts +156 -156
  141. package/lib/cjs/NavigationRelationship.js +225 -225
  142. package/lib/cjs/NavigationRelationship.js.map +1 -1
  143. package/lib/cjs/PromiseMemoizer.d.ts +51 -51
  144. package/lib/cjs/PromiseMemoizer.js +101 -101
  145. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  146. package/lib/cjs/PropertyStore.d.ts +132 -132
  147. package/lib/cjs/PropertyStore.js +11 -11
  148. package/lib/cjs/PropertyStore.js.map +1 -1
  149. package/lib/cjs/Relationship.d.ts +416 -416
  150. package/lib/cjs/Relationship.js +494 -494
  151. package/lib/cjs/Relationship.js.map +1 -1
  152. package/lib/cjs/RpcBackend.d.ts +28 -28
  153. package/lib/cjs/RpcBackend.js +126 -126
  154. package/lib/cjs/RpcBackend.js.map +1 -1
  155. package/lib/cjs/SQLiteDb.d.ts +219 -219
  156. package/lib/cjs/SQLiteDb.js +214 -214
  157. package/lib/cjs/SQLiteDb.js.map +1 -1
  158. package/lib/cjs/Schema.d.ts +55 -55
  159. package/lib/cjs/Schema.js +83 -83
  160. package/lib/cjs/Schema.js.map +1 -1
  161. package/lib/cjs/ServerBasedLocks.d.ts +57 -57
  162. package/lib/cjs/ServerBasedLocks.js +168 -168
  163. package/lib/cjs/ServerBasedLocks.js.map +1 -1
  164. package/lib/cjs/SqliteStatement.d.ts +283 -283
  165. package/lib/cjs/SqliteStatement.js +448 -448
  166. package/lib/cjs/SqliteStatement.js.map +1 -1
  167. package/lib/cjs/Texture.d.ts +58 -58
  168. package/lib/cjs/Texture.js +82 -82
  169. package/lib/cjs/Texture.js.map +1 -1
  170. package/lib/cjs/TileStorage.d.ts +18 -18
  171. package/lib/cjs/TileStorage.js +90 -90
  172. package/lib/cjs/TileStorage.js.map +1 -1
  173. package/lib/cjs/TxnManager.d.ts +202 -202
  174. package/lib/cjs/TxnManager.js +356 -356
  175. package/lib/cjs/TxnManager.js.map +1 -1
  176. package/lib/cjs/ViewDefinition.d.ts +439 -439
  177. package/lib/cjs/ViewDefinition.js +646 -646
  178. package/lib/cjs/ViewDefinition.js.map +1 -1
  179. package/lib/cjs/ViewStateHydrator.d.ts +13 -13
  180. package/lib/cjs/ViewStateHydrator.js +103 -103
  181. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  182. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  183. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +67 -67
  184. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +31 -31
  185. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +52 -52
  186. package/lib/cjs/assets/Settings/backend.setting.json5 +138 -138
  187. package/lib/cjs/core-backend.d.ts +183 -183
  188. package/lib/cjs/core-backend.js +203 -203
  189. package/lib/cjs/core-backend.js.map +1 -1
  190. package/lib/cjs/domains/FunctionalElements.d.ts +101 -101
  191. package/lib/cjs/domains/FunctionalElements.js +145 -145
  192. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  193. package/lib/cjs/domains/FunctionalSchema.d.ts +13 -13
  194. package/lib/cjs/domains/FunctionalSchema.js +40 -40
  195. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  196. package/lib/cjs/domains/GenericElements.d.ts +177 -177
  197. package/lib/cjs/domains/GenericElements.js +263 -263
  198. package/lib/cjs/domains/GenericElements.js.map +1 -1
  199. package/lib/cjs/domains/GenericSchema.d.ts +10 -10
  200. package/lib/cjs/domains/GenericSchema.js +28 -28
  201. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  202. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +15 -15
  203. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +32 -32
  204. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  205. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +46 -46
  206. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +287 -287
  207. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  208. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +22 -22
  209. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +202 -202
  210. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  211. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +36 -36
  212. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +168 -168
  213. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  214. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +16 -16
  215. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +43 -43
  216. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  217. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +15 -15
  218. package/lib/cjs/rpc-impl/WipRpcImpl.js +37 -37
  219. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  220. package/lib/cjs/workspace/Settings.d.ts +186 -186
  221. package/lib/cjs/workspace/Settings.js +155 -155
  222. package/lib/cjs/workspace/Settings.js.map +1 -1
  223. package/lib/cjs/workspace/SettingsSchemas.d.ts +75 -75
  224. package/lib/cjs/workspace/SettingsSchemas.js +191 -191
  225. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  226. package/lib/cjs/workspace/Workspace.d.ts +414 -414
  227. package/lib/cjs/workspace/Workspace.js +543 -543
  228. package/lib/cjs/workspace/Workspace.js.map +1 -1
  229. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,8DAAyE;AACzE,sEAAyE;AACzE,oEAAyF;AACzF,oEAA2D;AAC3D,sDAA+I;AAC/I,oDAAiH;AACjH,0DAAyD;AACzD,yCAAsC;AACtC,yBAAyB;AACzB,6BAA6B;AAE7B,mEAAgE;AAChE,mDAAgD;AAChD,yDAAsD;AACtD,+DAAqI;AACrI,iEAA8D;AAC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AAC,CAAC;IACxC,CAAC;IAED,+BAA+B;IACxB,MAAM,KAAK,MAAM;QACtB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACF;AAdD,wCAcC;AAED;;;;GAIG;AACH,MAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAgB,IAAwB,OAAO,SAAS,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACI,UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,OAAO,eAAe,CAAC,CAAC;SACzE;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","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 IModelHost\r\n */\r\n\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\r\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\r\nimport { ServerStorage } from \"@itwin/object-storage-core\";\r\nimport { AccessToken, assert, BeEvent, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\r\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\r\nimport { Container } from \"inversify\";\r\nimport * as os from \"os\";\r\nimport * as path from \"path\";\r\nimport { BackendHubAccess } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BisCoreSchema } from \"./BisCoreSchema\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { AzureBlobStorage, AzureBlobStorageCredentials, CloudStorageService, CloudStorageTileUploader } from \"./CloudStorageBackend\";\r\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\r\nimport { GenericSchema } from \"./domains/GenericSchema\";\r\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\r\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\r\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\r\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\r\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\r\nimport { initializeRpcBackend } from \"./RpcBackend\";\r\nimport { TileStorage } from \"./TileStorage\";\r\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\r\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\r\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelHost;\r\n\r\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs\r\n\r\n/** @alpha */\r\nexport interface CrashReportingConfigNameValuePair {\r\n name: string;\r\n value: string;\r\n}\r\n\r\n/** Configuration of the crash-reporting system.\r\n * @alpha\r\n */\r\nexport interface CrashReportingConfig {\r\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\r\n crashDir: string;\r\n /** max # .dmp files that may exist in crashDir. The default is 50. */\r\n maxDumpsInDir?: number;\r\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\r\n enableCrashDumps?: boolean;\r\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\r\n wantFullMemoryDumps?: boolean;\r\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\r\n enableNodeReport?: boolean;\r\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\r\n params?: CrashReportingConfigNameValuePair[];\r\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\r\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\r\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\r\n * Since it runs in a separate process, this script will have no access to the Javascript\r\n * context of the exiting backend. No default.\r\n */\r\n dumpProcessorScriptFileName?: string;\r\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\r\n uploadToBentley?: boolean;\r\n}\r\n\r\n/**\r\n * Options for [[IModelHost.startup]]\r\n * @public\r\n */\r\nexport interface IModelHostOptions {\r\n /**\r\n * Root of the directory holding all the files that iTwin.js caches\r\n * - If not specified at startup a platform specific default is used -\r\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\r\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\r\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\r\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\r\n * - if specified, ensure it is set to a folder with read/write access.\r\n * - Sub-folders within this folder organize various caches -\r\n * - bc/ -> Briefcases\r\n * - appSettings/ -> Offline application settings (only relevant in native applications)\r\n * - etc.\r\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\r\n */\r\n cacheDir?: LocalDirName;\r\n\r\n /** The directory where application assets are found. */\r\n appAssetsDir?: LocalDirName;\r\n\r\n /**\r\n * Options for creating the [[Workspace]]\r\n * @beta\r\n */\r\n workspace?: WorkspaceOpts;\r\n\r\n /**\r\n * The kind of iModel hub server to use.\r\n * @beta\r\n */\r\n hubAccess?: BackendHubAccess;\r\n\r\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\r\n * @beta\r\n */\r\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n\r\n /**\r\n * @beta\r\n * @deprecated use tileCacheStorage\r\n */\r\n tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /**\r\n * @beta\r\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\r\n * set this property with a custom ServerStorage.\r\n */\r\n tileCacheStorage?: ServerStorage;\r\n\r\n /** Whether to restrict tile cache URLs by client IP address (if available).\r\n * @beta\r\n */\r\n restrictTileUrlsByClientIp?: boolean;\r\n\r\n /**\r\n * Whether to enable OpenTelemetry tracing\r\n * @beta\r\n */\r\n enableOpenTelemetry?: boolean;\r\n\r\n /** Whether to compress cached tiles.\r\n * Defaults to `true`.\r\n */\r\n compressCachedTiles?: boolean;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileTreeRequestTimeout?: number;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileContentRequestTimeout?: number;\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds.\r\n * @internal\r\n */\r\n logTileLoadTimeThreshold?: number;\r\n\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\r\n * @internal\r\n */\r\n logTileSizeThreshold?: number;\r\n\r\n /** Crash-reporting configuration\r\n * @alpha\r\n */\r\n crashReportingConfig?: CrashReportingConfig;\r\n\r\n /** The AuthorizationClient used to get accessTokens\r\n * @beta\r\n */\r\n authorizationClient?: AuthorizationClient;\r\n}\r\n\r\n/** Configuration of core-backend.\r\n * @public\r\n */\r\nexport class IModelHostConfiguration implements IModelHostOptions {\r\n public static defaultTileRequestTimeout = 20 * 1000;\r\n public static defaultLogTileLoadTimeThreshold = 40;\r\n public static defaultLogTileSizeThreshold = 20 * 1000000;\r\n\r\n public appAssetsDir?: LocalDirName;\r\n public cacheDir?: LocalDirName;\r\n\r\n /** @beta */\r\n public workspace?: WorkspaceOpts;\r\n /** @beta */\r\n public hubAccess?: BackendHubAccess;\r\n /** @beta */\r\n public authorizationClient?: AuthorizationClient;\r\n /** @beta @deprecated */\r\n public tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n /** @beta */\r\n public restrictTileUrlsByClientIp?: boolean;\r\n public compressCachedTiles?: boolean;\r\n /** @beta */\r\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n /** @internal */\r\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n /** @internal */\r\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n /** @alpha */\r\n public crashReportingConfig?: CrashReportingConfig;\r\n}\r\n\r\n/**\r\n * Settings for `IModelHost.appWorkspace`.\r\n * @note this includes the default dictionary from the SettingsSpecRegistry\r\n */\r\nclass ApplicationSettings extends BaseSettings {\r\n private _remove?: VoidFunction;\r\n protected override verifyPriority(priority: SettingsPriority) {\r\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\r\n throw new Error(\"Use IModelSettings\");\r\n }\r\n private updateDefaults() {\r\n const defaults: SettingDictionary = {};\r\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\r\n if (val.default)\r\n defaults[schemaName] = val.default;\r\n }\r\n this.addDictionary(\"_default_\", 0, defaults);\r\n }\r\n\r\n public constructor() {\r\n super();\r\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\r\n this.updateDefaults();\r\n }\r\n\r\n public override close() {\r\n if (this._remove) {\r\n this._remove();\r\n this._remove = undefined;\r\n }\r\n }\r\n}\r\n\r\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\r\n * See [the learning article]($docs/learning/backend/IModelHost.md)\r\n * @public\r\n */\r\nexport class IModelHost {\r\n private constructor() { }\r\n public static authorizationClient?: AuthorizationClient;\r\n\r\n /** @alpha */\r\n public static readonly telemetry = new TelemetryManager();\r\n\r\n public static backendVersion = \"\";\r\n private static _cacheDir = \"\";\r\n private static _appWorkspace?: Workspace;\r\n\r\n private static _platform?: typeof IModelJsNative;\r\n /** @internal */\r\n public static get platform(): typeof IModelJsNative {\r\n if (this._platform === undefined)\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n return this._platform;\r\n }\r\n\r\n public static configuration?: IModelHostOptions;\r\n\r\n /** Event raised during startup to allow loading settings data */\r\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just after the backend IModelHost was started */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just before the backend IModelHost is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\r\n\r\n /** A uniqueId for this session */\r\n public static get sessionId() { return this.session.sessionId; }\r\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\r\n\r\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\r\n public static get applicationId() { return this.session.applicationId; }\r\n public static set applicationId(id: string) { this.session.applicationId = id; }\r\n\r\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\r\n public static get applicationVersion() { return this.session.applicationVersion; }\r\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\r\n\r\n /** Root directory holding files that iTwin.js caches */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** The application [[Workspace]] for this `IModelHost`\r\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\r\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\r\n * attempting to add them to this Workspace will fail.\r\n * @beta\r\n */\r\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\r\n public static snapshotFileNameResolver?: FileNameResolver;\r\n\r\n /** Get the current access token for this IModelHost, or a blank string if none is available.\r\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\r\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\r\n * obtains the token and forwards it to the frontend.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static flushLog() {\r\n return this.platform.flushLog();\r\n }\r\n /** @internal */\r\n public static loadNative(): void {\r\n const platform = Platform.load();\r\n this.registerPlatform(platform);\r\n }\r\n\r\n private static registerPlatform(platform: typeof IModelJsNative): void {\r\n this._platform = platform;\r\n if (undefined === platform)\r\n return;\r\n\r\n platform.logger = Logger;\r\n }\r\n\r\n /**\r\n * @internal\r\n * @deprecated\r\n * @note Use [[IModelHostOptions.tileCacheService]] to set the service provider.\r\n */\r\n public static tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\r\n\r\n /** @internal */\r\n public static tileStorage?: TileStorage;\r\n\r\n /**\r\n * @internal\r\n * @deprecated\r\n */\r\n public static tileUploader?: CloudStorageTileUploader; // eslint-disable-line deprecation/deprecation\r\n\r\n private static _hubAccess?: BackendHubAccess;\r\n /** @internal */\r\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\r\n\r\n /** get the current hubAccess, if present.\r\n * @beta\r\n */\r\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\r\n\r\n /** Provides access to the IModelHub for this IModelHost\r\n * @beta\r\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\r\n * To determine whether one is present, use [[getHubAccess]].\r\n */\r\n public static get hubAccess(): BackendHubAccess {\r\n if (this._hubAccess === undefined)\r\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\r\n return this._hubAccess;\r\n }\r\n\r\n private static initializeWorkspace(configuration: IModelHostOptions) {\r\n const settingAssets = path.join(KnownLocations.packageAssetsDir, \"Settings\");\r\n SettingsSchemas.addDirectory(path.join(settingAssets, \"Schemas\"));\r\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\r\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\r\n\r\n GeoCoordConfig.onStartup();\r\n // allow applications to load their default settings\r\n this.onWorkspaceStartup.raiseEvent();\r\n }\r\n\r\n private static _isValid = false;\r\n /** Returns true if IModelHost is started. */\r\n public static get isValid() { return this._isValid; }\r\n /** This method must be called before any iTwin.js services are used.\r\n * @param options Host configuration data.\r\n * Raises [[onAfterStartup]].\r\n * @see [[shutdown]].\r\n */\r\n public static async startup(options?: IModelHostOptions): Promise<void> {\r\n if (this._isValid)\r\n return; // we're already initialized\r\n this._isValid = true;\r\n\r\n options = options ?? {};\r\n if (IModelHost.sessionId === \"\")\r\n IModelHost.sessionId = Guid.createValue();\r\n\r\n this.authorizationClient = options.authorizationClient;\r\n\r\n this.logStartup();\r\n\r\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\r\n initializeRpcBackend(options.enableOpenTelemetry);\r\n\r\n if (this._platform === undefined) {\r\n try {\r\n this.loadNative();\r\n } catch (error) {\r\n Logger.logError(loggerCategory, \"Error registering/loading the native platform API\", () => (options));\r\n throw error;\r\n }\r\n }\r\n\r\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\r\n this.platform.setCrashReporting(options.crashReportingConfig);\r\n\r\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\r\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\r\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\r\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\r\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\r\n });\r\n\r\n if (options.crashReportingConfig.enableNodeReport) {\r\n if (process.report !== undefined) {\r\n process.report.reportOnFatalError = true;\r\n process.report.reportOnUncaughtException = true;\r\n process.report.directory = options.crashReportingConfig.crashDir;\r\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\r\n } else {\r\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\r\n }\r\n }\r\n }\r\n\r\n this.setupHostDirs(options);\r\n this.initializeWorkspace(options);\r\n\r\n BriefcaseManager.initialize(this._briefcaseCacheDir);\r\n\r\n [\r\n IModelReadRpcImpl,\r\n IModelTileRpcImpl,\r\n SnapshotIModelRpcImpl,\r\n WipRpcImpl,\r\n DevToolsRpcImpl,\r\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\r\n\r\n [\r\n BisCoreSchema,\r\n GenericSchema,\r\n FunctionalSchema,\r\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\r\n\r\n if (undefined !== options.hubAccess)\r\n this._hubAccess = options.hubAccess;\r\n\r\n this.configuration = options;\r\n this.setupTileCache();\r\n\r\n process.once(\"beforeExit\", IModelHost.shutdown);\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n private static _briefcaseCacheDir: LocalDirName;\r\n\r\n private static logStartup() {\r\n if (!Logger.isEnabled(loggerCategory, LogLevel.Trace))\r\n return;\r\n\r\n // Extract the iModel details from environment - note this is very specific to Bentley hosted backends, but is quite useful for tracing\r\n let startupInfo: any = {};\r\n const serviceName = process.env.FABRIC_SERVICE_NAME;\r\n if (serviceName) {\r\n // e.g., fabric:/iModelWebViewer3.0/iModelJSGuest/1/08daaeb3-b56f-480b-9051-7efc834d18ae/512d971d-b641-4735-bb1c-c07ab3e44ce7/c1315fcce125ca40b2d405bb7809214daf8b4c85\r\n const serviceNameComponents = serviceName.split(\"/\");\r\n if (serviceNameComponents.length === 7) {\r\n startupInfo = {\r\n ...startupInfo,\r\n iTwinId: serviceNameComponents[4],\r\n iModelId: serviceNameComponents[5],\r\n changesetId: serviceNameComponents[6],\r\n };\r\n }\r\n }\r\n\r\n Logger.logTrace(loggerCategory, \"IModelHost.startup\", () => startupInfo);\r\n }\r\n\r\n private static setupHostDirs(configuration: IModelHostOptions) {\r\n const setupDir = (dir: LocalDirName) => {\r\n dir = path.normalize(dir);\r\n IModelJsFs.recursiveMkDirSync(dir);\r\n return dir;\r\n };\r\n this._cacheDir = setupDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\r\n this._briefcaseCacheDir = path.join(this._cacheDir, \"imodels\");\r\n }\r\n\r\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n // NB: This method is set as a node listener where `this` is unbound\r\n if (!IModelHost._isValid)\r\n return;\r\n\r\n IModelHost._isValid = false;\r\n IModelHost.onBeforeShutdown.raiseEvent();\r\n IModelHost.configuration = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = undefined;\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = undefined;\r\n IModelHost.tileStorage = undefined;\r\n IModelHost._appWorkspace?.close();\r\n IModelHost._appWorkspace = undefined;\r\n ITwinWorkspace.finalize();\r\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\r\n }\r\n\r\n /**\r\n * Add or update a property that should be included in a crash report.\r\n * @param name The name of the property\r\n * @param value The value of the property\r\n * @alpha\r\n */\r\n public static setCrashReportProperty(name: string, value: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, value);\r\n }\r\n\r\n /**\r\n * Remove a previously defined property so that will not be included in a crash report.\r\n * @param name The name of the property\r\n * @alpha\r\n */\r\n public static removeCrashReportProperty(name: string): void {\r\n assert(undefined !== this._platform);\r\n this._platform.setCrashReportProperty(name, undefined);\r\n }\r\n\r\n /**\r\n * Get all properties that will be included in a crash report.\r\n * @alpha\r\n */\r\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\r\n assert(undefined !== this._platform);\r\n return this._platform.getCrashReportProperties();\r\n }\r\n\r\n /** The directory where application assets may be found */\r\n public static get appAssetsDir(): string | undefined { return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined; }\r\n\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileTreeRequestTimeout(): number {\r\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileContentRequestTimeout(): number {\r\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\r\n public static get logTileLoadTimeThreshold(): number { return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold; }\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\r\n public static get logTileSizeThreshold(): number { return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold; }\r\n\r\n /** Whether external tile caching is active.\r\n * @internal\r\n */\r\n public static get usingExternalTileCache(): boolean {\r\n return undefined !== IModelHost.tileStorage;\r\n }\r\n\r\n /** Whether to restrict tile cache URLs by client IP address.\r\n * @internal\r\n */\r\n public static get restrictTileUrlsByClientIp(): boolean { return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false); }\r\n\r\n /** Whether to compress cached tiles.\r\n * @internal\r\n */\r\n public static get compressCachedTiles(): boolean { return false !== IModelHost.configuration?.compressCachedTiles; }\r\n\r\n private static setupTileCache() {\r\n assert(undefined !== IModelHost.configuration);\r\n const config = IModelHost.configuration;\r\n // eslint-disable-next-line deprecation/deprecation\r\n const service = config.tileCacheService;\r\n const storage = config.tileCacheStorage;\r\n const credentials = config.tileCacheAzureCredentials;\r\n\r\n if (!service && !storage && !credentials) {\r\n this.platform.setUseTileCache(true);\r\n return;\r\n }\r\n this.platform.setUseTileCache(false);\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileUploader = new CloudStorageTileUploader();\r\n if (credentials) {\r\n if (storage || service)\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\r\n this.setupAzureTileCache(credentials);\r\n }\r\n if (service) {\r\n if (!storage)\r\n Logger.logWarning(loggerCategory, \"Using tileCacheService without tileCacheStorage is unsupported\");\r\n IModelHost.tileCacheService = service; // eslint-disable-line deprecation/deprecation\r\n }\r\n if (storage)\r\n IModelHost.tileStorage = new TileStorage(storage);\r\n }\r\n\r\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\r\n const config = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ServerSideStorage: {\r\n dependencyName: \"azure\",\r\n accountName: credentials.account,\r\n accountKey: credentials.accessKey,\r\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\r\n },\r\n };\r\n const ioc: Container = new Container();\r\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\r\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\r\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\r\n // eslint-disable-next-line deprecation/deprecation\r\n IModelHost.tileCacheService = new AzureBlobStorage(credentials); // needed for backwards compatibility with old frontends\r\n }\r\n\r\n /** @internal */\r\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\r\n return this.platform.computeSchemaChecksum(arg);\r\n }\r\n}\r\n\r\n/** Information about the platform on which the app is running. Also see [[KnownLocations]] and [[IModelJsFs]].\r\n * @public\r\n */\r\nexport class Platform {\r\n /** Get the name of the platform. */\r\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\r\n return process.platform as any;\r\n }\r\n\r\n /** @internal */\r\n public static load(): typeof IModelJsNative {\r\n return ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") : NativeLibrary.load();\r\n }\r\n}\r\n\r\n/** Well known directories that may be used by the application. Also see [[Platform]]\r\n * @public\r\n */\r\nexport class KnownLocations {\r\n\r\n /** The directory where the imodeljs-native assets are stored. */\r\n public static get nativeAssetsDir(): string { return IModelHost.platform.DgnDb.getAssetsDir(); }\r\n\r\n /** The directory where the core-backend assets are stored. */\r\n public static get packageAssetsDir(): string {\r\n return path.join(__dirname, \"assets\");\r\n }\r\n\r\n /** The temporary directory. */\r\n public static get tmpdir(): string {\r\n return os.tmpdir();\r\n }\r\n}\r\n\r\n/** Extend this class to provide custom file name resolution behavior.\r\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\r\n * @see [[IModelHost.snapshotFileNameResolver]]\r\n * @public\r\n */\r\nexport abstract class FileNameResolver {\r\n /** Resolve a file name from the specified key.\r\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name or `undefined` if not found.\r\n */\r\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\r\n /** Resolve a file name from the specified key.\r\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveKey(fileKey: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name or `undefined` if not found.\r\n */\r\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveFileName(inFileName: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;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C;AAED;;GAEG;AACH,MAAa,cAAc;IAEzB,iEAAiE;IAC1D,MAAM,KAAK,eAAe,KAAa,OAAO,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;IAEhG,8DAA8D;IACvD,MAAM,KAAK,gBAAgB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,+BAA+B;IACxB,MAAM,KAAK,MAAM;QACtB,OAAO,EAAE,CAAC,MAAM,EAAE,CAAC;IACrB,CAAC;CACF;AAdD,wCAcC;AAED;;;;GAIG;AACH,MAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAgB,IAAwB,OAAO,SAAS,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACI,UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,OAAO,eAAe,CAAC,CAAC;SACzE;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModelHost\n */\n\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\nimport { ServerStorage } from \"@itwin/object-storage-core\";\nimport { AccessToken, assert, BeEvent, Guid, GuidString, IModelStatus, Logger, LogLevel, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\nimport { TelemetryManager } from \"@itwin/core-telemetry\";\nimport { Container } from \"inversify\";\nimport * as os from \"os\";\nimport * as path from \"path\";\nimport { BackendHubAccess } from \"./BackendHubAccess\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { BisCoreSchema } from \"./BisCoreSchema\";\nimport { BriefcaseManager } from \"./BriefcaseManager\";\nimport { AzureBlobStorage, AzureBlobStorageCredentials, CloudStorageService, CloudStorageTileUploader } from \"./CloudStorageBackend\";\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\nimport { GenericSchema } from \"./domains/GenericSchema\";\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\nimport { IModelJsFs } from \"./IModelJsFs\";\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\nimport { initializeRpcBackend } from \"./RpcBackend\";\nimport { TileStorage } from \"./TileStorage\";\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\n\nconst loggerCategory = BackendLoggerCategory.IModelHost;\n\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs\n\n/** @alpha */\nexport interface CrashReportingConfigNameValuePair {\n name: string;\n value: string;\n}\n\n/** Configuration of the crash-reporting system.\n * @alpha\n */\nexport interface CrashReportingConfig {\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\n crashDir: string;\n /** max # .dmp files that may exist in crashDir. The default is 50. */\n maxDumpsInDir?: number;\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\n enableCrashDumps?: boolean;\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\n wantFullMemoryDumps?: boolean;\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\n enableNodeReport?: boolean;\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\n params?: CrashReportingConfigNameValuePair[];\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\n * Since it runs in a separate process, this script will have no access to the Javascript\n * context of the exiting backend. No default.\n */\n dumpProcessorScriptFileName?: string;\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\n uploadToBentley?: boolean;\n}\n\n/**\n * Options for [[IModelHost.startup]]\n * @public\n */\nexport interface IModelHostOptions {\n /**\n * Root of the directory holding all the files that iTwin.js caches\n * - If not specified at startup a platform specific default is used -\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\n * - if specified, ensure it is set to a folder with read/write access.\n * - Sub-folders within this folder organize various caches -\n * - bc/ -> Briefcases\n * - appSettings/ -> Offline application settings (only relevant in native applications)\n * - etc.\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\n */\n cacheDir?: LocalDirName;\n\n /** The directory where application assets are found. */\n appAssetsDir?: LocalDirName;\n\n /**\n * Options for creating the [[Workspace]]\n * @beta\n */\n workspace?: WorkspaceOpts;\n\n /**\n * The kind of iModel hub server to use.\n * @beta\n */\n hubAccess?: BackendHubAccess;\n\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\n * @beta\n */\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n\n /**\n * @beta\n * @deprecated use tileCacheStorage\n */\n tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\n\n /**\n * @beta\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\n * set this property with a custom ServerStorage.\n */\n tileCacheStorage?: ServerStorage;\n\n /** Whether to restrict tile cache URLs by client IP address (if available).\n * @beta\n */\n restrictTileUrlsByClientIp?: boolean;\n\n /**\n * Whether to enable OpenTelemetry tracing\n * @beta\n */\n enableOpenTelemetry?: boolean;\n\n /** Whether to compress cached tiles.\n * Defaults to `true`.\n */\n compressCachedTiles?: boolean;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileTreeRequestTimeout?: number;\n\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\n * @internal\n */\n tileContentRequestTimeout?: number;\n\n /** The backend will log when a tile took longer to load than this threshold in seconds.\n * @internal\n */\n logTileLoadTimeThreshold?: number;\n\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\n * @internal\n */\n logTileSizeThreshold?: number;\n\n /** Crash-reporting configuration\n * @alpha\n */\n crashReportingConfig?: CrashReportingConfig;\n\n /** The AuthorizationClient used to get accessTokens\n * @beta\n */\n authorizationClient?: AuthorizationClient;\n}\n\n/** Configuration of core-backend.\n * @public\n */\nexport class IModelHostConfiguration implements IModelHostOptions {\n public static defaultTileRequestTimeout = 20 * 1000;\n public static defaultLogTileLoadTimeThreshold = 40;\n public static defaultLogTileSizeThreshold = 20 * 1000000;\n\n public appAssetsDir?: LocalDirName;\n public cacheDir?: LocalDirName;\n\n /** @beta */\n public workspace?: WorkspaceOpts;\n /** @beta */\n public hubAccess?: BackendHubAccess;\n /** @beta */\n public authorizationClient?: AuthorizationClient;\n /** @beta @deprecated */\n public tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\n /** @beta */\n public restrictTileUrlsByClientIp?: boolean;\n public compressCachedTiles?: boolean;\n /** @beta */\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\n /** @internal */\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\n /** @internal */\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\n /** @internal */\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\n /** @alpha */\n public crashReportingConfig?: CrashReportingConfig;\n}\n\n/**\n * Settings for `IModelHost.appWorkspace`.\n * @note this includes the default dictionary from the SettingsSpecRegistry\n */\nclass ApplicationSettings extends BaseSettings {\n private _remove?: VoidFunction;\n protected override verifyPriority(priority: SettingsPriority) {\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\n throw new Error(\"Use IModelSettings\");\n }\n private updateDefaults() {\n const defaults: SettingDictionary = {};\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\n if (val.default)\n defaults[schemaName] = val.default;\n }\n this.addDictionary(\"_default_\", 0, defaults);\n }\n\n public constructor() {\n super();\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\n this.updateDefaults();\n }\n\n public override close() {\n if (this._remove) {\n this._remove();\n this._remove = undefined;\n }\n }\n}\n\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\n * See [the learning article]($docs/learning/backend/IModelHost.md)\n * @public\n */\nexport class IModelHost {\n private constructor() { }\n public static authorizationClient?: AuthorizationClient;\n\n /** @alpha */\n public static readonly telemetry = new TelemetryManager();\n\n public static backendVersion = \"\";\n private static _cacheDir = \"\";\n private static _appWorkspace?: Workspace;\n\n private static _platform?: typeof IModelJsNative;\n /** @internal */\n public static get platform(): typeof IModelJsNative {\n if (this._platform === undefined)\n throw new Error(\"IModelHost.startup must be called first\");\n return this._platform;\n }\n\n public static configuration?: IModelHostOptions;\n\n /** Event raised during startup to allow loading settings data */\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\n\n /** Event raised just after the backend IModelHost was started */\n public static readonly onAfterStartup = new BeEvent<() => void>();\n\n /** Event raised just before the backend IModelHost is to be shut down */\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\n\n /** @internal */\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\n\n /** A uniqueId for this session */\n public static get sessionId() { return this.session.sessionId; }\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\n\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\n public static get applicationId() { return this.session.applicationId; }\n public static set applicationId(id: string) { this.session.applicationId = id; }\n\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\n public static get applicationVersion() { return this.session.applicationVersion; }\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\n\n /** Root directory holding files that iTwin.js caches */\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\n\n /** The application [[Workspace]] for this `IModelHost`\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\n * attempting to add them to this Workspace will fail.\n * @beta\n */\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\n public static snapshotFileNameResolver?: FileNameResolver;\n\n /** Get the current access token for this IModelHost, or a blank string if none is available.\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\n * obtains the token and forwards it to the frontend.\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\n * returned by this method may change over time throughout the course of a session.\n */\n public static async getAccessToken(): Promise<AccessToken> {\n try {\n return (await this.authorizationClient?.getAccessToken()) ?? \"\";\n } catch (e) {\n return \"\";\n }\n }\n\n /** @internal */\n public static flushLog() {\n return this.platform.flushLog();\n }\n /** @internal */\n public static loadNative(): void {\n const platform = Platform.load();\n this.registerPlatform(platform);\n }\n\n private static registerPlatform(platform: typeof IModelJsNative): void {\n this._platform = platform;\n if (undefined === platform)\n return;\n\n platform.logger = Logger;\n }\n\n /**\n * @internal\n * @deprecated\n * @note Use [[IModelHostOptions.tileCacheService]] to set the service provider.\n */\n public static tileCacheService?: CloudStorageService; // eslint-disable-line deprecation/deprecation\n\n /** @internal */\n public static tileStorage?: TileStorage;\n\n /**\n * @internal\n * @deprecated\n */\n public static tileUploader?: CloudStorageTileUploader; // eslint-disable-line deprecation/deprecation\n\n private static _hubAccess?: BackendHubAccess;\n /** @internal */\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\n\n /** get the current hubAccess, if present.\n * @beta\n */\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\n\n /** Provides access to the IModelHub for this IModelHost\n * @beta\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\n * To determine whether one is present, use [[getHubAccess]].\n */\n public static get hubAccess(): BackendHubAccess {\n if (this._hubAccess === undefined)\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\n return this._hubAccess;\n }\n\n private static initializeWorkspace(configuration: IModelHostOptions) {\n const settingAssets = path.join(KnownLocations.packageAssetsDir, \"Settings\");\n SettingsSchemas.addDirectory(path.join(settingAssets, \"Schemas\"));\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\n\n GeoCoordConfig.onStartup();\n // allow applications to load their default settings\n this.onWorkspaceStartup.raiseEvent();\n }\n\n private static _isValid = false;\n /** Returns true if IModelHost is started. */\n public static get isValid() { return this._isValid; }\n /** This method must be called before any iTwin.js services are used.\n * @param options Host configuration data.\n * Raises [[onAfterStartup]].\n * @see [[shutdown]].\n */\n public static async startup(options?: IModelHostOptions): Promise<void> {\n if (this._isValid)\n return; // we're already initialized\n this._isValid = true;\n\n options = options ?? {};\n if (IModelHost.sessionId === \"\")\n IModelHost.sessionId = Guid.createValue();\n\n this.authorizationClient = options.authorizationClient;\n\n this.logStartup();\n\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\n initializeRpcBackend(options.enableOpenTelemetry);\n\n if (this._platform === undefined) {\n try {\n this.loadNative();\n } catch (error) {\n Logger.logError(loggerCategory, \"Error registering/loading the native platform API\", () => (options));\n throw error;\n }\n }\n\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\n this.platform.setCrashReporting(options.crashReportingConfig);\n\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\n });\n\n if (options.crashReportingConfig.enableNodeReport) {\n if (process.report !== undefined) {\n process.report.reportOnFatalError = true;\n process.report.reportOnUncaughtException = true;\n process.report.directory = options.crashReportingConfig.crashDir;\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\n } else {\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\n }\n }\n }\n\n this.setupHostDirs(options);\n this.initializeWorkspace(options);\n\n BriefcaseManager.initialize(this._briefcaseCacheDir);\n\n [\n IModelReadRpcImpl,\n IModelTileRpcImpl,\n SnapshotIModelRpcImpl,\n WipRpcImpl,\n DevToolsRpcImpl,\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\n\n [\n BisCoreSchema,\n GenericSchema,\n FunctionalSchema,\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\n\n if (undefined !== options.hubAccess)\n this._hubAccess = options.hubAccess;\n\n this.configuration = options;\n this.setupTileCache();\n\n process.once(\"beforeExit\", IModelHost.shutdown);\n this.onAfterStartup.raiseEvent();\n }\n\n private static _briefcaseCacheDir: LocalDirName;\n\n private static logStartup() {\n if (!Logger.isEnabled(loggerCategory, LogLevel.Trace))\n return;\n\n // Extract the iModel details from environment - note this is very specific to Bentley hosted backends, but is quite useful for tracing\n let startupInfo: any = {};\n const serviceName = process.env.FABRIC_SERVICE_NAME;\n if (serviceName) {\n // e.g., fabric:/iModelWebViewer3.0/iModelJSGuest/1/08daaeb3-b56f-480b-9051-7efc834d18ae/512d971d-b641-4735-bb1c-c07ab3e44ce7/c1315fcce125ca40b2d405bb7809214daf8b4c85\n const serviceNameComponents = serviceName.split(\"/\");\n if (serviceNameComponents.length === 7) {\n startupInfo = {\n ...startupInfo,\n iTwinId: serviceNameComponents[4],\n iModelId: serviceNameComponents[5],\n changesetId: serviceNameComponents[6],\n };\n }\n }\n\n Logger.logTrace(loggerCategory, \"IModelHost.startup\", () => startupInfo);\n }\n\n private static setupHostDirs(configuration: IModelHostOptions) {\n const setupDir = (dir: LocalDirName) => {\n dir = path.normalize(dir);\n IModelJsFs.recursiveMkDirSync(dir);\n return dir;\n };\n this._cacheDir = setupDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\n this._briefcaseCacheDir = path.join(this._cacheDir, \"imodels\");\n }\n\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\n public static async shutdown(): Promise<void> {\n // NB: This method is set as a node listener where `this` is unbound\n if (!IModelHost._isValid)\n return;\n\n IModelHost._isValid = false;\n IModelHost.onBeforeShutdown.raiseEvent();\n IModelHost.configuration = undefined;\n // eslint-disable-next-line deprecation/deprecation\n IModelHost.tileCacheService = undefined;\n // eslint-disable-next-line deprecation/deprecation\n IModelHost.tileUploader = undefined;\n IModelHost.tileStorage = undefined;\n IModelHost._appWorkspace?.close();\n IModelHost._appWorkspace = undefined;\n ITwinWorkspace.finalize();\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\n }\n\n /**\n * Add or update a property that should be included in a crash report.\n * @param name The name of the property\n * @param value The value of the property\n * @alpha\n */\n public static setCrashReportProperty(name: string, value: string): void {\n assert(undefined !== this._platform);\n this._platform.setCrashReportProperty(name, value);\n }\n\n /**\n * Remove a previously defined property so that will not be included in a crash report.\n * @param name The name of the property\n * @alpha\n */\n public static removeCrashReportProperty(name: string): void {\n assert(undefined !== this._platform);\n this._platform.setCrashReportProperty(name, undefined);\n }\n\n /**\n * Get all properties that will be included in a crash report.\n * @alpha\n */\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\n assert(undefined !== this._platform);\n return this._platform.getCrashReportProperties();\n }\n\n /** The directory where application assets may be found */\n public static get appAssetsDir(): string | undefined { return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined; }\n\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileTreeRequestTimeout(): number {\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\n * @internal\n */\n public static get tileContentRequestTimeout(): number {\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\n }\n\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\n public static get logTileLoadTimeThreshold(): number { return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold; }\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\n public static get logTileSizeThreshold(): number { return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold; }\n\n /** Whether external tile caching is active.\n * @internal\n */\n public static get usingExternalTileCache(): boolean {\n return undefined !== IModelHost.tileStorage;\n }\n\n /** Whether to restrict tile cache URLs by client IP address.\n * @internal\n */\n public static get restrictTileUrlsByClientIp(): boolean { return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false); }\n\n /** Whether to compress cached tiles.\n * @internal\n */\n public static get compressCachedTiles(): boolean { return false !== IModelHost.configuration?.compressCachedTiles; }\n\n private static setupTileCache() {\n assert(undefined !== IModelHost.configuration);\n const config = IModelHost.configuration;\n // eslint-disable-next-line deprecation/deprecation\n const service = config.tileCacheService;\n const storage = config.tileCacheStorage;\n const credentials = config.tileCacheAzureCredentials;\n\n if (!service && !storage && !credentials) {\n this.platform.setUseTileCache(true);\n return;\n }\n this.platform.setUseTileCache(false);\n // eslint-disable-next-line deprecation/deprecation\n IModelHost.tileUploader = new CloudStorageTileUploader();\n if (credentials) {\n if (storage || service)\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\n this.setupAzureTileCache(credentials);\n }\n if (service) {\n if (!storage)\n Logger.logWarning(loggerCategory, \"Using tileCacheService without tileCacheStorage is unsupported\");\n IModelHost.tileCacheService = service; // eslint-disable-line deprecation/deprecation\n }\n if (storage)\n IModelHost.tileStorage = new TileStorage(storage);\n }\n\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\n const config = {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n ServerSideStorage: {\n dependencyName: \"azure\",\n accountName: credentials.account,\n accountKey: credentials.accessKey,\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\n },\n };\n const ioc: Container = new Container();\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\n // eslint-disable-next-line deprecation/deprecation\n IModelHost.tileCacheService = new AzureBlobStorage(credentials); // needed for backwards compatibility with old frontends\n }\n\n /** @internal */\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\n return this.platform.computeSchemaChecksum(arg);\n }\n}\n\n/** Information about the platform on which the app is running. Also see [[KnownLocations]] and [[IModelJsFs]].\n * @public\n */\nexport class Platform {\n /** Get the name of the platform. */\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\n return process.platform as any;\n }\n\n /** @internal */\n public static load(): typeof IModelJsNative {\n return ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") : NativeLibrary.load();\n }\n}\n\n/** Well known directories that may be used by the application. Also see [[Platform]]\n * @public\n */\nexport class KnownLocations {\n\n /** The directory where the imodeljs-native assets are stored. */\n public static get nativeAssetsDir(): string { return IModelHost.platform.DgnDb.getAssetsDir(); }\n\n /** The directory where the core-backend assets are stored. */\n public static get packageAssetsDir(): string {\n return path.join(__dirname, \"assets\");\n }\n\n /** The temporary directory. */\n public static get tmpdir(): string {\n return os.tmpdir();\n }\n}\n\n/** Extend this class to provide custom file name resolution behavior.\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\n * @see [[IModelHost.snapshotFileNameResolver]]\n * @public\n */\nexport abstract class FileNameResolver {\n /** Resolve a file name from the specified key.\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name or `undefined` if not found.\n */\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\n /** Resolve a file name from the specified key.\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\n * @returns The resolved file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveKey(fileKey: string): string {\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\n }\n return resolvedFileName;\n }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name or `undefined` if not found.\n */\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\n /** Resolve the input file name, which may be a partial name, into a full path file name.\n * @param inFileName The partial file name.\n * @returns The resolved full path file name.\n * @throws [[IModelError]] if not found.\n */\n public resolveFileName(inFileName: string): string {\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\n if (undefined === resolvedFileName) {\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\n }\n return resolvedFileName;\n }\n}\n"]}
@@ -1,63 +1,63 @@
1
- /// <reference types="node" />
2
- /** Information about a file. See [[IModelJsFs.lstatSync]]
3
- * @public
4
- */
5
- export declare class IModelJsFsStats {
6
- size: number;
7
- atimeMs: number;
8
- mtimeMs: number;
9
- birthtimeMs: number;
10
- isDirectory: boolean;
11
- isFile: boolean;
12
- isSocket: boolean;
13
- isSymbolicLink: boolean;
14
- isReadOnly: boolean;
15
- constructor(size: number, atimeMs: number, mtimeMs: number, birthtimeMs: number, isDirectory: boolean, isFile: boolean, isSocket: boolean, isSymbolicLink: boolean, isReadOnly: boolean);
16
- }
17
- /** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]
18
- * @public
19
- */
20
- export declare class IModelJsFs {
21
- /** Does file or directory exist? */
22
- static existsSync(pathname: string): boolean;
23
- /** Delete a file. */
24
- static unlinkSync(pathname: string): void;
25
- /** Delete a file or remove a directory (rm -r). */
26
- static removeSync(pathname: string): void;
27
- /** Create a directory. */
28
- static mkdirSync(pathname: string): void;
29
- /** Remove a directory. */
30
- static rmdirSync(pathname: string): void;
31
- /** Write to a file. */
32
- static writeFileSync(pathname: string, data: string | Uint8Array, wflag?: string): void;
33
- /** Append to a file. */
34
- static appendFileSync(pathname: string, str: string): void;
35
- /** Make a copy of a file */
36
- static copySync(src: string, dest: string, opts?: any): void;
37
- /** Gets the file and directory names in the specified directory. Excludes "." and "..". Returns an empty array if the specified directory does not exist. */
38
- static readdirSync(pathname: string): string[];
39
- /** Read file */
40
- static readFileSync(pathname: string): string | Buffer;
41
- /** Test if the current user has permission to write to a file. */
42
- private static isFileWritable;
43
- /** Get information about a file. */
44
- static lstatSync(pathname: string): IModelJsFsStats | undefined;
45
- /**
46
- * Finds files recursively based on a pattern
47
- * @param rootDir Directory from where to start searching for files.
48
- * @param pattern A Regex that would be match to basename of files including extension
49
- * @returns list of file that match the pattern.
50
- */
51
- static recursiveFindSync(rootDir: string, pattern: RegExp): string[];
52
- /**
53
- * Walks a directory in breadth first fashion
54
- * @param rootDir directory from where the traversal starts
55
- * @param cb callback that would be called with full path of file or directory
56
- */
57
- static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void;
58
- /** Create a directory, recursively setting up the path as necessary */
59
- static recursiveMkDirSync(dirPath: string): void;
60
- /** Remove a directory, recursively */
61
- static purgeDirSync(dirPath: string): void;
62
- }
1
+ /// <reference types="node" />
2
+ /** Information about a file. See [[IModelJsFs.lstatSync]]
3
+ * @public
4
+ */
5
+ export declare class IModelJsFsStats {
6
+ size: number;
7
+ atimeMs: number;
8
+ mtimeMs: number;
9
+ birthtimeMs: number;
10
+ isDirectory: boolean;
11
+ isFile: boolean;
12
+ isSocket: boolean;
13
+ isSymbolicLink: boolean;
14
+ isReadOnly: boolean;
15
+ constructor(size: number, atimeMs: number, mtimeMs: number, birthtimeMs: number, isDirectory: boolean, isFile: boolean, isSocket: boolean, isSymbolicLink: boolean, isReadOnly: boolean);
16
+ }
17
+ /** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]
18
+ * @public
19
+ */
20
+ export declare class IModelJsFs {
21
+ /** Does file or directory exist? */
22
+ static existsSync(pathname: string): boolean;
23
+ /** Delete a file. */
24
+ static unlinkSync(pathname: string): void;
25
+ /** Delete a file or remove a directory (rm -r). */
26
+ static removeSync(pathname: string): void;
27
+ /** Create a directory. */
28
+ static mkdirSync(pathname: string): void;
29
+ /** Remove a directory. */
30
+ static rmdirSync(pathname: string): void;
31
+ /** Write to a file. */
32
+ static writeFileSync(pathname: string, data: string | Uint8Array, wflag?: string): void;
33
+ /** Append to a file. */
34
+ static appendFileSync(pathname: string, str: string): void;
35
+ /** Make a copy of a file */
36
+ static copySync(src: string, dest: string, opts?: any): void;
37
+ /** Gets the file and directory names in the specified directory. Excludes "." and "..". Returns an empty array if the specified directory does not exist. */
38
+ static readdirSync(pathname: string): string[];
39
+ /** Read file */
40
+ static readFileSync(pathname: string): string | Buffer;
41
+ /** Test if the current user has permission to write to a file. */
42
+ private static isFileWritable;
43
+ /** Get information about a file. */
44
+ static lstatSync(pathname: string): IModelJsFsStats | undefined;
45
+ /**
46
+ * Finds files recursively based on a pattern
47
+ * @param rootDir Directory from where to start searching for files.
48
+ * @param pattern A Regex that would be match to basename of files including extension
49
+ * @returns list of file that match the pattern.
50
+ */
51
+ static recursiveFindSync(rootDir: string, pattern: RegExp): string[];
52
+ /**
53
+ * Walks a directory in breadth first fashion
54
+ * @param rootDir directory from where the traversal starts
55
+ * @param cb callback that would be called with full path of file or directory
56
+ */
57
+ static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void;
58
+ /** Create a directory, recursively setting up the path as necessary */
59
+ static recursiveMkDirSync(dirPath: string): void;
60
+ /** Remove a directory, recursively */
61
+ static purgeDirSync(dirPath: string): void;
62
+ }
63
63
  //# sourceMappingURL=IModelJsFs.d.ts.map
@@ -1,141 +1,141 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.IModelJsFs = exports.IModelJsFsStats = void 0;
8
- /** @packageDocumentation
9
- * @module Portability
10
- */
11
- // cspell: ignore wflag
12
- const fs = require("fs-extra");
13
- const path = require("path");
14
- /* TODO: define File Mode Constants: S_IWUSR, et al. */
15
- /** Information about a file. See [[IModelJsFs.lstatSync]]
16
- * @public
17
- */
18
- class IModelJsFsStats {
19
- constructor(size, atimeMs, mtimeMs, birthtimeMs, isDirectory, isFile, isSocket, isSymbolicLink, isReadOnly) {
20
- this.size = size;
21
- this.atimeMs = atimeMs;
22
- this.mtimeMs = mtimeMs;
23
- this.birthtimeMs = birthtimeMs;
24
- this.isDirectory = isDirectory;
25
- this.isFile = isFile;
26
- this.isSocket = isSocket;
27
- this.isSymbolicLink = isSymbolicLink;
28
- this.isReadOnly = isReadOnly;
29
- }
30
- }
31
- exports.IModelJsFsStats = IModelJsFsStats;
32
- /** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]
33
- * @public
34
- */
35
- class IModelJsFs {
36
- /** Does file or directory exist? */
37
- static existsSync(pathname) { return fs.existsSync(pathname); }
38
- /** Delete a file. */
39
- static unlinkSync(pathname) { fs.unlinkSync(pathname); }
40
- /** Delete a file or remove a directory (rm -r). */
41
- static removeSync(pathname) { fs.removeSync(pathname); }
42
- /** Create a directory. */
43
- static mkdirSync(pathname) { fs.mkdirSync(pathname); }
44
- /** Remove a directory. */
45
- static rmdirSync(pathname) { fs.rmdirSync(pathname); }
46
- /** Write to a file. */
47
- static writeFileSync(pathname, data, wflag = "w") { fs.writeFileSync(pathname, data, { flag: wflag }); }
48
- /** Append to a file. */
49
- static appendFileSync(pathname, str) { fs.appendFileSync(pathname, str); }
50
- /** Make a copy of a file */
51
- static copySync(src, dest, opts) { fs.copySync(src, dest, opts); }
52
- /** Gets the file and directory names in the specified directory. Excludes "." and "..". Returns an empty array if the specified directory does not exist. */
53
- static readdirSync(pathname) { return fs.existsSync(pathname) ? fs.readdirSync(pathname) : []; }
54
- /** Read file */
55
- static readFileSync(pathname) { return fs.readFileSync(pathname); }
56
- /** Test if the current user has permission to write to a file. */
57
- static isFileWritable(pathname) {
58
- try {
59
- fs.accessSync(pathname, fs.constants.W_OK);
60
- return true;
61
- }
62
- catch (_err) {
63
- return false;
64
- }
65
- }
66
- /** Get information about a file. */
67
- static lstatSync(pathname) {
68
- const stats = fs.lstatSync(pathname);
69
- if (stats === undefined)
70
- return undefined;
71
- return new IModelJsFsStats(stats.size, stats.atime.getTime(), stats.mtime.getTime(), stats.birthtime.getTime(), stats.isDirectory(), stats.isFile(), stats.isSocket(), stats.isSymbolicLink(), !IModelJsFs.isFileWritable(pathname));
72
- }
73
- /**
74
- * Finds files recursively based on a pattern
75
- * @param rootDir Directory from where to start searching for files.
76
- * @param pattern A Regex that would be match to basename of files including extension
77
- * @returns list of file that match the pattern.
78
- */
79
- static recursiveFindSync(rootDir, pattern) {
80
- const files = [];
81
- IModelJsFs.walkDirSync(rootDir, (pathname, isDir) => {
82
- if (!isDir) {
83
- const fileName = path.basename(pathname);
84
- if (pattern.test(fileName)) {
85
- files.push(pathname);
86
- }
87
- }
88
- return true;
89
- });
90
- return files;
91
- }
92
- /**
93
- * Walks a directory in breadth first fashion
94
- * @param rootDir directory from where the traversal starts
95
- * @param cb callback that would be called with full path of file or directory
96
- */
97
- static walkDirSync(rootDir, cb) {
98
- var _a;
99
- const subDir = [];
100
- for (const childPath of IModelJsFs.readdirSync(rootDir)) {
101
- const fullPath = path.join(rootDir, childPath);
102
- const isDir = (_a = IModelJsFs.lstatSync(fullPath)) === null || _a === void 0 ? void 0 : _a.isDirectory;
103
- if (!cb(fullPath, isDir !== null && isDir !== void 0 ? isDir : false)) {
104
- return;
105
- }
106
- // Need to check if the directory still exists in case the callback has deleted it.
107
- if (isDir && IModelJsFs.existsSync(fullPath)) {
108
- subDir.push(fullPath);
109
- }
110
- }
111
- subDir.forEach((v) => {
112
- IModelJsFs.walkDirSync(v, cb);
113
- });
114
- }
115
- /** Create a directory, recursively setting up the path as necessary */
116
- static recursiveMkDirSync(dirPath) {
117
- if (IModelJsFs.existsSync(dirPath))
118
- return;
119
- const parentPath = path.dirname(dirPath);
120
- if (parentPath !== dirPath)
121
- IModelJsFs.recursiveMkDirSync(parentPath);
122
- IModelJsFs.mkdirSync(dirPath);
123
- }
124
- /** Remove a directory, recursively */
125
- static purgeDirSync(dirPath) {
126
- if (!IModelJsFs.existsSync(dirPath))
127
- return;
128
- IModelJsFs.walkDirSync(dirPath, (pathName, isDir) => {
129
- if (isDir) {
130
- IModelJsFs.purgeDirSync(pathName);
131
- IModelJsFs.removeSync(pathName);
132
- }
133
- else {
134
- IModelJsFs.unlinkSync(pathName);
135
- }
136
- return true;
137
- });
138
- }
139
- }
140
- exports.IModelJsFs = IModelJsFs;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.IModelJsFs = exports.IModelJsFsStats = void 0;
8
+ /** @packageDocumentation
9
+ * @module Portability
10
+ */
11
+ // cspell: ignore wflag
12
+ const fs = require("fs-extra");
13
+ const path = require("path");
14
+ /* TODO: define File Mode Constants: S_IWUSR, et al. */
15
+ /** Information about a file. See [[IModelJsFs.lstatSync]]
16
+ * @public
17
+ */
18
+ class IModelJsFsStats {
19
+ constructor(size, atimeMs, mtimeMs, birthtimeMs, isDirectory, isFile, isSocket, isSymbolicLink, isReadOnly) {
20
+ this.size = size;
21
+ this.atimeMs = atimeMs;
22
+ this.mtimeMs = mtimeMs;
23
+ this.birthtimeMs = birthtimeMs;
24
+ this.isDirectory = isDirectory;
25
+ this.isFile = isFile;
26
+ this.isSocket = isSocket;
27
+ this.isSymbolicLink = isSymbolicLink;
28
+ this.isReadOnly = isReadOnly;
29
+ }
30
+ }
31
+ exports.IModelJsFsStats = IModelJsFsStats;
32
+ /** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]
33
+ * @public
34
+ */
35
+ class IModelJsFs {
36
+ /** Does file or directory exist? */
37
+ static existsSync(pathname) { return fs.existsSync(pathname); }
38
+ /** Delete a file. */
39
+ static unlinkSync(pathname) { fs.unlinkSync(pathname); }
40
+ /** Delete a file or remove a directory (rm -r). */
41
+ static removeSync(pathname) { fs.removeSync(pathname); }
42
+ /** Create a directory. */
43
+ static mkdirSync(pathname) { fs.mkdirSync(pathname); }
44
+ /** Remove a directory. */
45
+ static rmdirSync(pathname) { fs.rmdirSync(pathname); }
46
+ /** Write to a file. */
47
+ static writeFileSync(pathname, data, wflag = "w") { fs.writeFileSync(pathname, data, { flag: wflag }); }
48
+ /** Append to a file. */
49
+ static appendFileSync(pathname, str) { fs.appendFileSync(pathname, str); }
50
+ /** Make a copy of a file */
51
+ static copySync(src, dest, opts) { fs.copySync(src, dest, opts); }
52
+ /** Gets the file and directory names in the specified directory. Excludes "." and "..". Returns an empty array if the specified directory does not exist. */
53
+ static readdirSync(pathname) { return fs.existsSync(pathname) ? fs.readdirSync(pathname) : []; }
54
+ /** Read file */
55
+ static readFileSync(pathname) { return fs.readFileSync(pathname); }
56
+ /** Test if the current user has permission to write to a file. */
57
+ static isFileWritable(pathname) {
58
+ try {
59
+ fs.accessSync(pathname, fs.constants.W_OK);
60
+ return true;
61
+ }
62
+ catch (_err) {
63
+ return false;
64
+ }
65
+ }
66
+ /** Get information about a file. */
67
+ static lstatSync(pathname) {
68
+ const stats = fs.lstatSync(pathname);
69
+ if (stats === undefined)
70
+ return undefined;
71
+ return new IModelJsFsStats(stats.size, stats.atime.getTime(), stats.mtime.getTime(), stats.birthtime.getTime(), stats.isDirectory(), stats.isFile(), stats.isSocket(), stats.isSymbolicLink(), !IModelJsFs.isFileWritable(pathname));
72
+ }
73
+ /**
74
+ * Finds files recursively based on a pattern
75
+ * @param rootDir Directory from where to start searching for files.
76
+ * @param pattern A Regex that would be match to basename of files including extension
77
+ * @returns list of file that match the pattern.
78
+ */
79
+ static recursiveFindSync(rootDir, pattern) {
80
+ const files = [];
81
+ IModelJsFs.walkDirSync(rootDir, (pathname, isDir) => {
82
+ if (!isDir) {
83
+ const fileName = path.basename(pathname);
84
+ if (pattern.test(fileName)) {
85
+ files.push(pathname);
86
+ }
87
+ }
88
+ return true;
89
+ });
90
+ return files;
91
+ }
92
+ /**
93
+ * Walks a directory in breadth first fashion
94
+ * @param rootDir directory from where the traversal starts
95
+ * @param cb callback that would be called with full path of file or directory
96
+ */
97
+ static walkDirSync(rootDir, cb) {
98
+ var _a;
99
+ const subDir = [];
100
+ for (const childPath of IModelJsFs.readdirSync(rootDir)) {
101
+ const fullPath = path.join(rootDir, childPath);
102
+ const isDir = (_a = IModelJsFs.lstatSync(fullPath)) === null || _a === void 0 ? void 0 : _a.isDirectory;
103
+ if (!cb(fullPath, isDir !== null && isDir !== void 0 ? isDir : false)) {
104
+ return;
105
+ }
106
+ // Need to check if the directory still exists in case the callback has deleted it.
107
+ if (isDir && IModelJsFs.existsSync(fullPath)) {
108
+ subDir.push(fullPath);
109
+ }
110
+ }
111
+ subDir.forEach((v) => {
112
+ IModelJsFs.walkDirSync(v, cb);
113
+ });
114
+ }
115
+ /** Create a directory, recursively setting up the path as necessary */
116
+ static recursiveMkDirSync(dirPath) {
117
+ if (IModelJsFs.existsSync(dirPath))
118
+ return;
119
+ const parentPath = path.dirname(dirPath);
120
+ if (parentPath !== dirPath)
121
+ IModelJsFs.recursiveMkDirSync(parentPath);
122
+ IModelJsFs.mkdirSync(dirPath);
123
+ }
124
+ /** Remove a directory, recursively */
125
+ static purgeDirSync(dirPath) {
126
+ if (!IModelJsFs.existsSync(dirPath))
127
+ return;
128
+ IModelJsFs.walkDirSync(dirPath, (pathName, isDir) => {
129
+ if (isDir) {
130
+ IModelJsFs.purgeDirSync(pathName);
131
+ IModelJsFs.removeSync(pathName);
132
+ }
133
+ else {
134
+ IModelJsFs.unlinkSync(pathName);
135
+ }
136
+ return true;
137
+ });
138
+ }
139
+ }
140
+ exports.IModelJsFs = IModelJsFs;
141
141
  //# sourceMappingURL=IModelJsFs.js.map