@itwin/core-backend 3.0.0-dev.100

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (245) hide show
  1. package/CHANGELOG.md +1525 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +11 -0
  4. package/lib/cjs/AliCloudStorageService.d.ts +12 -0
  5. package/lib/cjs/AliCloudStorageService.d.ts.map +1 -0
  6. package/lib/cjs/AliCloudStorageService.js +70 -0
  7. package/lib/cjs/AliCloudStorageService.js.map +1 -0
  8. package/lib/cjs/BackendHubAccess.d.ts +208 -0
  9. package/lib/cjs/BackendHubAccess.d.ts.map +1 -0
  10. package/lib/cjs/BackendHubAccess.js +42 -0
  11. package/lib/cjs/BackendHubAccess.js.map +1 -0
  12. package/lib/cjs/BackendLoggerCategory.d.ts +83 -0
  13. package/lib/cjs/BackendLoggerCategory.d.ts.map +1 -0
  14. package/lib/cjs/BackendLoggerCategory.js +91 -0
  15. package/lib/cjs/BackendLoggerCategory.js.map +1 -0
  16. package/lib/cjs/BisCoreSchema.d.ts +22 -0
  17. package/lib/cjs/BisCoreSchema.d.ts.map +1 -0
  18. package/lib/cjs/BisCoreSchema.js +61 -0
  19. package/lib/cjs/BisCoreSchema.js.map +1 -0
  20. package/lib/cjs/BriefcaseManager.d.ts +167 -0
  21. package/lib/cjs/BriefcaseManager.d.ts.map +1 -0
  22. package/lib/cjs/BriefcaseManager.js +406 -0
  23. package/lib/cjs/BriefcaseManager.js.map +1 -0
  24. package/lib/cjs/Category.d.ts +154 -0
  25. package/lib/cjs/Category.d.ts.map +1 -0
  26. package/lib/cjs/Category.js +244 -0
  27. package/lib/cjs/Category.js.map +1 -0
  28. package/lib/cjs/ChangeSummaryManager.d.ts +188 -0
  29. package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -0
  30. package/lib/cjs/ChangeSummaryManager.js +444 -0
  31. package/lib/cjs/ChangeSummaryManager.js.map +1 -0
  32. package/lib/cjs/ChangedElementsDb.d.ts +97 -0
  33. package/lib/cjs/ChangedElementsDb.d.ts.map +1 -0
  34. package/lib/cjs/ChangedElementsDb.js +166 -0
  35. package/lib/cjs/ChangedElementsDb.js.map +1 -0
  36. package/lib/cjs/ChangedElementsManager.d.ts +40 -0
  37. package/lib/cjs/ChangedElementsManager.d.ts.map +1 -0
  38. package/lib/cjs/ChangedElementsManager.js +89 -0
  39. package/lib/cjs/ChangedElementsManager.js.map +1 -0
  40. package/lib/cjs/CheckpointManager.d.ts +101 -0
  41. package/lib/cjs/CheckpointManager.d.ts.map +1 -0
  42. package/lib/cjs/CheckpointManager.js +257 -0
  43. package/lib/cjs/CheckpointManager.js.map +1 -0
  44. package/lib/cjs/ClassRegistry.d.ts +72 -0
  45. package/lib/cjs/ClassRegistry.d.ts.map +1 -0
  46. package/lib/cjs/ClassRegistry.js +154 -0
  47. package/lib/cjs/ClassRegistry.js.map +1 -0
  48. package/lib/cjs/CloudStorageBackend.d.ts +46 -0
  49. package/lib/cjs/CloudStorageBackend.d.ts.map +1 -0
  50. package/lib/cjs/CloudStorageBackend.js +157 -0
  51. package/lib/cjs/CloudStorageBackend.js.map +1 -0
  52. package/lib/cjs/CodeSpecs.d.ts +51 -0
  53. package/lib/cjs/CodeSpecs.d.ts.map +1 -0
  54. package/lib/cjs/CodeSpecs.js +113 -0
  55. package/lib/cjs/CodeSpecs.js.map +1 -0
  56. package/lib/cjs/ConcurrentQuery.d.ts +12 -0
  57. package/lib/cjs/ConcurrentQuery.d.ts.map +1 -0
  58. package/lib/cjs/ConcurrentQuery.js +24 -0
  59. package/lib/cjs/ConcurrentQuery.js.map +1 -0
  60. package/lib/cjs/DevTools.d.ts +72 -0
  61. package/lib/cjs/DevTools.d.ts.map +1 -0
  62. package/lib/cjs/DevTools.js +155 -0
  63. package/lib/cjs/DevTools.js.map +1 -0
  64. package/lib/cjs/DisplayStyle.d.ts +107 -0
  65. package/lib/cjs/DisplayStyle.d.ts.map +1 -0
  66. package/lib/cjs/DisplayStyle.js +292 -0
  67. package/lib/cjs/DisplayStyle.js.map +1 -0
  68. package/lib/cjs/ECDb.d.ts +196 -0
  69. package/lib/cjs/ECDb.d.ts.map +1 -0
  70. package/lib/cjs/ECDb.js +354 -0
  71. package/lib/cjs/ECDb.js.map +1 -0
  72. package/lib/cjs/ECSchemaXmlContext.d.ts +18 -0
  73. package/lib/cjs/ECSchemaXmlContext.d.ts.map +1 -0
  74. package/lib/cjs/ECSchemaXmlContext.js +36 -0
  75. package/lib/cjs/ECSchemaXmlContext.js.map +1 -0
  76. package/lib/cjs/ECSqlStatement.d.ts +467 -0
  77. package/lib/cjs/ECSqlStatement.d.ts.map +1 -0
  78. package/lib/cjs/ECSqlStatement.js +783 -0
  79. package/lib/cjs/ECSqlStatement.js.map +1 -0
  80. package/lib/cjs/Element.d.ts +1082 -0
  81. package/lib/cjs/Element.d.ts.map +1 -0
  82. package/lib/cjs/Element.js +1392 -0
  83. package/lib/cjs/Element.js.map +1 -0
  84. package/lib/cjs/ElementAspect.d.ts +157 -0
  85. package/lib/cjs/ElementAspect.d.ts.map +1 -0
  86. package/lib/cjs/ElementAspect.js +179 -0
  87. package/lib/cjs/ElementAspect.js.map +1 -0
  88. package/lib/cjs/ElementGraphics.d.ts +10 -0
  89. package/lib/cjs/ElementGraphics.d.ts.map +1 -0
  90. package/lib/cjs/ElementGraphics.js +42 -0
  91. package/lib/cjs/ElementGraphics.js.map +1 -0
  92. package/lib/cjs/Entity.d.ts +57 -0
  93. package/lib/cjs/Entity.d.ts.map +1 -0
  94. package/lib/cjs/Entity.js +63 -0
  95. package/lib/cjs/Entity.js.map +1 -0
  96. package/lib/cjs/ExportGraphics.d.ts +302 -0
  97. package/lib/cjs/ExportGraphics.d.ts.map +1 -0
  98. package/lib/cjs/ExportGraphics.js +206 -0
  99. package/lib/cjs/ExportGraphics.js.map +1 -0
  100. package/lib/cjs/ExternalSource.d.ts +95 -0
  101. package/lib/cjs/ExternalSource.d.ts.map +1 -0
  102. package/lib/cjs/ExternalSource.js +126 -0
  103. package/lib/cjs/ExternalSource.js.map +1 -0
  104. package/lib/cjs/GeometrySummary.d.ts +5 -0
  105. package/lib/cjs/GeometrySummary.d.ts.map +1 -0
  106. package/lib/cjs/GeometrySummary.js +378 -0
  107. package/lib/cjs/GeometrySummary.js.map +1 -0
  108. package/lib/cjs/IModelCloneContext.d.ts +74 -0
  109. package/lib/cjs/IModelCloneContext.d.ts.map +1 -0
  110. package/lib/cjs/IModelCloneContext.js +130 -0
  111. package/lib/cjs/IModelCloneContext.js.map +1 -0
  112. package/lib/cjs/IModelDb.d.ts +1107 -0
  113. package/lib/cjs/IModelDb.d.ts.map +1 -0
  114. package/lib/cjs/IModelDb.js +2161 -0
  115. package/lib/cjs/IModelDb.js.map +1 -0
  116. package/lib/cjs/IModelHost.d.ts +284 -0
  117. package/lib/cjs/IModelHost.d.ts.map +1 -0
  118. package/lib/cjs/IModelHost.js +411 -0
  119. package/lib/cjs/IModelHost.js.map +1 -0
  120. package/lib/cjs/IModelJsFs.d.ts +63 -0
  121. package/lib/cjs/IModelJsFs.d.ts.map +1 -0
  122. package/lib/cjs/IModelJsFs.js +141 -0
  123. package/lib/cjs/IModelJsFs.js.map +1 -0
  124. package/lib/cjs/IModelSchemaLoader.d.ts +26 -0
  125. package/lib/cjs/IModelSchemaLoader.d.ts.map +1 -0
  126. package/lib/cjs/IModelSchemaLoader.js +95 -0
  127. package/lib/cjs/IModelSchemaLoader.js.map +1 -0
  128. package/lib/cjs/IpcHost.d.ts +99 -0
  129. package/lib/cjs/IpcHost.d.ts.map +1 -0
  130. package/lib/cjs/IpcHost.js +234 -0
  131. package/lib/cjs/IpcHost.js.map +1 -0
  132. package/lib/cjs/LineStyle.d.ts +312 -0
  133. package/lib/cjs/LineStyle.d.ts.map +1 -0
  134. package/lib/cjs/LineStyle.js +296 -0
  135. package/lib/cjs/LineStyle.js.map +1 -0
  136. package/lib/cjs/LocalhostIpcHost.d.ts +19 -0
  137. package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -0
  138. package/lib/cjs/LocalhostIpcHost.js +52 -0
  139. package/lib/cjs/LocalhostIpcHost.js.map +1 -0
  140. package/lib/cjs/Material.d.ts +102 -0
  141. package/lib/cjs/Material.d.ts.map +1 -0
  142. package/lib/cjs/Material.js +146 -0
  143. package/lib/cjs/Material.js.map +1 -0
  144. package/lib/cjs/Model.d.ts +387 -0
  145. package/lib/cjs/Model.d.ts.map +1 -0
  146. package/lib/cjs/Model.js +469 -0
  147. package/lib/cjs/Model.js.map +1 -0
  148. package/lib/cjs/NativeAppStorage.d.ts +52 -0
  149. package/lib/cjs/NativeAppStorage.d.ts.map +1 -0
  150. package/lib/cjs/NativeAppStorage.js +203 -0
  151. package/lib/cjs/NativeAppStorage.js.map +1 -0
  152. package/lib/cjs/NativeHost.d.ts +71 -0
  153. package/lib/cjs/NativeHost.d.ts.map +1 -0
  154. package/lib/cjs/NativeHost.js +221 -0
  155. package/lib/cjs/NativeHost.js.map +1 -0
  156. package/lib/cjs/NavigationRelationship.d.ts +157 -0
  157. package/lib/cjs/NavigationRelationship.d.ts.map +1 -0
  158. package/lib/cjs/NavigationRelationship.js +226 -0
  159. package/lib/cjs/NavigationRelationship.js.map +1 -0
  160. package/lib/cjs/PromiseMemoizer.d.ts +52 -0
  161. package/lib/cjs/PromiseMemoizer.d.ts.map +1 -0
  162. package/lib/cjs/PromiseMemoizer.js +93 -0
  163. package/lib/cjs/PromiseMemoizer.js.map +1 -0
  164. package/lib/cjs/Relationship.d.ts +400 -0
  165. package/lib/cjs/Relationship.d.ts.map +1 -0
  166. package/lib/cjs/Relationship.js +460 -0
  167. package/lib/cjs/Relationship.js.map +1 -0
  168. package/lib/cjs/RpcBackend.d.ts +23 -0
  169. package/lib/cjs/RpcBackend.d.ts.map +1 -0
  170. package/lib/cjs/RpcBackend.js +94 -0
  171. package/lib/cjs/RpcBackend.js.map +1 -0
  172. package/lib/cjs/SQLiteDb.d.ts +66 -0
  173. package/lib/cjs/SQLiteDb.d.ts.map +1 -0
  174. package/lib/cjs/SQLiteDb.js +140 -0
  175. package/lib/cjs/SQLiteDb.js.map +1 -0
  176. package/lib/cjs/Schema.d.ts +56 -0
  177. package/lib/cjs/Schema.d.ts.map +1 -0
  178. package/lib/cjs/Schema.js +84 -0
  179. package/lib/cjs/Schema.js.map +1 -0
  180. package/lib/cjs/ServerBasedLocks.d.ts +64 -0
  181. package/lib/cjs/ServerBasedLocks.d.ts.map +1 -0
  182. package/lib/cjs/ServerBasedLocks.js +177 -0
  183. package/lib/cjs/ServerBasedLocks.js.map +1 -0
  184. package/lib/cjs/SqliteStatement.d.ts +264 -0
  185. package/lib/cjs/SqliteStatement.d.ts.map +1 -0
  186. package/lib/cjs/SqliteStatement.js +417 -0
  187. package/lib/cjs/SqliteStatement.js.map +1 -0
  188. package/lib/cjs/Texture.d.ts +59 -0
  189. package/lib/cjs/Texture.d.ts.map +1 -0
  190. package/lib/cjs/Texture.js +83 -0
  191. package/lib/cjs/Texture.js.map +1 -0
  192. package/lib/cjs/TxnManager.d.ts +203 -0
  193. package/lib/cjs/TxnManager.d.ts.map +1 -0
  194. package/lib/cjs/TxnManager.js +354 -0
  195. package/lib/cjs/TxnManager.js.map +1 -0
  196. package/lib/cjs/ViewDefinition.d.ts +432 -0
  197. package/lib/cjs/ViewDefinition.d.ts.map +1 -0
  198. package/lib/cjs/ViewDefinition.js +623 -0
  199. package/lib/cjs/ViewDefinition.js.map +1 -0
  200. package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -0
  201. package/lib/cjs/core-backend.d.ts +162 -0
  202. package/lib/cjs/core-backend.d.ts.map +1 -0
  203. package/lib/cjs/core-backend.js +181 -0
  204. package/lib/cjs/core-backend.js.map +1 -0
  205. package/lib/cjs/domains/FunctionalElements.d.ts +102 -0
  206. package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -0
  207. package/lib/cjs/domains/FunctionalElements.js +146 -0
  208. package/lib/cjs/domains/FunctionalElements.js.map +1 -0
  209. package/lib/cjs/domains/FunctionalSchema.d.ts +14 -0
  210. package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -0
  211. package/lib/cjs/domains/FunctionalSchema.js +41 -0
  212. package/lib/cjs/domains/FunctionalSchema.js.map +1 -0
  213. package/lib/cjs/domains/GenericElements.d.ts +178 -0
  214. package/lib/cjs/domains/GenericElements.d.ts.map +1 -0
  215. package/lib/cjs/domains/GenericElements.js +264 -0
  216. package/lib/cjs/domains/GenericElements.js.map +1 -0
  217. package/lib/cjs/domains/GenericSchema.d.ts +11 -0
  218. package/lib/cjs/domains/GenericSchema.d.ts.map +1 -0
  219. package/lib/cjs/domains/GenericSchema.js +29 -0
  220. package/lib/cjs/domains/GenericSchema.js.map +1 -0
  221. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts +16 -0
  222. package/lib/cjs/rpc-impl/DevToolsRpcImpl.d.ts.map +1 -0
  223. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js +33 -0
  224. package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -0
  225. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +40 -0
  226. package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -0
  227. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +207 -0
  228. package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -0
  229. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts +21 -0
  230. package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -0
  231. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +193 -0
  232. package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -0
  233. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts +37 -0
  234. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -0
  235. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +162 -0
  236. package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -0
  237. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts +17 -0
  238. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.d.ts.map +1 -0
  239. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js +44 -0
  240. package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -0
  241. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts +16 -0
  242. package/lib/cjs/rpc-impl/WipRpcImpl.d.ts.map +1 -0
  243. package/lib/cjs/rpc-impl/WipRpcImpl.js +35 -0
  244. package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -0
  245. package/package.json +101 -0
