@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
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { JWTUser } from "@rapidrest/core";
|
|
2
|
-
import type { HttpRequest
|
|
3
|
-
import { AccessControlList,
|
|
1
|
+
import { type JWTUser } from "@rapidrest/core";
|
|
2
|
+
import type { HttpRequest } from "../http/index.js";
|
|
3
|
+
import { type AccessControlList, type ACLRecord } from "./AccessControlList.js";
|
|
4
4
|
/**
|
|
5
5
|
* Common utility functions for working with `AccessControlList` objects and validating user permissions.
|
|
6
|
+
*
|
|
7
|
+
* @author Jean-Philippe Steinmetz
|
|
6
8
|
*/
|
|
7
9
|
export declare class ACLUtils {
|
|
10
|
+
private _objectFactory?;
|
|
8
11
|
enabled: boolean;
|
|
9
|
-
private
|
|
12
|
+
private cache?;
|
|
10
13
|
private connMgr?;
|
|
11
14
|
private logger?;
|
|
12
15
|
private trustedRoles;
|
|
13
|
-
private get cacheClient();
|
|
14
16
|
private get repo();
|
|
15
17
|
private init;
|
|
16
18
|
/**
|
|
17
|
-
*
|
|
19
|
+
* Classifies how specifically the given user matches the provided ACL record id. Used by `getRecord()` to
|
|
20
|
+
* prefer the most specific match among a record's siblings, rather than the first one in array order.
|
|
18
21
|
* @param user The user to check.
|
|
19
22
|
* @param userOrRoleId The ACL record id to check against.
|
|
20
|
-
* @returns `
|
|
23
|
+
* @returns `"exact"` for a direct uid/anonymous match, `"role"` for a role match, `"wildcard"` for a `.*`/`*`
|
|
24
|
+
* match, or `"none"` if the user doesn't match this id at all.
|
|
21
25
|
*/
|
|
22
|
-
private
|
|
26
|
+
private matchSpecificity;
|
|
23
27
|
/**
|
|
24
28
|
* Validates that the user has permission to perform the request operation against the URL path for the
|
|
25
|
-
* provided request. If ACLUtils has not been initialized or the `acl`
|
|
29
|
+
* provided request. If ACLUtils has not been initialized or the `acl` datasource has not been configured
|
|
26
30
|
* then always returns `true`.
|
|
27
31
|
*
|
|
28
32
|
* @param uid The uid of the access control list to verify against.
|
|
29
33
|
* @param user The user to validate.
|
|
30
|
-
* @param req The request
|
|
34
|
+
* @param req The HTTP request to check permissions for.
|
|
31
35
|
*/
|
|
32
|
-
checkRequestPerms(uid: string, user: JWTUser | undefined, req:
|
|
36
|
+
checkRequestPerms(uid: string, user: JWTUser | undefined, req: HttpRequest): Promise<boolean>;
|
|
33
37
|
/**
|
|
34
38
|
* Validates that the user has permission to perform the provided action using the given access control list.
|
|
35
39
|
*
|
|
@@ -38,19 +42,43 @@ export declare class ACLUtils {
|
|
|
38
42
|
* @param action The action that the user desires permission for.
|
|
39
43
|
* @returns `true` if the user has at least one of the permissions granted for the given entity, otherwise `false`.
|
|
40
44
|
*/
|
|
41
|
-
hasPermission(user: JWTUser | undefined, acl: AccessControlList | string, action:
|
|
45
|
+
hasPermission(user: JWTUser | undefined, acl: AccessControlList | string, action: string): Promise<boolean>;
|
|
42
46
|
/**
|
|
43
47
|
* Retrieves the access control list with the associated identifier and populates the parent(s).
|
|
44
48
|
*
|
|
49
|
+
* Deliberately not `@Transactional` and never participates in a caller's transaction: it's on the hot path
|
|
50
|
+
* for every permission check (`hasPermission`/`checkRequestPerms`), not just writes, so wrapping it would
|
|
51
|
+
* add a session open/close to every authorization check. It also has no way to safely reuse a *caller's*
|
|
52
|
+
* transaction context.
|
|
53
|
+
*
|
|
45
54
|
* @param entityId The unique identifier of the ACL to retrieve.
|
|
46
55
|
* @param parentUids The list of already found parent UIDs. This is used to break circular dependencies.
|
|
56
|
+
* @param options Set `skipCache: true` to bypass the cache and always read the current database state —
|
|
57
|
+
* mirrors `RepoUtils`'s `RepoFindOptions.skipCache`. The result is still written back into the cache
|
|
58
|
+
* afterward, same as a normal (non-skipped) lookup.
|
|
47
59
|
*/
|
|
48
|
-
findACL(entityId: string, parentUids?: string[],
|
|
60
|
+
findACL(entityId: string, parentUids?: string[], options?: {
|
|
61
|
+
skipCache?: boolean;
|
|
62
|
+
}): Promise<AccessControlList | undefined>;
|
|
49
63
|
/**
|
|
50
|
-
* Deletes the ACL with the given identifier from the database
|
|
64
|
+
* Deletes the ACL with the given identifier from the database, returning the document that was actually
|
|
65
|
+
* deleted (or `undefined` if none existed) — captured atomically as part of the delete itself (Mongo:
|
|
66
|
+
* `findOneAndDelete`; SQL: a `findOne` immediately followed by the `delete`, both inside this method's own
|
|
67
|
+
* `acl` transaction), not a separate, earlier read. A caller using the return value as a restore snapshot
|
|
68
|
+
* (see `RepoUtils.delete()`/`truncate()`'s `registerRollbackHook()` usage) always gets the exact row that
|
|
69
|
+
* was removed, never a possibly-stale one raced by a concurrent legitimate write between an earlier read
|
|
70
|
+
* and this delete — and restoring it later still goes through `saveACL()`'s own optimistic-lock version
|
|
71
|
+
* check, so a restore attempt can't clobber a *newer* row that appeared after this delete either.
|
|
72
|
+
*
|
|
73
|
+
* Runs in its own transaction scoped to the `acl` connection (see `Transactional`) rather than trying to
|
|
74
|
+
* join whatever transaction the caller is itself in — `acl` is frequently configured as its own, separate
|
|
75
|
+
* datastore (a documented, supported deployment shape), so a caller's session/entityManager almost never
|
|
76
|
+
* actually belongs to the same physical connection this repo does. Reusing it directly used to throw
|
|
77
|
+
* (Mongo) or silently target the wrong connection (SQL).
|
|
78
|
+
*
|
|
51
79
|
* @param uid The unique identifier of the ACL to remove.
|
|
52
80
|
*/
|
|
53
|
-
removeACL(uid: string): Promise<
|
|
81
|
+
removeACL(uid: string): Promise<AccessControlList | undefined>;
|
|
54
82
|
/**
|
|
55
83
|
* Compares two ACLs to see if they have been modified and returns the total number of changes between them.
|
|
56
84
|
*
|
|
@@ -60,12 +88,31 @@ export declare class ACLUtils {
|
|
|
60
88
|
*/
|
|
61
89
|
private diffACL;
|
|
62
90
|
/**
|
|
63
|
-
*
|
|
91
|
+
* Compares two lists of granted actions, ignoring order, to see if they differ.
|
|
92
|
+
*/
|
|
93
|
+
private actionsChanged;
|
|
94
|
+
/**
|
|
95
|
+
* Stores the given access control list into the ACL database. By default, bumps the version for optimistic
|
|
96
|
+
* locking (see below) — pass `preserveVersion: true` to instead write `acl` back with its own version
|
|
97
|
+
* exactly as given, for restoring a known-good snapshot (see `RepoUtils.delete()`/`truncate()`'s
|
|
98
|
+
* `registerRollbackHook()` usage) rather than applying a new change on top of whatever's currently stored.
|
|
99
|
+
* A restore only ever targets a uid with nothing currently at it (that's the point — the entity-side
|
|
100
|
+
* transaction it was tied to is being rolled back, so the row it deleted should no longer exist); if
|
|
101
|
+
* something *does* exist there already, the restore is refused rather than silently clobbering it.
|
|
102
|
+
*
|
|
103
|
+
* Runs in its own transaction scoped to the `acl` connection (see `Transactional`) rather than trying to
|
|
104
|
+
* join whatever transaction the caller is itself in — see `removeACL`'s doc comment for why. Callers that
|
|
105
|
+
* need the entity-side write and this ACL save to stay consistent should register a compensating action
|
|
106
|
+
* via `registerRollbackHook()`.
|
|
64
107
|
*
|
|
65
108
|
* @param acl The ACL to store.
|
|
109
|
+
* @param options Set `preserveVersion: true` to restore `acl` exactly as given (see above) instead of the
|
|
110
|
+
* normal optimistic-locking update semantics.
|
|
66
111
|
* @return Returns the ACL that was stored in the database.
|
|
67
112
|
*/
|
|
68
|
-
saveACL(acl: AccessControlList
|
|
113
|
+
saveACL(acl: AccessControlList, options?: {
|
|
114
|
+
preserveVersion?: boolean;
|
|
115
|
+
}): Promise<AccessControlList | null>;
|
|
69
116
|
/**
|
|
70
117
|
* Stores the given default access control list into the ACL database. A default ACL is a special type of ACL
|
|
71
118
|
* that is primarily defined and maintained within the code but allows for user-specific overrides. To accomplish
|
|
@@ -80,7 +127,36 @@ export declare class ACLUtils {
|
|
|
80
127
|
*/
|
|
81
128
|
saveDefaultACL(acl: AccessControlList): Promise<AccessControlList | null>;
|
|
82
129
|
/**
|
|
83
|
-
*
|
|
130
|
+
* Atomic removal of multiple ACLs in a single `acl`-scoped transaction (see `@Transactional`), returning
|
|
131
|
+
* whichever of them actually existed to be deleted (see `removeACL()`'s doc comment for why the returned
|
|
132
|
+
* documents — not a separate, earlier read — are the right thing to snapshot for a possible restore).
|
|
133
|
+
*
|
|
134
|
+
* Deliberately sequential, not batched-concurrent: every `removeACL()` call below resolves to this same
|
|
135
|
+
* `acl` datasource, so `@Transactional`'s merge logic joins all of them onto the one MongoDB
|
|
136
|
+
* `ClientSession`/SQL `EntityManager` this method opened. Running these with `Promise.all`
|
|
137
|
+
* would issue overlapping commands against one session, which drivers reject or misorder.
|
|
138
|
+
*
|
|
139
|
+
* @param uids The unique identifiers of the ACLs to remove.
|
|
140
|
+
*/
|
|
141
|
+
removeACLs(uids: string[]): Promise<AccessControlList[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Atomic save of multiple ACLs in a single `acl`-scoped transaction (see `Transactional`). Used to restore
|
|
144
|
+
* a batch of ACL snapshots — e.g. by a `registerRollbackHook()` compensating action — if the entity-side
|
|
145
|
+
* transaction they were removed alongside subsequently fails. Always restores each ACL's own version as
|
|
146
|
+
* given (see `saveACL()`'s `preserveVersion` option) rather than bumping it, since this is a restore, not
|
|
147
|
+
* a new change.
|
|
148
|
+
*
|
|
149
|
+
* Deliberately sequential. See `removeACLs()`'s doc comment for why.
|
|
150
|
+
*
|
|
151
|
+
* @param acls The ACLs to store.
|
|
152
|
+
*/
|
|
153
|
+
saveACLs(acls: AccessControlList[]): Promise<void>;
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves the most specific record in the provided ACL associated with the provided user: an exact
|
|
156
|
+
* uid/anonymous match beats a role match, which beats a wildcard (`.*`/`*`) match — regardless of where
|
|
157
|
+
* each record sits in `acl.records`. Without this, a wildcard grant authored before a specific record
|
|
158
|
+
* (a natural authoring order) would silently shadow that more specific record. Only falls back to the
|
|
159
|
+
* parent ACL when nothing in this ACL's own records matches at all.
|
|
84
160
|
*
|
|
85
161
|
* @param acl The access control list that will be searched.
|
|
86
162
|
* @param user The user to find a record for.
|
|
@@ -1,27 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* A set of conventional action strings recognized by the built-in CRUD routes and `RepoUtils`. `ACLRecord.actions`
|
|
3
|
+
* is not limited to these values — any arbitrary string may be granted (e.g. `"publish"`, `"document:archive"`) to
|
|
4
|
+
* express permissions beyond basic CRUD.
|
|
3
5
|
*
|
|
4
6
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
5
7
|
*/
|
|
6
|
-
export declare
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
export declare const ACLAction: {
|
|
9
|
+
/**
|
|
10
|
+
* Grants every action, including any action string not otherwise listed on the record. Supersedes all others.
|
|
11
|
+
*/
|
|
12
|
+
readonly FULL: "*";
|
|
13
|
+
readonly COUNT: "count";
|
|
14
|
+
readonly CREATE: "create";
|
|
15
|
+
readonly DELETE: "delete";
|
|
16
|
+
readonly EXISTS: "exists";
|
|
17
|
+
readonly LIST: "list";
|
|
18
|
+
readonly READ: "read";
|
|
19
|
+
readonly TRUNCATE: "truncate";
|
|
20
|
+
readonly UPDATE: "update";
|
|
21
|
+
};
|
|
14
22
|
/**
|
|
15
|
-
* The `ACLRecord` interface describes a single permissions entry in an `AccessControlList` that grants
|
|
16
|
-
*
|
|
23
|
+
* The `ACLRecord` interface describes a single permissions entry in an `AccessControlList` that grants a set of
|
|
24
|
+
* actions to a single user or role.
|
|
17
25
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
26
|
+
* `actions` is an arbitrary list of action strings the user or role is granted for the entity. The conventional
|
|
27
|
+
* CRUD actions are defined in `ACLAction`, but any string may be used to express custom, service-specific
|
|
28
|
+
* permissions. The sentinel value `ACLAction.FULL` (`"*"`) grants every action and supersedes all others.
|
|
29
|
+
*
|
|
30
|
+
* If no record matches a given user or role, permission is looked up on the `parent` ACL (see `parentUid`)
|
|
31
|
+
* instead. There is no per-action inheritance within a single matched record — if a record matches, only the
|
|
32
|
+
* actions it explicitly lists are granted.
|
|
33
|
+
*
|
|
34
|
+
* ACLs can be chained via single inheritance through the specification of the `parentUid`. This allows the ability to
|
|
35
|
+
* create complex trees of permissions that can easily inherit control schemes to make the definition of permissions
|
|
36
|
+
* easier.
|
|
25
37
|
*
|
|
26
38
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
27
39
|
*/
|
|
@@ -31,52 +43,18 @@ export interface ACLRecord {
|
|
|
31
43
|
*/
|
|
32
44
|
userOrRoleId: string;
|
|
33
45
|
/**
|
|
34
|
-
*
|
|
46
|
+
* The list of actions this user or role is granted for the entity. `ACLAction.FULL` (`"*"`) grants everything.
|
|
35
47
|
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Indicates that the user or role has permission to read records of the entity.
|
|
39
|
-
*/
|
|
40
|
-
read: boolean | null;
|
|
41
|
-
/**
|
|
42
|
-
* Indicates that the user or role has permission to modify existing records of the entity.
|
|
43
|
-
*/
|
|
44
|
-
update: boolean | null;
|
|
45
|
-
/**
|
|
46
|
-
* Indicates that the user or role has permission to delete existing records of the entity.
|
|
47
|
-
*/
|
|
48
|
-
delete: boolean | null;
|
|
49
|
-
/**
|
|
50
|
-
* Indicates that the user or role has special permission over records of the entity. The exact meaning of this
|
|
51
|
-
* may vary by service.
|
|
52
|
-
*/
|
|
53
|
-
special: boolean | null;
|
|
54
|
-
/**
|
|
55
|
-
* Indicates that the user or role has total control over records of the entity. This supersedes all of the above
|
|
56
|
-
* permissions.
|
|
57
|
-
*/
|
|
58
|
-
full: boolean | null;
|
|
48
|
+
actions: string[];
|
|
59
49
|
}
|
|
60
50
|
/**
|
|
61
51
|
* The access control list provides a generic interface for the storage of user and roles permissions. Each ACL object
|
|
62
52
|
* represents the permission set for a single entity within the system. The entity is identified generically by its
|
|
63
|
-
* universally unique identifier (`uuid`). Each entry in the ACL records the
|
|
64
|
-
* or role.
|
|
65
|
-
*
|
|
66
|
-
* Each permission can be one of the following actions:
|
|
67
|
-
* - `Create` - The user or role can create a new record or object.
|
|
68
|
-
* - `Read` - The user or role can read the record or object.
|
|
69
|
-
* - `Update` - The user or role can modify existing records or objects.
|
|
70
|
-
* - `Delete` - The user or role can delete existing records or objects.
|
|
71
|
-
* - `Special` - The user or role has special prilieges to edit the ACL permissions.
|
|
72
|
-
* - `Full` - The user or role has total control over the record or object and supersedes any of the above.
|
|
53
|
+
* universally unique identifier (`uuid`). Each entry in the ACL records the set of actions granted to a particular
|
|
54
|
+
* user or role (see `ACLRecord`).
|
|
73
55
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
* or role is denied that action. If no explicit `allow` or `deny` is set then the user or role will inherit the
|
|
77
|
-
* permission from a parent role or ACL.
|
|
78
|
-
*
|
|
79
|
-
* ACLs can be chained via single inheritance through the specification of the `parentUid`. This allows the ability to
|
|
56
|
+
* If no record in this ACL matches a given user or role, permission is looked up on the `parent` ACL instead. ACLs
|
|
57
|
+
* can be chained via single inheritance through the specification of the `parentUid`. This allows the ability to
|
|
80
58
|
* create complex trees of permissions that can easily inherit control schemes to make the definition of permissions
|
|
81
59
|
* easier.
|
|
82
60
|
*
|
|
@@ -90,7 +68,7 @@ export interface AccessControlList {
|
|
|
90
68
|
/**
|
|
91
69
|
* The parent access control list that this instance inherits permissions from.
|
|
92
70
|
*/
|
|
93
|
-
parent?: AccessControlList
|
|
71
|
+
parent?: AccessControlList;
|
|
94
72
|
/**
|
|
95
73
|
* The universally unique identifier of the parent `AccessControlList` that this object will inherit permissions
|
|
96
74
|
* from.
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { BaseMongoEntity } from "../models/index.js";
|
|
2
|
-
import { AccessControlList, ACLRecord } from "./AccessControlList.js";
|
|
2
|
+
import type { AccessControlList, ACLRecord } from "./AccessControlList.js";
|
|
3
3
|
/**
|
|
4
4
|
* Implementation of the `ACLRecord` interface for use with MongoDB databases.
|
|
5
5
|
*/
|
|
6
6
|
export declare class ACLRecordMongo implements ACLRecord {
|
|
7
7
|
userOrRoleId: string;
|
|
8
|
-
|
|
9
|
-
read: boolean | null;
|
|
10
|
-
update: boolean | null;
|
|
11
|
-
delete: boolean | null;
|
|
12
|
-
special: boolean | null;
|
|
13
|
-
full: boolean | null;
|
|
8
|
+
actions: string[];
|
|
14
9
|
constructor(other?: any);
|
|
15
10
|
}
|
|
16
11
|
/**
|
|
@@ -18,7 +13,7 @@ export declare class ACLRecordMongo implements ACLRecord {
|
|
|
18
13
|
*/
|
|
19
14
|
export declare class AccessControlListMongo extends BaseMongoEntity implements AccessControlList {
|
|
20
15
|
parent?: AccessControlList;
|
|
21
|
-
parentUid?: string
|
|
16
|
+
parentUid?: string;
|
|
22
17
|
records: ACLRecordMongo[];
|
|
23
18
|
constructor(other?: any);
|
|
24
19
|
}
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import { BaseEntity } from "../models/BaseEntity.js";
|
|
2
|
-
import { AccessControlList, ACLRecord } from "./AccessControlList.js";
|
|
2
|
+
import type { AccessControlList, ACLRecord } from "./AccessControlList.js";
|
|
3
3
|
/**
|
|
4
4
|
* Implementation of the `ACLRecord` interface for use with SQL databases.
|
|
5
5
|
*/
|
|
6
6
|
export declare class ACLRecordSQL implements ACLRecord {
|
|
7
7
|
userOrRoleId: string;
|
|
8
|
-
|
|
9
|
-
read: boolean | null;
|
|
10
|
-
update: boolean | null;
|
|
11
|
-
delete: boolean | null;
|
|
12
|
-
special: boolean | null;
|
|
13
|
-
full: boolean | null;
|
|
8
|
+
actions: string[];
|
|
14
9
|
constructor(other?: any);
|
|
15
10
|
}
|
|
16
11
|
/**
|
|
@@ -18,7 +13,7 @@ export declare class ACLRecordSQL implements ACLRecord {
|
|
|
18
13
|
*/
|
|
19
14
|
export declare class AccessControlListSQL extends BaseEntity implements AccessControlList {
|
|
20
15
|
parent?: AccessControlList;
|
|
21
|
-
parentUid?: string
|
|
16
|
+
parentUid?: string;
|
|
22
17
|
records: ACLRecordSQL[];
|
|
23
18
|
constructor(other?: any);
|
|
24
19
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { HttpRequest, HttpResponse } from "../http/index.js";
|
|
2
|
+
import { type AccessControlList } from "./AccessControlList.js";
|
|
3
|
+
import { type JWTUser } from "@rapidrest/core";
|
|
4
|
+
import type { UpdateObject } from "../routes/ModelRoute.js";
|
|
5
|
+
import { CRUDRoute } from "../routes/CRUDRoute.js";
|
|
6
|
+
/**
|
|
7
|
+
* The `BaseACLRoute` class provides a base set of endpoints for managing Access Control List records.
|
|
8
|
+
*
|
|
9
|
+
* Exposed endpoints:
|
|
10
|
+
*
|
|
11
|
+
* | Name | HTTP Method | What it does |
|
|
12
|
+
* | --- | --- | --- |
|
|
13
|
+
* | `count` | `HEAD /` | Counts the number of ACLs matching the provided set of criteria in the request's query parameters. Returns the count as the value of the `Content-Length` header. |
|
|
14
|
+
* | `create` | `POST /` | Adds one or more new ACLs to the datasource. |
|
|
15
|
+
* | `delete` | `DELETE /:id` | Removes an existing ACL from the datasource. |
|
|
16
|
+
* | `exists` | `HEAD /:id` | Checks if the ACL with the given ID exists in the datasource. Sets `Content-Length` header to `1` if the ACL exists, otherwise `0`. |
|
|
17
|
+
* | `find` | `GET /` | Returns all ACLs matching the provided set of criteria in the request's query parameters. |
|
|
18
|
+
* | `findById` | `GET /:id` | Returns a single ACL with a specified unique identifier. |
|
|
19
|
+
* | `truncate` | `DELETE /` | Removes all ACLs from the datasource. |
|
|
20
|
+
* | `update` | `PUT /:id` | Modifies an existing ACL in the datasource. |
|
|
21
|
+
* | `updateBulk` | `PUT /` | Modifies multiple existing ACLs in the datasource. |
|
|
22
|
+
* | `updateProperty` | `PUT /:id/:property` | Modifies an single property of the given name of an existing ACL in the datasource. |
|
|
23
|
+
*
|
|
24
|
+
* !!Note!! that the `BaseACLRoute` is not automatically registered with a server by default. You must create
|
|
25
|
+
* your own class that extends `BaseACLRoute` and apply the desired base path with `@Route()`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* import { AccessControlListMongo, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
30
|
+
* const { Model, Route } = RouteDecorators;
|
|
31
|
+
*
|
|
32
|
+
* @Model(AccessControlListMongo)
|
|
33
|
+
* @Route("/acls")
|
|
34
|
+
* export class ACLRoute extends BaseACLRoute<AccessControlListMongo> {}
|
|
35
|
+
* ```
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { AccessControlListSQL, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
39
|
+
* const { Model, Route } = RouteDecorators;
|
|
40
|
+
*
|
|
41
|
+
* @Model(AccessControlListSQL)
|
|
42
|
+
* @Route("/acls")
|
|
43
|
+
* export class ACLRoute extends BaseACLRoute<AccessControlListSQL> {}
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @author Jean-Philippe Steinmetz
|
|
47
|
+
*/
|
|
48
|
+
export declare abstract class BaseACLRoute<T extends AccessControlList> extends CRUDRoute<T> {
|
|
49
|
+
protected checkPerms(params: any, user: JWTUser): Promise<void>;
|
|
50
|
+
/**
|
|
51
|
+
* The `default_<uid>` records are regenerated from code on every server startup (see
|
|
52
|
+
* `ACLUtils.saveDefaultACL`) and exist solely to seed the user-editable override record. They must never be
|
|
53
|
+
* deleted or modified directly, even by an administrator, since doing so would have no lasting effect and would
|
|
54
|
+
* only cause confusion.
|
|
55
|
+
*/
|
|
56
|
+
protected checkNotDefault(id: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Bulk updates have no `:id` URI parameter to check a per-record permission against, so unlike `checkPerms`
|
|
59
|
+
* we can't fall back to a per-record `FULL` permission check here. Require a trusted role for every bulk
|
|
60
|
+
* update instead, and disallow touching any `default_<uid>` record (see `checkNotDefault`).
|
|
61
|
+
*/
|
|
62
|
+
protected checkPermsBulk(objs: UpdateObject<T>[], user: JWTUser): void;
|
|
63
|
+
count(params: any, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
|
|
64
|
+
create(obj: T | T[], req: HttpRequest, user?: JWTUser): Promise<T | Array<T>>;
|
|
65
|
+
delete(id: string, version: string | undefined, purge: string | undefined, req: HttpRequest, user?: JWTUser): Promise<void>;
|
|
66
|
+
exists(id: string, query: any, res: HttpResponse, user?: JWTUser): Promise<any>;
|
|
67
|
+
find(params: any, query: any, user?: JWTUser): Promise<Array<T>>;
|
|
68
|
+
findById(id: string, query: any, user?: JWTUser): Promise<T | null>;
|
|
69
|
+
truncate(params: any, query: any, user?: JWTUser): Promise<void>;
|
|
70
|
+
update(id: string, obj: UpdateObject<T>, req: HttpRequest, user?: JWTUser): Promise<T>;
|
|
71
|
+
updateProperty(id: string, propertyName: string, obj: any, user?: JWTUser): Promise<T>;
|
|
72
|
+
updateBulk(obj: UpdateObject<T>[], req: HttpRequest, user?: JWTUser): Promise<T[]>;
|
|
73
|
+
}
|
|
@@ -8,10 +8,12 @@ export interface TestResponse {
|
|
|
8
8
|
type: string;
|
|
9
9
|
headers: Record<string, string>;
|
|
10
10
|
ok: boolean;
|
|
11
|
+
/** True for 3xx responses that carry a Location header, matching superagent's `res.redirect`. */
|
|
12
|
+
redirect: boolean;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Creates a supertest-style request builder that sends requests via axios to
|
|
14
|
-
* `http://localhost:<port>`.
|
|
16
|
+
* `http://localhost:<port>`. No cookie persistence between calls — each call is independent.
|
|
15
17
|
*/
|
|
16
18
|
export declare function request(app: any): {
|
|
17
19
|
get: (url: string) => any;
|
|
@@ -22,3 +24,18 @@ export declare function request(app: any): {
|
|
|
22
24
|
head: (url: string) => any;
|
|
23
25
|
options: (url: string) => any;
|
|
24
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Creates a supertest `.agent()`-style request builder that persists cookies across every call
|
|
29
|
+
* made through it, matching real browser behavior. Use this for multi-request flows where a
|
|
30
|
+
* server-set cookie (e.g. a session cookie) must be sent back on a later request — a plain
|
|
31
|
+
* `request(app)` call issues a stateless request each time and never resends cookies.
|
|
32
|
+
*/
|
|
33
|
+
export declare function agent(app: any): {
|
|
34
|
+
get: (url: string) => any;
|
|
35
|
+
post: (url: string) => any;
|
|
36
|
+
put: (url: string) => any;
|
|
37
|
+
delete: (url: string) => any;
|
|
38
|
+
patch: (url: string) => any;
|
|
39
|
+
head: (url: string) => any;
|
|
40
|
+
options: (url: string) => any;
|
|
41
|
+
};
|