raiton 0.0.2 → 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +20 -0
- package/build/bin/index.mjs +6788 -47
- package/build/raiton-1.0.0-alpha.1.tgz +0 -0
- package/package.json +21 -36
- package/source/bin/bootstrapper.ts +15 -0
- package/source/bin/cli-tools.ts +43 -0
- package/source/bin/cli.ts +12 -0
- package/source/bin/index.ts +6 -0
- package/source/commands/artifact.command.ts +28 -0
- package/source/commands/build.command.ts +31 -0
- package/source/commands/develop.command.ts +47 -0
- package/source/commands/grafts.command.ts +27 -0
- package/source/commands/start.command.ts +28 -0
- package/source/core/application.ts +115 -0
- package/source/core/artifacts/artifact.ts +109 -0
- package/source/core/artifacts/artifacts.ts +10 -0
- package/source/core/artifacts/index.ts +1 -0
- package/source/core/artifacts/runner.ts +3 -0
- package/source/core/builder.ts +138 -0
- package/source/core/bytes.util.ts +17 -0
- package/source/core/command.ts +24 -0
- package/source/core/commands.ts +44 -0
- package/source/core/config/config.ts +51 -0
- package/source/core/config/define.ts +13 -0
- package/source/core/config/index.ts +2 -0
- package/source/core/context.ts +33 -0
- package/source/core/controller/builder.ts +38 -0
- package/source/core/controller/compiler.ts +22 -0
- package/source/core/controller/index.ts +3 -0
- package/source/core/controller/metadata.ts +13 -0
- package/source/core/directories.ts +30 -0
- package/source/core/helpers/index.ts +1 -0
- package/source/core/helpers/raiton.ts +3 -0
- package/source/core/hmr.ts +106 -0
- package/source/core/hooks.ts +28 -0
- package/source/core/index.ts +13 -0
- package/source/core/injection/index.ts +1 -0
- package/source/core/injection/injection.ts +157 -0
- package/source/core/middleware/compose.ts +40 -0
- package/source/core/middleware/index.ts +2 -0
- package/source/core/middleware/pipeline.ts +27 -0
- package/source/core/plugins/index.ts +2 -0
- package/source/core/plugins/plugin.ts +8 -0
- package/source/core/plugins/scope.ts +46 -0
- package/source/core/process.util.ts +12 -0
- package/source/core/raiton.ts +21 -0
- package/source/core/router/handler.ts +59 -0
- package/source/core/router/index.ts +4 -0
- package/source/core/router/matcher.ts +51 -0
- package/source/core/router/route.ts +63 -0
- package/source/core/router/router.ts +31 -0
- package/source/core/server.ts +26 -0
- package/source/core/thread.ts +87 -0
- package/source/env.d.ts +3 -0
- package/source/requirements.ts +27 -0
- package/source/sdk/artifacts.ts +55 -0
- package/source/sdk/constants/decorators.constant.ts +7 -0
- package/source/sdk/constants/index.ts +2 -0
- package/source/sdk/constants/microservices.constant.ts +4 -0
- package/source/sdk/controllers.ts +4 -0
- package/source/sdk/data-transfer-object.ts +7 -0
- package/source/sdk/decorators/access-guard.decorator.ts +9 -0
- package/source/sdk/decorators/controllable.decorator.ts +20 -0
- package/source/sdk/decorators/index.ts +5 -0
- package/source/sdk/decorators/injection.decorator.ts +46 -0
- package/source/sdk/decorators/middleware.decorator.ts +15 -0
- package/source/sdk/decorators/parametrable.ts +24 -0
- package/source/sdk/decorators/payload.decorator.ts +77 -0
- package/source/sdk/decorators/routable.decorator.ts +48 -0
- package/source/sdk/encryption.ts +155 -0
- package/source/sdk/enums/encrypted.enum.ts +13 -0
- package/source/sdk/enums/event.message.enum.ts +4 -0
- package/{build/sdk/enums/http-parameters.enum.d.ts → source/sdk/enums/http-parameters.enum.ts} +3 -5
- package/source/sdk/enums/http.enum.ts +10 -0
- package/source/sdk/enums/index.ts +6 -0
- package/{build/sdk/enums/runtime.enum.d.ts → source/sdk/enums/runtime.enum.ts} +2 -4
- package/{build/sdk/enums/timestamp.enum.d.ts → source/sdk/enums/timestamp.enum.ts} +2 -4
- package/source/sdk/env.ts +40 -0
- package/source/sdk/index.ts +6 -0
- package/source/sdk/json.ts +55 -0
- package/source/sdk/plugins/body-parser.plugin.ts +119 -0
- package/source/sdk/plugins/index.ts +2 -0
- package/source/sdk/plugins/security/body-limit.ts +19 -0
- package/source/sdk/plugins/security/cors.ts +44 -0
- package/source/sdk/plugins/security/headers.ts +14 -0
- package/source/sdk/plugins/security/index.ts +13 -0
- package/source/sdk/plugins/security/method-guard.ts +14 -0
- package/source/sdk/plugins/security/rate-limit.ts +42 -0
- package/source/sdk/repositories.ts +14 -0
- package/source/sdk/request.ts +3 -0
- package/source/sdk/responses.ts +45 -0
- package/source/sdk/runtime/bun/server.ts +72 -0
- package/source/sdk/runtime/deno/server.ts +53 -0
- package/source/sdk/runtime/index.ts +47 -0
- package/source/sdk/runtime/node/server.ts +60 -0
- package/source/sdk/runtime/web/server.ts +57 -0
- package/{build/sdk/schemes.d.ts → source/sdk/schemes.ts} +91 -33
- package/source/sdk/services.ts +9 -0
- package/{build/sdk/throwable.d.ts → source/sdk/throwable.ts} +35 -12
- package/source/sdk/utilities/alias-path.util.ts +49 -0
- package/source/sdk/utilities/artifacts.util.ts +62 -0
- package/source/sdk/utilities/callable.util.ts +27 -0
- package/source/sdk/utilities/controller.util.ts +8 -0
- package/source/sdk/utilities/index.ts +7 -0
- package/source/sdk/utilities/json.util.ts +21 -0
- package/source/sdk/utilities/path.util.ts +19 -0
- package/source/sdk/utilities/url.ts +5 -0
- package/source/sdk/utilities/utilities.util.ts +25 -0
- package/source/types/access-guards.ts +4 -0
- package/{build/types/application.d.ts → source/types/application.ts} +23 -7
- package/source/types/artifact.ts +40 -0
- package/source/types/builder.ts +48 -0
- package/source/types/config.ts +7 -0
- package/source/types/controller.ts +34 -0
- package/source/types/contruct.ts +3 -0
- package/source/types/core.ts +28 -0
- package/source/types/data-transfer-object.ts +4 -0
- package/{build/types/directory.d.ts → source/types/directory.ts} +4 -4
- package/source/types/encryption.ts +17 -0
- package/source/types/generic.ts +3 -0
- package/{build/types/hmr.d.ts → source/types/hmr.ts} +19 -5
- package/source/types/http-responses.ts +8 -0
- package/source/types/index.ts +26 -0
- package/source/types/injection.ts +13 -0
- package/source/types/middleware.ts +18 -0
- package/source/types/parseable.ts +7 -0
- package/source/types/plugin.ts +10 -0
- package/source/types/raiton.ts +9 -0
- package/source/types/responses.ts +10 -0
- package/source/types/router.ts +11 -0
- package/source/types/runtime.ts +53 -0
- package/{build/types/scheme.d.ts → source/types/scheme.ts} +33 -8
- package/source/types/server.ts +12 -0
- package/source/types/thread.ts +31 -0
- package/source/types/utilities.ts +4 -0
- package/source/types/values.ts +3 -0
- package/.releaserc.json +0 -45
- package/build/bin/bootstrapper.d.ts +0 -5
- package/build/bin/bootstrapper.mjs +0 -46
- package/build/bin/cli.d.ts +0 -5
- package/build/bin/cli.mjs +0 -6
- package/build/bin/index.d.ts +0 -1
- package/build/chunk-3PWMRP6G.mjs +0 -16
- package/build/chunk-52JR26TI.mjs +0 -29
- package/build/chunk-5LNOA4SK.mjs +0 -16
- package/build/chunk-AUGL35CF.mjs +0 -24
- package/build/chunk-BVILWYAP.mjs +0 -14
- package/build/chunk-BYYJRCB4.mjs +0 -10
- package/build/chunk-FFRJ4AUA.mjs +0 -16
- package/build/chunk-GPJSLV3Q.mjs +0 -50
- package/build/chunk-HVFHDVAH.mjs +0 -20
- package/build/chunk-IOCHNQMF.mjs +0 -13
- package/build/chunk-JATYBWHL.mjs +0 -36
- package/build/chunk-JWNBO7XV.mjs +0 -53
- package/build/chunk-K4IQQ2KF.mjs +0 -55
- package/build/chunk-K4KLOLSO.mjs +0 -645
- package/build/chunk-M2RZZJQR.mjs +0 -27
- package/build/chunk-MLFGBJDV.mjs +0 -12
- package/build/chunk-NB62GSFI.mjs +0 -27
- package/build/chunk-O7R3NJQN.mjs +0 -19
- package/build/chunk-P3IRIFPT.mjs +0 -53
- package/build/chunk-QFSXFOEN.mjs +0 -56
- package/build/chunk-QHCQ4AUA.mjs +0 -14
- package/build/chunk-QI7OFSXB.mjs +0 -37
- package/build/chunk-RVH2YBNU.mjs +0 -111
- package/build/chunk-RXG7754R.mjs +0 -25
- package/build/chunk-S3ONGVNZ.mjs +0 -11
- package/build/chunk-SRR4467I.mjs +0 -29
- package/build/chunk-T6L55AUG.mjs +0 -32
- package/build/chunk-TOJFTPAY.mjs +0 -83
- package/build/chunk-UAPCBU3J.mjs +0 -12
- package/build/chunk-UCHBN3DV.mjs +0 -52
- package/build/chunk-UWM46HLZ.mjs +0 -18
- package/build/chunk-UZFCGVHP.mjs +0 -8
- package/build/chunk-VQINCGLQ.mjs +0 -59
- package/build/chunk-VRL4S7UF.mjs +0 -74
- package/build/chunk-WAWFDMOH.mjs +0 -72
- package/build/chunk-X3JFRRRQ.mjs +0 -45
- package/build/chunk-XFBLELHI.mjs +0 -34
- package/build/chunk-XIGE72LC.mjs +0 -34
- package/build/chunk-XW7EPAD7.mjs +0 -0
- package/build/chunk-YGIZFKLJ.mjs +0 -20
- package/build/chunk-YRVIAORI.mjs +0 -8
- package/build/chunk-YXU5W2CB.mjs +0 -12
- package/build/commands/artifact.command.d.ts +0 -14
- package/build/commands/artifact.command.mjs +0 -59
- package/build/commands/build.command.d.ts +0 -14
- package/build/commands/build.command.mjs +0 -65
- package/build/commands/develop.command.d.ts +0 -13
- package/build/commands/develop.command.mjs +0 -75
- package/build/commands/grafts.command.d.ts +0 -12
- package/build/commands/grafts.command.mjs +0 -58
- package/build/commands/start.command.d.ts +0 -12
- package/build/commands/start.command.mjs +0 -64
- package/build/core/application.d.ts +0 -27
- package/build/core/application.mjs +0 -124
- package/build/core/artifact.d.ts +0 -19
- package/build/core/artifact.mjs +0 -133
- package/build/core/builder.d.ts +0 -35
- package/build/core/builder.mjs +0 -45
- package/build/core/bytes.util.d.ts +0 -6
- package/build/core/bytes.util.mjs +0 -8
- package/build/core/command.d.ts +0 -15
- package/build/core/command.mjs +0 -6
- package/build/core/commands.d.ts +0 -13
- package/build/core/commands.mjs +0 -7
- package/build/core/config.d.ts +0 -10
- package/build/core/config.mjs +0 -7
- package/build/core/context.d.ts +0 -15
- package/build/core/context.mjs +0 -6
- package/build/core/controller/builder.d.ts +0 -10
- package/build/core/controller/builder.mjs +0 -45
- package/build/core/controller/compiler.d.ts +0 -6
- package/build/core/controller/compiler.mjs +0 -45
- package/build/core/controller/index.d.ts +0 -13
- package/build/core/controller/index.mjs +0 -50
- package/build/core/controller/metadata.d.ts +0 -10
- package/build/core/controller/metadata.mjs +0 -6
- package/build/core/directories.d.ts +0 -11
- package/build/core/directories.mjs +0 -8
- package/build/core/hmr.d.ts +0 -22
- package/build/core/hmr.mjs +0 -6
- package/build/core/hooks.d.ts +0 -12
- package/build/core/hooks.mjs +0 -6
- package/build/core/index.d.ts +0 -41
- package/build/core/index.mjs +0 -100
- package/build/core/middleware/compose.d.ts +0 -8
- package/build/core/middleware/compose.mjs +0 -6
- package/build/core/middleware/index.d.ts +0 -6
- package/build/core/middleware/index.mjs +0 -11
- package/build/core/middleware/pipeline.d.ts +0 -14
- package/build/core/middleware/pipeline.mjs +0 -7
- package/build/core/plugins/index.d.ts +0 -14
- package/build/core/plugins/index.mjs +0 -48
- package/build/core/plugins/plugin.d.ts +0 -17
- package/build/core/plugins/plugin.mjs +0 -6
- package/build/core/plugins/scope.d.ts +0 -24
- package/build/core/plugins/scope.mjs +0 -45
- package/build/core/process.util.d.ts +0 -3
- package/build/core/process.util.mjs +0 -6
- package/build/core/raiton.d.ts +0 -20
- package/build/core/raiton.mjs +0 -6
- package/build/core/router/handler.d.ts +0 -10
- package/build/core/router/handler.mjs +0 -45
- package/build/core/router/index.d.ts +0 -12
- package/build/core/router/index.mjs +0 -54
- package/build/core/router/matcher.d.ts +0 -21
- package/build/core/router/matcher.mjs +0 -6
- package/build/core/router/route.d.ts +0 -20
- package/build/core/router/route.mjs +0 -6
- package/build/core/router/router.d.ts +0 -16
- package/build/core/router/router.mjs +0 -8
- package/build/core/thread.d.ts +0 -30
- package/build/core/thread.mjs +0 -45
- package/build/env.d.d.ts +0 -2
- package/build/env.d.mjs +0 -0
- package/build/raiton-0.0.2.tgz +0 -0
- package/build/requirements.d.ts +0 -2
- package/build/requirements.mjs +0 -19
- package/build/sdk/artifacts.d.ts +0 -13
- package/build/sdk/artifacts.mjs +0 -45
- package/build/sdk/constants/decorators.constant.d.ts +0 -11
- package/build/sdk/constants/decorators.constant.mjs +0 -6
- package/build/sdk/constants/index.d.ts +0 -2
- package/build/sdk/constants/index.mjs +0 -11
- package/build/sdk/constants/microservices.constant.d.ts +0 -5
- package/build/sdk/constants/microservices.constant.mjs +0 -6
- package/build/sdk/controllers.d.ts +0 -4
- package/build/sdk/controllers.mjs +0 -6
- package/build/sdk/data-transfer-object.d.ts +0 -7
- package/build/sdk/data-transfer-object.mjs +0 -7
- package/build/sdk/decorators/access-guard.decorator.d.ts +0 -2
- package/build/sdk/decorators/access-guard.decorator.mjs +0 -0
- package/build/sdk/decorators/controllable.d.ts +0 -3
- package/build/sdk/decorators/controllable.mjs +0 -45
- package/build/sdk/decorators/controllers.decorator.d.ts +0 -2
- package/build/sdk/decorators/controllers.decorator.mjs +0 -0
- package/build/sdk/decorators/grafts.decorator.d.ts +0 -2
- package/build/sdk/decorators/grafts.decorator.mjs +0 -0
- package/build/sdk/decorators/index.d.ts +0 -3
- package/build/sdk/decorators/index.mjs +0 -75
- package/build/sdk/decorators/parameters.decorator.d.ts +0 -2
- package/build/sdk/decorators/parameters.decorator.mjs +0 -0
- package/build/sdk/decorators/parametrable.d.ts +0 -9
- package/build/sdk/decorators/parametrable.mjs +0 -57
- package/build/sdk/decorators/payload.decorator.d.ts +0 -2
- package/build/sdk/decorators/payload.decorator.mjs +0 -0
- package/build/sdk/decorators/routable.d.ts +0 -10
- package/build/sdk/decorators/routable.mjs +0 -59
- package/build/sdk/dependency-container.d.ts +0 -19
- package/build/sdk/dependency-container.mjs +0 -46
- package/build/sdk/encryption.d.ts +0 -27
- package/build/sdk/encryption.mjs +0 -141
- package/build/sdk/enums/encrypted.enum.d.ts +0 -15
- package/build/sdk/enums/encrypted.enum.mjs +0 -6
- package/build/sdk/enums/event.message.enum.d.ts +0 -6
- package/build/sdk/enums/event.message.enum.mjs +0 -6
- package/build/sdk/enums/http-parameters.enum.mjs +0 -6
- package/build/sdk/enums/http.enum.d.ts +0 -12
- package/build/sdk/enums/http.enum.mjs +0 -6
- package/build/sdk/enums/index.d.ts +0 -6
- package/build/sdk/enums/index.mjs +0 -27
- package/build/sdk/enums/runtime.enum.mjs +0 -6
- package/build/sdk/enums/timestamp.enum.mjs +0 -6
- package/build/sdk/env.d.ts +0 -6
- package/build/sdk/env.mjs +0 -74
- package/build/sdk/fastify.d.ts +0 -11
- package/build/sdk/fastify.mjs +0 -9
- package/build/sdk/grafts.d.ts +0 -15
- package/build/sdk/grafts.mjs +0 -71
- package/build/sdk/index.d.ts +0 -34
- package/build/sdk/index.mjs +0 -126
- package/build/sdk/json.d.ts +0 -17
- package/build/sdk/json.mjs +0 -87
- package/build/sdk/plugins/body-parser.plugin.d.ts +0 -17
- package/build/sdk/plugins/body-parser.plugin.mjs +0 -7
- package/build/sdk/plugins/index.d.ts +0 -17
- package/build/sdk/plugins/index.mjs +0 -48
- package/build/sdk/plugins/security/body-limit.d.ts +0 -17
- package/build/sdk/plugins/security/body-limit.mjs +0 -45
- package/build/sdk/plugins/security/cors.d.ts +0 -22
- package/build/sdk/plugins/security/cors.mjs +0 -45
- package/build/sdk/plugins/security/headers.d.ts +0 -17
- package/build/sdk/plugins/security/headers.mjs +0 -45
- package/build/sdk/plugins/security/index.d.ts +0 -25
- package/build/sdk/plugins/security/index.mjs +0 -45
- package/build/sdk/plugins/security/method-guard.d.ts +0 -17
- package/build/sdk/plugins/security/method-guard.mjs +0 -45
- package/build/sdk/plugins/security/rate-limit.d.ts +0 -21
- package/build/sdk/plugins/security/rate-limit.mjs +0 -45
- package/build/sdk/repositories.d.ts +0 -7
- package/build/sdk/repositories.mjs +0 -17
- package/build/sdk/request.d.ts +0 -4
- package/build/sdk/request.mjs +0 -6
- package/build/sdk/responses.d.ts +0 -8
- package/build/sdk/responses.mjs +0 -20
- package/build/sdk/routes.d.ts +0 -7
- package/build/sdk/routes.mjs +0 -61
- package/build/sdk/runtime/bun/server.d.ts +0 -6
- package/build/sdk/runtime/bun/server.mjs +0 -6
- package/build/sdk/runtime/deno/server.d.ts +0 -6
- package/build/sdk/runtime/deno/server.mjs +0 -6
- package/build/sdk/runtime/index.d.ts +0 -15
- package/build/sdk/runtime/index.mjs +0 -11
- package/build/sdk/runtime/node/reply.d.ts +0 -2
- package/build/sdk/runtime/node/reply.mjs +0 -0
- package/build/sdk/runtime/node/request.d.ts +0 -2
- package/build/sdk/runtime/node/request.mjs +0 -0
- package/build/sdk/runtime/node/server.d.ts +0 -6
- package/build/sdk/runtime/node/server.mjs +0 -6
- package/build/sdk/runtime/web/server.d.ts +0 -6
- package/build/sdk/runtime/web/server.mjs +0 -6
- package/build/sdk/schemes.mjs +0 -129
- package/build/sdk/services.d.ts +0 -8
- package/build/sdk/services.mjs +0 -10
- package/build/sdk/throwable.mjs +0 -14
- package/build/sdk/utilities/alias-path.util.d.ts +0 -9
- package/build/sdk/utilities/alias-path.util.mjs +0 -6
- package/build/sdk/utilities/artifacts.util.d.ts +0 -3
- package/build/sdk/utilities/artifacts.util.mjs +0 -45
- package/build/sdk/utilities/callable.util.d.ts +0 -3
- package/build/sdk/utilities/callable.util.mjs +0 -6
- package/build/sdk/utilities/controller.util.d.ts +0 -3
- package/build/sdk/utilities/controller.util.mjs +0 -6
- package/build/sdk/utilities/index.d.ts +0 -7
- package/build/sdk/utilities/index.mjs +0 -62
- package/build/sdk/utilities/json.util.d.ts +0 -3
- package/build/sdk/utilities/json.util.mjs +0 -6
- package/build/sdk/utilities/parameters-arguments.util.d.ts +0 -2
- package/build/sdk/utilities/parameters-arguments.util.mjs +0 -0
- package/build/sdk/utilities/url.d.ts +0 -3
- package/build/sdk/utilities/url.mjs +0 -7
- package/build/sdk/utilities/utilities.util.d.ts +0 -6
- package/build/sdk/utilities/utilities.util.mjs +0 -8
- package/build/types/access-guards.d.ts +0 -6
- package/build/types/access-guards.mjs +0 -0
- package/build/types/application.mjs +0 -0
- package/build/types/artifact.d.ts +0 -21
- package/build/types/artifact.mjs +0 -0
- package/build/types/builder.d.ts +0 -32
- package/build/types/builder.mjs +0 -0
- package/build/types/config.d.ts +0 -6
- package/build/types/config.mjs +0 -0
- package/build/types/controller.d.ts +0 -25
- package/build/types/controller.mjs +0 -0
- package/build/types/contruct.d.ts +0 -3
- package/build/types/contruct.mjs +0 -0
- package/build/types/core.d.ts +0 -15
- package/build/types/core.mjs +0 -0
- package/build/types/data-transfer-object.d.ts +0 -5
- package/build/types/data-transfer-object.mjs +0 -0
- package/build/types/dependency-container.d.ts +0 -20
- package/build/types/dependency-container.mjs +0 -0
- package/build/types/directory.mjs +0 -0
- package/build/types/encryption.d.ts +0 -16
- package/build/types/encryption.mjs +0 -0
- package/build/types/generic.d.ts +0 -4
- package/build/types/generic.mjs +0 -0
- package/build/types/hmr.mjs +0 -0
- package/build/types/http-responses.d.ts +0 -10
- package/build/types/http-responses.mjs +0 -0
- package/build/types/index.d.ts +0 -45
- package/build/types/index.mjs +0 -0
- package/build/types/middleware.d.ts +0 -12
- package/build/types/middleware.mjs +0 -0
- package/build/types/parameters.d.ts +0 -19
- package/build/types/parameters.mjs +0 -0
- package/build/types/parseable.d.ts +0 -5
- package/build/types/parseable.mjs +0 -0
- package/build/types/payload.d.ts +0 -6
- package/build/types/payload.mjs +0 -0
- package/build/types/plugin.d.ts +0 -20
- package/build/types/plugin.mjs +0 -0
- package/build/types/raiton.d.ts +0 -12
- package/build/types/raiton.mjs +0 -0
- package/build/types/repositories.d.ts +0 -8
- package/build/types/repositories.mjs +0 -0
- package/build/types/router.d.ts +0 -14
- package/build/types/router.mjs +0 -0
- package/build/types/runtime.d.ts +0 -37
- package/build/types/runtime.mjs +0 -0
- package/build/types/scheme.mjs +0 -0
- package/build/types/server.d.ts +0 -57
- package/build/types/server.mjs +0 -0
- package/build/types/services.d.ts +0 -8
- package/build/types/services.mjs +0 -0
- package/build/types/thread.d.ts +0 -24
- package/build/types/thread.mjs +0 -0
- package/build/types/utilities.d.ts +0 -6
- package/build/types/utilities.mjs +0 -0
- package/build/types/values.d.ts +0 -4
- package/build/types/values.mjs +0 -0
- /package/{build/chunk-4OWCGDUD.mjs → source/sdk/runtime/node/reply.ts} +0 -0
- /package/{build/chunk-DIWD7ZCJ.mjs → source/sdk/runtime/node/request.ts} +0 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {RuntimeAdapterInterface, RuntimeReplyInterface, RuntimeRequestInterface} from '@/types'
|
|
2
|
+
|
|
3
|
+
export const webRuntime: RuntimeAdapterInterface = {
|
|
4
|
+
createServer(handler) {
|
|
5
|
+
async function fetching(request: Request, handler: (req: RuntimeRequestInterface, reply: RuntimeReplyInterface) => Promise<void>): Promise<Response> {
|
|
6
|
+
let responseBody: any
|
|
7
|
+
let statusCode = 200
|
|
8
|
+
const headers = new Headers()
|
|
9
|
+
|
|
10
|
+
const runtimeReq: RuntimeRequestInterface = {
|
|
11
|
+
method: request.method,
|
|
12
|
+
url: request.url,
|
|
13
|
+
headers: request.headers,
|
|
14
|
+
body: request.body as any
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const runtimeReply: RuntimeReplyInterface = {
|
|
18
|
+
status(code) {
|
|
19
|
+
statusCode = code
|
|
20
|
+
},
|
|
21
|
+
header(name, value) {
|
|
22
|
+
headers.set(name, value)
|
|
23
|
+
},
|
|
24
|
+
send(body) {
|
|
25
|
+
responseBody = body
|
|
26
|
+
},
|
|
27
|
+
text(text: string | Buffer) {
|
|
28
|
+
responseBody = text
|
|
29
|
+
},
|
|
30
|
+
json(json: any) {
|
|
31
|
+
responseBody = JSON.stringify(json)
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await handler(runtimeReq, runtimeReply)
|
|
36
|
+
|
|
37
|
+
return new Response(
|
|
38
|
+
typeof responseBody === 'object' && !(responseBody instanceof Uint8Array)
|
|
39
|
+
? JSON.stringify(responseBody)
|
|
40
|
+
: responseBody,
|
|
41
|
+
{status: statusCode, headers}
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
async listen() {
|
|
47
|
+
console.warn('Web runtime does not support listening')
|
|
48
|
+
},
|
|
49
|
+
async close() {
|
|
50
|
+
console.warn('Web runtime does not support closing')
|
|
51
|
+
},
|
|
52
|
+
async handle(request: Request) {
|
|
53
|
+
return fetching(request, handler)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {TSchema, Static, TProperties, Type} from "@sinclair/typebox";
|
|
2
|
+
import {ISchemeConfig, ISchemeOptions, IScheme} from "@/types";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export * from "@sinclair/typebox"
|
|
6
|
+
|
|
7
|
+
export function scheme() {
|
|
8
|
+
return new Scheme({});
|
|
9
|
+
}
|
|
10
|
+
|
|
4
11
|
|
|
5
|
-
declare function scheme(): Scheme<undefined, undefined, undefined, undefined>;
|
|
6
12
|
/**
|
|
7
13
|
* A utility type for casting and inferring a type based on the provided `Schematic` generic structure.
|
|
8
14
|
* It checks if the given type `T` extends from the `Schematic` type and applies the inference logic
|
|
@@ -13,28 +19,47 @@ declare function scheme(): Scheme<undefined, undefined, undefined, undefined>;
|
|
|
13
19
|
* If `T` is an instance of `Schematic` with defined type parameters, this utility resolves to the
|
|
14
20
|
* result returned by the `Schematic.infer` method applied to `T`. Otherwise, it will resolve to `never`.
|
|
15
21
|
*/
|
|
16
|
-
type SchematicCast<T> = T extends Scheme<any, any, any, any>
|
|
22
|
+
export type SchematicCast<T> = T extends Scheme<any, any, any, any>
|
|
23
|
+
? ReturnType<typeof Scheme.infer<T>>
|
|
24
|
+
: never;
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Represents a schema configuration that can be used with type-safe operations
|
|
19
|
-
* and is compatible with
|
|
28
|
+
* and is compatible with route options.
|
|
20
29
|
*
|
|
21
30
|
* @template TBody - Optional schema type for the request body.
|
|
22
31
|
* @template TParams - Optional schema type for the route parameters.
|
|
23
32
|
* @template TQuery - Optional schema type for the query string parameters.
|
|
24
33
|
* @template TResponse - Optional schema type for the response, where each status code can have its own schema.
|
|
25
34
|
*/
|
|
26
|
-
|
|
35
|
+
export class Scheme<
|
|
36
|
+
TBody extends TSchema | undefined = undefined,
|
|
37
|
+
TParams extends TSchema | undefined = undefined,
|
|
38
|
+
TQuery extends TSchema | undefined = undefined,
|
|
39
|
+
TResponse extends Record<number, TSchema> | undefined = undefined
|
|
40
|
+
> implements IScheme<TBody, TParams, TQuery, TResponse> {
|
|
27
41
|
protected _$body?: TBody;
|
|
28
42
|
protected _$params?: TParams;
|
|
29
43
|
protected _$querystring?: TQuery;
|
|
30
44
|
protected _$response?: TResponse;
|
|
31
|
-
|
|
45
|
+
|
|
46
|
+
constructor(config: ISchemeConfig<TBody, TParams, TQuery, TResponse>) {
|
|
47
|
+
this._$body = config.body;
|
|
48
|
+
// this._$body = config.body;
|
|
49
|
+
this._$params = config.params;
|
|
50
|
+
this._$querystring = config.querystring;
|
|
51
|
+
this._$response = config.response;
|
|
52
|
+
}
|
|
53
|
+
|
|
32
54
|
/**
|
|
33
55
|
* Retrieves the current value of the $body property.
|
|
34
56
|
*
|
|
35
57
|
* @return {TBody | undefined} The value of the $body property, or undefined if it is not set.
|
|
36
58
|
*/
|
|
37
|
-
get $body(): TBody | undefined
|
|
59
|
+
get $body(): TBody | undefined {
|
|
60
|
+
return this._$body;
|
|
61
|
+
}
|
|
62
|
+
|
|
38
63
|
/**
|
|
39
64
|
* Adds or updates a key-value pair in the body object.
|
|
40
65
|
*
|
|
@@ -42,13 +67,20 @@ declare class Scheme<TBody extends TSchema | undefined = undefined, TParams exte
|
|
|
42
67
|
* @param {TProperties} value - The value to associate with the specified key.
|
|
43
68
|
* @return {this} The current instance with the updated body object.
|
|
44
69
|
*/
|
|
45
|
-
body(key: string, value: TProperties): this
|
|
70
|
+
body(key: string, value: TProperties): this {
|
|
71
|
+
this._$body = {...(this._$body || {}), [key]: value} as TBody;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
|
|
46
75
|
/**
|
|
47
76
|
* Retrieves the current value of the `$params` property.
|
|
48
77
|
*
|
|
49
78
|
* @return {TParams | undefined} The value of `$params` if set, otherwise undefined.
|
|
50
79
|
*/
|
|
51
|
-
get $params(): TParams | undefined
|
|
80
|
+
get $params(): TParams | undefined {
|
|
81
|
+
return this._$params;
|
|
82
|
+
}
|
|
83
|
+
|
|
52
84
|
/**
|
|
53
85
|
* Adds or updates a parameter with the specified key and value.
|
|
54
86
|
*
|
|
@@ -56,13 +88,20 @@ declare class Scheme<TBody extends TSchema | undefined = undefined, TParams exte
|
|
|
56
88
|
* @param {TProperties} value - The value to associate with the specified key.
|
|
57
89
|
* @return {this} The current instance with the updated parameters.
|
|
58
90
|
*/
|
|
59
|
-
params(key: string, value: TProperties): this
|
|
91
|
+
params(key: string, value: TProperties): this {
|
|
92
|
+
this._$params = {...(this._$params || {}), [key]: value} as TParams;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
|
|
60
96
|
/**
|
|
61
97
|
* Retrieves the current query string.
|
|
62
98
|
*
|
|
63
99
|
* @return {TQuery | undefined} The query string object if available, otherwise undefined.
|
|
64
100
|
*/
|
|
65
|
-
get $querystring(): TQuery | undefined
|
|
101
|
+
get $querystring(): TQuery | undefined {
|
|
102
|
+
return this._$querystring;
|
|
103
|
+
}
|
|
104
|
+
|
|
66
105
|
/**
|
|
67
106
|
* Updates the query string parameters by setting the specified key-value pair.
|
|
68
107
|
*
|
|
@@ -70,13 +109,20 @@ declare class Scheme<TBody extends TSchema | undefined = undefined, TParams exte
|
|
|
70
109
|
* @param {TProperties} value - The value associated with the specified key.
|
|
71
110
|
* @return {this} The current instance of the class for method chaining.
|
|
72
111
|
*/
|
|
73
|
-
querystring(key: string, value: TProperties): this
|
|
112
|
+
querystring(key: string, value: TProperties): this {
|
|
113
|
+
this._$querystring = {...(this._$querystring || {}), [key]: value} as TQuery;
|
|
114
|
+
return this;
|
|
115
|
+
}
|
|
116
|
+
|
|
74
117
|
/**
|
|
75
118
|
* Retrieves the current response object.
|
|
76
119
|
*
|
|
77
120
|
* @return {TResponse | undefined} The response object if available; otherwise, undefined.
|
|
78
121
|
*/
|
|
79
|
-
get $response(): TResponse | undefined
|
|
122
|
+
get $response(): TResponse | undefined {
|
|
123
|
+
return this._$response;
|
|
124
|
+
}
|
|
125
|
+
|
|
80
126
|
/**
|
|
81
127
|
* Adds or updates a response key-value pair in the internal response object.
|
|
82
128
|
*
|
|
@@ -84,13 +130,27 @@ declare class Scheme<TBody extends TSchema | undefined = undefined, TParams exte
|
|
|
84
130
|
* @param {TProperties} value - The value associated with the given key.
|
|
85
131
|
* @return {this} The current instance to allow method chaining.
|
|
86
132
|
*/
|
|
87
|
-
response(key: number, value: TProperties): this
|
|
133
|
+
response(key: number, value: TProperties): this {
|
|
134
|
+
this._$response = {...(this._$response || {}), [key]: value} as TResponse;
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
88
138
|
/**
|
|
89
139
|
* Generates a schema object for validating different parts of an HTTP request.
|
|
90
140
|
*
|
|
91
141
|
* @return {Object} An object containing the schema definitions for `body`, `params`, `querystring`, and `response`. Each property returns a corresponding schema object.
|
|
92
142
|
*/
|
|
93
|
-
schema(): ISchemeOptions<TBody, TParams, TQuery, TResponse
|
|
143
|
+
schema(): ISchemeOptions<TBody, TParams, TQuery, TResponse> {
|
|
144
|
+
const schema: ISchemeOptions<TBody, TParams, TQuery, TResponse> = {}
|
|
145
|
+
|
|
146
|
+
if (this._$body) schema.body = Type.Object(this._$body);
|
|
147
|
+
if (this._$params) schema.params = Type.Object(this._$params);
|
|
148
|
+
if (this._$querystring) schema.querystring = Type.Object(this._$querystring);
|
|
149
|
+
if (this._$response) schema.response = Type.Object(this._$response);
|
|
150
|
+
|
|
151
|
+
return schema;
|
|
152
|
+
}
|
|
153
|
+
|
|
94
154
|
/**
|
|
95
155
|
* Infers and extracts static types from a given schema object.
|
|
96
156
|
*
|
|
@@ -101,20 +161,18 @@ declare class Scheme<TBody extends TSchema | undefined = undefined, TParams exte
|
|
|
101
161
|
* - Query: The static type of the query string if defined in the schema, otherwise undefined.
|
|
102
162
|
* - Reply: The response type mappings if defined in the schema, otherwise undefined.
|
|
103
163
|
*/
|
|
104
|
-
static infer<T extends Scheme<any, any, any, any>>(schema: T)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
}
|
|
164
|
+
static infer<T extends Scheme<any, any, any, any>>(schema: T) {
|
|
165
|
+
return {
|
|
166
|
+
Body: schema._$body ? ({} as Static<NonNullable<T["$body"]>>) : undefined,
|
|
167
|
+
Params: schema._$params
|
|
168
|
+
? ({} as Static<NonNullable<T["$params"]>>)
|
|
169
|
+
: undefined,
|
|
170
|
+
Query: schema._$querystring
|
|
171
|
+
? ({} as Static<NonNullable<T["$querystring"]>>)
|
|
172
|
+
: undefined,
|
|
173
|
+
Reply: schema._$response
|
|
174
|
+
? schema._$response as ({ [K in keyof NonNullable<T["$response"]>]: Static<NonNullable<T["$response"]>[K]> })
|
|
175
|
+
: undefined,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
118
178
|
}
|
|
119
|
-
|
|
120
|
-
export { type SchematicCast, Scheme, scheme };
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {LBadge, Logger} from "@protorians/logger";
|
|
2
|
+
import {EventBus, EventBusEnum} from "@protorians/events-bus";
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Represents a throwable error that extends the built-in JavaScript Error class.
|
|
3
6
|
* The Throwable class provides utility methods for triggering different levels
|
|
@@ -7,9 +10,14 @@
|
|
|
7
10
|
* throws an exception or exits the application depending on the severity level
|
|
8
11
|
* or the provided parameters.
|
|
9
12
|
*/
|
|
10
|
-
|
|
11
|
-
protected statusCode: number
|
|
12
|
-
|
|
13
|
+
export class Throwable extends Error {
|
|
14
|
+
constructor(message: string, protected statusCode: number = 500, label?: string) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'Throwable';
|
|
17
|
+
if (label) Logger.debug(LBadge.debug(label), message);
|
|
18
|
+
EventBus.dispatch(EventBusEnum.SERVER_THROW, {error: this})
|
|
19
|
+
}
|
|
20
|
+
|
|
13
21
|
/**
|
|
14
22
|
* Dispatches a system server error event and optionally throws an error.
|
|
15
23
|
*
|
|
@@ -18,7 +26,11 @@ declare class Throwable extends Error {
|
|
|
18
26
|
* @param statusCode
|
|
19
27
|
* @return {void} This method does not return a value.
|
|
20
28
|
*/
|
|
21
|
-
static error(message: string, soft
|
|
29
|
+
static error(message: string, soft: boolean = true, statusCode: number = 500): void {
|
|
30
|
+
EventBus.dispatch(EventBusEnum.SERVER_ERROR, {message, soft})
|
|
31
|
+
if (!soft) throw new Throwable(message, statusCode, 'ERR');
|
|
32
|
+
}
|
|
33
|
+
|
|
22
34
|
/**
|
|
23
35
|
* Emits a system server warning event and optionally throws an error based on the severity of the warning.
|
|
24
36
|
*
|
|
@@ -27,15 +39,24 @@ declare class Throwable extends Error {
|
|
|
27
39
|
* @param statusCode
|
|
28
40
|
* @return {void} This method does not return a value.
|
|
29
41
|
*/
|
|
30
|
-
static warning(message: string, soft
|
|
42
|
+
static warning(message: string, soft: boolean = true, statusCode: number = 500): void {
|
|
43
|
+
EventBus.dispatch(EventBusEnum.SERVER_WARNING, {message, soft})
|
|
44
|
+
if (!soft) throw new Throwable(message, statusCode, 'WRN');
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
/**
|
|
32
48
|
* Triggers a critical system event, dispatching an alert message and terminating the process.
|
|
33
49
|
*
|
|
34
50
|
* @param {string} message - The critical error message to be dispatched with the event.
|
|
35
51
|
* @return {void} This method does not return a value as it terminates the process.
|
|
36
52
|
*/
|
|
37
|
-
static critical(message: string): void
|
|
53
|
+
static critical(message: string): void {
|
|
54
|
+
Logger.debug(LBadge.debug('CRITICAL'), message);
|
|
55
|
+
EventBus.dispatch(EventBusEnum.SERVER_CRITICAL, {message})
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
38
58
|
}
|
|
59
|
+
|
|
39
60
|
/**
|
|
40
61
|
* A function that throws an error with a provided message and a specified error type.
|
|
41
62
|
*
|
|
@@ -45,7 +66,8 @@ declare class Throwable extends Error {
|
|
|
45
66
|
* @param statusCode
|
|
46
67
|
* @returns {void}
|
|
47
68
|
*/
|
|
48
|
-
|
|
69
|
+
export const throwError = (message: string, soft: boolean = true, statusCode: number = 500): void => Throwable.error(message, soft, statusCode);
|
|
70
|
+
|
|
49
71
|
/**
|
|
50
72
|
* Function to throw an error with a specified message.
|
|
51
73
|
*
|
|
@@ -53,7 +75,8 @@ declare const throwError: (message: string, soft?: boolean, statusCode?: number)
|
|
|
53
75
|
* @param statusCode
|
|
54
76
|
* @throws {Throwable} always throw an error with the provided message.
|
|
55
77
|
*/
|
|
56
|
-
|
|
78
|
+
export const throwException = (message: string, statusCode: number = 500): void => throwError(message, false, statusCode);
|
|
79
|
+
|
|
57
80
|
/**
|
|
58
81
|
* Emits a warning with the specified message and behavior.
|
|
59
82
|
*
|
|
@@ -63,7 +86,9 @@ declare const throwException: (message: string, statusCode?: number) => void;
|
|
|
63
86
|
* @param statusCode
|
|
64
87
|
* @returns {void} This function does not return any value.
|
|
65
88
|
*/
|
|
66
|
-
|
|
89
|
+
export const throwWarning = (message: string, soft: boolean = true, statusCode: number = 500): void =>
|
|
90
|
+
Throwable.warning(message, soft, statusCode);
|
|
91
|
+
|
|
67
92
|
/**
|
|
68
93
|
* A variable representing a function that throws a critical error.
|
|
69
94
|
*
|
|
@@ -73,6 +98,4 @@ declare const throwWarning: (message: string, soft?: boolean, statusCode?: numbe
|
|
|
73
98
|
* @param {string} message - The error message describing the critical error to be thrown.
|
|
74
99
|
* @returns {Throwable} The critical throwable generated with the provided message.
|
|
75
100
|
*/
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
export { Throwable, throwCritical, throwError, throwException, throwWarning };
|
|
101
|
+
export const throwCritical = (message: string): void => Throwable.critical(message);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// import fs from "fs";
|
|
2
|
+
// import path from "path";
|
|
3
|
+
// import tsconfig from "../../../tsconfig.json";
|
|
4
|
+
//
|
|
5
|
+
// /**
|
|
6
|
+
// * Resolves the provided pathname to its corresponding alias path based on the configured TypeScript paths and output directories.
|
|
7
|
+
// *
|
|
8
|
+
// * @param {string} pathname - The input path to resolve as per the alias configurations in the TypeScript configuration.
|
|
9
|
+
// * @return {string | null} - The resolved alias path if it exists, or null if no matching alias is found.
|
|
10
|
+
// */
|
|
11
|
+
// export function aliasPath(pathname: string): string | null {
|
|
12
|
+
//
|
|
13
|
+
// const paths = (tsconfig.compilerOptions as any)?.paths ?? {};
|
|
14
|
+
// const prefix = (process.env.RAITON_NATURAL_MODE) ? "" : (tsconfig.compilerOptions?.outDir ?? "dist");
|
|
15
|
+
// // pathname = pathname.replace(/^@\/?/, prefix ? prefix + "/" : "");
|
|
16
|
+
//
|
|
17
|
+
// const baseUrl = (tsconfig.compilerOptions as any)?.baseUrl ?? ".";
|
|
18
|
+
//
|
|
19
|
+
// for (const [aliasPattern, resolvedPaths] of Object.entries(paths)) {
|
|
20
|
+
// const aliasKey = aliasPattern.replace("/*", "");
|
|
21
|
+
// const aliasValue = path.join(prefix, (resolvedPaths as string[])[0]?.replace("/*", ""));
|
|
22
|
+
//
|
|
23
|
+
// if (pathname.startsWith(aliasKey)) {
|
|
24
|
+
// const relativePath = pathname.replace(aliasKey, aliasValue);
|
|
25
|
+
// const fullPath = path.resolve(baseUrl, relativePath);
|
|
26
|
+
// const extensions = [".ts", ".js"];
|
|
27
|
+
//
|
|
28
|
+
// for (const ext of extensions)
|
|
29
|
+
// if (fs.existsSync(fullPath + ext))
|
|
30
|
+
// return fullPath + ext;
|
|
31
|
+
//
|
|
32
|
+
// if (fs.existsSync(path.join(fullPath, "index.ts")))
|
|
33
|
+
// return path.join(fullPath, "index.ts");
|
|
34
|
+
//
|
|
35
|
+
// if (fs.existsSync(path.join(fullPath, "index.js")))
|
|
36
|
+
// return path.join(fullPath, "index.js");
|
|
37
|
+
//
|
|
38
|
+
// if (fs.existsSync(path.join(fullPath, "index.mjs")))
|
|
39
|
+
// return path.join(fullPath, "index.mjs");
|
|
40
|
+
//
|
|
41
|
+
// if (fs.existsSync(path.join(fullPath, "index.cjs")))
|
|
42
|
+
// return path.join(fullPath, "index.cjs");
|
|
43
|
+
//
|
|
44
|
+
// return fullPath;
|
|
45
|
+
// }
|
|
46
|
+
// }
|
|
47
|
+
//
|
|
48
|
+
// return null;
|
|
49
|
+
// }
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import {LBadge, Logger} from "@protorians/logger";
|
|
4
|
+
import {RaitonDirectories} from "@/core";
|
|
5
|
+
import {Raiton} from "@/core/raiton";
|
|
6
|
+
import {ArtifactFactory} from "@/sdk/artifacts";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function generateArtifacts(
|
|
10
|
+
artifact: string,
|
|
11
|
+
interfaceName: string,
|
|
12
|
+
decoratorSyntax: RegExp,
|
|
13
|
+
verbose: boolean = false,
|
|
14
|
+
) {
|
|
15
|
+
const artifacts = RaitonDirectories.artifacts(Raiton.thread.builder.workdir)
|
|
16
|
+
const dir = Raiton.thread.builder.source;
|
|
17
|
+
const outputFile = path.join(artifacts, `${artifact}.d.ts`);
|
|
18
|
+
|
|
19
|
+
if (!dir) return;
|
|
20
|
+
|
|
21
|
+
const files = fs.readdirSync(dir, {recursive: true})
|
|
22
|
+
.filter(f => [`.ts`, `.js`, `.mjs`, `.cjs`,].some(ext => f.toString().endsWith(ext)))
|
|
23
|
+
.map(f => f.toString())
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
let mappings = "";
|
|
27
|
+
for (const file of files) {
|
|
28
|
+
|
|
29
|
+
const filename = path.join(dir, file);
|
|
30
|
+
const content = fs.readFileSync(filename, "utf-8");
|
|
31
|
+
const match = content.match(decoratorSyntax);
|
|
32
|
+
|
|
33
|
+
if (!match) continue;
|
|
34
|
+
|
|
35
|
+
let name = match[3] || match[1] || "";
|
|
36
|
+
if (!name) {
|
|
37
|
+
const classMatch = content.match(/export\s+default\s+class\s+([A-Za-z0-9_]+)/);
|
|
38
|
+
name = classMatch?.[1] || path.parse(filename).name;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
mappings += ` ${name}: InstanceType<typeof import("@/${file}").default>;\n`;
|
|
42
|
+
|
|
43
|
+
if (verbose) Logger.info(LBadge.debug(name), `artifact detected`);
|
|
44
|
+
ArtifactFactory.add(artifact, {
|
|
45
|
+
file,
|
|
46
|
+
dir,
|
|
47
|
+
relative: file,
|
|
48
|
+
absolute: filename
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const content = `// AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
|
|
53
|
+
declare global {
|
|
54
|
+
interface ${interfaceName} {
|
|
55
|
+
${mappings} }
|
|
56
|
+
}
|
|
57
|
+
export {};`;
|
|
58
|
+
fs.writeFileSync(outputFile, content, "utf-8");
|
|
59
|
+
if (!ArtifactFactory.save(artifact)) Logger.error(`Failed to save artifacts for ${artifact}`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {LBadge, Logger} from "@protorians/logger";
|
|
2
|
+
|
|
3
|
+
export async function retryCallable(
|
|
4
|
+
label: string,
|
|
5
|
+
callback: () => Promise<void>,
|
|
6
|
+
onFail?: (e: any) => void,
|
|
7
|
+
trying: number = 0,
|
|
8
|
+
limit: number = 7,
|
|
9
|
+
) {
|
|
10
|
+
try {
|
|
11
|
+
Logger.info(
|
|
12
|
+
LBadge.debug(label || 'Running'),
|
|
13
|
+
LBadge.info(trying),
|
|
14
|
+
LBadge.log(limit),
|
|
15
|
+
)
|
|
16
|
+
await callback()
|
|
17
|
+
} catch (e) {
|
|
18
|
+
Logger.info(
|
|
19
|
+
LBadge.debug('Trying'),
|
|
20
|
+
LBadge.info(trying),
|
|
21
|
+
LBadge.log(limit),
|
|
22
|
+
)
|
|
23
|
+
if (trying < limit)
|
|
24
|
+
setTimeout(() => retryCallable(label, callback, onFail, trying + 1, limit), 1000);
|
|
25
|
+
else onFail?.(e)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
|
|
3
|
+
export function tryParseJson<T>(obj: any): T | null {
|
|
4
|
+
try {
|
|
5
|
+
return JSON.parse(obj);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export class JsonUtil {
|
|
13
|
+
static trying = tryParseJson;
|
|
14
|
+
static parse = JSON.parse;
|
|
15
|
+
static stringify = JSON.stringify;
|
|
16
|
+
|
|
17
|
+
static import(pathname: string) {
|
|
18
|
+
const json = fs.readFileSync(pathname, "utf-8");
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
export function getDirname(importMetaUrl: string): string {
|
|
5
|
+
return path.dirname(fileURLToPath(importMetaUrl));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function getFilename(importMetaUrl: string): string {
|
|
9
|
+
return fileURLToPath(importMetaUrl);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function getPackageRoot(importMetaUrl: string): string {
|
|
13
|
+
const dirname = getDirname(importMetaUrl);
|
|
14
|
+
// On remonte jusqu'à trouver un package.json ou on remonte d'un niveau si on est dans source/bin ou build/bin
|
|
15
|
+
if (dirname.endsWith('bin')) {
|
|
16
|
+
return path.join(dirname, '..');
|
|
17
|
+
}
|
|
18
|
+
return dirname;
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {IGenericValueType} from "../../types";
|
|
2
|
+
|
|
3
|
+
export function getType(value: any): IGenericValueType {
|
|
4
|
+
if (typeof value === "string") return "string";
|
|
5
|
+
if (typeof value === "boolean") return "boolean";
|
|
6
|
+
if (typeof value === "bigint") return "bigInt";
|
|
7
|
+
if (typeof value === "number") {
|
|
8
|
+
if (Number.isInteger(value)) return "int";
|
|
9
|
+
return "float";
|
|
10
|
+
}
|
|
11
|
+
return (typeof value) as any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function stabilizeJson<T>(json: string | T | null) {
|
|
15
|
+
if (!json) return {} as T;
|
|
16
|
+
|
|
17
|
+
switch (typeof json) {
|
|
18
|
+
case 'string':
|
|
19
|
+
return JSON.parse(json);
|
|
20
|
+
case 'object':
|
|
21
|
+
return json as T;
|
|
22
|
+
default:
|
|
23
|
+
throw new Error('Invalid JSON format');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {HttpMethod} from "@/sdk";
|
|
2
2
|
|
|
3
|
-
interface ApplicationConfig {
|
|
3
|
+
export interface ApplicationConfig {
|
|
4
4
|
workdir?: string;
|
|
5
5
|
hostname?: string;
|
|
6
6
|
port?: number;
|
|
@@ -10,21 +10,37 @@ interface ApplicationConfig {
|
|
|
10
10
|
develop?: boolean;
|
|
11
11
|
verbose?: boolean;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
|
+
export interface ApplicationInterface {
|
|
14
15
|
readonly config: ApplicationConfig;
|
|
16
|
+
|
|
15
17
|
get hostname(): string;
|
|
18
|
+
|
|
19
|
+
// setOption<K extends keyof ApplicationConfig>(key: K, value: ApplicationConfig[K]): this;
|
|
20
|
+
//
|
|
21
|
+
// setOptions(options: ApplicationConfig): this;
|
|
22
|
+
|
|
16
23
|
register(plugin: any): this;
|
|
24
|
+
|
|
17
25
|
use(mw: any): this;
|
|
18
|
-
|
|
26
|
+
|
|
27
|
+
route(method: HttpMethod, path: string, handler: any, version?: string): this
|
|
28
|
+
|
|
19
29
|
get(path: string, handler: any, version?: string): this;
|
|
30
|
+
|
|
20
31
|
post(path: string, handler: any, version?: string): this;
|
|
32
|
+
|
|
21
33
|
patch(path: string, handler: any, version?: string): this;
|
|
34
|
+
|
|
22
35
|
put(path: string, handler: any, version?: string): this;
|
|
36
|
+
|
|
23
37
|
delete(path: string, handler: any, version?: string): this;
|
|
38
|
+
|
|
24
39
|
options(path: string, handler: any, version?: string): this;
|
|
40
|
+
|
|
25
41
|
head(path: string, handler: any, version?: string): this;
|
|
42
|
+
|
|
26
43
|
trace(path: string, handler: any, version?: string): this;
|
|
27
|
-
handle(req: any, reply: any): Promise<any>;
|
|
28
|
-
}
|
|
29
44
|
|
|
30
|
-
|
|
45
|
+
handle(req: any, reply: any): Promise<any>;
|
|
46
|
+
}
|