@itwin/core-backend 4.8.0-dev.3 → 4.8.0-dev.31

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 (284) hide show
  1. package/CHANGELOG.md +57 -1
  2. package/lib/cjs/BackendHubAccess.d.ts +18 -16
  3. package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
  4. package/lib/cjs/BackendHubAccess.js +16 -15
  5. package/lib/cjs/BackendHubAccess.js.map +1 -1
  6. package/lib/cjs/BackendLoggerCategory.d.ts +3 -1
  7. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -1
  8. package/lib/cjs/BackendLoggerCategory.js +2 -0
  9. package/lib/cjs/BackendLoggerCategory.js.map +1 -1
  10. package/lib/cjs/BisCoreSchema.js.map +1 -1
  11. package/lib/cjs/BlobContainerService.d.ts +3 -3
  12. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  13. package/lib/cjs/BlobContainerService.js.map +1 -1
  14. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  15. package/lib/cjs/BriefcaseManager.js +19 -11
  16. package/lib/cjs/BriefcaseManager.js.map +1 -1
  17. package/lib/cjs/Category.d.ts +0 -6
  18. package/lib/cjs/Category.d.ts.map +1 -1
  19. package/lib/cjs/Category.js +0 -6
  20. package/lib/cjs/Category.js.map +1 -1
  21. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  22. package/lib/cjs/ChangeSummaryManager.js +13 -11
  23. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  24. package/lib/cjs/ChangedElementsDb.d.ts +1 -0
  25. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
  26. package/lib/cjs/ChangedElementsDb.js +6 -4
  27. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  28. package/lib/cjs/ChangedElementsManager.js.map +1 -1
  29. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  30. package/lib/cjs/ChangesetECAdaptor.js +242 -237
  31. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  32. package/lib/cjs/ChannelControl.d.ts +4 -26
  33. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  34. package/lib/cjs/ChannelControl.js +2 -101
  35. package/lib/cjs/ChannelControl.js.map +1 -1
  36. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  37. package/lib/cjs/CheckpointManager.js +5 -3
  38. package/lib/cjs/CheckpointManager.js.map +1 -1
  39. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  40. package/lib/cjs/ClassRegistry.js +8 -7
  41. package/lib/cjs/ClassRegistry.js.map +1 -1
  42. package/lib/cjs/CloudSqlite.d.ts +49 -24
  43. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  44. package/lib/cjs/CloudSqlite.js +66 -7
  45. package/lib/cjs/CloudSqlite.js.map +1 -1
  46. package/lib/cjs/CodeService.d.ts +4 -4
  47. package/lib/cjs/CodeService.d.ts.map +1 -1
  48. package/lib/cjs/CodeService.js.map +1 -1
  49. package/lib/cjs/CodeSpecs.js.map +1 -1
  50. package/lib/cjs/ConcurrentQuery.js.map +1 -1
  51. package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
  52. package/lib/cjs/DevTools.d.ts.map +1 -1
  53. package/lib/cjs/DevTools.js +2 -1
  54. package/lib/cjs/DevTools.js.map +1 -1
  55. package/lib/cjs/DisplayStyle.d.ts +0 -3
  56. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  57. package/lib/cjs/DisplayStyle.js +0 -3
  58. package/lib/cjs/DisplayStyle.js.map +1 -1
  59. package/lib/cjs/ECDb.d.ts +6 -1
  60. package/lib/cjs/ECDb.d.ts.map +1 -1
  61. package/lib/cjs/ECDb.js +19 -14
  62. package/lib/cjs/ECDb.js.map +1 -1
  63. package/lib/cjs/ECSchemaXmlContext.js +2 -2
  64. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  65. package/lib/cjs/ECSqlStatement.d.ts +6 -3
  66. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  67. package/lib/cjs/ECSqlStatement.js +3 -3
  68. package/lib/cjs/ECSqlStatement.js.map +1 -1
  69. package/lib/cjs/Element.d.ts +3 -60
  70. package/lib/cjs/Element.d.ts.map +1 -1
  71. package/lib/cjs/Element.js +8 -64
  72. package/lib/cjs/Element.js.map +1 -1
  73. package/lib/cjs/ElementAspect.d.ts +0 -5
  74. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  75. package/lib/cjs/ElementAspect.js +4 -8
  76. package/lib/cjs/ElementAspect.js.map +1 -1
  77. package/lib/cjs/ElementGraphics.d.ts.map +1 -1
  78. package/lib/cjs/ElementGraphics.js +2 -1
  79. package/lib/cjs/ElementGraphics.js.map +1 -1
  80. package/lib/cjs/ElementTreeWalker.js.map +1 -1
  81. package/lib/cjs/Entity.js.map +1 -1
  82. package/lib/cjs/EntityReferences.js.map +1 -1
  83. package/lib/cjs/ExportGraphics.js.map +1 -1
  84. package/lib/cjs/ExternalSource.js.map +1 -1
  85. package/lib/cjs/GeoCoordConfig.d.ts +10 -0
  86. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  87. package/lib/cjs/GeoCoordConfig.js +22 -24
  88. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  89. package/lib/cjs/GeographicCRSServices.js +2 -2
  90. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  91. package/lib/cjs/GeometrySummary.d.ts.map +1 -1
  92. package/lib/cjs/GeometrySummary.js +49 -48
  93. package/lib/cjs/GeometrySummary.js.map +1 -1
  94. package/lib/cjs/HubMock.js.map +1 -1
  95. package/lib/cjs/IModelCloneContext.js.map +1 -1
  96. package/lib/cjs/IModelDb.d.ts +33 -98
  97. package/lib/cjs/IModelDb.d.ts.map +1 -1
  98. package/lib/cjs/IModelDb.js +250 -164
  99. package/lib/cjs/IModelDb.js.map +1 -1
  100. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  101. package/lib/cjs/IModelElementCloneContext.js +5 -4
  102. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  103. package/lib/cjs/IModelHost.d.ts +13 -4
  104. package/lib/cjs/IModelHost.d.ts.map +1 -1
  105. package/lib/cjs/IModelHost.js +39 -32
  106. package/lib/cjs/IModelHost.js.map +1 -1
  107. package/lib/cjs/IModelJsFs.js.map +1 -1
  108. package/lib/cjs/IpcHost.d.ts.map +1 -1
  109. package/lib/cjs/IpcHost.js +15 -13
  110. package/lib/cjs/IpcHost.js.map +1 -1
  111. package/lib/cjs/LineStyle.js.map +1 -1
  112. package/lib/cjs/LocalHub.d.ts +2 -2
  113. package/lib/cjs/LocalHub.d.ts.map +1 -1
  114. package/lib/cjs/LocalHub.js +18 -18
  115. package/lib/cjs/LocalHub.js.map +1 -1
  116. package/lib/cjs/LocalhostIpcHost.js.map +1 -1
  117. package/lib/cjs/LockControl.d.ts +73 -0
  118. package/lib/cjs/LockControl.d.ts.map +1 -0
  119. package/lib/cjs/LockControl.js +11 -0
  120. package/lib/cjs/LockControl.js.map +1 -0
  121. package/lib/cjs/Material.d.ts +2 -5
  122. package/lib/cjs/Material.d.ts.map +1 -1
  123. package/lib/cjs/Material.js +6 -4
  124. package/lib/cjs/Material.js.map +1 -1
  125. package/lib/cjs/Model.d.ts +0 -22
  126. package/lib/cjs/Model.d.ts.map +1 -1
  127. package/lib/cjs/Model.js +5 -26
  128. package/lib/cjs/Model.js.map +1 -1
  129. package/lib/cjs/NativeAppStorage.js.map +1 -1
  130. package/lib/cjs/NativeHost.js.map +1 -1
  131. package/lib/cjs/NavigationRelationship.js.map +1 -1
  132. package/lib/cjs/PromiseMemoizer.js.map +1 -1
  133. package/lib/cjs/PropertyStore.d.ts +17 -7
  134. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  135. package/lib/cjs/PropertyStore.js +11 -5
  136. package/lib/cjs/PropertyStore.js.map +1 -1
  137. package/lib/cjs/Relationship.d.ts +0 -12
  138. package/lib/cjs/Relationship.d.ts.map +1 -1
  139. package/lib/cjs/Relationship.js +5 -16
  140. package/lib/cjs/Relationship.js.map +1 -1
  141. package/lib/cjs/RpcBackend.js.map +1 -1
  142. package/lib/cjs/SQLiteDb.d.ts +8 -4
  143. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  144. package/lib/cjs/SQLiteDb.js +25 -19
  145. package/lib/cjs/SQLiteDb.js.map +1 -1
  146. package/lib/cjs/Schema.js.map +1 -1
  147. package/lib/cjs/SchemaSync.d.ts +4 -1
  148. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  149. package/lib/cjs/SchemaSync.js +24 -11
  150. package/lib/cjs/SchemaSync.js.map +1 -1
  151. package/lib/cjs/SchemaUtils.js +3 -3
  152. package/lib/cjs/SchemaUtils.js.map +1 -1
  153. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  154. package/lib/cjs/SqliteChangesetReader.js +2 -2
  155. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  156. package/lib/cjs/SqliteStatement.js +2 -2
  157. package/lib/cjs/SqliteStatement.js.map +1 -1
  158. package/lib/cjs/TextAnnotationElement.js.map +1 -1
  159. package/lib/cjs/TextAnnotationGeometry.d.ts +5 -1
  160. package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
  161. package/lib/cjs/TextAnnotationGeometry.js +11 -8
  162. package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
  163. package/lib/cjs/TextAnnotationLayout.d.ts +21 -13
  164. package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
  165. package/lib/cjs/TextAnnotationLayout.js +134 -92
  166. package/lib/cjs/TextAnnotationLayout.js.map +1 -1
  167. package/lib/cjs/Texture.js.map +1 -1
  168. package/lib/cjs/TileStorage.js.map +1 -1
  169. package/lib/cjs/TxnManager.d.ts +2 -1
  170. package/lib/cjs/TxnManager.d.ts.map +1 -1
  171. package/lib/cjs/TxnManager.js +4 -2
  172. package/lib/cjs/TxnManager.js.map +1 -1
  173. package/lib/cjs/ViewDefinition.d.ts +1 -18
  174. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  175. package/lib/cjs/ViewDefinition.js +1 -18
  176. package/lib/cjs/ViewDefinition.js.map +1 -1
  177. package/lib/cjs/ViewStateHydrator.js.map +1 -1
  178. package/lib/cjs/ViewStore.d.ts +16 -2
  179. package/lib/cjs/ViewStore.d.ts.map +1 -1
  180. package/lib/cjs/ViewStore.js +20 -6
  181. package/lib/cjs/ViewStore.js.map +1 -1
  182. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
  183. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +33 -0
  184. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -31
  185. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -52
  186. package/lib/cjs/assets/Settings/backend.setting.json5 +21 -132
  187. package/lib/cjs/core-backend.d.ts +4 -2
  188. package/lib/cjs/core-backend.d.ts.map +1 -1
  189. package/lib/cjs/core-backend.js +5 -6
  190. package/lib/cjs/core-backend.js.map +1 -1
  191. package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
  192. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  193. package/lib/cjs/domains/FunctionalElements.js +0 -10
  194. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  195. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  196. package/lib/cjs/domains/FunctionalSchema.js +2 -1
  197. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  198. package/lib/cjs/domains/GenericElements.d.ts +0 -18
  199. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  200. package/lib/cjs/domains/GenericElements.js +0 -18
  201. package/lib/cjs/domains/GenericElements.js.map +1 -1
  202. package/lib/cjs/domains/GenericSchema.js.map +1 -1
  203. package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
  204. package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
  205. package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
  206. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
  207. package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
  208. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
  209. package/lib/cjs/internal/ChannelAdmin.js +117 -0
  210. package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
  211. package/lib/cjs/internal/NativePlatform.d.ts +15 -0
  212. package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
  213. package/lib/cjs/internal/NativePlatform.js +49 -0
  214. package/lib/cjs/internal/NativePlatform.js.map +1 -0
  215. package/lib/cjs/internal/NoLocks.d.ts +6 -0
  216. package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
  217. package/lib/cjs/internal/NoLocks.js +31 -0
  218. package/lib/cjs/internal/NoLocks.js.map +1 -0
  219. package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
  220. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
  221. package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
  222. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
  223. package/lib/cjs/internal/Symbols.d.ts +11 -0
  224. package/lib/cjs/internal/Symbols.d.ts.map +1 -0
  225. package/lib/cjs/internal/Symbols.js +21 -0
  226. package/lib/cjs/internal/Symbols.js.map +1 -0
  227. package/lib/cjs/internal/cross-package.d.ts +4 -0
  228. package/lib/cjs/internal/cross-package.d.ts.map +1 -0
  229. package/lib/cjs/internal/cross-package.js +16 -0
  230. package/lib/cjs/internal/cross-package.js.map +1 -0
  231. package/lib/cjs/internal/workspace/SettingsImpl.d.ts +43 -0
  232. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -0
  233. package/lib/cjs/internal/workspace/SettingsImpl.js +161 -0
  234. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -0
  235. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts +6 -0
  236. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -0
  237. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +276 -0
  238. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -0
  239. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +41 -0
  240. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -0
  241. package/lib/cjs/internal/workspace/WorkspaceImpl.js +696 -0
  242. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -0
  243. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts +10 -0
  244. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -0
  245. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +42 -0
  246. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -0
  247. package/lib/cjs/rpc/multipart.js.map +1 -1
  248. package/lib/cjs/rpc/tracing.d.ts.map +1 -1
  249. package/lib/cjs/rpc/tracing.js +5 -2
  250. package/lib/cjs/rpc/tracing.js.map +1 -1
  251. package/lib/cjs/rpc/web/logging.js.map +1 -1
  252. package/lib/cjs/rpc/web/request.js.map +1 -1
  253. package/lib/cjs/rpc/web/response.js.map +1 -1
  254. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
  255. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
  256. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  257. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +10 -6
  258. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  259. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  260. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
  261. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  262. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
  263. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
  264. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
  265. package/lib/cjs/workspace/Settings.d.ts +167 -138
  266. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  267. package/lib/cjs/workspace/Settings.js +68 -138
  268. package/lib/cjs/workspace/Settings.js.map +1 -1
  269. package/lib/cjs/workspace/SettingsSchemas.d.ts +112 -48
  270. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  271. package/lib/cjs/workspace/SettingsSchemas.js +1 -172
  272. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  273. package/lib/cjs/workspace/Workspace.d.ts +411 -277
  274. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  275. package/lib/cjs/workspace/Workspace.js +76 -457
  276. package/lib/cjs/workspace/Workspace.js.map +1 -1
  277. package/lib/cjs/workspace/WorkspaceEditor.d.ts +245 -0
  278. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -0
  279. package/lib/cjs/workspace/WorkspaceEditor.js +34 -0
  280. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -0
  281. package/package.json +15 -14
  282. package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
  283. package/lib/cjs/ServerBasedLocks.js.map +0 -1
  284. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +0 -45
