arkos 2.0.0-next.2 → 2.0.0-next.21
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/README.md +146 -145
- package/cli.js +11 -13
- package/dist/esm/app.js +17 -16
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/components/arkos-gateway/arkos-gateway.js +338 -0
- package/dist/esm/components/arkos-gateway/arkos-gateway.js.map +1 -0
- package/dist/esm/components/arkos-gateway/socket-extensions.js +168 -0
- package/dist/esm/components/arkos-gateway/socket-extensions.js.map +1 -0
- package/dist/esm/components/arkos-gateway/types.js +3 -0
- package/dist/esm/components/arkos-gateway/types.js.map +1 -0
- package/dist/esm/components/arkos-gateway/utils/helpers.js +105 -0
- package/dist/esm/components/arkos-gateway/utils/helpers.js.map +1 -0
- package/dist/esm/components/arkos-gateway/utils/memory-gateway-store.js +45 -0
- package/dist/esm/components/arkos-gateway/utils/memory-gateway-store.js.map +1 -0
- package/dist/esm/components/arkos-gateway/utils/multi-tier-arkos-gateway-store.js +40 -0
- package/dist/esm/components/arkos-gateway/utils/multi-tier-arkos-gateway-store.js.map +1 -0
- package/dist/esm/components/arkos-gateway/utils/rate-limiter.js +13 -0
- package/dist/esm/components/arkos-gateway/utils/rate-limiter.js.map +1 -0
- package/dist/esm/components/arkos-loadable-registry/index.js +1 -3
- package/dist/esm/components/arkos-loadable-registry/index.js.map +1 -1
- package/dist/esm/components/arkos-policy/index.js +3 -1
- package/dist/esm/components/arkos-policy/index.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/index.js +2 -1
- package/dist/esm/components/arkos-route-hook/index.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/reader.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/types.js.map +1 -1
- package/dist/esm/exports/error-handler/index.js +1 -0
- package/dist/esm/exports/error-handler/index.js.map +1 -1
- package/dist/esm/exports/index.js +3 -3
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/middlewares/index.js +1 -1
- package/dist/esm/exports/middlewares/index.js.map +1 -1
- package/dist/esm/exports/services/index.js +2 -2
- package/dist/esm/exports/services/index.js.map +1 -1
- package/dist/esm/exports/websockets.js +5 -0
- package/dist/esm/exports/websockets.js.map +1 -0
- package/dist/esm/generated.js.map +1 -1
- package/dist/esm/modules/auth/auth.controller.js +214 -222
- package/dist/esm/modules/auth/auth.controller.js.map +1 -1
- package/dist/esm/modules/auth/auth.router.js +26 -9
- package/dist/esm/modules/auth/auth.router.js.map +1 -1
- package/dist/esm/modules/auth/auth.service.js +90 -102
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/auth/utils/auth-error-objects.js +2 -2
- package/dist/esm/modules/auth/utils/auth-error-objects.js.map +1 -1
- package/dist/esm/modules/auth/utils/auth-hooks-manager.js +148 -0
- package/dist/esm/modules/auth/utils/auth-hooks-manager.js.map +1 -0
- package/dist/esm/modules/auth/utils/auth-openapi-generator.js +367 -0
- package/dist/esm/modules/auth/utils/auth-openapi-generator.js.map +1 -0
- package/dist/esm/modules/auth/utils/auth-prisma-json-schema-generator.js +97 -0
- package/dist/esm/modules/auth/utils/auth-prisma-json-schema-generator.js.map +1 -0
- package/dist/esm/modules/auth/utils/docs-links.js +6 -0
- package/dist/esm/modules/auth/utils/docs-links.js.map +1 -0
- package/dist/esm/modules/auth/utils/services/auth-action.service.js +20 -16
- package/dist/esm/modules/auth/utils/services/auth-action.service.js.map +1 -1
- package/dist/esm/modules/base/base.controller.js +182 -162
- package/dist/esm/modules/base/base.controller.js.map +1 -1
- package/dist/esm/modules/base/base.middlewares.js +31 -48
- package/dist/esm/modules/base/base.middlewares.js.map +1 -1
- package/dist/esm/modules/base/base.router.js +23 -9
- package/dist/esm/modules/base/base.router.js.map +1 -1
- package/dist/esm/modules/base/base.service.js +33 -138
- package/dist/esm/modules/base/base.service.js.map +1 -1
- package/dist/esm/modules/base/types/base.service.types.js.map +1 -1
- package/dist/esm/modules/base/utils/error-prettifier.js +26 -30
- package/dist/esm/modules/base/utils/error-prettifier.js.map +1 -1
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js +26 -5
- package/dist/esm/modules/base/utils/helpers/base.service.helpers.js.map +1 -1
- package/dist/esm/modules/base/utils/model-openapi-generator.js +438 -0
- package/dist/esm/modules/base/utils/model-openapi-generator.js.map +1 -0
- package/dist/esm/modules/email/email.service.js +17 -10
- package/dist/esm/modules/email/email.service.js.map +1 -1
- package/dist/esm/modules/error-handler/error-handler.controller.js +24 -113
- package/dist/esm/modules/error-handler/error-handler.controller.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/app-error.js +5 -2
- package/dist/esm/modules/error-handler/utils/app-error.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/catch-async.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +9 -103
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/errors.js +127 -0
- package/dist/esm/modules/error-handler/utils/errors.js.map +1 -0
- package/dist/esm/modules/error-handler/utils/get-handled-error.js +68 -0
- package/dist/esm/modules/error-handler/utils/get-handled-error.js.map +1 -0
- package/dist/esm/modules/error-handler/utils/multer-error-handler.js +34 -0
- package/dist/esm/modules/error-handler/utils/multer-error-handler.js.map +1 -0
- package/dist/esm/modules/file-upload/file-upload.controller.js +208 -214
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +35 -12
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.service.js +13 -8
- package/dist/esm/modules/file-upload/file-upload.service.js.map +1 -1
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js +346 -0
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js.map +1 -0
- package/dist/esm/modules/swagger/swagger.router.js +39 -22
- package/dist/esm/modules/swagger/swagger.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js +305 -0
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +6 -7
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +6 -3
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
- package/dist/esm/server.js +1 -1
- package/dist/esm/server.js.map +1 -1
- package/dist/esm/types/arkos-config/utils.js +2 -0
- package/dist/esm/types/arkos-config/utils.js.map +1 -0
- package/dist/esm/types/arkos-prisma-input.js.map +1 -1
- package/dist/esm/types/arkos.js.map +1 -1
- package/dist/esm/types/auth.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/new-arkos-config.js.map +1 -1
- package/dist/esm/types/router-config.js.map +1 -1
- package/dist/esm/types/upload.js +2 -0
- package/dist/esm/types/upload.js.map +1 -0
- package/dist/esm/types/validation/validation-manager.js +49 -0
- package/dist/esm/types/validation/validation-manager.js.map +1 -0
- package/dist/esm/types/validation/validator.js +2 -0
- package/dist/esm/types/validation/validator.js.map +1 -0
- package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js +68 -34
- package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
- package/dist/esm/utils/arkos-router/index.js +37 -130
- package/dist/esm/utils/arkos-router/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/route-config-registry.js +2 -3
- package/dist/esm/utils/arkos-router/route-config-registry.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/openapi-config.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/upload-config.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +188 -0
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -0
- package/dist/esm/utils/arkos-router/utils/helpers/index.js +88 -29
- package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js +364 -89
- package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
- package/dist/esm/utils/bundler.js +6 -6
- package/dist/esm/utils/bundler.js.map +1 -1
- package/dist/esm/utils/cli/build.js +16 -7
- package/dist/esm/utils/cli/build.js.map +1 -1
- package/dist/esm/utils/cli/dev.js +18 -28
- package/dist/esm/utils/cli/dev.js.map +1 -1
- package/dist/esm/utils/cli/export-auth-action.js +5 -4
- package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
- package/dist/esm/utils/cli/generate.js +70 -56
- package/dist/esm/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/index.js +54 -50
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/prisma-generate.js +8 -37
- package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
- package/dist/esm/utils/cli/start.js +25 -14
- package/dist/esm/utils/cli/start.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/runtime-cli-commander.js +7 -4
- package/dist/esm/utils/cli/utils/runtime-cli-commander.js.map +1 -1
- package/dist/esm/utils/cli/utils/smart-fs-watcher.js +3 -0
- package/dist/esm/utils/cli/utils/smart-fs-watcher.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +307 -11
- package/dist/esm/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js +16 -7
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-multiple-components.js +117 -65
- package/dist/esm/utils/cli/utils/template-generator/templates/generate-multiple-components.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js +6 -8
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js +13 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js +2 -2
- package/dist/esm/utils/cli/utils/template-generator/templates/service-template.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js +213 -19
- package/dist/esm/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +1 -1
- package/dist/esm/utils/cli/utils/template-generators.js +31 -18
- package/dist/esm/utils/cli/utils/template-generators.js.map +1 -1
- package/dist/esm/utils/define-config.js +14 -0
- package/dist/esm/utils/define-config.js.map +1 -1
- package/dist/esm/utils/docs-links.js +2 -0
- package/dist/esm/utils/docs-links.js.map +1 -0
- package/dist/esm/utils/dotenv.helpers.js +0 -6
- package/dist/esm/utils/dotenv.helpers.js.map +1 -1
- package/dist/esm/utils/dynamic-loader.js +2 -1
- package/dist/esm/utils/dynamic-loader.js.map +1 -1
- package/dist/esm/utils/features/api.features.js +46 -27
- package/dist/esm/utils/features/api.features.js.map +1 -1
- package/dist/esm/utils/features/port-and-host-allocator.js +4 -3
- package/dist/esm/utils/features/port-and-host-allocator.js.map +1 -1
- package/dist/esm/utils/helpers/api.features.helpers.js +20 -0
- package/dist/esm/utils/helpers/api.features.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/arkos-config.helpers.js +20 -2
- package/dist/esm/utils/helpers/arkos-config.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/exit-error.js +1 -0
- package/dist/esm/utils/helpers/exit-error.js.map +1 -1
- package/dist/esm/utils/helpers/fs.helpers.js +26 -33
- package/dist/esm/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/global.helpers.js +1 -1
- package/dist/esm/utils/helpers/global.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/prisma.helpers.js +10 -7
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/query-parser.helpers.js +7 -22
- package/dist/esm/utils/helpers/query-parser.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/routers.helpers.js +2 -2
- package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/url-helpers.js +11 -0
- package/dist/esm/utils/helpers/url-helpers.js.map +1 -0
- package/dist/esm/utils/initialize-app.js +41 -17
- package/dist/esm/utils/initialize-app.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js +154 -226
- package/dist/esm/utils/prisma/prisma-json-schema-generator.js.map +1 -1
- package/dist/esm/utils/prisma/prisma-schema-parser.js +37 -11
- package/dist/esm/utils/prisma/prisma-schema-parser.js.map +1 -1
- package/dist/esm/utils/prisma/types.js.map +1 -1
- package/dist/esm/utils/remove-dir.js +1 -1
- package/dist/esm/utils/remove-dir.js.map +1 -1
- package/dist/esm/utils/setup-app.js +59 -42
- package/dist/esm/utils/setup-app.js.map +1 -1
- package/dist/esm/utils/validate-schema.js +23 -21
- package/dist/esm/utils/validate-schema.js.map +1 -1
- package/dist/types/app.d.ts +10 -7
- package/dist/types/components/arkos-gateway/arkos-gateway.d.ts +121 -0
- package/dist/types/components/arkos-gateway/socket-extensions.d.ts +79 -0
- package/dist/types/components/arkos-gateway/types.d.ts +364 -0
- package/dist/types/components/arkos-gateway/utils/helpers.d.ts +9 -0
- package/dist/types/components/arkos-gateway/utils/memory-gateway-store.d.ts +14 -0
- package/dist/types/components/arkos-gateway/utils/multi-tier-arkos-gateway-store.d.ts +20 -0
- package/dist/types/components/arkos-gateway/utils/rate-limiter.d.ts +11 -0
- package/dist/types/components/arkos-route-hook/index.d.ts +11 -5
- package/dist/types/components/arkos-route-hook/reader.d.ts +4 -7
- package/dist/types/components/arkos-route-hook/types.d.ts +9 -5
- package/dist/types/exports/error-handler/index.d.ts +1 -0
- package/dist/types/exports/index.d.ts +5 -5
- package/dist/types/exports/middlewares/index.d.ts +1 -1
- package/dist/types/exports/services/index.d.ts +3 -3
- package/dist/types/exports/websockets.d.ts +5 -0
- package/dist/types/modules/auth/auth.service.d.ts +80 -51
- package/dist/types/modules/auth/utils/auth-hooks-manager.d.ts +63 -0
- package/dist/types/modules/auth/utils/auth-openapi-generator.d.ts +9 -0
- package/dist/types/modules/auth/utils/auth-prisma-json-schema-generator.d.ts +13 -0
- package/dist/types/modules/auth/utils/docs-links.d.ts +3 -0
- package/dist/types/modules/auth/utils/services/auth-action.service.d.ts +2 -2
- package/dist/types/modules/base/base.controller.d.ts +4 -4
- package/dist/types/modules/base/base.middlewares.d.ts +1 -7
- package/dist/types/modules/base/base.service.d.ts +8 -17
- package/dist/types/modules/base/types/base.service.types.d.ts +11 -0
- package/dist/types/modules/base/utils/helpers/base.service.helpers.d.ts +1 -1
- package/dist/types/modules/base/utils/model-openapi-generator.d.ts +12 -0
- package/dist/types/modules/email/email.service.d.ts +1 -1
- package/dist/types/modules/error-handler/utils/app-error.d.ts +0 -2
- package/dist/types/modules/error-handler/utils/catch-async.d.ts +2 -2
- package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +1 -27
- package/dist/types/modules/error-handler/utils/errors.d.ts +176 -0
- package/dist/types/modules/error-handler/utils/get-handled-error.d.ts +1 -0
- package/dist/types/modules/error-handler/utils/multer-error-handler.d.ts +7 -0
- package/dist/types/modules/file-upload/file-upload.controller.d.ts +7 -2
- package/dist/types/modules/file-upload/utils/file-upload-json-schema-generator.d.ts +12 -0
- package/dist/types/modules/swagger/swagger.router.d.ts +1 -2
- package/dist/types/modules/swagger/utils/get-open-api-login-html.d.ts +1 -0
- package/dist/types/modules/swagger/utils/helpers/get-swagger-default-configs.d.ts +48 -3
- package/dist/types/modules/swagger/utils/helpers/openapi-schema-converter.d.ts +6 -1
- package/dist/types/types/arkos-config/utils.d.ts +68 -0
- package/dist/types/types/arkos-prisma-input.d.ts +4 -3
- package/dist/types/types/arkos.d.ts +5 -15
- package/dist/types/types/auth.d.ts +4 -4
- package/dist/types/types/index.d.ts +10 -58
- package/dist/types/types/new-arkos-config.d.ts +326 -36
- package/dist/types/types/router-config.d.ts +0 -63
- package/dist/types/types/upload.d.ts +10 -0
- package/dist/types/types/validation/validation-manager.d.ts +27 -0
- package/dist/types/types/validation/validator.d.ts +2 -0
- package/dist/types/utils/arkos-router/arkos-router-openapi-manager.d.ts +14 -1
- package/dist/types/utils/arkos-router/index.d.ts +83 -8
- package/dist/types/utils/arkos-router/types/index.d.ts +74 -23
- package/dist/types/utils/arkos-router/types/openapi-config.d.ts +3 -2
- package/dist/types/utils/arkos-router/types/upload-config.d.ts +65 -8
- package/dist/types/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.d.ts +6 -0
- package/dist/types/utils/arkos-router/utils/helpers/index.d.ts +4 -6
- package/dist/types/utils/arkos-router/utils/helpers/upload-manager.d.ts +1 -36
- package/dist/types/utils/bundler.d.ts +1 -1
- package/dist/types/utils/cli/build.d.ts +1 -1
- package/dist/types/utils/cli/generate.d.ts +15 -6
- package/dist/types/utils/cli/start.d.ts +3 -1
- package/dist/types/utils/cli/utils/template-generator/templates/class-validator-dto-generator.d.ts +11 -0
- package/dist/types/utils/cli/utils/template-generator/templates/zod-schema-generator.d.ts +4 -0
- package/dist/types/utils/define-config.d.ts +1 -1
- package/dist/types/utils/docs-links.d.ts +1 -0
- package/dist/types/utils/dynamic-loader.d.ts +2 -2
- package/dist/types/utils/features/api.features.d.ts +1 -2
- package/dist/types/utils/helpers/arkos-config.helpers.d.ts +7 -0
- package/dist/types/utils/helpers/fs.helpers.d.ts +1 -16
- package/dist/types/utils/helpers/global.helpers.d.ts +1 -0
- package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -1
- package/dist/types/utils/helpers/query-parser.helpers.d.ts +1 -1
- package/dist/types/utils/helpers/url-helpers.d.ts +1 -0
- package/dist/types/utils/initialize-app.d.ts +1 -0
- package/dist/types/utils/prisma/prisma-json-schema-generator.d.ts +12 -30
- package/dist/types/utils/prisma/prisma-schema-parser.d.ts +4 -0
- package/dist/types/utils/prisma/types.d.ts +3 -2
- package/package.json +117 -84
- package/dist/cjs/app.js +0 -79
- package/dist/cjs/app.js.map +0 -1
- package/dist/cjs/components/arkos-loadable-registry/index.js +0 -28
- package/dist/cjs/components/arkos-loadable-registry/index.js.map +0 -1
- package/dist/cjs/components/arkos-loadable-translator/index.js +0 -144
- package/dist/cjs/components/arkos-loadable-translator/index.js.map +0 -1
- package/dist/cjs/components/arkos-policy/index.js +0 -36
- package/dist/cjs/components/arkos-policy/index.js.map +0 -1
- package/dist/cjs/components/arkos-policy/types.js +0 -3
- package/dist/cjs/components/arkos-policy/types.js.map +0 -1
- package/dist/cjs/components/arkos-route-hook/index.js +0 -50
- package/dist/cjs/components/arkos-route-hook/index.js.map +0 -1
- package/dist/cjs/components/arkos-route-hook/reader.js +0 -47
- package/dist/cjs/components/arkos-route-hook/reader.js.map +0 -1
- package/dist/cjs/components/arkos-route-hook/types.js +0 -3
- package/dist/cjs/components/arkos-route-hook/types.js.map +0 -1
- package/dist/cjs/components/arkos-service-hook/index.js +0 -35
- package/dist/cjs/components/arkos-service-hook/index.js.map +0 -1
- package/dist/cjs/components/arkos-service-hook/reader.js +0 -30
- package/dist/cjs/components/arkos-service-hook/reader.js.map +0 -1
- package/dist/cjs/components/arkos-service-hook/types.js +0 -3
- package/dist/cjs/components/arkos-service-hook/types.js.map +0 -1
- package/dist/cjs/exports/auth/index.js +0 -6
- package/dist/cjs/exports/auth/index.js.map +0 -1
- package/dist/cjs/exports/config.js +0 -6
- package/dist/cjs/exports/config.js.map +0 -1
- package/dist/cjs/exports/controllers/index.js +0 -42
- package/dist/cjs/exports/controllers/index.js.map +0 -1
- package/dist/cjs/exports/error-handler/index.js +0 -11
- package/dist/cjs/exports/error-handler/index.js.map +0 -1
- package/dist/cjs/exports/index.js +0 -23
- package/dist/cjs/exports/index.js.map +0 -1
- package/dist/cjs/exports/middlewares/index.js +0 -7
- package/dist/cjs/exports/middlewares/index.js.map +0 -1
- package/dist/cjs/exports/prisma/index.js +0 -13
- package/dist/cjs/exports/prisma/index.js.map +0 -1
- package/dist/cjs/exports/services/index.js +0 -53
- package/dist/cjs/exports/services/index.js.map +0 -1
- package/dist/cjs/exports/utils/index.js +0 -26
- package/dist/cjs/exports/utils/index.js.map +0 -1
- package/dist/cjs/exports/validation/index.js +0 -11
- package/dist/cjs/exports/validation/index.js.map +0 -1
- package/dist/cjs/generated.js +0 -7
- package/dist/cjs/generated.js.map +0 -1
- package/dist/cjs/modules/auth/auth.controller.js +0 -254
- package/dist/cjs/modules/auth/auth.controller.js.map +0 -1
- package/dist/cjs/modules/auth/auth.router.js +0 -113
- package/dist/cjs/modules/auth/auth.router.js.map +0 -1
- package/dist/cjs/modules/auth/auth.service.js +0 -277
- package/dist/cjs/modules/auth/auth.service.js.map +0 -1
- package/dist/cjs/modules/auth/utils/auth-error-objects.js +0 -10
- package/dist/cjs/modules/auth/utils/auth-error-objects.js.map +0 -1
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +0 -83
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js.map +0 -1
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js +0 -150
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js.map +0 -1
- package/dist/cjs/modules/base/base.controller.js +0 -275
- package/dist/cjs/modules/base/base.controller.js.map +0 -1
- package/dist/cjs/modules/base/base.middlewares.js +0 -231
- package/dist/cjs/modules/base/base.middlewares.js.map +0 -1
- package/dist/cjs/modules/base/base.router.js +0 -112
- package/dist/cjs/modules/base/base.router.js.map +0 -1
- package/dist/cjs/modules/base/base.service.js +0 -432
- package/dist/cjs/modules/base/base.service.js.map +0 -1
- package/dist/cjs/modules/base/types/base.service.types.js +0 -3
- package/dist/cjs/modules/base/types/base.service.types.js.map +0 -1
- package/dist/cjs/modules/base/utils/error-prettifier.js +0 -188
- package/dist/cjs/modules/base/utils/error-prettifier.js.map +0 -1
- package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js +0 -49
- package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js.map +0 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +0 -13
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +0 -222
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js.map +0 -1
- package/dist/cjs/modules/base/utils/router-validator.js +0 -13
- package/dist/cjs/modules/base/utils/router-validator.js.map +0 -1
- package/dist/cjs/modules/base/utils/service-hooks-manager.js +0 -19
- package/dist/cjs/modules/base/utils/service-hooks-manager.js.map +0 -1
- package/dist/cjs/modules/debugger/debugger.service.js +0 -59
- package/dist/cjs/modules/debugger/debugger.service.js.map +0 -1
- package/dist/cjs/modules/email/email.service.js +0 -106
- package/dist/cjs/modules/email/email.service.js.map +0 -1
- package/dist/cjs/modules/error-handler/error-handler.controller.js +0 -192
- package/dist/cjs/modules/error-handler/error-handler.controller.js.map +0 -1
- package/dist/cjs/modules/error-handler/utils/app-error.js +0 -28
- package/dist/cjs/modules/error-handler/utils/app-error.js.map +0 -1
- package/dist/cjs/modules/error-handler/utils/catch-async.js +0 -21
- package/dist/cjs/modules/error-handler/utils/catch-async.js.map +0 -1
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +0 -218
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js.map +0 -1
- package/dist/cjs/modules/file-upload/file-upload.controller.js +0 -256
- package/dist/cjs/modules/file-upload/file-upload.controller.js.map +0 -1
- package/dist/cjs/modules/file-upload/file-upload.router.js +0 -80
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +0 -1
- package/dist/cjs/modules/file-upload/file-upload.service.js +0 -343
- package/dist/cjs/modules/file-upload/file-upload.service.js.map +0 -1
- package/dist/cjs/modules/file-upload/utils/helpers/file-extensions.js +0 -134
- package/dist/cjs/modules/file-upload/utils/helpers/file-extensions.js.map +0 -1
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +0 -100
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js.map +0 -1
- package/dist/cjs/modules/swagger/swagger.router.js +0 -65
- package/dist/cjs/modules/swagger/swagger.router.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js +0 -7
- package/dist/cjs/modules/swagger/utils/built-in-route-path-object-manager.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js +0 -53
- package/dist/cjs/modules/swagger/utils/helpers/class-validator-to-json-schema.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -473
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +0 -491
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +0 -73
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -37
- package/dist/cjs/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -61
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -31
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +0 -49
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +0 -39
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +0 -468
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +0 -260
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +0 -331
- package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js.map +0 -1
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -109
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/server.js +0 -60
- package/dist/cjs/server.js.map +0 -1
- package/dist/cjs/types/arkos-prisma-input.js +0 -3
- package/dist/cjs/types/arkos-prisma-input.js.map +0 -1
- package/dist/cjs/types/arkos.js +0 -3
- package/dist/cjs/types/arkos.js.map +0 -1
- package/dist/cjs/types/auth.js +0 -3
- package/dist/cjs/types/auth.js.map +0 -1
- package/dist/cjs/types/index.js +0 -3
- package/dist/cjs/types/index.js.map +0 -1
- package/dist/cjs/types/new-arkos-config.js +0 -3
- package/dist/cjs/types/new-arkos-config.js.map +0 -1
- package/dist/cjs/types/router-config.js +0 -3
- package/dist/cjs/types/router-config.js.map +0 -1
- package/dist/cjs/utils/arkos-env.js +0 -9
- package/dist/cjs/utils/arkos-env.js.map +0 -1
- package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js +0 -126
- package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js.map +0 -1
- package/dist/cjs/utils/arkos-router/index.js +0 -253
- package/dist/cjs/utils/arkos-router/index.js.map +0 -1
- package/dist/cjs/utils/arkos-router/route-config-registry.js +0 -16
- package/dist/cjs/utils/arkos-router/route-config-registry.js.map +0 -1
- package/dist/cjs/utils/arkos-router/route-config-validator.js +0 -56
- package/dist/cjs/utils/arkos-router/route-config-validator.js.map +0 -1
- package/dist/cjs/utils/arkos-router/types/body-parser-config.js +0 -3
- package/dist/cjs/utils/arkos-router/types/body-parser-config.js.map +0 -1
- package/dist/cjs/utils/arkos-router/types/index.js +0 -3
- package/dist/cjs/utils/arkos-router/types/index.js.map +0 -1
- package/dist/cjs/utils/arkos-router/types/openapi-config.js +0 -3
- package/dist/cjs/utils/arkos-router/types/openapi-config.js.map +0 -1
- package/dist/cjs/utils/arkos-router/types/upload-config.js +0 -3
- package/dist/cjs/utils/arkos-router/types/upload-config.js.map +0 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js +0 -163
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js.map +0 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js +0 -283
- package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js.map +0 -1
- package/dist/cjs/utils/bundler.js +0 -163
- package/dist/cjs/utils/bundler.js.map +0 -1
- package/dist/cjs/utils/cli/build.js +0 -199
- package/dist/cjs/utils/cli/build.js.map +0 -1
- package/dist/cjs/utils/cli/dev.js +0 -128
- package/dist/cjs/utils/cli/dev.js.map +0 -1
- package/dist/cjs/utils/cli/export-auth-action.js +0 -79
- package/dist/cjs/utils/cli/export-auth-action.js.map +0 -1
- package/dist/cjs/utils/cli/generate.js +0 -229
- package/dist/cjs/utils/cli/generate.js.map +0 -1
- package/dist/cjs/utils/cli/index.js +0 -191
- package/dist/cjs/utils/cli/index.js.map +0 -1
- package/dist/cjs/utils/cli/prisma-generate.js +0 -112
- package/dist/cjs/utils/cli/prisma-generate.js.map +0 -1
- package/dist/cjs/utils/cli/start.js +0 -72
- package/dist/cjs/utils/cli/start.js.map +0 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +0 -24
- package/dist/cjs/utils/cli/utils/cli.helpers.js.map +0 -1
- package/dist/cjs/utils/cli/utils/runtime-cli-commander.js +0 -115
- package/dist/cjs/utils/cli/utils/runtime-cli-commander.js.map +0 -1
- package/dist/cjs/utils/cli/utils/smart-fs-watcher.js +0 -73
- package/dist/cjs/utils/cli/utils/smart-fs-watcher.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +0 -550
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js +0 -52
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-controller-template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-multiple-components.js +0 -139
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-multiple-components.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js +0 -53
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/route-hook.template.js +0 -39
- package/dist/cjs/utils/cli/utils/template-generator/templates/route-hook.template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +0 -19
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/service-hook.template.js +0 -32
- package/dist/cjs/utils/cli/utils/template-generator/templates/service-hook.template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js +0 -50
- package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js +0 -351
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js.map +0 -1
- package/dist/cjs/utils/cli/utils/template-generators.js +0 -52
- package/dist/cjs/utils/cli/utils/template-generators.js.map +0 -1
- package/dist/cjs/utils/cli/utils/watermark-stamper.js +0 -26
- package/dist/cjs/utils/cli/utils/watermark-stamper.js.map +0 -1
- package/dist/cjs/utils/define-config.js +0 -46
- package/dist/cjs/utils/define-config.js.map +0 -1
- package/dist/cjs/utils/dotenv.helpers.js +0 -52
- package/dist/cjs/utils/dotenv.helpers.js.map +0 -1
- package/dist/cjs/utils/dynamic-loader.js +0 -22
- package/dist/cjs/utils/dynamic-loader.js.map +0 -1
- package/dist/cjs/utils/expand-env.js +0 -72
- package/dist/cjs/utils/expand-env.js.map +0 -1
- package/dist/cjs/utils/features/api.features.js +0 -201
- package/dist/cjs/utils/features/api.features.js.map +0 -1
- package/dist/cjs/utils/features/port-and-host-allocator.js +0 -129
- package/dist/cjs/utils/features/port-and-host-allocator.js.map +0 -1
- package/dist/cjs/utils/helpers/api.features.helpers.js +0 -327
- package/dist/cjs/utils/helpers/api.features.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/arkos-config.helpers.js +0 -86
- package/dist/cjs/utils/helpers/arkos-config.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/change-case.helpers.js +0 -177
- package/dist/cjs/utils/helpers/change-case.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/deepmerge.helper.js +0 -115
- package/dist/cjs/utils/helpers/deepmerge.helper.js.map +0 -1
- package/dist/cjs/utils/helpers/exit-error.js +0 -12
- package/dist/cjs/utils/helpers/exit-error.js.map +0 -1
- package/dist/cjs/utils/helpers/fs.helpers.js +0 -60
- package/dist/cjs/utils/helpers/fs.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/global.helpers.js +0 -105
- package/dist/cjs/utils/helpers/global.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +0 -53
- package/dist/cjs/utils/helpers/prisma.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/query-parser.helpers.js +0 -69
- package/dist/cjs/utils/helpers/query-parser.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/routers.helpers.js +0 -36
- package/dist/cjs/utils/helpers/routers.helpers.js.map +0 -1
- package/dist/cjs/utils/helpers/text.helpers.js +0 -28
- package/dist/cjs/utils/helpers/text.helpers.js.map +0 -1
- package/dist/cjs/utils/initialize-app.js +0 -55
- package/dist/cjs/utils/initialize-app.js.map +0 -1
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +0 -437
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js.map +0 -1
- package/dist/cjs/utils/prisma/prisma-schema-parser.js +0 -360
- package/dist/cjs/utils/prisma/prisma-schema-parser.js.map +0 -1
- package/dist/cjs/utils/prisma/types.js +0 -3
- package/dist/cjs/utils/prisma/types.js.map +0 -1
- package/dist/cjs/utils/remove-dir.js +0 -14
- package/dist/cjs/utils/remove-dir.js.map +0 -1
- package/dist/cjs/utils/setup-app.js +0 -119
- package/dist/cjs/utils/setup-app.js.map +0 -1
- package/dist/cjs/utils/sheu.js +0 -131
- package/dist/cjs/utils/sheu.js.map +0 -1
- package/dist/cjs/utils/validate-dto.js +0 -19
- package/dist/cjs/utils/validate-dto.js.map +0 -1
- package/dist/cjs/utils/validate-schema.js +0 -75
- package/dist/cjs/utils/validate-schema.js.map +0 -1
- package/dist/esm/components/arkos-loadable-translator/index.js +0 -138
- package/dist/esm/components/arkos-loadable-translator/index.js.map +0 -1
- package/dist/esm/components/arkos-service-hook/index.js +0 -32
- package/dist/esm/components/arkos-service-hook/index.js.map +0 -1
- package/dist/esm/components/arkos-service-hook/reader.js +0 -24
- package/dist/esm/components/arkos-service-hook/reader.js.map +0 -1
- package/dist/esm/components/arkos-service-hook/types.js +0 -2
- package/dist/esm/components/arkos-service-hook/types.js.map +0 -1
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js +0 -10
- package/dist/esm/modules/base/utils/helpers/base.router.helpers.js.map +0 -1
- package/dist/esm/modules/base/utils/service-hooks-manager.js +0 -17
- package/dist/esm/modules/base/utils/service-hooks-manager.js.map +0 -1
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js +0 -5
- package/dist/esm/modules/swagger/utils/built-in-route-path-object-manager.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +0 -469
- package/dist/esm/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +0 -485
- package/dist/esm/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js +0 -34
- package/dist/esm/modules/swagger/utils/helpers/get-system-json-schema-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +0 -55
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +0 -25
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js +0 -46
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +0 -33
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +0 -462
- package/dist/esm/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js +0 -255
- package/dist/esm/modules/swagger/utils/helpers/missing-json-schemas-generator.js.map +0 -1
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js +0 -98
- package/dist/esm/modules/swagger/utils/helpers/swagger.router.helpers.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/route-hook.template.js +0 -36
- package/dist/esm/utils/cli/utils/template-generator/templates/route-hook.template.js.map +0 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/service-hook.template.js +0 -29
- package/dist/esm/utils/cli/utils/template-generator/templates/service-hook.template.js.map +0 -1
- package/dist/types/components/arkos-loadable-translator/index.d.ts +0 -53
- package/dist/types/components/arkos-service-hook/index.d.ts +0 -41
- package/dist/types/components/arkos-service-hook/reader.d.ts +0 -35
- package/dist/types/components/arkos-service-hook/types.d.ts +0 -240
- package/dist/types/modules/base/utils/helpers/base.router.helpers.d.ts +0 -3
- package/dist/types/modules/base/utils/service-hooks-manager.d.ts +0 -10
- package/dist/types/modules/swagger/utils/built-in-route-path-object-manager.d.ts +0 -4
- package/dist/types/modules/swagger/utils/helpers/get-authentication-json-schema-paths.d.ts +0 -5
- package/dist/types/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.d.ts +0 -3
- package/dist/types/modules/swagger/utils/helpers/get-system-json-schema-paths.d.ts +0 -2
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-system-json-schemas.d.ts +0 -4
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.d.ts +0 -1
- package/dist/types/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.d.ts +0 -2
- package/dist/types/modules/swagger/utils/helpers/missing-json-schemas-generator.d.ts +0 -76
- package/dist/types/modules/swagger/utils/helpers/swagger.router.helpers.d.ts +0 -19
- package/dist/types/utils/cli/utils/template-generator/templates/route-hook.template.d.ts +0 -2
- package/dist/types/utils/cli/utils/template-generator/templates/service-hook.template.d.ts +0 -2
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.removeApiAction = removeApiAction;
|
|
7
|
-
exports.isPrismaRelationFormat = isPrismaRelationFormat;
|
|
8
|
-
exports.throwErrorIfApiActionIsInvalid = throwErrorIfApiActionIsInvalid;
|
|
9
|
-
exports.handleRelationFieldsInBody = handleRelationFieldsInBody;
|
|
10
|
-
exports.canBeUsedToConnect = canBeUsedToConnect;
|
|
11
|
-
const prisma_schema_parser_1 = __importDefault(require("../../../../utils/prisma/prisma-schema-parser.js"));
|
|
12
|
-
const app_error_1 = __importDefault(require("../../../error-handler/utils/app-error.js"));
|
|
13
|
-
function removeApiAction(obj) {
|
|
14
|
-
if (!obj || typeof obj !== "object")
|
|
15
|
-
return obj;
|
|
16
|
-
const result = {};
|
|
17
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
18
|
-
if (key === "apiAction")
|
|
19
|
-
continue;
|
|
20
|
-
if (Array.isArray(value)) {
|
|
21
|
-
result[key] = value.map((item) => typeof item === "object" && item !== null ? removeApiAction(item) : item);
|
|
22
|
-
}
|
|
23
|
-
else if (typeof value === "object" && value !== null) {
|
|
24
|
-
result[key] = removeApiAction(value);
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
result[key] = value;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return result;
|
|
31
|
-
}
|
|
32
|
-
const prismaOperations = [
|
|
33
|
-
"create",
|
|
34
|
-
"connect",
|
|
35
|
-
"update",
|
|
36
|
-
"delete",
|
|
37
|
-
"disconnect",
|
|
38
|
-
"deleteMany",
|
|
39
|
-
"connectOrCreate",
|
|
40
|
-
"upsert",
|
|
41
|
-
"set",
|
|
42
|
-
];
|
|
43
|
-
function isPrismaRelationFormat(obj) {
|
|
44
|
-
if (!obj || typeof obj !== "object")
|
|
45
|
-
return false;
|
|
46
|
-
return prismaOperations.some((op) => obj?.[op]);
|
|
47
|
-
}
|
|
48
|
-
function throwErrorIfApiActionIsInvalid(apiAction) {
|
|
49
|
-
if (apiAction && !prismaOperations.includes(apiAction))
|
|
50
|
-
throw new app_error_1.default(`Unknown value "${apiAction}" for apiAction field, available values are ${prismaOperations.join(", ")}.`, 400, "InvalidApiAction");
|
|
51
|
-
}
|
|
52
|
-
function handleRelationFieldsInBody(body, relationFields, ignoreActions = [], isRelation = false) {
|
|
53
|
-
body = JSON.parse(JSON.stringify(body));
|
|
54
|
-
let mutableBody = { ...body };
|
|
55
|
-
relationFields?.list?.forEach((field) => {
|
|
56
|
-
if (!body?.[field.name])
|
|
57
|
-
return;
|
|
58
|
-
if (ignoreActions?.includes?.(body[field.name]?.apiAction)) {
|
|
59
|
-
delete mutableBody[field.name];
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (isPrismaRelationFormat(body[field.name]))
|
|
63
|
-
return;
|
|
64
|
-
if (!Array.isArray(body[field.name]))
|
|
65
|
-
return;
|
|
66
|
-
const createData = [];
|
|
67
|
-
const connectData = [];
|
|
68
|
-
const updateData = [];
|
|
69
|
-
const disconnectData = [];
|
|
70
|
-
const deleteManyIds = [];
|
|
71
|
-
body[field.name]?.forEach((bodyField) => {
|
|
72
|
-
if (ignoreActions?.includes?.(bodyField?.apiAction))
|
|
73
|
-
return;
|
|
74
|
-
const apiAction = bodyField?.apiAction;
|
|
75
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
76
|
-
if (apiAction === "delete") {
|
|
77
|
-
deleteManyIds.push(bodyField.id);
|
|
78
|
-
}
|
|
79
|
-
else if (apiAction === "disconnect") {
|
|
80
|
-
disconnectData.push({ id: bodyField.id });
|
|
81
|
-
}
|
|
82
|
-
else if (bodyField?.apiAction !== "update" &&
|
|
83
|
-
canBeUsedToConnect(field.type, bodyField)) {
|
|
84
|
-
const { apiAction, ...cleanedData } = bodyField;
|
|
85
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
86
|
-
connectData.push(cleanedData);
|
|
87
|
-
}
|
|
88
|
-
else if (bodyField?.apiAction !== "update" && !bodyField?.id) {
|
|
89
|
-
let nestedRelations = getGroupedModelReations(field.type);
|
|
90
|
-
let dataToPush = { ...bodyField };
|
|
91
|
-
if (nestedRelations?.singular || nestedRelations?.list) {
|
|
92
|
-
dataToPush = handleRelationFieldsInBody(dataToPush, nestedRelations, ignoreActions, true);
|
|
93
|
-
}
|
|
94
|
-
if (dataToPush?.apiAction) {
|
|
95
|
-
const { apiAction, ...rest } = dataToPush;
|
|
96
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
97
|
-
dataToPush = rest;
|
|
98
|
-
}
|
|
99
|
-
createData.push(dataToPush);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
const { apiAction, ...data } = bodyField;
|
|
103
|
-
let foreignKeyFieldName = bodyField?.id ? "id" : "";
|
|
104
|
-
let foreignKeyFieldValue = bodyField?.id ? bodyField.id : "";
|
|
105
|
-
if (!foreignKeyFieldName) {
|
|
106
|
-
for (const [key, value] of Object.entries(data)) {
|
|
107
|
-
if (canBeUsedToConnect(field.type, { [key]: value })) {
|
|
108
|
-
foreignKeyFieldName = key;
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (!foreignKeyFieldName)
|
|
113
|
-
throw new app_error_1.default("No unique fields to be used in the prisma where clause", 400, "NoFieldToIsInPrismaWhereClause", { data: body });
|
|
114
|
-
}
|
|
115
|
-
foreignKeyFieldValue = data[foreignKeyFieldName];
|
|
116
|
-
delete data[foreignKeyFieldName];
|
|
117
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
118
|
-
let nestedRelations = getGroupedModelReations(field.type);
|
|
119
|
-
let dataToPush = data;
|
|
120
|
-
if (nestedRelations?.singular || nestedRelations?.list) {
|
|
121
|
-
dataToPush = handleRelationFieldsInBody(data, nestedRelations, ignoreActions, true);
|
|
122
|
-
}
|
|
123
|
-
updateData.push({
|
|
124
|
-
where: { [foreignKeyFieldName]: foreignKeyFieldValue },
|
|
125
|
-
data: dataToPush,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
mutableBody[field.name] = {
|
|
130
|
-
...(createData.length ? { create: createData } : {}),
|
|
131
|
-
...(connectData.length ? { connect: connectData } : {}),
|
|
132
|
-
...(updateData.length ? { update: updateData } : {}),
|
|
133
|
-
...(disconnectData.length ? { disconnect: disconnectData } : {}),
|
|
134
|
-
...(deleteManyIds.length
|
|
135
|
-
? { deleteMany: { id: { in: deleteManyIds } } }
|
|
136
|
-
: {}),
|
|
137
|
-
};
|
|
138
|
-
});
|
|
139
|
-
relationFields?.singular?.forEach((field) => {
|
|
140
|
-
if (!body?.[field.name])
|
|
141
|
-
return;
|
|
142
|
-
if (ignoreActions?.includes?.(body[field.name]?.apiAction)) {
|
|
143
|
-
delete mutableBody[field.name];
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (isPrismaRelationFormat(body[field.name])) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
const relationData = body[field.name];
|
|
150
|
-
let nestedRelations = getGroupedModelReations(field.type);
|
|
151
|
-
if (relationData?.apiAction === "delete") {
|
|
152
|
-
mutableBody[field.name] = { delete: true };
|
|
153
|
-
}
|
|
154
|
-
else if (relationData?.apiAction === "disconnect") {
|
|
155
|
-
mutableBody[field.name] = { disconnect: true };
|
|
156
|
-
}
|
|
157
|
-
else if (relationData?.apiAction !== "update" &&
|
|
158
|
-
canBeUsedToConnect(field.type, relationData)) {
|
|
159
|
-
const { apiAction, ...cleanedData } = relationData;
|
|
160
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
161
|
-
mutableBody[field.name] = { connect: cleanedData };
|
|
162
|
-
}
|
|
163
|
-
else if (relationData?.apiAction !== "update" && !relationData?.id) {
|
|
164
|
-
let dataToCreate = { ...relationData };
|
|
165
|
-
if (dataToCreate?.apiAction) {
|
|
166
|
-
const { apiAction, ...rest } = dataToCreate;
|
|
167
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
168
|
-
dataToCreate = rest;
|
|
169
|
-
}
|
|
170
|
-
if (nestedRelations?.singular || nestedRelations?.list) {
|
|
171
|
-
dataToCreate = handleRelationFieldsInBody(dataToCreate, nestedRelations, ignoreActions, true);
|
|
172
|
-
}
|
|
173
|
-
mutableBody[field.name] = { create: dataToCreate };
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const { id, apiAction, ...data } = relationData;
|
|
177
|
-
throwErrorIfApiActionIsInvalid(apiAction);
|
|
178
|
-
let dataToUpdate = data;
|
|
179
|
-
if (nestedRelations?.singular || nestedRelations?.list) {
|
|
180
|
-
dataToUpdate = handleRelationFieldsInBody(data, nestedRelations, ignoreActions, true);
|
|
181
|
-
}
|
|
182
|
-
mutableBody[field.name] = {
|
|
183
|
-
update: {
|
|
184
|
-
where: { id },
|
|
185
|
-
data: dataToUpdate,
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
if (mutableBody?.apiAction && !isRelation) {
|
|
191
|
-
throw new app_error_1.default("Invalid usage of apiAction field, it must only be used on relation fields whether single or multiple.", 400, {
|
|
192
|
-
data: {
|
|
193
|
-
...body,
|
|
194
|
-
},
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return removeApiAction(mutableBody);
|
|
198
|
-
}
|
|
199
|
-
function getGroupedModelReations(modelName) {
|
|
200
|
-
const relationsFields = prisma_schema_parser_1.default.getModelRelations(modelName);
|
|
201
|
-
return {
|
|
202
|
-
singular: relationsFields?.filter((field) => field.isRelation && !field.isArray),
|
|
203
|
-
list: relationsFields?.filter((field) => field.isRelation && field.isArray),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
function canBeUsedToConnect(modelName, bodyField) {
|
|
207
|
-
if (!bodyField)
|
|
208
|
-
return false;
|
|
209
|
-
if (bodyField.apiAction && !["connect"]?.includes?.(bodyField.apiAction))
|
|
210
|
-
return false;
|
|
211
|
-
if (bodyField.apiAction === "connect")
|
|
212
|
-
return true;
|
|
213
|
-
if (Object.keys(bodyField)?.length === 1 && bodyField?.id)
|
|
214
|
-
return true;
|
|
215
|
-
const uniqueFields = prisma_schema_parser_1.default.getModelUniqueFields(modelName) || [];
|
|
216
|
-
if (Object.keys(bodyField).length === 1 && uniqueFields?.length > 0) {
|
|
217
|
-
const fieldName = Object.keys(bodyField)[0];
|
|
218
|
-
return uniqueFields?.some((field) => field.name === fieldName);
|
|
219
|
-
}
|
|
220
|
-
return false;
|
|
221
|
-
}
|
|
222
|
-
//# sourceMappingURL=base.service.helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"base.service.helpers.js","sourceRoot":"","sources":["../../../../../../src/modules/base/utils/helpers/base.service.helpers.ts"],"names":[],"mappings":";;;;;AAUA,0CAoBC;AAoBD,wDAKC;AAED,wEAOC;AA4BD,gEAmNC;AAyBD,gDAqBC;AA7VD,yGAA+E;AAE/E,uFAA8D;AAQ9D,SAAgB,eAAe,CAAC,GAAwB;IACtD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IAEhD,MAAM,MAAM,GAAwB,EAAE,CAAC;IAEvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/C,IAAI,GAAG,KAAK,WAAW;YAAE,SAAS;QAElC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/B,OAAO,IAAI,KAAK,QAAQ,IAAI,IA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AS,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IAEnD,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,CAAC,IAAI,SAAS,EAAE,EAAE;QAAE,OAAO,IAAI,CAAC;IAEvE,MAAM,YAAY,GAAG,8BAAkB,CAAC,oBAAoB,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;IAE9E,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,YAAY,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;QACpE,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,OAAO,YAAY,EAAE,IAAI,CAAC,CAAC,KAAkB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import prismaSchemaParser from \"../../../../utils/prisma/prisma-schema-parser\";\nimport { PrismaField } from \"../../../../utils/prisma/types\";\nimport AppError from \"../../../error-handler/utils/app-error\";\n\n/**\n * Removes apiAction field from an object and all nested objects\n *\n * @param {Record<string, any>} obj - The object to clean\n * @returns {Record<string, any>} - The cleaned object\n */\nexport function removeApiAction(obj: Record<string, any>): Record<string, any> {\n if (!obj || typeof obj !== \"object\") return obj;\n\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(obj)) {\n if (key === \"apiAction\") continue;\n\n if (Array.isArray(value)) {\n result[key] = value.map((item) =>\n typeof item === \"object\" && item !== null ? removeApiAction(item) : item\n );\n } else if (typeof value === \"object\" && value !== null) {\n result[key] = removeApiAction(value);\n } else {\n result[key] = value;\n }\n }\n\n return result;\n}\n\nconst prismaOperations = [\n \"create\",\n \"connect\",\n \"update\",\n \"delete\",\n \"disconnect\",\n \"deleteMany\",\n \"connectOrCreate\",\n \"upsert\",\n \"set\",\n];\n\n/**\n * Checks if an object is already formatted as a Prisma relation operation\n *\n * @param {Record<string, any>} obj - The object to check\n * @returns {boolean} - True if the object contains Prisma relation operations\n */\nexport function isPrismaRelationFormat(obj: Record<string, any>): boolean {\n if (!obj || typeof obj !== \"object\") return false;\n\n // Check if any key is a Prisma operation\n return prismaOperations.some((op) => obj?.[op]);\n}\n\nexport function throwErrorIfApiActionIsInvalid(apiAction: string) {\n if (apiAction && !prismaOperations.includes(apiAction))\n throw new AppError(\n `Unknown value \"${apiAction}\" for apiAction field, available values are ${prismaOperations.join(\", \")}.`,\n 400,\n \"InvalidApiAction\"\n );\n}\n\n/**\n * Determines the appropriate Prisma operation (`create`, `connect`, `update`, `delete`, or `disconnect`)\n * for each relation field in the provided body based on its nested data and recursively does the same for each relation field.\n *\n * This function handles the following types of relations:\n * - **One-to-one**\n * - **One-to-many**\n *\n *\n * ### Operation Rules:\n *\n *\n * - **Create**: Used when the nested relation data is provided **without an `id` or unique field**.\n * - **Connect**: Used when the nested relation data contains **only an `id` or a unique field** (e.g., email).\n * - **Update**: Used when the nested relation data contains **both an `id` and additional fields**.\n * - **Delete**: Used when the nested relation data includes **`apiAction: \"delete\"`**.\n * - **Disconnect**: Used when the nested relation data includes **`apiAction: \"disconnect\"`**.\n *\n * The function will preserve existing Prisma operation formats if detected,\n * allowing developers to manually structure relation operations when needed.\n *\n * @param {Record<string, any>} body - The object containing relation fields to be processed.\n * @param {ModelGroupRelationFields} relationFields - List of many-side relation field names (one-to-many).\n * @param {string[]} ignoreActions - Optional list of apiAction values to ignore.\n * @returns {Record<string, any>} The transformed data with appropriate Prisma operations applied.\n */\nexport function handleRelationFieldsInBody(\n body: Record<string, any>,\n relationFields: ModelGroupRelationFields,\n ignoreActions: string[] = [],\n isRelation: boolean = false\n): Record<string, any> {\n body = JSON.parse(JSON.stringify(body));\n let mutableBody = { ...body };\n\n relationFields?.list?.forEach((field) => {\n if (!body?.[field.name]) return;\n\n if (ignoreActions?.includes?.(body[field.name]?.apiAction)) {\n delete mutableBody[field.name];\n return;\n }\n\n if (isPrismaRelationFormat(body[field.name])) return;\n\n if (!Array.isArray(body[field.name])) return;\n\n const createData: any[] = [];\n const connectData: any[] = [];\n const updateData: any[] = [];\n const disconnectData: any[] = [];\n const deleteManyIds: any[] = [];\n\n body[field.name]?.forEach((bodyField: any) => {\n if (ignoreActions?.includes?.(bodyField?.apiAction)) return;\n\n const apiAction = bodyField?.apiAction;\n\n throwErrorIfApiActionIsInvalid(apiAction);\n\n if (apiAction === \"delete\") {\n deleteManyIds.push(bodyField.id);\n } else if (apiAction === \"disconnect\") {\n disconnectData.push({ id: bodyField.id });\n } else if (\n bodyField?.apiAction !== \"update\" &&\n canBeUsedToConnect(field.type, bodyField)\n ) {\n const { apiAction, ...cleanedData } = bodyField;\n\n throwErrorIfApiActionIsInvalid(apiAction);\n connectData.push(cleanedData);\n } else if (bodyField?.apiAction !== \"update\" && !bodyField?.id) {\n let nestedRelations = getGroupedModelReations(field.type);\n\n let dataToPush = { ...bodyField };\n\n if (nestedRelations?.singular || nestedRelations?.list) {\n dataToPush = handleRelationFieldsInBody(\n dataToPush,\n nestedRelations,\n ignoreActions,\n true\n );\n }\n\n if (dataToPush?.apiAction) {\n const { apiAction, ...rest } = dataToPush;\n\n throwErrorIfApiActionIsInvalid(apiAction);\n dataToPush = rest;\n }\n\n createData.push(dataToPush);\n } else {\n const { apiAction, ...data } = bodyField;\n let foreignKeyFieldName = bodyField?.id ? \"id\" : \"\";\n let foreignKeyFieldValue = bodyField?.id ? bodyField.id : \"\";\n\n if (!foreignKeyFieldName) {\n for (const [key, value] of Object.entries(data)) {\n if (canBeUsedToConnect(field.type, { [key]: value })) {\n foreignKeyFieldName = key;\n break;\n }\n }\n\n if (!foreignKeyFieldName)\n throw new AppError(\n \"No unique fields to be used in the prisma where clause\",\n 400,\n \"NoFieldToIsInPrismaWhereClause\",\n { data: body }\n );\n }\n\n foreignKeyFieldValue = data[foreignKeyFieldName];\n delete data[foreignKeyFieldName];\n\n throwErrorIfApiActionIsInvalid(apiAction);\n let nestedRelations = getGroupedModelReations(field.type);\n\n let dataToPush = data;\n if (nestedRelations?.singular || nestedRelations?.list) {\n dataToPush = handleRelationFieldsInBody(\n data,\n nestedRelations,\n ignoreActions,\n true\n );\n }\n\n updateData.push({\n where: { [foreignKeyFieldName]: foreignKeyFieldValue },\n data: dataToPush,\n });\n }\n });\n\n mutableBody[field.name] = {\n ...(createData.length ? { create: createData } : {}),\n ...(connectData.length ? { connect: connectData } : {}),\n ...(updateData.length ? { update: updateData } : {}),\n ...(disconnectData.length ? { disconnect: disconnectData } : {}),\n ...(deleteManyIds.length\n ? { deleteMany: { id: { in: deleteManyIds } } }\n : {}),\n };\n });\n\n relationFields?.singular?.forEach((field) => {\n if (!body?.[field.name]) return;\n\n if (ignoreActions?.includes?.(body[field.name]?.apiAction)) {\n delete mutableBody[field.name];\n return;\n }\n\n if (isPrismaRelationFormat(body[field.name])) {\n return;\n }\n\n const relationData = body[field.name];\n let nestedRelations = getGroupedModelReations(field.type);\n\n if (relationData?.apiAction === \"delete\") {\n mutableBody[field.name] = { delete: true };\n } else if (relationData?.apiAction === \"disconnect\") {\n mutableBody[field.name] = { disconnect: true };\n } else if (\n relationData?.apiAction !== \"update\" &&\n canBeUsedToConnect(field.type, relationData)\n ) {\n const { apiAction, ...cleanedData } = relationData;\n\n throwErrorIfApiActionIsInvalid(apiAction);\n\n mutableBody[field.name] = { connect: cleanedData };\n } else if (relationData?.apiAction !== \"update\" && !relationData?.id) {\n let dataToCreate = { ...relationData };\n\n if (dataToCreate?.apiAction) {\n const { apiAction, ...rest } = dataToCreate;\n throwErrorIfApiActionIsInvalid(apiAction);\n\n dataToCreate = rest;\n }\n\n if (nestedRelations?.singular || nestedRelations?.list) {\n dataToCreate = handleRelationFieldsInBody(\n dataToCreate,\n nestedRelations,\n ignoreActions,\n true\n );\n }\n\n mutableBody[field.name] = { create: dataToCreate };\n } else {\n // If ID and other fields, assume update operation\n const { id, apiAction, ...data } = relationData;\n\n throwErrorIfApiActionIsInvalid(apiAction);\n\n let dataToUpdate = data;\n if (nestedRelations?.singular || nestedRelations?.list) {\n dataToUpdate = handleRelationFieldsInBody(\n data,\n nestedRelations,\n ignoreActions,\n true\n );\n }\n\n mutableBody[field.name] = {\n update: {\n where: { id },\n data: dataToUpdate,\n },\n };\n }\n });\n\n if (mutableBody?.apiAction && !isRelation) {\n throw new AppError(\n \"Invalid usage of apiAction field, it must only be used on relation fields whether single or multiple.\",\n 400,\n {\n data: {\n ...body,\n },\n }\n );\n }\n\n // As a final step, recursively remove any remaining apiAction fields\n return removeApiAction(mutableBody);\n}\n\nexport type ModelGroupRelationFields = ReturnType<\n typeof getGroupedModelReations\n>;\n\nfunction getGroupedModelReations(modelName: string) {\n const relationsFields = prismaSchemaParser.getModelRelations(modelName);\n\n return {\n singular: relationsFields?.filter(\n (field) => field.isRelation && !field.isArray\n ),\n list: relationsFields?.filter((field) => field.isRelation && field.isArray),\n };\n}\n\n/**\n * Checks if a field value can be used to connect to a model\n * This happens when the field contains only an ID or a single unique field\n *\n * @param {string} modelName - The model name to get unique fields for\n * @param {Record<string, any>} bodyField - The field value from the body\n * @returns {boolean} True if the field can be used for a connect operation\n */\nexport function canBeUsedToConnect(\n modelName: string,\n bodyField: Record<string, any> | undefined | null\n): boolean {\n if (!bodyField) return false;\n\n if (bodyField.apiAction && ![\"connect\"]?.includes?.(bodyField.apiAction))\n return false;\n\n if (bodyField.apiAction === \"connect\") return true;\n\n if (Object.keys(bodyField)?.length === 1 && bodyField?.id) return true;\n\n const uniqueFields = prismaSchemaParser.getModelUniqueFields(modelName) || [];\n\n if (Object.keys(bodyField).length === 1 && uniqueFields?.length > 0) {\n const fieldName = Object.keys(bodyField)[0];\n return uniqueFields?.some((field: PrismaField) => field.name === fieldName);\n }\n\n return false;\n}\n"]}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class RouterValidator {
|
|
4
|
-
isExpressRouter(router) {
|
|
5
|
-
if (!router || typeof router !== "function")
|
|
6
|
-
return false;
|
|
7
|
-
const hasStack = Array.isArray(router?.stack);
|
|
8
|
-
return hasStack;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const routerValidator = new RouterValidator();
|
|
12
|
-
exports.default = routerValidator;
|
|
13
|
-
//# sourceMappingURL=router-validator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"router-validator.js","sourceRoot":"","sources":["../../../../../src/modules/base/utils/router-validator.ts"],"names":[],"mappings":";;AAAA,MAAM,eAAe;IACnB,eAAe,CAAC,MAAW;QACzB,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,UAAU;YAAE,OAAO,KAAK,CAAC;QAC1D,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC9C,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAE9C,kBAAe,eAAe,CAAC","sourcesContent":["class RouterValidator {\n isExpressRouter(router: any) {\n if (!router || typeof router !== \"function\") return false;\n const hasStack = Array.isArray(router?.stack);\n return hasStack;\n }\n}\n\nconst routerValidator = new RouterValidator();\n\nexport default routerValidator;\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class ServiceHooksManager {
|
|
4
|
-
async handleHook(hooksReceived, hooksArgs) {
|
|
5
|
-
const hooks = Array.isArray(hooksReceived)
|
|
6
|
-
? hooksReceived
|
|
7
|
-
: [hooksReceived];
|
|
8
|
-
for (const hook of hooks) {
|
|
9
|
-
await hook(hooksArgs);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
validateServiceHook(hook) {
|
|
13
|
-
if (typeof hook !== "function")
|
|
14
|
-
throw new Error(`Validation Error: service hook must be of type function or array of functions but received value of type ${typeof hook}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const serviceHooksManager = new ServiceHooksManager();
|
|
18
|
-
exports.default = serviceHooksManager;
|
|
19
|
-
//# sourceMappingURL=service-hooks-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service-hooks-manager.js","sourceRoot":"","sources":["../../../../../src/modules/base/utils/service-hooks-manager.ts"],"names":[],"mappings":";;AAKA,MAAM,mBAAmB;IAIvB,KAAK,CAAC,UAAU,CACd,aAAkE,EAClE,SAA8B;QAE9B,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC;YACxC,CAAC,CAAC,aAAa;YACf,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAEpB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,mBAAmB,CAAC,IAA6B;QAC/C,IAAI,OAAO,IAAI,KAAK,UAAU;YAC5B,MAAM,IAAI,KAAK,CACb,4GAA4G,OAAO,IAAI,EAAE,CAC1H,CAAC;IACN,CAAC;CACF;AAED,MAAM,mBAAmB,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAEtD,kBAAe,mBAAmB,CAAC","sourcesContent":["import { ServiceHookHandler } from \"../../../components/arkos-service-hook/types\";\n\n/**\n * Manages and handles service hooks implementation on the base service class\n */\nclass ServiceHooksManager {\n /*\n * Handles single function or array of functions of service hook\n */\n async handleHook(\n hooksReceived: ServiceHookHandler<any> | ServiceHookHandler<any>[],\n hooksArgs: Record<string, any>\n ) {\n const hooks = Array.isArray(hooksReceived)\n ? hooksReceived\n : [hooksReceived];\n\n for (const hook of hooks) {\n await hook(hooksArgs);\n }\n }\n\n validateServiceHook(hook: ServiceHookHandler<any>) {\n if (typeof hook !== \"function\")\n throw new Error(\n `Validation Error: service hook must be of type function or array of functions but received value of type ${typeof hook}`\n );\n }\n}\n\nconst serviceHooksManager = new ServiceHooksManager();\n\nexport default serviceHooksManager;\n"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const sheu_1 = __importDefault(require("../../utils/sheu.js"));
|
|
7
|
-
const server_1 = require("../../server.js");
|
|
8
|
-
class DebuggerService {
|
|
9
|
-
handleTransformedQueryLog(transformedQuery) {
|
|
10
|
-
const config = (0, server_1.getArkosConfig)();
|
|
11
|
-
const debugLevel = config.debugging?.requests?.level || 0;
|
|
12
|
-
if (debugLevel < 2)
|
|
13
|
-
return;
|
|
14
|
-
if (transformedQuery && Object.keys(transformedQuery).length > 0) {
|
|
15
|
-
sheu_1.default.debug(`Transformed Request Parameters\n${JSON.stringify(transformedQuery, null, 2)}`, { timestamp: true });
|
|
16
|
-
}
|
|
17
|
-
else
|
|
18
|
-
sheu_1.default.debug(`Transformed Request Parameters - Empty`, {
|
|
19
|
-
timestamp: true,
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
logRequestInfo(req, _, next) {
|
|
23
|
-
const config = (0, server_1.getArkosConfig)();
|
|
24
|
-
const debugLevel = config.debugging?.requests?.level || 0;
|
|
25
|
-
const filter = config.debugging?.requests?.filter;
|
|
26
|
-
function shouldLog(inputName) {
|
|
27
|
-
const hasFilter = (filter?.length || 0) > 0;
|
|
28
|
-
if (!hasFilter)
|
|
29
|
-
return true;
|
|
30
|
-
return filter?.includes(inputName);
|
|
31
|
-
}
|
|
32
|
-
if (debugLevel < 2)
|
|
33
|
-
return next();
|
|
34
|
-
if (req.modelName)
|
|
35
|
-
sheu_1.default.debug(`Prisma Model Module\n${req.modelName}`, { timestamp: true });
|
|
36
|
-
if (Object.keys(req.params).length > 0 && shouldLog("Params"))
|
|
37
|
-
sheu_1.default.debug(`Original Request Params (req.params)\n${JSON.stringify(req.params || {}, null, 2)}`, { timestamp: true });
|
|
38
|
-
else
|
|
39
|
-
sheu_1.default.debug(`Original Request Params (req.params) - Empty`, {
|
|
40
|
-
timestamp: true,
|
|
41
|
-
});
|
|
42
|
-
if (req.body && Object.keys(req.body).length > 0 && shouldLog("Body"))
|
|
43
|
-
sheu_1.default.debug(`Original Request Body (req.body)\n${JSON.stringify(req.body, null, 2)}`, { timestamp: true });
|
|
44
|
-
else
|
|
45
|
-
sheu_1.default.debug(`Original Request Body (req.body) - Empty`, {
|
|
46
|
-
timestamp: true,
|
|
47
|
-
});
|
|
48
|
-
if (Object.keys(req.query).length > 0 && shouldLog("Query"))
|
|
49
|
-
sheu_1.default.debug(`Original Request Query (req.query)\n${JSON.stringify(req.query || {}, null, 2)}`, { timestamp: true });
|
|
50
|
-
else
|
|
51
|
-
sheu_1.default.debug(`Original Request Query (req.query) - Empty`, {
|
|
52
|
-
timestamp: true,
|
|
53
|
-
});
|
|
54
|
-
next();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const debuggerService = new DebuggerService();
|
|
58
|
-
exports.default = debuggerService;
|
|
59
|
-
//# sourceMappingURL=debugger.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.service.js","sourceRoot":"","sources":["../../../../src/modules/debugger/debugger.service.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAEpC,yCAA8C;AAE9C,MAAM,eAAe;IACnB,yBAAyB,CAAC,gBAAqC;QAC7D,MAAM,MAAM,GAAG,IAAA,uBAAc,GAAE,CAAC;QAChC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAAE,QAAQ,EAAE,KAAK,IAAI,CAAC,CAAC;QAC1D,IAAI,UAAU,GAAG,CAAC;YAAE,OAAO;QAE3B,IAAI,gBAAgB,IAAI,MAAM,CA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E,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EACpF,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;;YAEF,cAAI,CAAC,KAAK,CAAC,8CAA8C,EAAE;gBACzD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,GAAG,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,CAAC;YACnE,cAAI,CAAC,KAAK,CACR,qCAAqC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EACxE,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;;YAEF,cAAI,CAAC,KAAK,CAAC,0CAA0C,EAAE;gBACrD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC;YACzD,cAAI,CAAC,KAAK,CACR,uCAAuC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EACjF,EAAE,SAAS,EAAE,IAAI,EAAE,CACpB,CAAC;;YAEF,cAAI,CAAC,KAAK,CAAC,4CAA4C,EAAE;gBACvD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QAEL,IAAI,EAAE,CAAC;IACT,CAAC;CACF;AAED,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAE9C,kBAAe,eAAe,CAAC","sourcesContent":["import sheu from \"../../utils/sheu\";\nimport { ArkosNextFunction, ArkosRequest, ArkosResponse } from \"../../exports\";\nimport { getArkosConfig } from \"../../server\";\n\nclass DebuggerService {\n handleTransformedQueryLog(transformedQuery: Record<string, any>) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n if (debugLevel < 2) return;\n\n if (transformedQuery && Object.keys(transformedQuery).length > 0) {\n sheu.debug(\n `Transformed Request Parameters\\n${JSON.stringify(transformedQuery, null, 2)}`,\n { timestamp: true }\n );\n } else\n sheu.debug(`Transformed Request Parameters - Empty`, {\n timestamp: true,\n });\n }\n\n logRequestInfo(req: ArkosRequest, _: ArkosResponse, next: ArkosNextFunction) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n const filter = config.debugging?.requests?.filter;\n\n function shouldLog(inputName: any) {\n const hasFilter = (filter?.length || 0) > 0;\n if (!hasFilter) return true;\n return filter?.includes(inputName);\n }\n\n if (debugLevel < 2) return next();\n\n if (req.modelName)\n sheu.debug(`Prisma Model Module\\n${req.modelName}`, { timestamp: true });\n\n if (Object.keys(req.params).length > 0 && shouldLog(\"Params\"))\n sheu.debug(\n `Original Request Params (req.params)\\n${JSON.stringify(req.params || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Params (req.params) - Empty`, {\n timestamp: true,\n });\n\n if (req.body && Object.keys(req.body).length > 0 && shouldLog(\"Body\"))\n sheu.debug(\n `Original Request Body (req.body)\\n${JSON.stringify(req.body, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Body (req.body) - Empty`, {\n timestamp: true,\n });\n\n if (Object.keys(req.query).length > 0 && shouldLog(\"Query\"))\n sheu.debug(\n `Original Request Query (req.query)\\n${JSON.stringify(req.query || {}, null, 2)}`,\n { timestamp: true }\n );\n else\n sheu.debug(`Original Request Query (req.query) - Empty`, {\n timestamp: true,\n });\n\n next();\n }\n}\n\nconst debuggerService = new DebuggerService();\n\nexport default debuggerService;\n"]}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EmailService = void 0;
|
|
7
|
-
const nodemailer_1 = __importDefault(require("nodemailer"));
|
|
8
|
-
const html_to_text_1 = require("html-to-text");
|
|
9
|
-
const server_1 = require("../../server.js");
|
|
10
|
-
const app_error_1 = __importDefault(require("../error-handler/utils/app-error.js"));
|
|
11
|
-
class EmailService {
|
|
12
|
-
constructor(config) {
|
|
13
|
-
this.transporter = null;
|
|
14
|
-
this.customConfig = null;
|
|
15
|
-
if (config) {
|
|
16
|
-
this.customConfig = config;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
getEmailConfig() {
|
|
20
|
-
if (this.customConfig) {
|
|
21
|
-
return this.customConfig;
|
|
22
|
-
}
|
|
23
|
-
const { email: emailConfigs } = (0, server_1.getArkosConfig)();
|
|
24
|
-
const host = emailConfigs?.host || process.env.EMAIL_HOST;
|
|
25
|
-
const port = emailConfigs?.port ||
|
|
26
|
-
(process.env.EMAIL_PORT ? parseInt(process.env.EMAIL_PORT) : undefined);
|
|
27
|
-
const secure = emailConfigs?.secure !== undefined
|
|
28
|
-
? emailConfigs.secure
|
|
29
|
-
: process.env.EMAIL_SECURE
|
|
30
|
-
? process.env.EMAIL_SECURE === "true"
|
|
31
|
-
: undefined;
|
|
32
|
-
const user = emailConfigs?.auth?.user || process.env.EMAIL_USER;
|
|
33
|
-
const pass = emailConfigs?.auth?.pass || process.env.EMAIL_PASSWORD;
|
|
34
|
-
const name = emailConfigs?.name || process.env.EMAIL_NAME;
|
|
35
|
-
if (!host || !user || !pass) {
|
|
36
|
-
throw new app_error_1.default("You are trying to use emailService without setting email configurations. " +
|
|
37
|
-
"Please configure either arkosConfig.email or environment variables (EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD)", 500, {
|
|
38
|
-
docs: "Read more about emailService at https://www.arkosjs.com/docs/core-concepts/sending-emails",
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
host,
|
|
43
|
-
port: port || 465,
|
|
44
|
-
secure: secure !== undefined ? secure : true,
|
|
45
|
-
auth: {
|
|
46
|
-
user,
|
|
47
|
-
pass,
|
|
48
|
-
},
|
|
49
|
-
name,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
getTransporter(customConfig) {
|
|
53
|
-
if (customConfig) {
|
|
54
|
-
const { name, ...config } = customConfig;
|
|
55
|
-
return nodemailer_1.default.createTransport(config);
|
|
56
|
-
}
|
|
57
|
-
if (!this.transporter) {
|
|
58
|
-
const { name, ...config } = this.getEmailConfig() || {};
|
|
59
|
-
this.transporter = nodemailer_1.default.createTransport(config);
|
|
60
|
-
}
|
|
61
|
-
return this.transporter;
|
|
62
|
-
}
|
|
63
|
-
async send(options, connectionOptions, skipVerification = true) {
|
|
64
|
-
const config = this.getEmailConfig();
|
|
65
|
-
const transporter = connectionOptions
|
|
66
|
-
? this.getTransporter(connectionOptions)
|
|
67
|
-
: this.getTransporter();
|
|
68
|
-
const fromAddress = options.from || connectionOptions?.auth?.user || config.auth?.user;
|
|
69
|
-
if (connectionOptions || !skipVerification) {
|
|
70
|
-
const isConnected = await this.verifyConnection(transporter);
|
|
71
|
-
if (!isConnected)
|
|
72
|
-
throw new Error("Failed to connect to email server");
|
|
73
|
-
}
|
|
74
|
-
const info = await transporter.sendMail({
|
|
75
|
-
...options,
|
|
76
|
-
from: fromAddress,
|
|
77
|
-
text: options?.text ||
|
|
78
|
-
(typeof options.html === "string" && options.html
|
|
79
|
-
? (0, html_to_text_1.convert)(options.html)
|
|
80
|
-
: undefined),
|
|
81
|
-
});
|
|
82
|
-
return { success: true, ...info };
|
|
83
|
-
}
|
|
84
|
-
async verifyConnection(transporterToVerify) {
|
|
85
|
-
try {
|
|
86
|
-
const transporter = transporterToVerify || this.getTransporter();
|
|
87
|
-
await transporter.verify();
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
console.error("Email Server Connection Failed", error);
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
updateConfig(config) {
|
|
96
|
-
this.customConfig = config;
|
|
97
|
-
this.transporter = null;
|
|
98
|
-
}
|
|
99
|
-
static create(config) {
|
|
100
|
-
return new EmailService(config);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.EmailService = EmailService;
|
|
104
|
-
const emailService = new EmailService();
|
|
105
|
-
exports.default = emailService;
|
|
106
|
-
//# sourceMappingURL=email.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.service.js","sourceRoot":"","sources":["../../../../src/modules/email/email.service.ts"],"names":[],"mappings":";;;;;;AAAA,4DAAsE;AACtE,+CAAuC;AACvC,yCAA8C;AAC9C,iFAAwD;AAiCxD,MAAa,YAAY;IAUvB,YAAY,MAA8B;QAT1C,gBAAW,GAAuB,IAAI,CAAC;QAC/B,iBAAY,GAAiC,IAAI,CAAC;QASxD,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC7B,CAAC;IACH,CAAC;IAUO,cAAc;QACpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC,YAAY,CAAC;QAC3B,CAAC;QAED,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,IAAA,uBAAc,GAAE,CAAC;QACjD,MAAM,IAAI,GAAG,YAAY,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;QAC1D,MAAM,IAAI,GACR,YAAY,EAAE,IAAI;YAClB,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAC1E,MAAM,MAAM,GACV,YAAY,EAAE,MAAM,KAAK,SAAS;YAChC,CAAC,CAAC,YAAY,CAAC,MAAM;YACrB,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M,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAMM,YAAY,CAAC,MAA6B;QAC/C,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAOM,MAAM,CAAC,MAAM,CAAC,MAA6B;QAChD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;CACF;AAhKD,oCAgKC;AAED,MAAM,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAExC,kBAAe,YAAY,CAAC","sourcesContent":["import nodemailer, { SendMailOptions, Transporter } from \"nodemailer\";\nimport { convert } from \"html-to-text\";\nimport { getArkosConfig } from \"../../server\";\nimport AppError from \"../error-handler/utils/app-error\";\n\n/**\n * Defines the options for sending an email.\n */\nexport type EmailOptions = {\n subject: string;\n} & SendMailOptions;\n\n/**\n * Defines the authentication options for SMTP.\n */\nexport type SMTPAuthOptions = {\n user: string;\n pass: string;\n};\n\n/**\n * Defines the connection options for SMTP server.\n */\nexport type SMTPConnectionOptions = {\n host?: string;\n port?: number;\n secure?: boolean;\n auth?: SMTPAuthOptions;\n name?: string;\n};\n\n/**\n * A service class to handle email-related tasks, including sending emails.\n *\n * See the api reference [www.arkosjs.com/docs/api-reference/the-email-service-class](https://www.arkosjs.com/docs/api-reference/the-email-service-class)\n */\nexport class EmailService {\n transporter: Transporter | null = null;\n private customConfig: SMTPConnectionOptions | null = null;\n\n /**\n * Creates an instance of the EmailService class.\n *\n * @param {SMTPConnectionOptions} [config] - Optional custom SMTP configuration.\n * If provided, these settings will be used instead of the Arkos config.\n */\n constructor(config?: SMTPConnectionOptions) {\n if (config) {\n this.customConfig = config;\n }\n }\n\n /**\n * Gets the email configuration from multiple sources with priority:\n * 1. Constructor customConfig\n * 2. ArkosConfig\n * 3. Environment variables\n * @returns Configuration object with host, port, and auth details\n * @throws AppError if required email configuration is not set\n */\n private getEmailConfig(): SMTPConnectionOptions {\n if (this.customConfig) {\n return this.customConfig;\n }\n\n const { email: emailConfigs } = getArkosConfig();\n const host = emailConfigs?.host || process.env.EMAIL_HOST;\n const port =\n emailConfigs?.port ||\n (process.env.EMAIL_PORT ? parseInt(process.env.EMAIL_PORT) : undefined);\n const secure =\n emailConfigs?.secure !== undefined\n ? emailConfigs.secure\n : process.env.EMAIL_SECURE\n ? process.env.EMAIL_SECURE === \"true\"\n : undefined;\n const user = emailConfigs?.auth?.user || process.env.EMAIL_USER;\n const pass = emailConfigs?.auth?.pass || process.env.EMAIL_PASSWORD;\n const name = emailConfigs?.name || process.env.EMAIL_NAME;\n\n if (!host || !user || !pass) {\n throw new AppError(\n \"You are trying to use emailService without setting email configurations. \" +\n \"Please configure either arkosConfig.email or environment variables (EMAIL_HOST, EMAIL_USER, EMAIL_PASSWORD)\",\n 500,\n {\n docs: \"Read more about emailService at https://www.arkosjs.com/docs/core-concepts/sending-emails\",\n }\n );\n }\n\n return {\n host,\n port: port || 465,\n secure: secure !== undefined ? secure : true,\n auth: {\n user,\n pass,\n },\n name,\n };\n }\n\n /**\n * Gets or creates a transporter using the email configuration\n * @param customConfig Optional override connection settings (takes full priority if provided)\n * @returns A configured nodemailer transporter\n */\n private getTransporter(customConfig?: SMTPConnectionOptions): Transporter {\n if (customConfig) {\n const { name, ...config } = customConfig;\n return nodemailer.createTransport(config);\n }\n\n if (!this.transporter) {\n const { name, ...config } = this.getEmailConfig() || {};\n this.transporter = nodemailer.createTransport(config);\n }\n return this.transporter;\n }\n\n /**\n * Sends an email with the provided options.\n * Can use either the default configuration or custom connection options.\n *\n * @param {EmailOptions} options - The options for the email to be sent.\n * @param {SMTPConnectionOptions} [connectionOptions] - Optional custom connection settings.\n * @param {boolean} [skipVerification=false] - Whether to skip connection verification.\n * @returns {Promise<{ success: boolean; messageId?: string } & Record<string, any>>} Result with message ID on success.\n */\n public async send(\n options: EmailOptions & SendMailOptions,\n connectionOptions?: SMTPConnectionOptions,\n skipVerification: boolean = true\n ): Promise<{ success: boolean; messageId?: string } & Record<string, any>> {\n const config = this.getEmailConfig();\n const transporter = connectionOptions\n ? this.getTransporter(connectionOptions)\n : this.getTransporter();\n\n const fromAddress =\n options.from || connectionOptions?.auth?.user || config.auth?.user;\n\n if (connectionOptions || !skipVerification) {\n const isConnected = await this.verifyConnection(transporter);\n if (!isConnected) throw new Error(\"Failed to connect to email server\");\n }\n\n const info = await transporter.sendMail({\n ...options,\n from: fromAddress,\n text:\n options?.text ||\n (typeof options.html === \"string\" && options.html\n ? convert(options.html as string)\n : undefined),\n });\n\n return { success: true, ...info };\n }\n\n /**\n * Verifies the connection to the email server.\n * @param {Transporter} [transporterToVerify] - Optional transporter to verify.\n * @returns {Promise<boolean>} A promise that resolves to true if connection is valid.\n */\n public async verifyConnection(\n transporterToVerify?: Transporter\n ): Promise<boolean> {\n try {\n const transporter = transporterToVerify || this.getTransporter();\n await transporter.verify();\n return true;\n } catch (error) {\n console.error(\"Email Server Connection Failed\", error);\n return false;\n }\n }\n\n /**\n * Updates the custom configuration for this email service instance.\n * @param {SMTPConnectionOptions} config - The new connection options.\n */\n public updateConfig(config: SMTPConnectionOptions): void {\n this.customConfig = config;\n this.transporter = null; // Reset transporter so it will be recreated with new config\n }\n\n /**\n * Creates a new instance of EmailService with custom configuration.\n * @param {SMTPConnectionOptions} config - The connection options for the new instance.\n * @returns {EmailService} A new EmailService instance.\n */\n public static create(config: SMTPConnectionOptions): EmailService {\n return new EmailService(config);\n }\n}\n\nconst emailService = new EmailService();\n\nexport default emailService;\n"]}
|