node-server-engine 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +193 -193
- package/.mocharc.js +13 -13
- package/.nycrc +18 -18
- package/.prettierrc +7 -7
- package/Dockerfile +30 -30
- package/README.md +991 -1025
- package/babel.config.json +35 -35
- package/dist/const/DebeziumEvent.js.map +1 -1
- package/dist/const/LogSeverity.js.map +1 -1
- package/dist/const/index.js.map +1 -1
- package/dist/const/metrics.js.map +1 -1
- package/dist/const/mime.js.map +1 -1
- package/dist/const/tokenIssuer.js.map +1 -1
- package/dist/db/migrations/20241030121500-create-sequelize-meta-table.js.map +1 -1
- package/dist/db/models/SequelizeMeta.js.map +1 -1
- package/dist/db/models/index.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.js +7 -7
- package/dist/entities/ElasticSearch/ElasticSearch.js.map +1 -1
- package/dist/entities/ElasticSearch/ElasticSearch.types.js.map +1 -1
- package/dist/entities/ElasticSearch/index.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.js +8 -8
- package/dist/entities/Endpoint/Endpoint.js.map +1 -1
- package/dist/entities/Endpoint/Endpoint.types.js.map +1 -1
- package/dist/entities/Endpoint/index.js.map +1 -1
- package/dist/entities/EngineError/EngineError.js +2 -2
- package/dist/entities/EngineError/EngineError.js.map +1 -1
- package/dist/entities/EngineError/EngineError.types.js.map +1 -1
- package/dist/entities/EngineError/index.js.map +1 -1
- package/dist/entities/KeySet/KeySet.js +3 -3
- package/dist/entities/KeySet/KeySet.js.map +1 -1
- package/dist/entities/KeySet/KeySet.types.js.map +1 -1
- package/dist/entities/KeySet/index.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.js.map +1 -1
- package/dist/entities/LifecycleController/LifecycleController.types.js.map +1 -1
- package/dist/entities/LifecycleController/index.js.map +1 -1
- package/dist/entities/Localizator/Localizator.js +7 -7
- package/dist/entities/Localizator/Localizator.js.map +1 -1
- package/dist/entities/Localizator/Localizator.types.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/guessNamingConvention.js.map +1 -1
- package/dist/entities/Localizator/guessNamingConvention/index.js.map +1 -1
- package/dist/entities/Localizator/index.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.js +2 -2
- package/dist/entities/MessageHandler/MessageHandler.js.map +1 -1
- package/dist/entities/MessageHandler/MessageHandler.types.js.map +1 -1
- package/dist/entities/MessageHandler/index.js.map +1 -1
- package/dist/entities/PubSub/PubSub.js +25 -25
- package/dist/entities/PubSub/PubSub.js.map +1 -1
- package/dist/entities/PubSub/PubSub.types.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/handleMessage.js +6 -6
- package/dist/entities/PubSub/handleMessage/handleMessage.js.map +1 -1
- package/dist/entities/PubSub/handleMessage/index.js.map +1 -1
- package/dist/entities/PubSub/index.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.js +4 -4
- package/dist/entities/PushNotification/PushNotification.js.map +1 -1
- package/dist/entities/PushNotification/PushNotification.types.js.map +1 -1
- package/dist/entities/PushNotification/index.js.map +1 -1
- package/dist/entities/Redis/Redis.js +8 -8
- package/dist/entities/Redis/Redis.js.map +1 -1
- package/dist/entities/Redis/Redis.types.js.map +1 -1
- package/dist/entities/Redis/Redis.validate.js +2 -2
- package/dist/entities/Redis/Redis.validate.js.map +1 -1
- package/dist/entities/Redis/index.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.config.js +42 -2
- package/dist/entities/Sequelize/Sequelize.config.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.js +3 -3
- package/dist/entities/Sequelize/Sequelize.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.types.js.map +1 -1
- package/dist/entities/Sequelize/Sequelize.validate.js +2 -2
- package/dist/entities/Sequelize/Sequelize.validate.js.map +1 -1
- package/dist/entities/Sequelize/index.js.map +1 -1
- package/dist/entities/Server/Server.const.js.map +1 -1
- package/dist/entities/Server/Server.js +2 -2
- package/dist/entities/Server/Server.js.map +1 -1
- package/dist/entities/Server/Server.types.js.map +1 -1
- package/dist/entities/Server/index.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.js +15 -15
- package/dist/entities/SocketClient/SocketClient.js.map +1 -1
- package/dist/entities/SocketClient/SocketClient.types.js.map +1 -1
- package/dist/entities/SocketClient/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/index.js.map +1 -1
- package/dist/entities/SocketClient/parseMessage/parseMessage.js +2 -2
- package/dist/entities/SocketClient/parseMessage/parseMessage.js.map +1 -1
- package/dist/entities/Storage/Storage.js +20 -20
- package/dist/entities/Storage/Storage.js.map +1 -1
- package/dist/entities/Storage/Storage.types.js.map +1 -1
- package/dist/entities/Storage/index.js.map +1 -1
- package/dist/entities/ValidationError/ValidationError.js.map +1 -1
- package/dist/entities/ValidationError/index.js.map +1 -1
- package/dist/entities/WebError/WebError.js +4 -4
- package/dist/entities/WebError/WebError.js.map +1 -1
- package/dist/entities/WebError/WebError.types.js.map +1 -1
- package/dist/entities/WebError/index.js.map +1 -1
- package/dist/entities/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metrics/debug.js.map +1 -1
- package/dist/metrics/index.js.map +1 -1
- package/dist/metrics/request.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.js.map +1 -1
- package/dist/middleware/authAdmin/authAdmin.types.js.map +1 -1
- package/dist/middleware/authAdmin/index.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.js.map +1 -1
- package/dist/middleware/authHmac/authHmac.types.js.map +1 -1
- package/dist/middleware/authHmac/index.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.js.map +1 -1
- package/dist/middleware/authJwt/authJwt.types.js.map +1 -1
- package/dist/middleware/authJwt/index.js.map +1 -1
- package/dist/middleware/authStatic/authStatic.js +3 -3
- package/dist/middleware/authStatic/authStatic.js.map +1 -1
- package/dist/middleware/authStatic/index.js.map +1 -1
- package/dist/middleware/authTls/authTls.js +8 -8
- package/dist/middleware/authTls/authTls.js.map +1 -1
- package/dist/middleware/authTls/authTls.types.js.map +1 -1
- package/dist/middleware/authTls/index.js.map +1 -1
- package/dist/middleware/checkPermission/checkPermission.js.map +1 -1
- package/dist/middleware/error/error.js.map +1 -1
- package/dist/middleware/error/index.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js +2 -2
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/compressAvatar.types.js.map +1 -1
- package/dist/middleware/fileUploader/compressAvatar/index.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.js +12 -12
- package/dist/middleware/fileUploader/fileUploader.js.map +1 -1
- package/dist/middleware/fileUploader/fileUploader.types.js.map +1 -1
- package/dist/middleware/fileUploader/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/index.js.map +1 -1
- package/dist/middleware/fileUploader/isMultiPart/isMultipart.js.map +1 -1
- package/dist/middleware/fileUploader/validate/index.js.map +1 -1
- package/dist/middleware/fileUploader/validate/validate.js.map +1 -1
- package/dist/middleware/fourOhFour/fourOhFour.js.map +1 -1
- package/dist/middleware/fourOhFour/index.js.map +1 -1
- package/dist/middleware/geminiFileUploader/geminiFileUploader.js.map +1 -1
- package/dist/middleware/geminiFileUploader/index.js.map +1 -1
- package/dist/middleware/healthCheck/healthCheck.js +2 -2
- package/dist/middleware/healthCheck/healthCheck.js.map +1 -1
- package/dist/middleware/healthCheck/index.js.map +1 -1
- package/dist/middleware/index.js.map +1 -1
- package/dist/middleware/metrics/index.js.map +1 -1
- package/dist/middleware/metrics/metrics.js.map +1 -1
- package/dist/middleware/requestMetrics/index.js.map +1 -1
- package/dist/middleware/requestMetrics/requestMetrics.js.map +1 -1
- package/dist/middleware/swaggerDocs/index.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.js +7 -7
- package/dist/middleware/swaggerDocs/swaggerDocs.js.map +1 -1
- package/dist/middleware/swaggerDocs/swaggerDocs.types.js.map +1 -1
- package/dist/middleware/userResolver/index.js.map +1 -1
- package/dist/middleware/userResolver/userResolver.js.map +1 -1
- package/dist/middleware/validate/index.js.map +1 -1
- package/dist/middleware/validate/validate.js.map +1 -1
- package/dist/middleware/version/index.js.map +1 -1
- package/dist/middleware/version/version.js +3 -3
- package/dist/middleware/version/version.js.map +1 -1
- package/dist/utils/checkEnvironment/index.js +13 -13
- package/dist/utils/checkEnvironment/index.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.js.map +1 -1
- package/dist/utils/createHttpServer/createHttpServer.validate.js +2 -2
- package/dist/utils/createHttpServer/createHttpServer.validate.js.map +1 -1
- package/dist/utils/createHttpServer/index.js.map +1 -1
- package/dist/utils/createSortedObject/createSortedObject.js.map +1 -1
- package/dist/utils/createSortedObject/index.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.js +8 -8
- package/dist/utils/dbMigration/dbMigration.js.map +1 -1
- package/dist/utils/dbMigration/dbMigration.types.js.map +1 -1
- package/dist/utils/dbMigration/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/index.js.map +1 -1
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.d.ts +2 -2
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js +47 -15
- package/dist/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.js.map +1 -1
- package/dist/utils/envAssert/envAssert.js +6 -6
- package/dist/utils/envAssert/envAssert.js.map +1 -1
- package/dist/utils/envAssert/index.js.map +1 -1
- package/dist/utils/envAssert/validators/hostList.js +2 -2
- package/dist/utils/envAssert/validators/hostList.js.map +1 -1
- package/dist/utils/envAssert/validators/index.js.map +1 -1
- package/dist/utils/envAssert/validators/ipList.js +2 -2
- package/dist/utils/envAssert/validators/ipList.js.map +1 -1
- package/dist/utils/envAssert/validators/path.js +2 -2
- package/dist/utils/envAssert/validators/path.js.map +1 -1
- package/dist/utils/envAssert/validators/string.js +2 -2
- package/dist/utils/envAssert/validators/string.js.map +1 -1
- package/dist/utils/envAssert/validators/stringList.js +3 -3
- package/dist/utils/envAssert/validators/stringList.js.map +1 -1
- package/dist/utils/filter/filter.js +4 -4
- package/dist/utils/filter/filter.js.map +1 -1
- package/dist/utils/filter/index.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.types.js.map +1 -1
- package/dist/utils/getDynamicLink/getDynamicLink.validate.js.map +1 -1
- package/dist/utils/getDynamicLink/index.js.map +1 -1
- package/dist/utils/hmac/checkEnv/checkEnv.js +2 -2
- package/dist/utils/hmac/checkEnv/checkEnv.js.map +1 -1
- package/dist/utils/hmac/checkEnv/index.js.map +1 -1
- package/dist/utils/hmac/createHmac/createHmac.js.map +1 -1
- package/dist/utils/hmac/createHmac/index.js.map +1 -1
- package/dist/utils/hmac/index.js.map +1 -1
- package/dist/utils/hmac/index.types.js.map +1 -1
- package/dist/utils/hmac/signPayload/index.js.map +1 -1
- package/dist/utils/hmac/signPayload/signPayload.js.map +1 -1
- package/dist/utils/hmac/verifySignature/index.js.map +1 -1
- package/dist/utils/hmac/verifySignature/verifySignature.js.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/jwt/index.js.map +1 -1
- package/dist/utils/jwt/jwt.js.map +1 -1
- package/dist/utils/jwt/jwt.types.js.map +1 -1
- package/dist/utils/report/index.js.map +1 -1
- package/dist/utils/report/output.js.map +1 -1
- package/dist/utils/report/output.types.js.map +1 -1
- package/dist/utils/report/report.js.map +1 -1
- package/dist/utils/report/report.types.js.map +1 -1
- package/dist/utils/request/index.js.map +1 -1
- package/dist/utils/request/request.js.map +1 -1
- package/dist/utils/semverCompare/index.js.map +1 -1
- package/dist/utils/semverCompare/semverCompare.js +5 -5
- package/dist/utils/semverCompare/semverCompare.js.map +1 -1
- package/dist/utils/sendEmail/index.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.js +8 -8
- package/dist/utils/sendEmail/sendEmail.js.map +1 -1
- package/dist/utils/sendEmail/sendEmail.types.js.map +1 -1
- package/dist/utils/sendPush/index.js.map +1 -1
- package/dist/utils/sendPush/sendPush.js +5 -5
- package/dist/utils/sendPush/sendPush.js.map +1 -1
- package/dist/utils/sendPush/sendPush.types.js.map +1 -1
- package/dist/utils/tlsConfig/index.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.types.js.map +1 -1
- package/dist/utils/tlsConfig/tlsConfig.validate.js +2 -2
- package/dist/utils/tlsConfig/tlsConfig.validate.js.map +1 -1
- package/dist/utils/tlsRequest/index.js.map +1 -1
- package/dist/utils/tlsRequest/tlsRequest.js.map +1 -1
- package/dist/utils/trimPathSlash/index.js.map +1 -1
- package/dist/utils/trimPathSlash/trimPathSlash.js +4 -4
- package/dist/utils/trimPathSlash/trimPathSlash.js.map +1 -1
- package/eslint.config.mjs +11 -11
- package/package.json +164 -161
- package/src/const/DebeziumEvent.ts +6 -6
- package/src/const/LogSeverity.ts +7 -7
- package/src/const/index.ts +5 -5
- package/src/const/metrics.ts +6 -6
- package/src/const/mime.ts +37 -37
- package/src/const/tokenIssuer.ts +9 -9
- package/src/db/migrations/20241030121500-create-sequelize-meta-table.ts +29 -29
- package/src/db/models/SequelizeMeta.ts +16 -16
- package/src/db/models/index.ts +2 -2
- package/src/entities/ElasticSearch/ElasticSearch.ts +103 -103
- package/src/entities/ElasticSearch/ElasticSearch.types.ts +7 -7
- package/src/entities/ElasticSearch/index.ts +2 -2
- package/src/entities/Endpoint/Endpoint.test.ts +337 -337
- package/src/entities/Endpoint/Endpoint.ts +202 -202
- package/src/entities/Endpoint/Endpoint.types.ts +205 -205
- package/src/entities/Endpoint/index.ts +2 -2
- package/src/entities/EngineError/EngineError.ts +28 -28
- package/src/entities/EngineError/EngineError.types.ts +15 -15
- package/src/entities/EngineError/index.ts +2 -2
- package/src/entities/KeySet/KeySet.test.ts +126 -126
- package/src/entities/KeySet/KeySet.ts +172 -172
- package/src/entities/KeySet/KeySet.types.ts +28 -28
- package/src/entities/KeySet/index.ts +2 -2
- package/src/entities/LifecycleController/LifecycleController.test.ts +48 -48
- package/src/entities/LifecycleController/LifecycleController.ts +24 -24
- package/src/entities/LifecycleController/LifecycleController.types.ts +5 -5
- package/src/entities/LifecycleController/index.ts +2 -2
- package/src/entities/Localizator/Localizator.ts +139 -139
- package/src/entities/Localizator/Localizator.types.ts +52 -52
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.test.ts +165 -165
- package/src/entities/Localizator/guessNamingConvention/guessNamingConvention.ts +58 -58
- package/src/entities/Localizator/guessNamingConvention/index.ts +1 -1
- package/src/entities/Localizator/index.ts +2 -2
- package/src/entities/MessageHandler/MessageHandler.test.ts +130 -130
- package/src/entities/MessageHandler/MessageHandler.ts +72 -72
- package/src/entities/MessageHandler/MessageHandler.types.ts +15 -15
- package/src/entities/MessageHandler/index.ts +2 -2
- package/src/entities/PubSub/PubSub.test.ts +297 -297
- package/src/entities/PubSub/PubSub.ts +202 -202
- package/src/entities/PubSub/PubSub.types.ts +76 -76
- package/src/entities/PubSub/handleMessage/handleMessage.test.ts +102 -102
- package/src/entities/PubSub/handleMessage/handleMessage.ts +65 -65
- package/src/entities/PubSub/handleMessage/index.ts +1 -1
- package/src/entities/PubSub/index.ts +2 -2
- package/src/entities/PushNotification/PushNotification.test.ts +35 -35
- package/src/entities/PushNotification/PushNotification.ts +44 -44
- package/src/entities/PushNotification/PushNotification.types.ts +25 -25
- package/src/entities/PushNotification/index.ts +2 -2
- package/src/entities/Redis/Redis.ts +71 -71
- package/src/entities/Redis/Redis.types.ts +19 -19
- package/src/entities/Redis/Redis.validate.ts +17 -17
- package/src/entities/Redis/index.ts +2 -2
- package/src/entities/Sequelize/Sequelize.config.ts +59 -29
- package/src/entities/Sequelize/Sequelize.test.ts +21 -21
- package/src/entities/Sequelize/Sequelize.ts +75 -75
- package/src/entities/Sequelize/Sequelize.types.ts +10 -10
- package/src/entities/Sequelize/Sequelize.validate.ts +15 -15
- package/src/entities/Sequelize/index.ts +2 -2
- package/src/entities/Server/Server.const.ts +56 -56
- package/src/entities/Server/Server.test.ts +272 -272
- package/src/entities/Server/Server.ts +445 -445
- package/src/entities/Server/Server.types.ts +88 -88
- package/src/entities/Server/index.ts +2 -2
- package/src/entities/SocketClient/SocketClient.test.ts +392 -392
- package/src/entities/SocketClient/SocketClient.ts +401 -401
- package/src/entities/SocketClient/SocketClient.types.ts +62 -62
- package/src/entities/SocketClient/index.ts +2 -2
- package/src/entities/SocketClient/parseMessage/index.ts +1 -1
- package/src/entities/SocketClient/parseMessage/parseMessage.test.ts +20 -20
- package/src/entities/SocketClient/parseMessage/parseMessage.ts +26 -26
- package/src/entities/Storage/Storage.test.ts +58 -58
- package/src/entities/Storage/Storage.ts +219 -219
- package/src/entities/Storage/Storage.types.ts +57 -57
- package/src/entities/Storage/index.ts +2 -2
- package/src/entities/ValidationError/ValidationError.ts +34 -34
- package/src/entities/ValidationError/index.ts +1 -1
- package/src/entities/WebError/WebError.test.ts +18 -18
- package/src/entities/WebError/WebError.ts +23 -23
- package/src/entities/WebError/WebError.types.ts +9 -9
- package/src/entities/WebError/index.ts +2 -2
- package/src/entities/index.ts +16 -16
- package/src/index.ts +4 -4
- package/src/metrics/debug.ts +10 -10
- package/src/metrics/index.ts +2 -2
- package/src/metrics/request.ts +17 -17
- package/src/middleware/authAdmin/authAdmin.test.ts +199 -199
- package/src/middleware/authAdmin/authAdmin.ts +114 -114
- package/src/middleware/authAdmin/authAdmin.types.ts +19 -19
- package/src/middleware/authAdmin/index.ts +2 -2
- package/src/middleware/authHmac/authHmac.test.ts +86 -86
- package/src/middleware/authHmac/authHmac.ts +56 -56
- package/src/middleware/authHmac/authHmac.types.ts +7 -7
- package/src/middleware/authHmac/index.ts +2 -2
- package/src/middleware/authJwt/authJwt.test.ts +54 -54
- package/src/middleware/authJwt/authJwt.ts +55 -55
- package/src/middleware/authJwt/authJwt.types.ts +14 -14
- package/src/middleware/authJwt/index.ts +2 -2
- package/src/middleware/authStatic/authStatic.test.ts +36 -36
- package/src/middleware/authStatic/authStatic.ts +45 -45
- package/src/middleware/authStatic/index.ts +1 -1
- package/src/middleware/authTls/authTls.test.ts +138 -138
- package/src/middleware/authTls/authTls.ts +106 -106
- package/src/middleware/authTls/authTls.types.ts +13 -13
- package/src/middleware/authTls/index.ts +2 -2
- package/src/middleware/checkPermission/checkPermission.ts +32 -32
- package/src/middleware/error/error.test.ts +60 -60
- package/src/middleware/error/error.ts +25 -25
- package/src/middleware/error/index.ts +1 -1
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.ts +25 -25
- package/src/middleware/fileUploader/compressAvatar/compressAvatar.types.ts +12 -12
- package/src/middleware/fileUploader/compressAvatar/index.ts +2 -2
- package/src/middleware/fileUploader/fileUploader.test.ts +310 -310
- package/src/middleware/fileUploader/fileUploader.ts +303 -303
- package/src/middleware/fileUploader/fileUploader.types.ts +52 -52
- package/src/middleware/fileUploader/index.ts +2 -2
- package/src/middleware/fileUploader/isMultiPart/index.ts +1 -1
- package/src/middleware/fileUploader/isMultiPart/isMultipart.ts +9 -9
- package/src/middleware/fileUploader/validate/index.ts +1 -1
- package/src/middleware/fileUploader/validate/validate.ts +27 -27
- package/src/middleware/fourOhFour/fourOhFour.test.ts +14 -14
- package/src/middleware/fourOhFour/fourOhFour.ts +13 -13
- package/src/middleware/fourOhFour/index.ts +1 -1
- package/src/middleware/geminiFileUploader/geminiFileUploader.ts +117 -117
- package/src/middleware/geminiFileUploader/index.ts +1 -1
- package/src/middleware/healthCheck/healthCheck.test.ts +12 -12
- package/src/middleware/healthCheck/healthCheck.ts +14 -14
- package/src/middleware/healthCheck/index.ts +1 -1
- package/src/middleware/index.ts +17 -17
- package/src/middleware/metrics/index.ts +1 -1
- package/src/middleware/metrics/metrics.test.ts +46 -46
- package/src/middleware/metrics/metrics.ts +24 -24
- package/src/middleware/requestMetrics/index.ts +1 -1
- package/src/middleware/requestMetrics/requestMetrics.test.ts +77 -77
- package/src/middleware/requestMetrics/requestMetrics.ts +20 -20
- package/src/middleware/swaggerDocs/index.ts +2 -2
- package/src/middleware/swaggerDocs/swaggerDocs.ts +114 -114
- package/src/middleware/swaggerDocs/swaggerDocs.types.ts +41 -41
- package/src/middleware/userResolver/index.ts +1 -1
- package/src/middleware/userResolver/userResolver.test.ts +35 -35
- package/src/middleware/userResolver/userResolver.ts +35 -35
- package/src/middleware/validate/index.ts +1 -1
- package/src/middleware/validate/validate.test.ts +43 -43
- package/src/middleware/validate/validate.ts +25 -25
- package/src/middleware/version/index.ts +1 -1
- package/src/middleware/version/version.test.ts +23 -23
- package/src/middleware/version/version.ts +12 -12
- package/src/utils/checkEnvironment/index.ts +49 -49
- package/src/utils/createHttpServer/createHttpServer.test.ts +24 -24
- package/src/utils/createHttpServer/createHttpServer.ts +34 -34
- package/src/utils/createHttpServer/createHttpServer.validate.ts +17 -17
- package/src/utils/createHttpServer/index.ts +1 -1
- package/src/utils/createSortedObject/createSortedObject.ts +20 -20
- package/src/utils/createSortedObject/createSortedObjet.test.ts +47 -47
- package/src/utils/createSortedObject/index.ts +1 -1
- package/src/utils/dbMigration/dbMigration.test.ts +209 -209
- package/src/utils/dbMigration/dbMigration.ts +199 -199
- package/src/utils/dbMigration/dbMigration.types.ts +11 -11
- package/src/utils/dbMigration/index.ts +2 -2
- package/src/utils/dbMigration/migrateMetadataTable/index.ts +1 -1
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.test.ts +59 -59
- package/src/utils/dbMigration/migrateMetadataTable/migrateMetadataTable.ts +102 -70
- package/src/utils/envAssert/envAssert.ts +31 -31
- package/src/utils/envAssert/index.ts +1 -1
- package/src/utils/envAssert/validators/hostList.ts +17 -17
- package/src/utils/envAssert/validators/index.ts +5 -5
- package/src/utils/envAssert/validators/ipList.ts +13 -13
- package/src/utils/envAssert/validators/path.ts +13 -13
- package/src/utils/envAssert/validators/string.ts +9 -9
- package/src/utils/envAssert/validators/stringList.ts +13 -13
- package/src/utils/filter/filter.ts +17 -17
- package/src/utils/filter/index.ts +1 -1
- package/src/utils/getDynamicLink/getDynamicLink.test.ts +51 -51
- package/src/utils/getDynamicLink/getDynamicLink.ts +28 -28
- package/src/utils/getDynamicLink/getDynamicLink.types.ts +11 -11
- package/src/utils/getDynamicLink/getDynamicLink.validate.ts +6 -6
- package/src/utils/getDynamicLink/index.ts +2 -2
- package/src/utils/hmac/checkEnv/checkEnv.test.ts +18 -18
- package/src/utils/hmac/checkEnv/checkEnv.ts +9 -9
- package/src/utils/hmac/checkEnv/index.ts +1 -1
- package/src/utils/hmac/createHmac/createHmac.ts +33 -33
- package/src/utils/hmac/createHmac/index.ts +1 -1
- package/src/utils/hmac/index.ts +4 -4
- package/src/utils/hmac/index.types.ts +13 -13
- package/src/utils/hmac/signPayload/index.ts +1 -1
- package/src/utils/hmac/signPayload/signPayload.ts +16 -16
- package/src/utils/hmac/verifySignature/index.ts +1 -1
- package/src/utils/hmac/verifySignature/verifySignature.ts +24 -24
- package/src/utils/index.ts +26 -26
- package/src/utils/jwt/index.ts +2 -2
- package/src/utils/jwt/jwt.test.ts +41 -41
- package/src/utils/jwt/jwt.ts +204 -204
- package/src/utils/jwt/jwt.types.ts +21 -21
- package/src/utils/report/index.ts +3 -3
- package/src/utils/report/output.ts +45 -45
- package/src/utils/report/output.types.ts +70 -70
- package/src/utils/report/report.test.ts +133 -133
- package/src/utils/report/report.ts +134 -134
- package/src/utils/report/report.types.ts +13 -13
- package/src/utils/request/index.ts +1 -1
- package/src/utils/request/request.test.ts +26 -26
- package/src/utils/request/request.ts +48 -48
- package/src/utils/semverCompare/index.ts +1 -1
- package/src/utils/semverCompare/semverCompare.test.ts +49 -49
- package/src/utils/semverCompare/semverCompare.ts +60 -60
- package/src/utils/sendEmail/index.ts +1 -1
- package/src/utils/sendEmail/sendEmail.ts +27 -27
- package/src/utils/sendEmail/sendEmail.types.ts +7 -7
- package/src/utils/sendPush/index.ts +2 -2
- package/src/utils/sendPush/sendPush.ts +20 -20
- package/src/utils/sendPush/sendPush.types.ts +25 -25
- package/src/utils/tlsConfig/index.ts +2 -2
- package/src/utils/tlsConfig/tlsConfig.test.ts +32 -32
- package/src/utils/tlsConfig/tlsConfig.ts +47 -47
- package/src/utils/tlsConfig/tlsConfig.types.ts +11 -11
- package/src/utils/tlsConfig/tlsConfig.validate.ts +25 -25
- package/src/utils/tlsRequest/index.ts +1 -1
- package/src/utils/tlsRequest/tlsRequest.test.ts +63 -63
- package/src/utils/tlsRequest/tlsRequest.ts +12 -12
- package/src/utils/trimPathSlash/index.ts +1 -1
- package/src/utils/trimPathSlash/trimPathSlash.test.ts +26 -26
- package/src/utils/trimPathSlash/trimPathSlash.ts +8 -8
- package/test/env.ts +56 -56
- package/test/factory/index.ts +8 -8
- package/test/factory/sequelizeMeta.ts +12 -12
- package/test/hooks.ts +37 -37
- package/test/index.ts +3 -3
- package/test/stub/index.ts +3 -3
- package/test/stub/stubLocales.ts +68 -68
- package/test/stub/stubPubSub.ts +7 -7
- package/test/stub/stubStorage.ts +77 -77
- package/test/stub/stubStorage.types.ts +11 -11
- package/test/utils/app.ts +31 -31
- package/test/utils/index.ts +1 -1
- package/tsconfig.build.json +5 -5
- package/tsconfig.json +32 -32
package/babel.config.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"presets": [
|
|
3
|
-
"@babel/preset-typescript",
|
|
4
|
-
[
|
|
5
|
-
"@babel/preset-env",
|
|
6
|
-
{
|
|
7
|
-
"targets": { "node": 20 },
|
|
8
|
-
"useBuiltIns": "entry",
|
|
9
|
-
"corejs": 3
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
],
|
|
13
|
-
"plugins": [
|
|
14
|
-
[
|
|
15
|
-
"module-resolver",
|
|
16
|
-
{
|
|
17
|
-
"root": "src",
|
|
18
|
-
"alias": {
|
|
19
|
-
"test": "test"
|
|
20
|
-
},
|
|
21
|
-
"extensions": [".js", ".ts"]
|
|
22
|
-
}
|
|
23
|
-
],
|
|
24
|
-
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
|
25
|
-
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
|
26
|
-
"@babel/plugin-transform-class-properties",
|
|
27
|
-
"@babel/plugin-transform-classes",
|
|
28
|
-
"@babel/plugin-transform-runtime"
|
|
29
|
-
],
|
|
30
|
-
"env": {
|
|
31
|
-
"test": {
|
|
32
|
-
"plugins": ["istanbul"]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"presets": [
|
|
3
|
+
"@babel/preset-typescript",
|
|
4
|
+
[
|
|
5
|
+
"@babel/preset-env",
|
|
6
|
+
{
|
|
7
|
+
"targets": { "node": 20 },
|
|
8
|
+
"useBuiltIns": "entry",
|
|
9
|
+
"corejs": 3
|
|
10
|
+
}
|
|
11
|
+
]
|
|
12
|
+
],
|
|
13
|
+
"plugins": [
|
|
14
|
+
[
|
|
15
|
+
"module-resolver",
|
|
16
|
+
{
|
|
17
|
+
"root": "src",
|
|
18
|
+
"alias": {
|
|
19
|
+
"test": "test"
|
|
20
|
+
},
|
|
21
|
+
"extensions": [".js", ".ts"]
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
["@babel/plugin-proposal-decorators", { "legacy": true }],
|
|
25
|
+
["@babel/plugin-proposal-class-properties", { "loose": true }],
|
|
26
|
+
"@babel/plugin-transform-class-properties",
|
|
27
|
+
"@babel/plugin-transform-classes",
|
|
28
|
+
"@babel/plugin-transform-runtime"
|
|
29
|
+
],
|
|
30
|
+
"env": {
|
|
31
|
+
"test": {
|
|
32
|
+
"plugins": ["istanbul"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DebeziumEvent.js","names":["DebeziumEvent","exports"],"sources":["../../src/const/DebeziumEvent.ts"],"sourcesContent":["/** Debezium event types */\nexport enum DebeziumEvent {\n Create = 'c',\n Update = 'u',\n Delete = 'd'\n}\n"],"mappings":";;;;;;AAAA;AAAA,IACYA,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"DebeziumEvent.js","names":["DebeziumEvent","exports"],"sources":["../../src/const/DebeziumEvent.ts"],"sourcesContent":["/** Debezium event types */\r\nexport enum DebeziumEvent {\r\n Create = 'c',\r\n Update = 'u',\r\n Delete = 'd'\r\n}\r\n"],"mappings":";;;;;;AAAA;AAAA,IACYA,aAAa,GAAAC,OAAA,CAAAD,aAAA,0BAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAbA,aAAa;EAAA,OAAbA,aAAa;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LogSeverity.js","names":["LogSeverity","exports"],"sources":["../../src/const/LogSeverity.ts"],"sourcesContent":["export enum LogSeverity {\n DEBUG = 'DEBUG',\n INFO = 'INFO',\n WARNING = 'WARNING',\n ERROR = 'ERROR',\n CRITICAL = 'CRITICAL'\n}\n"],"mappings":";;;;;;IAAYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LogSeverity.js","names":["LogSeverity","exports"],"sources":["../../src/const/LogSeverity.ts"],"sourcesContent":["export enum LogSeverity {\r\n DEBUG = 'DEBUG',\r\n INFO = 'INFO',\r\n WARNING = 'WARNING',\r\n ERROR = 'ERROR',\r\n CRITICAL = 'CRITICAL'\r\n}\r\n"],"mappings":";;;;;;IAAYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA","ignoreList":[]}
|
package/dist/const/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_mime","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_metrics","_DebeziumEvent","_LogSeverity","_tokenIssuer"],"sources":["../../src/const/index.ts"],"sourcesContent":["export * from './mime';\nexport * from './metrics';\nexport * from './DebeziumEvent';\nexport * from './LogSeverity';\nexport * from './tokenIssuer';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,cAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,cAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,cAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,cAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,YAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,YAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,YAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,YAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,YAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,YAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,YAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,YAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_mime","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_metrics","_DebeziumEvent","_LogSeverity","_tokenIssuer"],"sources":["../../src/const/index.ts"],"sourcesContent":["export * from './mime';\r\nexport * from './metrics';\r\nexport * from './DebeziumEvent';\r\nexport * from './LogSeverity';\r\nexport * from './tokenIssuer';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EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,YAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,YAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;AACA,IAAAQ,YAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,YAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,YAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,YAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metrics.js","names":["_promClient","require","instanceRegistry","exports","Registry","serviceRegistry"],"sources":["../../src/const/metrics.ts"],"sourcesContent":["import { Registry } from 'prom-client';\n\n// Registry for metrics that apply to this specific instance of the service\nexport const instanceRegistry = new Registry();\n// Registry for metrics that apply to the service as a whole\nexport const serviceRegistry = new Registry();\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA;AACO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,oBAAQ,CAAC,CAAC;AAC9C;AACO,MAAMC,eAAe,GAAAF,OAAA,CAAAE,eAAA,GAAG,IAAID,oBAAQ,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"metrics.js","names":["_promClient","require","instanceRegistry","exports","Registry","serviceRegistry"],"sources":["../../src/const/metrics.ts"],"sourcesContent":["import { Registry } from 'prom-client';\r\n\r\n// Registry for metrics that apply to this specific instance of the service\r\nexport const instanceRegistry = new Registry();\r\n// Registry for metrics that apply to the service as a whole\r\nexport const serviceRegistry = new Registry();\r\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAEA;AACO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,oBAAQ,CAAC,CAAC;AAC9C;AACO,MAAMC,eAAe,GAAAF,OAAA,CAAAE,eAAA,GAAG,IAAID,oBAAQ,CAAC,CAAC","ignoreList":[]}
|
package/dist/const/mime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mime.js","names":["IMAGE_BASIC_MIME","exports","IMAGE_MIME","AUDIO_MIME","VIDEO_MIME","PDF_MIME","WORD_MIME","EXCEL_MIME","POWERPOINT_MIME","OFFICE_MIME"],"sources":["../../src/const/mime.ts"],"sourcesContent":["export const IMAGE_BASIC_MIME = ['image/jpeg', 'image/png'];\n\nexport const IMAGE_MIME = [...IMAGE_BASIC_MIME, 'image/gif', 'image/bmp'];\n\nexport const AUDIO_MIME = [\n 'audio/aac',\n 'audio/mpeg',\n 'audio/wave',\n 'audio/wav'\n];\n\nexport const VIDEO_MIME = [\n 'video/mpeg',\n 'video/mp4',\n 'video/3gpp',\n 'video/3gp2'\n];\n\nexport const PDF_MIME = ['application/pdf'];\n\nexport const WORD_MIME = [\n 'application/msword',\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n];\n\nexport const EXCEL_MIME = [\n 'application/vnd.ms-excel',\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\n];\n\nexport const POWERPOINT_MIME = [\n 'application/vnd.ms-powerpoint',\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'\n];\n\nexport const OFFICE_MIME = [...WORD_MIME, ...EXCEL_MIME, ...POWERPOINT_MIME];\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC;AAEpD,MAAME,UAAU,GAAAD,OAAA,CAAAC,UAAA,GAAG,CAAC,GAAGF,gBAAgB,EAAE,WAAW,EAAE,WAAW,CAAC;AAElE,MAAMG,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,CACxB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,CACZ;AAEM,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,CACxB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,CACb;AAEM,MAAMC,QAAQ,GAAAJ,OAAA,CAAAI,QAAA,GAAG,CAAC,iBAAiB,CAAC;AAEpC,MAAMC,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAG,CACvB,oBAAoB,EACpB,yEAAyE,CAC1E;AAEM,MAAMC,UAAU,GAAAN,OAAA,CAAAM,UAAA,GAAG,CACxB,0BAA0B,EAC1B,mEAAmE,CACpE;AAEM,MAAMC,eAAe,GAAAP,OAAA,CAAAO,eAAA,GAAG,CAC7B,+BAA+B,EAC/B,2EAA2E,EAC3E,wEAAwE,CACzE;AAEM,MAAMC,WAAW,GAAAR,OAAA,CAAAQ,WAAA,GAAG,CAAC,GAAGH,SAAS,EAAE,GAAGC,UAAU,EAAE,GAAGC,eAAe,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"mime.js","names":["IMAGE_BASIC_MIME","exports","IMAGE_MIME","AUDIO_MIME","VIDEO_MIME","PDF_MIME","WORD_MIME","EXCEL_MIME","POWERPOINT_MIME","OFFICE_MIME"],"sources":["../../src/const/mime.ts"],"sourcesContent":["export const IMAGE_BASIC_MIME = ['image/jpeg', 'image/png'];\r\n\r\nexport const IMAGE_MIME = [...IMAGE_BASIC_MIME, 'image/gif', 'image/bmp'];\r\n\r\nexport const AUDIO_MIME = [\r\n 'audio/aac',\r\n 'audio/mpeg',\r\n 'audio/wave',\r\n 'audio/wav'\r\n];\r\n\r\nexport const VIDEO_MIME = [\r\n 'video/mpeg',\r\n 'video/mp4',\r\n 'video/3gpp',\r\n 'video/3gp2'\r\n];\r\n\r\nexport const PDF_MIME = ['application/pdf'];\r\n\r\nexport const WORD_MIME = [\r\n 'application/msword',\r\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\r\n];\r\n\r\nexport const EXCEL_MIME = [\r\n 'application/vnd.ms-excel',\r\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'\r\n];\r\n\r\nexport const POWERPOINT_MIME = [\r\n 'application/vnd.ms-powerpoint',\r\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\r\n 'application/vnd.openxmlformats-officedocument.presentationml.slideshow'\r\n];\r\n\r\nexport const OFFICE_MIME = [...WORD_MIME, ...EXCEL_MIME, ...POWERPOINT_MIME];\r\n"],"mappings":";;;;;;AAAO,MAAMA,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC;AAEpD,MAAME,UAAU,GAAAD,OAAA,CAAAC,UAAA,GAAG,CAAC,GAAGF,gBAAgB,EAAE,WAAW,EAAE,WAAW,CAAC;AAElE,MAAMG,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAG,CACxB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,CACZ;AAEM,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,CACxB,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,YAAY,CACb;AAEM,MAAMC,QAAQ,GAAAJ,OAAA,CAAAI,QAAA,GAAG,CAAC,iBAAiB,CAAC;AAEpC,MAAMC,SAAS,GAAAL,OAAA,CAAAK,SAAA,GAAG,CACvB,oBAAoB,EACpB,yEAAyE,CAC1E;AAEM,MAAMC,UAAU,GAAAN,OAAA,CAAAM,UAAA,GAAG,CACxB,0BAA0B,EAC1B,mEAAmE,CACpE;AAEM,MAAMC,eAAe,GAAAP,OAAA,CAAAO,eAAA,GAAG,CAC7B,+BAA+B,EAC/B,2EAA2E,EAC3E,wEAAwE,CACzE;AAEM,MAAMC,WAAW,GAAAR,OAAA,CAAAQ,WAAA,GAAG,CAAC,GAAGH,SAAS,EAAE,GAAGC,UAAU,EAAE,GAAGC,eAAe,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tokenIssuer.js","names":["TokenIssuer","exports","TOKEN_ISSUERS","Object","values"],"sources":["../../src/const/tokenIssuer.ts"],"sourcesContent":["/** Enum to identify access tokens JWT issuers */\nexport enum TokenIssuer {\n /** For tokens issued by the auth service */\n AUTH_SERVICE,\n /** For tokens issued by the admin API */\n ADMIN_API\n}\n\nexport const TOKEN_ISSUERS = Object.values(TokenIssuer);\n"],"mappings":";;;;;;AAAA;AAAA,IACYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOhB,MAAME,aAAa,GAAAD,OAAA,CAAAC,aAAA,GAAGC,MAAM,CAACC,MAAM,CAACJ,WAAW,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"tokenIssuer.js","names":["TokenIssuer","exports","TOKEN_ISSUERS","Object","values"],"sources":["../../src/const/tokenIssuer.ts"],"sourcesContent":["/** Enum to identify access tokens JWT issuers */\r\nexport enum TokenIssuer {\r\n /** For tokens issued by the auth service */\r\n AUTH_SERVICE,\r\n /** For tokens issued by the admin API */\r\n ADMIN_API\r\n}\r\n\r\nexport const TOKEN_ISSUERS = Object.values(TokenIssuer);\r\n"],"mappings":";;;;;;AAAA;AAAA,IACYA,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAXA,WAAW,CAAXA,WAAW;EAAA,OAAXA,WAAW;AAAA;AAOhB,MAAME,aAAa,GAAAD,OAAA,CAAAC,aAAA,GAAGC,MAAM,CAACC,MAAM,CAACJ,WAAW,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"20241030121500-create-sequelize-meta-table.js","names":["_sequelize","require","up","queryInterface","createTable","id","type","DataTypes","INTEGER","autoIncrement","primaryKey","name","STRING","allowNull","version","charset","collate","down","dropTable"],"sources":["../../../src/db/migrations/20241030121500-create-sequelize-meta-table.ts"],"sourcesContent":["import { QueryInterface, DataTypes } from 'sequelize';\n\nexport async function up(queryInterface: QueryInterface): Promise<void> {\n await queryInterface.createTable(\n 'SequelizeMeta',\n {\n id: {\n type: DataTypes.INTEGER,\n autoIncrement: true,\n primaryKey: true\n },\n name: {\n type: DataTypes.STRING,\n allowNull: false\n },\n version: {\n type: DataTypes.STRING,\n allowNull: false\n }\n },\n {\n charset: 'utf8mb4',\n collate: 'utf8mb4_unicode_ci' // Change this to a valid collation\n }\n );\n}\nexport async function down(queryInterface: QueryInterface): Promise<void> {\n await queryInterface.dropTable('SequelizeMeta');\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,eAAeC,EAAEA,CAACC,cAA8B,EAAiB;EACtE,MAAMA,cAAc,CAACC,WAAW,CAC9B,eAAe,EACf;IACEC,EAAE,EAAE;MACFC,IAAI,EAAEC,oBAAS,CAACC,OAAO;MACvBC,aAAa,EAAE,IAAI;MACnBC,UAAU,EAAE;IACd,CAAC;IACDC,IAAI,EAAE;MACJL,IAAI,EAAEC,oBAAS,CAACK,MAAM;MACtBC,SAAS,EAAE;IACb,CAAC;IACDC,OAAO,EAAE;MACPR,IAAI,EAAEC,oBAAS,CAACK,MAAM;MACtBC,SAAS,EAAE;IACb;EACF,CAAC,EACD;IACEE,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,oBAAoB,CAAC;EAChC,CACF,CAAC;AACH;AACO,eAAeC,IAAIA,CAACd,cAA8B,EAAiB;EACxE,MAAMA,cAAc,CAACe,SAAS,CAAC,eAAe,CAAC;AACjD","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"20241030121500-create-sequelize-meta-table.js","names":["_sequelize","require","up","queryInterface","createTable","id","type","DataTypes","INTEGER","autoIncrement","primaryKey","name","STRING","allowNull","version","charset","collate","down","dropTable"],"sources":["../../../src/db/migrations/20241030121500-create-sequelize-meta-table.ts"],"sourcesContent":["import { QueryInterface, DataTypes } from 'sequelize';\r\n\r\nexport async function up(queryInterface: QueryInterface): Promise<void> {\r\n await queryInterface.createTable(\r\n 'SequelizeMeta',\r\n {\r\n id: {\r\n type: DataTypes.INTEGER,\r\n autoIncrement: true,\r\n primaryKey: true\r\n },\r\n name: {\r\n type: DataTypes.STRING,\r\n allowNull: false\r\n },\r\n version: {\r\n type: DataTypes.STRING,\r\n allowNull: false\r\n }\r\n },\r\n {\r\n charset: 'utf8mb4',\r\n collate: 'utf8mb4_unicode_ci' // Change this to a valid collation\r\n }\r\n );\r\n}\r\nexport async function down(queryInterface: QueryInterface): Promise<void> {\r\n await queryInterface.dropTable('SequelizeMeta');\r\n}\r\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEO,eAAeC,EAAEA,CAACC,cAA8B,EAAiB;EACtE,MAAMA,cAAc,CAACC,WAAW,CAC9B,eAAe,EACf;IACEC,EAAE,EAAE;MACFC,IAAI,EAAEC,oBAAS,CAACC,OAAO;MACvBC,aAAa,EAAE,IAAI;MACnBC,UAAU,EAAE;IACd,CAAC;IACDC,IAAI,EAAE;MACJL,IAAI,EAAEC,oBAAS,CAACK,MAAM;MACtBC,SAAS,EAAE;IACb,CAAC;IACDC,OAAO,EAAE;MACPR,IAAI,EAAEC,oBAAS,CAACK,MAAM;MACtBC,SAAS,EAAE;IACb;EACF,CAAC,EACD;IACEE,OAAO,EAAE,SAAS;IAClBC,OAAO,EAAE,oBAAoB,CAAC;EAChC,CACF,CAAC;AACH;AACO,eAAeC,IAAIA,CAACd,cAA8B,EAAiB;EACxE,MAAMA,cAAc,CAACe,SAAS,CAAC,eAAe,CAAC;AACjD","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SequelizeMeta.js","names":["_sequelizeTypescript","require","_dec","_dec2","_class","_class2","_descriptor","_descriptor2","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","SequelizeMeta","exports","Column","type","DataType","STRING","allowNull","Table","_Model","args","_this","_classCallCheck2","_initializerDefineProperty2","_inherits2","_createClass2","Model","_applyDecoratedDescriptor2","configurable","enumerable","writable","initializer"],"sources":["../../../src/db/models/SequelizeMeta.ts"],"sourcesContent":["import { Table, Column, Model, DataType } from 'sequelize-typescript';\n\n@Table\nexport class SequelizeMeta extends Model {\n @Column({\n type: DataType.STRING,\n allowNull: false\n })\n name!: string;\n\n @Column({\n type: DataType.STRING,\n allowNull: false\n })\n version!: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAsE,IAAAC,IAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,OAAA,EAAAC,WAAA,EAAAC,YAAA;AAAA,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAP,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAS,WAAA,IAAAR,CAAA,CAAAS,KAAA,CAAAV,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAW,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAX,CAAA,aAAAM,yBAAA,YAAAA,CAAA,aAAAN,CAA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","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","SequelizeMeta","exports","Column","type","DataType","STRING","allowNull","Table","_Model","args","_this","_classCallCheck2","_initializerDefineProperty2","_inherits2","_createClass2","Model","_applyDecoratedDescriptor2","configurable","enumerable","writable","initializer"],"sources":["../../../src/db/models/SequelizeMeta.ts"],"sourcesContent":["import { Table, Column, Model, DataType } from 'sequelize-typescript';\r\n\r\n@Table\r\nexport class SequelizeMeta extends Model {\r\n @Column({\r\n type: DataType.STRING,\r\n allowNull: false\r\n })\r\n name!: string;\r\n\r\n @Column({\r\n type: DataType.STRING,\r\n allowNull: false\r\n })\r\n version!: string;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAsE,IAAAC,IAAA,EAAAC,KAAA,EAAAC,MAAA,EAAAC,OAAA,EAAAC,WAAA,EAAAC,YAAA;AAAA,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAP,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAS,WAAA,IAAAR,CAAA,CAAAS,KAAA,CAAAV,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAW,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAX,CAAA,aAAAM,yBAAA,YAAAA,CAAA,aAAAN,CAAA;AAAA,IAGzDe,aAAa,GAAAC,OAAA,CAAAD,aAAA,IAAAtB,IAAA,GACvB,IAAAwB,2BAAM,EAAC;EACNC,IAAI,EAAEC,6BAAQ,CAACC,MAAM;EACrBC,SAAS,EAAE;AACb,CAAC,CAAC,EAAA3B,KAAA,GAGD,IAAAuB,2BAAM,EAAC;EACNC,IAAI,EAAEC,6BAAQ,CAACC,MAAM;EACrBC,SAAS,EAAE;AACb,CAAC,CAAC,MAXHC,0BAAK,EAAA3B,MAAA,IAAAC,OAAA,0BAAA2B,MAAA;EAAA,SAAAR,cAAA,GAAAS,IAAA;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAtB,OAAA,QAAAW,aAAA;IAAAU,KAAA,GAAA1B,UAAA,OAAAgB,aAAA,MAAAS,IAAA;IAAA,IAAAG,2BAAA,CAAAvB,OAAA,EAAAqB,KAAA,UAAA5B,WAAA,EAAA4B,KAAA;IAAA,IAAAE,2BAAA,CAAAvB,OAAA,EAAAqB,KAAA,aAAA3B,YAAA,EAAA2B,KAAA;IAAA,OAAAA,KAAA;EAAA;EAAA,IAAAG,UAAA,CAAAxB,OAAA,EAAAW,aAAA,EAAAQ,MAAA;EAAA,WAAAM,aAAA,CAAAzB,OAAA,EAAAW,aAAA;AAAA,EAC6Be,0BAAK,GAAAjC,WAAA,OAAAkC,0BAAA,CAAA3B,OAAA,EAAAR,OAAA,CAAAgB,SAAA,WAAAnB,IAAA;EAAAuC,YAAA;EAAAC,UAAA;EAAAC,QAAA;EAAAC,WAAA;AAAA,IAAArC,YAAA,OAAAiC,0BAAA,CAAA3B,OAAA,EAAAR,OAAA,CAAAgB,SAAA,cAAAlB,KAAA;EAAAsC,YAAA;EAAAC,UAAA;EAAAC,QAAA;EAAAC,WAAA;AAAA,IAAAvC,OAAA,MAAAD,MAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_SequelizeMeta","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/db/models/index.ts"],"sourcesContent":["export * from './SequelizeMeta';\n\n"],"mappings":";;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,cAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_SequelizeMeta","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["../../../src/db/models/index.ts"],"sourcesContent":["export * from './SequelizeMeta';\r\n\r\n"],"mappings":";;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,cAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -17,8 +17,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
17
17
|
/** Elastic search client */
|
|
18
18
|
let client;
|
|
19
19
|
const ElasticSearch = exports.ElasticSearch = {
|
|
20
|
-
/**
|
|
21
|
-
* Init function that should be called on server startup to establish the connection
|
|
20
|
+
/**
|
|
21
|
+
* Init function that should be called on server startup to establish the connection
|
|
22
22
|
*/
|
|
23
23
|
async init() {
|
|
24
24
|
(0, _checkEnvironment.checkEnvironment)({
|
|
@@ -44,9 +44,9 @@ const ElasticSearch = exports.ElasticSearch = {
|
|
|
44
44
|
await this.migrate();
|
|
45
45
|
_LifecycleController.LifecycleController.register(this);
|
|
46
46
|
},
|
|
47
|
-
/**
|
|
48
|
-
* Migration function called during the init process
|
|
49
|
-
* Manages the database structure
|
|
47
|
+
/**
|
|
48
|
+
* Migration function called during the init process
|
|
49
|
+
* Manages the database structure
|
|
50
50
|
*/
|
|
51
51
|
async migrate() {
|
|
52
52
|
if (!client) throw new _EngineError.EngineError('ElasticSearch was not initialized');
|
|
@@ -104,8 +104,8 @@ const ElasticSearch = exports.ElasticSearch = {
|
|
|
104
104
|
}
|
|
105
105
|
});
|
|
106
106
|
},
|
|
107
|
-
/**
|
|
108
|
-
* Shutdown function that should be called on server stop to close the connection
|
|
107
|
+
/**
|
|
108
|
+
* Shutdown function that should be called on server stop to close the connection
|
|
109
109
|
*/
|
|
110
110
|
async shutdown() {
|
|
111
111
|
if (client) await client.close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElasticSearch.js","names":["_fs","require","_path","_interopRequireDefault","_elasticsearch","_EngineError","_LifecycleController","_utils","_checkEnvironment","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","client","ElasticSearch","exports","init","checkEnvironment","ELASTIC_SEARCH_HOST","envAssert","isString","ELASTIC_SEARCH_USERNAME","ELASTIC_SEARCH_PASSWORD","ELASTIC_SEARCH_MIGRATION_PATH","process","env","EngineError","message","Client","node","auth","username","password","NODE_ENV","indices","delete","index","migrate","LifecycleController","register","migrationPath","path","resolve","files","readdirSync","indexExists","exists","ran","file","hits","total","search","body","query","match","tot","value","push","migration","specifier","Promise","then","s","error","reportError","exit","create","id","ranAt","Date","reportInfo","length","data","shutdown","close"],"sources":["../../../src/entities/ElasticSearch/ElasticSearch.ts"],"sourcesContent":["import { readdirSync } from 'fs';\nimport path from 'path';\nimport { Client } from '@elastic/elasticsearch';\nimport { ElasticSearchMigration } from './ElasticSearch.types';\nimport { EngineError } from 'entities/EngineError';\nimport { LifecycleController } from 'entities/LifecycleController';\nimport { envAssert, reportError, reportInfo } from 'utils';\nimport { checkEnvironment } from 'utils/checkEnvironment';\n\n/** Elastic search client */\nlet client: undefined | Client;\n\nexport const ElasticSearch = {\n /**\n * Init function that should be called on server startup to establish the connection\n */\n async init(): Promise<void> {\n checkEnvironment({\n ELASTIC_SEARCH_HOST: envAssert.isString(),\n ELASTIC_SEARCH_USERNAME: envAssert.isString(),\n ELASTIC_SEARCH_PASSWORD: envAssert.isString(),\n ELASTIC_SEARCH_MIGRATION_PATH: envAssert.isString()\n });\n\n if (!process.env.ELASTIC_SEARCH_HOST)\n throw new EngineError({\n message: 'ElasticSearch Hosts not set in environment'\n });\n\n client = new Client({\n node: process.env.ELASTIC_SEARCH_HOST,\n auth: {\n username: process.env.ELASTIC_SEARCH_USERNAME as string,\n password: process.env.ELASTIC_SEARCH_PASSWORD as string\n }\n });\n // In test environment flush the database before running migrations\n if (process.env.NODE_ENV === 'test')\n await client.indices.delete({ index: '*' });\n await this.migrate();\n LifecycleController.register(this);\n },\n\n /**\n * Migration function called during the init process\n * Manages the database structure\n */\n async migrate(): Promise<void> {\n if (!client) throw new EngineError('ElasticSearch was not initialized');\n const migrationPath = path.resolve(\n process.env.ELASTIC_SEARCH_MIGRATION_PATH as string\n );\n const files = readdirSync(`${migrationPath}`);\n const indexExists = await client.indices.exists({\n index: 'migrations'\n });\n const ran = [];\n for (const file of files) {\n if (indexExists) {\n const {\n hits: { total }\n } = await client.search({\n index: 'migrations',\n body: { query: { match: { file } } }\n });\n let tot = 0;\n if (typeof total === 'number') {\n tot = total;\n } else {\n tot = total?.value ?? 0;\n }\n if (tot > 0) continue;\n }\n ran.push(file);\n const migration = (await import(\n `${migrationPath}/${file}`\n )) as ElasticSearchMigration;\n try {\n await migration.migrate(client);\n } catch (error) {\n reportError(error);\n process.exit(1);\n }\n\n await client.create({\n index: 'migrations',\n id: file,\n body: { file, ranAt: new Date() }\n });\n }\n reportInfo({\n message: `ElasticSearch: ran ${ran.length} migrations`,\n data: { files: ran }\n });\n },\n\n /**\n * Shutdown function that should be called on server stop to close the connection\n */\n async shutdown(): Promise<void> {\n if (client) await client.close();\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAA0D,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAI,GAAA,CAAAP,CAAA,UAAAG,CAAA,CAAAK,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAf,CAAA,oBAAAe,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAjB,CAAA,EAAAe,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAd,CAAA,EAAAe,CAAA,UAAAG,CAAA,KAAAA,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;MAC5B,IAAI;QACF,MAAMU,SAAS,CAACrB,OAAO,CAACxB,MAAM,CAAC;MACjC,CAAC,CAAC,OAAOkD,KAAK,EAAE;QACd,IAAAC,kBAAW,EAACD,KAAK,CAAC;QAClBvC,OAAO,CAACyC,IAAI,CAAC,CAAC,CAAC;MACjB;MAEA,MAAMpD,MAAM,CAACqD,MAAM,CAAC;QAClB9B,KAAK,EAAE,YAAY;QACnB+B,EAAE,EAAEnB,IAAI;QACRI,IAAI,EAAE;UAAEJ,IAAI;UAAEoB,KAAK,EAAE,IAAIC,IAAI,CAAC;QAAE;MAClC,CAAC,CAAC;IACJ;IACA,IAAAC,iBAAU,EAAC;MACT3C,OAAO,EAAE,sBAAsBoB,GAAG,CAACwB,MAAM,aAAa;MACtDC,IAAI,EAAE;QAAE7B,KAAK,EAAEI;MAAI;IACrB,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;EACE,MAAM0B,QAAQA,CAAA,EAAkB;IAC9B,IAAI5D,MAAM,EAAE,MAAMA,MAAM,CAAC6D,KAAK,CAAC,CAAC;EAClC;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ElasticSearch.js","names":["_fs","require","_path","_interopRequireDefault","_elasticsearch","_EngineError","_LifecycleController","_utils","_checkEnvironment","_getRequireWildcardCache","e","WeakMap","r","t","_interopRequireWildcard","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","client","ElasticSearch","exports","init","checkEnvironment","ELASTIC_SEARCH_HOST","envAssert","isString","ELASTIC_SEARCH_USERNAME","ELASTIC_SEARCH_PASSWORD","ELASTIC_SEARCH_MIGRATION_PATH","process","env","EngineError","message","Client","node","auth","username","password","NODE_ENV","indices","delete","index","migrate","LifecycleController","register","migrationPath","path","resolve","files","readdirSync","indexExists","exists","ran","file","hits","total","search","body","query","match","tot","value","push","migration","specifier","Promise","then","s","error","reportError","exit","create","id","ranAt","Date","reportInfo","length","data","shutdown","close"],"sources":["../../../src/entities/ElasticSearch/ElasticSearch.ts"],"sourcesContent":["import { readdirSync } from 'fs';\r\nimport path from 'path';\r\nimport { Client } from '@elastic/elasticsearch';\r\nimport { ElasticSearchMigration } from './ElasticSearch.types';\r\nimport { EngineError } from 'entities/EngineError';\r\nimport { LifecycleController } from 'entities/LifecycleController';\r\nimport { envAssert, reportError, reportInfo } from 'utils';\r\nimport { checkEnvironment } from 'utils/checkEnvironment';\r\n\r\n/** Elastic search client */\r\nlet client: undefined | Client;\r\n\r\nexport const ElasticSearch = {\r\n /**\r\n * Init function that should be called on server startup to establish the connection\r\n */\r\n async init(): Promise<void> {\r\n checkEnvironment({\r\n ELASTIC_SEARCH_HOST: envAssert.isString(),\r\n ELASTIC_SEARCH_USERNAME: envAssert.isString(),\r\n ELASTIC_SEARCH_PASSWORD: envAssert.isString(),\r\n ELASTIC_SEARCH_MIGRATION_PATH: envAssert.isString()\r\n });\r\n\r\n if (!process.env.ELASTIC_SEARCH_HOST)\r\n throw new EngineError({\r\n message: 'ElasticSearch Hosts not set in environment'\r\n });\r\n\r\n client = new Client({\r\n node: process.env.ELASTIC_SEARCH_HOST,\r\n auth: {\r\n username: process.env.ELASTIC_SEARCH_USERNAME as string,\r\n password: process.env.ELASTIC_SEARCH_PASSWORD as string\r\n }\r\n });\r\n // In test environment flush the database before running migrations\r\n if (process.env.NODE_ENV === 'test')\r\n await client.indices.delete({ index: '*' });\r\n await this.migrate();\r\n LifecycleController.register(this);\r\n },\r\n\r\n /**\r\n * Migration function called during the init process\r\n * Manages the database structure\r\n */\r\n async migrate(): Promise<void> {\r\n if (!client) throw new EngineError('ElasticSearch was not initialized');\r\n const migrationPath = path.resolve(\r\n process.env.ELASTIC_SEARCH_MIGRATION_PATH as string\r\n );\r\n const files = readdirSync(`${migrationPath}`);\r\n const indexExists = await client.indices.exists({\r\n index: 'migrations'\r\n });\r\n const ran = [];\r\n for (const file of files) {\r\n if (indexExists) {\r\n const {\r\n hits: { total }\r\n } = await client.search({\r\n index: 'migrations',\r\n body: { query: { match: { file } } }\r\n });\r\n let tot = 0;\r\n if (typeof total === 'number') {\r\n tot = total;\r\n } else {\r\n tot = total?.value ?? 0;\r\n }\r\n if (tot > 0) continue;\r\n }\r\n ran.push(file);\r\n const migration = (await import(\r\n `${migrationPath}/${file}`\r\n )) as ElasticSearchMigration;\r\n try {\r\n await migration.migrate(client);\r\n } catch (error) {\r\n reportError(error);\r\n process.exit(1);\r\n }\r\n\r\n await client.create({\r\n index: 'migrations',\r\n id: file,\r\n body: { file, ranAt: new Date() }\r\n });\r\n }\r\n reportInfo({\r\n message: `ElasticSearch: ran ${ran.length} migrations`,\r\n data: { files: ran }\r\n });\r\n },\r\n\r\n /**\r\n * Shutdown function that should be called on server stop to close the connection\r\n */\r\n async shutdown(): Promise<void> {\r\n if (client) await client.close();\r\n }\r\n};\r\n"],"mappings":";;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAEA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,oBAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AAA0D,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAI,wBAAAJ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAM,OAAA,EAAAN,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAI,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AM;UACLK,GAAG,GAAGL,KAAK,EAAEM,KAAK,IAAI,CAAC;QACzB;QACA,IAAID,GAAG,GAAG,CAAC,EAAE;MACf;MACAR,GAAG,CAACU,IAAI,CAACT,IAAI,CAAC;MACd,MAAMU,SAAS,GAAI,OAAAC,SAAA,QAAAC,OAAA,CAAAjE,CAAA,IAAAA,CAAA,CAAAgE,SAAA,GAAAE,IAAA,CAAAC,CAAA,IAAAjE,uBAAA,CAAAb,OAAA,CAAA8E,CAAA,KACjB,GAAGtB,aAAa,IAAIQ,IAAI,EAAE,CACA;MAC5B,IAAI;QACF,MAAMU,SAAS,CAACrB,OAAO,CAACxB,MAAM,CAAC;MACjC,CAAC,CAAC,OAAOkD,KAAK,EAAE;QACd,IAAAC,kBAAW,EAACD,KAAK,CAAC;QAClBvC,OAAO,CAACyC,IAAI,CAAC,CAAC,CAAC;MACjB;MAEA,MAAMpD,MAAM,CAACqD,MAAM,CAAC;QAClB9B,KAAK,EAAE,YAAY;QACnB+B,EAAE,EAAEnB,IAAI;QACRI,IAAI,EAAE;UAAEJ,IAAI;UAAEoB,KAAK,EAAE,IAAIC,IAAI,CAAC;QAAE;MAClC,CAAC,CAAC;IACJ;IACA,IAAAC,iBAAU,EAAC;MACT3C,OAAO,EAAE,sBAAsBoB,GAAG,CAACwB,MAAM,aAAa;MACtDC,IAAI,EAAE;QAAE7B,KAAK,EAAEI;MAAI;IACrB,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;EACE,MAAM0B,QAAQA,CAAA,EAAkB;IAC9B,IAAI5D,MAAM,EAAE,MAAMA,MAAM,CAAC6D,KAAK,CAAC,CAAC;EAClC;AACF,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElasticSearch.types.js","names":[],"sources":["../../../src/entities/ElasticSearch/ElasticSearch.types.ts"],"sourcesContent":["import { Client } from '@elastic/elasticsearch';\n\n/** Represents a migration that should be executed on ElasticSearch */\nexport interface ElasticSearchMigration {\n /** Migration function */\n migrate: (client: Client) => Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ElasticSearch.types.js","names":[],"sources":["../../../src/entities/ElasticSearch/ElasticSearch.types.ts"],"sourcesContent":["import { Client } from '@elastic/elasticsearch';\r\n\r\n/** Represents a migration that should be executed on ElasticSearch */\r\nexport interface ElasticSearchMigration {\r\n /** Migration function */\r\n migrate: (client: Client) => Promise<void>;\r\n}\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_ElasticSearch","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ElasticSearch2"],"sources":["../../../src/entities/ElasticSearch/index.ts"],"sourcesContent":["export * from './ElasticSearch';\nexport * from './ElasticSearch.types';\n"],"mappings":";;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,cAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,eAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,eAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,eAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,eAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_ElasticSearch","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_ElasticSearch2"],"sources":["../../../src/entities/ElasticSearch/index.ts"],"sourcesContent":["export * from './ElasticSearch';\r\nexport * from './ElasticSearch.types';\r\n"],"mappings":";;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,cAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,cAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,cAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,eAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,eAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,eAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,eAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -14,8 +14,8 @@ var _middleware = require("../../middleware");
|
|
|
14
14
|
var _report = require("../../utils/report");
|
|
15
15
|
const namespace = 'engine:Endpoint';
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Object representing a REST endpoint served by server
|
|
17
|
+
/**
|
|
18
|
+
* Object representing a REST endpoint served by server
|
|
19
19
|
*/
|
|
20
20
|
let Endpoint = exports.Endpoint = /*#__PURE__*/function () {
|
|
21
21
|
/** Create a REST endpoint */
|
|
@@ -77,8 +77,8 @@ let Endpoint = exports.Endpoint = /*#__PURE__*/function () {
|
|
|
77
77
|
if (config.errorMiddleware instanceof Array) this.errorMiddleware = config.errorMiddleware;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
/**
|
|
81
|
-
* Register the endpoint to a react app
|
|
80
|
+
/**
|
|
81
|
+
* Register the endpoint to a react app
|
|
82
82
|
*/
|
|
83
83
|
return (0, _createClass2.default)(Endpoint, [{
|
|
84
84
|
key: "register",
|
|
@@ -110,8 +110,8 @@ let Endpoint = exports.Endpoint = /*#__PURE__*/function () {
|
|
|
110
110
|
app[this.method](this.path, ...safeMiddlewareChain.flat());
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* Catch exceptions thrown inside of middleware and pass them properly to express
|
|
113
|
+
/**
|
|
114
|
+
* Catch exceptions thrown inside of middleware and pass them properly to express
|
|
115
115
|
*/
|
|
116
116
|
}, {
|
|
117
117
|
key: "catchExceptionForExpress",
|
|
@@ -142,8 +142,8 @@ let Endpoint = exports.Endpoint = /*#__PURE__*/function () {
|
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
/**
|
|
146
|
-
* Get the authentication middleware for a given type of authentication
|
|
145
|
+
/**
|
|
146
|
+
* Get the authentication middleware for a given type of authentication
|
|
147
147
|
*/
|
|
148
148
|
}, {
|
|
149
149
|
key: "getAuthMiddleware",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Endpoint.js","names":["_EngineError","require","_Endpoint2","_const","_middleware","_report","namespace","Endpoint","exports","config","_classCallCheck2","default","path","method","authType","handler","validator","authParams","files","middleware","errorMiddleware","reportDebug","message","data","file","EngineError","EndpointMethods","includes","EndpointAuthTypes","Array","_createClass2","key","value","register","app","middlewareChain","requestMetrics","push","getAuthMiddleware","fileUploader","validate","safeMiddlewareChain","catchExceptionForExpress","flat","map","req","res","next","err","catch","error","reportError","type","EndpointAuthHandlers","reportInfo","severity","LogSeverity","WARNING","request","response","acceptInvalid"],"sources":["../../../src/entities/Endpoint/Endpoint.ts"],"sourcesContent":["import {\n RequestHandler,\n ErrorRequestHandler,\n Application,\n Request,\n Response,\n NextFunction\n} from 'express';\nimport { Schema } from 'express-validator';\nimport { EngineError } from '../EngineError';\nimport {\n EndpointOptions,\n EndpointAuthType,\n EndpointAuthTypes,\n EndpointMethod,\n EndpointMethods,\n EndpointAuthParams,\n Middleware,\n MiddlewareChainElement,\n SafeMiddleWareChain,\n EndpointAuthHandlers,\n EndpointAuthHandler,\n EndpointRequestType,\n EndpointHandler\n} from './Endpoint.types';\nimport { LogSeverity } from 'const';\nimport { validate, fileUploader, requestMetrics } from 'middleware';\nimport { FileUploaderConfig } from 'middleware/fileUploader';\nimport { reportDebug, reportError, reportInfo } from 'utils/report';\n\nconst namespace = 'engine:Endpoint';\n\n/**\n * Object representing a REST endpoint served by server\n */\nexport class Endpoint<T extends EndpointAuthType> {\n /** Path at which the endpoint is reachable */\n public readonly path: string;\n /** HTTP method of the endpoint */\n public readonly method: EndpointMethod;\n /** Authentication system required by this endpoint */\n public readonly authType: T;\n /** Function handling the endpoint's business logic */\n private handler: EndpointHandler<T>;\n /** Validation schema that the request must pass before reaching the handler */\n private validator: Schema;\n /** Authentication related options for this endpoint */\n private authParams?: EndpointAuthParams<T>;\n /** Settings to upload files through this endpoint (this will automatically switch the expected request to be a multipart) */\n private files?: Array<FileUploaderConfig>;\n /** Express request handlers that should run on this endpoint before the business logic, they will run after the global middleware */\n private middleware?: Array<Middleware<T>>;\n /** Express error handlers that should be registered for this endpoint. they will run before the global error handler */\n private errorMiddleware?: Array<ErrorRequestHandler>;\n\n /** Create a REST endpoint */\n public constructor(config: EndpointOptions<T>) {\n reportDebug({\n namespace,\n message: `Creating Endpoint [${config.method} - ${config.path}]`,\n data: {\n method: config.method,\n path: config.path,\n authType: config.authType,\n authParams: config.authParams,\n file: config.file\n }\n });\n\n if (typeof config.path !== 'string')\n throw new EngineError({\n message: 'Endpoint path was not declared as a string'\n });\n this.path = config.path;\n\n if (!EndpointMethods.includes(config.method))\n throw new EngineError({\n message: 'Endpoint method is not a valid HTTP method'\n });\n this.method = config.method;\n\n if (typeof config.handler !== 'function')\n throw new EngineError({ message: 'Endpoint handler is not a function' });\n this.handler = config.handler;\n\n if (!EndpointAuthTypes.includes(config.authType))\n throw new EngineError({ message: 'Endpoint auth type is not valid' });\n this.authType = config.authType;\n\n this.validator = config.validator;\n this.authParams = config.authParams;\n this.files = config.file ? [config.file] : config.files;\n\n // Middleware can both be function or arrays\n if (typeof config.middleware === 'function')\n this.middleware = [config.middleware];\n if (config.middleware instanceof Array) this.middleware = config.middleware;\n if (typeof config.errorMiddleware === 'function')\n this.errorMiddleware = [config.errorMiddleware];\n if (config.errorMiddleware instanceof Array)\n this.errorMiddleware = config.errorMiddleware;\n }\n\n /**\n * Register the endpoint to a react app\n */\n public register(app: Application): void {\n // First initialize the handling calculation\n const middlewareChain: Array<MiddlewareChainElement<T>> = [requestMetrics];\n // Register auth middleware\n middlewareChain.push(...this.getAuthMiddleware(this.authType));\n if (this.files) {\n // Register file upload\n // Validation is included in the file upload process as this uses multipart/form-data\n middlewareChain.push(fileUploader(this.files, this.validator));\n } else {\n // Register validator for regular cases\n middlewareChain.push(validate(this.validator));\n }\n // Register additional middleware\n if (this.middleware) {\n middlewareChain.push(...this.middleware);\n }\n // Register handler\n middlewareChain.push(this.handler);\n // Wrap middleware to await any async execution and catch any errors thrown\n const safeMiddlewareChain: SafeMiddleWareChain =\n this.catchExceptionForExpress(middlewareChain);\n // Register error middleware\n if (this.errorMiddleware) {\n safeMiddlewareChain.push(...this.errorMiddleware);\n }\n app[this.method](\n this.path,\n ...(safeMiddlewareChain.flat() as Array<\n RequestHandler | ErrorRequestHandler\n >)\n );\n }\n\n /**\n * Catch exceptions thrown inside of middleware and pass them properly to express\n */\n private catchExceptionForExpress(\n middlewareChain: Array<MiddlewareChainElement<T>>\n ): SafeMiddleWareChain {\n return middlewareChain.map((middleware) => {\n if (middleware instanceof Array) {\n return this.catchExceptionForExpress(middleware);\n }\n if (typeof middleware === 'function') {\n return (req: Request, res: Response, next: NextFunction) => {\n (async (): Promise<void> => {\n try {\n await middleware(req as EndpointRequestType[T], res, next);\n } catch (err) {\n next(err);\n }\n })().catch((error) => {\n reportError(error);\n });\n };\n }\n throw new EngineError({\n message: 'Middleware is not a function nor an array',\n data: { type: typeof middleware }\n });\n });\n }\n\n /**\n * Get the authentication middleware for a given type of authentication\n */\n private getAuthMiddleware(authType: EndpointAuthType): Array<RequestHandler> {\n const middlewareChain: Array<RequestHandler> = [];\n\n const handler = EndpointAuthHandlers[authType] as EndpointAuthHandler<T>;\n if (!handler) {\n reportInfo({\n severity: LogSeverity.WARNING,\n message: `Endpoint \"${this.method} - ${this.path}\" was declared with no authentication method`\n });\n return [];\n }\n\n const middleware = handler(this.authParams);\n\n middlewareChain.push(\n async (request: Request, response: Response, next: NextFunction) => {\n try {\n await middleware(request, response, next);\n } catch (error) {\n if (!this.authParams?.acceptInvalid) throw error;\n reportError(error);\n next();\n }\n }\n );\n\n return middlewareChain;\n }\n}\n"],"mappings":";;;;;;;;;AASA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAeA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAEA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,GAAG,iBAAiB;;AAEnC;AACA;AACA;AAFA,IAGaC,QAAQ,GAAAC,OAAA,CAAAD,QAAA;EAoBnB;EACA,SAAAA,SAAmBE,MAA0B,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAJ,QAAA;IApB/C;IAAA,KACgBK,IAAI;IACpB;IAAA,KACgBC,MAAM;IACtB;IAAA,KACgBC,QAAQ;IACxB;IAAA,KACQC,OAAO;IACf;IAAA,KACQC,SAAS;IACjB;IAAA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GA,SAAQM,iBAAiBA,CAACxB,QAA0B,EAAyB;MAC3E,MAAMqB,eAAsC,GAAG,EAAE;MAEjD,MAAMpB,OAAO,GAAGsC,+BAAoB,CAACvC,QAAQ,CAA2B;MACxE,IAAI,CAACC,OAAO,EAAE;QACZ,IAAAuC,kBAAU,EAAC;UACTC,QAAQ,EAAEC,kBAAW,CAACC,OAAO;UAC7BnC,OAAO,EAAE,aAAa,IAAI,CAACT,MAAM,MAAM,IAAI,CAACD,IAAI;QAClD,CAAC,CAAC;QACF,OAAO,EAAE;MACX;MAEA,MAAMO,UAAU,GAAGJ,OAAO,CAAC,IAAI,CAACE,UAAU,CAAC;MAE3CkB,eAAe,CAACE,IAAI,CAClB,OAAOqB,OAAgB,EAAEC,QAAkB,EAAEZ,IAAkB,KAAK;QAClE,IAAI;UACF,MAAM5B,UAAU,CAACuC,OAAO,EAAEC,QAAQ,EAAEZ,IAAI,CAAC;QAC3C,CAAC,CAAC,OAAOG,KAAK,EAAE;UACd,IAAI,CAAC,IAAI,CAACjC,UAAU,EAAE2C,aAAa,EAAE,MAAMV,KAAK;UAChD,IAAAC,mBAAW,EAACD,KAAK,CAAC;UAClBH,IAAI,CAAC,CAAC;QACR;MACF,CACF,CAAC;MAED,OAAOZ,eAAe;IACxB;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Endpoint.js","names":["_EngineError","require","_Endpoint2","_const","_middleware","_report","namespace","Endpoint","exports","config","_classCallCheck2","default","path","method","authType","handler","validator","authParams","files","middleware","errorMiddleware","reportDebug","message","data","file","EngineError","EndpointMethods","includes","EndpointAuthTypes","Array","_createClass2","key","value","register","app","middlewareChain","requestMetrics","push","getAuthMiddleware","fileUploader","validate","safeMiddlewareChain","catchExceptionForExpress","flat","map","req","res","next","err","catch","error","reportError","type","EndpointAuthHandlers","reportInfo","severity","LogSeverity","WARNING","request","response","acceptInvalid"],"sources":["../../../src/entities/Endpoint/Endpoint.ts"],"sourcesContent":["import {\r\n RequestHandler,\r\n ErrorRequestHandler,\r\n Application,\r\n Request,\r\n Response,\r\n NextFunction\r\n} from 'express';\r\nimport { Schema } from 'express-validator';\r\nimport { EngineError } from '../EngineError';\r\nimport {\r\n EndpointOptions,\r\n EndpointAuthType,\r\n EndpointAuthTypes,\r\n EndpointMethod,\r\n EndpointMethods,\r\n EndpointAuthParams,\r\n Middleware,\r\n MiddlewareChainElement,\r\n SafeMiddleWareChain,\r\n EndpointAuthHandlers,\r\n EndpointAuthHandler,\r\n EndpointRequestType,\r\n EndpointHandler\r\n} from './Endpoint.types';\r\nimport { LogSeverity } from 'const';\r\nimport { validate, fileUploader, requestMetrics } from 'middleware';\r\nimport { FileUploaderConfig } from 'middleware/fileUploader';\r\nimport { reportDebug, reportError, reportInfo } from 'utils/report';\r\n\r\nconst namespace = 'engine:Endpoint';\r\n\r\n/**\r\n * Object representing a REST endpoint served by server\r\n */\r\nexport class Endpoint<T extends EndpointAuthType> {\r\n /** Path at which the endpoint is reachable */\r\n public readonly path: string;\r\n /** HTTP method of the endpoint */\r\n public readonly method: EndpointMethod;\r\n /** Authentication system required by this endpoint */\r\n public readonly authType: T;\r\n /** Function handling the endpoint's business logic */\r\n private handler: EndpointHandler<T>;\r\n /** Validation schema that the request must pass before reaching the handler */\r\n private validator: Schema;\r\n /** Authentication related options for this endpoint */\r\n private authParams?: EndpointAuthParams<T>;\r\n /** Settings to upload files through this endpoint (this will automatically switch the expected request to be a multipart) */\r\n private files?: Array<FileUploaderConfig>;\r\n /** Express request handlers that should run on this endpoint before the business logic, they will run after the global middleware */\r\n private middleware?: Array<Middleware<T>>;\r\n /** Express error handlers that should be registered for this endpoint. they will run before the global error handler */\r\n private errorMiddleware?: Array<ErrorRequestHandler>;\r\n\r\n /** Create a REST endpoint */\r\n public constructor(config: EndpointOptions<T>) {\r\n reportDebug({\r\n namespace,\r\n message: `Creating Endpoint [${config.method} - ${config.path}]`,\r\n data: {\r\n method: config.method,\r\n path: config.path,\r\n authType: config.authType,\r\n authParams: config.authParams,\r\n file: config.file\r\n }\r\n });\r\n\r\n if (typeof config.path !== 'string')\r\n throw new EngineError({\r\n message: 'Endpoint path was not declared as a string'\r\n });\r\n this.path = config.path;\r\n\r\n if (!EndpointMethods.includes(config.method))\r\n throw new EngineError({\r\n message: 'Endpoint method is not a valid HTTP method'\r\n });\r\n this.method = config.method;\r\n\r\n if (typeof config.handler !== 'function')\r\n throw new EngineError({ message: 'Endpoint handler is not a function' });\r\n this.handler = config.handler;\r\n\r\n if (!EndpointAuthTypes.includes(config.authType))\r\n throw new EngineError({ message: 'Endpoint auth type is not valid' });\r\n this.authType = config.authType;\r\n\r\n this.validator = config.validator;\r\n this.authParams = config.authParams;\r\n this.files = config.file ? [config.file] : config.files;\r\n\r\n // Middleware can both be function or arrays\r\n if (typeof config.middleware === 'function')\r\n this.middleware = [config.middleware];\r\n if (config.middleware instanceof Array) this.middleware = config.middleware;\r\n if (typeof config.errorMiddleware === 'function')\r\n this.errorMiddleware = [config.errorMiddleware];\r\n if (config.errorMiddleware instanceof Array)\r\n this.errorMiddleware = config.errorMiddleware;\r\n }\r\n\r\n /**\r\n * Register the endpoint to a react app\r\n */\r\n public register(app: Application): void {\r\n // First initialize the handling calculation\r\n const middlewareChain: Array<MiddlewareChainElement<T>> = [requestMetrics];\r\n // Register auth middleware\r\n middlewareChain.push(...this.getAuthMiddleware(this.authType));\r\n if (this.files) {\r\n // Register file upload\r\n // Validation is included in the file upload process as this uses multipart/form-data\r\n middlewareChain.push(fileUploader(this.files, this.validator));\r\n } else {\r\n // Register validator for regular cases\r\n middlewareChain.push(validate(this.validator));\r\n }\r\n // Register additional middleware\r\n if (this.middleware) {\r\n middlewareChain.push(...this.middleware);\r\n }\r\n // Register handler\r\n middlewareChain.push(this.handler);\r\n // Wrap middleware to await any async execution and catch any errors thrown\r\n const safeMiddlewareChain: SafeMiddleWareChain =\r\n this.catchExceptionForExpress(middlewareChain);\r\n // Register error middleware\r\n if (this.errorMiddleware) {\r\n safeMiddlewareChain.push(...this.errorMiddleware);\r\n }\r\n app[this.method](\r\n this.path,\r\n ...(safeMiddlewareChain.flat() as Array<\r\n RequestHandler | ErrorRequestHandler\r\n >)\r\n );\r\n }\r\n\r\n /**\r\n * Catch exceptions thrown inside of middleware and pass them properly to express\r\n */\r\n private catchExceptionForExpress(\r\n middlewareChain: Array<MiddlewareChainElement<T>>\r\n ): SafeMiddleWareChain {\r\n return middlewareChain.map((middleware) => {\r\n if (middleware instanceof Array) {\r\n return this.catchExceptionForExpress(middleware);\r\n }\r\n if (typeof middleware === 'function') {\r\n return (req: Request, res: Response, next: NextFunction) => {\r\n (async (): Promise<void> => {\r\n try {\r\n await middleware(req as EndpointRequestType[T], res, next);\r\n } catch (err) {\r\n next(err);\r\n }\r\n })().catch((error) => {\r\n reportError(error);\r\n });\r\n };\r\n }\r\n throw new EngineError({\r\n message: 'Middleware is not a function nor an array',\r\n data: { type: typeof middleware }\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * Get the authentication middleware for a given type of authentication\r\n */\r\n private getAuthMiddleware(authType: EndpointAuthType): Array<RequestHandler> {\r\n const middlewareChain: Array<RequestHandler> = [];\r\n\r\n const handler = EndpointAuthHandlers[authType] as EndpointAuthHandler<T>;\r\n if (!handler) {\r\n reportInfo({\r\n severity: LogSeverity.WARNING,\r\n message: `Endpoint \"${this.method} - ${this.path}\" was declared with no authentication method`\r\n });\r\n return [];\r\n }\r\n\r\n const middleware = handler(this.authParams);\r\n\r\n middlewareChain.push(\r\n async (request: Request, response: Response, next: NextFunction) => {\r\n try {\r\n await middleware(request, response, next);\r\n } catch (error) {\r\n if (!this.authParams?.acceptInvalid) throw error;\r\n reportError(error);\r\n next();\r\n }\r\n }\r\n );\r\n\r\n return middlewareChain;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;AASA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AAeA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAA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oint.types.js","names":["_middleware","require","EndpointMethod","exports","EndpointMethods","Object","values","EndpointAuthType","EndpointAuthTypes","EndpointAuthHandlers","NONE","undefined","JWT","authJwt","TLS","authTls","HMAC","authHmac","STATIC","authStatic","ADMIN","authAdmin"],"sources":["../../../src/entities/Endpoint/Endpoint.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport {\n ErrorRequestHandler,\n Request,\n Response,\n NextFunction,\n RequestHandler\n} from 'express';\nimport { ParamsDictionary } from 'express-serve-static-core';\nimport { Schema } from 'express-validator';\nimport { ParsedQs } from 'qs';\n\nimport {\n authJwt,\n authHmac,\n authTls,\n authStatic,\n authAdmin,\n FileUploaderConfig,\n RequestAdminProps\n} from 'middleware';\n\nexport enum EndpointMethod {\n GET = 'get',\n POST = 'post',\n PUT = 'put',\n PATCH = 'patch',\n DELETE = 'delete',\n HEAD = 'head',\n ALL = 'all'\n}\n\nexport const EndpointMethods = Object.values(EndpointMethod);\n\nexport enum EndpointAuthType {\n NONE = 'none',\n JWT = 'jwt',\n TLS = 'tls',\n HMAC = 'hmac',\n STATIC = 'static',\n ADMIN = 'admin'\n}\n\nexport const EndpointAuthTypes = Object.values(EndpointAuthType);\n\nexport type Middleware<T extends EndpointAuthType> = (\n request: EndpointRequestType[T],\n response: Response,\n next: NextFunction\n) => unknown | Promise<unknown>;\n\nexport type MiddlewareChainElement<T extends EndpointAuthType> =\n | Array<Middleware<T>>\n | Middleware<T>\n | any;\n\n/** Auth related parameters used with Admin authentication */\ninterface EndpointAuthAdminParams {\n /** [Admin] User permission required to use this endpoint */\n permission: string;\n}\n\n/** Auth related parameters used with HMAC authentication */\ninterface EndpointAuthHmacParams {\n /** [HMAC] Secret used for signature */\n secret?: string;\n /** [HMAC] For Github webhook, the standard differs slightly, so this option must be selected */\n isGithub?: boolean;\n}\n\n/** Auth related parameters used with mTLS authentication */\ninterface EndpointAuthTlsParams {\n /** [TLS] List oh hosts that are allowed to use the endpoint, this is compared to the claims in the certificate */\n whitelist?: Array<string>;\n}\n\n/** Mapping used to get auth specific parameters depending on the auth type used */\ninterface EndpointAuthSpecificParams {\n /** Auth parameters for no authentication */\n [EndpointAuthType.NONE]: any;\n /** Auth parameters for JWT authentication */\n [EndpointAuthType.JWT]: any;\n /** Auth parameters for mTLS authentication */\n [EndpointAuthType.TLS]: EndpointAuthTlsParams;\n /** Auth parameters for HMAC authentication */\n [EndpointAuthType.HMAC]: EndpointAuthHmacParams;\n /** Auth parameters for static authentication */\n [EndpointAuthType.STATIC]: any;\n /** Auth parameters for admin token authentication */\n [EndpointAuthType.ADMIN]: EndpointAuthAdminParams;\n}\n\nexport type EndpointAuthParams<T extends EndpointAuthType> =\n EndpointAuthSpecificParams[T] & {\n /** This will allow the business logic to run event if the authentication fails */\n acceptInvalid?: boolean;\n };\n\nexport type EndpointAuthHandler<T extends EndpointAuthType> = (\n options?: EndpointAuthParams<T>\n) => (\n request: Request,\n response: Response,\n next: NextFunction\n) => void | Promise<void>;\n\nexport const EndpointAuthHandlers = {\n /** Auth handler for no authentication */\n [EndpointAuthType.NONE]: undefined,\n /** Auth handler for JWT authentication */\n [EndpointAuthType.JWT]: authJwt,\n /** Auth handler for mTLS authentication */\n [EndpointAuthType.TLS]: authTls,\n /** Auth handler for HMAC authentication */\n [EndpointAuthType.HMAC]: authHmac,\n /** Auth handler for static authentication */\n [EndpointAuthType.STATIC]: authStatic,\n /** Auth handler for admin token authentication */\n [EndpointAuthType.ADMIN]: authAdmin\n};\n\nexport type EndpointHandler<T extends EndpointAuthType> = (\n request: EndpointRequestType[T],\n response: Response\n) => void | Promise<void>;\n\n/** Endpoint initialization options */\nexport interface EndpointOptions<T extends EndpointAuthType> {\n /** Path at which the endpoint is reachable */\n path: string;\n /** HTTP method of the endpoint */\n method: EndpointMethod;\n /** Function handling the endpoint's business logic */\n handler: EndpointHandler<T>;\n /** Validation schema that the request must pass before reaching the handler */\n validator: Schema;\n /** Authentication system required by this endpoint */\n authType: T;\n /** Authentication related options for this endpoint */\n authParams?: EndpointAuthParams<T>;\n /** @deprecated Setting to upload a file through this endpoint */\n file?: FileUploaderConfig;\n /** Settings to upload files through this endpoint (this will automatically switch the expected request to be a multipart) */\n files?: Array<FileUploaderConfig>;\n /** Express request handlers that should run on this endpoint before the business logic, they will run after the global middleware */\n middleware?: MiddlewareChainElement<T>;\n /** Express error handlers that should be registered for this endpoint. they will run before the global error handler */\n errorMiddleware?: ErrorRequestHandler | Array<ErrorRequestHandler>;\n}\n\n/** Request type when using JWT authentication */\nexport interface JwtRequest<\n P = ParamsDictionary,\n ResBody = any,\n ReqBody = any,\n ReqQuery = ParsedQs,\n Locals extends Record<string, any> = Record<string, any>\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\n /** User that identified using a JWT */\n user: Record<string, any> | any;\n}\n\n/** Request type when using mTLS authentication */\nexport interface TlsRequest<\n P = ParamsDictionary,\n ResBody = any,\n ReqBody = any,\n ReqQuery = ParsedQs,\n Locals extends Record<string, any> = Record<string, any>\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\n /** Host names provided by the mTLS authenticated client */\n hosts: Array<string>;\n}\n\n/** Request type when using HMAC authentication */\nexport interface AdminRequest<\n P = ParamsDictionary,\n ResBody = any,\n ReqBody = any,\n ReqQuery = ParsedQs,\n Locals extends Record<string, any> = Record<string, any>\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\n /** User that identified using a JWT */\n admin: RequestAdminProps;\n}\n\n/** Mapping of request types in endpoints based on auth type used */\nexport interface EndpointRequestType {\n /** Request type for no authentication */\n [EndpointAuthType.NONE]: Request;\n /** Request type when using JWT authentication */\n [EndpointAuthType.JWT]: JwtRequest;\n /** Request type when using mTLS authentication */\n [EndpointAuthType.TLS]: TlsRequest;\n /** Request type when using HMAC authentication */\n [EndpointAuthType.HMAC]: Request;\n /** Auth handler for static authentication */\n [EndpointAuthType.STATIC]: Request;\n /** Auth handler for admin token authentication */\n [EndpointAuthType.ADMIN]: AdminRequest;\n}\n\nexport type SafeMiddleWareChain = Array<\n RequestHandler | ErrorRequestHandler | SafeMiddleWareChain\n>;\n"],"mappings":";;;;;;AAYA,IAAAA,WAAA,GAAAC,OAAA;AAZA;AAAA,IAsBYC,cAAc,GAAAC,OAAA,CAAAD,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAUnB,MAAME,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAGC,MAAM,CAACC,MAAM,CAACJ,cAAc,CAAC;AAAC,IAEjDK,gBAAgB,GAAAJ,OAAA,CAAAI,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AASrB,MAAMC,iBAAiB,GAAAL,OAAA,CAAAK,iBAAA,GAAGH,MAAM,CAACC,MAAM,CAACC,gBAAgB,CAAC;;AAahE;;AAMA;;AAQA;;AAMA;;AA8BO,MAAME,oBAAoB,GAAAN,OAAA,CAAAM,oBAAA,GAAG;EAClC;EACA,CAACF,gBAAgB,CAACG,IAAI,GAAGC,SAAS;EAClC;EACA,CAACJ,gBAAgB,CAACK,GAAG,GAAGC,mBAAO;EAC/B;EACA,CAACN,gBAAgB,CAACO,GAAG,GAAGC,mBAAO;EAC/B;EACA,CAACR,gBAAgB,CAACS,IAAI,GAAGC,oBAAQ;EACjC;EACA,CAACV,gBAAgB,CAACW,MAAM,GAAGC,sBAAU;EACrC;EACA,CAACZ,gBAAgB,CAACa,KAAK,GAAGC;AAC5B,CAAC;;AAOD;;AAwBA;;AAYA;;AAYA;;AAYA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Endpoint.types.js","names":["_middleware","require","EndpointMethod","exports","EndpointMethods","Object","values","EndpointAuthType","EndpointAuthTypes","EndpointAuthHandlers","NONE","undefined","JWT","authJwt","TLS","authTls","HMAC","authHmac","STATIC","authStatic","ADMIN","authAdmin"],"sources":["../../../src/entities/Endpoint/Endpoint.types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\r\nimport {\r\n ErrorRequestHandler,\r\n Request,\r\n Response,\r\n NextFunction,\r\n RequestHandler\r\n} from 'express';\r\nimport { ParamsDictionary } from 'express-serve-static-core';\r\nimport { Schema } from 'express-validator';\r\nimport { ParsedQs } from 'qs';\r\n\r\nimport {\r\n authJwt,\r\n authHmac,\r\n authTls,\r\n authStatic,\r\n authAdmin,\r\n FileUploaderConfig,\r\n RequestAdminProps\r\n} from 'middleware';\r\n\r\nexport enum EndpointMethod {\r\n GET = 'get',\r\n POST = 'post',\r\n PUT = 'put',\r\n PATCH = 'patch',\r\n DELETE = 'delete',\r\n HEAD = 'head',\r\n ALL = 'all'\r\n}\r\n\r\nexport const EndpointMethods = Object.values(EndpointMethod);\r\n\r\nexport enum EndpointAuthType {\r\n NONE = 'none',\r\n JWT = 'jwt',\r\n TLS = 'tls',\r\n HMAC = 'hmac',\r\n STATIC = 'static',\r\n ADMIN = 'admin'\r\n}\r\n\r\nexport const EndpointAuthTypes = Object.values(EndpointAuthType);\r\n\r\nexport type Middleware<T extends EndpointAuthType> = (\r\n request: EndpointRequestType[T],\r\n response: Response,\r\n next: NextFunction\r\n) => unknown | Promise<unknown>;\r\n\r\nexport type MiddlewareChainElement<T extends EndpointAuthType> =\r\n | Array<Middleware<T>>\r\n | Middleware<T>\r\n | any;\r\n\r\n/** Auth related parameters used with Admin authentication */\r\ninterface EndpointAuthAdminParams {\r\n /** [Admin] User permission required to use this endpoint */\r\n permission: string;\r\n}\r\n\r\n/** Auth related parameters used with HMAC authentication */\r\ninterface EndpointAuthHmacParams {\r\n /** [HMAC] Secret used for signature */\r\n secret?: string;\r\n /** [HMAC] For Github webhook, the standard differs slightly, so this option must be selected */\r\n isGithub?: boolean;\r\n}\r\n\r\n/** Auth related parameters used with mTLS authentication */\r\ninterface EndpointAuthTlsParams {\r\n /** [TLS] List oh hosts that are allowed to use the endpoint, this is compared to the claims in the certificate */\r\n whitelist?: Array<string>;\r\n}\r\n\r\n/** Mapping used to get auth specific parameters depending on the auth type used */\r\ninterface EndpointAuthSpecificParams {\r\n /** Auth parameters for no authentication */\r\n [EndpointAuthType.NONE]: any;\r\n /** Auth parameters for JWT authentication */\r\n [EndpointAuthType.JWT]: any;\r\n /** Auth parameters for mTLS authentication */\r\n [EndpointAuthType.TLS]: EndpointAuthTlsParams;\r\n /** Auth parameters for HMAC authentication */\r\n [EndpointAuthType.HMAC]: EndpointAuthHmacParams;\r\n /** Auth parameters for static authentication */\r\n [EndpointAuthType.STATIC]: any;\r\n /** Auth parameters for admin token authentication */\r\n [EndpointAuthType.ADMIN]: EndpointAuthAdminParams;\r\n}\r\n\r\nexport type EndpointAuthParams<T extends EndpointAuthType> =\r\n EndpointAuthSpecificParams[T] & {\r\n /** This will allow the business logic to run event if the authentication fails */\r\n acceptInvalid?: boolean;\r\n };\r\n\r\nexport type EndpointAuthHandler<T extends EndpointAuthType> = (\r\n options?: EndpointAuthParams<T>\r\n) => (\r\n request: Request,\r\n response: Response,\r\n next: NextFunction\r\n) => void | Promise<void>;\r\n\r\nexport const EndpointAuthHandlers = {\r\n /** Auth handler for no authentication */\r\n [EndpointAuthType.NONE]: undefined,\r\n /** Auth handler for JWT authentication */\r\n [EndpointAuthType.JWT]: authJwt,\r\n /** Auth handler for mTLS authentication */\r\n [EndpointAuthType.TLS]: authTls,\r\n /** Auth handler for HMAC authentication */\r\n [EndpointAuthType.HMAC]: authHmac,\r\n /** Auth handler for static authentication */\r\n [EndpointAuthType.STATIC]: authStatic,\r\n /** Auth handler for admin token authentication */\r\n [EndpointAuthType.ADMIN]: authAdmin\r\n};\r\n\r\nexport type EndpointHandler<T extends EndpointAuthType> = (\r\n request: EndpointRequestType[T],\r\n response: Response\r\n) => void | Promise<void>;\r\n\r\n/** Endpoint initialization options */\r\nexport interface EndpointOptions<T extends EndpointAuthType> {\r\n /** Path at which the endpoint is reachable */\r\n path: string;\r\n /** HTTP method of the endpoint */\r\n method: EndpointMethod;\r\n /** Function handling the endpoint's business logic */\r\n handler: EndpointHandler<T>;\r\n /** Validation schema that the request must pass before reaching the handler */\r\n validator: Schema;\r\n /** Authentication system required by this endpoint */\r\n authType: T;\r\n /** Authentication related options for this endpoint */\r\n authParams?: EndpointAuthParams<T>;\r\n /** @deprecated Setting to upload a file through this endpoint */\r\n file?: FileUploaderConfig;\r\n /** Settings to upload files through this endpoint (this will automatically switch the expected request to be a multipart) */\r\n files?: Array<FileUploaderConfig>;\r\n /** Express request handlers that should run on this endpoint before the business logic, they will run after the global middleware */\r\n middleware?: MiddlewareChainElement<T>;\r\n /** Express error handlers that should be registered for this endpoint. they will run before the global error handler */\r\n errorMiddleware?: ErrorRequestHandler | Array<ErrorRequestHandler>;\r\n}\r\n\r\n/** Request type when using JWT authentication */\r\nexport interface JwtRequest<\r\n P = ParamsDictionary,\r\n ResBody = any,\r\n ReqBody = any,\r\n ReqQuery = ParsedQs,\r\n Locals extends Record<string, any> = Record<string, any>\r\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\r\n /** User that identified using a JWT */\r\n user: Record<string, any> | any;\r\n}\r\n\r\n/** Request type when using mTLS authentication */\r\nexport interface TlsRequest<\r\n P = ParamsDictionary,\r\n ResBody = any,\r\n ReqBody = any,\r\n ReqQuery = ParsedQs,\r\n Locals extends Record<string, any> = Record<string, any>\r\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\r\n /** Host names provided by the mTLS authenticated client */\r\n hosts: Array<string>;\r\n}\r\n\r\n/** Request type when using HMAC authentication */\r\nexport interface AdminRequest<\r\n P = ParamsDictionary,\r\n ResBody = any,\r\n ReqBody = any,\r\n ReqQuery = ParsedQs,\r\n Locals extends Record<string, any> = Record<string, any>\r\n> extends Request<P, ResBody, ReqBody, ReqQuery, Locals> {\r\n /** User that identified using a JWT */\r\n admin: RequestAdminProps;\r\n}\r\n\r\n/** Mapping of request types in endpoints based on auth type used */\r\nexport interface EndpointRequestType {\r\n /** Request type for no authentication */\r\n [EndpointAuthType.NONE]: Request;\r\n /** Request type when using JWT authentication */\r\n [EndpointAuthType.JWT]: JwtRequest;\r\n /** Request type when using mTLS authentication */\r\n [EndpointAuthType.TLS]: TlsRequest;\r\n /** Request type when using HMAC authentication */\r\n [EndpointAuthType.HMAC]: Request;\r\n /** Auth handler for static authentication */\r\n [EndpointAuthType.STATIC]: Request;\r\n /** Auth handler for admin token authentication */\r\n [EndpointAuthType.ADMIN]: AdminRequest;\r\n}\r\n\r\nexport type SafeMiddleWareChain = Array<\r\n RequestHandler | ErrorRequestHandler | SafeMiddleWareChain\r\n>;\r\n"],"mappings":";;;;;;AAYA,IAAAA,WAAA,GAAAC,OAAA;AAZA;AAAA,IAsBYC,cAAc,GAAAC,OAAA,CAAAD,cAAA,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;AAUnB,MAAME,eAAe,GAAAD,OAAA,CAAAC,eAAA,GAAGC,MAAM,CAACC,MAAM,CAACJ,cAAc,CAAC;AAAC,IAEjDK,gBAAgB,GAAAJ,OAAA,CAAAI,gBAAA,0BAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAhBA,gBAAgB;EAAA,OAAhBA,gBAAgB;AAAA;AASrB,MAAMC,iBAAiB,GAAAL,OAAA,CAAAK,iBAAA,GAAGH,MAAM,CAACC,MAAM,CAACC,gBAAgB,CAAC;;AAahE;;AAMA;;AAQA;;AAMA;;AA8BO,MAAME,oBAAoB,GAAAN,OAAA,CAAAM,oBAAA,GAAG;EAClC;EACA,CAACF,gBAAgB,CAACG,IAAI,GAAGC,SAAS;EAClC;EACA,CAACJ,gBAAgB,CAACK,GAAG,GAAGC,mBAAO;EAC/B;EACA,CAACN,gBAAgB,CAACO,GAAG,GAAGC,mBAAO;EAC/B;EACA,CAACR,gBAAgB,CAACS,IAAI,GAAGC,oBAAQ;EACjC;EACA,CAACV,gBAAgB,CAACW,MAAM,GAAGC,sBAAU;EACrC;EACA,CAACZ,gBAAgB,CAACa,KAAK,GAAGC;AAC5B,CAAC;;AAOD;;AAwBA;;AAYA;;AAYA;;AAYA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Endpoint","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Endpoint2"],"sources":["../../../src/entities/Endpoint/index.ts"],"sourcesContent":["export * from './Endpoint';\nexport * from './Endpoint.types';\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Endpoint","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_Endpoint2"],"sources":["../../../src/entities/Endpoint/index.ts"],"sourcesContent":["export * from './Endpoint';\r\nexport * from './Endpoint.types';\r\n"],"mappings":";;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -14,8 +14,8 @@ var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/w
|
|
|
14
14
|
var _const = require("../../const");
|
|
15
15
|
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
16
16
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function () { return !!t; })(); }
|
|
17
|
-
/**
|
|
18
|
-
* Base error type for engine related errors
|
|
17
|
+
/**
|
|
18
|
+
* Base error type for engine related errors
|
|
19
19
|
*/
|
|
20
20
|
let EngineError = exports.EngineError = /*#__PURE__*/function (_Error) {
|
|
21
21
|
/** Create an EngineError, these errors represent errors in the engine itself */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineError.js","names":["_const","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","EngineError","exports","_Error","config","_this","_classCallCheck2","options","message","severity","error","data","hint","LogSeverity","CRITICAL","_inherits2","_createClass2","_wrapNativeSuper2","Error"],"sources":["../../../src/entities/EngineError/EngineError.ts"],"sourcesContent":["import { EngineErrorOptions } from './EngineError.types';\nimport { LogSeverity } from 'const';\n\n/**\n * Base error type for engine related errors\n */\nexport class EngineError extends Error {\n /** Severity of the log entry */\n public severity: LogSeverity;\n /** If this error is wrapping another one, this will contain the original error */\n public error?: Error;\n /** Additional contextual data for debugging */\n public data?: unknown;\n /** Human readable error message sent to the client */\n public hint?: unknown;\n\n /** Create an EngineError, these errors represent errors in the engine itself */\n public constructor(config: EngineErrorOptions | string) {\n const options: EngineErrorOptions =\n typeof config === 'string' ? { message: config } : config;\n super(options.message);\n\n this.severity = options.severity ?? LogSeverity.CRITICAL;\n this.data = options.data;\n this.error = options.error;\n this.hint = options.hint;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAoC,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAA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AAAgB,iBAAA,CAAA3B,OAAA,EApB8B4B,KAAK","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EngineError.js","names":["_const","require","_callSuper","t","o","e","_getPrototypeOf2","default","_possibleConstructorReturn2","_isNativeReflectConstruct","Reflect","construct","constructor","apply","Boolean","prototype","valueOf","call","EngineError","exports","_Error","config","_this","_classCallCheck2","options","message","severity","error","data","hint","LogSeverity","CRITICAL","_inherits2","_createClass2","_wrapNativeSuper2","Error"],"sources":["../../../src/entities/EngineError/EngineError.ts"],"sourcesContent":["import { EngineErrorOptions } from './EngineError.types';\r\nimport { LogSeverity } from 'const';\r\n\r\n/**\r\n * Base error type for engine related errors\r\n */\r\nexport class EngineError extends Error {\r\n /** Severity of the log entry */\r\n public severity: LogSeverity;\r\n /** If this error is wrapping another one, this will contain the original error */\r\n public error?: Error;\r\n /** Additional contextual data for debugging */\r\n public data?: unknown;\r\n /** Human readable error message sent to the client */\r\n public hint?: unknown;\r\n\r\n /** Create an EngineError, these errors represent errors in the engine itself */\r\n public constructor(config: EngineErrorOptions | string) {\r\n const options: EngineErrorOptions =\r\n typeof config === 'string' ? { message: config } : config;\r\n super(options.message);\r\n\r\n this.severity = options.severity ?? LogSeverity.CRITICAL;\r\n this.data = options.data;\r\n this.error = options.error;\r\n this.hint = options.hint;\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAAoC,SAAAC,WAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,WAAAD,CAAA,OAAAE,gBAAA,CAAAC,OAAA,EAAAH,CAAA,OAAAI,2BAAA,CAAAD,OAAA,EAAAJ,CAAA,EAAAM,yBAAA,KAAAC,OAAA,CAAAC,SAAA,CAAAP,CAAA,EAAAC,CAAA,YAAAC,gBAAA,CAAAC,OAAA,EAAAJ,CAAA,EAAAS,WAAA,IAAAR,CAAA,CAAAS,KAAA,CAAAV,CAAA,EAAAE,CAAA;AAAA,SAAAI,0BAAA,cAAAN,CAAA,IAAAW,OAAA,CAAAC,SAAA,CAAAC,OAAA,CAAAC,IAAA,CAAAP,OAAA,CAAAC,SAAA,CAAAG,OAAA,iCAAAX,CAAA,aAAAM,yBAAA,YAAAA,CAAA,aAAAN,CAAA;AAEpC;AACA;AACA;AAFA,IAGae,WAAW,GAAAC,OAAA,CAAAD,WAAA,0BAAAE,MAAA;EAUtB;EACA,SAAAF,YAAmBG,MAAmC,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAhB,OAAA,QAAAW,WAAA;IACtD,MAAMM,OAA2B,GAC/B,OAAOH,MAAM,KAAK,QAAQ,GAAG;MAAEI,OAAO,EAAEJ;IAAO,CAAC,GAAGA,MAAM;IAC3DC,KAAA,GAAApB,UAAA,OAAAgB,WAAA,GAAMM,OAAO,CAACC,OAAO;IAbvB;IAAAH,KAAA,CACOI,QAAQ;IACf;IAAAJ,KAAA,CACOK,KAAK;IACZ;IAAAL,KAAA,CACOM,IAAI;IACX;IAAAN,KAAA,CACOO,IAAI;IAQTP,KAAA,CAAKI,QAAQ,GAAGF,OAAO,CAACE,QAAQ,IAAII,kBAAW,CAACC,QAAQ;IACxDT,KAAA,CAAKM,IAAI,GAAGJ,OAAO,CAACI,IAAI;IACxBN,KAAA,CAAKK,KAAK,GAAGH,OAAO,CAACG,KAAK;IAC1BL,KAAA,CAAKO,IAAI,GAAGL,OAAO,CAACK,IAAI;IAAC,OAAAP,KAAA;EAC3B;EAAC,IAAAU,UAAA,CAAAzB,OAAA,EAAAW,WAAA,EAAAE,MAAA;EAAA,WAAAa,aAAA,CAAA1B,OAAA,EAAAW,WAAA;AAAA,mBAAAgB,iBAAA,CAAA3B,OAAA,EApB8B4B,KAAK","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EngineError.types.js","names":[],"sources":["../../../src/entities/EngineError/EngineError.types.ts"],"sourcesContent":["import { LogSeverity } from 'const';\n\n/** EngineError initialization options */\nexport interface EngineErrorOptions {\n /** Main logged message */\n message: string;\n /** Severity of the log entry */\n severity?: LogSeverity;\n /** If this error is wrapping another one, this will contain the original error */\n error?: Error;\n /** Additional contextual data for debugging */\n data?: unknown;\n /** Human readable error message sent to the client */\n hint?: unknown;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"EngineError.types.js","names":[],"sources":["../../../src/entities/EngineError/EngineError.types.ts"],"sourcesContent":["import { LogSeverity } from 'const';\r\n\r\n/** EngineError initialization options */\r\nexport interface EngineErrorOptions {\r\n /** Main logged message */\r\n message: string;\r\n /** Severity of the log entry */\r\n severity?: LogSeverity;\r\n /** If this error is wrapping another one, this will contain the original error */\r\n error?: Error;\r\n /** Additional contextual data for debugging */\r\n data?: unknown;\r\n /** Human readable error message sent to the client */\r\n hint?: unknown;\r\n}\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_EngineError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_EngineError2"],"sources":["../../../src/entities/EngineError/index.ts"],"sourcesContent":["export * from './EngineError';\nexport * from './EngineError.types';\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_EngineError","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_EngineError2"],"sources":["../../../src/entities/EngineError/index.ts"],"sourcesContent":["export * from './EngineError';\r\nexport * from './EngineError.types';\r\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,aAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,aAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,aAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,aAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -19,9 +19,9 @@ const namespace = 'engine:keySet';
|
|
|
19
19
|
// Number of seconds between each key refresh
|
|
20
20
|
const KEY_REFRESH_INTERVAL = 300;
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Fetch Json Web Key Sets and cache them
|
|
24
|
-
* Keys can then be used for Json Web Token authentication
|
|
22
|
+
/**
|
|
23
|
+
* Fetch Json Web Key Sets and cache them
|
|
24
|
+
* Keys can then be used for Json Web Token authentication
|
|
25
25
|
*/
|
|
26
26
|
let KeySet = exports.KeySet = /*#__PURE__*/function () {
|
|
27
27
|
/** Create a new Key Set */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeySet.js","names":["_crypto","require","_fs","_const","_EngineError","_report","_request","_tlsRequest","namespace","KEY_REFRESH_INTERVAL","KeySet","exports","url","options","_classCallCheck2","default","keySet","internal","file","pem","interval","_createClass2","key","value","init","fetch","setInterval","error","reportError","catch","shutdown","clearInterval","getKey","keyId","getKeys","reportDebug","message","data","kid","calculateKeyId","set","JSON","parse","readFileSync","keys","Array","EngineError","severity","LogSeverity","ERROR","reduce","createPublicKey","format","export","type","requestOptions","method","tlsRequest","request","Object","length","keyIds","hash","createHash","update","trim","digest"],"sources":["../../../src/entities/KeySet/KeySet.ts"],"sourcesContent":["import { createPublicKey, createHash } from 'crypto';\nimport { readFileSync } from 'fs';\nimport { Method } from 'axios';\nimport { KeySetOptions, KeySetValues, JWKS } from './KeySet.types';\nimport { LogSeverity } from 'const';\nimport { EngineError } from 'entities/EngineError';\nimport { reportDebug, reportError } from 'utils/report';\nimport { request } from 'utils/request';\nimport { tlsRequest } from 'utils/tlsRequest';\n\nconst namespace = 'engine:keySet';\n\n// Number of seconds between each key refresh\nconst KEY_REFRESH_INTERVAL = 300;\n\n/**\n * Fetch Json Web Key Sets and cache them\n * Keys can then be used for Json Web Token authentication\n */\nexport class KeySet {\n /** Latest known value for the keys in the set, indexed by the key id */\n private keySet: KeySetValues = {};\n /** URL at which the key set can be fetched */\n private url: string;\n /** This resource is located on a service inside of our private cluster */\n private internal: boolean;\n /** This URL is actually a path to a local key file encoded in PEM */\n private file: boolean;\n /** This input is actually a full PEM string representation of a key */\n private pem: boolean;\n /** Timer for the key fetching interval */\n private interval?: NodeJS.Timeout | string | number | undefined;\n\n /** Create a new Key Set */\n public constructor(url: string, options: KeySetOptions = {}) {\n this.url = url;\n this.internal = options.internal ?? false;\n this.file = options.file ?? false;\n this.pem = options.pem ?? false;\n }\n\n /** Calculate key ID from PEM string */\n private static calculateKeyId(pem: string): string {\n // We use the md5 hash of the PEM file to defined the key ID\n const hash = createHash('md5');\n hash.update(pem.trim());\n const kid = hash.digest('base64url');\n reportDebug({\n namespace,\n message: `Calculated Key ID: \"${kid}\"`,\n data: { key: pem }\n });\n return kid;\n }\n\n /** Initialize a KeySet, should be run on server startup to avoid any misconfiguration */\n public async init(): Promise<void> {\n await this.fetch();\n this.interval = setInterval(() => {\n (async (): Promise<void> => {\n try {\n await this.fetch();\n } catch (error) {\n reportError(error);\n }\n })().catch((error) => {\n reportError(error);\n });\n }, KEY_REFRESH_INTERVAL * 1000);\n }\n\n /** Clear any pending timers to avoid pending process */\n public shutdown(): void {\n if (this.interval) clearInterval(this.interval);\n }\n\n /** Get the PEM encoded version of a key by its id */\n public getKey(keyId: string): string | undefined {\n return this.keySet[keyId];\n }\n\n /** Get all the keys in the set mapped by their ID */\n public getKeys(): KeySetValues {\n return this.keySet;\n }\n\n /** Fetch the latest version of the key set */\n private async fetch(): Promise<void> {\n reportDebug({\n namespace,\n message: `Fetching JWKS`,\n data: { url: this.url }\n });\n\n if (this.pem) {\n // Read the key from the parameter directly\n reportDebug({\n namespace,\n message: 'Processing key from given PEM string'\n });\n\n const kid = KeySet.calculateKeyId(this.url);\n\n this.keySet = { [kid]: this.url };\n } else if (this.file) {\n // Read the key from a file\n reportDebug({\n namespace,\n message: `Reading key on disk at path \"${this.url}\"`\n });\n const set = JSON.parse(readFileSync(this.url, 'utf-8'));\n\n // Check that the returned data has the shape of a JWKS\n if (!(set.keys && set.keys instanceof Array))\n throw new EngineError({\n severity: LogSeverity.ERROR,\n message: 'Fetched key set is not in an appropriate format',\n data: { url: this.url, set }\n });\n\n // Create a node.crypto public key object for each key in the set\n this.keySet = set.keys.reduce(\n (set: { [x: string]: string; }, key: { kid: string | number; }) => {\n set[key.kid] = createPublicKey({ key, format: 'jwk' }).export({\n format: 'pem',\n type: 'spki'\n }) as string;\n return set;\n },\n {} as Record<string, string>\n );\n } else {\n // Fetch key by making a network request\n reportDebug({\n namespace,\n message: `Making network request to \"${this.url}\"`\n });\n\n const requestOptions = { url: this.url, method: 'get' as Method };\n // For services inside of our cluster we use the TLS authenticated request method\n const { data: set } = await (this.internal\n ? tlsRequest<JWKS>(requestOptions)\n : request<JWKS>(requestOptions));\n\n // Check that the returned data has the shape of a JWKS\n if (!(set.keys && set.keys instanceof Array))\n throw new EngineError({\n severity: LogSeverity.ERROR,\n message: 'Fetched key set is not in an appropriate format',\n data: { url: this.url, set }\n });\n\n // Create a node.crypto public key object for each key in the set\n this.keySet = set.keys.reduce(\n (set, key) => {\n set[key.kid] = createPublicKey({ key, format: 'jwk' }).export({\n format: 'pem',\n type: 'spki'\n }) as string;\n return set;\n },\n {} as Record<string, string>\n );\n }\n\n reportDebug({\n namespace,\n message: `Stored ${Object.keys(this.keySet).length} keys`,\n data: { keyIds: Object.keys(this.keySet) }\n });\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAEA,MAAMO,SAAS,GAAG,eAAe;;AAEjC;AACA,MAAMC,oBAAoB,GAAG,GAAG;;AAEhC;AACA;AACA;AACA;AAHA,IAIaC,MAAM,GAAAC,OAAA,CAAAD,MAAA;EAcjB;EACA,SAAAA,OAAmBE,GAAW,EAAEC,OAAsB,GAA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E8B,MAAM,EAAE;UAAM,CAAC,CAAC,CAACC,MAAM,CAAC;YAC5DD,MAAM,EAAE,KAAK;YACbE,IAAI,EAAE;UACR,CAAC,CAAW;UACZ,OAAOd,GAAG;QACZ,CAAC,EACD,CAAC,CACH,CAAC;MACH;MAEA,IAAAL,mBAAW,EAAC;QACV3B,SAAS;QACT4B,OAAO,EAAE,UAAUuB,MAAM,CAACf,IAAI,CAAC,IAAI,CAAC5B,MAAM,CAAC,CAAC4C,MAAM,OAAO;QACzDvB,IAAI,EAAE;UAAEwB,MAAM,EAAEF,MAAM,CAACf,IAAI,CAAC,IAAI,CAAC5B,MAAM;QAAE;MAC3C,CAAC,CAAC;IACJ;EAAC;IAAAM,GAAA;IAAAC,KAAA,EAhID,SAAegB,cAAcA,CAACpB,GAAW,EAAU;MACjD;MACA,MAAM2C,IAAI,GAAG,IAAAC,kBAAU,EAAC,KAAK,CAAC;MAC9BD,IAAI,CAACE,MAAM,CAAC7C,GAAG,CAAC8C,IAAI,CAAC,CAAC,CAAC;MACvB,MAAM3B,GAAG,GAAGwB,IAAI,CAACI,MAAM,CAAC,WAAW,CAAC;MACpC,IAAA/B,mBAAW,EAAC;QACV3B,SAAS;QACT4B,OAAO,EAAE,uBAAuBE,GAAG,GAAG;QACtCD,IAAI,EAAE;UAAEf,GAAG,EAAEH;QAAI;MACnB,CAAC,CAAC;MACF,OAAOmB,GAAG;IACZ;EAAC;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"KeySet.js","names":["_crypto","require","_fs","_const","_EngineError","_report","_request","_tlsRequest","namespace","KEY_REFRESH_INTERVAL","KeySet","exports","url","options","_classCallCheck2","default","keySet","internal","file","pem","interval","_createClass2","key","value","init","fetch","setInterval","error","reportError","catch","shutdown","clearInterval","getKey","keyId","getKeys","reportDebug","message","data","kid","calculateKeyId","set","JSON","parse","readFileSync","keys","Array","EngineError","severity","LogSeverity","ERROR","reduce","createPublicKey","format","export","type","requestOptions","method","tlsRequest","request","Object","length","keyIds","hash","createHash","update","trim","digest"],"sources":["../../../src/entities/KeySet/KeySet.ts"],"sourcesContent":["import { createPublicKey, createHash } from 'crypto';\r\nimport { readFileSync } from 'fs';\r\nimport { Method } from 'axios';\r\nimport { KeySetOptions, KeySetValues, JWKS } from './KeySet.types';\r\nimport { LogSeverity } from 'const';\r\nimport { EngineError } from 'entities/EngineError';\r\nimport { reportDebug, reportError } from 'utils/report';\r\nimport { request } from 'utils/request';\r\nimport { tlsRequest } from 'utils/tlsRequest';\r\n\r\nconst namespace = 'engine:keySet';\r\n\r\n// Number of seconds between each key refresh\r\nconst KEY_REFRESH_INTERVAL = 300;\r\n\r\n/**\r\n * Fetch Json Web Key Sets and cache them\r\n * Keys can then be used for Json Web Token authentication\r\n */\r\nexport class KeySet {\r\n /** Latest known value for the keys in the set, indexed by the key id */\r\n private keySet: KeySetValues = {};\r\n /** URL at which the key set can be fetched */\r\n private url: string;\r\n /** This resource is located on a service inside of our private cluster */\r\n private internal: boolean;\r\n /** This URL is actually a path to a local key file encoded in PEM */\r\n private file: boolean;\r\n /** This input is actually a full PEM string representation of a key */\r\n private pem: boolean;\r\n /** Timer for the key fetching interval */\r\n private interval?: NodeJS.Timeout | string | number | undefined;\r\n\r\n /** Create a new Key Set */\r\n public constructor(url: string, options: KeySetOptions = {}) {\r\n this.url = url;\r\n this.internal = options.internal ?? false;\r\n this.file = options.file ?? false;\r\n this.pem = options.pem ?? false;\r\n }\r\n\r\n /** Calculate key ID from PEM string */\r\n private static calculateKeyId(pem: string): string {\r\n // We use the md5 hash of the PEM file to defined the key ID\r\n const hash = createHash('md5');\r\n hash.update(pem.trim());\r\n const kid = hash.digest('base64url');\r\n reportDebug({\r\n namespace,\r\n message: `Calculated Key ID: \"${kid}\"`,\r\n data: { key: pem }\r\n });\r\n return kid;\r\n }\r\n\r\n /** Initialize a KeySet, should be run on server startup to avoid any misconfiguration */\r\n public async init(): Promise<void> {\r\n await this.fetch();\r\n this.interval = setInterval(() => {\r\n (async (): Promise<void> => {\r\n try {\r\n await this.fetch();\r\n } catch (error) {\r\n reportError(error);\r\n }\r\n })().catch((error) => {\r\n reportError(error);\r\n });\r\n }, KEY_REFRESH_INTERVAL * 1000);\r\n }\r\n\r\n /** Clear any pending timers to avoid pending process */\r\n public shutdown(): void {\r\n if (this.interval) clearInterval(this.interval);\r\n }\r\n\r\n /** Get the PEM encoded version of a key by its id */\r\n public getKey(keyId: string): string | undefined {\r\n return this.keySet[keyId];\r\n }\r\n\r\n /** Get all the keys in the set mapped by their ID */\r\n public getKeys(): KeySetValues {\r\n return this.keySet;\r\n }\r\n\r\n /** Fetch the latest version of the key set */\r\n private async fetch(): Promise<void> {\r\n reportDebug({\r\n namespace,\r\n message: `Fetching JWKS`,\r\n data: { url: this.url }\r\n });\r\n\r\n if (this.pem) {\r\n // Read the key from the parameter directly\r\n reportDebug({\r\n namespace,\r\n message: 'Processing key from given PEM string'\r\n });\r\n\r\n const kid = KeySet.calculateKeyId(this.url);\r\n\r\n this.keySet = { [kid]: this.url };\r\n } else if (this.file) {\r\n // Read the key from a file\r\n reportDebug({\r\n namespace,\r\n message: `Reading key on disk at path \"${this.url}\"`\r\n });\r\n const set = JSON.parse(readFileSync(this.url, 'utf-8'));\r\n\r\n // Check that the returned data has the shape of a JWKS\r\n if (!(set.keys && set.keys instanceof Array))\r\n throw new EngineError({\r\n severity: LogSeverity.ERROR,\r\n message: 'Fetched key set is not in an appropriate format',\r\n data: { url: this.url, set }\r\n });\r\n\r\n // Create a node.crypto public key object for each key in the set\r\n this.keySet = set.keys.reduce(\r\n (set: { [x: string]: string; }, key: { kid: string | number; }) => {\r\n set[key.kid] = createPublicKey({ key, format: 'jwk' }).export({\r\n format: 'pem',\r\n type: 'spki'\r\n }) as string;\r\n return set;\r\n },\r\n {} as Record<string, string>\r\n );\r\n } else {\r\n // Fetch key by making a network request\r\n reportDebug({\r\n namespace,\r\n message: `Making network request to \"${this.url}\"`\r\n });\r\n\r\n const requestOptions = { url: this.url, method: 'get' as Method };\r\n // For services inside of our cluster we use the TLS authenticated request method\r\n const { data: set } = await (this.internal\r\n ? tlsRequest<JWKS>(requestOptions)\r\n : request<JWKS>(requestOptions));\r\n\r\n // Check that the returned data has the shape of a JWKS\r\n if (!(set.keys && set.keys instanceof Array))\r\n throw new EngineError({\r\n severity: LogSeverity.ERROR,\r\n message: 'Fetched key set is not in an appropriate format',\r\n data: { url: this.url, set }\r\n });\r\n\r\n // Create a node.crypto public key object for each key in the set\r\n this.keySet = set.keys.reduce(\r\n (set, key) => {\r\n set[key.kid] = createPublicKey({ key, format: 'jwk' }).export({\r\n format: 'pem',\r\n type: 'spki'\r\n }) as string;\r\n return set;\r\n },\r\n {} as Record<string, string>\r\n );\r\n }\r\n\r\n reportDebug({\r\n namespace,\r\n message: `Stored ${Object.keys(this.keySet).length} keys`,\r\n data: { keyIds: Object.keys(this.keySet) }\r\n });\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAEA,MAAMO,SAAS,GAAG,eAAe;;AAEjC;AACA,MAAMC,oBAAoB,GAAG,GAAG;;AAEhC;AACA;AACA;AACA;AAHA,IAIaC,MAAM,GAAAC,OAAA,CAAAD,MAAA;EAcjB;EACA,SAAAA,OAAmBE,GAAW,EAAEC,OAAsB,GAAG,CAAC,CAAC,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAL,MAAA;IAd7D;IAAA,KACQM,MAAM,GAAiB,CAAC,CAAC;IACjC;IAAA,KACQJ,GAAG;IACX;IAAA,KACQK,QAAQ;IAChB;IAAA,KACQC,IAAI;IACZ;IAAA,KACQC,GAAG;IACX;IAAA,KACQC,QAAQ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AAUuB,MAAM,CAACf,IAAI,CAAC,IAAI,CAAC5B,MAAM,CAAC,CAAC4C,MAAM,OAAO;QACzDvB,IAAI,EAAE;UAAEwB,MAAM,EAAEF,MAAM,CAACf,IAAI,CAAC,IAAI,CAAC5B,MAAM;QAAE;MAC3C,CAAC,CAAC;IACJ;EAAC;IAAAM,GAAA;IAAAC,KAAA,EAhID,SAAegB,cAAcA,CAACpB,GAAW,EAAU;MACjD;MACA,MAAM2C,IAAI,GAAG,IAAAC,kBAAU,EAAC,KAAK,CAAC;MAC9BD,IAAI,CAACE,MAAM,CAAC7C,GAAG,CAAC8C,IAAI,CAAC,CAAC,CAAC;MACvB,MAAM3B,GAAG,GAAGwB,IAAI,CAACI,MAAM,CAAC,WAAW,CAAC;MACpC,IAAA/B,mBAAW,EAAC;QACV3B,SAAS;QACT4B,OAAO,EAAE,uBAAuBE,GAAG,GAAG;QACtCD,IAAI,EAAE;UAAEf,GAAG,EAAEH;QAAI;MACnB,CAAC,CAAC;MACF,OAAOmB,GAAG;IACZ;EAAC;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KeySet.types.js","names":[],"sources":["../../../src/entities/KeySet/KeySet.types.ts"],"sourcesContent":["import { JsonWebKey } from 'crypto';\n\n/** KeySet initialization options */\nexport interface KeySetOptions {\n /** This resource is located on a service inside of our private cluster */\n internal?: boolean;\n /** This URL is actually a path to a local key file encoded in PEM */\n file?: boolean;\n /** This input is actually a full PEM string representation of a key */\n pem?: boolean;\n}\n\n/** Keep a mapping ok keyId => PEM */\nexport interface KeySetValues {\n [id: string]: string;\n}\n\n/** Object holding JWK keys */\nexport interface JWKS {\n /** Key set is JWKS format */\n keys: Array<JWK>;\n}\n\n/** JWK key with custom claims */\ninterface JWK extends JsonWebKey {\n /** ID of the key */\n kid: string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"KeySet.types.js","names":[],"sources":["../../../src/entities/KeySet/KeySet.types.ts"],"sourcesContent":["import { JsonWebKey } from 'crypto';\r\n\r\n/** KeySet initialization options */\r\nexport interface KeySetOptions {\r\n /** This resource is located on a service inside of our private cluster */\r\n internal?: boolean;\r\n /** This URL is actually a path to a local key file encoded in PEM */\r\n file?: boolean;\r\n /** This input is actually a full PEM string representation of a key */\r\n pem?: boolean;\r\n}\r\n\r\n/** Keep a mapping ok keyId => PEM */\r\nexport interface KeySetValues {\r\n [id: string]: string;\r\n}\r\n\r\n/** Object holding JWK keys */\r\nexport interface JWKS {\r\n /** Key set is JWKS format */\r\n keys: Array<JWK>;\r\n}\r\n\r\n/** JWK key with custom claims */\r\ninterface JWK extends JsonWebKey {\r\n /** ID of the key */\r\n kid: string;\r\n}\r\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_KeySet","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_KeySet2"],"sources":["../../../src/entities/KeySet/index.ts"],"sourcesContent":["export * from './KeySet';\nexport * from './KeySet.types';\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_KeySet","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_KeySet2"],"sources":["../../../src/entities/KeySet/index.ts"],"sourcesContent":["export * from './KeySet';\r\nexport * from './KeySet.types';\r\n"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,QAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,QAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,QAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,QAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifecycleController.js","names":["runningInstances","exports","Set","LifecycleController","register","instance","add","shutdownRunningInstances","promises","push","shutdown","bind","Promise","all","clear"],"sources":["../../../src/entities/LifecycleController/LifecycleController.ts"],"sourcesContent":["import { LifecycleControlledInstance } from './LifecycleController.types';\n\n/** List of initialized entities */\nexport const runningInstances: Set<LifecycleControlledInstance> = new Set();\n\n/** LifecycleController is used to shutdown all the entities on server shutdown */\nexport const LifecycleController = {\n /** Add the initialized instances into the runningInstance property */\n register(instance: LifecycleControlledInstance): void {\n runningInstances.add(instance);\n },\n\n /** Shutdown all the running instances */\n async shutdownRunningInstances(): Promise<void> {\n const promises = [];\n for (const instance of runningInstances) {\n if (instance) {\n promises.push(instance.shutdown.bind(instance)());\n }\n }\n await Promise.all(promises);\n runningInstances.clear();\n }\n};\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,gBAAkD,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,GAAG,CAAC,CAAC;;AAE3E;AACO,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG;EACjC;EACAC,QAAQA,CAACC,QAAqC,EAAQ;IACpDL,gBAAgB,CAACM,GAAG,CAACD,QAAQ,CAAC;EAChC,CAAC;EAED;EACA,MAAME,wBAAwBA,CAAA,EAAkB;IAC9C,MAAMC,QAAQ,GAAG,EAAE;IACnB,KAAK,MAAMH,QAAQ,IAAIL,gBAAgB,EAAE;MACvC,IAAIK,QAAQ,EAAE;QACZG,QAAQ,CAACC,IAAI,CAACJ,QAAQ,CAACK,QAAQ,CAACC,IAAI,CAACN,QAAQ,CAAC,CAAC,CAAC,CAAC;MACnD;IACF;IACA,MAAMO,OAAO,CAACC,GAAG,CAACL,QAAQ,CAAC;IAC3BR,gBAAgB,CAACc,KAAK,CAAC,CAAC;EAC1B;AACF,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LifecycleController.js","names":["runningInstances","exports","Set","LifecycleController","register","instance","add","shutdownRunningInstances","promises","push","shutdown","bind","Promise","all","clear"],"sources":["../../../src/entities/LifecycleController/LifecycleController.ts"],"sourcesContent":["import { LifecycleControlledInstance } from './LifecycleController.types';\r\n\r\n/** List of initialized entities */\r\nexport const runningInstances: Set<LifecycleControlledInstance> = new Set();\r\n\r\n/** LifecycleController is used to shutdown all the entities on server shutdown */\r\nexport const LifecycleController = {\r\n /** Add the initialized instances into the runningInstance property */\r\n register(instance: LifecycleControlledInstance): void {\r\n runningInstances.add(instance);\r\n },\r\n\r\n /** Shutdown all the running instances */\r\n async shutdownRunningInstances(): Promise<void> {\r\n const promises = [];\r\n for (const instance of runningInstances) {\r\n if (instance) {\r\n promises.push(instance.shutdown.bind(instance)());\r\n }\r\n }\r\n await Promise.all(promises);\r\n runningInstances.clear();\r\n }\r\n};\r\n"],"mappings":";;;;;;AAEA;AACO,MAAMA,gBAAkD,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAIE,GAAG,CAAC,CAAC;;AAE3E;AACO,MAAMC,mBAAmB,GAAAF,OAAA,CAAAE,mBAAA,GAAG;EACjC;EACAC,QAAQA,CAACC,QAAqC,EAAQ;IACpDL,gBAAgB,CAACM,GAAG,CAACD,QAAQ,CAAC;EAChC,CAAC;EAED;EACA,MAAME,wBAAwBA,CAAA,EAAkB;IAC9C,MAAMC,QAAQ,GAAG,EAAE;IACnB,KAAK,MAAMH,QAAQ,IAAIL,gBAAgB,EAAE;MACvC,IAAIK,QAAQ,EAAE;QACZG,QAAQ,CAACC,IAAI,CAACJ,QAAQ,CAACK,QAAQ,CAACC,IAAI,CAACN,QAAQ,CAAC,CAAC,CAAC,CAAC;MACnD;IACF;IACA,MAAMO,OAAO,CAACC,GAAG,CAACL,QAAQ,CAAC;IAC3BR,gBAAgB,CAACc,KAAK,CAAC,CAAC;EAC1B;AACF,CAAC","ignoreList":[]}
|