@@ -0,0 +1,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
+ /** Get the file and directory names in the specified directory. Excludes "." and "..". */
53
+ static readdirSync(pathname) { return 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)) {
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
+ //# sourceMappingURL=IModelJsFs.js.map
@@ -0,0 +1 @@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I,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;gBAC5C,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;aACvB;SACF;QACD,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACnB,UAAU,CAAC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACL,CAAC;IAED,uEAAuE;IAChE,MAAM,CAAC,kBAAkB,CAAC,OAAe;QAC9C,IAAI,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;YAChC,OAAO;QACT,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,UAAU,KAAK,OAAO;YACxB,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QAC5C,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;IAED,sCAAsC;IAC/B,MAAM,CAAC,YAAY,CAAC,OAAe;QACxC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC;YACjC,OAAO;QAET,UAAU,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,KAAc,EAAE,EAAE;YACnE,IAAI,KAAK,EAAE;gBACT,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;gBAClC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;iBAAM;gBACL,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACjC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhID,gCAgIC","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\r\n/** @packageDocumentation\r\n * @module Portability\r\n */\r\n\r\n// cspell: ignore wflag\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport * as path from \"path\";\r\n\r\n/* TODO: define File Mode Constants: S_IWUSR, et al. */\r\n/** Information about a file. See [[IModelJsFs.lstatSync]]\r\n * @public\r\n */\r\nexport class IModelJsFsStats {\r\n constructor(\r\n public size: number,\r\n public atimeMs: number,\r\n public mtimeMs: number,\r\n public birthtimeMs: number,\r\n public isDirectory: boolean,\r\n public isFile: boolean,\r\n public isSocket: boolean,\r\n public isSymbolicLink: boolean,\r\n public isReadOnly: boolean,\r\n ) { }\r\n}\r\n\r\n/** File system operations that are defined on all platforms. See also [[Platform]] and [[KnownLocations]]\r\n * @public\r\n */\r\nexport class IModelJsFs {\r\n\r\n /** Does file or directory exist? */\r\n public static existsSync(pathname: string): boolean { return fs.existsSync(pathname); }\r\n\r\n /** Delete a file. */\r\n public static unlinkSync(pathname: string): void { fs.unlinkSync(pathname); }\r\n\r\n /** Delete a file or remove a directory (rm -r). */\r\n public static removeSync(pathname: string): void { fs.removeSync(pathname); }\r\n\r\n /** Create a directory. */\r\n public static mkdirSync(pathname: string): void { fs.mkdirSync(pathname); }\r\n\r\n /** Remove a directory. */\r\n public static rmdirSync(pathname: string): void { fs.rmdirSync(pathname); }\r\n\r\n /** Write to a file. */\r\n public static writeFileSync(pathname: string, data: string | Uint8Array, wflag: string = \"w\"): void { fs.writeFileSync(pathname, data, { flag: wflag }); }\r\n\r\n /** Append to a file. */\r\n public static appendFileSync(pathname: string, str: string): void { fs.appendFileSync(pathname, str); }\r\n\r\n /** Make a copy of a file */\r\n public static copySync(src: string, dest: string, opts?: any): void { fs.copySync(src, dest, opts); }\r\n\r\n /** Get the file and directory names in the specified directory. Excludes \".\" and \"..\". */\r\n public static readdirSync(pathname: string): string[] { return fs.readdirSync(pathname); }\r\n\r\n /** Read file */\r\n public static readFileSync(pathname: string): string | Buffer { return fs.readFileSync(pathname); }\r\n\r\n /** Test if the current user has permission to write to a file. */\r\n private static isFileWritable(pathname: string): boolean {\r\n try {\r\n fs.accessSync(pathname, fs.constants.W_OK);\r\n return true;\r\n } catch (_err) {\r\n return false;\r\n }\r\n }\r\n\r\n /** Get information about a file. */\r\n public static lstatSync(pathname: string): IModelJsFsStats | undefined {\r\n const stats = fs.lstatSync(pathname);\r\n if (stats === undefined)\r\n return undefined;\r\n\r\n return new IModelJsFsStats(\r\n stats.size,\r\n stats.atime.getTime(),\r\n stats.mtime.getTime(),\r\n stats.birthtime.getTime(),\r\n stats.isDirectory(),\r\n stats.isFile(),\r\n stats.isSocket(),\r\n stats.isSymbolicLink(),\r\n !IModelJsFs.isFileWritable(pathname));\r\n }\r\n\r\n /**\r\n * Finds files recursively based on a pattern\r\n * @param rootDir Directory from where to start searching for files.\r\n * @param pattern A Regex that would be match to basename of files including extension\r\n * @returns list of file that match the pattern.\r\n */\r\n public static recursiveFindSync(rootDir: string, pattern: RegExp): string[] {\r\n const files: string[] = [];\r\n IModelJsFs.walkDirSync(rootDir, (pathname: string, isDir: boolean) => {\r\n if (!isDir) {\r\n const fileName = path.basename(pathname);\r\n if (pattern.test(fileName)) {\r\n files.push(pathname);\r\n }\r\n }\r\n return true;\r\n });\r\n return files;\r\n }\r\n\r\n /**\r\n * Walks a directory in breadth first fashion\r\n * @param rootDir directory from where the traversal starts\r\n * @param cb callback that would be called with full path of file or directory\r\n */\r\n public static walkDirSync(rootDir: string, cb: (pathname: string, isDir: boolean) => boolean): void {\r\n const subDir = [];\r\n for (const childPath of IModelJsFs.readdirSync(rootDir)) {\r\n const fullPath = path.join(rootDir, childPath);\r\n const isDir = IModelJsFs.lstatSync(fullPath)?.isDirectory;\r\n if (!cb(fullPath, isDir!)) {\r\n return;\r\n }\r\n // Need to check if the directory still exists in case the callback has deleted it.\r\n if (isDir && IModelJsFs.existsSync(fullPath)) {\r\n subDir.push(fullPath);\r\n }\r\n }\r\n subDir.forEach((v) => {\r\n IModelJsFs.walkDirSync(v, cb);\r\n });\r\n }\r\n\r\n /** Create a directory, recursively setting up the path as necessary */\r\n public static recursiveMkDirSync(dirPath: string) {\r\n if (IModelJsFs.existsSync(dirPath))\r\n return;\r\n const parentPath = path.dirname(dirPath);\r\n if (parentPath !== dirPath)\r\n IModelJsFs.recursiveMkDirSync(parentPath);\r\n IModelJsFs.mkdirSync(dirPath);\r\n }\r\n\r\n /** Remove a directory, recursively */\r\n public static purgeDirSync(dirPath: string) {\r\n if (!IModelJsFs.existsSync(dirPath))\r\n return;\r\n\r\n IModelJsFs.walkDirSync(dirPath, (pathName: string, isDir: boolean) => {\r\n if (isDir) {\r\n IModelJsFs.purgeDirSync(pathName);\r\n IModelJsFs.removeSync(pathName);\r\n } else {\r\n IModelJsFs.unlinkSync(pathName);\r\n }\r\n return true;\r\n });\r\n }\r\n}\r\n"]}
@@ -0,0 +1,26 @@
1
+ import { Schema } from "@itwin/ecschema-metadata";
2
+ import { IModelDb } from "./IModelDb";
3
+ /**
4
+ * A utility class for retrieving EC Schema objects from an iModel. Loaded schemas are held in memory within
5
+ * a schema context managed by IModelSchemaLoader. The IModelSchemaLoader object should be held in memory if
6
+ * multiple calls to [[getSchema]] or [[tryGetSchema]] is a possibility, thereby avoiding unnecessary schema
7
+ * retrievals from an iModel.
8
+ * @alpha
9
+ */
10
+ export declare class IModelSchemaLoader {
11
+ private _iModel;
12
+ private _context;
13
+ /** @internal */
14
+ constructor(_iModel: IModelDb);
15
+ /** Get a schema by name
16
+ * @param schemaName a string with the name of the schema to load.
17
+ * @throws [IModelError]($common) if the schema is not found or cannot be loaded.
18
+ */
19
+ getSchema<T extends Schema>(schemaName: string): T;
20
+ /** Attempts to get a schema by name
21
+ * @param schemaName a string with the name of the schema to load.
22
+ * @throws [IModelError]($common) if the schema exists, but cannot be loaded.
23
+ */
24
+ tryGetSchema<T extends Schema>(schemaName: string): T | undefined;
25
+ }
26
+ //# sourceMappingURL=IModelSchemaLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelSchemaLoader.d.ts","sourceRoot":"","sources":["../../src/IModelSchemaLoader.ts"],"names":[],"mappings":"AAMA,OAAO,EAA6B,MAAM,EAA6C,MAAM,0BAA0B,CAAC;AAGxH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;GAMG;AACH,qBAAa,kBAAkB;IAIV,OAAO,CAAC,OAAO;IAHlC,OAAO,CAAC,QAAQ,CAAgB;IAEhC,gBAAgB;gBACW,OAAO,EAAE,QAAQ;IAM5C;;;OAGG;IACI,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC;IAQzD;;;OAGG;IACI,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;CAMzE"}
@@ -0,0 +1,95 @@
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.IModelSchemaLoader = void 0;
8
+ const core_bentley_1 = require("@itwin/core-bentley");
9
+ const ecschema_metadata_1 = require("@itwin/ecschema-metadata");
10
+ const core_common_1 = require("@itwin/core-common");
11
+ /**
12
+ * A utility class for retrieving EC Schema objects from an iModel. Loaded schemas are held in memory within
13
+ * a schema context managed by IModelSchemaLoader. The IModelSchemaLoader object should be held in memory if
14
+ * multiple calls to [[getSchema]] or [[tryGetSchema]] is a possibility, thereby avoiding unnecessary schema
15
+ * retrievals from an iModel.
16
+ * @alpha
17
+ */
18
+ class IModelSchemaLoader {
19
+ /** @internal */
20
+ constructor(_iModel) {
21
+ this._iModel = _iModel;
22
+ this._context = new ecschema_metadata_1.SchemaContext();
23
+ const locater = new IModelSchemaLocater(this._iModel);
24
+ this._context.addLocater(locater);
25
+ }
26
+ /** Get a schema by name
27
+ * @param schemaName a string with the name of the schema to load.
28
+ * @throws [IModelError]($common) if the schema is not found or cannot be loaded.
29
+ */
30
+ getSchema(schemaName) {
31
+ const schema = this.tryGetSchema(schemaName);
32
+ if (!schema)
33
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, `reading schema=${schemaName}`);
34
+ return schema;
35
+ }
36
+ /** Attempts to get a schema by name
37
+ * @param schemaName a string with the name of the schema to load.
38
+ * @throws [IModelError]($common) if the schema exists, but cannot be loaded.
39
+ */
40
+ tryGetSchema(schemaName) {
41
+ // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.
42
+ const key = new ecschema_metadata_1.SchemaKey(schemaName, new ecschema_metadata_1.ECVersion(1, 0, 0));
43
+ const schema = this._context.getSchemaSync(key, ecschema_metadata_1.SchemaMatchType.Latest);
44
+ return schema;
45
+ }
46
+ }
47
+ exports.IModelSchemaLoader = IModelSchemaLoader;
48
+ /**
49
+ * A private ISchemaLocater implementation for locating and retrieving EC Schema objects from an iModel
50
+ * @alpha
51
+ */
52
+ class IModelSchemaLocater {
53
+ /** @internal */
54
+ constructor(_iModel) {
55
+ this._iModel = _iModel;
56
+ }
57
+ /** Get a schema by [SchemaKey]
58
+ * @param schemaKey The [SchemaKey] that identifies the schema.
59
+ * @param matchType The [SchemaMatchType] to used for comparing schema versions.
60
+ * @param context The [SchemaContext] used to facilitate schema location.
61
+ * @throws [IModelError]($common) if the schema exists, but cannot be loaded.
62
+ */
63
+ async getSchema(schemaKey, matchType, context) {
64
+ return this.getSchemaSync(schemaKey, matchType, context);
65
+ }
66
+ /** Get a schema by [SchemaKey] synchronously.
67
+ * @param schemaKey The [SchemaKey] that identifies the schema.
68
+ * * @param matchType The [SchemaMatchType] to used for comparing schema versions.
69
+ * @param context The [SchemaContext] used to facilitate schema location.
70
+ * @throws [IModelError]($common) if the schema exists, but cannot be loaded.
71
+ */
72
+ getSchemaSync(schemaKey, _matchType, context) {
73
+ const schemaProps = this.getSchemaString(schemaKey.name);
74
+ if (!schemaProps)
75
+ return undefined;
76
+ context = context ? context : new ecschema_metadata_1.SchemaContext();
77
+ return ecschema_metadata_1.Schema.fromJsonSync(schemaProps, context);
78
+ }
79
+ /** Read schema data from the iModel as JSON string
80
+ * @param schemaName A string with the name of the schema to load.
81
+ * @returns A string with the JSON for the schema or `undefined` if the schema is not found.
82
+ * @throws [IModelError]($common) if the schema exists, but cannot be loaded.
83
+ */
84
+ getSchemaString(schemaName) {
85
+ const val = this._iModel.nativeDb.getSchema(schemaName);
86
+ if (undefined !== val.error) {
87
+ if (core_bentley_1.IModelStatus.NotFound === val.error.status) {
88
+ return undefined;
89
+ }
90
+ throw new core_common_1.IModelError(val.error.status, `reading schema=${schemaName}`);
91
+ }
92
+ return val.result;
93
+ }
94
+ }
95
+ //# sourceMappingURL=IModelSchemaLoader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IModelSchemaLoader.js","sourceRoot":"","sources":["../../src/IModelSchemaLoader.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;;;AAE/F,sDAAmD;AACnD,gEAAwH;AACxH,oDAAiD;AAIjD;;;;;;GAMG;AACH,MAAa,kBAAkB;IAG7B,gBAAgB;IAChB,YAA2B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,iCAAa,EAAE,CAAC;QACpC,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,SAAS,CAAmB,UAAkB;QACnD,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM;YACT,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;QAE/E,OAAO,MAAW,CAAC;IACrB,CAAC;IAED;;;OAGG;IACI,YAAY,CA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AAS,CAAC;aAClB;YACD,MAAM,IAAI,yBAAW,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,UAAU,EAAE,CAAC,CAAC;SACzE;QACD,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;CACF","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\r\nimport { IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ECVersion, ISchemaLocater, Schema, SchemaContext, SchemaKey, SchemaMatchType } from \"@itwin/ecschema-metadata\";\r\nimport { IModelError } from \"@itwin/core-common\";\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { IModelDb } from \"./IModelDb\";\r\n\r\n/**\r\n * A utility class for retrieving EC Schema objects from an iModel. Loaded schemas are held in memory within\r\n * a schema context managed by IModelSchemaLoader. The IModelSchemaLoader object should be held in memory if\r\n * multiple calls to [[getSchema]] or [[tryGetSchema]] is a possibility, thereby avoiding unnecessary schema\r\n * retrievals from an iModel.\r\n * @alpha\r\n */\r\nexport class IModelSchemaLoader {\r\n private _context: SchemaContext;\r\n\r\n /** @internal */\r\n public constructor(private _iModel: IModelDb) {\r\n this._context = new SchemaContext();\r\n const locater = new IModelSchemaLocater(this._iModel);\r\n this._context.addLocater(locater);\r\n }\r\n\r\n /** Get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [IModelError]($common) if the schema is not found or cannot be loaded.\r\n */\r\n public getSchema<T extends Schema>(schemaName: string): T {\r\n const schema = this.tryGetSchema(schemaName);\r\n if (!schema)\r\n throw new IModelError(IModelStatus.NotFound, `reading schema=${schemaName}`);\r\n\r\n return schema as T;\r\n }\r\n\r\n /** Attempts to get a schema by name\r\n * @param schemaName a string with the name of the schema to load.\r\n * @throws [IModelError]($common) if the schema exists, but cannot be loaded.\r\n */\r\n public tryGetSchema<T extends Schema>(schemaName: string): T | undefined {\r\n // SchemaKey version is not used when locating schema in an iModel, so the version is arbitrary.\r\n const key = new SchemaKey(schemaName, new ECVersion(1, 0, 0));\r\n const schema = this._context.getSchemaSync(key, SchemaMatchType.Latest);\r\n return schema as T;\r\n }\r\n}\r\n\r\n/**\r\n * A private ISchemaLocater implementation for locating and retrieving EC Schema objects from an iModel\r\n * @alpha\r\n */\r\nclass IModelSchemaLocater implements ISchemaLocater {\r\n /** @internal */\r\n public constructor(private _iModel: IModelDb) { }\r\n\r\n /** Get a schema by [SchemaKey]\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [IModelError]($common) if the schema exists, but cannot be loaded.\r\n */\r\n public async getSchema<T extends Schema>(schemaKey: SchemaKey, matchType: SchemaMatchType, context?: SchemaContext | undefined): Promise<T | undefined> {\r\n return this.getSchemaSync(schemaKey, matchType, context) as T;\r\n }\r\n\r\n /** Get a schema by [SchemaKey] synchronously.\r\n * @param schemaKey The [SchemaKey] that identifies the schema.\r\n * * @param matchType The [SchemaMatchType] to used for comparing schema versions.\r\n * @param context The [SchemaContext] used to facilitate schema location.\r\n * @throws [IModelError]($common) if the schema exists, but cannot be loaded.\r\n */\r\n public getSchemaSync<T extends Schema>(schemaKey: SchemaKey, _matchType: SchemaMatchType, context?: SchemaContext | undefined): T | undefined {\r\n const schemaProps = this.getSchemaString(schemaKey.name);\r\n if (!schemaProps)\r\n return undefined;\r\n\r\n context = context ? context : new SchemaContext();\r\n return Schema.fromJsonSync(schemaProps, context) as T;\r\n }\r\n\r\n /** Read schema data from the iModel as JSON string\r\n * @param schemaName A string with the name of the schema to load.\r\n * @returns A string with the JSON for the schema or `undefined` if the schema is not found.\r\n * @throws [IModelError]($common) if the schema exists, but cannot be loaded.\r\n */\r\n private getSchemaString(schemaName: string): string | undefined {\r\n const val: IModelJsNative.ErrorStatusOrResult<any, any> = this._iModel.nativeDb.getSchema(schemaName);\r\n if (undefined !== val.error) {\r\n if (IModelStatus.NotFound === val.error.status) {\r\n return undefined;\r\n }\r\n throw new IModelError(val.error.status, `reading schema=${schemaName}`);\r\n }\r\n return val.result;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,99 @@
1
+ /** @packageDocumentation
2
+ * @module NativeApp
3
+ */
4
+ import { EditingScopeNotifications, IpcAppNotifications, IpcListener, IpcSocketBackend, RemoveFunction, TxnNotifications } from "@itwin/core-common";
5
+ import { BriefcaseDb, StandaloneDb } from "./IModelDb";
6
+ import { IModelHostConfiguration } from "./IModelHost";
7
+ /**
8
+ * Options for [[IpcHost.startup]]
9
+ * @public
10
+ */
11
+ export interface IpcHostOpts {
12
+ iModelHost?: IModelHostConfiguration;
13
+ ipcHost?: {
14
+ /** The Ipc socket to use for communications with frontend. Allows undefined only for headless tests. */
15
+ socket?: IpcSocketBackend;
16
+ /** don't send stack information on exceptions */
17
+ exceptions?: {
18
+ noStack?: boolean;
19
+ };
20
+ };
21
+ }
22
+ /**
23
+ * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.
24
+ * @note if either end terminates, the other must too.
25
+ * @public
26
+ */
27
+ export declare class IpcHost {
28
+ static noStack: boolean;
29
+ private static _ipc;
30
+ /** Get the implementation of the [IpcSocketBackend]($common) interface. */
31
+ private static get ipc();
32
+ /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */
33
+ static get isValid(): boolean;
34
+ /**
35
+ * Send a message to the frontend over an Ipc channel.
36
+ * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].
37
+ * @param data The content of the message.
38
+ */
39
+ static send(channel: string, ...data: any[]): void;
40
+ /**
41
+ * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls
42
+ * @param channel The name of the channel for this handler.
43
+ * @param handler A function that supplies the implementation for `channel`
44
+ * @note returns A function to call to remove the handler.
45
+ */
46
+ static handle(channel: string, handler: (...args: any[]) => Promise<any>): RemoveFunction;
47
+ /**
48
+ * Establish a handler to receive messages sent via [[IpcApp.send]].
49
+ * @param channel The name of the channel for the messages.
50
+ * @param listener A function called when messages are sent over `channel`
51
+ * @note returns A function to call to remove the listener.
52
+ */
53
+ static addListener(channel: string, listener: IpcListener): RemoveFunction;
54
+ /**
55
+ * Remove a previously registered listener
56
+ * @param channel The name of the channel for the listener previously registered with [[addListener]]
57
+ * @param listener The function passed to [[addListener]]
58
+ */
59
+ static removeListener(channel: string, listener: IpcListener): void;
60
+ private static notify;
61
+ /** @internal */
62
+ static notifyIpcFrontend<T extends keyof IpcAppNotifications>(methodName: T, ...args: Parameters<IpcAppNotifications[T]>): void;
63
+ /** @internal */
64
+ static notifyTxns<T extends keyof TxnNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<TxnNotifications[T]>): void;
65
+ /** @internal */
66
+ static notifyEditingScope<T extends keyof EditingScopeNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<EditingScopeNotifications[T]>): void;
67
+ /**
68
+ * Start the backend of an Ipc app.
69
+ * @param opt
70
+ * @note this method calls [[IModelHost.startup]] internally.
71
+ */
72
+ static startup(opt?: IpcHostOpts): Promise<void>;
73
+ /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */
74
+ static shutdown(): Promise<void>;
75
+ }
76
+ /**
77
+ * Base class for all implementations of an Ipc interface.
78
+ *
79
+ * Create a subclass to implement your Ipc interface. Your class should be declared like this:
80
+ * ```ts
81
+ * class MyHandler extends IpcHandler implements MyInterface
82
+ * ```
83
+ * to ensure all methods and signatures are correct.
84
+ *
85
+ * Then, call `MyClass.register` at startup to connect your class to your channel.
86
+ * @public
87
+ */
88
+ export declare abstract class IpcHandler {
89
+ /** All subclasses must implement this method to specify their channel name. */
90
+ abstract get channelName(): string;
91
+ /**
92
+ * Register this class as the handler for methods on its channel. This static method creates a new instance
93
+ * that becomes the handler and is `this` when its methods are called.
94
+ * @returns A function that can be called to remove the handler.
95
+ * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.
96
+ */
97
+ static register(): RemoveFunction;
98
+ }
99
+ //# sourceMappingURL=IpcHost.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IpcHost.d.ts","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACgC,yBAAyB,EAC9D,mBAAmB,EAAmB,WAAW,EAAE,gBAAgB,EAAoC,cAAc,EACjG,gBAAgB,EACrC,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAY,YAAY,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAc,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGnE;;;IAGI;AACJ,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,uBAAuB,CAAC;IACrC,OAAO,CAAC,EAAE;QACR,wGAAwG;QACxG,MAAM,CAAC,EAAE,gBAAgB,CAAC;QAE1B,iDAAiD;QACjD,UAAU,CAAC,EAAE;YACX,OAAO,CAAC,EAAE,OAAO,CAAC;SACnB,CAAC;KACH,CAAC;CACH;AAED;;;;GAIG;AACH,qBAAa,OAAO;IAClB,OAAc,OAAO,UAAS;IAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,CAA+B;IAClD,2EAA2E;IAC3E,OAAO,CAAC,MAAM,KAAK,GAAG,GAA2C;IACjE,gIAAgI;IAChI,WAAkB,OAAO,IAAI,OAAO,CAAoC;IAExE;;;;OAIG;WACW,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzD;;;;;OAKG;WACW,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,GAAG,cAAc;IAGhG;;;;;OAKG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,cAAc;IAGjF;;;;OAIG;WACW,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,IAAI;IAI1E,OAAO,CAAC,MAAM,CAAC,MAAM;IAKrB,gBAAgB;WACF,iBAAiB,CAAC,CAAC,SAAS,MAAM,mBAAmB,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAI/H,gBAAgB;WACF,UAAU,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,SAAS,EAAE,WAAW,GAAG,YAAY,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAIzJ,gBAAgB;WACF,kBAAkB,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAAE,SAAS,EAAE,WAAW,GAAG,YAAY,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAInL;;;;OAIG;WACiB,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7D,mEAAmE;WAC/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAI9C;AAED;;;;;;;;;;;GAWG;AACH,8BAAsB,UAAU;IAC9B,+EAA+E;IAC/E,aAAoB,WAAW,IAAI,MAAM,CAAC;IAE1C;;;;;OAKG;WACW,QAAQ,IAAI,cAAc;CAuBzC"}
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module NativeApp
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.IpcHandler = exports.IpcHost = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_common_1 = require("@itwin/core-common");
13
+ const IModelDb_1 = require("./IModelDb");
14
+ const IModelHost_1 = require("./IModelHost");
15
+ const IModelTileRpcImpl_1 = require("./rpc-impl/IModelTileRpcImpl");
16
+ /**
17
+ * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.
18
+ * @note if either end terminates, the other must too.
19
+ * @public
20
+ */
21
+ class IpcHost {
22
+ /** Get the implementation of the [IpcSocketBackend]($common) interface. */
23
+ static get ipc() { return this._ipc; }
24
+ /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */
25
+ static get isValid() { return undefined !== this._ipc; }
26
+ /**
27
+ * Send a message to the frontend over an Ipc channel.
28
+ * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].
29
+ * @param data The content of the message.
30
+ */
31
+ static send(channel, ...data) {
32
+ this.ipc.send((0, core_common_1.iTwinChannel)(channel), ...data);
33
+ }
34
+ /**
35
+ * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls
36
+ * @param channel The name of the channel for this handler.
37
+ * @param handler A function that supplies the implementation for `channel`
38
+ * @note returns A function to call to remove the handler.
39
+ */
40
+ static handle(channel, handler) {
41
+ return this.ipc.handle((0, core_common_1.iTwinChannel)(channel), handler);
42
+ }
43
+ /**
44
+ * Establish a handler to receive messages sent via [[IpcApp.send]].
45
+ * @param channel The name of the channel for the messages.
46
+ * @param listener A function called when messages are sent over `channel`
47
+ * @note returns A function to call to remove the listener.
48
+ */
49
+ static addListener(channel, listener) {
50
+ return this.ipc.addListener((0, core_common_1.iTwinChannel)(channel), listener);
51
+ }
52
+ /**
53
+ * Remove a previously registered listener
54
+ * @param channel The name of the channel for the listener previously registered with [[addListener]]
55
+ * @param listener The function passed to [[addListener]]
56
+ */
57
+ static removeListener(channel, listener) {
58
+ this.ipc.removeListener((0, core_common_1.iTwinChannel)(channel), listener);
59
+ }
60
+ static notify(channel, briefcase, methodName, ...args) {
61
+ if (this.isValid)
62
+ return this.send(`${channel}:${briefcase.key}`, methodName, ...args);
63
+ }
64
+ /** @internal */
65
+ static notifyIpcFrontend(methodName, ...args) {
66
+ return IpcHost.send(core_common_1.IpcAppChannel.AppNotify, methodName, ...args);
67
+ }
68
+ /** @internal */
69
+ static notifyTxns(briefcase, methodName, ...args) {
70
+ this.notify(core_common_1.IpcAppChannel.Txns, briefcase, methodName, ...args);
71
+ }
72
+ /** @internal */
73
+ static notifyEditingScope(briefcase, methodName, ...args) {
74
+ this.notify(core_common_1.IpcAppChannel.EditingScope, briefcase, methodName, ...args);
75
+ }
76
+ /**
77
+ * Start the backend of an Ipc app.
78
+ * @param opt
79
+ * @note this method calls [[IModelHost.startup]] internally.
80
+ */
81
+ static async startup(opt) {
82
+ var _a, _b, _c;
83
+ this._ipc = (_a = opt === null || opt === void 0 ? void 0 : opt.ipcHost) === null || _a === void 0 ? void 0 : _a.socket;
84
+ if ((_c = (_b = opt === null || opt === void 0 ? void 0 : opt.ipcHost) === null || _b === void 0 ? void 0 : _b.exceptions) === null || _c === void 0 ? void 0 : _c.noStack)
85
+ this.noStack = true;
86
+ if (this.isValid) { // for tests, we use IpcHost but don't have a frontend
87
+ IpcAppHandler.register();
88
+ }
89
+ await IModelHost_1.IModelHost.startup(opt === null || opt === void 0 ? void 0 : opt.iModelHost);
90
+ }
91
+ /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */
92
+ static async shutdown() {
93
+ this._ipc = undefined;
94
+ await IModelHost_1.IModelHost.shutdown();
95
+ }
96
+ }
97
+ exports.IpcHost = IpcHost;
98
+ IpcHost.noStack = false;
99
+ /**
100
+ * Base class for all implementations of an Ipc interface.
101
+ *
102
+ * Create a subclass to implement your Ipc interface. Your class should be declared like this:
103
+ * ```ts
104
+ * class MyHandler extends IpcHandler implements MyInterface
105
+ * ```
106
+ * to ensure all methods and signatures are correct.
107
+ *
108
+ * Then, call `MyClass.register` at startup to connect your class to your channel.
109
+ * @public
110
+ */
111
+ class IpcHandler {
112
+ /**
113
+ * Register this class as the handler for methods on its channel. This static method creates a new instance
114
+ * that becomes the handler and is `this` when its methods are called.
115
+ * @returns A function that can be called to remove the handler.
116
+ * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.
117
+ */
118
+ static register() {
119
+ const impl = new this(); // create an instance of subclass. "as any" is necessary because base class is abstract
120
+ return IpcHost.handle(impl.channelName, async (_evt, funcName, ...args) => {
121
+ var _a;
122
+ try {
123
+ const func = impl[funcName];
124
+ if (typeof func !== "function")
125
+ throw new core_common_1.IModelError(core_bentley_1.IModelStatus.FunctionNotFound, `Method "${impl.constructor.name}.${funcName}" not found on IpcHandler registered for channel: ${impl.channelName}`);
126
+ return { result: await func.call(impl, ...args) };
127
+ }
128
+ catch (err) {
129
+ const ret = {
130
+ error: {
131
+ name: (err && typeof (err) === "object") ? err.constructor.name : "Unknown Error",
132
+ message: core_bentley_1.BentleyError.getErrorMessage(err),
133
+ errorNumber: (_a = err.errorNumber) !== null && _a !== void 0 ? _a : 0,
134
+ },
135
+ };
136
+ if (!IpcHost.noStack)
137
+ ret.error.stack = core_bentley_1.BentleyError.getErrorStack(err);
138
+ return ret;
139
+ }
140
+ });
141
+ }
142
+ }
143
+ exports.IpcHandler = IpcHandler;
144
+ /**
145
+ * Implementation of IpcAppFunctions
146
+ */
147
+ class IpcAppHandler extends IpcHandler {
148
+ get channelName() { return core_common_1.IpcAppChannel.Functions; }
149
+ async log(_timestamp, level, category, message, metaData) {
150
+ switch (level) {
151
+ case core_bentley_1.LogLevel.Error:
152
+ core_bentley_1.Logger.logError(category, message, metaData);
153
+ break;
154
+ case core_bentley_1.LogLevel.Info:
155
+ core_bentley_1.Logger.logInfo(category, message, metaData);
156
+ break;
157
+ case core_bentley_1.LogLevel.Trace:
158
+ core_bentley_1.Logger.logTrace(category, message, metaData);
159
+ break;
160
+ case core_bentley_1.LogLevel.Warning:
161
+ core_bentley_1.Logger.logWarning(category, message, metaData);
162
+ break;
163
+ }
164
+ }
165
+ async cancelTileContentRequests(tokenProps, contentIds) {
166
+ return (0, IModelTileRpcImpl_1.cancelTileContentRequests)(tokenProps, contentIds);
167
+ }
168
+ async cancelElementGraphicsRequests(key, requestIds) {
169
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.cancelElementGraphicsRequests(requestIds);
170
+ }
171
+ async openBriefcase(args) {
172
+ const db = await IModelDb_1.BriefcaseDb.open(args);
173
+ return db.toJSON();
174
+ }
175
+ async openStandalone(filePath, openMode, opts) {
176
+ return IModelDb_1.StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();
177
+ }
178
+ async closeIModel(key) {
179
+ IModelDb_1.IModelDb.findByKey(key).close();
180
+ }
181
+ async saveChanges(key, description) {
182
+ IModelDb_1.IModelDb.findByKey(key).saveChanges(description);
183
+ }
184
+ async hasPendingTxns(key) {
185
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.hasPendingTxns();
186
+ }
187
+ async isUndoPossible(key) {
188
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.isUndoPossible();
189
+ }
190
+ async isRedoPossible(key) {
191
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.isRedoPossible();
192
+ }
193
+ async getUndoString(key) {
194
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.getUndoString();
195
+ }
196
+ async getRedoString(key) {
197
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.getUndoString();
198
+ }
199
+ async pullChanges(key, toIndex) {
200
+ const iModelDb = IModelDb_1.BriefcaseDb.findByKey(key);
201
+ await iModelDb.pullChanges({ toIndex });
202
+ return iModelDb.changeset;
203
+ }
204
+ async pushChanges(key, description) {
205
+ const iModelDb = IModelDb_1.BriefcaseDb.findByKey(key);
206
+ await iModelDb.pushChanges({ description });
207
+ return iModelDb.changeset;
208
+ }
209
+ async toggleGraphicalEditingScope(key, startSession) {
210
+ const val = IModelDb_1.IModelDb.findByKey(key).nativeDb.setGeometricModelTrackingEnabled(startSession);
211
+ if (val.error)
212
+ throw new core_common_1.IModelError(val.error.status, "Failed to toggle graphical editing scope");
213
+ return val.result;
214
+ }
215
+ async isGraphicalEditingSupported(key) {
216
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.isGeometricModelTrackingSupported();
217
+ }
218
+ async reverseTxns(key, numOperations) {
219
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.reverseTxns(numOperations);
220
+ }
221
+ async reverseAllTxn(key) {
222
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.reverseAll();
223
+ }
224
+ async reinstateTxn(key) {
225
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.reinstateTxn();
226
+ }
227
+ async restartTxnSession(key) {
228
+ return IModelDb_1.IModelDb.findByKey(key).nativeDb.restartTxnSession();
229
+ }
230
+ async queryConcurrency(pool) {
231
+ return IModelHost_1.IModelHost.platform.queryConcurrency(pool);
232
+ }
233
+ }
234
+ //# sourceMappingURL=IpcHost.js.map