@@ -3,185 +3,214 @@
3
3
  */
4
4
  import { BeEvent, JSONSchemaType } from "@itwin/core-bentley";
5
5
  import { LocalDirName, LocalFileName } from "@itwin/core-common";
6
- /** The type of a Setting, according to its schema
6
+ import { WorkspaceDb } from "./Workspace";
7
+ import { _implementationProhibited } from "../internal/Symbols";
8
+ /** The value of a single named parameter within a [[Workspace.settings]] that configures some aspect of the applications run-time behavior.
9
+ * Settings are stored in a [[SettingsDictionary]]. A setting is described by its [[SettingSchema]].
7
10
  * @beta
8
11
  */
9
- export type SettingType = JSONSchemaType;
12
+ export type Setting = JSONSchemaType;
13
+ /** @beta */
14
+ export declare namespace Setting {
15
+ /** Create a deep copy of a [[Setting]]. */
16
+ function clone<T extends Setting>(setting: T): T;
17
+ /** Returns true if `a` and `b` are considered equivalent [[Setting]] values.
18
+ * Settings of primitive types like `number` and `string` are compared using `===`.
19
+ * Settings of type "object" are compared by comparing each property using `areEqual`; the objects are considered
20
+ * equal if they have the exact same set of property names with equivalent values.
21
+ * Settings of type "array" are compared by comparing each element of the arrays use `areEqual`; the arrays are considered
22
+ * equal if they have the same number of elements with equivalent values in the same exact order.
23
+ */
24
+ function areEqual(a: Setting | undefined, b: Setting | undefined): boolean;
25
+ }
10
26
  /**
11
- * The name of a Setting. SettingNames must be valid JavaScript property names, defined in a [[SettingSchema]].
12
- * @see [SettingName]($docs/learning/backend/Workspace#settingnames)
27
+ * The name of a [[Setting]].
28
+ * Setting names must be [valid JavaScript property names](https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript) containing no spaces or periods.
29
+ * The name of a setting begins with the schema prefix of the [[SettingGroupSchema]] in which its [[SettingSchema]] is defined.
30
+ * A setting name therefore forms a path like file names in a file system.
31
+ * For example, the following are setting names defined in the `energyAnalysis`, `iot-scan-visualization`, and `vibration-map` schemas.
32
+ *
33
+ * ```ts
34
+ * "energyAnalysis/formats/totalWork"
35
+ * "energyAnalysis/formats/totalHours"
36
+ * "energyAnalysis/units/power"
37
+ * "energyAnalysis/units/temperature"
38
+ * "energyAnalysis/startupMode"
39
+ * "iot-scan-visualization/ports/cameras"
40
+ * "vibration-map/filters/scope"
41
+ * "vibration-map/filters/prefabricated"
42
+ * ```
43
+ *
13
44
  * @beta
14
45
  */
