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

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 (249) 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/BlobContainerService.d.ts +3 -3
  11. package/lib/cjs/BlobContainerService.d.ts.map +1 -1
  12. package/lib/cjs/BlobContainerService.js.map +1 -1
  13. package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
  14. package/lib/cjs/BriefcaseManager.js +19 -11
  15. package/lib/cjs/BriefcaseManager.js.map +1 -1
  16. package/lib/cjs/Category.d.ts +0 -6
  17. package/lib/cjs/Category.d.ts.map +1 -1
  18. package/lib/cjs/Category.js +0 -6
  19. package/lib/cjs/Category.js.map +1 -1
  20. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
  21. package/lib/cjs/ChangeSummaryManager.js +11 -9
  22. package/lib/cjs/ChangeSummaryManager.js.map +1 -1
  23. package/lib/cjs/ChangedElementsDb.d.ts +1 -0
  24. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
  25. package/lib/cjs/ChangedElementsDb.js +6 -4
  26. package/lib/cjs/ChangedElementsDb.js.map +1 -1
  27. package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
  28. package/lib/cjs/ChangesetECAdaptor.js +26 -21
  29. package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
  30. package/lib/cjs/ChannelControl.d.ts +4 -26
  31. package/lib/cjs/ChannelControl.d.ts.map +1 -1
  32. package/lib/cjs/ChannelControl.js +2 -101
  33. package/lib/cjs/ChannelControl.js.map +1 -1
  34. package/lib/cjs/CheckpointManager.d.ts.map +1 -1
  35. package/lib/cjs/CheckpointManager.js +5 -3
  36. package/lib/cjs/CheckpointManager.js.map +1 -1
  37. package/lib/cjs/ClassRegistry.d.ts.map +1 -1
  38. package/lib/cjs/ClassRegistry.js +3 -2
  39. package/lib/cjs/ClassRegistry.js.map +1 -1
  40. package/lib/cjs/CloudSqlite.d.ts +49 -24
  41. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  42. package/lib/cjs/CloudSqlite.js +66 -7
  43. package/lib/cjs/CloudSqlite.js.map +1 -1
  44. package/lib/cjs/CodeService.d.ts +4 -4
  45. package/lib/cjs/CodeService.d.ts.map +1 -1
  46. package/lib/cjs/CodeService.js.map +1 -1
  47. package/lib/cjs/DevTools.d.ts.map +1 -1
  48. package/lib/cjs/DevTools.js +2 -1
  49. package/lib/cjs/DevTools.js.map +1 -1
  50. package/lib/cjs/DisplayStyle.d.ts +0 -3
  51. package/lib/cjs/DisplayStyle.d.ts.map +1 -1
  52. package/lib/cjs/DisplayStyle.js +0 -3
  53. package/lib/cjs/DisplayStyle.js.map +1 -1
  54. package/lib/cjs/ECDb.d.ts +6 -1
  55. package/lib/cjs/ECDb.d.ts.map +1 -1
  56. package/lib/cjs/ECDb.js +19 -14
  57. package/lib/cjs/ECDb.js.map +1 -1
  58. package/lib/cjs/ECSchemaXmlContext.js +2 -2
  59. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  60. package/lib/cjs/ECSqlStatement.d.ts +6 -3
  61. package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
  62. package/lib/cjs/ECSqlStatement.js +3 -3
  63. package/lib/cjs/ECSqlStatement.js.map +1 -1
  64. package/lib/cjs/Element.d.ts +3 -60
  65. package/lib/cjs/Element.d.ts.map +1 -1
  66. package/lib/cjs/Element.js +8 -64
  67. package/lib/cjs/Element.js.map +1 -1
  68. package/lib/cjs/ElementAspect.d.ts +0 -5
  69. package/lib/cjs/ElementAspect.d.ts.map +1 -1
  70. package/lib/cjs/ElementAspect.js +4 -8
  71. package/lib/cjs/ElementAspect.js.map +1 -1
  72. package/lib/cjs/ElementGraphics.d.ts.map +1 -1
  73. package/lib/cjs/ElementGraphics.js +2 -1
  74. package/lib/cjs/ElementGraphics.js.map +1 -1
  75. package/lib/cjs/GeoCoordConfig.d.ts +10 -0
  76. package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
  77. package/lib/cjs/GeoCoordConfig.js +22 -24
  78. package/lib/cjs/GeoCoordConfig.js.map +1 -1
  79. package/lib/cjs/GeographicCRSServices.js +2 -2
  80. package/lib/cjs/GeographicCRSServices.js.map +1 -1
  81. package/lib/cjs/GeometrySummary.d.ts.map +1 -1
  82. package/lib/cjs/GeometrySummary.js +2 -1
  83. package/lib/cjs/GeometrySummary.js.map +1 -1
  84. package/lib/cjs/IModelDb.d.ts +33 -98
  85. package/lib/cjs/IModelDb.d.ts.map +1 -1
  86. package/lib/cjs/IModelDb.js +242 -156
  87. package/lib/cjs/IModelDb.js.map +1 -1
  88. package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
  89. package/lib/cjs/IModelElementCloneContext.js +5 -4
  90. package/lib/cjs/IModelElementCloneContext.js.map +1 -1
  91. package/lib/cjs/IModelHost.d.ts +13 -4
  92. package/lib/cjs/IModelHost.d.ts.map +1 -1
  93. package/lib/cjs/IModelHost.js +39 -32
  94. package/lib/cjs/IModelHost.js.map +1 -1
  95. package/lib/cjs/IpcHost.d.ts.map +1 -1
  96. package/lib/cjs/IpcHost.js +15 -13
  97. package/lib/cjs/IpcHost.js.map +1 -1
  98. package/lib/cjs/LocalHub.d.ts +2 -2
  99. package/lib/cjs/LocalHub.d.ts.map +1 -1
  100. package/lib/cjs/LocalHub.js +17 -17
  101. package/lib/cjs/LocalHub.js.map +1 -1
  102. package/lib/cjs/LockControl.d.ts +73 -0
  103. package/lib/cjs/LockControl.d.ts.map +1 -0
  104. package/lib/cjs/LockControl.js +11 -0
  105. package/lib/cjs/LockControl.js.map +1 -0
  106. package/lib/cjs/Material.d.ts +2 -5
  107. package/lib/cjs/Material.d.ts.map +1 -1
  108. package/lib/cjs/Material.js +6 -4
  109. package/lib/cjs/Material.js.map +1 -1
  110. package/lib/cjs/Model.d.ts +0 -22
  111. package/lib/cjs/Model.d.ts.map +1 -1
  112. package/lib/cjs/Model.js +5 -26
  113. package/lib/cjs/Model.js.map +1 -1
  114. package/lib/cjs/PropertyStore.d.ts +17 -7
  115. package/lib/cjs/PropertyStore.d.ts.map +1 -1
  116. package/lib/cjs/PropertyStore.js +11 -5
  117. package/lib/cjs/PropertyStore.js.map +1 -1
  118. package/lib/cjs/Relationship.d.ts +0 -12
  119. package/lib/cjs/Relationship.d.ts.map +1 -1
  120. package/lib/cjs/Relationship.js +5 -16
  121. package/lib/cjs/Relationship.js.map +1 -1
  122. package/lib/cjs/SQLiteDb.d.ts +8 -4
  123. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  124. package/lib/cjs/SQLiteDb.js +25 -19
  125. package/lib/cjs/SQLiteDb.js.map +1 -1
  126. package/lib/cjs/SchemaSync.d.ts +4 -1
  127. package/lib/cjs/SchemaSync.d.ts.map +1 -1
  128. package/lib/cjs/SchemaSync.js +24 -11
  129. package/lib/cjs/SchemaSync.js.map +1 -1
  130. package/lib/cjs/SchemaUtils.js +3 -3
  131. package/lib/cjs/SchemaUtils.js.map +1 -1
  132. package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
  133. package/lib/cjs/SqliteChangesetReader.js +2 -2
  134. package/lib/cjs/SqliteChangesetReader.js.map +1 -1
  135. package/lib/cjs/SqliteStatement.js +2 -2
  136. package/lib/cjs/SqliteStatement.js.map +1 -1
  137. package/lib/cjs/TextAnnotationGeometry.d.ts +5 -1
  138. package/lib/cjs/TextAnnotationGeometry.d.ts.map +1 -1
  139. package/lib/cjs/TextAnnotationGeometry.js +11 -8
  140. package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
  141. package/lib/cjs/TextAnnotationLayout.d.ts +21 -13
  142. package/lib/cjs/TextAnnotationLayout.d.ts.map +1 -1
  143. package/lib/cjs/TextAnnotationLayout.js +134 -92
  144. package/lib/cjs/TextAnnotationLayout.js.map +1 -1
  145. package/lib/cjs/TxnManager.d.ts +2 -1
  146. package/lib/cjs/TxnManager.d.ts.map +1 -1
  147. package/lib/cjs/TxnManager.js +4 -2
  148. package/lib/cjs/TxnManager.js.map +1 -1
  149. package/lib/cjs/ViewDefinition.d.ts +1 -18
  150. package/lib/cjs/ViewDefinition.d.ts.map +1 -1
  151. package/lib/cjs/ViewDefinition.js +1 -18
  152. package/lib/cjs/ViewDefinition.js.map +1 -1
  153. package/lib/cjs/ViewStore.d.ts +16 -2
  154. package/lib/cjs/ViewStore.d.ts.map +1 -1
  155. package/lib/cjs/ViewStore.js +20 -6
  156. package/lib/cjs/ViewStore.js.map +1 -1
  157. package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +33 -0
  158. package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +17 -21
  159. package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +80 -38
  160. package/lib/cjs/assets/Settings/backend.setting.json5 +8 -119
  161. package/lib/cjs/core-backend.d.ts +4 -2
  162. package/lib/cjs/core-backend.d.ts.map +1 -1
  163. package/lib/cjs/core-backend.js +5 -6
  164. package/lib/cjs/core-backend.js.map +1 -1
  165. package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
  166. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
  167. package/lib/cjs/domains/FunctionalElements.js +0 -10
  168. package/lib/cjs/domains/FunctionalElements.js.map +1 -1
  169. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
  170. package/lib/cjs/domains/FunctionalSchema.js +2 -1
  171. package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
  172. package/lib/cjs/domains/GenericElements.d.ts +0 -18
  173. package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
  174. package/lib/cjs/domains/GenericElements.js +0 -18
  175. package/lib/cjs/domains/GenericElements.js.map +1 -1
  176. package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
  177. package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
  178. package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
  179. package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
  180. package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
  181. package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
  182. package/lib/cjs/internal/ChannelAdmin.js +117 -0
  183. package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
  184. package/lib/cjs/internal/NativePlatform.d.ts +15 -0
  185. package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
  186. package/lib/cjs/internal/NativePlatform.js +49 -0
  187. package/lib/cjs/internal/NativePlatform.js.map +1 -0
  188. package/lib/cjs/internal/NoLocks.d.ts +6 -0
  189. package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
  190. package/lib/cjs/internal/NoLocks.js +31 -0
  191. package/lib/cjs/internal/NoLocks.js.map +1 -0
  192. package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
  193. package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
  194. package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
  195. package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
  196. package/lib/cjs/internal/Symbols.d.ts +11 -0
  197. package/lib/cjs/internal/Symbols.d.ts.map +1 -0
  198. package/lib/cjs/internal/Symbols.js +21 -0
  199. package/lib/cjs/internal/Symbols.js.map +1 -0
  200. package/lib/cjs/internal/cross-package.d.ts +4 -0
  201. package/lib/cjs/internal/cross-package.d.ts.map +1 -0
  202. package/lib/cjs/internal/cross-package.js +16 -0
  203. package/lib/cjs/internal/cross-package.js.map +1 -0
  204. package/lib/cjs/internal/workspace/SettingsImpl.d.ts +43 -0
  205. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -0
  206. package/lib/cjs/internal/workspace/SettingsImpl.js +161 -0
  207. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -0
  208. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts +6 -0
  209. package/lib/cjs/internal/workspace/SettingsSchemasImpl.d.ts.map +1 -0
  210. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +276 -0
  211. package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -0
  212. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +41 -0
  213. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -0
  214. package/lib/cjs/internal/workspace/WorkspaceImpl.js +696 -0
  215. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -0
  216. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts +10 -0
  217. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -0
  218. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +42 -0
  219. package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -0
  220. package/lib/cjs/rpc/tracing.d.ts.map +1 -1
  221. package/lib/cjs/rpc/tracing.js +5 -2
  222. package/lib/cjs/rpc/tracing.js.map +1 -1
  223. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
  224. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
  225. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +10 -6
  226. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
  227. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
  228. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
  229. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
  230. package/lib/cjs/workspace/Settings.d.ts +167 -138
  231. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  232. package/lib/cjs/workspace/Settings.js +68 -138
  233. package/lib/cjs/workspace/Settings.js.map +1 -1
  234. package/lib/cjs/workspace/SettingsSchemas.d.ts +112 -48
  235. package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
  236. package/lib/cjs/workspace/SettingsSchemas.js +1 -172
  237. package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
  238. package/lib/cjs/workspace/Workspace.d.ts +411 -277
  239. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  240. package/lib/cjs/workspace/Workspace.js +76 -457
  241. package/lib/cjs/workspace/Workspace.js.map +1 -1
  242. package/lib/cjs/workspace/WorkspaceEditor.d.ts +245 -0
  243. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -0
  244. package/lib/cjs/workspace/WorkspaceEditor.js +34 -0
  245. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -0
  246. package/package.json +15 -14
  247. package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
  248. package/lib/cjs/ServerBasedLocks.js.map +0 -1
  249. package/lib/cjs/assets/Settings/Schemas/Cloud.Schema.json +0 -45
