@itwin/core-backend 3.1.0-dev.26 → 3.1.0-dev.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +130 -67
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +58 -5
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/Entity.d.ts +12 -0
- package/lib/cjs/Entity.d.ts.map +1 -1
- package/lib/cjs/Entity.js +12 -0
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +4 -2
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +15 -6
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +22 -4
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelSchemaLoader.d.ts +3 -3
- package/lib/cjs/IModelSchemaLoader.d.ts.map +1 -1
- package/lib/cjs/IModelSchemaLoader.js +33 -6
- package/lib/cjs/IModelSchemaLoader.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.d.ts.map +1 -1
- package/lib/cjs/PromiseMemoizer.js +3 -0
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/package.json +18 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 24 Jan 2022 14:00:52 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.0.0
|
|
6
|
+
Mon, 24 Jan 2022 14:00:52 GMT
|
|
7
|
+
|
|
8
|
+
### Updates
|
|
9
|
+
|
|
10
|
+
- add briefcaseAlias argument to acquireNewBriefcaseId
|
|
11
|
+
- make one method to acquire both shared and exclusive locks
|
|
12
|
+
- Add GeometryClass to ExportGraphics
|
|
13
|
+
- Update SQLiteDb to public release tag
|
|
14
|
+
- initial support for cloud-based WorkspaceContainers
|
|
15
|
+
- added IModelDb.workspace
|
|
16
|
+
- improve concurrent query changes
|
|
17
|
+
- Skip full schema load that cause OOM error on node backend
|
|
18
|
+
- Do not reopen connection on schema change
|
|
19
|
+
- Remove usage-logging-client
|
|
20
|
+
- Upgrade target to ES2019
|
|
21
|
+
- Entity no longer implements EntityProps.
|
|
22
|
+
- suppress error logging during test that expect errors
|
|
23
|
+
- add test and improved concurrent query support
|
|
24
|
+
- fix flaky test
|
|
25
|
+
- Update BackendHubAccess api to use ChangesetIndexAndId
|
|
26
|
+
- Add new GeoServices class and first method to interpret WKT or complete GCS JSON."
|
|
27
|
+
- getAccessToken always returns a token
|
|
28
|
+
- Fix an exception when attempting to pull changes into a briefcase that already has all the changes.
|
|
29
|
+
- LocalhostIpcHost, display-test-app support for R/W web (via orchestrator)
|
|
30
|
+
- Added ability to convert iModel coordinates to or from any Geographic CRS
|
|
31
|
+
- rename contextId -> iTwinId
|
|
32
|
+
- Tests for solid kernel severe error exceptions.
|
|
33
|
+
- throw rather than returning status from IModelDb.saveFileProperty and IModelDb.deleteFileProperty
|
|
34
|
+
- use db.locks to release all locks
|
|
35
|
+
- rename to @itwin/core-backend
|
|
36
|
+
- export blobdaemon, blobdaemoncommandargs from imodeljs-native
|
|
37
|
+
- Log the error that we catch when v2 checkpoint fails to open
|
|
38
|
+
- use BentleyError.getErrorProps(e) instead of just logging e
|
|
39
|
+
- Introduce no-non-null-assertion lint rule.
|
|
40
|
+
- remove ClientRequestContext and its subclasses
|
|
41
|
+
- Removed config.app usage
|
|
42
|
+
- Remove deprecated APIs for 3.0.
|
|
43
|
+
- allow apps to set safety interval for reattaching deamon
|
|
44
|
+
- removed several previously-deprecated apis
|
|
45
|
+
- remove IModelWriteRpcInterface
|
|
46
|
+
- remove ClientRequestContext.current
|
|
47
|
+
- Renamed all occurrences of the term revision0 to version0.
|
|
48
|
+
- rework locks
|
|
49
|
+
- Removed NativeAppAuthorizationBackend
|
|
50
|
+
- Removed two unit tests for reproj and added one
|
|
51
|
+
- added RpcTrace
|
|
52
|
+
- Bumped dotenv and removed deprecated @types/dotenv
|
|
53
|
+
- Replaced ContextRegistry with generalized ITwinAccess interface
|
|
54
|
+
- Switching to consume new Projects-Client
|
|
55
|
+
- Renamed an iModel's parent container to iTwin
|
|
56
|
+
- Removed references to the deleted config-loader package
|
|
57
|
+
- split imodel-transformer out of imodel-backend package
|
|
58
|
+
- remove use of "any" types in SqliteStatement
|
|
59
|
+
- IModelDb.getTextureImage is async.
|
|
60
|
+
- Support for TypeDoc v0.22.7. Fix various broken docs links.
|
|
61
|
+
- only export necessary schemas during imodel transformation
|
|
62
|
+
- Improved log message when v2 checkpoint downloaded is not for the changeset requested
|
|
63
|
+
- caching options for changed elements processing
|
|
64
|
+
- Adding WebEditServer (test scenarios only for now)
|
|
65
|
+
- add persistent iModel-based settings
|
|
66
|
+
- initial implementation of Workspace and Settings
|
|
4
67
|
|
|
5
68
|
## 2.19.28
|
|
6
69
|
Wed, 12 Jan 2022 14:52:38 GMT
|
|
@@ -166,7 +229,7 @@ Mon, 26 Jul 2021 12:21:25 GMT
|
|
|
166
229
|
|
|
167
230
|
- Reactivated test that stopped working when a previous PR for ecef dependency to geographicCRS was reverted
|
|
168
231
|
- store changesetIndex on IModelDb
|
|
169
|
-
- Better error checks when creating SpatialViewDefinition-s.
|
|
232
|
+
- Better error checks when creating SpatialViewDefinition-s.
|
|
170
233
|
- remove internal barrel-import usage
|
|
171
234
|
- throw exception when attempting to download a briefcase on top of an existing file
|
|
172
235
|
- Add case for InterpolationCurve3d
|
|
@@ -201,11 +264,11 @@ Fri, 09 Jul 2021 18:11:24 GMT
|
|
|
201
264
|
### Updates
|
|
202
265
|
|
|
203
266
|
- TemplateModelCloner now assigns a new FederationGuid for cloned element instances.
|
|
204
|
-
- Accomodated the inability to reverse Changesets when creating change summaries.
|
|
267
|
+
- Accomodated the inability to reverse Changesets when creating change summaries.
|
|
205
268
|
- fix lint issue
|
|
206
269
|
- begin api transition to changeset index rather than changeset Id
|
|
207
270
|
- Use ecef location calculated for projected iModels
|
|
208
|
-
- Push refreshes access token if necessary.
|
|
271
|
+
- Push refreshes access token if necessary.
|
|
209
272
|
- Do not reuse briefcase ids in ReadWrite workflows when using the RPC interfaces (if the briefcase was not found in the local file system)
|
|
210
273
|
- Add missing SectionDrawing properties.
|
|
211
274
|
|
|
@@ -226,7 +289,7 @@ Fri, 02 Jul 2021 15:38:31 GMT
|
|
|
226
289
|
|
|
227
290
|
### Updates
|
|
228
291
|
|
|
229
|
-
- Update to @bentley/imodeljs-native@2.17.10
|
|
292
|
+
- Update to @bentley/imodeljs-native@2.17.10
|
|
230
293
|
|
|
231
294
|
## 2.17.0
|
|
232
295
|
Mon, 28 Jun 2021 16:20:11 GMT
|
|
@@ -492,8 +555,8 @@ Thu, 28 Jan 2021 13:39:27 GMT
|
|
|
492
555
|
|
|
493
556
|
- Changed storageType from azure to azure?sas=1 for getCommandArgs function
|
|
494
557
|
- Fix brep DataProps to/from flatbuffer to account for base64 string header.
|
|
495
|
-
- Element geometry creation by brep operations.
|
|
496
|
-
- Reinstated behavior when re-opening files read-write.
|
|
558
|
+
- Element geometry creation by brep operations.
|
|
559
|
+
- Reinstated behavior when re-opening files read-write.
|
|
497
560
|
- enhance BriefcaseManager and BriefcaseDb for edit commands
|
|
498
561
|
- Improve ElementGeometry documentation.
|
|
499
562
|
- Add a check to verify, and fix, the DbGuid in the iModel if it is different than the Guid in iModelHub.
|
|
@@ -683,8 +746,8 @@ Fri, 02 Oct 2020 18:03:32 GMT
|
|
|
683
746
|
### Updates
|
|
684
747
|
|
|
685
748
|
- Update to @bentley/imodeljs-native@2.7.4
|
|
686
|
-
- Fixes to front end methods to pull, merge and push.
|
|
687
|
-
- Setup IModelHost.startup() to use proxy servers if configured/available - this is valuable for debugging agents, backends and electron applications.
|
|
749
|
+
- Fixes to front end methods to pull, merge and push.
|
|
750
|
+
- Setup IModelHost.startup() to use proxy servers if configured/available - this is valuable for debugging agents, backends and electron applications.
|
|
688
751
|
- On iOS download in background
|
|
689
752
|
- Fix ios hang issue
|
|
690
753
|
- Modify queryModelRanges to handle non geometric model errors
|
|
@@ -775,7 +838,7 @@ Thu, 20 Aug 2020 20:57:09 GMT
|
|
|
775
838
|
### Updates
|
|
776
839
|
|
|
777
840
|
- Update to imodeljs-native 2.5.0
|
|
778
|
-
- VSTS#419723: Accomodated "bad" checkpoints that may have serialized transactions preventing their use in ReadWrite cases.
|
|
841
|
+
- VSTS#419723: Accomodated "bad" checkpoints that may have serialized transactions preventing their use in ReadWrite cases.
|
|
779
842
|
- Fix for a recursive exception while closing a briefcase
|
|
780
843
|
- Added mobile oidc client
|
|
781
844
|
- Remove special code handling for mobile.
|
|
@@ -839,7 +902,7 @@ Fri, 10 Jul 2020 17:23:14 GMT
|
|
|
839
902
|
- Changes to support imodel-bridge
|
|
840
903
|
- fix spelling mistakes in Device class
|
|
841
904
|
- Fix typo in comments
|
|
842
|
-
- Setup BriefcaseDb.open() to allow profile and domain schema validation and upgrades.
|
|
905
|
+
- Setup BriefcaseDb.open() to allow profile and domain schema validation and upgrades.
|
|
843
906
|
- disallow protected operations for missing schemas marked with SchemaHasBehavior custom attribute
|
|
844
907
|
|
|
845
908
|
## 2.2.1
|
|
@@ -880,25 +943,25 @@ Thu, 28 May 2020 22:48:59 GMT
|
|
|
880
943
|
- Update to imodeljs-native 2.1.0
|
|
881
944
|
- Support for finding an ExternalSourceAspect given scope, id, and kind/hash.
|
|
882
945
|
- ApplyChangeset perf tests updated
|
|
883
|
-
- Fixed token expiry check for desktop authorization.
|
|
946
|
+
- Fixed token expiry check for desktop authorization.
|
|
884
947
|
- Download ChangeSets in chunks
|
|
885
948
|
- (1) In xy region booleans, support curved edges; (2) ExportGraphicsMeshVisitor class
|
|
886
949
|
- Add ability to convert ExportGraphicsMesh to Polyface
|
|
887
950
|
- Fixed validation of Guids (ContextId, IModelId) cached within a briefcase.
|
|
888
951
|
- Moved iModelBridgeFwk to a separate package
|
|
889
|
-
- Simplified logging for monitoring briefcase operations.
|
|
952
|
+
- Simplified logging for monitoring briefcase operations.
|
|
890
953
|
- Fix transforms for creating and querying part instance geometry in world coordinate.
|
|
891
954
|
- Fix and improvement to performance tests
|
|
892
955
|
- Added support for schema XML import to iModelJs backend via the IModelDb.importSchemaStrings method.
|
|
893
956
|
- channel rules
|
|
894
|
-
- Fixed logging usage when opening connections.
|
|
957
|
+
- Fixed logging usage when opening connections.
|
|
895
958
|
|
|
896
959
|
## 2.0.0
|
|
897
960
|
Wed, 06 May 2020 13:17:49 GMT
|
|
898
961
|
|
|
899
962
|
### Updates
|
|
900
963
|
|
|
901
|
-
- Fixed setup of UserInfo from browser clients, and more cleanups to AccessToken API.
|
|
964
|
+
- Fixed setup of UserInfo from browser clients, and more cleanups to AccessToken API.
|
|
902
965
|
- Added RivisionUtility class for debug/testing
|
|
903
966
|
- node addon 2.0.18
|
|
904
967
|
- addon 2.0.25
|
|
@@ -911,23 +974,23 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
911
974
|
- Performance tests for Applying Changesets
|
|
912
975
|
- `IModelHost.startup` is now async.
|
|
913
976
|
- `IModelHost.shutdown` is now async.
|
|
914
|
-
- Refined checks for briefcase id, and fixed failing integration tests.
|
|
977
|
+
- Refined checks for briefcase id, and fixed failing integration tests.
|
|
915
978
|
- Product Backlog Item 276268: Deleting the briefcase cache if the cache version is incorrect should not attempt to delete the root directory.
|
|
916
979
|
- Setup initialization of briefcase cache for offline workflows. (VSTS#286489)
|
|
917
|
-
- Monitor progress of downloading briefcases, ability to cancel download of briefcases.
|
|
980
|
+
- Monitor progress of downloading briefcases, ability to cancel download of briefcases.
|
|
918
981
|
- Move briefcase-specific events into BriefcaseIModelDb subclass
|
|
919
982
|
- Fixed param when calling logger so that it is a function as the logger expects
|
|
920
|
-
- Setup a common cache locaton for iModel.js, with briefcases taking up a sub-folder.
|
|
983
|
+
- Setup a common cache locaton for iModel.js, with briefcases taking up a sub-folder.
|
|
921
984
|
- Changed ChangeSets download API
|
|
922
985
|
- Added unlink for file handler
|
|
923
986
|
- Update UlasClient tests to send more detailed feature log data
|
|
924
987
|
- react to renaming of imodeljs-clients-backend to backend-itwin-client
|
|
925
988
|
- apply changeset performance tests with local datasets
|
|
926
|
-
- BriefcaseManager.delete should work in offline scenarios.
|
|
989
|
+
- BriefcaseManager.delete should work in offline scenarios.
|
|
927
990
|
- Remove deprecated members of SectionLocation and downgrade to alpha pending refactor.
|
|
928
991
|
- Support for progress/cancel from ios
|
|
929
992
|
- Remove deprecated ExportGraphics types etc for 2.0
|
|
930
|
-
- Updated docs.
|
|
993
|
+
- Updated docs.
|
|
931
994
|
- IModelDb.findByKey replaces IModelDb.find
|
|
932
995
|
- Include model extents with ViewStateProps for drawing views.
|
|
933
996
|
- Remove deprecated APIs; see NextVersion.md for details.
|
|
@@ -948,29 +1011,29 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
948
1011
|
- Introduce the BriefcaseIModelDb class, make IModelDb abstract.
|
|
949
1012
|
- Cleaned up unused async-s in BriefcaseManager
|
|
950
1013
|
- Avoided casting of BriefcaseProps to IModelRpcProps.
|
|
951
|
-
- Added NativeApp.deleteBriefcase, avoided authorization exceptions when offline.
|
|
1014
|
+
- Added NativeApp.deleteBriefcase, avoided authorization exceptions when offline.
|
|
952
1015
|
- Move briefcase property from IModelDb --> BriefcaseIModelDb
|
|
953
1016
|
- BriefcaseId is now an enum instead of a class
|
|
954
1017
|
- Rename BriefcaseId --> ReservedBriefcaseId, introduce BriefcaseId type
|
|
955
|
-
- VSTS#297017: Update cached briefcase information if changes were applied.
|
|
956
|
-
- Refactored NativeApp API and RPC interfaces. This continues to be WIP.
|
|
957
|
-
- Removed the call to simultaneously download and open the briefcase at the backend. This should be done in two separate steps henceforth. The download must be done with BriefcaseManager, and the open is now a synchronous call in BriefcaseDb.
|
|
958
|
-
- Added DownloadBriefcaseOptions and OpenBriefcaseOptions as parameters to the download/open calls for a briefcase.
|
|
1018
|
+
- VSTS#297017: Update cached briefcase information if changes were applied.
|
|
1019
|
+
- Refactored NativeApp API and RPC interfaces. This continues to be WIP.
|
|
1020
|
+
- Removed the call to simultaneously download and open the briefcase at the backend. This should be done in two separate steps henceforth. The download must be done with BriefcaseManager, and the open is now a synchronous call in BriefcaseDb.
|
|
1021
|
+
- Added DownloadBriefcaseOptions and OpenBriefcaseOptions as parameters to the download/open calls for a briefcase.
|
|
959
1022
|
- Removed BriefcaseDb.create
|
|
960
|
-
- Setup ability to use NativeApp.openBriefcase() in offline scenarios.
|
|
1023
|
+
- Setup ability to use NativeApp.openBriefcase() in offline scenarios.
|
|
961
1024
|
- fixed flaky test
|
|
962
|
-
- VSTS#217447, 162382: Cleanups to implementation of downloading/opening/discovering briefcases in native applications (WIP).
|
|
1025
|
+
- VSTS#217447, 162382: Cleanups to implementation of downloading/opening/discovering briefcases in native applications (WIP).
|
|
963
1026
|
- do not throw exception in NativeAppBackend.startup()
|
|
964
|
-
- VSTS#296110: Setup a way to close briefcases when the native application is offline.
|
|
1027
|
+
- VSTS#296110: Setup a way to close briefcases when the native application is offline.
|
|
965
1028
|
- Move concurrencyControl from IModelDb to BriefcaseIModelDb
|
|
966
1029
|
- Renamed OIDC constructs for consistency; Removed SAML support.
|
|
967
1030
|
- Add support for password-protecting snapshot iModels
|
|
968
1031
|
- Fixed typo for ElementAspect perf tests
|
|
969
|
-
- VSTS#217447, VSTS#162382: Reinstated option to open briefcases with SyncMode = PullOnly.
|
|
1032
|
+
- VSTS#217447, VSTS#162382: Reinstated option to open briefcases with SyncMode = PullOnly.
|
|
970
1033
|
- Add purge dir method to iModelJsFs
|
|
971
1034
|
- react to creation of new clients packages from imodeljs-clients
|
|
972
1035
|
- ; substitute current date for feature usage without any set start/end dates
|
|
973
|
-
- Removed deprecated utilities.
|
|
1036
|
+
- Removed deprecated utilities.
|
|
974
1037
|
- enforce opening Snapshots readonly through StandaloneDb
|
|
975
1038
|
- Remove the deprecated Entity.clone method
|
|
976
1039
|
- Adjusted calls to some node addon changes (ECUtils removed)
|
|
@@ -982,13 +1045,13 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
982
1045
|
- Add FileNameResolver class
|
|
983
1046
|
- Move snapshot methods out of IModelDb and into new SnapshotIModelDb class.
|
|
984
1047
|
- Add TemplateModelCloner to place instances of a template model
|
|
985
|
-
- Renamed TestOidcClient and related constructs for consistency.
|
|
1048
|
+
- Renamed TestOidcClient and related constructs for consistency.
|
|
986
1049
|
- Add IModelDb.tryPrepareStatement
|
|
987
|
-
- Fixed usage logging.
|
|
1050
|
+
- Fixed usage logging.
|
|
988
1051
|
- fix failing ulas tests due to invalid featureId
|
|
989
1052
|
- update ULAS test logging & feedback
|
|
990
1053
|
- Update UlasUtilities to support exception-throwing native functions
|
|
991
|
-
- Use standalone briefcases for PullOnly cases.
|
|
1054
|
+
- Use standalone briefcases for PullOnly cases.
|
|
992
1055
|
|
|
993
1056
|
## 1.14.1
|
|
994
1057
|
Wed, 22 Apr 2020 19:04:00 GMT
|
|
@@ -1003,7 +1066,7 @@ Tue, 31 Mar 2020 15:44:19 GMT
|
|
|
1003
1066
|
### Updates
|
|
1004
1067
|
|
|
1005
1068
|
- Update to addon 1.14.1
|
|
1006
|
-
- Fixed downloading of files using https/streaming to resolve when the filestream is closed instead of when the input stream is exhausted.
|
|
1069
|
+
- Fixed downloading of files using https/streaming to resolve when the filestream is closed instead of when the input stream is exhausted.
|
|
1007
1070
|
- Add handling for invalid predecessor ids to IModelTransformer
|
|
1008
1071
|
- Accomodate updated imodeljs-native ULAS functions
|
|
1009
1072
|
|
|
@@ -1018,7 +1081,7 @@ Wed, 12 Feb 2020 17:45:50 GMT
|
|
|
1018
1081
|
### Updates
|
|
1019
1082
|
|
|
1020
1083
|
- Fix IGeometry roundtripping issue through ECSql. Fix insert/update binary properties for Element Aspect.
|
|
1021
|
-
- Separated out routines to download and open briefcases.
|
|
1084
|
+
- Separated out routines to download and open briefcases.
|
|
1022
1085
|
- bulk mode
|
|
1023
1086
|
- Consolidated sign-in for integration tests
|
|
1024
1087
|
- bulkmode
|
|
@@ -1029,7 +1092,7 @@ Wed, 12 Feb 2020 17:45:50 GMT
|
|
|
1029
1092
|
- Add ViewDefinition.getAuxiliaryCoordinateSystemId and ViewDefinition.setAuxiliaryCoordinateSystemId methods
|
|
1030
1093
|
- Add SpatialLocationModel.insert
|
|
1031
1094
|
- Add optional isPlantProjection parameter to PhysicalModel.insert
|
|
1032
|
-
- VSTS#256133: Fixed issue with reopening connections if the backend crashes. Fixes to integration tests.
|
|
1095
|
+
- VSTS#256133: Fixed issue with reopening connections if the backend crashes. Fixes to integration tests.
|
|
1033
1096
|
- Better documentation of OidcDesktopClient
|
|
1034
1097
|
- Fixed changeset perf test by using another iModel on Hub
|
|
1035
1098
|
- Add ViewDetails to ViewDefinition.
|
|
@@ -1062,7 +1125,7 @@ Tue, 07 Jan 2020 19:44:01 GMT
|
|
|
1062
1125
|
- Allow events to be sent from backend to frontend
|
|
1063
1126
|
- Add tryGetInstance / tryGetInstanceProps methods to the Relationship class which return undefined rather than throwing an exception when a relationship is not found.
|
|
1064
1127
|
- Fix webpack for ios test that were failing due to new dependencies
|
|
1065
|
-
- VSTS#225894 - Allowed agents to bypass usage logging calls. These cause usage logging errors.
|
|
1128
|
+
- VSTS#225894 - Allowed agents to bypass usage logging calls. These cause usage logging errors.
|
|
1066
1129
|
- Add tryGetElement / tryGetElementProps which return undefined rather than throwing an exception when an element is not found.
|
|
1067
1130
|
- Add tryGetModel, tryGetModelProps, tryGetSubModel which return undefined instead of throwing exceptions when the model is not found.
|
|
1068
1131
|
|
|
@@ -1074,7 +1137,7 @@ Tue, 10 Dec 2019 18:08:56 GMT
|
|
|
1074
1137
|
- Updated to addon 9.1.3
|
|
1075
1138
|
- Added AliCloud tile cache service
|
|
1076
1139
|
- Added framework to run imodeljs-backend test on ios using appcenter
|
|
1077
|
-
- Setup OidcDesktopClient for Electron use cases.
|
|
1140
|
+
- Setup OidcDesktopClient for Electron use cases.
|
|
1078
1141
|
- fix warnings from static analysis
|
|
1079
1142
|
- Enabling testing code for updating LR aspects after fix in native side.
|
|
1080
1143
|
- Addressing typo in a couple of members, making them match the schema properly.
|
|
@@ -1130,9 +1193,9 @@ Mon, 30 Sep 2019 22:28:48 GMT
|
|
|
1130
1193
|
### Updates
|
|
1131
1194
|
|
|
1132
1195
|
- added support for blank IModelConnections
|
|
1133
|
-
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1134
|
-
- Error log when downloading change sets should include iModelId for context.
|
|
1135
|
-
- Fixed the iModelHub client to properly dispose a file handle after upload to the iModelHub.
|
|
1196
|
+
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1197
|
+
- Error log when downloading change sets should include iModelId for context.
|
|
1198
|
+
- Fixed the iModelHub client to properly dispose a file handle after upload to the iModelHub.
|
|
1136
1199
|
- Add IModelDb.Elements.hasSubModel
|
|
1137
1200
|
- Make ExternalSourceAspect.checksum optional
|
|
1138
1201
|
- Clear statement cache after schema import
|
|
@@ -1147,14 +1210,14 @@ Tue, 10 Sep 2019 12:09:49 GMT
|
|
|
1147
1210
|
|
|
1148
1211
|
### Updates
|
|
1149
1212
|
|
|
1150
|
-
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1151
|
-
- Allow attaching change cache file before change summary extraction.
|
|
1152
|
-
- Added change summary test, and improved doc a little.
|
|
1213
|
+
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1214
|
+
- Allow attaching change cache file before change summary extraction.
|
|
1215
|
+
- Added change summary test, and improved doc a little.
|
|
1153
1216
|
- Add minimum brep size option to IModelDb.exportGraphics
|
|
1154
1217
|
- FunctionalSchema.importSchema is now deprecated.
|
|
1155
1218
|
- Add support for GeometricModel.geometryGuid for detecting whether tiles for a model can be reused across versions
|
|
1156
1219
|
- Added performance logging for tile upload
|
|
1157
|
-
- IModelConnection.close() for read-only connections should not close the Db at the backend; Opening an iModel with SyncModel.PullAndPush() multiple times (without disposing it) must reuse the briefcase.
|
|
1220
|
+
- IModelConnection.close() for read-only connections should not close the Db at the backend; Opening an iModel with SyncModel.PullAndPush() multiple times (without disposing it) must reuse the briefcase.
|
|
1158
1221
|
- Add method to create view with camera
|
|
1159
1222
|
- Fixed misleading logging output in tile upload
|
|
1160
1223
|
|
|
@@ -1164,14 +1227,14 @@ Tue, 13 Aug 2019 20:25:53 GMT
|
|
|
1164
1227
|
### Updates
|
|
1165
1228
|
|
|
1166
1229
|
- Allow custom tile cache services.
|
|
1167
|
-
- Always acquire a briefcase when creating a new backend instance for PullAndPush workflows.
|
|
1168
|
-
- Added Change Summary integration test, and fixed documentation.
|
|
1230
|
+
- Always acquire a briefcase when creating a new backend instance for PullAndPush workflows.
|
|
1231
|
+
- Added Change Summary integration test, and fixed documentation.
|
|
1169
1232
|
- Trial code for tile upload errors
|
|
1170
1233
|
- Fixed changeset performance tests
|
|
1171
1234
|
- Tile upload logging.
|
|
1172
1235
|
- Mark ExportGraphics API as public
|
|
1173
1236
|
- Support for gzip compression of tiles
|
|
1174
|
-
- Fixed issue with opening iModels with names that are invalid on Unix or Windows.
|
|
1237
|
+
- Fixed issue with opening iModels with names that are invalid on Unix or Windows.
|
|
1175
1238
|
- Add IModelDb.isSnapshot
|
|
1176
1239
|
- Tile upload error catching.
|
|
1177
1240
|
- Azure tile upload logging
|
|
@@ -1183,7 +1246,7 @@ Wed, 24 Jul 2019 11:47:26 GMT
|
|
|
1183
1246
|
### Updates
|
|
1184
1247
|
|
|
1185
1248
|
- Added option to restrict tile cache URLs by client IP address.
|
|
1186
|
-
- Apply change sets at the backend in a non-blocking worker thread.
|
|
1249
|
+
- Apply change sets at the backend in a non-blocking worker thread.
|
|
1187
1250
|
- Add ElementAspect handler methods
|
|
1188
1251
|
- When deleting a parent element, make sure there are onDelete/onDeleted callbacks for child elements
|
|
1189
1252
|
- Add support for linework to IModelDb.exportGraphics
|
|
@@ -1201,19 +1264,19 @@ Mon, 01 Jul 2019 19:04:29 GMT
|
|
|
1201
1264
|
|
|
1202
1265
|
### Updates
|
|
1203
1266
|
|
|
1204
|
-
- Open fixes when briefcase requires merges.
|
|
1267
|
+
- Open fixes when briefcase requires merges.
|
|
1205
1268
|
- Catch tile upload errors.
|
|
1206
|
-
- Setting up briefcase is always from an older checkpoint.
|
|
1269
|
+
- Setting up briefcase is always from an older checkpoint.
|
|
1207
1270
|
- Add materialId, subCategory to ExportGraphicsInfo
|
|
1208
|
-
- Fix crash in getViewThumbnail for odd number of bytes
|
|
1271
|
+
- Fix crash in getViewThumbnail for odd number of bytes
|
|
1209
1272
|
- Adding relationship class for GraphicalElement3dRepresentsElement.
|
|
1210
1273
|
- Initial implementation of the LinearReferencing typescript domain
|
|
1211
1274
|
- Adding domain classes for all relatinships in the LinearReferencing schema.
|
|
1212
1275
|
- Exporting relationships module.
|
|
1213
|
-
- Fixes to opening iModel-s ReadWrite from mutiple IModelConnection-s.
|
|
1214
|
-
- Fixed issues with deleting briefcases if there were errors with preparing briefcases.
|
|
1276
|
+
- Fixes to opening iModel-s ReadWrite from mutiple IModelConnection-s.
|
|
1277
|
+
- Fixed issues with deleting briefcases if there were errors with preparing briefcases.
|
|
1215
1278
|
- Add a new method `forceLoadSchemas` to `IModelJsNative.ECPresentationManager`.
|
|
1216
|
-
- Introduced AsyncMutex - a utility to run async blocks of code in sequence.
|
|
1279
|
+
- Introduced AsyncMutex - a utility to run async blocks of code in sequence.
|
|
1217
1280
|
- Properly document ModelSelector.models and CategorySelector.categories as Id64String arrays
|
|
1218
1281
|
- Made `insertElement` not return Id64.invalid, throws error instead
|
|
1219
1282
|
- Update to TypeScript 3.5
|
|
@@ -1224,7 +1287,7 @@ Mon, 03 Jun 2019 18:09:39 GMT
|
|
|
1224
1287
|
|
|
1225
1288
|
### Updates
|
|
1226
1289
|
|
|
1227
|
-
- Migrated agent applications to the newer client
|
|
1290
|
+
- Migrated agent applications to the newer client
|
|
1228
1291
|
- RPC system now accepts only basic values (primitives, "interface" objects, and binary).
|
|
1229
1292
|
- Switched from iModelHub Project API to Context API
|
|
1230
1293
|
- Fix bug in IModelDb.createSnapshotFromSeed
|
|
@@ -1272,12 +1335,12 @@ Mon, 13 May 2019 15:52:05 GMT
|
|
|
1272
1335
|
- Cleanup old imodelbank references
|
|
1273
1336
|
- Add InformationRecordModel.insert, GroupModel.insert
|
|
1274
1337
|
- Introduce LoggerCategory enum to advertise logger categories used by this package.
|
|
1275
|
-
- Limited maximum cache size of the backend PromiseMemoizer.
|
|
1338
|
+
- Limited maximum cache size of the backend PromiseMemoizer.
|
|
1276
1339
|
- Missing dependency on node-report
|
|
1277
|
-
- Fixed memoization problem that caused an endless stream of 404 NotFound errors.
|
|
1340
|
+
- Fixed memoization problem that caused an endless stream of 404 NotFound errors.
|
|
1278
1341
|
- Reinstated old version of OidcAgentClient
|
|
1279
|
-
- Unauthorized open requests should cause a more obvious error.
|
|
1280
|
-
- Improved performance logging, especially of IModelDb open operations; ChangeSets are merged one-by-one to prevent hogging the event loop.
|
|
1342
|
+
- Unauthorized open requests should cause a more obvious error.
|
|
1343
|
+
- Improved performance logging, especially of IModelDb open operations; ChangeSets are merged one-by-one to prevent hogging the event loop.
|
|
1281
1344
|
- Memoization fix when opening iModels in shared, read-only mode .
|
|
1282
1345
|
- Fixed setup of application version.
|
|
1283
1346
|
- Updated Element CRUD perf tests
|
|
@@ -1287,7 +1350,7 @@ Mon, 13 May 2019 15:52:05 GMT
|
|
|
1287
1350
|
- Remove ElementPropertyFormatter, IModelDb.getElementPropertiesForDisplay (use presentation rules instead)
|
|
1288
1351
|
- Remove StandaloneIModelRpcImpl
|
|
1289
1352
|
- Fix for Render Gradient.Symb test
|
|
1290
|
-
- Setup a generic context for tracking client requests, and made various related enhancements to logging, usage tracking and authorization.
|
|
1353
|
+
- Setup a generic context for tracking client requests, and made various related enhancements to logging, usage tracking and authorization.
|
|
1291
1354
|
- Add IModelDb.createSnapshot/openSnapshot/closeSnapshot, deprecate IModelDb.createStandalone/openStandalone/closeStandalone
|
|
1292
1355
|
- Moved IModelJsExpressServer class into a new package (@itwin/express-server).
|
|
1293
1356
|
- Simplified tile caching IModelHost config and removed dev flags. Allow
|
|
@@ -1314,7 +1377,7 @@ Wed, 06 Mar 2019 15:41:22 GMT
|
|
|
1314
1377
|
- Changes package.json to include api-extractor and adds api-extractor.json
|
|
1315
1378
|
- Use new buildIModelJsBuild script
|
|
1316
1379
|
- AxisAlignedBox and ElementAlignedBox are now typed to Range3d rather than classes
|
|
1317
|
-
- Moved AzureFileHandler, IOSAzureFileHandler, UrlFileHandler and the iModelHub tests to the imodeljs-clients-backend package. This removes the dependency of imodeljs-clients on the "fs" module, and turns it into a browser only package.
|
|
1380
|
+
- Moved AzureFileHandler, IOSAzureFileHandler, UrlFileHandler and the iModelHub tests to the imodeljs-clients-backend package. This removes the dependency of imodeljs-clients on the "fs" module, and turns it into a browser only package.
|
|
1318
1381
|
- Clone methods are no longer generic
|
|
1319
1382
|
- Remove unneeded typedoc plugin dependency
|
|
1320
1383
|
- Added spatial <-> cartographic methods that check/use the geographic coordinate system before using ecef location.
|
|
@@ -1359,8 +1422,8 @@ Mon, 14 Jan 2019 23:09:10 GMT
|
|
|
1359
1422
|
|
|
1360
1423
|
### Updates
|
|
1361
1424
|
|
|
1362
|
-
- More logging of HTTP requests, and enabled use of fiddler for backend diagnostics.
|
|
1363
|
-
- Removed IModelDb's cache of accessToken. For long running operations like AutoPush, the user must explicitly supply an IAccessTokenManager to keep the token current.
|
|
1425
|
+
- More logging of HTTP requests, and enabled use of fiddler for backend diagnostics.
|
|
1426
|
+
- Removed IModelDb's cache of accessToken. For long running operations like AutoPush, the user must explicitly supply an IAccessTokenManager to keep the token current.
|
|
1364
1427
|
- Renamed RequestProxy->RequestHost. Allowed applications to configure proxy server with HTTPS_PROXY env.
|
|
1365
1428
|
- Add backend TextureAPI and accompanying test
|
|
1366
1429
|
|
|
@@ -1465,7 +1528,7 @@ Mon, 03 Dec 2018 18:52:58 GMT
|
|
|
1465
1528
|
|
|
1466
1529
|
### Updates
|
|
1467
1530
|
|
|
1468
|
-
- More information logged from BriefcaseManager.\nFixed deletion/cleanup of invalid briefcases.\nAdded OIDC support for simpleviewtest application.
|
|
1531
|
+
- More information logged from BriefcaseManager.\nFixed deletion/cleanup of invalid briefcases.\nAdded OIDC support for simpleviewtest application.
|
|
1469
1532
|
- Add ElementRefersToElements.insert
|
|
1470
1533
|
- Fixed front end integration tests.
|
|
1471
1534
|
- Document the intended purpose of IModelJsExpressServer within a deployment environment.
|
|
@@ -1534,11 +1597,11 @@ Thu, 08 Nov 2018 17:59:20 GMT
|
|
|
1534
1597
|
|
|
1535
1598
|
- Fix JSON representation of DisplayStyle.
|
|
1536
1599
|
- Add IModelImporter as a base class for utility methods needed by all importers
|
|
1537
|
-
- Removed assertion when deleting a memoized open call.
|
|
1600
|
+
- Removed assertion when deleting a memoized open call.
|
|
1538
1601
|
- Add more methods to IModelImporter
|
|
1539
1602
|
- Fix snapping test
|
|
1540
1603
|
- OIDC related enhancments (WIP).
|
|
1541
|
-
- Re-enabled several backend integration tests.
|
|
1604
|
+
- Re-enabled several backend integration tests.
|
|
1542
1605
|
- Refactor analysis-importer to use IModelImporter
|
|
1543
1606
|
- Updated to TypeScript 3.1
|
|
1544
1607
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.d.ts","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"ClassRegistry.d.ts","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,cAAc,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,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
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
12
|
const core_common_1 = require("@itwin/core-common");
|
|
13
13
|
const Entity_1 = require("./Entity");
|
|
14
|
+
const Element_1 = require("./Element");
|
|
14
15
|
const Schema_1 = require("./Schema");
|
|
16
|
+
const isGeneratedClassTag = Symbol("isGeneratedClassTag");
|
|
15
17
|
/** The mapping between a BIS class name (in the form "schema:class") and its JavaScript constructor function
|
|
16
18
|
* @public
|
|
17
19
|
*/
|
|
@@ -54,6 +56,7 @@ class ClassRegistry {
|
|
|
54
56
|
* @param entityMetaData The Entity metadata that defines the class
|
|
55
57
|
*/
|
|
56
58
|
static generateClassForEntity(entityMetaData, iModel) {
|
|
59
|
+
var _a, _b;
|
|
57
60
|
const name = entityMetaData.ecclass.split(":");
|
|
58
61
|
const domainName = name[0];
|
|
59
62
|
const className = name[1];
|
|
@@ -63,15 +66,65 @@ class ClassRegistry {
|
|
|
63
66
|
let schema = Schema_1.Schemas.getRegisteredSchema(domainName);
|
|
64
67
|
if (undefined === schema)
|
|
65
68
|
schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too
|
|
66
|
-
// this method relies on the caller having previously created/registered all superclasses
|
|
67
69
|
const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());
|
|
68
70
|
if (undefined === superclass)
|
|
69
71
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NotFound, `cannot find superclass for class ${name}`);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot
|
|
73
|
+
// be used to tell if there are any generated classes in the hierarchy
|
|
74
|
+
let generatedClassHasNonGeneratedNonCoreAncestor = false;
|
|
75
|
+
let currentSuperclass = superclass;
|
|
76
|
+
const MAX_ITERS = 1000;
|
|
77
|
+
for (let i = 0; i < MAX_ITERS; ++i) {
|
|
78
|
+
if (currentSuperclass.schema.schemaName === "BisCore")
|
|
79
|
+
break;
|
|
80
|
+
if (!currentSuperclass.isGeneratedClass) {
|
|
81
|
+
generatedClassHasNonGeneratedNonCoreAncestor = true;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);
|
|
85
|
+
if (superclassMetaData === undefined)
|
|
86
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);
|
|
87
|
+
const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);
|
|
88
|
+
if (maybeNextSuperclass === undefined)
|
|
89
|
+
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);
|
|
90
|
+
currentSuperclass = maybeNextSuperclass;
|
|
91
|
+
}
|
|
92
|
+
const generatedClass = (_b = class extends superclass {
|
|
93
|
+
static get className() { return className; }
|
|
94
|
+
static get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }
|
|
95
|
+
},
|
|
96
|
+
_a = isGeneratedClassTag,
|
|
97
|
+
_b[_a] = true,
|
|
98
|
+
_b);
|
|
99
|
+
// the above creates an anonymous class. For help debugging, set the "constructor.name" property to be the same as the bisClassName.
|
|
74
100
|
Object.defineProperty(generatedClass, "name", { get: () => className }); // this is the (only) way to change that readonly property.
|
|
101
|
+
const navigationProps = Object.entries(entityMetaData.properties)
|
|
102
|
+
.filter(([_propName, prop]) => prop.isNavigation)
|
|
103
|
+
.map(([propName, _prop]) => propName);
|
|
104
|
+
const isElement = (t) => t.is(Element_1.Element); // Entity.is check but with type information to avoid casts later
|
|
105
|
+
// a class only gets an automatic `collectPredecessorIds` implementation if:
|
|
106
|
+
// - it derives from `BisCore:Element`
|
|
107
|
+
// - it is not in the `BisCore` schema
|
|
108
|
+
// - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)
|
|
109
|
+
if (!generatedClassHasNonGeneratedNonCoreAncestor && isElement(superclass)) {
|
|
110
|
+
Object.defineProperty(generatedClass.prototype, "collectPredecessorIds", {
|
|
111
|
+
// first prototype of `this` is its class
|
|
112
|
+
value(predecessorIds) {
|
|
113
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
114
|
+
const superImpl = superclass.prototype["collectPredecessorIds"];
|
|
115
|
+
superImpl.call(this, predecessorIds);
|
|
116
|
+
for (const navProp of navigationProps) {
|
|
117
|
+
const relatedElem = this[navProp]; // cast to any since subclass can have any extensions
|
|
118
|
+
if (!relatedElem || !core_bentley_1.Id64.isValid(relatedElem.id))
|
|
119
|
+
continue;
|
|
120
|
+
predecessorIds.add(relatedElem.id);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
// defaults for methods on a prototype (required for sinon to stub out methods on tests)
|
|
124
|
+
writable: true,
|
|
125
|
+
configurable: true,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
75
128
|
// if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations
|
|
76
129
|
if (schema.missingRequiredBehavior) {
|
|
77
130
|
const throwError = () => { throw new core_common_1.IModelError(core_bentley_1.IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAqE;AACrE,oDAAiE;AACjE,qCAAkC;AAElC,qCAA2C;AAE3C;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GAAQ,IAAI,OAAO,CAAC,GAAG,YAAY,yBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,KAAK,2BAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/H,gBAAgB;IACT,MAAM,CAAC,yBAAyB,CAAC,SAAiB,IAAiB,OAAO,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AC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IAE1H,gCAAgC;IACzB,GAAG,CAAC,aAAqB,EAAE,QAAwB,IAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { DbResult, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, IModelError } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = iModel.withPreparedSqliteStatement(`\r\n SELECT NULL FROM [ec_CustomAttribute] [c]\r\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\r\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\r\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\r\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\r\n stmt.bindString(1, domain);\r\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\r\n return stmt.step() === DbResult.BE_SQLITE_ROW;\r\n });\r\n\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n // this method relies on the caller having previously created/registered all superclasses\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n const generatedClass = class extends superclass { public static override get className() { return className; } };\r\n // the above line creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => { throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ClassRegistry.js","sourceRoot":"","sources":["../../src/ClassRegistry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoF;AACpF,oDAAiF;AACjF,qCAAkC;AAClC,uCAAoC;AAEpC,qCAA2C;AAE3C,MAAM,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAa,aAAa;IAExB,gBAAgB;IACT,MAAM,CAAC,eAAe,CAAC,GAAQ,IAAI,OAAO,CAAC,GAAG,YAAY,yBAAW,CAAC,IAAI,CAAC,GA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AAG,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACjI;AARD,4CAQC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { DbResult, Id64, Id64Set, IModelStatus, Logger } from \"@itwin/core-bentley\";\r\nimport { EntityMetaData, IModelError, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { Element } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { Schema, Schemas } from \"./Schema\";\r\n\r\nconst isGeneratedClassTag = Symbol(\"isGeneratedClassTag\");\r\n\r\n/** The mapping between a BIS class name (in the form \"schema:class\") and its JavaScript constructor function\r\n * @public\r\n */\r\nexport class ClassRegistry {\r\n private static readonly _classMap = new Map<string, typeof Entity>();\r\n /** @internal */\r\n public static isNotFoundError(err: any) { return (err instanceof IModelError) && (err.errorNumber === IModelStatus.NotFound); }\r\n /** @internal */\r\n public static makeMetaDataNotFoundError(className: string): IModelError { return new IModelError(IModelStatus.NotFound, `metadata not found for ${className}`); }\r\n /** @internal */\r\n public static register(entityClass: typeof Entity, schema: typeof Schema) {\r\n entityClass.schema = schema;\r\n const key = (`${schema.schemaName}:${entityClass.className}`).toLowerCase();\r\n if (this._classMap.has(key)) {\r\n const errMsg = `Class ${key} is already registered. Make sure static className member is correct on JavaScript class ${entityClass.name}`;\r\n Logger.logError(\"core-frontend.classRegistry\", errMsg);\r\n throw new Error(errMsg);\r\n }\r\n\r\n this._classMap.set(key, entityClass);\r\n }\r\n\r\n /** Generate a proxy Schema for a domain that has not been registered. */\r\n private static generateProxySchema(domain: string, iModel: IModelDb): typeof Schema {\r\n const hasBehavior = iModel.withPreparedSqliteStatement(`\r\n SELECT NULL FROM [ec_CustomAttribute] [c]\r\n JOIN [ec_schema] [s] ON [s].[Id] = [c].[ContainerId]\r\n JOIN [ec_class] [e] ON [e].[Id] = [c].[ClassId]\r\n JOIN [ec_schema] [b] ON [e].[SchemaId] = [b].[Id]\r\n WHERE [c].[ContainerType] = 1 AND [s].[Name] = ? AND [b].[Name] || '.' || [e].[name] = ?`, (stmt) => {\r\n stmt.bindString(1, domain);\r\n stmt.bindString(2, \"BisCore.SchemaHasBehavior\");\r\n return stmt.step() === DbResult.BE_SQLITE_ROW;\r\n });\r\n\r\n const schemaClass = class extends Schema {\r\n public static override get schemaName() { return domain; }\r\n public static override get missingRequiredBehavior() { return hasBehavior; }\r\n };\r\n\r\n Schemas.registerSchema(schemaClass); // register the class before we return it.\r\n return schemaClass;\r\n }\r\n\r\n /** Generate a JavaScript class from Entity metadata.\r\n * @param entityMetaData The Entity metadata that defines the class\r\n */\r\n private static generateClassForEntity(entityMetaData: EntityMetaData, iModel: IModelDb): typeof Entity {\r\n const name = entityMetaData.ecclass.split(\":\");\r\n const domainName = name[0];\r\n const className = name[1];\r\n\r\n if (0 === entityMetaData.baseClasses.length) // metadata must contain a superclass\r\n throw new IModelError(IModelStatus.BadArg, `class ${name} has no superclass`);\r\n\r\n // make sure schema exists\r\n let schema = Schemas.getRegisteredSchema(domainName);\r\n if (undefined === schema)\r\n schema = this.generateProxySchema(domainName, iModel); // no schema found, create it too\r\n\r\n const superclass = this._classMap.get(entityMetaData.baseClasses[0].toLowerCase());\r\n if (undefined === superclass)\r\n throw new IModelError(IModelStatus.NotFound, `cannot find superclass for class ${name}`);\r\n\r\n // user defined class hierarchies may skip a class in the hierarchy, and therefore their JS base class cannot\r\n // be used to tell if there are any generated classes in the hierarchy\r\n let generatedClassHasNonGeneratedNonCoreAncestor = false;\r\n let currentSuperclass = superclass;\r\n const MAX_ITERS = 1000;\r\n for (let i = 0; i < MAX_ITERS; ++i) {\r\n if (currentSuperclass.schema.schemaName === \"BisCore\") break;\r\n if (!currentSuperclass.isGeneratedClass) {\r\n generatedClassHasNonGeneratedNonCoreAncestor = true;\r\n break;\r\n }\r\n const superclassMetaData = iModel.classMetaDataRegistry.find(currentSuperclass.classFullName);\r\n if (superclassMetaData === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the metadata for class '${currentSuperclass.name}', class metadata should be loaded by now`);\r\n const maybeNextSuperclass = this.getClass(superclassMetaData.baseClasses[0], iModel);\r\n if (maybeNextSuperclass === undefined)\r\n throw new IModelError(IModelStatus.BadSchema, `could not find the base class of '${currentSuperclass.name}', all generated classes must have a base class`);\r\n currentSuperclass = maybeNextSuperclass;\r\n }\r\n\r\n const generatedClass = class extends superclass {\r\n public static override get className() { return className; }\r\n private static [isGeneratedClassTag] = true;\r\n public static override get isGeneratedClass() { return this.hasOwnProperty(isGeneratedClassTag); }\r\n };\r\n\r\n // the above creates an anonymous class. For help debugging, set the \"constructor.name\" property to be the same as the bisClassName.\r\n Object.defineProperty(generatedClass, \"name\", { get: () => className }); // this is the (only) way to change that readonly property.\r\n\r\n const navigationProps = Object.entries(entityMetaData.properties)\r\n .filter(([_propName, prop]) => prop.isNavigation)\r\n .map(([propName, _prop]) => propName);\r\n\r\n const isElement = (t: typeof Entity): t is typeof Element => t.is(Element); // Entity.is check but with type information to avoid casts later\r\n\r\n // a class only gets an automatic `collectPredecessorIds` implementation if:\r\n // - it derives from `BisCore:Element`\r\n // - it is not in the `BisCore` schema\r\n // - there are no ancestors with manually registered JS implementations, (excluding BisCore base classes)\r\n if (!generatedClassHasNonGeneratedNonCoreAncestor && isElement(superclass)) {\r\n Object.defineProperty(\r\n generatedClass.prototype,\r\n \"collectPredecessorIds\",\r\n {\r\n // first prototype of `this` is its class\r\n value(this: typeof generatedClass, predecessorIds: Id64Set) {\r\n // eslint-disable-next-line @typescript-eslint/dot-notation\r\n const superImpl = superclass.prototype[\"collectPredecessorIds\"];\r\n superImpl.call(this, predecessorIds);\r\n for (const navProp of navigationProps) {\r\n const relatedElem: RelatedElement | undefined = (this as any)[navProp]; // cast to any since subclass can have any extensions\r\n if (!relatedElem || !Id64.isValid(relatedElem.id)) continue;\r\n predecessorIds.add(relatedElem.id);\r\n }\r\n },\r\n // defaults for methods on a prototype (required for sinon to stub out methods on tests)\r\n writable: true,\r\n configurable: true,\r\n }\r\n );\r\n }\r\n\r\n // if the schema is a proxy for a domain with behavior, throw exceptions for all protected operations\r\n if (schema.missingRequiredBehavior) {\r\n const throwError = () => { throw new IModelError(IModelStatus.WrongHandler, `Schema [${domainName}] not registered, but is marked with SchemaHasBehavior`); };\r\n superclass.protectedOperations.forEach((operation) => (generatedClass as any)[operation] = throwError);\r\n }\r\n\r\n this.register(generatedClass, schema); // register it before returning\r\n return generatedClass;\r\n }\r\n\r\n /** Register all of the classes found in the given module that derive from Entity. See the example in [[Schema]]\r\n * @param moduleObj The module to search for subclasses of Entity\r\n * @param schema The schema for all found classes\r\n */\r\n public static registerModule(moduleObj: any, schema: typeof Schema) {\r\n for (const thisMember in moduleObj) { // eslint-disable-line guard-for-in\r\n const thisClass = moduleObj[thisMember];\r\n if (thisClass.prototype instanceof Entity)\r\n this.register(thisClass, schema);\r\n }\r\n }\r\n\r\n /**\r\n * This function fetches the specified Entity from the imodel, generates a JavaScript class for it, and registers the generated\r\n * class. This function also ensures that all of the base classes of the Entity exist and are registered.\r\n */\r\n private static generateClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const metadata: EntityMetaData | undefined = iModel.classMetaDataRegistry.find(classFullName);\r\n if (metadata === undefined || metadata.ecclass === undefined)\r\n throw this.makeMetaDataNotFoundError(classFullName);\r\n\r\n // Make sure we have all base classes registered.\r\n if (metadata.baseClasses && (0 !== metadata.baseClasses.length))\r\n this.getClass(metadata.baseClasses[0], iModel);\r\n\r\n // Now we can generate the class from the classDef.\r\n return this.generateClassForEntity(metadata, iModel);\r\n }\r\n\r\n /** Find a registered class by classFullName.\r\n * @param classFullName class to find\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class or undefined\r\n */\r\n public static findRegisteredClass(classFullName: string): typeof Entity | undefined {\r\n return this._classMap.get(classFullName.toLowerCase());\r\n }\r\n\r\n /** Get the Entity class for the specified Entity className.\r\n * @param classFullName The full BIS class name of the Entity\r\n * @param iModel The IModel that contains the class definitions\r\n * @returns The Entity class\r\n */\r\n public static getClass(classFullName: string, iModel: IModelDb): typeof Entity {\r\n const key = classFullName.toLowerCase();\r\n const ctor = this._classMap.get(key);\r\n return ctor ? ctor : this.generateClass(key, iModel);\r\n }\r\n\r\n /** Unregister a class, by name, if one is already registered.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* class needs to be replaced by the *real* class.\r\n * @param classFullName Name of the class to unregister\r\n * @return true if the class was unregistered\r\n * @internal\r\n */\r\n public static unregisterCLass(classFullName: string) { return this._classMap.delete(classFullName.toLowerCase()); }\r\n /** Unregister all classes from a schema.\r\n * This function is not normally needed, but is useful for cases where a generated *proxy* schema needs to be replaced by the *real* schema.\r\n * @param schema Name of the schema to unregister\r\n * @internal\r\n */\r\n public static unregisterClassesFrom(schema: typeof Schema) {\r\n for (const entry of Array.from(this._classMap)) {\r\n if (entry[1].schema === schema)\r\n this.unregisterCLass(entry[0]);\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * A cache that records the mapping between class names and class metadata\r\n * @internal\r\n */\r\nexport class MetaDataRegistry {\r\n private _registry: Map<string, EntityMetaData> = new Map<string, EntityMetaData>();\r\n\r\n /** Get the specified Entity metadata */\r\n public find(classFullName: string): EntityMetaData | undefined { return this._registry.get(classFullName.toLowerCase()); }\r\n\r\n /** Add metadata to the cache */\r\n public add(classFullName: string, metaData: EntityMetaData): void { this._registry.set(classFullName.toLowerCase(), metaData); }\r\n}\r\n"]}
|