@itwin/core-backend 3.1.0-dev.8 → 3.2.0-dev.3
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 +135 -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/CloudStorageBackend.d.ts +2 -0
- package/lib/cjs/CloudStorageBackend.d.ts.map +1 -1
- package/lib/cjs/CloudStorageBackend.js +9 -4
- package/lib/cjs/CloudStorageBackend.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 +24 -6
- 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/LocalhostIpcHost.d.ts +2 -0
- package/lib/cjs/LocalhostIpcHost.d.ts.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js +14 -7
- package/lib/cjs/LocalhostIpcHost.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/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +2 -2
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +3 -10
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/package.json +19 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
# Change Log - @itwin/core-backend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 24 Feb 2022 15:26:55 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.0.1
|
|
6
|
+
Thu, 24 Feb 2022 15:26:55 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.0.0
|
|
11
|
+
Mon, 24 Jan 2022 14:00:52 GMT
|
|
12
|
+
|
|
13
|
+
### Updates
|
|
14
|
+
|
|
15
|
+
- add briefcaseAlias argument to acquireNewBriefcaseId
|
|
16
|
+
- make one method to acquire both shared and exclusive locks
|
|
17
|
+
- Add GeometryClass to ExportGraphics
|
|
18
|
+
- Update SQLiteDb to public release tag
|
|
19
|
+
- initial support for cloud-based WorkspaceContainers
|
|
20
|
+
- added IModelDb.workspace
|
|
21
|
+
- improve concurrent query changes
|
|
22
|
+
- Skip full schema load that cause OOM error on node backend
|
|
23
|
+
- Do not reopen connection on schema change
|
|
24
|
+
- Remove usage-logging-client
|
|
25
|
+
- Upgrade target to ES2019
|
|
26
|
+
- Entity no longer implements EntityProps.
|
|
27
|
+
- suppress error logging during test that expect errors
|
|
28
|
+
- add test and improved concurrent query support
|
|
29
|
+
- fix flaky test
|
|
30
|
+
- Update BackendHubAccess api to use ChangesetIndexAndId
|
|
31
|
+
- Add new GeoServices class and first method to interpret WKT or complete GCS JSON."
|
|
32
|
+
- getAccessToken always returns a token
|
|
33
|
+
- Fix an exception when attempting to pull changes into a briefcase that already has all the changes.
|
|
34
|
+
- LocalhostIpcHost, display-test-app support for R/W web (via orchestrator)
|
|
35
|
+
- Added ability to convert iModel coordinates to or from any Geographic CRS
|
|
36
|
+
- rename contextId -> iTwinId
|
|
37
|
+
- Tests for solid kernel severe error exceptions.
|
|
38
|
+
- throw rather than returning status from IModelDb.saveFileProperty and IModelDb.deleteFileProperty
|
|
39
|
+
- use db.locks to release all locks
|
|
40
|
+
- rename to @itwin/core-backend
|
|
41
|
+
- export blobdaemon, blobdaemoncommandargs from imodeljs-native
|
|
42
|
+
- Log the error that we catch when v2 checkpoint fails to open
|
|
43
|
+
- use BentleyError.getErrorProps(e) instead of just logging e
|
|
44
|
+
- Introduce no-non-null-assertion lint rule.
|
|
45
|
+
- remove ClientRequestContext and its subclasses
|
|
46
|
+
- Removed config.app usage
|
|
47
|
+
- Remove deprecated APIs for 3.0.
|
|
48
|
+
- allow apps to set safety interval for reattaching deamon
|
|
49
|
+
- removed several previously-deprecated apis
|
|
50
|
+
- remove IModelWriteRpcInterface
|
|
51
|
+
- remove ClientRequestContext.current
|
|
52
|
+
- Renamed all occurrences of the term revision0 to version0.
|
|
53
|
+
- rework locks
|
|
54
|
+
- Removed NativeAppAuthorizationBackend
|
|
55
|
+
- Removed two unit tests for reproj and added one
|
|
56
|
+
- added RpcTrace
|
|
57
|
+
- Bumped dotenv and removed deprecated @types/dotenv
|
|
58
|
+
- Replaced ContextRegistry with generalized ITwinAccess interface
|
|
59
|
+
- Switching to consume new Projects-Client
|
|
60
|
+
- Renamed an iModel's parent container to iTwin
|
|
61
|
+
- Removed references to the deleted config-loader package
|
|
62
|
+
- split imodel-transformer out of imodel-backend package
|
|
63
|
+
- remove use of "any" types in SqliteStatement
|
|
64
|
+
- IModelDb.getTextureImage is async.
|
|
65
|
+
- Support for TypeDoc v0.22.7. Fix various broken docs links.
|
|
66
|
+
- only export necessary schemas during imodel transformation
|
|
67
|
+
- Improved log message when v2 checkpoint downloaded is not for the changeset requested
|
|
68
|
+
- caching options for changed elements processing
|
|
69
|
+
- Adding WebEditServer (test scenarios only for now)
|
|
70
|
+
- add persistent iModel-based settings
|
|
71
|
+
- initial implementation of Workspace and Settings
|
|
4
72
|
|
|
5
73
|
## 2.19.28
|
|
6
74
|
Wed, 12 Jan 2022 14:52:38 GMT
|
|
@@ -166,7 +234,7 @@ Mon, 26 Jul 2021 12:21:25 GMT
|
|
|
166
234
|
|
|
167
235
|
- Reactivated test that stopped working when a previous PR for ecef dependency to geographicCRS was reverted
|
|
168
236
|
- store changesetIndex on IModelDb
|
|
169
|
-
- Better error checks when creating SpatialViewDefinition-s.
|
|
237
|
+
- Better error checks when creating SpatialViewDefinition-s.
|
|
170
238
|
- remove internal barrel-import usage
|
|
171
239
|
- throw exception when attempting to download a briefcase on top of an existing file
|
|
172
240
|
- Add case for InterpolationCurve3d
|
|
@@ -201,11 +269,11 @@ Fri, 09 Jul 2021 18:11:24 GMT
|
|
|
201
269
|
### Updates
|
|
202
270
|
|
|
203
271
|
- TemplateModelCloner now assigns a new FederationGuid for cloned element instances.
|
|
204
|
-
- Accomodated the inability to reverse Changesets when creating change summaries.
|
|
272
|
+
- Accomodated the inability to reverse Changesets when creating change summaries.
|
|
205
273
|
- fix lint issue
|
|
206
274
|
- begin api transition to changeset index rather than changeset Id
|
|
207
275
|
- Use ecef location calculated for projected iModels
|
|
208
|
-
- Push refreshes access token if necessary.
|
|
276
|
+
- Push refreshes access token if necessary.
|
|
209
277
|
- 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
278
|
- Add missing SectionDrawing properties.
|
|
211
279
|
|
|
@@ -226,7 +294,7 @@ Fri, 02 Jul 2021 15:38:31 GMT
|
|
|
226
294
|
|
|
227
295
|
### Updates
|
|
228
296
|
|
|
229
|
-
- Update to @bentley/imodeljs-native@2.17.10
|
|
297
|
+
- Update to @bentley/imodeljs-native@2.17.10
|
|
230
298
|
|
|
231
299
|
## 2.17.0
|
|
232
300
|
Mon, 28 Jun 2021 16:20:11 GMT
|
|
@@ -492,8 +560,8 @@ Thu, 28 Jan 2021 13:39:27 GMT
|
|
|
492
560
|
|
|
493
561
|
- Changed storageType from azure to azure?sas=1 for getCommandArgs function
|
|
494
562
|
- 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.
|
|
563
|
+
- Element geometry creation by brep operations.
|
|
564
|
+
- Reinstated behavior when re-opening files read-write.
|
|
497
565
|
- enhance BriefcaseManager and BriefcaseDb for edit commands
|
|
498
566
|
- Improve ElementGeometry documentation.
|
|
499
567
|
- Add a check to verify, and fix, the DbGuid in the iModel if it is different than the Guid in iModelHub.
|
|
@@ -683,8 +751,8 @@ Fri, 02 Oct 2020 18:03:32 GMT
|
|
|
683
751
|
### Updates
|
|
684
752
|
|
|
685
753
|
- 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.
|
|
754
|
+
- Fixes to front end methods to pull, merge and push.
|
|
755
|
+
- Setup IModelHost.startup() to use proxy servers if configured/available - this is valuable for debugging agents, backends and electron applications.
|
|
688
756
|
- On iOS download in background
|
|
689
757
|
- Fix ios hang issue
|
|
690
758
|
- Modify queryModelRanges to handle non geometric model errors
|
|
@@ -775,7 +843,7 @@ Thu, 20 Aug 2020 20:57:09 GMT
|
|
|
775
843
|
### Updates
|
|
776
844
|
|
|
777
845
|
- Update to imodeljs-native 2.5.0
|
|
778
|
-
- VSTS#419723: Accomodated "bad" checkpoints that may have serialized transactions preventing their use in ReadWrite cases.
|
|
846
|
+
- VSTS#419723: Accomodated "bad" checkpoints that may have serialized transactions preventing their use in ReadWrite cases.
|
|
779
847
|
- Fix for a recursive exception while closing a briefcase
|
|
780
848
|
- Added mobile oidc client
|
|
781
849
|
- Remove special code handling for mobile.
|
|
@@ -839,7 +907,7 @@ Fri, 10 Jul 2020 17:23:14 GMT
|
|
|
839
907
|
- Changes to support imodel-bridge
|
|
840
908
|
- fix spelling mistakes in Device class
|
|
841
909
|
- Fix typo in comments
|
|
842
|
-
- Setup BriefcaseDb.open() to allow profile and domain schema validation and upgrades.
|
|
910
|
+
- Setup BriefcaseDb.open() to allow profile and domain schema validation and upgrades.
|
|
843
911
|
- disallow protected operations for missing schemas marked with SchemaHasBehavior custom attribute
|
|
844
912
|
|
|
845
913
|
## 2.2.1
|
|
@@ -880,25 +948,25 @@ Thu, 28 May 2020 22:48:59 GMT
|
|
|
880
948
|
- Update to imodeljs-native 2.1.0
|
|
881
949
|
- Support for finding an ExternalSourceAspect given scope, id, and kind/hash.
|
|
882
950
|
- ApplyChangeset perf tests updated
|
|
883
|
-
- Fixed token expiry check for desktop authorization.
|
|
951
|
+
- Fixed token expiry check for desktop authorization.
|
|
884
952
|
- Download ChangeSets in chunks
|
|
885
953
|
- (1) In xy region booleans, support curved edges; (2) ExportGraphicsMeshVisitor class
|
|
886
954
|
- Add ability to convert ExportGraphicsMesh to Polyface
|
|
887
955
|
- Fixed validation of Guids (ContextId, IModelId) cached within a briefcase.
|
|
888
956
|
- Moved iModelBridgeFwk to a separate package
|
|
889
|
-
- Simplified logging for monitoring briefcase operations.
|
|
957
|
+
- Simplified logging for monitoring briefcase operations.
|
|
890
958
|
- Fix transforms for creating and querying part instance geometry in world coordinate.
|
|
891
959
|
- Fix and improvement to performance tests
|
|
892
960
|
- Added support for schema XML import to iModelJs backend via the IModelDb.importSchemaStrings method.
|
|
893
961
|
- channel rules
|
|
894
|
-
- Fixed logging usage when opening connections.
|
|
962
|
+
- Fixed logging usage when opening connections.
|
|
895
963
|
|
|
896
964
|
## 2.0.0
|
|
897
965
|
Wed, 06 May 2020 13:17:49 GMT
|
|
898
966
|
|
|
899
967
|
### Updates
|
|
900
968
|
|
|
901
|
-
- Fixed setup of UserInfo from browser clients, and more cleanups to AccessToken API.
|
|
969
|
+
- Fixed setup of UserInfo from browser clients, and more cleanups to AccessToken API.
|
|
902
970
|
- Added RivisionUtility class for debug/testing
|
|
903
971
|
- node addon 2.0.18
|
|
904
972
|
- addon 2.0.25
|
|
@@ -911,23 +979,23 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
911
979
|
- Performance tests for Applying Changesets
|
|
912
980
|
- `IModelHost.startup` is now async.
|
|
913
981
|
- `IModelHost.shutdown` is now async.
|
|
914
|
-
- Refined checks for briefcase id, and fixed failing integration tests.
|
|
982
|
+
- Refined checks for briefcase id, and fixed failing integration tests.
|
|
915
983
|
- Product Backlog Item 276268: Deleting the briefcase cache if the cache version is incorrect should not attempt to delete the root directory.
|
|
916
984
|
- Setup initialization of briefcase cache for offline workflows. (VSTS#286489)
|
|
917
|
-
- Monitor progress of downloading briefcases, ability to cancel download of briefcases.
|
|
985
|
+
- Monitor progress of downloading briefcases, ability to cancel download of briefcases.
|
|
918
986
|
- Move briefcase-specific events into BriefcaseIModelDb subclass
|
|
919
987
|
- 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.
|
|
988
|
+
- Setup a common cache locaton for iModel.js, with briefcases taking up a sub-folder.
|
|
921
989
|
- Changed ChangeSets download API
|
|
922
990
|
- Added unlink for file handler
|
|
923
991
|
- Update UlasClient tests to send more detailed feature log data
|
|
924
992
|
- react to renaming of imodeljs-clients-backend to backend-itwin-client
|
|
925
993
|
- apply changeset performance tests with local datasets
|
|
926
|
-
- BriefcaseManager.delete should work in offline scenarios.
|
|
994
|
+
- BriefcaseManager.delete should work in offline scenarios.
|
|
927
995
|
- Remove deprecated members of SectionLocation and downgrade to alpha pending refactor.
|
|
928
996
|
- Support for progress/cancel from ios
|
|
929
997
|
- Remove deprecated ExportGraphics types etc for 2.0
|
|
930
|
-
- Updated docs.
|
|
998
|
+
- Updated docs.
|
|
931
999
|
- IModelDb.findByKey replaces IModelDb.find
|
|
932
1000
|
- Include model extents with ViewStateProps for drawing views.
|
|
933
1001
|
- Remove deprecated APIs; see NextVersion.md for details.
|
|
@@ -948,29 +1016,29 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
948
1016
|
- Introduce the BriefcaseIModelDb class, make IModelDb abstract.
|
|
949
1017
|
- Cleaned up unused async-s in BriefcaseManager
|
|
950
1018
|
- Avoided casting of BriefcaseProps to IModelRpcProps.
|
|
951
|
-
- Added NativeApp.deleteBriefcase, avoided authorization exceptions when offline.
|
|
1019
|
+
- Added NativeApp.deleteBriefcase, avoided authorization exceptions when offline.
|
|
952
1020
|
- Move briefcase property from IModelDb --> BriefcaseIModelDb
|
|
953
1021
|
- BriefcaseId is now an enum instead of a class
|
|
954
1022
|
- 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.
|
|
1023
|
+
- VSTS#297017: Update cached briefcase information if changes were applied.
|
|
1024
|
+
- Refactored NativeApp API and RPC interfaces. This continues to be WIP.
|
|
1025
|
+
- 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.
|
|
1026
|
+
- Added DownloadBriefcaseOptions and OpenBriefcaseOptions as parameters to the download/open calls for a briefcase.
|
|
959
1027
|
- Removed BriefcaseDb.create
|
|
960
|
-
- Setup ability to use NativeApp.openBriefcase() in offline scenarios.
|
|
1028
|
+
- Setup ability to use NativeApp.openBriefcase() in offline scenarios.
|
|
961
1029
|
- fixed flaky test
|
|
962
|
-
- VSTS#217447, 162382: Cleanups to implementation of downloading/opening/discovering briefcases in native applications (WIP).
|
|
1030
|
+
- VSTS#217447, 162382: Cleanups to implementation of downloading/opening/discovering briefcases in native applications (WIP).
|
|
963
1031
|
- do not throw exception in NativeAppBackend.startup()
|
|
964
|
-
- VSTS#296110: Setup a way to close briefcases when the native application is offline.
|
|
1032
|
+
- VSTS#296110: Setup a way to close briefcases when the native application is offline.
|
|
965
1033
|
- Move concurrencyControl from IModelDb to BriefcaseIModelDb
|
|
966
1034
|
- Renamed OIDC constructs for consistency; Removed SAML support.
|
|
967
1035
|
- Add support for password-protecting snapshot iModels
|
|
968
1036
|
- Fixed typo for ElementAspect perf tests
|
|
969
|
-
- VSTS#217447, VSTS#162382: Reinstated option to open briefcases with SyncMode = PullOnly.
|
|
1037
|
+
- VSTS#217447, VSTS#162382: Reinstated option to open briefcases with SyncMode = PullOnly.
|
|
970
1038
|
- Add purge dir method to iModelJsFs
|
|
971
1039
|
- react to creation of new clients packages from imodeljs-clients
|
|
972
1040
|
- ; substitute current date for feature usage without any set start/end dates
|
|
973
|
-
- Removed deprecated utilities.
|
|
1041
|
+
- Removed deprecated utilities.
|
|
974
1042
|
- enforce opening Snapshots readonly through StandaloneDb
|
|
975
1043
|
- Remove the deprecated Entity.clone method
|
|
976
1044
|
- Adjusted calls to some node addon changes (ECUtils removed)
|
|
@@ -982,13 +1050,13 @@ Wed, 06 May 2020 13:17:49 GMT
|
|
|
982
1050
|
- Add FileNameResolver class
|
|
983
1051
|
- Move snapshot methods out of IModelDb and into new SnapshotIModelDb class.
|
|
984
1052
|
- Add TemplateModelCloner to place instances of a template model
|
|
985
|
-
- Renamed TestOidcClient and related constructs for consistency.
|
|
1053
|
+
- Renamed TestOidcClient and related constructs for consistency.
|
|
986
1054
|
- Add IModelDb.tryPrepareStatement
|
|
987
|
-
- Fixed usage logging.
|
|
1055
|
+
- Fixed usage logging.
|
|
988
1056
|
- fix failing ulas tests due to invalid featureId
|
|
989
1057
|
- update ULAS test logging & feedback
|
|
990
1058
|
- Update UlasUtilities to support exception-throwing native functions
|
|
991
|
-
- Use standalone briefcases for PullOnly cases.
|
|
1059
|
+
- Use standalone briefcases for PullOnly cases.
|
|
992
1060
|
|
|
993
1061
|
## 1.14.1
|
|
994
1062
|
Wed, 22 Apr 2020 19:04:00 GMT
|
|
@@ -1003,7 +1071,7 @@ Tue, 31 Mar 2020 15:44:19 GMT
|
|
|
1003
1071
|
### Updates
|
|
1004
1072
|
|
|
1005
1073
|
- 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.
|
|
1074
|
+
- Fixed downloading of files using https/streaming to resolve when the filestream is closed instead of when the input stream is exhausted.
|
|
1007
1075
|
- Add handling for invalid predecessor ids to IModelTransformer
|
|
1008
1076
|
- Accomodate updated imodeljs-native ULAS functions
|
|
1009
1077
|
|
|
@@ -1018,7 +1086,7 @@ Wed, 12 Feb 2020 17:45:50 GMT
|
|
|
1018
1086
|
### Updates
|
|
1019
1087
|
|
|
1020
1088
|
- Fix IGeometry roundtripping issue through ECSql. Fix insert/update binary properties for Element Aspect.
|
|
1021
|
-
- Separated out routines to download and open briefcases.
|
|
1089
|
+
- Separated out routines to download and open briefcases.
|
|
1022
1090
|
- bulk mode
|
|
1023
1091
|
- Consolidated sign-in for integration tests
|
|
1024
1092
|
- bulkmode
|
|
@@ -1029,7 +1097,7 @@ Wed, 12 Feb 2020 17:45:50 GMT
|
|
|
1029
1097
|
- Add ViewDefinition.getAuxiliaryCoordinateSystemId and ViewDefinition.setAuxiliaryCoordinateSystemId methods
|
|
1030
1098
|
- Add SpatialLocationModel.insert
|
|
1031
1099
|
- Add optional isPlantProjection parameter to PhysicalModel.insert
|
|
1032
|
-
- VSTS#256133: Fixed issue with reopening connections if the backend crashes. Fixes to integration tests.
|
|
1100
|
+
- VSTS#256133: Fixed issue with reopening connections if the backend crashes. Fixes to integration tests.
|
|
1033
1101
|
- Better documentation of OidcDesktopClient
|
|
1034
1102
|
- Fixed changeset perf test by using another iModel on Hub
|
|
1035
1103
|
- Add ViewDetails to ViewDefinition.
|
|
@@ -1062,7 +1130,7 @@ Tue, 07 Jan 2020 19:44:01 GMT
|
|
|
1062
1130
|
- Allow events to be sent from backend to frontend
|
|
1063
1131
|
- Add tryGetInstance / tryGetInstanceProps methods to the Relationship class which return undefined rather than throwing an exception when a relationship is not found.
|
|
1064
1132
|
- 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.
|
|
1133
|
+
- VSTS#225894 - Allowed agents to bypass usage logging calls. These cause usage logging errors.
|
|
1066
1134
|
- Add tryGetElement / tryGetElementProps which return undefined rather than throwing an exception when an element is not found.
|
|
1067
1135
|
- Add tryGetModel, tryGetModelProps, tryGetSubModel which return undefined instead of throwing exceptions when the model is not found.
|
|
1068
1136
|
|
|
@@ -1074,7 +1142,7 @@ Tue, 10 Dec 2019 18:08:56 GMT
|
|
|
1074
1142
|
- Updated to addon 9.1.3
|
|
1075
1143
|
- Added AliCloud tile cache service
|
|
1076
1144
|
- Added framework to run imodeljs-backend test on ios using appcenter
|
|
1077
|
-
- Setup OidcDesktopClient for Electron use cases.
|
|
1145
|
+
- Setup OidcDesktopClient for Electron use cases.
|
|
1078
1146
|
- fix warnings from static analysis
|
|
1079
1147
|
- Enabling testing code for updating LR aspects after fix in native side.
|
|
1080
1148
|
- Addressing typo in a couple of members, making them match the schema properly.
|
|
@@ -1130,9 +1198,9 @@ Mon, 30 Sep 2019 22:28:48 GMT
|
|
|
1130
1198
|
### Updates
|
|
1131
1199
|
|
|
1132
1200
|
- 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.
|
|
1201
|
+
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1202
|
+
- Error log when downloading change sets should include iModelId for context.
|
|
1203
|
+
- Fixed the iModelHub client to properly dispose a file handle after upload to the iModelHub.
|
|
1136
1204
|
- Add IModelDb.Elements.hasSubModel
|
|
1137
1205
|
- Make ExternalSourceAspect.checksum optional
|
|
1138
1206
|
- Clear statement cache after schema import
|
|
@@ -1147,14 +1215,14 @@ Tue, 10 Sep 2019 12:09:49 GMT
|
|
|
1147
1215
|
|
|
1148
1216
|
### Updates
|
|
1149
1217
|
|
|
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.
|
|
1218
|
+
- Setup a way to supply authorization through the backend for frontend requests.
|
|
1219
|
+
- Allow attaching change cache file before change summary extraction.
|
|
1220
|
+
- Added change summary test, and improved doc a little.
|
|
1153
1221
|
- Add minimum brep size option to IModelDb.exportGraphics
|
|
1154
1222
|
- FunctionalSchema.importSchema is now deprecated.
|
|
1155
1223
|
- Add support for GeometricModel.geometryGuid for detecting whether tiles for a model can be reused across versions
|
|
1156
1224
|
- 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.
|
|
1225
|
+
- 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
1226
|
- Add method to create view with camera
|
|
1159
1227
|
- Fixed misleading logging output in tile upload
|
|
1160
1228
|
|
|
@@ -1164,14 +1232,14 @@ Tue, 13 Aug 2019 20:25:53 GMT
|
|
|
1164
1232
|
### Updates
|
|
1165
1233
|
|
|
1166
1234
|
- 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.
|
|
1235
|
+
- Always acquire a briefcase when creating a new backend instance for PullAndPush workflows.
|
|
1236
|
+
- Added Change Summary integration test, and fixed documentation.
|
|
1169
1237
|
- Trial code for tile upload errors
|
|
1170
1238
|
- Fixed changeset performance tests
|
|
1171
1239
|
- Tile upload logging.
|
|
1172
1240
|
- Mark ExportGraphics API as public
|
|
1173
1241
|
- Support for gzip compression of tiles
|
|
1174
|
-
- Fixed issue with opening iModels with names that are invalid on Unix or Windows.
|
|
1242
|
+
- Fixed issue with opening iModels with names that are invalid on Unix or Windows.
|
|
1175
1243
|
- Add IModelDb.isSnapshot
|
|
1176
1244
|
- Tile upload error catching.
|
|
1177
1245
|
- Azure tile upload logging
|
|
@@ -1183,7 +1251,7 @@ Wed, 24 Jul 2019 11:47:26 GMT
|
|
|
1183
1251
|
### Updates
|
|
1184
1252
|
|
|
1185
1253
|
- Added option to restrict tile cache URLs by client IP address.
|
|
1186
|
-
- Apply change sets at the backend in a non-blocking worker thread.
|
|
1254
|
+
- Apply change sets at the backend in a non-blocking worker thread.
|
|
1187
1255
|
- Add ElementAspect handler methods
|
|
1188
1256
|
- When deleting a parent element, make sure there are onDelete/onDeleted callbacks for child elements
|
|
1189
1257
|
- Add support for linework to IModelDb.exportGraphics
|
|
@@ -1201,19 +1269,19 @@ Mon, 01 Jul 2019 19:04:29 GMT
|
|
|
1201
1269
|
|
|
1202
1270
|
### Updates
|
|
1203
1271
|
|
|
1204
|
-
- Open fixes when briefcase requires merges.
|
|
1272
|
+
- Open fixes when briefcase requires merges.
|
|
1205
1273
|
- Catch tile upload errors.
|
|
1206
|
-
- Setting up briefcase is always from an older checkpoint.
|
|
1274
|
+
- Setting up briefcase is always from an older checkpoint.
|
|
1207
1275
|
- Add materialId, subCategory to ExportGraphicsInfo
|
|
1208
|
-
- Fix crash in getViewThumbnail for odd number of bytes
|
|
1276
|
+
- Fix crash in getViewThumbnail for odd number of bytes
|
|
1209
1277
|
- Adding relationship class for GraphicalElement3dRepresentsElement.
|
|
1210
1278
|
- Initial implementation of the LinearReferencing typescript domain
|
|
1211
1279
|
- Adding domain classes for all relatinships in the LinearReferencing schema.
|
|
1212
1280
|
- 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.
|
|
1281
|
+
- Fixes to opening iModel-s ReadWrite from mutiple IModelConnection-s.
|
|
1282
|
+
- Fixed issues with deleting briefcases if there were errors with preparing briefcases.
|
|
1215
1283
|
- Add a new method `forceLoadSchemas` to `IModelJsNative.ECPresentationManager`.
|
|
1216
|
-
- Introduced AsyncMutex - a utility to run async blocks of code in sequence.
|
|
1284
|
+
- Introduced AsyncMutex - a utility to run async blocks of code in sequence.
|
|
1217
1285
|
- Properly document ModelSelector.models and CategorySelector.categories as Id64String arrays
|
|
1218
1286
|
- Made `insertElement` not return Id64.invalid, throws error instead
|
|
1219
1287
|
- Update to TypeScript 3.5
|
|
@@ -1224,7 +1292,7 @@ Mon, 03 Jun 2019 18:09:39 GMT
|
|
|
1224
1292
|
|
|
1225
1293
|
### Updates
|
|
1226
1294
|
|
|
1227
|
-
- Migrated agent applications to the newer client
|
|
1295
|
+
- Migrated agent applications to the newer client
|
|
1228
1296
|
- RPC system now accepts only basic values (primitives, "interface" objects, and binary).
|
|
1229
1297
|
- Switched from iModelHub Project API to Context API
|
|
1230
1298
|
- Fix bug in IModelDb.createSnapshotFromSeed
|
|
@@ -1272,12 +1340,12 @@ Mon, 13 May 2019 15:52:05 GMT
|
|
|
1272
1340
|
- Cleanup old imodelbank references
|
|
1273
1341
|
- Add InformationRecordModel.insert, GroupModel.insert
|
|
1274
1342
|
- Introduce LoggerCategory enum to advertise logger categories used by this package.
|
|
1275
|
-
- Limited maximum cache size of the backend PromiseMemoizer.
|
|
1343
|
+
- Limited maximum cache size of the backend PromiseMemoizer.
|
|
1276
1344
|
- Missing dependency on node-report
|
|
1277
|
-
- Fixed memoization problem that caused an endless stream of 404 NotFound errors.
|
|
1345
|
+
- Fixed memoization problem that caused an endless stream of 404 NotFound errors.
|
|
1278
1346
|
- 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.
|
|
1347
|
+
- Unauthorized open requests should cause a more obvious error.
|
|
1348
|
+
- Improved performance logging, especially of IModelDb open operations; ChangeSets are merged one-by-one to prevent hogging the event loop.
|
|
1281
1349
|
- Memoization fix when opening iModels in shared, read-only mode .
|
|
1282
1350
|
- Fixed setup of application version.
|
|
1283
1351
|
- Updated Element CRUD perf tests
|
|
@@ -1287,7 +1355,7 @@ Mon, 13 May 2019 15:52:05 GMT
|
|
|
1287
1355
|
- Remove ElementPropertyFormatter, IModelDb.getElementPropertiesForDisplay (use presentation rules instead)
|
|
1288
1356
|
- Remove StandaloneIModelRpcImpl
|
|
1289
1357
|
- 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.
|
|
1358
|
+
- Setup a generic context for tracking client requests, and made various related enhancements to logging, usage tracking and authorization.
|
|
1291
1359
|
- Add IModelDb.createSnapshot/openSnapshot/closeSnapshot, deprecate IModelDb.createStandalone/openStandalone/closeStandalone
|
|
1292
1360
|
- Moved IModelJsExpressServer class into a new package (@itwin/express-server).
|
|
1293
1361
|
- Simplified tile caching IModelHost config and removed dev flags. Allow
|
|
@@ -1314,7 +1382,7 @@ Wed, 06 Mar 2019 15:41:22 GMT
|
|
|
1314
1382
|
- Changes package.json to include api-extractor and adds api-extractor.json
|
|
1315
1383
|
- Use new buildIModelJsBuild script
|
|
1316
1384
|
- 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.
|
|
1385
|
+
- 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
1386
|
- Clone methods are no longer generic
|
|
1319
1387
|
- Remove unneeded typedoc plugin dependency
|
|
1320
1388
|
- Added spatial <-> cartographic methods that check/use the geographic coordinate system before using ecef location.
|
|
@@ -1359,8 +1427,8 @@ Mon, 14 Jan 2019 23:09:10 GMT
|
|
|
1359
1427
|
|
|
1360
1428
|
### Updates
|
|
1361
1429
|
|
|
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.
|
|
1430
|
+
- More logging of HTTP requests, and enabled use of fiddler for backend diagnostics.
|
|
1431
|
+
- 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
1432
|
- Renamed RequestProxy->RequestHost. Allowed applications to configure proxy server with HTTPS_PROXY env.
|
|
1365
1433
|
- Add backend TextureAPI and accompanying test
|
|
1366
1434
|
|
|
@@ -1465,7 +1533,7 @@ Mon, 03 Dec 2018 18:52:58 GMT
|
|
|
1465
1533
|
|
|
1466
1534
|
### Updates
|
|
1467
1535
|
|
|
1468
|
-
- More information logged from BriefcaseManager.\nFixed deletion/cleanup of invalid briefcases.\nAdded OIDC support for simpleviewtest application.
|
|
1536
|
+
- More information logged from BriefcaseManager.\nFixed deletion/cleanup of invalid briefcases.\nAdded OIDC support for simpleviewtest application.
|
|
1469
1537
|
- Add ElementRefersToElements.insert
|
|
1470
1538
|
- Fixed front end integration tests.
|
|
1471
1539
|
- Document the intended purpose of IModelJsExpressServer within a deployment environment.
|
|
@@ -1534,11 +1602,11 @@ Thu, 08 Nov 2018 17:59:20 GMT
|
|
|
1534
1602
|
|
|
1535
1603
|
- Fix JSON representation of DisplayStyle.
|
|
1536
1604
|
- Add IModelImporter as a base class for utility methods needed by all importers
|
|
1537
|
-
- Removed assertion when deleting a memoized open call.
|
|
1605
|
+
- Removed assertion when deleting a memoized open call.
|
|
1538
1606
|
- Add more methods to IModelImporter
|
|
1539
1607
|
- Fix snapping test
|
|
1540
1608
|
- OIDC related enhancments (WIP).
|
|
1541
|
-
- Re-enabled several backend integration tests.
|
|
1609
|
+
- Re-enabled several backend integration tests.
|
|
1542
1610
|
- Refactor analysis-importer to use IModelImporter
|
|
1543
1611
|
- Updated to TypeScript 3.1
|
|
1544
1612
|
|
|
@@ -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,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,MAAM,EAAW,MAAM,UAAU,CAAC;AAI3C;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAoC;IACrE,gBAAgB;WACF,eAAe,CAAC,GAAG,EAAE,GAAG;IACtC,gBAAgB;WACF,yBAAyB,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW;IACvE,gBAAgB;WACF,QAAQ,CAAC,WAAW,EAAE,OAAO,MAAM,EAAE,MAAM,EAAE,OAAO,MAAM;IAYxE,yEAAyE;IACzE,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAqBlC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAyFrC;;;OAGG;WACW,cAAc,CAAC,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,MAAM;IAQlE;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAa5B;;;;OAIG;WACW,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,MAAM,GAAG,SAAS;IAInF;;;;OAIG;WACW,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,MAAM;IAM9E;;;;;OAKG;WACW,eAAe,CAAC,aAAa,EAAE,MAAM;IACnD;;;;OAIG;WACW,qBAAqB,CAAC,MAAM,EAAE,OAAO,MAAM;CAM1D;AAED;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,SAAS,CAAkE;IAEnF,wCAAwC;IACjC,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAE9D,gCAAgC;IACzB,GAAG,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,IAAI;CAClE"}
|
package/lib/cjs/ClassRegistry.js
CHANGED
|
@@ -11,7 +11,9 @@ exports.MetaDataRegistry = exports.ClassRegistry = void 0;
|
|
|
11
11
|
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,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjK,gBAAgB;IACT,MAAM,CAAC,QAAQ,CAAC,WAA0B,EAAE,MAAqB;QACtE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,SAAS,GAAG,4FAA4F,WAAW,CAAC,IAAI,EAAE,CAAC;YAC1I,qBAAM,CAAC,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;YACvD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;SACzB;QAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;I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C,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC;IACnH;;;;OAIG;IACI,MAAM,CAAC,qBAAqB,CAAC,MAAqB;QACvD,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AA9IH,sCA+IC;AA9IyB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAgJvE;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,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,GAAG,CAAC,WAAW,KAAK,2BAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC/H,gBAAgB;IACT,MAAM,CAAC,yBAAyB,CAAC,SAAiB,IAAiB,OAAO,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,0BAA0B,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IACjK,gBAAgB;IACT,MAAM,CAAC,QAAQ,CAAC,WAA0B,EAAE,MAAqB;QACtE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC;QAC5B,MAAM,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC,UAAU,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC5E,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,SAAS,GAAG,4FAA4F,WAAW,CAAC,IAAI,EAAE,CAAC;YAC1I,qBAAM,CAAC,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC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AK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC9C,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM;gBAC5B,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAClC;IACH,CAAC;;AAvMH,sCAwMC;AAvMyB,uBAAS,GAAG,IAAI,GAAG,EAAyB,CAAC;AAyMvE;;;GAGG;AACH,MAAa,gBAAgB;IAA7B;QACU,cAAS,GAAgC,IAAI,GAAG,EAA0B,CAAC;IAOrF,CAAC;IALC,wCAAwC;IACjC,IAAI,CAAC,aAAqB,IAAgC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,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, 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"]}
|