@rapidrest/service-core 1.0.0-beta.1
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/LICENSE +23 -0
- package/README.md +16 -0
- package/dist/lib/ApiErrors.js +41 -0
- package/dist/lib/ApiErrors.js.map +1 -0
- package/dist/lib/BackgroundService.js +16 -0
- package/dist/lib/BackgroundService.js.map +1 -0
- package/dist/lib/BackgroundServiceManager.js +135 -0
- package/dist/lib/BackgroundServiceManager.js.map +1 -0
- package/dist/lib/BulkError.js +24 -0
- package/dist/lib/BulkError.js.map +1 -0
- package/dist/lib/EventListenerManager.js +161 -0
- package/dist/lib/EventListenerManager.js.map +1 -0
- package/dist/lib/NetUtils.js +103 -0
- package/dist/lib/NetUtils.js.map +1 -0
- package/dist/lib/NotificationUtils.js +34 -0
- package/dist/lib/NotificationUtils.js.map +1 -0
- package/dist/lib/ObjectFactory.js +90 -0
- package/dist/lib/ObjectFactory.js.map +1 -0
- package/dist/lib/OpenApiSpec.js +748 -0
- package/dist/lib/OpenApiSpec.js.map +1 -0
- package/dist/lib/Server.js +549 -0
- package/dist/lib/Server.js.map +1 -0
- package/dist/lib/Types.js +2 -0
- package/dist/lib/Types.js.map +1 -0
- package/dist/lib/auth/AuthMiddleware.js +229 -0
- package/dist/lib/auth/AuthMiddleware.js.map +1 -0
- package/dist/lib/auth/AuthStrategy.js +2 -0
- package/dist/lib/auth/AuthStrategy.js.map +1 -0
- package/dist/lib/auth/BasicStrategy.js +106 -0
- package/dist/lib/auth/BasicStrategy.js.map +1 -0
- package/dist/lib/auth/JWTStrategy.js +161 -0
- package/dist/lib/auth/JWTStrategy.js.map +1 -0
- package/dist/lib/auth/index.js +5 -0
- package/dist/lib/auth/index.js.map +1 -0
- package/dist/lib/database/ConnectionKinds.js +14 -0
- package/dist/lib/database/ConnectionKinds.js.map +1 -0
- package/dist/lib/database/ConnectionManager.js +161 -0
- package/dist/lib/database/ConnectionManager.js.map +1 -0
- package/dist/lib/database/MongoConnection.js +86 -0
- package/dist/lib/database/MongoConnection.js.map +1 -0
- package/dist/lib/database/MongoRepository.js +136 -0
- package/dist/lib/database/MongoRepository.js.map +1 -0
- package/dist/lib/database/MongoSchemaSync.js +136 -0
- package/dist/lib/database/MongoSchemaSync.js.map +1 -0
- package/dist/lib/database/NamingUtils.js +52 -0
- package/dist/lib/database/NamingUtils.js.map +1 -0
- package/dist/lib/database/TypeOrmSupport.js +146 -0
- package/dist/lib/database/TypeOrmSupport.js.map +1 -0
- package/dist/lib/database/index.js +7 -0
- package/dist/lib/database/index.js.map +1 -0
- package/dist/lib/decorators/DatabaseDecorators.js +52 -0
- package/dist/lib/decorators/DatabaseDecorators.js.map +1 -0
- package/dist/lib/decorators/DocDecorators.js +120 -0
- package/dist/lib/decorators/DocDecorators.js.map +1 -0
- package/dist/lib/decorators/EventDecorators.js +24 -0
- package/dist/lib/decorators/EventDecorators.js.map +1 -0
- package/dist/lib/decorators/ModelDecorators.js +173 -0
- package/dist/lib/decorators/ModelDecorators.js.map +1 -0
- package/dist/lib/decorators/PersistenceDecorators.js +177 -0
- package/dist/lib/decorators/PersistenceDecorators.js.map +1 -0
- package/dist/lib/decorators/RouteDecorators.js +324 -0
- package/dist/lib/decorators/RouteDecorators.js.map +1 -0
- package/dist/lib/decorators/index.js +7 -0
- package/dist/lib/decorators/index.js.map +1 -0
- package/dist/lib/http/Adapters.js +230 -0
- package/dist/lib/http/Adapters.js.map +1 -0
- package/dist/lib/http/Router.js +403 -0
- package/dist/lib/http/Router.js.map +1 -0
- package/dist/lib/http/WebSocket.js +82 -0
- package/dist/lib/http/WebSocket.js.map +1 -0
- package/dist/lib/http/index.js +4 -0
- package/dist/lib/http/index.js.map +1 -0
- package/dist/lib/http/types.js +5 -0
- package/dist/lib/http/types.js.map +1 -0
- package/dist/lib/index.js +18 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/models/BaseEntity.js +83 -0
- package/dist/lib/models/BaseEntity.js.map +1 -0
- package/dist/lib/models/BaseMongoEntity.js +40 -0
- package/dist/lib/models/BaseMongoEntity.js.map +1 -0
- package/dist/lib/models/ModelUtils.js +645 -0
- package/dist/lib/models/ModelUtils.js.map +1 -0
- package/dist/lib/models/RecoverableBaseEntity.js +39 -0
- package/dist/lib/models/RecoverableBaseEntity.js.map +1 -0
- package/dist/lib/models/RecoverableBaseMongoEntity.js +40 -0
- package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -0
- package/dist/lib/models/RepoUtils.js +717 -0
- package/dist/lib/models/RepoUtils.js.map +1 -0
- package/dist/lib/models/SimpleEntity.js +42 -0
- package/dist/lib/models/SimpleEntity.js.map +1 -0
- package/dist/lib/models/SimpleMongoEntity.js +38 -0
- package/dist/lib/models/SimpleMongoEntity.js.map +1 -0
- package/dist/lib/models/StatusExtraData.js +15 -0
- package/dist/lib/models/StatusExtraData.js.map +1 -0
- package/dist/lib/models/index.js +10 -0
- package/dist/lib/models/index.js.map +1 -0
- package/dist/lib/routes/AdminRoute.js +268 -0
- package/dist/lib/routes/AdminRoute.js.map +1 -0
- package/dist/lib/routes/MetricsRoute.js +86 -0
- package/dist/lib/routes/MetricsRoute.js.map +1 -0
- package/dist/lib/routes/ModelRoute.js +481 -0
- package/dist/lib/routes/ModelRoute.js.map +1 -0
- package/dist/lib/routes/OpenAPIRoute.js +115 -0
- package/dist/lib/routes/OpenAPIRoute.js.map +1 -0
- package/dist/lib/routes/RouteUtils.js +445 -0
- package/dist/lib/routes/RouteUtils.js.map +1 -0
- package/dist/lib/routes/StatusRoute.js +55 -0
- package/dist/lib/routes/StatusRoute.js.map +1 -0
- package/dist/lib/routes/index.js +7 -0
- package/dist/lib/routes/index.js.map +1 -0
- package/dist/lib/security/ACLRouteMongo.js +194 -0
- package/dist/lib/security/ACLRouteMongo.js.map +1 -0
- package/dist/lib/security/ACLRouteSQL.js +193 -0
- package/dist/lib/security/ACLRouteSQL.js.map +1 -0
- package/dist/lib/security/ACLUtils.js +457 -0
- package/dist/lib/security/ACLUtils.js.map +1 -0
- package/dist/lib/security/AccessControlList.js +18 -0
- package/dist/lib/security/AccessControlList.js.map +1 -0
- package/dist/lib/security/AccessControlListMongo.js +155 -0
- package/dist/lib/security/AccessControlListMongo.js.map +1 -0
- package/dist/lib/security/AccessControlListSQL.js +149 -0
- package/dist/lib/security/AccessControlListSQL.js.map +1 -0
- package/dist/lib/security/index.js +3 -0
- package/dist/lib/security/index.js.map +1 -0
- package/dist/lib/test/index.js +3 -0
- package/dist/lib/test/index.js.map +1 -0
- package/dist/lib/test/request.js +99 -0
- package/dist/lib/test/request.js.map +1 -0
- package/dist/lib/test/requestws.js +173 -0
- package/dist/lib/test/requestws.js.map +1 -0
- package/dist/types/ApiErrors.d.ts +38 -0
- package/dist/types/BackgroundService.d.ts +30 -0
- package/dist/types/BackgroundServiceManager.d.ts +66 -0
- package/dist/types/BulkError.d.ts +11 -0
- package/dist/types/EventListenerManager.d.ts +36 -0
- package/dist/types/NetUtils.d.ts +29 -0
- package/dist/types/NotificationUtils.d.ts +25 -0
- package/dist/types/ObjectFactory.d.ts +17 -0
- package/dist/types/OpenApiSpec.d.ts +114 -0
- package/dist/types/Server.d.ts +180 -0
- package/dist/types/Types.d.ts +8 -0
- package/dist/types/auth/AuthMiddleware.d.ts +42 -0
- package/dist/types/auth/AuthStrategy.d.ts +32 -0
- package/dist/types/auth/BasicStrategy.d.ts +33 -0
- package/dist/types/auth/JWTStrategy.d.ts +61 -0
- package/dist/types/auth/index.d.ts +4 -0
- package/dist/types/database/ConnectionKinds.d.ts +7 -0
- package/dist/types/database/ConnectionManager.d.ts +35 -0
- package/dist/types/database/MongoConnection.d.ts +54 -0
- package/dist/types/database/MongoRepository.d.ts +92 -0
- package/dist/types/database/MongoSchemaSync.d.ts +41 -0
- package/dist/types/database/NamingUtils.d.ts +24 -0
- package/dist/types/database/TypeOrmSupport.d.ts +20 -0
- package/dist/types/database/index.d.ts +6 -0
- package/dist/types/decorators/DatabaseDecorators.d.ts +18 -0
- package/dist/types/decorators/DocDecorators.d.ts +69 -0
- package/dist/types/decorators/EventDecorators.d.ts +12 -0
- package/dist/types/decorators/ModelDecorators.d.ts +80 -0
- package/dist/types/decorators/PersistenceDecorators.d.ts +117 -0
- package/dist/types/decorators/RouteDecorators.d.ts +172 -0
- package/dist/types/decorators/index.d.ts +6 -0
- package/dist/types/http/Adapters.d.ts +68 -0
- package/dist/types/http/Router.d.ts +99 -0
- package/dist/types/http/WebSocket.d.ts +56 -0
- package/dist/types/http/index.d.ts +6 -0
- package/dist/types/http/types.d.ts +54 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/models/BaseEntity.d.ts +29 -0
- package/dist/types/models/BaseMongoEntity.d.ts +13 -0
- package/dist/types/models/ModelUtils.d.ts +166 -0
- package/dist/types/models/RecoverableBaseEntity.d.ts +16 -0
- package/dist/types/models/RecoverableBaseMongoEntity.d.ts +16 -0
- package/dist/types/models/RepoUtils.d.ts +154 -0
- package/dist/types/models/SimpleEntity.d.ts +14 -0
- package/dist/types/models/SimpleMongoEntity.d.ts +15 -0
- package/dist/types/models/StatusExtraData.d.ts +6 -0
- package/dist/types/models/index.d.ts +9 -0
- package/dist/types/routes/AdminRoute.d.ts +47 -0
- package/dist/types/routes/MetricsRoute.d.ts +15 -0
- package/dist/types/routes/ModelRoute.d.ts +226 -0
- package/dist/types/routes/OpenAPIRoute.d.ts +17 -0
- package/dist/types/routes/RouteUtils.d.ts +55 -0
- package/dist/types/routes/StatusRoute.d.ts +11 -0
- package/dist/types/routes/index.d.ts +6 -0
- package/dist/types/security/ACLRouteMongo.d.ts +19 -0
- package/dist/types/security/ACLRouteSQL.d.ts +19 -0
- package/dist/types/security/ACLUtils.d.ts +94 -0
- package/dist/types/security/AccessControlList.d.ts +103 -0
- package/dist/types/security/AccessControlListMongo.d.ts +24 -0
- package/dist/types/security/AccessControlListSQL.d.ts +24 -0
- package/dist/types/security/index.d.ts +2 -0
- package/dist/types/test/index.d.ts +2 -0
- package/dist/types/test/request.d.ts +24 -0
- package/dist/types/test/requestws.d.ts +21 -0
- package/docs/Makefile +20 -0
- package/docs/conf.py +58 -0
- package/docs/index.rst +17 -0
- package/docs/make.bat +35 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +13 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +23 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +28 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +25 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +28 -0
- package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +57 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +12 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +17 -0
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +18 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +35 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +25 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +27 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +26 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +45 -0
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +14 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +119 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +25 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +68 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +26 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +27 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +41 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +51 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +41 -0
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +51 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +36 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +33 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +26 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +33 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +31 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +25 -0
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +25 -0
- package/docs/reference/README.md +20 -0
- package/docs/reference/classes/ACLUtils.md +251 -0
- package/docs/reference/classes/AdminRoute.md +51 -0
- package/docs/reference/classes/AuthMiddleware.md +131 -0
- package/docs/reference/classes/BackgroundService.md +117 -0
- package/docs/reference/classes/BackgroundServiceManager.md +172 -0
- package/docs/reference/classes/BaseEntity.md +82 -0
- package/docs/reference/classes/BaseMongoEntity.md +107 -0
- package/docs/reference/classes/BasicStrategy.md +89 -0
- package/docs/reference/classes/BasicStrategyOptions.md +91 -0
- package/docs/reference/classes/BulkError.md +271 -0
- package/docs/reference/classes/ConnectionManager.md +75 -0
- package/docs/reference/classes/EventListenerManager.md +88 -0
- package/docs/reference/classes/JWTStrategy.md +77 -0
- package/docs/reference/classes/JWTStrategyOptions.md +97 -0
- package/docs/reference/classes/MetricsRoute.md +27 -0
- package/docs/reference/classes/ModelRoute.md +527 -0
- package/docs/reference/classes/ModelUtils.md +448 -0
- package/docs/reference/classes/MongoConnection.md +218 -0
- package/docs/reference/classes/MongoRepository.md +354 -0
- package/docs/reference/classes/MongoSchemaSync.md +67 -0
- package/docs/reference/classes/NetUtils.md +90 -0
- package/docs/reference/classes/NotificationUtils.md +77 -0
- package/docs/reference/classes/ObjectFactory.md +336 -0
- package/docs/reference/classes/OpenAPIRoute.md +77 -0
- package/docs/reference/classes/OpenApiSpec.md +892 -0
- package/docs/reference/classes/RecoverableBaseEntity.md +114 -0
- package/docs/reference/classes/RecoverableBaseMongoEntity.md +124 -0
- package/docs/reference/classes/RedisTransport.md +2202 -0
- package/docs/reference/classes/RepoUtils.md +486 -0
- package/docs/reference/classes/RouteUtils.md +191 -0
- package/docs/reference/classes/Server.md +408 -0
- package/docs/reference/classes/SimpleEntity.md +48 -0
- package/docs/reference/classes/SimpleMongoEntity.md +66 -0
- package/docs/reference/classes/StatusExtraData.md +57 -0
- package/docs/reference/classes/StatusRoute.md +26 -0
- package/docs/reference/enumerations/ACLAction.md +63 -0
- package/docs/reference/enumerations/ApiErrorMessages.md +123 -0
- package/docs/reference/enumerations/ApiErrors.md +123 -0
- package/docs/reference/functions/isSqlDataSource.md +26 -0
- package/docs/reference/functions/resolveCollectionName.md +33 -0
- package/docs/reference/functions/snakeCase.md +28 -0
- package/docs/reference/globals.md +91 -0
- package/docs/reference/interfaces/ACLRecord.md +96 -0
- package/docs/reference/interfaces/AccessControlList.md +76 -0
- package/docs/reference/interfaces/AuthResult.md +55 -0
- package/docs/reference/interfaces/AuthStrategy.md +57 -0
- package/docs/reference/interfaces/CreateRequestOptions.md +121 -0
- package/docs/reference/interfaces/DeleteRequestOptions.md +147 -0
- package/docs/reference/interfaces/FindRequestOptions.md +133 -0
- package/docs/reference/interfaces/JWTAuthResult.md +84 -0
- package/docs/reference/interfaces/RepoCreateOptions.md +95 -0
- package/docs/reference/interfaces/RepoDeleteOptions.md +115 -0
- package/docs/reference/interfaces/RepoFindOptions.md +135 -0
- package/docs/reference/interfaces/RepoOperationOptions.md +69 -0
- package/docs/reference/interfaces/RepoUpdateOptions.md +111 -0
- package/docs/reference/interfaces/RequestOptions.md +112 -0
- package/docs/reference/interfaces/TruncateRequestOptions.md +175 -0
- package/docs/reference/interfaces/UpdateRequestOptions.md +149 -0
- package/docs/reference/type-aliases/OneOrMany.md +19 -0
- package/docs/reference/type-aliases/OneOrNull.md +19 -0
- package/docs/reference/type-aliases/PartialBaseEntity.md +17 -0
- package/docs/reference/type-aliases/PartialSimpleEntity.md +17 -0
- package/docs/reference/type-aliases/UpdateObject.md +19 -0
- package/package.json +125 -0
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
[**@rapidrest/service-core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/service-core](../globals.md) / RepoUtils
|
|
6
|
+
|
|
7
|
+
# Class: RepoUtils\<T\>
|
|
8
|
+
|
|
9
|
+
Defined in: [src/models/RepoUtils.ts:89](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L89)
|
|
10
|
+
|
|
11
|
+
## Author
|
|
12
|
+
|
|
13
|
+
Jean-Philippe Steinmetz
|
|
14
|
+
|
|
15
|
+
## Type Parameters
|
|
16
|
+
|
|
17
|
+
### T
|
|
18
|
+
|
|
19
|
+
`T` *extends* [`BaseEntity`](BaseEntity.md) \| [`SimpleEntity`](SimpleEntity.md)
|
|
20
|
+
|
|
21
|
+
## Constructors
|
|
22
|
+
|
|
23
|
+
### Constructor
|
|
24
|
+
|
|
25
|
+
> **new RepoUtils**\<`T`\>(`modelClass`, `repo?`): `RepoUtils`\<`T`\>
|
|
26
|
+
|
|
27
|
+
Defined in: [src/models/RepoUtils.ts:123](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L123)
|
|
28
|
+
|
|
29
|
+
#### Parameters
|
|
30
|
+
|
|
31
|
+
##### modelClass
|
|
32
|
+
|
|
33
|
+
`any`
|
|
34
|
+
|
|
35
|
+
##### repo?
|
|
36
|
+
|
|
37
|
+
`Repository`\<`T`\> \| [`MongoRepository`](MongoRepository.md)\<`T`\>
|
|
38
|
+
|
|
39
|
+
#### Returns
|
|
40
|
+
|
|
41
|
+
`RepoUtils`\<`T`\>
|
|
42
|
+
|
|
43
|
+
## Properties
|
|
44
|
+
|
|
45
|
+
### aclUtils?
|
|
46
|
+
|
|
47
|
+
> `protected` `optional` **aclUtils?**: [`ACLUtils`](ACLUtils.md)
|
|
48
|
+
|
|
49
|
+
Defined in: [src/models/RepoUtils.ts:91](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L91)
|
|
50
|
+
|
|
51
|
+
***
|
|
52
|
+
|
|
53
|
+
### cacheClient?
|
|
54
|
+
|
|
55
|
+
> `protected` `optional` **cacheClient?**: `Redis`
|
|
56
|
+
|
|
57
|
+
Defined in: [src/models/RepoUtils.ts:95](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L95)
|
|
58
|
+
|
|
59
|
+
The redis client that will be used as a 2nd level cache for all cacheable models.
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### config
|
|
64
|
+
|
|
65
|
+
> `protected` **config**: `any`
|
|
66
|
+
|
|
67
|
+
Defined in: [src/models/RepoUtils.ts:98](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L98)
|
|
68
|
+
|
|
69
|
+
***
|
|
70
|
+
|
|
71
|
+
### connectionManager?
|
|
72
|
+
|
|
73
|
+
> `protected` `optional` **connectionManager?**: [`ConnectionManager`](ConnectionManager.md)
|
|
74
|
+
|
|
75
|
+
Defined in: [src/models/RepoUtils.ts:101](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L101)
|
|
76
|
+
|
|
77
|
+
***
|
|
78
|
+
|
|
79
|
+
### defaultACLUid
|
|
80
|
+
|
|
81
|
+
> **defaultACLUid**: `string` = `""`
|
|
82
|
+
|
|
83
|
+
Defined in: [src/models/RepoUtils.ts:104](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L104)
|
|
84
|
+
|
|
85
|
+
The unique identifier of the default ACL for the model type.
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### logger
|
|
90
|
+
|
|
91
|
+
> `protected` **logger**: `any`
|
|
92
|
+
|
|
93
|
+
Defined in: [src/models/RepoUtils.ts:107](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L107)
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
### modelClass
|
|
98
|
+
|
|
99
|
+
> `protected` **modelClass**: `any`
|
|
100
|
+
|
|
101
|
+
Defined in: [src/models/RepoUtils.ts:109](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L109)
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
### notificationUtils?
|
|
106
|
+
|
|
107
|
+
> `protected` `optional` **notificationUtils?**: [`NotificationUtils`](NotificationUtils.md)
|
|
108
|
+
|
|
109
|
+
Defined in: [src/models/RepoUtils.ts:115](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L115)
|
|
110
|
+
|
|
111
|
+
***
|
|
112
|
+
|
|
113
|
+
### objectFactory?
|
|
114
|
+
|
|
115
|
+
> `protected` `optional` **objectFactory?**: [`ObjectFactory`](ObjectFactory.md)
|
|
116
|
+
|
|
117
|
+
Defined in: [src/models/RepoUtils.ts:112](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L112)
|
|
118
|
+
|
|
119
|
+
***
|
|
120
|
+
|
|
121
|
+
### repo?
|
|
122
|
+
|
|
123
|
+
> `optional` **repo?**: `Repository`\<`T`\> \| [`MongoRepository`](MongoRepository.md)\<`T`\>
|
|
124
|
+
|
|
125
|
+
Defined in: [src/models/RepoUtils.ts:118](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L118)
|
|
126
|
+
|
|
127
|
+
The model class associated with the controller to perform operations against.
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
### trustedRoles
|
|
132
|
+
|
|
133
|
+
> `protected` **trustedRoles**: `string`[]
|
|
134
|
+
|
|
135
|
+
Defined in: [src/models/RepoUtils.ts:121](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L121)
|
|
136
|
+
|
|
137
|
+
## Accessors
|
|
138
|
+
|
|
139
|
+
### baseCacheKey
|
|
140
|
+
|
|
141
|
+
#### Get Signature
|
|
142
|
+
|
|
143
|
+
> **get** **baseCacheKey**(): `string`
|
|
144
|
+
|
|
145
|
+
Defined in: [src/models/RepoUtils.ts:195](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L195)
|
|
146
|
+
|
|
147
|
+
The base key used to get or set data in the cache.
|
|
148
|
+
|
|
149
|
+
##### Returns
|
|
150
|
+
|
|
151
|
+
`string`
|
|
152
|
+
|
|
153
|
+
## Methods
|
|
154
|
+
|
|
155
|
+
### count()
|
|
156
|
+
|
|
157
|
+
> **count**(`query`, `options?`): `Promise`\<`number`\>
|
|
158
|
+
|
|
159
|
+
Defined in: [src/models/RepoUtils.ts:199](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L199)
|
|
160
|
+
|
|
161
|
+
#### Parameters
|
|
162
|
+
|
|
163
|
+
##### query
|
|
164
|
+
|
|
165
|
+
`any`
|
|
166
|
+
|
|
167
|
+
##### options?
|
|
168
|
+
|
|
169
|
+
[`RepoFindOptions`](../interfaces/RepoFindOptions.md)
|
|
170
|
+
|
|
171
|
+
#### Returns
|
|
172
|
+
|
|
173
|
+
`Promise`\<`number`\>
|
|
174
|
+
|
|
175
|
+
***
|
|
176
|
+
|
|
177
|
+
### create()
|
|
178
|
+
|
|
179
|
+
> **create**(`obj`, `options?`): `Promise`\<`T`\>
|
|
180
|
+
|
|
181
|
+
Defined in: [src/models/RepoUtils.ts:231](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L231)
|
|
182
|
+
|
|
183
|
+
Stores a new record of the provided object in the datastore. Performs pre-processing, permission checks against
|
|
184
|
+
the class ACL, cache seeding, telemetry recording and push notifications.
|
|
185
|
+
|
|
186
|
+
#### Parameters
|
|
187
|
+
|
|
188
|
+
##### obj
|
|
189
|
+
|
|
190
|
+
`Partial`\<`T`\>
|
|
191
|
+
|
|
192
|
+
The object to store.
|
|
193
|
+
|
|
194
|
+
##### options?
|
|
195
|
+
|
|
196
|
+
[`RepoCreateOptions`](../interfaces/RepoCreateOptions.md)
|
|
197
|
+
|
|
198
|
+
#### Returns
|
|
199
|
+
|
|
200
|
+
`Promise`\<`T`\>
|
|
201
|
+
|
|
202
|
+
***
|
|
203
|
+
|
|
204
|
+
### delete()
|
|
205
|
+
|
|
206
|
+
> **delete**(`uid`, `options`): `Promise`\<`void`\>
|
|
207
|
+
|
|
208
|
+
Defined in: [src/models/RepoUtils.ts:324](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L324)
|
|
209
|
+
|
|
210
|
+
#### Parameters
|
|
211
|
+
|
|
212
|
+
##### uid
|
|
213
|
+
|
|
214
|
+
`string`
|
|
215
|
+
|
|
216
|
+
##### options
|
|
217
|
+
|
|
218
|
+
[`RepoDeleteOptions`](../interfaces/RepoDeleteOptions.md)
|
|
219
|
+
|
|
220
|
+
#### Returns
|
|
221
|
+
|
|
222
|
+
`Promise`\<`void`\>
|
|
223
|
+
|
|
224
|
+
***
|
|
225
|
+
|
|
226
|
+
### find()
|
|
227
|
+
|
|
228
|
+
> **find**(`query`, `options?`): `Promise`\<`T`[]\>
|
|
229
|
+
|
|
230
|
+
Defined in: [src/models/RepoUtils.ts:395](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L395)
|
|
231
|
+
|
|
232
|
+
Retrieves an array of objects from the datastore matching the given search query. This function will first
|
|
233
|
+
attempt to look up the results in the cache. Also checks ACLs for READ permission.
|
|
234
|
+
|
|
235
|
+
#### Parameters
|
|
236
|
+
|
|
237
|
+
##### query
|
|
238
|
+
|
|
239
|
+
`any`
|
|
240
|
+
|
|
241
|
+
The constructed search query to run.
|
|
242
|
+
|
|
243
|
+
##### options?
|
|
244
|
+
|
|
245
|
+
[`RepoFindOptions`](../interfaces/RepoFindOptions.md)
|
|
246
|
+
|
|
247
|
+
The additional options to consider during the search.
|
|
248
|
+
|
|
249
|
+
#### Returns
|
|
250
|
+
|
|
251
|
+
`Promise`\<`T`[]\>
|
|
252
|
+
|
|
253
|
+
***
|
|
254
|
+
|
|
255
|
+
### findOne()
|
|
256
|
+
|
|
257
|
+
> **findOne**(`id`, `options?`): `Promise`\<`T` \| `undefined`\>
|
|
258
|
+
|
|
259
|
+
Defined in: [src/models/RepoUtils.ts:474](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L474)
|
|
260
|
+
|
|
261
|
+
Retrieves the object with the given id from either the cache or the database. If retrieving from the database
|
|
262
|
+
the cache is populated to speed up subsequent requests.
|
|
263
|
+
|
|
264
|
+
#### Parameters
|
|
265
|
+
|
|
266
|
+
##### id
|
|
267
|
+
|
|
268
|
+
`string`
|
|
269
|
+
|
|
270
|
+
The unique identifier of the object to retrieve.
|
|
271
|
+
|
|
272
|
+
##### options?
|
|
273
|
+
|
|
274
|
+
[`RepoFindOptions`](../interfaces/RepoFindOptions.md)
|
|
275
|
+
|
|
276
|
+
The additional options to consider during the search.
|
|
277
|
+
|
|
278
|
+
#### Returns
|
|
279
|
+
|
|
280
|
+
`Promise`\<`T` \| `undefined`\>
|
|
281
|
+
|
|
282
|
+
***
|
|
283
|
+
|
|
284
|
+
### getClassType()
|
|
285
|
+
|
|
286
|
+
> **getClassType**(`obj`): `any`
|
|
287
|
+
|
|
288
|
+
Defined in: [src/models/RepoUtils.ts:560](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L560)
|
|
289
|
+
|
|
290
|
+
Returns the class type (constructor) for the given object. This uses the `_fqn` or `_type` property of `obj` to
|
|
291
|
+
identify the class. If neither property is defined `modelClass` is assumed.
|
|
292
|
+
|
|
293
|
+
#### Parameters
|
|
294
|
+
|
|
295
|
+
##### obj
|
|
296
|
+
|
|
297
|
+
`any`
|
|
298
|
+
|
|
299
|
+
The object whose class type to look up.
|
|
300
|
+
|
|
301
|
+
#### Returns
|
|
302
|
+
|
|
303
|
+
`any`
|
|
304
|
+
|
|
305
|
+
The class type (constructor) associated with the given object.
|
|
306
|
+
|
|
307
|
+
***
|
|
308
|
+
|
|
309
|
+
### getDefaultACL()
|
|
310
|
+
|
|
311
|
+
> **getDefaultACL**(): [`AccessControlList`](../interfaces/AccessControlList.md) \| `undefined`
|
|
312
|
+
|
|
313
|
+
Defined in: [src/models/RepoUtils.ts:529](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L529)
|
|
314
|
+
|
|
315
|
+
Returns the default access control list governing the model type. Returning a value of `undefined` will grant
|
|
316
|
+
full acccess to any user (including unauthenticated anonymous users).
|
|
317
|
+
|
|
318
|
+
#### Returns
|
|
319
|
+
|
|
320
|
+
[`AccessControlList`](../interfaces/AccessControlList.md) \| `undefined`
|
|
321
|
+
|
|
322
|
+
***
|
|
323
|
+
|
|
324
|
+
### hashQuery()
|
|
325
|
+
|
|
326
|
+
> **hashQuery**(`query`): `string`
|
|
327
|
+
|
|
328
|
+
Defined in: [src/models/RepoUtils.ts:548](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L548)
|
|
329
|
+
|
|
330
|
+
Hashes the given query object to a unique string.
|
|
331
|
+
|
|
332
|
+
#### Parameters
|
|
333
|
+
|
|
334
|
+
##### query
|
|
335
|
+
|
|
336
|
+
`any`
|
|
337
|
+
|
|
338
|
+
The query object to hash.
|
|
339
|
+
|
|
340
|
+
#### Returns
|
|
341
|
+
|
|
342
|
+
`string`
|
|
343
|
+
|
|
344
|
+
***
|
|
345
|
+
|
|
346
|
+
### init()
|
|
347
|
+
|
|
348
|
+
> `protected` **init**(): `Promise`\<`void`\>
|
|
349
|
+
|
|
350
|
+
Defined in: [src/models/RepoUtils.ts:129](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L129)
|
|
351
|
+
|
|
352
|
+
#### Returns
|
|
353
|
+
|
|
354
|
+
`Promise`\<`void`\>
|
|
355
|
+
|
|
356
|
+
***
|
|
357
|
+
|
|
358
|
+
### instantiateObject()
|
|
359
|
+
|
|
360
|
+
> **instantiateObject**(`obj`, `clazz?`): `T`
|
|
361
|
+
|
|
362
|
+
Defined in: [src/models/RepoUtils.ts:577](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L577)
|
|
363
|
+
|
|
364
|
+
Creates a new instance of obj scoped to the correct model class or sub-class.
|
|
365
|
+
|
|
366
|
+
#### Parameters
|
|
367
|
+
|
|
368
|
+
##### obj
|
|
369
|
+
|
|
370
|
+
`any`
|
|
371
|
+
|
|
372
|
+
##### clazz?
|
|
373
|
+
|
|
374
|
+
`any`
|
|
375
|
+
|
|
376
|
+
#### Returns
|
|
377
|
+
|
|
378
|
+
`T`
|
|
379
|
+
|
|
380
|
+
***
|
|
381
|
+
|
|
382
|
+
### searchIdQuery()
|
|
383
|
+
|
|
384
|
+
> **searchIdQuery**(`id`, `version?`, `productUid?`): `any`
|
|
385
|
+
|
|
386
|
+
Defined in: [src/models/RepoUtils.ts:594](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L594)
|
|
387
|
+
|
|
388
|
+
Search for existing object based on passed in id and version and product uid.
|
|
389
|
+
|
|
390
|
+
The result of this function is compatible with all `Repository.find()` functions.
|
|
391
|
+
|
|
392
|
+
#### Parameters
|
|
393
|
+
|
|
394
|
+
##### id
|
|
395
|
+
|
|
396
|
+
`string`
|
|
397
|
+
|
|
398
|
+
##### version?
|
|
399
|
+
|
|
400
|
+
`string` \| `number`
|
|
401
|
+
|
|
402
|
+
##### productUid?
|
|
403
|
+
|
|
404
|
+
`string`
|
|
405
|
+
|
|
406
|
+
#### Returns
|
|
407
|
+
|
|
408
|
+
`any`
|
|
409
|
+
|
|
410
|
+
***
|
|
411
|
+
|
|
412
|
+
### truncate()
|
|
413
|
+
|
|
414
|
+
> **truncate**(`query`, `options`): `Promise`\<`void`\>
|
|
415
|
+
|
|
416
|
+
Defined in: [src/models/RepoUtils.ts:604](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L604)
|
|
417
|
+
|
|
418
|
+
#### Parameters
|
|
419
|
+
|
|
420
|
+
##### query
|
|
421
|
+
|
|
422
|
+
`any`
|
|
423
|
+
|
|
424
|
+
##### options
|
|
425
|
+
|
|
426
|
+
[`RepoFindOptions`](../interfaces/RepoFindOptions.md)
|
|
427
|
+
|
|
428
|
+
#### Returns
|
|
429
|
+
|
|
430
|
+
`Promise`\<`void`\>
|
|
431
|
+
|
|
432
|
+
***
|
|
433
|
+
|
|
434
|
+
### update()
|
|
435
|
+
|
|
436
|
+
> **update**(`obj`, `existing`, `options?`): `Promise`\<`T`\>
|
|
437
|
+
|
|
438
|
+
Defined in: [src/models/RepoUtils.ts:673](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L673)
|
|
439
|
+
|
|
440
|
+
#### Parameters
|
|
441
|
+
|
|
442
|
+
##### obj
|
|
443
|
+
|
|
444
|
+
`Partial`\<`T`\>
|
|
445
|
+
|
|
446
|
+
##### existing
|
|
447
|
+
|
|
448
|
+
`T`
|
|
449
|
+
|
|
450
|
+
##### options?
|
|
451
|
+
|
|
452
|
+
[`RepoUpdateOptions`](../interfaces/RepoUpdateOptions.md)\<`T`\>
|
|
453
|
+
|
|
454
|
+
#### Returns
|
|
455
|
+
|
|
456
|
+
`Promise`\<`T`\>
|
|
457
|
+
|
|
458
|
+
***
|
|
459
|
+
|
|
460
|
+
### validate()
|
|
461
|
+
|
|
462
|
+
> **validate**(`objs`, `options?`): `Promise`\<`void`\>
|
|
463
|
+
|
|
464
|
+
Defined in: [src/models/RepoUtils.ts:840](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/models/RepoUtils.ts#L840)
|
|
465
|
+
|
|
466
|
+
Performs validation on the object(s) provided. This function first calls `ObjectUtils.validate()` to check
|
|
467
|
+
any class level defined validation functions. Second, it scans for any properties with the `@Reference`
|
|
468
|
+
decorator and attempts to verify that an existing object for the given reference ID is valid.
|
|
469
|
+
|
|
470
|
+
#### Parameters
|
|
471
|
+
|
|
472
|
+
##### objs
|
|
473
|
+
|
|
474
|
+
`Partial`\<`T`\> \| `Partial`\<`T`\>[]
|
|
475
|
+
|
|
476
|
+
The object(s) to validate.
|
|
477
|
+
|
|
478
|
+
##### options?
|
|
479
|
+
|
|
480
|
+
[`RepoOperationOptions`](../interfaces/RepoOperationOptions.md)
|
|
481
|
+
|
|
482
|
+
The optional set of arguments that can be passed to perform additonal checks.
|
|
483
|
+
|
|
484
|
+
#### Returns
|
|
485
|
+
|
|
486
|
+
`Promise`\<`void`\>
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
[**@rapidrest/service-core**](../README.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@rapidrest/service-core](../globals.md) / RouteUtils
|
|
6
|
+
|
|
7
|
+
# Class: RouteUtils
|
|
8
|
+
|
|
9
|
+
Defined in: [src/routes/RouteUtils.ts:22](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L22)
|
|
10
|
+
|
|
11
|
+
Provides a set of utilities for converting Route classes to HTTP middleware.
|
|
12
|
+
|
|
13
|
+
## Author
|
|
14
|
+
|
|
15
|
+
Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
### Constructor
|
|
20
|
+
|
|
21
|
+
> **new RouteUtils**(): `RouteUtils`
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`RouteUtils`
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### checkRequiredPerms()
|
|
30
|
+
|
|
31
|
+
> **checkRequiredPerms**(`aclUid`): `RequestHandler`
|
|
32
|
+
|
|
33
|
+
Defined in: [src/routes/RouteUtils.ts:39](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L39)
|
|
34
|
+
|
|
35
|
+
Creates a middleware function that verifies the incoming request is from a valid user with at least
|
|
36
|
+
one of the specified roles.
|
|
37
|
+
|
|
38
|
+
#### Parameters
|
|
39
|
+
|
|
40
|
+
##### aclUid
|
|
41
|
+
|
|
42
|
+
`string`
|
|
43
|
+
|
|
44
|
+
#### Returns
|
|
45
|
+
|
|
46
|
+
`RequestHandler`
|
|
47
|
+
|
|
48
|
+
***
|
|
49
|
+
|
|
50
|
+
### checkRequiredRoles()
|
|
51
|
+
|
|
52
|
+
> **checkRequiredRoles**(`requiredRoles`): `RequestHandler`
|
|
53
|
+
|
|
54
|
+
Defined in: [src/routes/RouteUtils.ts:62](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L62)
|
|
55
|
+
|
|
56
|
+
Creates a middleware function that verifies the incoming request is from a valid user with at least
|
|
57
|
+
one of the specified roles.
|
|
58
|
+
|
|
59
|
+
#### Parameters
|
|
60
|
+
|
|
61
|
+
##### requiredRoles
|
|
62
|
+
|
|
63
|
+
`string`[]
|
|
64
|
+
|
|
65
|
+
The list of roles that the authenticated user must have.
|
|
66
|
+
|
|
67
|
+
#### Returns
|
|
68
|
+
|
|
69
|
+
`RequestHandler`
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### getFuncArray()
|
|
74
|
+
|
|
75
|
+
> **getFuncArray**(`route`, `funcs`, `send?`): `RequestHandler`[]
|
|
76
|
+
|
|
77
|
+
Defined in: [src/routes/RouteUtils.ts:87](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L87)
|
|
78
|
+
|
|
79
|
+
Converts the given array of string or Function objects to functions bound to the given route object.
|
|
80
|
+
|
|
81
|
+
#### Parameters
|
|
82
|
+
|
|
83
|
+
##### route
|
|
84
|
+
|
|
85
|
+
`any`
|
|
86
|
+
|
|
87
|
+
The route object that the list of functions is bound to.
|
|
88
|
+
|
|
89
|
+
##### funcs
|
|
90
|
+
|
|
91
|
+
(`string` \| `Function`)[]
|
|
92
|
+
|
|
93
|
+
The array of functions (or function names) to return.
|
|
94
|
+
|
|
95
|
+
##### send?
|
|
96
|
+
|
|
97
|
+
`boolean` = `false`
|
|
98
|
+
|
|
99
|
+
Set to true to have the last wrapped function send its payload to the client.
|
|
100
|
+
|
|
101
|
+
#### Returns
|
|
102
|
+
|
|
103
|
+
`RequestHandler`[]
|
|
104
|
+
|
|
105
|
+
An array of Function objects mapping to the route object.
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### getRouteMethods()
|
|
110
|
+
|
|
111
|
+
> **getRouteMethods**(`route`): `Map`\<`string`, `any`\>
|
|
112
|
+
|
|
113
|
+
Defined in: [src/routes/RouteUtils.ts:110](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L110)
|
|
114
|
+
|
|
115
|
+
Searches an route object for any functions that implement a `@Method` decorator.
|
|
116
|
+
|
|
117
|
+
#### Parameters
|
|
118
|
+
|
|
119
|
+
##### route
|
|
120
|
+
|
|
121
|
+
`any`
|
|
122
|
+
|
|
123
|
+
The route object to search.
|
|
124
|
+
|
|
125
|
+
#### Returns
|
|
126
|
+
|
|
127
|
+
`Map`\<`string`, `any`\>
|
|
128
|
+
|
|
129
|
+
The list of `@Method` decorated functions that were found.
|
|
130
|
+
|
|
131
|
+
***
|
|
132
|
+
|
|
133
|
+
### registerRoute()
|
|
134
|
+
|
|
135
|
+
> **registerRoute**(`app`, `route`): `Promise`\<`void`\>
|
|
136
|
+
|
|
137
|
+
Defined in: [src/routes/RouteUtils.ts:139](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L139)
|
|
138
|
+
|
|
139
|
+
Registers the provided route object containing a set of decorated endpoints to the server.
|
|
140
|
+
|
|
141
|
+
#### Parameters
|
|
142
|
+
|
|
143
|
+
##### app
|
|
144
|
+
|
|
145
|
+
`any`
|
|
146
|
+
|
|
147
|
+
The HTTP application/router to register the route to.
|
|
148
|
+
|
|
149
|
+
##### route
|
|
150
|
+
|
|
151
|
+
`any`
|
|
152
|
+
|
|
153
|
+
The route object to register.
|
|
154
|
+
|
|
155
|
+
#### Returns
|
|
156
|
+
|
|
157
|
+
`Promise`\<`void`\>
|
|
158
|
+
|
|
159
|
+
***
|
|
160
|
+
|
|
161
|
+
### wrapMiddleware()
|
|
162
|
+
|
|
163
|
+
> **wrapMiddleware**(`obj`, `func`, `send?`): `RequestHandler`
|
|
164
|
+
|
|
165
|
+
Defined in: [src/routes/RouteUtils.ts:306](https://github.com/rapidrest/service-core/blob/c8974caa9b5d3eb225bcbcd93945f2e588fe2f0a/src/routes/RouteUtils.ts#L306)
|
|
166
|
+
|
|
167
|
+
Wraps the provided function with HTTP handling based on the function's defined decorators.
|
|
168
|
+
|
|
169
|
+
#### Parameters
|
|
170
|
+
|
|
171
|
+
##### obj
|
|
172
|
+
|
|
173
|
+
`any`
|
|
174
|
+
|
|
175
|
+
The bound object whose middleware function will be wrapped.
|
|
176
|
+
|
|
177
|
+
##### func
|
|
178
|
+
|
|
179
|
+
`Function`
|
|
180
|
+
|
|
181
|
+
The decorated function to wrap.
|
|
182
|
+
|
|
183
|
+
##### send?
|
|
184
|
+
|
|
185
|
+
`boolean` = `false`
|
|
186
|
+
|
|
187
|
+
Set to true to have `func`'s result sent to the client.
|
|
188
|
+
|
|
189
|
+
#### Returns
|
|
190
|
+
|
|
191
|
+
`RequestHandler`
|