15
46
  export type SettingName = string;
16
- /** The name of a [[SettingDictionary]]. `SettingDictionary`s are stored in [[Settings]] and may be removed by DictionaryName.
17
- * DictionaryNames must be valid JavaScript property names.
47
+ /** An object that defines the values for any number of [[Setting]]s. Each of its properties' names must conform to the semantics of a [[SettingName]].
18
48
  * @beta
19
49
  */
20
- export type DictionaryName = string;
21
- /**
22
- * A function called by [[Settings.resolveSetting]] for every SettingDictionary with a Setting that matches a name. The
23
- * SettingDictionaries are sorted by priority and this function is called in priority order with the highest priority first.
24
- * When this function returns a non-undefined value, the iteration is stopped and that value is returned. In this way,
25
- * applications can "combine" the prioritized Setting values as appropriate. The default implementation of this function
26
- * used by [[Settings.getSetting]] merely returns a clone of the value the first time it is called, so the highest priority
27
- * value is returned.
50
+ export interface SettingsContainer {
51
+ /** Accesses settings by their names. */
52
+ [name: SettingName]: Setting | undefined;
53
+ }
54
+ /** Defines the precedence of a [[SettingsDictionary]].
55
+ * [[Settings]] may contain multiple dictionaries containing different values for the same [[SettingName]].
56
+ * When resolving the value of a [[Setting]], the value from the highest-priority dictionary is used.
57
+ * Priorities are grouped into coarse categories like [[SettingsPriority.application]] and [[SettingsPriority.iModel]].
58
+ * Settings with priorities less than or equal to [[SettingsPriority.application]] are stored in [[IModelHost.appWorkspace]], while
59
+ * those with priorities higher than [[SettingsPriority.application]] are stored inside [[IModelDb.workspace]].
28
60
  * @beta
29
61
  */
