@rapidrest/service-core 1.0.0-rc.7 → 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 -203
- 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,239 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { ACLAction } from "./AccessControlList.js";
|
|
14
|
+
import { ApiError, UserUtils } from "@rapidrest/core";
|
|
15
|
+
import { ApiErrorMessages, ApiErrors } from "../ApiErrors.js";
|
|
16
|
+
import { Before, Param, Query, Request, Response, User } from "../decorators/RouteDecorators.js";
|
|
17
|
+
import { CRUDRoute } from "../routes/CRUDRoute.js";
|
|
18
|
+
/**
|
|
19
|
+
* The `BaseACLRoute` class provides a base set of endpoints for managing Access Control List records.
|
|
20
|
+
*
|
|
21
|
+
* Exposed endpoints:
|
|
22
|
+
*
|
|
23
|
+
* | Name | HTTP Method | What it does |
|
|
24
|
+
* | --- | --- | --- |
|
|
25
|
+
* | `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. |
|
|
26
|
+
* | `create` | `POST /` | Adds one or more new ACLs to the datasource. |
|
|
27
|
+
* | `delete` | `DELETE /:id` | Removes an existing ACL from the datasource. |
|
|
28
|
+
* | `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`. |
|
|
29
|
+
* | `find` | `GET /` | Returns all ACLs matching the provided set of criteria in the request's query parameters. |
|
|
30
|
+
* | `findById` | `GET /:id` | Returns a single ACL with a specified unique identifier. |
|
|
31
|
+
* | `truncate` | `DELETE /` | Removes all ACLs from the datasource. |
|
|
32
|
+
* | `update` | `PUT /:id` | Modifies an existing ACL in the datasource. |
|
|
33
|
+
* | `updateBulk` | `PUT /` | Modifies multiple existing ACLs in the datasource. |
|
|
34
|
+
* | `updateProperty` | `PUT /:id/:property` | Modifies an single property of the given name of an existing ACL in the datasource. |
|
|
35
|
+
*
|
|
36
|
+
* !!Note!! that the `BaseACLRoute` is not automatically registered with a server by default. You must create
|
|
37
|
+
* your own class that extends `BaseACLRoute` and apply the desired base path with `@Route()`.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { AccessControlListMongo, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
42
|
+
* const { Model, Route } = RouteDecorators;
|
|
43
|
+
*
|
|
44
|
+
* @Model(AccessControlListMongo)
|
|
45
|
+
* @Route("/acls")
|
|
46
|
+
* export class ACLRoute extends BaseACLRoute<AccessControlListMongo> {}
|
|
47
|
+
* ```
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { AccessControlListSQL, BaseACLRoute, RouteDecorators } from "@rapidrest/service-core";
|
|
51
|
+
* const { Model, Route } = RouteDecorators;
|
|
52
|
+
*
|
|
53
|
+
* @Model(AccessControlListSQL)
|
|
54
|
+
* @Route("/acls")
|
|
55
|
+
* export class ACLRoute extends BaseACLRoute<AccessControlListSQL> {}
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @author Jean-Philippe Steinmetz
|
|
59
|
+
*/
|
|
60
|
+
export class BaseACLRoute extends CRUDRoute {
|
|
61
|
+
async checkPerms(params, user) {
|
|
62
|
+
if (!user) {
|
|
63
|
+
throw new ApiError(ApiErrors.AUTH_REQUIRED, 401, ApiErrorMessages.AUTH_REQUIRED);
|
|
64
|
+
}
|
|
65
|
+
if (!UserUtils.hasRoles(user, this.config.get("trusted_roles")) &&
|
|
66
|
+
!(params.id && (await this.aclUtils?.hasPermission(user, params.id, ACLAction.FULL)))) {
|
|
67
|
+
throw new ApiError(ApiErrors.AUTH_PERMISSION_FAILURE, 403, ApiErrorMessages.AUTH_PERMISSION_FAILURE);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The `default_<uid>` records are regenerated from code on every server startup (see
|
|
72
|
+
* `ACLUtils.saveDefaultACL`) and exist solely to seed the user-editable override record. They must never be
|
|
73
|
+
* deleted or modified directly, even by an administrator, since doing so would have no lasting effect and would
|
|
74
|
+
* only cause confusion.
|
|
75
|
+
*/
|
|
76
|
+
checkNotDefault(id) {
|
|
77
|
+
if (id && id.startsWith("default_")) {
|
|
78
|
+
throw new ApiError(ApiErrors.AUTH_PERMISSION_FAILURE, 403, ApiErrorMessages.AUTH_PERMISSION_FAILURE);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Bulk updates have no `:id` URI parameter to check a per-record permission against, so unlike `checkPerms`
|
|
83
|
+
* we can't fall back to a per-record `FULL` permission check here. Require a trusted role for every bulk
|
|
84
|
+
* update instead, and disallow touching any `default_<uid>` record (see `checkNotDefault`).
|
|
85
|
+
*/
|
|
86
|
+
checkPermsBulk(objs, user) {
|
|
87
|
+
if (!user) {
|
|
88
|
+
throw new ApiError(ApiErrors.AUTH_REQUIRED, 401, ApiErrorMessages.AUTH_REQUIRED);
|
|
89
|
+
}
|
|
90
|
+
if (!UserUtils.hasRoles(user, this.config.get("trusted_roles"))) {
|
|
91
|
+
throw new ApiError(ApiErrors.AUTH_PERMISSION_FAILURE, 403, ApiErrorMessages.AUTH_PERMISSION_FAILURE);
|
|
92
|
+
}
|
|
93
|
+
if (objs?.some((obj) => obj.uid && obj.uid.startsWith("default_"))) {
|
|
94
|
+
throw new ApiError(ApiErrors.AUTH_PERMISSION_FAILURE, 403, ApiErrorMessages.AUTH_PERMISSION_FAILURE);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
count(params, query, res, user) {
|
|
98
|
+
return super.count(params, query, res, user);
|
|
99
|
+
}
|
|
100
|
+
create(obj, req, user) {
|
|
101
|
+
return super.create(obj, req, user);
|
|
102
|
+
}
|
|
103
|
+
delete(id, version, purge, req, user) {
|
|
104
|
+
return super.delete(id, version, purge, req, user);
|
|
105
|
+
}
|
|
106
|
+
exists(id, query, res, user) {
|
|
107
|
+
return super.exists(id, query, res, user);
|
|
108
|
+
}
|
|
109
|
+
find(params, query, user) {
|
|
110
|
+
return super.find(params, query, user);
|
|
111
|
+
}
|
|
112
|
+
async findById(id, query, user) {
|
|
113
|
+
return super.findById(id, query, user);
|
|
114
|
+
}
|
|
115
|
+
truncate(params, query, user) {
|
|
116
|
+
return super.truncate(params, query, user);
|
|
117
|
+
}
|
|
118
|
+
update(id, obj, req, user) {
|
|
119
|
+
return super.update(id, obj, req, user);
|
|
120
|
+
}
|
|
121
|
+
updateProperty(id, propertyName, obj, user) {
|
|
122
|
+
return super.updateProperty(id, propertyName, obj, user);
|
|
123
|
+
}
|
|
124
|
+
updateBulk(obj, req, user) {
|
|
125
|
+
return super.updateBulk(obj, req, user);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
__decorate([
|
|
129
|
+
__param(0, Param()),
|
|
130
|
+
__param(1, User),
|
|
131
|
+
__metadata("design:type", Function),
|
|
132
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
133
|
+
__metadata("design:returntype", Promise)
|
|
134
|
+
], BaseACLRoute.prototype, "checkPerms", null);
|
|
135
|
+
__decorate([
|
|
136
|
+
__param(0, Param("id")),
|
|
137
|
+
__metadata("design:type", Function),
|
|
138
|
+
__metadata("design:paramtypes", [String]),
|
|
139
|
+
__metadata("design:returntype", void 0)
|
|
140
|
+
], BaseACLRoute.prototype, "checkNotDefault", null);
|
|
141
|
+
__decorate([
|
|
142
|
+
__param(1, User),
|
|
143
|
+
__metadata("design:type", Function),
|
|
144
|
+
__metadata("design:paramtypes", [Array, Object]),
|
|
145
|
+
__metadata("design:returntype", void 0)
|
|
146
|
+
], BaseACLRoute.prototype, "checkPermsBulk", null);
|
|
147
|
+
__decorate([
|
|
148
|
+
Before("checkPerms"),
|
|
149
|
+
__param(0, Param()),
|
|
150
|
+
__param(1, Query()),
|
|
151
|
+
__param(2, Response),
|
|
152
|
+
__param(3, User),
|
|
153
|
+
__metadata("design:type", Function),
|
|
154
|
+
__metadata("design:paramtypes", [Object, Object, Object, Object]),
|
|
155
|
+
__metadata("design:returntype", Promise)
|
|
156
|
+
], BaseACLRoute.prototype, "count", null);
|
|
157
|
+
__decorate([
|
|
158
|
+
Before("checkPerms"),
|
|
159
|
+
__param(1, Request),
|
|
160
|
+
__param(2, User),
|
|
161
|
+
__metadata("design:type", Function),
|
|
162
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
163
|
+
__metadata("design:returntype", Promise)
|
|
164
|
+
], BaseACLRoute.prototype, "create", null);
|
|
165
|
+
__decorate([
|
|
166
|
+
Before(["checkPerms", "checkNotDefault"]),
|
|
167
|
+
__param(0, Param("id")),
|
|
168
|
+
__param(1, Query("version")),
|
|
169
|
+
__param(2, Query("purge")),
|
|
170
|
+
__param(3, Request),
|
|
171
|
+
__param(4, User),
|
|
172
|
+
__metadata("design:type", Function),
|
|
173
|
+
__metadata("design:paramtypes", [String, Object, Object, Object, Object]),
|
|
174
|
+
__metadata("design:returntype", Promise)
|
|
175
|
+
], BaseACLRoute.prototype, "delete", null);
|
|
176
|
+
__decorate([
|
|
177
|
+
Before("checkPerms"),
|
|
178
|
+
__param(0, Param("id")),
|
|
179
|
+
__param(1, Query()),
|
|
180
|
+
__param(2, Response),
|
|
181
|
+
__param(3, User),
|
|
182
|
+
__metadata("design:type", Function),
|
|
183
|
+
__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
184
|
+
__metadata("design:returntype", Promise)
|
|
185
|
+
], BaseACLRoute.prototype, "exists", null);
|
|
186
|
+
__decorate([
|
|
187
|
+
Before("checkPerms"),
|
|
188
|
+
__param(0, Param()),
|
|
189
|
+
__param(1, Query()),
|
|
190
|
+
__param(2, User),
|
|
191
|
+
__metadata("design:type", Function),
|
|
192
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
193
|
+
__metadata("design:returntype", Promise)
|
|
194
|
+
], BaseACLRoute.prototype, "find", null);
|
|
195
|
+
__decorate([
|
|
196
|
+
Before("checkPerms"),
|
|
197
|
+
__param(0, Param("id")),
|
|
198
|
+
__param(1, Query()),
|
|
199
|
+
__param(2, User),
|
|
200
|
+
__metadata("design:type", Function),
|
|
201
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
202
|
+
__metadata("design:returntype", Promise)
|
|
203
|
+
], BaseACLRoute.prototype, "findById", null);
|
|
204
|
+
__decorate([
|
|
205
|
+
Before("checkPerms"),
|
|
206
|
+
__param(0, Param()),
|
|
207
|
+
__param(1, Query()),
|
|
208
|
+
__param(2, User),
|
|
209
|
+
__metadata("design:type", Function),
|
|
210
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
211
|
+
__metadata("design:returntype", Promise)
|
|
212
|
+
], BaseACLRoute.prototype, "truncate", null);
|
|
213
|
+
__decorate([
|
|
214
|
+
Before(["checkPerms", "checkNotDefault"]),
|
|
215
|
+
__param(0, Param("id")),
|
|
216
|
+
__param(2, Request),
|
|
217
|
+
__param(3, User),
|
|
218
|
+
__metadata("design:type", Function),
|
|
219
|
+
__metadata("design:paramtypes", [String, Object, Object, Object]),
|
|
220
|
+
__metadata("design:returntype", Promise)
|
|
221
|
+
], BaseACLRoute.prototype, "update", null);
|
|
222
|
+
__decorate([
|
|
223
|
+
Before(["checkPerms", "checkNotDefault"]),
|
|
224
|
+
__param(0, Param("id")),
|
|
225
|
+
__param(1, Param("property")),
|
|
226
|
+
__param(3, User),
|
|
227
|
+
__metadata("design:type", Function),
|
|
228
|
+
__metadata("design:paramtypes", [String, String, Object, Object]),
|
|
229
|
+
__metadata("design:returntype", Promise)
|
|
230
|
+
], BaseACLRoute.prototype, "updateProperty", null);
|
|
231
|
+
__decorate([
|
|
232
|
+
Before("checkPermsBulk"),
|
|
233
|
+
__param(1, Request),
|
|
234
|
+
__param(2, User),
|
|
235
|
+
__metadata("design:type", Function),
|
|
236
|
+
__metadata("design:paramtypes", [Array, Object, Object]),
|
|
237
|
+
__metadata("design:returntype", Promise)
|
|
238
|
+
], BaseACLRoute.prototype, "updateBulk", null);
|
|
239
|
+
//# sourceMappingURL=BaseACLRoute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseACLRoute.js","sourceRoot":"","sources":["../../../src/security/BaseACLRoute.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,OAAO,EAAE,SAAS,EAA0B,MAAM,wBAAwB,CAAC;AAC3E,OAAO,EAAE,QAAQ,EA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N,MAAM,CAAC,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAErC,WAAA,KAAK,CAAC,IAAI,CAAC,CAAA;IACX,WAAA,KAAK,CAAC,UAAU,CAAC,CAAA;IAEjB,WAAA,IAAI,CAAA;;;;kDAGR;AAGM;IADN,MAAM,CAAC,gBAAgB,CAAC;IACkB,WAAA,OAAO,CAAA;IAAoB,WAAA,IAAI,CAAA;;;;8CAEzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/security/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC"}
|
package/dist/lib/test/request.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
///////////////////////////////////////////////////////////////////////////////
|
|
2
2
|
// Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
4
5
|
/**
|
|
5
6
|
* Supertest-compatible HTTP test helper built on axios.
|
|
@@ -22,11 +23,36 @@ function extractMimeType(contentType) {
|
|
|
22
23
|
return "";
|
|
23
24
|
return contentType.split(";")[0].trim();
|
|
24
25
|
}
|
|
26
|
+
/** Parses one or more `Set-Cookie` header values, merging `name=value` pairs into the given jar. */
|
|
27
|
+
function absorbSetCookie(jar, setCookie) {
|
|
28
|
+
if (!setCookie)
|
|
29
|
+
return;
|
|
30
|
+
const values = Array.isArray(setCookie) ? setCookie : [setCookie];
|
|
31
|
+
for (const value of values) {
|
|
32
|
+
const pair = value.split(";")[0];
|
|
33
|
+
const idx = pair.indexOf("=");
|
|
34
|
+
if (idx < 0)
|
|
35
|
+
continue;
|
|
36
|
+
const name = pair.slice(0, idx).trim();
|
|
37
|
+
const val = pair.slice(idx + 1).trim();
|
|
38
|
+
jar.set(name, val);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Serializes the jar's contents into a `Cookie` request header value, or `undefined` if empty. */
|
|
42
|
+
function buildCookieHeader(jar) {
|
|
43
|
+
if (jar.size === 0)
|
|
44
|
+
return undefined;
|
|
45
|
+
return Array.from(jar.entries())
|
|
46
|
+
.map(([name, value]) => `${name}=${value}`)
|
|
47
|
+
.join("; ");
|
|
48
|
+
}
|
|
25
49
|
/**
|
|
26
|
-
*
|
|
27
|
-
* `
|
|
50
|
+
* Builds a supertest-style request builder that sends requests via axios to `http://localhost:<port>`.
|
|
51
|
+
* When `jar` is provided, every request sends the jar's accumulated cookies and every response's
|
|
52
|
+
* `Set-Cookie` header(s) are merged back into it — this is what powers `agent()`'s cross-request
|
|
53
|
+
* cookie persistence. `request()` passes no jar, so it stays stateless between calls.
|
|
28
54
|
*/
|
|
29
|
-
|
|
55
|
+
function createRequester(app, jar) {
|
|
30
56
|
const port = extractPort(app);
|
|
31
57
|
const baseUrl = `http://localhost:${port}`;
|
|
32
58
|
function makeChain(method, url) {
|
|
@@ -42,10 +68,19 @@ export function request(app) {
|
|
|
42
68
|
return chain;
|
|
43
69
|
},
|
|
44
70
|
then(onFulfilled, onRejected) {
|
|
45
|
-
// Auto-set Content-Type for JSON
|
|
46
|
-
|
|
71
|
+
// Auto-set Content-Type for JSON bodies. Buffers are sent verbatim. Everything else (objects,
|
|
72
|
+
// numbers, booleans, and strings — which callers pre-encode as JSON, e.g. `.send('"foo"')`) is
|
|
73
|
+
// treated as JSON: axios's default transform only auto-serializes plain objects, leaves strings
|
|
74
|
+
// untouched but defaults their Content-Type to form-urlencoded, and hands numbers/booleans straight
|
|
75
|
+
// to the HTTP adapter, which rejects anything that isn't a string/Buffer/Stream.
|
|
76
|
+
if (body !== undefined && !Buffer.isBuffer(body)) {
|
|
47
77
|
hdrs["content-type"] = hdrs["content-type"] || "application/json";
|
|
48
78
|
}
|
|
79
|
+
if (jar && !hdrs["Cookie"] && !hdrs["cookie"]) {
|
|
80
|
+
const cookieHeader = buildCookieHeader(jar);
|
|
81
|
+
if (cookieHeader)
|
|
82
|
+
hdrs["Cookie"] = cookieHeader;
|
|
83
|
+
}
|
|
49
84
|
return axios
|
|
50
85
|
.request({
|
|
51
86
|
method,
|
|
@@ -55,8 +90,13 @@ export function request(app) {
|
|
|
55
90
|
validateStatus: () => true,
|
|
56
91
|
responseType: "text",
|
|
57
92
|
transformResponse: (data) => data,
|
|
93
|
+
// supertest/superagent does not auto-follow redirects; callers inspect
|
|
94
|
+
// res.headers.location themselves. Match that so 3xx responses come back as-is.
|
|
95
|
+
maxRedirects: 0,
|
|
58
96
|
})
|
|
59
97
|
.then((res) => {
|
|
98
|
+
if (jar)
|
|
99
|
+
absorbSetCookie(jar, res.headers["set-cookie"]);
|
|
60
100
|
const raw = res.data;
|
|
61
101
|
const ct = res.headers["content-type"];
|
|
62
102
|
const mime = extractMimeType(ct);
|
|
@@ -75,6 +115,7 @@ export function request(app) {
|
|
|
75
115
|
type: mime,
|
|
76
116
|
headers: res.headers,
|
|
77
117
|
ok: res.status >= 200 && res.status < 300,
|
|
118
|
+
redirect: [301, 302, 303, 305, 307, 308].includes(res.status),
|
|
78
119
|
};
|
|
79
120
|
return onFulfilled ? onFulfilled(result) : result;
|
|
80
121
|
})
|
|
@@ -96,4 +137,20 @@ export function request(app) {
|
|
|
96
137
|
options: (url) => makeChain("OPTIONS", url),
|
|
97
138
|
};
|
|
98
139
|
}
|
|
140
|
+
/**
|
|
141
|
+
* Creates a supertest-style request builder that sends requests via axios to
|
|
142
|
+
* `http://localhost:<port>`. No cookie persistence between calls — each call is independent.
|
|
143
|
+
*/
|
|
144
|
+
export function request(app) {
|
|
145
|
+
return createRequester(app);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Creates a supertest `.agent()`-style request builder that persists cookies across every call
|
|
149
|
+
* made through it, matching real browser behavior. Use this for multi-request flows where a
|
|
150
|
+
* server-set cookie (e.g. a session cookie) must be sent back on a later request — a plain
|
|
151
|
+
* `request(app)` call issues a stateless request each time and never resends cookies.
|
|
152
|
+
*/
|
|
153
|
+
export function agent(app) {
|
|
154
|
+
return createRequester(app, new Map());
|
|
155
|
+
}
|
|
99
156
|
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/test/request.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../src/test/request.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,mCAAmC;AACnC,+EAA+E;AAC/E;;;GAGG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,SAAS,WAAW,CAAC,GAAQ;IACzB,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,kBAAkB;IAClB,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IACzD,sBAAsB;IACtB,IAAI,GAAG,IAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC,UAAU,CAAC;IACrE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,eAAe,CAAC,WAAoB;IACzC,IAAI,CAAC,WAAW;QAAE,OAAO,EAAE,CAAC;IAC5B,OAAO,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,C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SAAS,EAAE,UAAU,CAAC,CAAC;YAC7C,CAAC;SACJ,CAAC;QAEF,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,OAAO;QACH,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAC3C,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;QAC7C,GAAG,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC;QAC3C,MAAM,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,CAAC;QACjD,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;QAC/C,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;QAC7C,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;KACtD,CAAC;AACN,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,GAAQ;IAC5B,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,GAAQ;IAC1B,OAAO,eAAe,CAAC,GAAG,EAAE,IAAI,GAAG,EAAkB,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
///////////////////////////////////////////////////////////////////////////////
|
|
2
2
|
// Copyright (C) 2020-2026 Jean-Philippe Steinmetz. All rights reserved.
|
|
3
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
3
4
|
///////////////////////////////////////////////////////////////////////////////
|
|
4
5
|
/**
|
|
5
6
|
* Superwstest-compatible WebSocket test helper built on the `ws` package.
|
|
@@ -64,6 +65,32 @@ export class WsChain {
|
|
|
64
65
|
ws.terminate();
|
|
65
66
|
resolve();
|
|
66
67
|
};
|
|
68
|
+
// Messages can arrive before the action that expects them is reached — e.g. a fast
|
|
69
|
+
// server response racing the client's send() callback, which can resolve after the
|
|
70
|
+
// response has already been delivered. Buffer every message as it arrives via a
|
|
71
|
+
// persistent listener rather than reactively registering a `once("message")` handler
|
|
72
|
+
// per action, so a message that arrives early is never silently dropped.
|
|
73
|
+
const messageQueue = [];
|
|
74
|
+
let pendingMessageHandler = null;
|
|
75
|
+
ws.on("message", (raw) => {
|
|
76
|
+
const text = raw.toString();
|
|
77
|
+
if (pendingMessageHandler) {
|
|
78
|
+
const handler = pendingMessageHandler;
|
|
79
|
+
pendingMessageHandler = null;
|
|
80
|
+
handler(text);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
messageQueue.push(text);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
const nextMessage = (handler) => {
|
|
87
|
+
if (messageQueue.length > 0) {
|
|
88
|
+
handler(messageQueue.shift());
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
pendingMessageHandler = handler;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
67
94
|
/** Execute the next action, or resolve if all done. */
|
|
68
95
|
const next = () => {
|
|
69
96
|
if (actionIndex >= actions.length) {
|
|
@@ -117,10 +144,9 @@ export class WsChain {
|
|
|
117
144
|
}
|
|
118
145
|
}
|
|
119
146
|
else {
|
|
120
|
-
// expectText / expectJson —
|
|
121
|
-
|
|
147
|
+
// expectText / expectJson — consume the next buffered/incoming message
|
|
148
|
+
nextMessage((text) => {
|
|
122
149
|
try {
|
|
123
|
-
const text = raw.toString();
|
|
124
150
|
if (action.kind === "expectText") {
|
|
125
151
|
if (text !== action.value) {
|
|
126
152
|
fail(new Error(`Expected text "${action.value}" but got "${text}"`));
|
|
@@ -146,7 +172,9 @@ export class WsChain {
|
|
|
146
172
|
}
|
|
147
173
|
};
|
|
148
174
|
ws.on("error", fail);
|
|
149
|
-
ws.on("close", () => {
|
|
175
|
+
ws.on("close", () => {
|
|
176
|
+
closed = true;
|
|
177
|
+
});
|
|
150
178
|
ws.on("open", () => {
|
|
151
179
|
next();
|
|
152
180
|
});
|
|
@@ -155,17 +183,13 @@ export class WsChain {
|
|
|
155
183
|
}
|
|
156
184
|
/** Creates a superwstest-style chain connected to `ws://localhost:<port>`. */
|
|
157
185
|
export function requestws(appOrPort) {
|
|
158
|
-
const port = typeof appOrPort === "number"
|
|
159
|
-
? appOrPort
|
|
160
|
-
: appOrPort?.port ?? appOrPort?.listenPort;
|
|
186
|
+
const port = typeof appOrPort === "number" ? appOrPort : (appOrPort?.port ?? appOrPort?.listenPort);
|
|
161
187
|
if (!port) {
|
|
162
188
|
throw new Error("requestws(): cannot determine port from argument");
|
|
163
189
|
}
|
|
164
190
|
return {
|
|
165
191
|
ws(path, options) {
|
|
166
|
-
const wsOptions = options
|
|
167
|
-
? { headers: options.headers }
|
|
168
|
-
: undefined;
|
|
192
|
+
const wsOptions = options ? { headers: options.headers } : undefined;
|
|
169
193
|
return new WsChain(`ws://localhost:${port}${path}`, wsOptions);
|
|
170
194
|
},
|
|
171
195
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"requestws.js","sourceRoot":"","sources":["../../../src/test/requestws.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,wEAAwE;AACxE,+EAA+E;AAC/E;;;GAGG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAU/B,gEAAgE;AAChE,MAAM,OAAO,OAAO;IAKhB,YAAY,GAAW,EAAE,SAAe;QAFvB,YAAO,GAAe,EAAE,CAAC;QAGtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED,UAAU,CAAC,KAAa;QACpB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,E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Errors {
|
|
|
5
5
|
UNKNOWN = "api-001",
|
|
6
6
|
INTERNAL_ERROR = "api-002",
|
|
7
7
|
INVALID_REQUEST = "api-003",
|
|
8
|
+
PAYLOAD_TOO_LARGE = "api-004",
|
|
8
9
|
NOT_FOUND = "api-010",
|
|
9
10
|
IDENTIFIER_EXISTS = "api-011",
|
|
10
11
|
INVALID_OBJECT_VERSION = "api-012",
|
|
@@ -15,7 +16,9 @@ export declare enum ApiErrors {
|
|
|
15
16
|
BULK_UPDATE_FAILURE = "api-022",
|
|
16
17
|
AUTH_REQUIRED = "api-100",
|
|
17
18
|
AUTH_FAILED = "api-101",
|
|
18
|
-
AUTH_PERMISSION_FAILURE = "api-102"
|
|
19
|
+
AUTH_PERMISSION_FAILURE = "api-102",
|
|
20
|
+
AUTH_REQUIRES_TRUSTED_ROLE = "api-103",
|
|
21
|
+
AUTH_REQUIRES_ELEVATION = "api-104"
|
|
19
22
|
}
|
|
20
23
|
/**
|
|
21
24
|
* Defines the default message of all common API errors.
|
|
@@ -24,6 +27,7 @@ export declare enum ApiErrorMessages {
|
|
|
24
27
|
UNKNOWN = "An unknown error has occurred. Please try again.",
|
|
25
28
|
INTERNAL_ERROR = "An internal error has occurred. Please contact the adminstrator.",
|
|
26
29
|
INVALID_REQUEST = "Invalid message or request.",
|
|
30
|
+
PAYLOAD_TOO_LARGE = "The request body exceeds the maximum allowed size.",
|
|
27
31
|
NOT_FOUND = "No resource could be found with the specified identifier.",
|
|
28
32
|
IDENTIFIER_EXISTS = "A resource with that identifier already exists.",
|
|
29
33
|
INVALID_OBJECT_VERSION = "Invalid object version. Do you have the latest version?",
|
|
@@ -34,5 +38,7 @@ export declare enum ApiErrorMessages {
|
|
|
34
38
|
BULK_UPDATE_FAILURE = "Failed to update one or more objects.",
|
|
35
39
|
AUTH_REQUIRED = "Authorization is required to access this resource.",
|
|
36
40
|
AUTH_FAILED = "Invalid or missing authentication token.",
|
|
37
|
-
AUTH_PERMISSION_FAILURE = "User does not have permission to perform this action."
|
|
41
|
+
AUTH_PERMISSION_FAILURE = "User does not have permission to perform this action.",
|
|
42
|
+
AUTH_REQUIRES_TRUSTED_ROLE = "User does not have permission to perform this action.",
|
|
43
|
+
AUTH_REQUIRES_ELEVATION = "This operation requires elevation."
|
|
38
44
|
}
|
|
@@ -5,11 +5,6 @@
|
|
|
5
5
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
6
6
|
*/
|
|
7
7
|
export declare abstract class BackgroundService {
|
|
8
|
-
/** The global application configuration that the service can reference. */
|
|
9
|
-
protected config: any;
|
|
10
|
-
/** The logging utility to use. */
|
|
11
|
-
protected logger: any;
|
|
12
|
-
constructor(config: any, logger: any);
|
|
13
8
|
/**
|
|
14
9
|
* Returns the desired execution interval that this service should be scheduled with. If `undefined` is returned
|
|
15
10
|
* the service is executed only once.
|
|
@@ -33,8 +33,9 @@ export declare class BackgroundServiceManager {
|
|
|
33
33
|
private jobs;
|
|
34
34
|
private readonly logger;
|
|
35
35
|
private objectFactory;
|
|
36
|
+
private runningJobs;
|
|
36
37
|
private services;
|
|
37
|
-
constructor(objectFactory: ObjectFactory, classes: {}
|
|
38
|
+
constructor(objectFactory: ObjectFactory, classes: {});
|
|
38
39
|
/**
|
|
39
40
|
* Returns the service instance with the given name.
|
|
40
41
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RedisClientType } from "redis";
|
|
2
2
|
import { ObjectFactory } from "./ObjectFactory.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `EventListenerManager` is responsible for managing event handlers and processing of incoming
|
|
@@ -10,12 +10,13 @@ import { ObjectFactory } from "./ObjectFactory.js";
|
|
|
10
10
|
* @author Jean-Philippe Steinmetz <rapidrests@gmail.com>
|
|
11
11
|
*/
|
|
12
12
|
export declare class EventListenerManager {
|
|
13
|
-
private channels;
|
|
14
|
-
private logger;
|
|
15
|
-
private objectFactory;
|
|
13
|
+
private readonly channels;
|
|
14
|
+
private readonly logger;
|
|
15
|
+
private readonly objectFactory;
|
|
16
16
|
private handlers;
|
|
17
|
-
private
|
|
18
|
-
|
|
17
|
+
private readonly typePatterns;
|
|
18
|
+
private readonly redis;
|
|
19
|
+
constructor(objectFactory: ObjectFactory, redis: RedisClientType);
|
|
19
20
|
init(): Promise<void>;
|
|
20
21
|
destroy(): Promise<void>;
|
|
21
22
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { RedisClientType } from "redis";
|
|
2
2
|
/**
|
|
3
3
|
* Utility functions for sending push notifications to registered clients.
|
|
4
4
|
*
|
|
@@ -7,14 +7,16 @@ import { Redis } from "ioredis";
|
|
|
7
7
|
export declare class NotificationUtils {
|
|
8
8
|
/** The redis client to use for broadcasting messages. */
|
|
9
9
|
private redis;
|
|
10
|
+
private logger?;
|
|
10
11
|
/**
|
|
11
12
|
* Initializes the utility using the given redis connection.
|
|
12
13
|
*
|
|
13
14
|
* @param {any} redis The redis connection to publish to.
|
|
14
15
|
*/
|
|
15
|
-
constructor(redis:
|
|
16
|
+
constructor(redis: RedisClientType);
|
|
16
17
|
/**
|
|
17
|
-
* Sends a given message to the room or user with the specified uid(s).
|
|
18
|
+
* Sends a given message to the room or user with the specified uid(s). Publishing is fire-and-forget: a
|
|
19
|
+
* broadcast failure will never propagate back into whatever write triggered the notification.
|
|
18
20
|
*
|
|
19
21
|
* @param {string} uids The universally unique identifier of the room or user to send the message to.
|
|
20
22
|
* @param {string} type The type of message being sent.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { oas31 as oa } from "openapi3-ts";
|
|
2
|
-
import { DocumentsData } from "./decorators/DocDecorators.js";
|
|
2
|
+
import { type DocumentsData } from "./decorators/DocDecorators.js";
|
|
3
3
|
/**
|
|
4
4
|
* `OpenApiSpec` is a container for an OpenAPI specification.
|
|
5
5
|
*
|
|
@@ -66,7 +66,7 @@ export declare class OpenApiSpec {
|
|
|
66
66
|
* @param docs The object containing all documentation information about the route handler.
|
|
67
67
|
* @param routeClass The parent route class that the route handler belongs to.
|
|
68
68
|
*/
|
|
69
|
-
addRoute(name: string, path: string, method: string, metadata: any, docs: DocumentsData, routeClass: any): OpenApiSpec;
|
|
69
|
+
addRoute(name: string, path: string, method: string, metadata: any, docs: DocumentsData, routeClass: any, isWebSocket?: boolean): OpenApiSpec;
|
|
70
70
|
/**
|
|
71
71
|
* Determines if the given type is a primitive or built-in class type.
|
|
72
72
|
* @param value
|