@@ -7,176 +7,5 @@
7
7
  * @module Workspace
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.SettingsSchemas = 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
- * The registry of available [[SettingSchemaGroup]]s.
18
- * The registry is used for editing Settings files and for finding default values for settings.
19
- * @beta
20
- */
21
- class SettingsSchemas {
22
- constructor() { } // singleton
23
- /** @internal */
24
- static validateArrayObject(val, schemaName, msg) {
25
- const schema = this.allSchemas.get(schemaName);
26
- const items = schema?.items;
27
- if (undefined === items)
28
- return val;
29
- const required = items.required;
30
- const properties = items.properties;
31
- if (undefined === required || undefined === properties)
32
- return val;
33
- for (const entry of required) {
34
- const entryType = properties[entry].type;
35
- const value = val[entry];
36
- if (entryType === "array" && Array.isArray(value))
37
- continue;
38
- if (typeof value !== entryType)
39
- throw new Error(`invalid "${schemaName}" setting entry for "${msg}": ${entry} is ${value}`);
40
- }
41
- return val;
42
- }
43
- /**
44
- * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `groupName` member that is used
45
- * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.
46
- */
47
- static addGroup(settingsGroup) {
48
- if (!Array.isArray(settingsGroup))
49
- settingsGroup = [settingsGroup];
50
- this.doAdd(settingsGroup);
51
- this.onSchemaChanged.raiseEvent();
52
- }
53
- /** Add a [[SettingSchemaGroup]] from stringified json5. */
54
- static addJson(settingSchema) {
55
- this.addGroup((0, json5_1.parse)(settingSchema));
56
- }
57
- /** Add a [[SettingSchemaGroup]] from a json5 file. */
58
- static addFile(fileName) {
59
- try {
60
- this.addJson(fs.readFileSync(fileName, "utf-8"));
61
- }
62
- catch (e) {
63
- throw new Error(`parsing SettingSchema file "${fileName}": ${e.message}"`);
64
- }
65
- }
66
- /** Add all files with a either ".json" or ".json5" extension from a supplied directory. */
67
- static addDirectory(dirName) {
68
- for (const fileName of IModelJsFs_1.IModelJsFs.readdirSync(dirName)) {
69
- const ext = (0, path_1.extname)(fileName);
70
- if (ext === ".json5" || ext === ".json")
71
- this.addFile((0, path_1.join)(dirName, fileName));
72
- }
73
- }
74
- /** Remove a previously added [[SettingSchemaGroup]] by groupName */
75
- static removeGroup(groupName) {
76
- this.doRemove(groupName);
77
- this.onSchemaChanged.raiseEvent();
78
- }
79
- static doAdd(settingsGroup) {
80
- settingsGroup.forEach((group) => {
81
- if (undefined === group.groupName)
82
- throw new Error(`settings group has no "groupName" member`);
83
- this.doRemove(group.groupName);
84
- this.validateAndAdd(group);
85
- this._allGroups.set(group.groupName, group);
86
- });
87
- }
88
- static doRemove(groupName) {
89
- const group = this._allGroups.get(groupName);
90
- if (undefined !== group?.properties) {
91
- for (const key of Object.keys(group.properties))
92
- this.allSchemas.delete(key);
93
- }
94
- this._allGroups.delete(groupName);
95
- }
96
- static validateName(name) {
97
- if (!name.trim())
98
- throw new Error(`empty property name`);
99
- if (this.allSchemas.has(name))
100
- throw new Error(`property "${name}" is already defined`);
101
- }
102
- static validateProperty(name, property) {
103
- if (!property)
104
- throw new Error(`missing required property ${name}`);
105
- if (!property.type)
106
- throw new Error(`property ${name} has no type`);
107
- switch (property.type) {
108
- case "boolean":
109
- case "integer":
110
- case "null":
111
- case "number":
112
- case "string":
113
- return;
114
- case "object":
115
- const required = property.required;
116
- const props = property.properties;
117
- if (required && props) {
118
- for (const entry of required)
119
- this.validateProperty(entry, props[entry]);
120
- }
121
- if (props) {
122
- for (const key of Object.keys(props))
123
- try {
124
- this.validateProperty(key, props[key]);
125
- }
126
- catch (e) {
127
- throw new Error(`property ${key} of ${name}: ${e.message}`);
128
- }
129
- }
130
- return;
131
- case "array":
132
- if (typeof property.items !== "object")
133
- throw new Error(`array property ${name} has no items member`);
134
- try {
135
- this.validateProperty("items", property.items);
136
- }
137
- catch (e) {
138
- throw new Error(`array property ${name}: ${e.message}`);
139
- }
140
- return;
141
- default:
142
- throw new Error(`property ${name} has illegal type "${property.type}"`);
143
- }
144
- }
145
- static validateAndAdd(group) {
146
- const properties = group.properties;
147
- if (undefined === properties)
148
- throw new Error(`group ${group.groupName} has no properties`);
149
- for (const key of Object.keys(properties)) {
150
- this.validateName(key);
151
- this.validateProperty(key, properties[key]);
152
- const property = properties[key];
153
- property.default = property.default ?? this.getDefaultValue(property.type);
154
- this.allSchemas.set(key, property);
155
- }
156
- }
157
- static getDefaultValue(type) {
158
- type = Array.isArray(type) ? type[0] : type;
159
- switch (type) {
160
- case "boolean":
161
- return false;
162
- case "integer":
163
- case "number":
164
- return 0;
165
- case "string":
166
- return "";
167
- case "array":
168
- return [];
169
- case "object":
170
- return {};
171
- default:
172
- return undefined;
173
- }
174
- }
175
- }
176
- exports.SettingsSchemas = SettingsSchemas;
177
- SettingsSchemas._allGroups = new Map();
178
- /** a map of all registered [[SettingSchema]]s */
179
- SettingsSchemas.allSchemas = new Map();
180
- /** event that signals that the values in [[allSchemas]] have changed in some way. */
181
- SettingsSchemas.onSchemaChanged = new core_bentley_1.BeEvent();
10
+ const Symbols_1 = require("../internal/Symbols");
182
11
  //# sourceMappingURL=SettingsSchemas.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsSchemas.js","sourceRoot":"","sources":["../../../src/workspace/SettingsSchemas.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAAuG;AAEvG,8CAA2C;AAgC3C;;;;GAIG;AACH,MAAa,eAAe;IAC1B,gBAAwB,CAAC,CAAC,YAAY;IAOtC,gBAAgB;IACT,MAAM,CAAC,mBAAmB,CAAI,GAAM,EAAE,UAAkB,EAAE,GAAW;QAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;QAC5B,IAAI,SAAS,KAAK,KAAK;YACrB,OAAO,GAAG,CAAC;QACb,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,UAAU;YACpD,OAAO,GAAG,CAAC;QAEb,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;YACzC,MAAM,KAAK,GAAI,GAAW,CAAC,KAAK,CAAC,CAAC;YAClC,IAAI,SAAS,KAAK,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,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AC,IAAI,CAAC;QAC5C,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO;gBACV,OAAO,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;;AAhLH,0CAiLC;AA/KyB,0BAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC3E,iDAAiD;AAC1B,0BAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;AACrE,qFAAqF;AAC9D,+BAAe,GAAG,IAAI,sBAAO,EAAc,CAAC","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 Workspace\r\n */\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport { parse } from \"json5\";\r\nimport { extname, join } from \"path\";\r\nimport { BeEvent, JSONSchema, JSONSchemaType, JSONSchemaTypeName, Mutable } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsFs } from \"../IModelJsFs\";\r\n\r\n/**\r\n * The properties of a single Setting, used by the settings editor. This interface also includes the\r\n * default value if it is not specified in any Settings file.\r\n * This interface includes all members of [JSONSchema]($bentley) with the extensions added by VSCode.\r\n * @note the `type` member is marked optional in JSONSchema but is required for Settings.\r\n * @beta\r\n */\r\nexport interface SettingSchema extends Readonly<JSONSchema> {\r\n readonly items?: SettingSchema; // must be single object, not array\r\n readonly type: JSONSchemaTypeName; // type is required for settings\r\n readonly properties?: { [name: string]: SettingSchema };\r\n\r\n /** whether the setting replaces lower priority entries with the same name or combines with them. */\r\n readonly cumulative?: true;\r\n}\r\n\r\n/**\r\n * The properties of a group of [[SettingSchema]]s for an application. Groups can be added and removed from [[SettingsSchemas]]\r\n * and are identified by their (required) `groupName` member\r\n * @beta\r\n */\r\nexport interface SettingSchemaGroup {\r\n readonly groupName: string;\r\n readonly properties: { [name: string]: SettingSchema };\r\n readonly order?: number;\r\n readonly title?: string;\r\n readonly description?: string;\r\n readonly extensionId?: string;\r\n}\r\n\r\n/**\r\n * The registry of available [[SettingSchemaGroup]]s.\r\n * The registry is used for editing Settings files and for finding default values for settings.\r\n * @beta\r\n */\r\nexport class SettingsSchemas {\r\n private constructor() { } // singleton\r\n private static readonly _allGroups = new Map<string, SettingSchemaGroup>();\r\n /** a map of all registered [[SettingSchema]]s */\r\n public static readonly allSchemas = new Map<string, SettingSchema>();\r\n /** event that signals that the values in [[allSchemas]] have changed in some way. */\r\n public static readonly onSchemaChanged = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static validateArrayObject<T>(val: T, schemaName: string, msg: string): T {\r\n const schema = this.allSchemas.get(schemaName);\r\n const items = schema?.items;\r\n if (undefined === items)\r\n return val;\r\n const required = items.required;\r\n const properties = items.properties;\r\n if (undefined === required || undefined === properties)\r\n return val;\r\n\r\n for (const entry of required) {\r\n const entryType = properties[entry].type;\r\n const value = (val as any)[entry];\r\n if (entryType === \"array\" && Array.isArray(value))\r\n continue;\r\n if (typeof value !== entryType)\r\n throw new Error(`invalid \"${schemaName}\" setting entry for \"${msg}\": ${entry} is ${value}`);\r\n }\r\n return val;\r\n }\r\n\r\n /**\r\n * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `groupName` member that is used\r\n * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.\r\n */\r\n public static addGroup(settingsGroup: SettingSchemaGroup | SettingSchemaGroup[]): void {\r\n if (!Array.isArray(settingsGroup))\r\n settingsGroup = [settingsGroup];\r\n\r\n this.doAdd(settingsGroup);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from stringified json5. */\r\n public static addJson(settingSchema: string): void {\r\n this.addGroup(parse(settingSchema));\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from a json5 file. */\r\n public static addFile(fileName: LocalFileName): void {\r\n try {\r\n this.addJson(fs.readFileSync(fileName, \"utf-8\"));\r\n } catch (e: any) {\r\n throw new Error(`parsing SettingSchema file \"${fileName}\": ${e.message}\"`);\r\n }\r\n }\r\n\r\n /** Add all files with a either \".json\" or \".json5\" extension from a supplied directory. */\r\n public static addDirectory(dirName: LocalDirName) {\r\n for (const fileName of IModelJsFs.readdirSync(dirName)) {\r\n const ext = extname(fileName);\r\n if (ext === \".json5\" || ext === \".json\")\r\n this.addFile(join(dirName, fileName));\r\n }\r\n }\r\n\r\n /** Remove a previously added [[SettingSchemaGroup]] by groupName */\r\n public static removeGroup(groupName: string): void {\r\n this.doRemove(groupName);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n private static doAdd(settingsGroup: SettingSchemaGroup[]) {\r\n settingsGroup.forEach((group) => {\r\n if (undefined === group.groupName)\r\n throw new Error(`settings group has no \"groupName\" member`);\r\n\r\n this.doRemove(group.groupName);\r\n this.validateAndAdd(group);\r\n this._allGroups.set(group.groupName, group);\r\n });\r\n }\r\n\r\n private static doRemove(groupName: string) {\r\n const group = this._allGroups.get(groupName);\r\n if (undefined !== group?.properties) {\r\n for (const key of Object.keys(group.properties))\r\n this.allSchemas.delete(key);\r\n }\r\n this._allGroups.delete(groupName);\r\n }\r\n\r\n private static validateName(name: string) {\r\n if (!name.trim())\r\n throw new Error(`empty property name`);\r\n if (this.allSchemas.has(name))\r\n throw new Error(`property \"${name}\" is already defined`);\r\n }\r\n\r\n private static validateProperty(name: string, property: SettingSchema | undefined) {\r\n if (!property)\r\n throw new Error(`missing required property ${name}`);\r\n\r\n if (!property.type)\r\n throw new Error(`property ${name} has no type`);\r\n\r\n switch (property.type) {\r\n case \"boolean\":\r\n case \"integer\":\r\n case \"null\":\r\n case \"number\":\r\n case \"string\":\r\n return;\r\n\r\n case \"object\":\r\n const required = property.required;\r\n const props = property.properties;\r\n if (required && props) {\r\n for (const entry of required)\r\n this.validateProperty(entry, props[entry]);\r\n }\r\n if (props) {\r\n for (const key of Object.keys(props))\r\n try {\r\n this.validateProperty(key, props[key]);\r\n } catch (e: any) {\r\n throw new Error(`property ${key} of ${name}: ${e.message}`);\r\n }\r\n }\r\n return;\r\n\r\n case \"array\":\r\n if (typeof property.items !== \"object\")\r\n throw new Error(`array property ${name} has no items member`);\r\n try {\r\n this.validateProperty(\"items\", property.items);\r\n } catch (e: any) {\r\n throw new Error(`array property ${name}: ${e.message}`);\r\n }\r\n return;\r\n\r\n default:\r\n throw new Error(`property ${name} has illegal type \"${property.type}\"`);\r\n }\r\n }\r\n\r\n private static validateAndAdd(group: SettingSchemaGroup) {\r\n const properties = group.properties;\r\n if (undefined === properties)\r\n throw new Error(`group ${group.groupName} has no properties`);\r\n\r\n for (const key of Object.keys(properties)) {\r\n this.validateName(key);\r\n this.validateProperty(key, properties[key]);\r\n const property: Mutable<SettingSchema> = properties[key];\r\n property.default = property.default ?? this.getDefaultValue(property.type);\r\n this.allSchemas.set(key, property);\r\n }\r\n }\r\n\r\n private static getDefaultValue(type: JSONSchemaTypeName | JSONSchemaTypeName[]): JSONSchemaType | undefined {\r\n type = Array.isArray(type) ? type[0] : type;\r\n switch (type) {\r\n case \"boolean\":\r\n return false;\r\n case \"integer\":\r\n case \"number\":\r\n return 0;\r\n case \"string\":\r\n return \"\";\r\n case \"array\":\r\n return [];\r\n case \"object\":\r\n return {};\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SettingsSchemas.js","sourceRoot":"","sources":["../../../src/workspace/SettingsSchemas.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAIH,iDAAgE","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 Workspace\r\n */\r\n\r\nimport { BeEvent, JSONSchema, JSONSchemaTypeName } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { _implementationProhibited } from \"../internal/Symbols\";\r\nimport { SettingName } from \"./Settings\";\r\n\r\n/** Metadata describing a single [[Setting]] as part of a [[SettingGroupSchema]].\r\n * Every setting has a [[type]], which can be one of the following:\r\n * - A primitive type like `string` or `number`;\r\n * - An object containing any number of named properties, each with their own types; or\r\n * - An array of elements, all of the same type.\r\n * This metadata is used to validate setting values against the schema, and to enable user interfaces by which\r\n * users can view and modify their settings.\r\n * @beta\r\n */\r\nexport interface SettingSchema extends Readonly<JSONSchema> {\r\n /** For arrays only, the metadata describing every element in the array. */\r\n readonly items?: SettingSchema;\r\n /** The name of the [[Setting]]'s data type. */\r\n readonly type: JSONSchemaTypeName;\r\n /** For objects and arrays only, the name of a [[SettingSchema]] that provides a base definition for this type.\r\n * The name is expected to refer to a type definition registered with [[SettingsSchema.typeDefs]].\r\n * Therefore, it must be the full name, including the [[SettingGroupSchema.schemaPrefix]].\r\n */\r\n readonly extends?: string;\r\n /** For objects only, the name and metadata of each of the object's properties. */\r\n readonly properties?: { [name: SettingName]: SettingSchema };\r\n /** For arrays only, specifies how [[SettingsDictionary.getArray]] resolves the value of the setting.\r\n * By default, like other types of settings, the setting uses the value of the setting from the highest-priority dictionary.\r\n * If `combineArray` is `true`, then the value of the setting is computed by combining the elements of every array from every dictionary,\r\n * ordered by priority and eliminating duplicate elements.\r\n * Two elements are considered duplicates of one another if [[Setting.areEqual]] returns `true`.\r\n */\r\n readonly combineArray?: boolean;\r\n}\r\n\r\n/** Metadata describing a group of related [[SettingSchema]]s. You can register setting schema groups via [[SettingsSchemas.addGroup]] and\r\n * remove them via [[SettingsSchemas.removeGroup]].\r\n *\r\n * All of the settings share the same [[schemaPrefix]], which must be unique amongst all other groups.\r\n * The prefix is combined with the name of each [[SettingSchema]] in the group to form the fully-qualified name used to refer\r\n * to the setting outside of the group, e.g., when accessing [[SettingsSchemas.settingDefs]] or in [[SettingSchema.extends]].\r\n * In the following example, the fully-qualified name of the setting named \"metric\" is \"format/units/metric\".\r\n *\r\n * ```json\r\n * {\r\n * \"schemaPrefix\": \"format/units\",\r\n * \"settingDefs\": {\r\n * \"metric\": { \"type\": \"boolean\" }\r\n * }\r\n * }\r\n * ```\r\n *\r\n * A group can also define [[SettingSchema]]s that, rather than describing actual [[Setting]]s, instead describe types that can be extended by [[Setting]]s via\r\n * [[SettingSchema.extends]]. A [[SettingSchema]] can refer to type definitions defined in its own group or any other group.\r\n * @beta\r\n */\r\nexport interface SettingGroupSchema {\r\n /** Uniquely identifies this group amongst all other groups.\r\n * The prefix can use forward-slashes to define logical subgroups - for example, two related groups with the prefixes \"units/metric\" and \"units/imperial\".\r\n * The user interface may parse these prefixes to display both groups under a \"units\" tab or expandable tree view node.\r\n *\r\n * @note Schema prefixes beginning with \"itwin\" are reserved for use by iTwin.js.\r\n */\r\n readonly schemaPrefix: string;\r\n /** Metadata for each [[Setting]] in this group. */\r\n readonly settingDefs?: { [name: string]: SettingSchema | undefined };\r\n /** Metadata for types that can be extended by other [[Setting]]s via [[SettingSchema.extends]]. */\r\n readonly typeDefs?: { [name: string]: SettingSchema | undefined };\r\n /** An integer used when displaying a list of schemas in a user interface, to sort schemas with a lower `order` before those with a `higher` order. */\r\n readonly order?: number;\r\n /** A description of this group suitable for displaying to a user. */\r\n readonly description: string;\r\n}\r\n\r\n/**\r\n * The registry of available [[SettingGroupSchema]]s.\r\n * The registry is used for editing Settings files and for finding default values for settings.\r\n * @beta\r\n */\r\n\r\n/** The registry of metadata describing groups of [[SettingSchema]]s available to the current session.\r\n * The schemas are used to look up the default values of [[Setting]]s, validate that their values are of the type dictated by the schema, and\r\n * query metadata like [[SettingsSchema.combineArray]] that modify their behavior.\r\n * They can also be used to drive a user interface that enables end users to edit [[Settings]].\r\n *\r\n * When [[IModelHost.startup]] is invoked at the beginning of a session, schemas delivered with the application - like those describing\r\n * [[Workspace]]s - are automatically loaded.\r\n * The application can manually register additional schemas using methods like [[addGroup]], [[addFile]], [[addDirectory]], and [[addJson]].\r\n * When [[IModelHost.shutdown]] is invoked at the end of a session, all registered schemas are unregistered.\r\n *\r\n * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.\r\n *\r\n * @see [[IModelHost.settingsSchemas]] to access the registry for the current session.\r\n * @beta\r\n */\r\nexport interface SettingsSchemas {\r\n /** @internal */\r\n readonly [_implementationProhibited]: unknown;\r\n\r\n /** The map of each individual registered [[SettingSchema]] defining a [[Setting]], accessed by its fully-qualified name (including its [[SettingGroupSchema.schemaPrefix]]). */\r\n readonly settingDefs: ReadonlyMap<SettingName, SettingSchema>;\r\n\r\n /** The map of each individual registered [[SettingSchema]] defining a type that can be extended by other [[SettingSchema]]s via [[SettingSchema.extends]],\r\n * accessed by its fully-qualified name (including its [[SettingGroupSchema.schemaPrefix]]).\r\n */\r\n readonly typeDefs: ReadonlyMap<SettingName, SettingSchema>;\r\n\r\n /** An event raised whenever schemas are added or removed. */\r\n readonly onSchemaChanged: BeEvent<() => void>;\r\n\r\n /**\r\n * Ensure that the setting value supplied is valid according to its [[SettingSchema]].\r\n * If no schema has been registered for the setting, no validation is performed.\r\n * @param value The value of the setting to validate against the schema.\r\n * @param settingName The fully-qualified setting name.\r\n * @returns `value` if `value` matches the schema corresponding to `settingName`, or if no such schema has been registered.\r\n * @throws Error if `value` is invalid according to the schema.\r\n */\r\n validateSetting<T>(value: T, settingName: SettingName): T;\r\n\r\n /** Register one or more [[SettingGroupSchema]]s.\r\n * If a group with the same [[SettingGroupSchema.prefix]] was previously registered, it will be replaced.\r\n * Each [[SettingSchema]] in the group will be added to [[settingDefs]] or [[typeDefs]].\r\n */\r\n addGroup(settingsGroup: SettingGroupSchema | SettingGroupSchema[]): void;\r\n\r\n /** Invokes [[addGroup]] for a [[SettingGroupSchema]] supplied as stringified json5. */\r\n addJson(settingSchema: string): void;\r\n\r\n /** Invokes [[addGroup]] for a json5 file containiner a [[SettingGroupSchema]]. */\r\n addFile(fileName: LocalFileName): void;\r\n\r\n /** Invokes [[addFile]] for every json and json5 file in the specified directory. */\r\n addDirectory(dirName: LocalDirName): void;\r\n\r\n /** Unregisters all [[settingDefs]] and [[typeDefs]] with the specified [[SettingGroupSchema.schemaPrefix]]. */\r\n removeGroup(schemaPrefix: string): void;\r\n}\r\n"]}