30
- export type SettingResolver<T> = (val: T, dict: DictionaryName, priority: SettingsPriority) => T | undefined;
31
- /** An entry in the array returned by [[Settings.inspectSetting]]
62
+ export type SettingsPriority = number;
63
+ /** @beta */
64
+ export declare namespace SettingsPriority {
65
+ /** Settings that originate from default setting files loaded automatically at the start of a session. */
66
+ const defaults = 100;
67
+ /** Settings supplied by an application at runtime. */
68
+ const application = 200;
69
+ /** Settings that apply to all iTwins for an organization. */
70
+ const organization = 300;
71
+ /** Settings that apply to all iModels in an iTwin. */
72
+ const iTwin = 400;
73
+ /** Settings that apply to all branches of an iModel. */
74
+ const branch = 500;
75
+ /** Settings that apply to a specific iModel. */
76
+ const iModel = 600;
77
+ }
78
+ /** A named container that supplies values for [[Setting]]s.
79
+ * @see [[Settings.addDictionary]] to register a new settings dictionary.
32
80
  * @beta
33
- *
34
81
  */
35
- export interface SettingInspector<T> {
36
- value: T;
37
- dictionary: DictionaryName;
38
- priority: number;
82
+ export interface SettingsDictionary {
83
+ /** @internal */
84
+ [_implementationProhibited]: unknown;
85
+ /** Metadata describing the dictionary. */
86
+ readonly props: SettingsDictionaryProps;
87
+ /** Obtain a copy of the value of the setting named `settingName` stored in this dictionary, or `undefined` if no such setting exists.
88
+ * The returned value is always cloned using [[Setting.clone]].
89
+ * @note Generally, applications use methods like [[Settings.getString]] and [[Setting.getArray]] to resolve a setting value from multiple
90
+ * dictionaries. Those methods - unlike this one - also validate that `settingName` is of type `T` as defined by its [[SettingSchema]].
91
+ */
92
+ getSetting<T extends Setting>(settingName: SettingName): T | undefined;
39
93
  }
40
- /** An object with string-named members (as opposed to an array object).
94
+ /** Uniquely identifies a [[SettingsDictionary]].
41
95
  * @beta
42
96
  */
43
- export interface SettingObject {
44
- [name: string]: SettingType;
97
+ export interface SettingsDictionarySource {
98
+ /** The name of the dictionary, which must be unique within its [[workspaceDb]], or - if [[workspaceDb]] is undefined - unique among all dictionaries not associated with any [[WorkspaceDb]]. */
99
+ readonly name: string;
100
+ /** The [[WorkspaceDb]] from which the dictionary originated. */
101
+ readonly workspaceDb?: WorkspaceDb;
45
102
  }
46
- /**
47
- * An object with Settings as its members. A SettingDictionary also has a name and generally comes from a parsed JSON file, but
48
- * may also be created in memory by applications
103
+ /** Properties of a [[SettingsDictionary]], defining its name, the [[WorkspaceDb]] (if any) from which it originated, and its [[priority]] relative to other dictionaries.
49
104
  * @beta
50
105
  */
51
- export type SettingDictionary = SettingObject;
52
- /**
53
- * Values for SettingsPriority determine the sort order for Settings. Higher values take precedence over lower values.
54
- * @beta
55
- */
56
- export declare enum SettingsPriority {
57
- /** values supplied default-settings files */
58
- defaults = 100,
59
- /** values supplied by applications at runtime */
60
- application = 200,
61
- /** values that apply to all iTwins for an organization. */
62
- organization = 300,
63
- /** values that apply to all iModels in an iTwin. */
64
- iTwin = 400,
65
- /** values that apply to a single iModel. */
66
- iModel = 500
106
+ export interface SettingsDictionaryProps extends SettingsDictionarySource {
107
+ /** Precedence value determining which setting value to use when multiple dictionaries supply values for the same [[SettingName]]. */
108
+ readonly priority: SettingsPriority;
67
109
  }
68
- /** The current set of Settings for a Workspace.
110
+ /**
111
+ * The collection of [[Setting]]s that supply the run-time configuration of a [[Workspace]].
112
+ * The `Settings` object comprises a collection of named [[SettingsDictionary]] objects.
113
+ * Methods like [[getSetting]], [[getString]], and [[getArray]] provide access to the value of an individual [[Setting]] by searching
114
+ * the [[dictionaries]] in order by their [[SettingsPriority]] to find the highest-priority setting with the requested [[SettingName]].
115
+ * Most methods that retrieve [[Setting]] values validate them against their [[SettingSchema]]s to ensure that they are of the correct type.
116
+ * A [[SettingsDictionary]] can be added or removed using [[addDictionary]] and [[dropDictionary]].
117
+ * Because [[Setting]]s can change at any time during the session, you should avoid caching their values wherever possible.
118
+ * If you must cache them (for example, to display in a user interface), you should listen for the [[onSettingsChanged]] event to be
119
+ * notified of potential changes.
120
+ *
121
+ * Settings are accessed via [[Workspace.settings]]. They are defined at the application level by [[IModelHost.appWorkspace]], but individual iModels may supply
122
+ * additional iModel-specific settings or overrides for application-level settings. When working in the context of a specific iModel, use [[IModelDb.workspace]]'s `settings`
123
+ * property. Any settings not overridden by the iModel will fall back to the settings defined in [[IModelHost.appWorkspace]].
124
+ *
125
+ * Application settings are loaded into [[IModelHost.appWorkspace]] when the session begins (i.e., when [[IModelHost.startup]] is invoked), and unloaded when it ends (in [[IModelHost.shutdown]]).
126
+ * They are read from [JSON5](https://json5.org/) files delivered with the application. The application should register any additional [[SettingsDictionary]]'s '(and their corresponding
127
+ * [[SettingGroupSchema]]s) at this time.
128
+ *
129
+ * iModel-specific settings are stored in the iModel's property table and loaded into [[IModelDb.workspace]] when the iModel is first opened.
130
+ * You can add and remove a [[SettingsDictionary]] from the property table using [[IModelDb.saveSettingDictionary]] and [[IModelDb.deleteSettingDictionary]].
131
+ *
132
+ * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.
133
+ *
134
+ * @see [[IModelHost.appWorkspace]] application-wide settings, and [[IModelDb.workspace]] for settings specific to a given iModel.
69
135
  * @beta
70
136
  */
71
137
  export interface Settings {
138
+ /** @internal */
139
+ [_implementationProhibited]: unknown;
72
140
  /** @internal */
73
141
  close(): void;
74
- /** Event raised whenever a SettingsDictionary is added or removed. */
142
+ /** The set of settings dictionaries from which [[Setting]] values are obtained, sorted by [[SettingsPriority]].
143
+ * The set can contain at most one dictionary for each unique combination of name and [[WorkspaceDb]].
144
+ * @see [[addDictionary]], [[addFile]], [[addJson]], and [[addDirectory]] to add a new dictionary.
145
+ * @see [[dropDictionary]] to remove a dictionary.
146
+ * @see [[getDictionary]] to look up a dictionary.
147
+ */
148
+ readonly dictionaries: readonly SettingsDictionary[];
149
+ /** Event raised whenever a [[SettingsDictionary]] is added or removed. */
75
150
  readonly onSettingsChanged: BeEvent<() => void>;
76
- /** Add a SettingDictionary from a local settings file. The file should be in [JSON5](https://json5.org/) format. It is read
77
- * and parsed and the fileName is used as the DictionaryName.
78
- * @param fileName the name of a local settings file of the SettingDictionary. This becomes the DictionaryName.
79
- * @param priority the SettingsPriority for the SettingDictionary
80
- * @note If the SettingDictionary was previously added, the new content overrides the old content.
151
+ /** Parses the contents of a local [JSON5](https://json5.org/) file as a [[SettingsContainer]] and invokes [[addDictionary]] to
152
+ * add a [[SettingsDictionary]] named `fileName` with the specified priority.
153
+ * @param fileName the name of a local settings file containing the dictionary.
154
+ * @param priority the priority for the dictionary.
81
155
  */
82
156
  addFile(fileName: LocalFileName, priority: SettingsPriority): void;
83
- /** Add all files in the supplied directory with the extension ".json" or ".json5"
84
- * @param dirName the name of a local settings directory
157
+ /** Invokes [[addFile]] for all files in `directory` with the extension ".json" or ".json5". */
158
+ addDirectory(directory: LocalDirName, priority: SettingsPriority): void;
159
+ /** Parses `settingsJson` as a [[SettingsContainer]] and invokes [[addDictionary]] to add a [[SettingsDictionary]] with the specified `props`.
160
+ * This is typically used when reading dictionaries out of a [[WorkspaceDb]], where they are stored as stringified JSON.
85
161
  */
86
- addDirectory(dirName: LocalDirName, priority: SettingsPriority): void;
87
- /** Add a SettingDictionary from a JSON5 stringified string. The string is parsed and the resultant object is added as a SettingDictionary.
88
- * @param dictionaryName the name of the SettingDictionary
89
- * @param priority the SettingsPriority for the SettingDictionary
90
- * @param settingsJson the JSON5 stringified string to be parsed.
91
- * @note If the SettingDictionary was previously added, the new content overrides the old content.
162
+ addJson(props: SettingsDictionaryProps, settingsJson: string): void;
163
+ /** Find a [[SettingsDictionary]] with the same name and [[WorkspaceDb]] as `source`. */
164
+ getDictionary(source: SettingsDictionarySource): SettingsDictionary | undefined;
165
+ /** Add a new [[SettingsDictionary]] with the priority, name, and [[WorkspaceDb]] specified by `props` and setting values supplied by `settings`.
166
+ * @note If a dictionary with the same name and [[WorkspaceDb]] already exists, it will be replaced.
167
+ * @see [[addFile]], [[addJson]], and [[addDirectory]] for convenient ways to add dictionaries from various sources.
92
168
  */
93
- addJson(dictionaryName: DictionaryName, priority: SettingsPriority, settingsJson: string): void;
94
- /** Add a SettingDictionary object.
95
- * @param dictionaryName the name of the SettingDictionary
96
- * @param priority the SettingsPriority for the SettingDictionary
97
- * @param settings the SettingDictionary object to be added.
98
- * @note If the SettingDictionary was previously added, the new content overrides the old content.
99
- */
100
- addDictionary(dictionaryName: DictionaryName, priority: SettingsPriority, settings: SettingDictionary): void;
101
- /** Remove a SettingDictionary by name. */
102
- dropDictionary(dictionaryName: DictionaryName): void;
103
- /**
104
- * Resolve a setting, by name, using a SettingResolver.
105
- * @param settingName The name of the setting to resolve
106
- * @param resolver function to be called for each SettingDictionary with a matching Setting. Iteration stops when it returns a non-undefined value.
107
- * @param defaultValue value returned if settingName is not present in any SettingDictionary or resolver never returned a value.
108
- * @returns the resolved setting value.
109
- */
110
- resolveSetting<T extends SettingType>(settingName: SettingName, resolver: SettingResolver<T>, defaultValue: T): T;
111
- resolveSetting<T extends SettingType>(settingName: SettingName, resolver: SettingResolver<T>, defaultValue?: T): T | undefined;
112
- /** Get the highest priority setting for a SettingName.
113
- * @param settingName The name of the setting
114
- * @param defaultValue value returned if settingName is not present in any SettingDictionary.
115
- * @note This method is generic on SettingType, but no type checking is actually performed at run time. So, if you
169
+ addDictionary(props: SettingsDictionaryProps, settings: SettingsContainer): void;
170
+ /** Removes a previously-added [[SettingsDictionary]]. */
171
+ dropDictionary(props: SettingsDictionarySource): void;
172
+ /** Looks up the highest priority setting value for a SettingName, falling back to a default value if no value for the setting is found.
173
+ * The [[dictionaries]] are searched in order by [[SettingsPriority]]; the first one that provides a value for `settingName` wins.
174
+ * @param settingName The name of the setting.
175
+ * @param defaultValue value returned if settingName is not present in any [[SettingsDictionary]].
176
+ * @note This method is generic on [[Setting]] type, but no type checking is actually performed at run time. So, if you
116
177
  * use this method to get a setting with an expected type, but its value is a different type, the return type of this method will be wrong.
117
- * You must always type check the result. Use the non-generic "get" methods (e.g. [[getString]]) if you only want the value
178
+ * You must always type check the result. Use the non-generic "get" methods like [[getString]] and [[getArray]] if you only want the value
118
179
  * if its type is correct.
180
+ * @note Unlike [[getArray]], this method does not combine arrays - it ignores [[SettingsSchema.combineArrays]].
119
181
  */
120
- getSetting<T extends SettingType>(settingName: SettingName, defaultValue?: T): T | undefined;
121
- /** Get a string setting by SettingName.
122
- * @param settingName The name of the setting
123
- * @param defaultValue value returned if settingName is not present in any SettingDictionary, or if the highest priority setting is not a string.
182
+ getSetting<T extends Setting>(settingName: SettingName, defaultValue?: T): T | undefined;
183
+ /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */
184
+ getSettingEntries<T extends Setting>(settingName: SettingName): Iterable<{
185
+ value: T;
186
+ dictionary: SettingsDictionary;
187
+ }>;
188
+ /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */
189
+ getSettingValues<T extends Setting>(settingName: SettingName): Iterable<T>;
190
+ /** Look up the value of a string [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.
191
+ * @throws Error if the setting exists but is not a string.
124
192
  */
125
193
  getString(settingName: SettingName, defaultValue: string): string;
126
194
  getString(settingName: SettingName, defaultValue?: string): string | undefined;
127
- /** Get a boolean setting by SettingName.
128
- * @param settingName The name of the setting
129
- * @param defaultValue value returned if settingName is not present in any SettingDictionary, or if the highest priority setting is not a boolean.
130
- */
195
+ /** Look up the value of a boolean [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.
196
+ * @throws Error if the setting exists but is not a boolean.
197
+ */
131
198
  getBoolean(settingName: SettingName, defaultValue: boolean): boolean;
132
199
  getBoolean(settingName: SettingName, defaultValue?: boolean): boolean | undefined;
133
- /** Get a number setting by SettingName.
134
- * @param settingName The name of the setting
135
- * @param defaultValue value returned if settingName is not present in any SettingDictionary, or if the highest priority setting is not a number.
136
- */
200
+ /** Look up the value of a numeric [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.
201
+ * @throws Error if the setting exists but is not a number.
202
+ */
137
203
  getNumber(settingName: SettingName, defaultValue: number): number;
138
204
  getNumber(settingName: SettingName): number | undefined;
139
- /** Get an object setting by SettingName.
140
- * @param settingName The name of the setting
141
- * @param defaultValue value returned if settingName is not present in any SettingDictionary, or if the highest priority setting is not an object.
142
- */
205
+ /** Look up the value of an object [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.
206
+ * @throws Error if the setting exists but is not an object.
207
+ */
143
208
  getObject<T extends object>(settingName: SettingName, defaultValue: T): T;
144
209
  getObject<T extends object>(settingName: SettingName): T | undefined;
145
- /** Get an array setting by SettingName.
146
- * @param settingName The name of the setting
147
- * @param defaultValue value returned if settingName is not present in any SettingDictionary, or if the highest priority setting is not an array.
148
- */
149
- getArray<T extends SettingType>(settingName: SettingName, defaultValue: Array<T>): Array<T>;
150
- getArray<T extends SettingType>(settingName: SettingName): Array<T> | undefined;
151
- /** Get an array of [[SettingInspector] objects, sorted in priority order, for all Settings that match a SettingName.
152
- * @note this method is mainly for debugging and diagnostics.
153
- */
154
- inspectSetting<T extends SettingType>(name: SettingName): SettingInspector<T>[];
155
- }
156
- /**
157
- * Internal implementation of Settings interface.
158
- * @internal
159
- */
160
- export declare class BaseSettings implements Settings {
161
- private _dictionaries;
162
- protected verifyPriority(_priority: SettingsPriority): void;
163
- close(): void;
164
- readonly onSettingsChanged: BeEvent<() => void>;
165
- addFile(fileName: LocalFileName, priority: SettingsPriority): void;
166
- addDirectory(dirName: LocalDirName, priority: SettingsPriority): void;
167
- addJson(dictionaryName: string, priority: SettingsPriority, settingsJson: string): void;
168
- addDictionary(dictionaryName: string, priority: SettingsPriority, settings: SettingDictionary): void;
169
- dropDictionary(dictionaryName: DictionaryName, raiseEvent?: boolean): boolean;
170
- resolveSetting<T extends SettingType>(name: SettingName, resolver: SettingResolver<T>, defaultValue?: T): T | undefined;
171
- getSetting<T extends SettingType>(name: SettingName, defaultValue?: T): T | undefined;
172
- /** for debugging. Returns an array of all values for a setting, sorted by priority.
173
- * @note values are not cloned. Do not modify objects or arrays.
210
+ /** Look up the value of an array [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.
211
+ * @throws Error if the setting exists but is not an array.
174
212
  */
175
- inspectSetting<T extends SettingType>(name: SettingName): SettingInspector<T>[];
176
- getString(name: SettingName, defaultValue: string): string;
177
- getString(name: SettingName): string | undefined;
178
- getBoolean(name: SettingName, defaultValue: boolean): boolean;
179
- getBoolean(name: SettingName): boolean | undefined;
180
- getNumber(name: SettingName, defaultValue: number): number;
181
- getNumber(name: SettingName): number | undefined;
182
- getObject<T extends object>(name: SettingName, defaultValue: T): T;
183
- getObject<T extends object>(name: SettingName): T | undefined;
184
- getArray<T extends SettingType>(name: SettingName, defaultValue: Array<T>): Array<T>;
185
- getArray<T extends SettingType>(name: SettingName): Array<T> | undefined;
213
+ getArray<T extends Setting>(settingName: SettingName, defaultValue: Array<T>): Array<T>;
214
+ getArray<T extends Setting>(settingName: SettingName): Array<T> | undefined;
186
215
  }
187
216
  //# sourceMappingURL=Settings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Settings.d.ts","sourceRoot":"","sources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,MAAM,CAAC;IAClE,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAAC;IAExD;;OAEG;IACH,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,GAAG,CAAC,CAAC;IAC1E,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,CAAC,GAAG,SAAS,CAAC;IAErE;;OAEG;IACH,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACxF,QAAQ,CAAC,CAAC,SAAS,OAAO,EAAE,WAAW,EAAE,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAC7E"}
@@ -7,150 +7,80 @@
7
7
  * @module Workspace
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.BaseSettings = exports.SettingsPriority = void 0;
11
- const fs = require("fs-extra");
12
- const json5_1 = require("json5");
13
- const path_1 = require("path");
14
- const core_bentley_1 = require("@itwin/core-bentley");
15
- const IModelJsFs_1 = require("../IModelJsFs");
16
- /**
17
- * Values for SettingsPriority determine the sort order for Settings. Higher values take precedence over lower values.
18
- * @beta
19
- */
20
- var SettingsPriority;
21
- (function (SettingsPriority) {
22
- /** values supplied default-settings files */
23
- SettingsPriority[SettingsPriority["defaults"] = 100] = "defaults";
24
- /** values supplied by applications at runtime */
25
- SettingsPriority[SettingsPriority["application"] = 200] = "application";
26
- /** values that apply to all iTwins for an organization. */
27
- SettingsPriority[SettingsPriority["organization"] = 300] = "organization";
28
- /** values that apply to all iModels in an iTwin. */
29
- SettingsPriority[SettingsPriority["iTwin"] = 400] = "iTwin";
30
- /** values that apply to a single iModel. */
31
- SettingsPriority[SettingsPriority["iModel"] = 500] = "iModel";
32
- })(SettingsPriority || (exports.SettingsPriority = SettingsPriority = {}));
33
- /** @internal */
34
- function deepClone(obj) {
35
- if (!obj || typeof obj !== "object")
36
- return obj;
37
- const result = Array.isArray(obj) ? [] : {};
38
- Object.keys(obj).forEach((key) => {
39
- const val = obj[key];
40
- if (val && typeof val === "object") {
41
- result[key] = deepClone(val);
10
+ exports.SettingsPriority = exports.Setting = void 0;
11
+ const Symbols_1 = require("../internal/Symbols");
12
+ /** @beta */
13
+ var Setting;
14
+ (function (Setting) {
15
+ /** Create a deep copy of a [[Setting]]. */
16
+ function clone(setting) {
17
+ if (!setting || typeof setting !== "object")
18
+ return setting;
19
+ const result = Array.isArray(setting) ? [] : {};
20
+ Object.keys(setting).forEach((key) => result[key] = clone(setting[key]));
21
+ return result;
22
+ }
23
+ Setting.clone = clone;
24
+ /** Returns true if `a` and `b` are considered equivalent [[Setting]] values.
25
+ * Settings of primitive types like `number` and `string` are compared using `===`.
26
+ * Settings of type "object" are compared by comparing each property using `areEqual`; the objects are considered
27
+ * equal if they have the exact same set of property names with equivalent values.
28
+ * Settings of type "array" are compared by comparing each element of the arrays use `areEqual`; the arrays are considered
29
+ * equal if they have the same number of elements with equivalent values in the same exact order.
30
+ */
31
+ function areEqual(a, b) {
32
+ if (a === b) {
33
+ return true;
42
34
  }
43
- else {
44
- result[key] = val;
35
+ // For primitive types, === suffices.
36
+ if (typeof a !== "object" || typeof b !== "object") {
37
+ return false;
45
38
  }
46
- });
47
- return result;
48
- }
49
- class SettingsDictionary {
50
- constructor(name, priority, settings) {
51
- this.name = name;
52
- this.priority = priority;
53
- this.settings = settings;
54
- }
55
- getSetting(settingName) {
56
- return this.settings[settingName];
57
- }
58
- }
59
- /**
60
- * Internal implementation of Settings interface.
61
- * @internal
62
- */
63
- class BaseSettings {
64
- constructor() {
65
- this._dictionaries = [];
66
- this.onSettingsChanged = new core_bentley_1.BeEvent();
67
- }
68
- verifyPriority(_priority) { }
69
- close() { }
70
- addFile(fileName, priority) {
71
- this.addJson(fileName, priority, fs.readFileSync(fileName, "utf-8"));
72
- }
73
- addDirectory(dirName, priority) {
74
- for (const fileName of IModelJsFs_1.IModelJsFs.readdirSync(dirName)) {
75
- const ext = (0, path_1.extname)(fileName);
76
- if (ext === ".json5" || ext === ".json")
77
- this.addFile((0, path_1.join)(dirName, fileName), priority);
78
- }
79
- }
80
- addJson(dictionaryName, priority, settingsJson) {
81
- this.addDictionary(dictionaryName, priority, (0, json5_1.parse)(settingsJson));
82
- }
83
- addDictionary(dictionaryName, priority, settings) {
84
- this.verifyPriority(priority);
85
- this.dropDictionary(dictionaryName, false); // make sure we don't have the same dictionary twice
86
- const file = new SettingsDictionary(dictionaryName, priority, settings);
87
- const doAdd = () => {
88
- for (let i = 0; i < this._dictionaries.length; ++i) {
89
- if (this._dictionaries[i].priority <= file.priority) {
90
- this._dictionaries.splice(i, 0, file);
91
- return;
92
- }
39
+ if (Array.isArray(a) || Array.isArray(b)) {
40
+ if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
41
+ return false;
93
42
  }
94
- this._dictionaries.push(file);
95
- };
96
- doAdd();
97
- this.onSettingsChanged.raiseEvent();
98
- }
99
- dropDictionary(dictionaryName, raiseEvent = true) {
100
- for (let i = 0; i < this._dictionaries.length; ++i) {
101
- if (this._dictionaries[i].name === dictionaryName) {
102
- this._dictionaries.splice(i, 1);
103
- if (raiseEvent)
104
- this.onSettingsChanged.raiseEvent();
105
- return true;
43
+ for (let i = 0; i < a.length; i++) {
44
+ if (!areEqual(a[i], b[i])) {
45
+ return false;
46
+ }
106
47
  }
48
+ return true;
107
49
  }
108
- return false;
109
- }
110
- resolveSetting(name, resolver, defaultValue) {
111
- for (const dict of this._dictionaries) {
112
- const val = dict.getSetting(name);
113
- const resolved = val && resolver(val, dict.name, dict.priority);
114
- if (undefined !== resolved) {
115
- return resolved;
50
+ const aKeys = Object.keys(a);
51
+ const bKeys = Object.keys(b);
52
+ if (aKeys.length !== bKeys.length) {
53
+ return false;
54
+ }
55
+ aKeys.sort();
56
+ bKeys.sort();
57
+ for (let i = 0; i < aKeys.length; i++) {
58
+ const key = aKeys[i];
59
+ if (key !== bKeys[i]) {
60
+ return false;
61
+ }
62
+ if (!areEqual(a[key], b[key])) {
63
+ return false;
116
64
  }
117
65
  }
118
- return defaultValue;
119
- }
120
- getSetting(name, defaultValue) {
121
- return this.resolveSetting(name, (val) => deepClone(val)) ?? defaultValue;
122
- }
123
- /** for debugging. Returns an array of all values for a setting, sorted by priority.
124
- * @note values are not cloned. Do not modify objects or arrays.
125
- */
126
- inspectSetting(name) {
127
- const all = [];
128
- this.resolveSetting(name, (value, dictionary, priority) => {
129
- all.push({ value, dictionary, priority });
130
- return undefined;
131
- });
132
- return all;
133
- }
134
- getString(name, defaultValue) {
135
- const out = this.getSetting(name);
136
- return typeof out === "string" ? out : defaultValue;
66
+ return true;
137
67
  }
138
- getBoolean(name, defaultValue) {
139
- const out = this.getSetting(name);
140
- return typeof out === "boolean" ? out : defaultValue;
141
- }
142
- getNumber(name, defaultValue) {
143
- const out = this.getSetting(name);
144
- return typeof out === "number" ? out : defaultValue;
145
- }
146
- getObject(name, defaultValue) {
147
- const out = this.getSetting(name);
148
- return typeof out === "object" ? out : defaultValue;
149
- }
150
- getArray(name, defaultValue) {
151
- const out = this.getSetting(name);
152
- return Array.isArray(out) ? out : defaultValue;
153
- }
154
- }
155
- exports.BaseSettings = BaseSettings;
68
+ Setting.areEqual = areEqual;
69
+ })(Setting || (exports.Setting = Setting = {}));
70
+ /** @beta */
71
+ var SettingsPriority;
72
+ (function (SettingsPriority) {
73
+ /** Settings that originate from default setting files loaded automatically at the start of a session. */
74
+ SettingsPriority.defaults = 100;
75
+ /** Settings supplied by an application at runtime. */
76
+ SettingsPriority.application = 200;
77
+ /** Settings that apply to all iTwins for an organization. */
78
+ SettingsPriority.organization = 300;
79
+ /** Settings that apply to all iModels in an iTwin. */
80
+ SettingsPriority.iTwin = 400;
81
+ /** Settings that apply to all branches of an iModel. */
82
+ SettingsPriority.branch = 500;
83
+ /** Settings that apply to a specific iModel. */
84
+ SettingsPriority.iModel = 600;
85
+ })(SettingsPriority || (exports.SettingsPriority = SettingsPriority = {}));
156
86
  //# sourceMappingURL=Settings.js.map