@rapidrest/service-core 1.0.0-rc.9 → 1.0.0
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 +382 -23
- package/README.md +79 -5
- package/dist/lib/ApiErrors.js +10 -0
- package/dist/lib/ApiErrors.js.map +1 -1
- package/dist/lib/BackgroundService.js +1 -4
- package/dist/lib/BackgroundService.js.map +1 -1
- package/dist/lib/BackgroundServiceManager.js +47 -6
- package/dist/lib/BackgroundServiceManager.js.map +1 -1
- package/dist/lib/BulkError.js +4 -0
- package/dist/lib/BulkError.js.map +1 -1
- package/dist/lib/EventListenerManager.js +53 -18
- package/dist/lib/EventListenerManager.js.map +1 -1
- package/dist/lib/NetUtils.js +1 -0
- package/dist/lib/NetUtils.js.map +1 -1
- package/dist/lib/NotificationUtils.js +27 -8
- package/dist/lib/NotificationUtils.js.map +1 -1
- package/dist/lib/ObjectFactory.js +25 -44
- package/dist/lib/ObjectFactory.js.map +1 -1
- package/dist/lib/OpenApiSpec.js +31 -11
- package/dist/lib/OpenApiSpec.js.map +1 -1
- package/dist/lib/Server.js +74 -110
- package/dist/lib/Server.js.map +1 -1
- package/dist/lib/auth/AuthMiddleware.js +11 -16
- package/dist/lib/auth/AuthMiddleware.js.map +1 -1
- package/dist/lib/auth/JWTStrategy.js +68 -17
- package/dist/lib/auth/JWTStrategy.js.map +1 -1
- package/dist/lib/auth/index.js +0 -1
- package/dist/lib/auth/index.js.map +1 -1
- package/dist/lib/database/ConnectionKinds.js +15 -0
- package/dist/lib/database/ConnectionKinds.js.map +1 -1
- package/dist/lib/database/ConnectionManager.js +140 -61
- package/dist/lib/database/ConnectionManager.js.map +1 -1
- package/dist/lib/database/MongoConnection.js +13 -3
- package/dist/lib/database/MongoConnection.js.map +1 -1
- package/dist/lib/database/MongoRepository.js +61 -15
- package/dist/lib/database/MongoRepository.js.map +1 -1
- package/dist/lib/database/MongoSchemaSync.js +3 -3
- package/dist/lib/database/MongoSchemaSync.js.map +1 -1
- package/dist/lib/database/NamingUtils.js +3 -2
- package/dist/lib/database/NamingUtils.js.map +1 -1
- package/dist/lib/database/RedisCache.js +64 -0
- package/dist/lib/database/RedisCache.js.map +1 -0
- package/dist/lib/database/TypeOrmSupport.js +53 -13
- package/dist/lib/database/TypeOrmSupport.js.map +1 -1
- package/dist/lib/database/index.js +1 -0
- package/dist/lib/database/index.js.map +1 -1
- package/dist/lib/decorators/DatabaseDecorators.js +264 -20
- package/dist/lib/decorators/DatabaseDecorators.js.map +1 -1
- package/dist/lib/decorators/DocDecorators.js +30 -9
- package/dist/lib/decorators/DocDecorators.js.map +1 -1
- package/dist/lib/decorators/EventDecorators.js +1 -0
- package/dist/lib/decorators/EventDecorators.js.map +1 -1
- package/dist/lib/decorators/ModelDecorators.js +39 -23
- package/dist/lib/decorators/ModelDecorators.js.map +1 -1
- package/dist/lib/decorators/PersistenceDecorators.js +4 -3
- package/dist/lib/decorators/PersistenceDecorators.js.map +1 -1
- package/dist/lib/decorators/RouteDecorators.js +139 -36
- package/dist/lib/decorators/RouteDecorators.js.map +1 -1
- package/dist/lib/http/IWebSocketShim.js +2 -0
- package/dist/lib/http/IWebSocketShim.js.map +1 -0
- package/dist/lib/http/MiddlewareChain.js +167 -0
- package/dist/lib/http/MiddlewareChain.js.map +1 -0
- package/dist/lib/http/RuntimeDetect.js +9 -0
- package/dist/lib/http/RuntimeDetect.js.map +1 -0
- package/dist/lib/http/bun/BunAdapters.js +326 -0
- package/dist/lib/http/bun/BunAdapters.js.map +1 -0
- package/dist/lib/http/bun/BunRouter.js +391 -0
- package/dist/lib/http/bun/BunRouter.js.map +1 -0
- package/dist/lib/http/bun/BunWebSocket.js +49 -0
- package/dist/lib/http/bun/BunWebSocket.js.map +1 -0
- package/dist/lib/http/index.js +16 -3
- package/dist/lib/http/index.js.map +1 -1
- package/dist/lib/http/session/RedisSessionStore.js +30 -0
- package/dist/lib/http/session/RedisSessionStore.js.map +1 -0
- package/dist/lib/http/session/SessionManager.js +113 -0
- package/dist/lib/http/session/SessionManager.js.map +1 -0
- package/dist/lib/http/session/SessionStore.js +6 -0
- package/dist/lib/http/session/SessionStore.js.map +1 -0
- package/dist/lib/http/session/sessionMiddleware.js +42 -0
- package/dist/lib/http/session/sessionMiddleware.js.map +1 -0
- package/dist/lib/http/types.js +0 -3
- package/dist/lib/http/types.js.map +1 -1
- package/dist/lib/http/uWS/Adapters.js +421 -0
- package/dist/lib/http/uWS/Adapters.js.map +1 -0
- package/dist/lib/http/{Router.js → uWS/Router.js} +73 -173
- package/dist/lib/http/uWS/Router.js.map +1 -0
- package/dist/lib/http/{WebSocket.js → uWS/WebSocket.js} +4 -1
- package/dist/lib/http/uWS/WebSocket.js.map +1 -0
- package/dist/lib/models/BaseEntity.js +2 -1
- package/dist/lib/models/BaseEntity.js.map +1 -1
- package/dist/lib/models/BaseMongoEntity.js +2 -2
- package/dist/lib/models/BaseMongoEntity.js.map +1 -1
- package/dist/lib/models/ModelUtils.js +248 -101
- package/dist/lib/models/ModelUtils.js.map +1 -1
- package/dist/lib/models/RecoverableBaseEntity.js +6 -1
- package/dist/lib/models/RecoverableBaseEntity.js.map +1 -1
- package/dist/lib/models/RecoverableBaseMongoEntity.js +1 -0
- package/dist/lib/models/RecoverableBaseMongoEntity.js.map +1 -1
- package/dist/lib/models/RepoUtils.js +641 -213
- package/dist/lib/models/RepoUtils.js.map +1 -1
- package/dist/lib/models/SimpleEntity.js +1 -0
- package/dist/lib/models/SimpleEntity.js.map +1 -1
- package/dist/lib/models/SimpleMongoEntity.js +2 -1
- package/dist/lib/models/SimpleMongoEntity.js.map +1 -1
- package/dist/lib/models/StatusExtraData.js +4 -0
- package/dist/lib/models/StatusExtraData.js.map +1 -1
- package/dist/lib/routes/{AdminRoute.js → BaseAdminRoute.js} +98 -80
- package/dist/lib/routes/BaseAdminRoute.js.map +1 -0
- package/dist/lib/routes/{MetricsRoute.js → BaseMetricsRoute.js} +29 -15
- package/dist/lib/routes/BaseMetricsRoute.js.map +1 -0
- package/dist/lib/routes/{OpenAPIRoute.js → BaseOpenAPIRoute.js} +32 -32
- package/dist/lib/routes/BaseOpenAPIRoute.js.map +1 -0
- package/dist/lib/routes/BasePushRoute.js +305 -0
- package/dist/lib/routes/BasePushRoute.js.map +1 -0
- package/dist/lib/routes/BaseStaticRoute.js +153 -0
- package/dist/lib/routes/BaseStaticRoute.js.map +1 -0
- package/dist/lib/routes/BaseStatusRoute.js +80 -0
- package/dist/lib/routes/BaseStatusRoute.js.map +1 -0
- package/dist/lib/routes/CRUDRoute.js +284 -0
- package/dist/lib/routes/CRUDRoute.js.map +1 -0
- package/dist/lib/routes/ModelRoute.js +84 -57
- package/dist/lib/routes/ModelRoute.js.map +1 -1
- package/dist/lib/routes/RouteUtils.js +108 -20
- package/dist/lib/routes/RouteUtils.js.map +1 -1
- package/dist/lib/routes/index.js +7 -4
- package/dist/lib/routes/index.js.map +1 -1
- package/dist/lib/security/ACLUtils.js +297 -170
- package/dist/lib/security/ACLUtils.js.map +1 -1
- package/dist/lib/security/AccessControlList.js +18 -10
- package/dist/lib/security/AccessControlList.js.map +1 -1
- package/dist/lib/security/AccessControlListMongo.js +19 -68
- package/dist/lib/security/AccessControlListMongo.js.map +1 -1
- package/dist/lib/security/AccessControlListSQL.js +21 -70
- package/dist/lib/security/AccessControlListSQL.js.map +1 -1
- package/dist/lib/security/BaseACLRoute.js +239 -0
- package/dist/lib/security/BaseACLRoute.js.map +1 -0
- package/dist/lib/security/index.js +3 -0
- package/dist/lib/security/index.js.map +1 -1
- package/dist/lib/test/request.js +62 -5
- package/dist/lib/test/request.js.map +1 -1
- package/dist/lib/test/requestws.js +34 -10
- package/dist/lib/test/requestws.js.map +1 -1
- package/dist/types/ApiErrors.d.ts +8 -2
- package/dist/types/BackgroundService.d.ts +0 -5
- package/dist/types/BackgroundServiceManager.d.ts +2 -1
- package/dist/types/EventListenerManager.d.ts +7 -6
- package/dist/types/NotificationUtils.d.ts +5 -3
- package/dist/types/OpenApiSpec.d.ts +2 -2
- package/dist/types/Server.d.ts +28 -10
- package/dist/types/auth/AuthMiddleware.d.ts +3 -3
- package/dist/types/auth/AuthStrategy.d.ts +10 -7
- package/dist/types/auth/JWTStrategy.d.ts +6 -4
- package/dist/types/auth/index.d.ts +0 -1
- package/dist/types/database/ConnectionKinds.d.ts +7 -0
- package/dist/types/database/ConnectionManager.d.ts +29 -4
- package/dist/types/database/MongoConnection.d.ts +16 -4
- package/dist/types/database/MongoRepository.d.ts +32 -11
- package/dist/types/database/RedisCache.d.ts +23 -0
- package/dist/types/database/TypeOrmSupport.d.ts +4 -4
- package/dist/types/database/index.d.ts +1 -0
- package/dist/types/decorators/DatabaseDecorators.d.ts +139 -8
- package/dist/types/decorators/DocDecorators.d.ts +11 -2
- package/dist/types/decorators/ModelDecorators.d.ts +12 -5
- package/dist/types/decorators/PersistenceDecorators.d.ts +11 -4
- package/dist/types/decorators/RouteDecorators.d.ts +36 -6
- package/dist/types/http/IWebSocketShim.d.ts +11 -0
- package/dist/types/http/MiddlewareChain.d.ts +47 -0
- package/dist/types/http/RuntimeDetect.d.ts +2 -0
- package/dist/types/http/bun/BunAdapters.d.ts +139 -0
- package/dist/types/http/bun/BunRouter.d.ts +79 -0
- package/dist/types/http/bun/BunWebSocket.d.ts +35 -0
- package/dist/types/http/index.d.ts +16 -6
- package/dist/types/http/session/RedisSessionStore.d.ts +15 -0
- package/dist/types/http/session/SessionManager.d.ts +35 -0
- package/dist/types/http/session/SessionStore.d.ts +12 -0
- package/dist/types/http/session/sessionMiddleware.d.ts +10 -0
- package/dist/types/http/types.d.ts +42 -3
- package/dist/types/http/uWS/Adapters.d.ts +129 -0
- package/dist/types/http/{Router.d.ts → uWS/Router.d.ts} +14 -38
- package/dist/types/http/{WebSocket.d.ts → uWS/WebSocket.d.ts} +6 -5
- package/dist/types/models/BaseEntity.d.ts +1 -1
- package/dist/types/models/ModelUtils.d.ts +47 -14
- package/dist/types/models/RecoverableBaseEntity.d.ts +3 -1
- package/dist/types/models/RepoUtils.d.ts +84 -14
- package/dist/types/routes/BaseAdminRoute.d.ts +65 -0
- package/dist/types/routes/BaseMetricsRoute.d.ts +37 -0
- package/dist/types/routes/BaseOpenAPIRoute.d.ts +33 -0
- package/dist/types/routes/BasePushRoute.d.ts +53 -0
- package/dist/types/routes/BaseStaticRoute.d.ts +44 -0
- package/dist/types/routes/BaseStatusRoute.d.ts +37 -0
- package/dist/types/routes/CRUDRoute.d.ts +57 -0
- package/dist/types/routes/ModelRoute.d.ts +39 -36
- package/dist/types/routes/RouteUtils.d.ts +19 -0
- package/dist/types/routes/index.d.ts +7 -4
- package/dist/types/security/ACLUtils.d.ts +94 -18
- package/dist/types/security/AccessControlList.d.ts +37 -59
- package/dist/types/security/AccessControlListMongo.d.ts +3 -8
- package/dist/types/security/AccessControlListSQL.d.ts +3 -8
- package/dist/types/security/BaseACLRoute.d.ts +73 -0
- package/dist/types/security/index.d.ts +3 -0
- package/dist/types/test/request.d.ts +18 -1
- package/package.json +135 -129
- package/tsconfig.export.json +17 -0
- package/dist/lib/auth/BasicStrategy.js +0 -113
- package/dist/lib/auth/BasicStrategy.js.map +0 -1
- package/dist/lib/http/Adapters.js +0 -241
- package/dist/lib/http/Adapters.js.map +0 -1
- package/dist/lib/http/Router.js.map +0 -1
- package/dist/lib/http/WebSocket.js.map +0 -1
- package/dist/lib/routes/AdminRoute.js.map +0 -1
- package/dist/lib/routes/MetricsRoute.js.map +0 -1
- package/dist/lib/routes/OpenAPIRoute.js.map +0 -1
- package/dist/lib/routes/StatusRoute.js +0 -55
- package/dist/lib/routes/StatusRoute.js.map +0 -1
- package/dist/lib/security/ACLRouteMongo.js +0 -194
- package/dist/lib/security/ACLRouteMongo.js.map +0 -1
- package/dist/lib/security/ACLRouteSQL.js +0 -193
- package/dist/lib/security/ACLRouteSQL.js.map +0 -1
- package/dist/types/auth/BasicStrategy.d.ts +0 -37
- package/dist/types/http/Adapters.d.ts +0 -68
- package/dist/types/routes/AdminRoute.d.ts +0 -47
- package/dist/types/routes/MetricsRoute.d.ts +0 -15
- package/dist/types/routes/OpenAPIRoute.d.ts +0 -17
- package/dist/types/routes/StatusRoute.d.ts +0 -11
- package/dist/types/security/ACLRouteMongo.d.ts +0 -19
- package/dist/types/security/ACLRouteSQL.d.ts +0 -19
- package/docs/Makefile +0 -20
- package/docs/conf.py +0 -58
- package/docs/index.rst +0 -17
- package/docs/make.bat +0 -35
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/README.md +0 -13
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/MongoRepository.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/RedisConnection.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DatabaseDecorators/functions/Repository.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/README.md +0 -23
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Default.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Description.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Document.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Example.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Format.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Returns.md +0 -28
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Summary.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/Tags.md +0 -25
- package/docs/reference/@rapidrest/namespaces/DocDecorators/functions/TypeInfo.md +0 -28
- package/docs/reference/@rapidrest/namespaces/DocDecorators/interfaces/DocumentsData.md +0 -57
- package/docs/reference/@rapidrest/namespaces/EventDecorators/README.md +0 -12
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/EventListener.md +0 -17
- package/docs/reference/@rapidrest/namespaces/EventDecorators/functions/OnEvent.md +0 -26
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/README.md +0 -26
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Cache.md +0 -25
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/ChildEntity.md +0 -18
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/DataStore.md +0 -25
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Identifier.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Protect.md +0 -35
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Reference.md +0 -25
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/Shard.md +0 -27
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/functions/TrackChanges.md +0 -26
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/interfaces/PendingTypeOrmColumn.md +0 -45
- package/docs/reference/@rapidrest/namespaces/ModelDecorators/variables/pendingTypeOrmColumns.md +0 -14
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/README.md +0 -27
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Column.md +0 -25
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Entity.md +0 -25
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Index.md +0 -119
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/PrimaryColumn.md +0 -25
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/Unique.md +0 -68
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getColumnMetadata.md +0 -26
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getEntityName.md +0 -26
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/functions/getIndexMetadata.md +0 -27
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/CollationOptions.md +0 -79
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnInfo.md +0 -41
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/ColumnOptions.md +0 -51
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/EntityOptions.md +0 -32
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexInfo.md +0 -41
- package/docs/reference/@rapidrest/namespaces/PersistenceDecorators/interfaces/IndexOptions.md +0 -61
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/README.md +0 -36
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/After.md +0 -26
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Auth.md +0 -33
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/AuthResult.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Before.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/ContentType.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Delete.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Get.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Head.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Header.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Method.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Model.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Options.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Param.md +0 -26
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Patch.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Post.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Protect.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Put.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Query.md +0 -26
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Request.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/RequiresRole.md +0 -26
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Response.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Route.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Socket.md +0 -33
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/User.md +0 -31
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/Validate.md +0 -25
- package/docs/reference/@rapidrest/namespaces/RouteDecorators/functions/WebSocket.md +0 -25
- package/docs/reference/README.md +0 -20
- package/docs/reference/classes/ACLUtils.md +0 -263
- package/docs/reference/classes/AdminRoute.md +0 -51
- package/docs/reference/classes/AuthMiddleware.md +0 -173
- package/docs/reference/classes/BackgroundService.md +0 -117
- package/docs/reference/classes/BackgroundServiceManager.md +0 -172
- package/docs/reference/classes/BaseEntity.md +0 -82
- package/docs/reference/classes/BaseMongoEntity.md +0 -107
- package/docs/reference/classes/BasicStrategy.md +0 -131
- package/docs/reference/classes/BasicStrategyOptions.md +0 -115
- package/docs/reference/classes/BulkError.md +0 -271
- package/docs/reference/classes/ConnectionManager.md +0 -75
- package/docs/reference/classes/EventListenerManager.md +0 -88
- package/docs/reference/classes/HttpRouter.md +0 -343
- package/docs/reference/classes/JWTStrategy.md +0 -100
- package/docs/reference/classes/JWTStrategyOptions.md +0 -97
- package/docs/reference/classes/MetricsRoute.md +0 -27
- package/docs/reference/classes/ModelRoute.md +0 -527
- package/docs/reference/classes/ModelUtils.md +0 -446
- package/docs/reference/classes/MongoConnection.md +0 -218
- package/docs/reference/classes/MongoRepository.md +0 -390
- package/docs/reference/classes/MongoSchemaSync.md +0 -97
- package/docs/reference/classes/NetUtils.md +0 -90
- package/docs/reference/classes/NotificationUtils.md +0 -77
- package/docs/reference/classes/ObjectFactory.md +0 -336
- package/docs/reference/classes/OpenAPIRoute.md +0 -77
- package/docs/reference/classes/OpenApiSpec.md +0 -892
- package/docs/reference/classes/RecoverableBaseEntity.md +0 -114
- package/docs/reference/classes/RecoverableBaseMongoEntity.md +0 -124
- package/docs/reference/classes/RedisTransport.md +0 -2202
- package/docs/reference/classes/RepoUtils.md +0 -482
- package/docs/reference/classes/RouteUtils.md +0 -191
- package/docs/reference/classes/Server.md +0 -408
- package/docs/reference/classes/SimpleEntity.md +0 -48
- package/docs/reference/classes/SimpleMongoEntity.md +0 -66
- package/docs/reference/classes/StatusExtraData.md +0 -57
- package/docs/reference/classes/StatusRoute.md +0 -26
- package/docs/reference/classes/UWSRequest.md +0 -226
- package/docs/reference/classes/UWSResponse.md +0 -257
- package/docs/reference/classes/UWSWebSocketShim.md +0 -958
- package/docs/reference/enumerations/ACLAction.md +0 -63
- package/docs/reference/enumerations/ApiErrorMessages.md +0 -123
- package/docs/reference/enumerations/ApiErrors.md +0 -123
- package/docs/reference/functions/createWebSocketStream.md +0 -27
- package/docs/reference/functions/isSqlDataSource.md +0 -26
- package/docs/reference/functions/readBody.md +0 -29
- package/docs/reference/functions/resolveCollectionName.md +0 -33
- package/docs/reference/functions/runChain.md +0 -40
- package/docs/reference/functions/snakeCase.md +0 -28
- package/docs/reference/globals.md +0 -106
- package/docs/reference/interfaces/ACLRecord.md +0 -96
- package/docs/reference/interfaces/AccessControlList.md +0 -76
- package/docs/reference/interfaces/AuthResult.md +0 -55
- package/docs/reference/interfaces/AuthStrategy.md +0 -95
- package/docs/reference/interfaces/CreateRequestOptions.md +0 -121
- package/docs/reference/interfaces/DeleteRequestOptions.md +0 -137
- package/docs/reference/interfaces/FindRequestOptions.md +0 -133
- package/docs/reference/interfaces/HttpRequest.md +0 -147
- package/docs/reference/interfaces/HttpResponse.md +0 -164
- package/docs/reference/interfaces/JWTAuthResult.md +0 -84
- package/docs/reference/interfaces/RepoCreateOptions.md +0 -95
- package/docs/reference/interfaces/RepoDeleteOptions.md +0 -105
- package/docs/reference/interfaces/RepoFindOptions.md +0 -125
- package/docs/reference/interfaces/RepoOperationOptions.md +0 -69
- package/docs/reference/interfaces/RepoUpdateOptions.md +0 -101
- package/docs/reference/interfaces/RequestOptions.md +0 -112
- package/docs/reference/interfaces/RequestWS.md +0 -225
- package/docs/reference/interfaces/TruncateRequestOptions.md +0 -161
- package/docs/reference/interfaces/UpdateRequestOptions.md +0 -139
- package/docs/reference/type-aliases/ErrorHandler.md +0 -35
- package/docs/reference/type-aliases/NextFunction.md +0 -23
- package/docs/reference/type-aliases/OneOrMany.md +0 -19
- package/docs/reference/type-aliases/OneOrNull.md +0 -19
- package/docs/reference/type-aliases/PartialBaseEntity.md +0 -17
- package/docs/reference/type-aliases/PartialSimpleEntity.md +0 -17
- package/docs/reference/type-aliases/RequestHandler.md +0 -31
- package/docs/reference/type-aliases/UpdateObject.md +0 -19
- package/docs/reference/type-aliases/WsUpgradeAuth.md +0 -27
- package/docs/reference/type-aliases/WsUpgradeAuthResult.md +0 -47
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type JWTUser } from "@rapidrest/core";
|
|
2
|
+
import type { RedisClientType } from "redis";
|
|
3
|
+
import Transport from "winston-transport";
|
|
4
|
+
import { type IWebSocketShim } from "../http/IWebSocketShim.js";
|
|
5
|
+
/**
|
|
6
|
+
* Implements a Winston transport that pipes incoming log messages to a configured redis pubsub channel.
|
|
7
|
+
*/
|
|
8
|
+
export declare class RedisTransport extends Transport {
|
|
9
|
+
private channel;
|
|
10
|
+
private redis;
|
|
11
|
+
constructor(opts: any);
|
|
12
|
+
close(): void;
|
|
13
|
+
log(info: any, next: Function): any;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The `BaseAdminRoute` class provides a base set of endpoints that gives trusted users the ability to perform common adminstrative actions
|
|
17
|
+
* with the server. Note that this route class requires elevated user privileges to perform any action.
|
|
18
|
+
*
|
|
19
|
+
* Exposed endpoints:
|
|
20
|
+
*
|
|
21
|
+
* | Name | HTTP Method | What it does |
|
|
22
|
+
* | --- | --- | --- |
|
|
23
|
+
* | `clearCache` | `GET /<base_path>/clear-cache` | Clears the Redis-based cache system. |
|
|
24
|
+
* | `logs` | `UPGRADE /<base_path>/logs` | Live tail the service logs |
|
|
25
|
+
* | `getReleaseNotes` | `GET /<base_path>/release-notes` | Retrieve the server release notes. |
|
|
26
|
+
* | `restart` | `GET /<base_path>/restart` | ` Restart the server |
|
|
27
|
+
*
|
|
28
|
+
* !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
|
|
29
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { BaseAdminRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
34
|
+
* const { Route } = RouteDecorators;
|
|
35
|
+
*
|
|
36
|
+
* @Route("/admin")
|
|
37
|
+
* export class AdminRoute extends BaseAdminRoute {}
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @author Jean-Philippe Steinmetz
|
|
41
|
+
*/
|
|
42
|
+
export declare class BaseAdminRoute {
|
|
43
|
+
/** A map of user uid's to active sockets. */
|
|
44
|
+
protected activeSockets: Map<string, any[]>;
|
|
45
|
+
protected cacheClient?: RedisClientType;
|
|
46
|
+
protected cacheConnConfig: any;
|
|
47
|
+
protected logger: any;
|
|
48
|
+
protected logsConnConfig: any;
|
|
49
|
+
protected redisClient?: RedisClientType;
|
|
50
|
+
/**
|
|
51
|
+
* A dedicated connection for publishing admin channel messages (e.g. the `RESTART` signal).
|
|
52
|
+
* `redisClient` issues `SUBSCRIBE` in `init()`, which puts it into subscriber-only mode — Redis
|
|
53
|
+
* connections in that state can't also run `PUBLISH`, so a separate connection is required.
|
|
54
|
+
*/
|
|
55
|
+
protected redisPublisher?: RedisClientType;
|
|
56
|
+
/** The underlying ReleaseNotes specification. */
|
|
57
|
+
protected releaseNotes?: string;
|
|
58
|
+
protected serviceName?: string;
|
|
59
|
+
protected trustedRoles: string[];
|
|
60
|
+
protected init(): Promise<void>;
|
|
61
|
+
clearCache(user?: JWTUser): Promise<void>;
|
|
62
|
+
logs(socket: IWebSocketShim, user: JWTUser): Promise<void>;
|
|
63
|
+
getReleaseNotes(user?: JWTUser): string | undefined;
|
|
64
|
+
restart(user?: JWTUser): void;
|
|
65
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as prom from "prom-client";
|
|
2
|
+
import { type JWTUser } from "@rapidrest/core";
|
|
3
|
+
/**
|
|
4
|
+
* The `BaseMetricsRoute` class provides a base set of endpoints for exposing Prometheus metrics.
|
|
5
|
+
*
|
|
6
|
+
* Exposed endpoints:
|
|
7
|
+
*
|
|
8
|
+
* | Name | HTTP Method | What it does |
|
|
9
|
+
* | --- | --- | --- |
|
|
10
|
+
* | `getMetrics` | `GET /<base_path>` | Returns all Prometheus metrics gathered by the system |
|
|
11
|
+
* | `getSingleMetric` | `GET /<base_path>/:metric` | Returns a single Prometheus metric with the given name |
|
|
12
|
+
*
|
|
13
|
+
* Services that wish to provide metrics to be exposed via this route can register them using the global registry
|
|
14
|
+
* from the provided `prom-client` dependency. See the `prom-client` documentation for more details.
|
|
15
|
+
*
|
|
16
|
+
* !!Note!! that the `BaseMetricsRoute` is not automatically registered with a server by default. You must create
|
|
17
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { BaseMetricsRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
22
|
+
* const { Route } = RouteDecorators;
|
|
23
|
+
*
|
|
24
|
+
* @Route("/metrics")
|
|
25
|
+
* export class MetricsRoute extends BaseMetricsRoute {}
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class BaseMetricsRoute {
|
|
29
|
+
protected metricsConfig: {
|
|
30
|
+
authRequired: boolean;
|
|
31
|
+
};
|
|
32
|
+
protected registry: prom.Registry;
|
|
33
|
+
protected trustedRoles: string[];
|
|
34
|
+
constructor();
|
|
35
|
+
getMetrics(user?: JWTUser): Promise<string>;
|
|
36
|
+
getSingleMetric(metric: any, user?: JWTUser): Promise<string>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { OpenApiSpec } from "../OpenApiSpec.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `BaseOpenAPIRoute` class provides a base set of endpoints exposing the server's OpenAPI specification.
|
|
4
|
+
*
|
|
5
|
+
* Exposed endpoints:
|
|
6
|
+
*
|
|
7
|
+
* | Name | HTTP Method | What it does |
|
|
8
|
+
* | --- | --- | --- |
|
|
9
|
+
* | `getHTML` | `GET /<base_path>` | Swagger UI HTML (loads swagger-ui-dist from CDN) |
|
|
10
|
+
* | `getJSON` | `GET /<base_path>/json` | raw OpenAPI specification as JSON |
|
|
11
|
+
* | `getYAML` | `GET /<base_path>/yaml` | raw OpenAPI specification as YAML |
|
|
12
|
+
*
|
|
13
|
+
* !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
|
|
14
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { BaseOpenAPIRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
19
|
+
* const { Route } = RouteDecorators;
|
|
20
|
+
*
|
|
21
|
+
* @Route("/openapi")
|
|
22
|
+
* export class OpenAPIRoute extends BaseOpenAPIRoute {}
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @author Jean-Philippe Steinmetz
|
|
26
|
+
*/
|
|
27
|
+
export declare class BaseOpenAPIRoute {
|
|
28
|
+
/** The underlying OpenAPI specification. */
|
|
29
|
+
protected apiSpec: OpenApiSpec;
|
|
30
|
+
getHTML(): string;
|
|
31
|
+
getJSON(): any;
|
|
32
|
+
getYAML(): string;
|
|
33
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import ws from "ws";
|
|
2
|
+
/**
|
|
3
|
+
* The `BasePushRoute` class provides a base set of endpoints for implement client push notifications.
|
|
4
|
+
*
|
|
5
|
+
* Exposed endpoints:
|
|
6
|
+
*
|
|
7
|
+
* | Name | HTTP Method | What it does |
|
|
8
|
+
* | --- | --- | --- |
|
|
9
|
+
* | `connect` | `UPGRADE /<base_path>/connect` | Establishes a connection to the push notification system. |
|
|
10
|
+
* | `send` | `POST /<base_path>/:id` | Sends a push notification message to the channel with the given id |
|
|
11
|
+
*
|
|
12
|
+
* !!Note!! that the `BasePushRoute` is not automatically registered with a server by default. You must create
|
|
13
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { BasePushRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
18
|
+
* const { Route } = RouteDecorators;
|
|
19
|
+
*
|
|
20
|
+
* @Route("/push")
|
|
21
|
+
* export class PushRoute extends BasePushRoute {}
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @author Jean-Philippe Steinmetz
|
|
25
|
+
*/
|
|
26
|
+
export declare class BasePushRoute {
|
|
27
|
+
private aclUtils?;
|
|
28
|
+
/** A map of active socket connections to users. */
|
|
29
|
+
private activeSocks;
|
|
30
|
+
/** A map of active subscription uids to users. */
|
|
31
|
+
private activeSubs;
|
|
32
|
+
/** Per-user in-process locks (see `runExclusive`) guarding read-modify-write access to `activeSubs`. */
|
|
33
|
+
private subLocks;
|
|
34
|
+
private logger;
|
|
35
|
+
private redisConfig;
|
|
36
|
+
/** The maximum number of concurrent sockets a single user may hold open at once. */
|
|
37
|
+
private maxSocketsPerUser;
|
|
38
|
+
/** The maximum number of channels a single user may be subscribed to at once. */
|
|
39
|
+
private maxSubscriptionsPerUser;
|
|
40
|
+
/** A persistent redis client used to publish outgoing push messages. */
|
|
41
|
+
private redisPub?;
|
|
42
|
+
private init;
|
|
43
|
+
/**
|
|
44
|
+
* Runs `fn` exclusively with respect to any other call currently queued under the same `key` on this
|
|
45
|
+
* instance — a call only starts once every call queued ahead of it under that key has fully settled. Used
|
|
46
|
+
* to serialize SUBSCRIBE/UNSUBSCRIBE handling per user so two messages arriving close together (on the same
|
|
47
|
+
* or different concurrent sockets for that user) can't both read the same stale `activeSubs` snapshot and
|
|
48
|
+
* clobber (or exceed the cap on) each other's committed subscription list.
|
|
49
|
+
*/
|
|
50
|
+
private runExclusive;
|
|
51
|
+
connect(sock: ws, user: any): Promise<void>;
|
|
52
|
+
send(id: string, msg: any, user: any): Promise<void>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from "../http/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `BaseStaticRoute` class provides a single endpoint for serving static files from a designated path on the filesystem (e.g. `./public`).
|
|
4
|
+
* Uses the path specified in the project configuration key `static_files`. Default is `public`.
|
|
5
|
+
*
|
|
6
|
+
* Exposed endpoints:
|
|
7
|
+
*
|
|
8
|
+
* | Name | HTTP Method | What it does |
|
|
9
|
+
* | --- | --- | --- |
|
|
10
|
+
* | `get` | `GET /<base_path>/*` | Serves static files from the configured `static_files`. |
|
|
11
|
+
*
|
|
12
|
+
* !!Note!! that the `BaseStaticRoute` is not automatically registered with a server by default. You must create
|
|
13
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { BaseStaticRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
18
|
+
* const { Route } = RouteDecorators;
|
|
19
|
+
*
|
|
20
|
+
* @Route("/static")
|
|
21
|
+
* export class StaticRoute extends BaseStaticRoute {}
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @author Jean-Philippe Steinmetz
|
|
25
|
+
*/
|
|
26
|
+
export declare class BaseStaticRoute {
|
|
27
|
+
/**
|
|
28
|
+
* The URL prefix derived from `@Route` metadata at init time.
|
|
29
|
+
* E.g. `@Route("/app/*")` → prefix = "/app". Used to strip the prefix from req.path
|
|
30
|
+
* before resolving app page files, and to scope the dev-reload SSE endpoint.
|
|
31
|
+
*/
|
|
32
|
+
protected routePrefix: string;
|
|
33
|
+
/** The location of the static files to serve. Defaults to `./public`. */
|
|
34
|
+
protected readonly staticDir: string;
|
|
35
|
+
protected init(): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve a file in the static directory by trying multiple extensions in order.
|
|
38
|
+
* If the path segment ends in a `/`, `index.html` is automatically appended.
|
|
39
|
+
*
|
|
40
|
+
* @returns The full path to the file on disk if exists, otherwise `null`.
|
|
41
|
+
*/
|
|
42
|
+
private resolveFile;
|
|
43
|
+
get(req: HttpRequest, res: HttpResponse): Promise<any>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StatusExtraData } from "../models/StatusExtraData.js";
|
|
2
|
+
/**
|
|
3
|
+
* The `BaseStatusRoute` class provides a base set of endpoints exposing status metadata information about the server.
|
|
4
|
+
*
|
|
5
|
+
* Included Metadata:
|
|
6
|
+
* | Name | Description |
|
|
7
|
+
* | --- | --- |
|
|
8
|
+
* | `name` | The name of the server (e.g. `petstore_example`) |
|
|
9
|
+
* | `time` | The current UTC timestamp of the server |
|
|
10
|
+
* | `version` | The release version of the server. (e.g. `1.0.0`) |
|
|
11
|
+
*
|
|
12
|
+
* Exposed endpoints:
|
|
13
|
+
*
|
|
14
|
+
* | Name | HTTP Method | What it does |
|
|
15
|
+
* | --- | --- | --- |
|
|
16
|
+
* | `get` | `GET /<base_path>` | Returns the server's status metadata |
|
|
17
|
+
*
|
|
18
|
+
* !!Note!! that the `BaseAdminRoute` is not automatically registered with a server by default. You must create
|
|
19
|
+
* your own class that extends `AdminRoute` and apply the desired base path with `@Route()`.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* import { BaseStatusRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
24
|
+
* const { Route } = RouteDecorators;
|
|
25
|
+
*
|
|
26
|
+
* @Route("/status")
|
|
27
|
+
* export class StatusRoute extends BaseStatusRoute {}
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @author Jean-Philippe Steinmetz
|
|
31
|
+
*/
|
|
32
|
+
export declare class BaseStatusRoute {
|
|
33
|
+
protected serviceName: any;
|
|
34
|
+
protected serviceVersion: any;
|
|
35
|
+
protected statusExtraData: StatusExtraData | undefined;
|
|
36
|
+
get(): any;
|
|
37
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { BaseEntity } from "../models/BaseEntity.js";
|
|
2
|
+
import type { HttpRequest, HttpResponse } from "../http/index.js";
|
|
3
|
+
import { SimpleEntity } from "../models/SimpleEntity.js";
|
|
4
|
+
import { type JWTUser } from "@rapidrest/core";
|
|
5
|
+
import { ModelRoute, type UpdateObject } from "./ModelRoute.js";
|
|
6
|
+
/**
|
|
7
|
+
* The `CRUDRoute` provides a base implementation of all CRUD endpoint behaviors that `ModelRoute` offers for a given
|
|
8
|
+
* data model class. This class provides the most common default settings for each route handler. If you desire additional
|
|
9
|
+
* functionality you may override the handler function and add desired functionality via additional decorators or override
|
|
10
|
+
* existing decorator behavior.
|
|
11
|
+
*
|
|
12
|
+
* The route endpoints provided by this class do not explicitly require authentication. However, if the RBAC system
|
|
13
|
+
* is enabled these handlers will still validate permissions appropriately.
|
|
14
|
+
*
|
|
15
|
+
* Included Endpoints:
|
|
16
|
+
*
|
|
17
|
+
* | Name | HTTP Method | What it does |
|
|
18
|
+
* | --- | --- | --- |
|
|
19
|
+
* | `count` | `HEAD /` | Counts the number of objects matching the provided set of criteria in the request's query parameters. Returns the count as the value of the `Content-Length` header. |
|
|
20
|
+
* | `create` | `POST /` | Adds one or more new objects to the datasource. |
|
|
21
|
+
* | `delete` | `DELETE /:id` | Removes an existing object from the datasource. |
|
|
22
|
+
* | `exists` | `HEAD /:id` | Checks if the object with the given ID exists in the datasource. Sets `Content-Length` header to `1` if the object exists, otherwise `0`. |
|
|
23
|
+
* | `find` | `GET /` | Returns all objects matching the provided set of criteria in the request's query parameters. |
|
|
24
|
+
* | `findById` | `GET /:id` | Returns a single object with a specified unique identifier. |
|
|
25
|
+
* | `truncate` | `DELETE /` | Removes all objects from the datasource. |
|
|
26
|
+
* | `update` | `PUT /:id` | Modifies an existing object in the datasource. |
|
|
27
|
+
* | `updateBulk` | `PUT /` | Modifies multiple existing objects in the datasource. |
|
|
28
|
+
* | `updateProperty` | `PUT /:id/:property` | Modifies an single property of the given name of an existing object in the datasource. |
|
|
29
|
+
*
|
|
30
|
+
* @author Jean-Philippe Steinmetz
|
|
31
|
+
*/
|
|
32
|
+
export declare abstract class CRUDRoute<T extends BaseEntity | SimpleEntity> extends ModelRoute<T> {
|
|
33
|
+
protected readonly repoUtilsClass: any;
|
|
34
|
+
count(params: any, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Override this function to perform additional custom validation of object creation. This is called
|
|
37
|
+
* for each object passed to the `create()` operation.
|
|
38
|
+
*/
|
|
39
|
+
protected validateCreate(obj: Partial<T>, user?: JWTUser): Promise<void>;
|
|
40
|
+
private validateCreateBulk;
|
|
41
|
+
create(obj: T | T[], req: HttpRequest, user?: JWTUser): Promise<T | Array<T>>;
|
|
42
|
+
delete(id: string, version: string | undefined, purge: string | undefined, req: HttpRequest, user?: JWTUser): Promise<void>;
|
|
43
|
+
exists(id: string, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
|
|
44
|
+
find(params: any, query: any, user?: JWTUser): Promise<Array<T>>;
|
|
45
|
+
findById(id: string, query: any, user?: JWTUser): Promise<T | null>;
|
|
46
|
+
truncate(params: any, query: any, user?: JWTUser): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Override this function to perform additional custom validation of object updates. This is called
|
|
49
|
+
* for `update()` and `updateBulk()` operations. `updateBulk()` calls this function for each update
|
|
50
|
+
* object.
|
|
51
|
+
*/
|
|
52
|
+
protected validateUpdate(id: string, obj: UpdateObject<T>, user?: JWTUser): Promise<void>;
|
|
53
|
+
update(id: string, obj: UpdateObject<T>, req: HttpRequest, user?: JWTUser): Promise<T>;
|
|
54
|
+
private validateUpdateBulk;
|
|
55
|
+
updateBulk(obj: UpdateObject<T>[], req: HttpRequest, user?: JWTUser): Promise<T[]>;
|
|
56
|
+
updateProperty(id: string, propertyName: string, obj: any, user?: JWTUser): Promise<T>;
|
|
57
|
+
}
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RepoUtils, type RepoOperationOptions } from "../models/RepoUtils.js";
|
|
2
2
|
import { BaseEntity } from "../models/BaseEntity.js";
|
|
3
|
-
import {
|
|
4
|
-
import type { HttpRequest as XRequest, HttpResponse as XResponse } from "../http/index.js";
|
|
3
|
+
import type { HttpRequest, HttpResponse } from "../http/index.js";
|
|
5
4
|
import { SimpleEntity } from "../models/SimpleEntity.js";
|
|
6
|
-
import { AccessControlList } from "../security/AccessControlList.js";
|
|
5
|
+
import { type AccessControlList } from "../security/AccessControlList.js";
|
|
7
6
|
import { ACLUtils } from "../security/ACLUtils.js";
|
|
8
7
|
import { NotificationUtils } from "../NotificationUtils.js";
|
|
9
|
-
import { ObjectFactory } from "../ObjectFactory.js";
|
|
10
8
|
/**
|
|
11
9
|
* The set of options required by all request handlers.
|
|
12
10
|
*/
|
|
13
11
|
export interface RequestOptions extends RepoOperationOptions {
|
|
14
12
|
/** The originating client request. */
|
|
15
|
-
req?:
|
|
13
|
+
req?: HttpRequest;
|
|
16
14
|
/** The outgoing client response. */
|
|
17
|
-
res?:
|
|
15
|
+
res?: HttpResponse;
|
|
18
16
|
}
|
|
19
17
|
/**
|
|
20
18
|
* The set of options required by create request handlers.
|
|
@@ -67,7 +65,7 @@ export type UpdateObject<T extends BaseEntity | SimpleEntity> = Partial<T> & Pic
|
|
|
67
65
|
* The set of options required by update request handlers.
|
|
68
66
|
*/
|
|
69
67
|
export interface UpdateRequestOptions<T extends BaseEntity | SimpleEntity> extends RequestOptions {
|
|
70
|
-
/** The existing object that has already been recently pulled from the
|
|
68
|
+
/** The existing object that has already been recently pulled from the datasource. */
|
|
71
69
|
existing?: T | null;
|
|
72
70
|
/** An additional list of channel names to send push notifications to. */
|
|
73
71
|
pushChannels?: string[];
|
|
@@ -78,30 +76,35 @@ export interface UpdateRequestOptions<T extends BaseEntity | SimpleEntity> exten
|
|
|
78
76
|
}
|
|
79
77
|
/**
|
|
80
78
|
* The `ModelRoute` is an abstract base class that provides a set of built-in route behavior functions for handling
|
|
81
|
-
* requests for a given data model that is managed by a persistent
|
|
79
|
+
* requests for a given data model that is managed by a persistent datasource. This class _does not_ provide route
|
|
80
|
+
* handlers for the defined behaviors. This class is intended to serve as a base class for you to extend and hook
|
|
81
|
+
* up your own route handlers that use the included functionality as desired so that you only expose the CRUD
|
|
82
|
+
* endpoints for your model that you desire. If you desire a fully functional set of route handlers that implements
|
|
83
|
+
* all of these behaviors you should extend the `CRUDRoute` class instead.
|
|
82
84
|
*
|
|
83
85
|
* Provided behaviors:
|
|
84
|
-
* * `
|
|
85
|
-
* * `
|
|
86
|
-
* * `
|
|
87
|
-
* * `
|
|
88
|
-
* * `
|
|
89
|
-
* * `
|
|
90
|
-
* * `
|
|
86
|
+
* * `doCount`: Counts the number of objects matching the provided set of criteria in the request's query parameters. Returns the count as the value of the `Content-Length` header.
|
|
87
|
+
* * `doCreate`: Adds one or more new objects to the datasource.
|
|
88
|
+
* * `doDelete`: Removes an existing object from the datasource.
|
|
89
|
+
* * `doExists`: Checks if the object with the given ID exists in the datasource. Sets `Content-Length` header to `1` if the object exists, otherwise `0`.
|
|
90
|
+
* * `doFind`: Returns all objects matching the provided set of criteria in the request's query parameters.
|
|
91
|
+
* * `doFindById`: Returns a single object with a specified unique identifier.
|
|
92
|
+
* * `doTruncate`: Removes all objects from the datasource.
|
|
93
|
+
* * `doUpdate`: Modifies an existing object in the datasource.
|
|
94
|
+
* * `doUpdateBulk`: Modifies multiple existing objects in the datasource.
|
|
95
|
+
* * `doUpdateProperty`: Modifies an single property of the given name of an existing object in the datasource.
|
|
91
96
|
*
|
|
92
97
|
* @author Jean-Philippe Steinmetz
|
|
93
98
|
*/
|
|
94
99
|
export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
|
|
100
|
+
private _objectFactory?;
|
|
95
101
|
protected aclUtils?: ACLUtils;
|
|
96
|
-
/** The redis client that will be used as a 2nd level cache for all cacheable models. */
|
|
97
|
-
protected cacheClient?: Redis;
|
|
98
102
|
/** The global application configuration. */
|
|
99
103
|
protected config?: any;
|
|
100
104
|
/** The unique identifier of the default ACL for the model type. */
|
|
101
105
|
protected defaultACLUid: string;
|
|
102
106
|
protected logger: any;
|
|
103
107
|
protected notificationUtils?: NotificationUtils;
|
|
104
|
-
protected objectFactory?: ObjectFactory;
|
|
105
108
|
/** The class of the RepoUtils to use when instantiating the utility. */
|
|
106
109
|
protected abstract readonly repoUtilsClass: any;
|
|
107
110
|
/** The repository utility class to use for common operations. */
|
|
@@ -126,34 +129,34 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
|
|
|
126
129
|
*
|
|
127
130
|
* @param options The options to process the request using.
|
|
128
131
|
*/
|
|
129
|
-
doCount(options: FindRequestOptions): Promise<
|
|
132
|
+
protected doCount(options: FindRequestOptions): Promise<HttpResponse>;
|
|
130
133
|
/**
|
|
131
|
-
* Attempts to store an object provided in `options.req.body` into the
|
|
134
|
+
* Attempts to store an object provided in `options.req.body` into the datasource. Upon success, sets the newly persisted
|
|
132
135
|
* object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
|
|
133
136
|
* client.
|
|
134
137
|
*
|
|
135
138
|
* @param obj The object to store in the database.
|
|
136
139
|
* @param options The options to process the request using.
|
|
137
140
|
*/
|
|
138
|
-
doCreateObject(obj: Partial<T>, options: CreateRequestOptions): Promise<T>;
|
|
141
|
+
protected doCreateObject(obj: Partial<T>, options: CreateRequestOptions): Promise<T>;
|
|
139
142
|
/**
|
|
140
|
-
* Attempts to store a collection of objects provided in `options.req.body` into the
|
|
143
|
+
* Attempts to store a collection of objects provided in `options.req.body` into the datasource. Upon success, sets the newly persisted
|
|
141
144
|
* object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
|
|
142
145
|
* client.
|
|
143
146
|
*
|
|
144
147
|
* @param objs The object(s) to store in the database.
|
|
145
148
|
* @param options The options to process the request using.
|
|
146
149
|
*/
|
|
147
|
-
doBulkCreate(objs: Partial<T>[], options: CreateRequestOptions): Promise<T[]>;
|
|
150
|
+
protected doBulkCreate(objs: Partial<T>[], options: CreateRequestOptions): Promise<T[]>;
|
|
148
151
|
/**
|
|
149
|
-
* Attempts to store one or more objects provided in `options.req.body` into the
|
|
152
|
+
* Attempts to store one or more objects provided in `options.req.body` into the datasource. Upon success, sets the newly persisted
|
|
150
153
|
* object(s) to the `result` property of the `options.res` argument, otherwise sends a `400 BAD REQUEST` response to the
|
|
151
154
|
* client.
|
|
152
155
|
*
|
|
153
156
|
* @param obj The object(s) to store in the database.
|
|
154
157
|
* @param options The options to process the request using.
|
|
155
158
|
*/
|
|
156
|
-
doCreate(obj: Partial<T> | Partial<T>[], options: CreateRequestOptions): Promise<T | T[]>;
|
|
159
|
+
protected doCreate(obj: Partial<T> | Partial<T>[], options: CreateRequestOptions): Promise<T | T[]>;
|
|
157
160
|
/**
|
|
158
161
|
* Attempts to delete an existing data model object with a given unique identifier encoded by the URI parameter
|
|
159
162
|
* `id`.
|
|
@@ -161,14 +164,14 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
|
|
|
161
164
|
* @param id The unique identifier of the object to delete.
|
|
162
165
|
* @param options The options to process the request using.
|
|
163
166
|
*/
|
|
164
|
-
doDelete(id: string, options: DeleteRequestOptions): Promise<void>;
|
|
167
|
+
protected doDelete(id: string, options: DeleteRequestOptions): Promise<void>;
|
|
165
168
|
/**
|
|
166
169
|
* Attempts to determine if an existing object with the given unique identifier exists.
|
|
167
170
|
*
|
|
168
171
|
* @param id The unique identifier of the object to verify exists.
|
|
169
172
|
* @param options The options to process the request using.
|
|
170
173
|
*/
|
|
171
|
-
doExists(id: string, options: FindRequestOptions): Promise<any>;
|
|
174
|
+
protected doExists(id: string, options: FindRequestOptions): Promise<any>;
|
|
172
175
|
/**
|
|
173
176
|
* Attempts to retrieve all data model objects matching the given set of criteria as specified in the request
|
|
174
177
|
* `query`. Any results that have been found are set to the `result` property of the `res` argument. `result` is
|
|
@@ -176,34 +179,34 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
|
|
|
176
179
|
*
|
|
177
180
|
* @param options The options to process the request using.
|
|
178
181
|
*/
|
|
179
|
-
|
|
182
|
+
protected doFind(options: FindRequestOptions): Promise<T[]>;
|
|
180
183
|
/**
|
|
181
184
|
* Attempts to retrieve a single data model object as identified by the `id` parameter in the URI.
|
|
182
185
|
*
|
|
183
186
|
* @param options The options to process the request using.
|
|
184
187
|
*/
|
|
185
|
-
doFindById(id: string, options: FindRequestOptions): Promise<T | null>;
|
|
188
|
+
protected doFindById(id: string, options: FindRequestOptions): Promise<T | null>;
|
|
186
189
|
/**
|
|
187
|
-
* Attempts to remove all entries of the data model type from the
|
|
190
|
+
* Attempts to remove all entries of the data model type from the datasource matching the given
|
|
188
191
|
* parameters and query.
|
|
189
192
|
*
|
|
190
193
|
* @param options The options to process the request using.
|
|
191
194
|
*/
|
|
192
|
-
doTruncate(options: TruncateRequestOptions): Promise<void>;
|
|
195
|
+
protected doTruncate(options: TruncateRequestOptions): Promise<void>;
|
|
193
196
|
/**
|
|
194
197
|
* Attempts to modify a collection of existing data model objects.
|
|
195
198
|
*
|
|
196
199
|
* @param objs The object(s) to bulk update in the database.
|
|
197
200
|
* @param options The options to process the request using.
|
|
198
201
|
*/
|
|
199
|
-
doBulkUpdate(objs: UpdateObject<T>[], options: UpdateRequestOptions<T>): Promise<T[]>;
|
|
202
|
+
protected doBulkUpdate(objs: UpdateObject<T>[], options: UpdateRequestOptions<T>): Promise<T[]>;
|
|
200
203
|
/**
|
|
201
204
|
* Attempts to modify an existing data model object as identified by the `id` parameter in the URI.
|
|
202
205
|
*
|
|
203
206
|
* @param obj The object to update in the database
|
|
204
207
|
* @param options The options to process the request using.
|
|
205
208
|
*/
|
|
206
|
-
doUpdate(id: string, obj: UpdateObject<T>, options: UpdateRequestOptions<T>): Promise<T>;
|
|
209
|
+
protected doUpdate(id: string, obj: UpdateObject<T>, options: UpdateRequestOptions<T>): Promise<T>;
|
|
207
210
|
/**
|
|
208
211
|
* Attempts to modify a single property of an existing data model object as identified by the `id` parameter in the URI.
|
|
209
212
|
*
|
|
@@ -214,9 +217,9 @@ export declare abstract class ModelRoute<T extends BaseEntity | SimpleEntity> {
|
|
|
214
217
|
* @param value The value of the property to set.
|
|
215
218
|
* @param options The options to process the request using.
|
|
216
219
|
*/
|
|
217
|
-
doUpdateProperty(id: string, propertyName: string, value: any, options: UpdateRequestOptions<T>): Promise<T>;
|
|
220
|
+
protected doUpdateProperty(id: string, propertyName: string, value: any, options: UpdateRequestOptions<T>): Promise<T>;
|
|
218
221
|
/**
|
|
219
222
|
* Calls `repoUtils.validate()` to validate the object(s) provided.
|
|
220
223
|
*/
|
|
221
|
-
|
|
224
|
+
validate(objs: Partial<T> | Partial<T>[], options?: CreateRequestOptions | UpdateRequestOptions<T>): Promise<void>;
|
|
222
225
|
}
|
|
@@ -9,6 +9,12 @@ export declare class RouteUtils {
|
|
|
9
9
|
private apiSpec;
|
|
10
10
|
private authMiddleware?;
|
|
11
11
|
private logger?;
|
|
12
|
+
protected trustedRoles: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Creates a middleware function that checks if the user has elevated privileges and if not
|
|
15
|
+
* throws the `AUTH_REQUIRES_ELEVATION` error.
|
|
16
|
+
*/
|
|
17
|
+
checkElevation(lastStart?: number): RequestHandler;
|
|
12
18
|
/**
|
|
13
19
|
* Creates a middleware function that verifies the incoming request is from a valid user with at least
|
|
14
20
|
* one of the specified roles.
|
|
@@ -21,6 +27,19 @@ export declare class RouteUtils {
|
|
|
21
27
|
* @param requiredRoles The list of roles that the authenticated user must have.
|
|
22
28
|
*/
|
|
23
29
|
checkRequiredRoles(requiredRoles: string[]): RequestHandler;
|
|
30
|
+
/**
|
|
31
|
+
* Creates a middleware function that verifies the incoming request is from a valid user with at least
|
|
32
|
+
* one of the trusted roles.
|
|
33
|
+
*/
|
|
34
|
+
checkTrusedRoles(): RequestHandler;
|
|
35
|
+
/**
|
|
36
|
+
* Creates a middleware function that verifies the incoming request's token carries at least one of the
|
|
37
|
+
* specified scopes. This is a coarse, token-level pre-check that runs before the per-resource ACL check —
|
|
38
|
+
* see `RequiresScope`.
|
|
39
|
+
*
|
|
40
|
+
* @param requiredScopes The list of scopes of which the authenticated user's token must carry at least one.
|
|
41
|
+
*/
|
|
42
|
+
checkRequiredScopes(requiredScopes: string[]): RequestHandler;
|
|
24
43
|
/**
|
|
25
44
|
* Converts the given array of string or Function objects to functions bound to the given route object.
|
|
26
45
|
*
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
1
|
+
export * from "./BaseAdminRoute.js";
|
|
2
|
+
export * from "./BaseMetricsRoute.js";
|
|
3
|
+
export * from "./BaseOpenAPIRoute.js";
|
|
4
|
+
export * from "./BasePushRoute.js";
|
|
5
|
+
export * from "./BaseStaticRoute.js";
|
|
6
|
+
export * from "./BaseStatusRoute.js";
|
|
7
|
+
export * from "./CRUDRoute.js";
|
|
3
8
|
export * from "./ModelRoute.js";
|
|
4
|
-
export * from "./OpenAPIRoute.js";
|
|
5
9
|
export * from "./RouteUtils.js";
|
|
6
|
-
export * from "./StatusRoute.js";
|