@minimaltech/node-infra 0.5.9-2 → 0.5.9-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/dist/base/applications/base.application.d.ts +2 -1
- package/dist/base/applications/base.application.js +31 -41
- package/dist/base/applications/default.application.js +2 -9
- package/dist/base/applications/index.js +0 -1
- package/dist/base/base.component.js +2 -3
- package/dist/base/base.helper.js +4 -4
- package/dist/base/base.provider.js +2 -3
- package/dist/base/base.sequence.js +17 -27
- package/dist/base/controllers/common.js +8 -10
- package/dist/base/controllers/crud.controller.js +55 -68
- package/dist/base/controllers/express-request-handler.d.ts +16 -0
- package/dist/base/controllers/express-request-handler.js +19 -0
- package/dist/base/controllers/index.d.ts +1 -0
- package/dist/base/controllers/index.js +1 -1
- package/dist/base/controllers/kv.controller.js +7 -19
- package/dist/base/controllers/relational.controller.d.ts +1 -3
- package/dist/base/controllers/relational.controller.js +40 -58
- package/dist/base/controllers/service-crud.controller.js +46 -47
- package/dist/base/datasources/base.datasource.js +1 -1
- package/dist/base/datasources/index.js +0 -1
- package/dist/base/datasources/types.js +0 -1
- package/dist/base/index.js +0 -1
- package/dist/base/loopback/@lb/auth/index.js +0 -1
- package/dist/base/loopback/@lb/core/index.d.ts +1 -1
- package/dist/base/loopback/@lb/core/index.js +1 -2
- package/dist/base/loopback/@lb/repository/index.d.ts +0 -1
- package/dist/base/loopback/@lb/repository/index.js +0 -2
- package/dist/base/loopback/@lb/rest/index.js +0 -1
- package/dist/base/loopback/authentication/index.d.ts +0 -2
- package/dist/base/loopback/authentication/index.js +0 -2
- package/dist/base/loopback/authorization/index.js +0 -1
- package/dist/base/loopback/boot/index.js +0 -1
- package/dist/base/loopback/core/index.js +0 -1
- package/dist/base/loopback/filter/index.d.ts +1 -2
- package/dist/base/loopback/filter/index.js +0 -16
- package/dist/base/loopback/health-check/index.d.ts +2 -0
- package/dist/base/loopback/health-check/index.js +17 -0
- package/dist/base/loopback/http-server/index.d.ts +1 -2
- package/dist/base/loopback/http-server/index.js +0 -16
- package/dist/base/loopback/metadata/index.js +0 -1
- package/dist/base/loopback/repository/index.js +0 -1
- package/dist/base/loopback/rest/index.js +0 -1
- package/dist/base/loopback/security/index.js +0 -1
- package/dist/base/loopback/service-proxy/index.js +0 -1
- package/dist/base/models/base.model.d.ts +0 -7
- package/dist/base/models/base.model.js +5 -24
- package/dist/base/models/index.js +0 -1
- package/dist/base/repositories/base.repository.d.ts +0 -3
- package/dist/base/repositories/base.repository.js +5 -25
- package/dist/base/repositories/index.js +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/decorator.d.ts +0 -8
- package/dist/base/repositories/relations/has-many-polymorphic/decorator.js +11 -11
- package/dist/base/repositories/relations/has-many-polymorphic/factory.d.ts +0 -9
- package/dist/base/repositories/relations/has-many-polymorphic/factory.js +12 -31
- package/dist/base/repositories/relations/has-many-polymorphic/index.js +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/types.js +0 -1
- package/dist/base/repositories/relations/index.js +0 -1
- package/dist/base/repositories/searchable-tz-crud.repository.js +129 -161
- package/dist/base/repositories/tz-crud.repository.js +23 -59
- package/dist/base/services/base-crud.service.js +6 -10
- package/dist/base/services/base.service.js +2 -3
- package/dist/base/services/index.js +0 -1
- package/dist/common/constants.js +81 -90
- package/dist/common/environments.js +25 -26
- package/dist/common/index.js +0 -1
- package/dist/common/keys.js +2 -3
- package/dist/common/statuses.js +28 -32
- package/dist/common/types.d.ts +0 -3
- package/dist/common/types.js +0 -1
- package/dist/components/authenticate/common/constants.js +11 -14
- package/dist/components/authenticate/common/index.js +0 -1
- package/dist/components/authenticate/common/keys.js +7 -8
- package/dist/components/authenticate/common/types.js +11 -4
- package/dist/components/authenticate/component.js +22 -30
- package/dist/components/authenticate/controllers/auth.controller.js +13 -12
- package/dist/components/authenticate/controllers/index.js +0 -1
- package/dist/components/authenticate/controllers/oauth2.controller.d.ts +6 -9
- package/dist/components/authenticate/controllers/oauth2.controller.js +20 -28
- package/dist/components/authenticate/index.js +0 -1
- package/dist/components/authenticate/middleware.js +25 -36
- package/dist/components/authenticate/models/index.js +0 -1
- package/dist/components/authenticate/models/oauth2-client.model.js +8 -4
- package/dist/components/authenticate/models/oauth2-scope.model.js +4 -1
- package/dist/components/authenticate/models/oauth2-token.model.js +7 -1
- package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.js +4 -6
- package/dist/components/authenticate/oauth2-handlers/base.js +95 -111
- package/dist/components/authenticate/oauth2-handlers/client-credential.handler.js +2 -4
- package/dist/components/authenticate/oauth2-handlers/index.js +0 -1
- package/dist/components/authenticate/oauth2-handlers/oauth2.js +3 -3
- package/dist/components/authenticate/oauth2-handlers/password.handler.js +0 -1
- package/dist/components/authenticate/repositories/index.js +0 -1
- package/dist/components/authenticate/repositories/oauth2.repository.js +2 -1
- package/dist/components/authenticate/services/basic-token.service.js +18 -30
- package/dist/components/authenticate/services/basic.strategy.js +7 -18
- package/dist/components/authenticate/services/index.js +0 -1
- package/dist/components/authenticate/services/jwt-token.service.js +27 -41
- package/dist/components/authenticate/services/jwt.strategy.js +2 -2
- package/dist/components/authenticate/services/oauth2.service.js +98 -111
- package/dist/components/authenticate/services/oauth2.strategy.js +19 -32
- package/dist/components/authorize/adapters/adapter-builder.js +1 -1
- package/dist/components/authorize/adapters/base.adapter.js +2 -10
- package/dist/components/authorize/adapters/casbin-postgres-adapter.helper.js +37 -56
- package/dist/components/authorize/adapters/casbin-redis-adapter.helper.js +0 -2
- package/dist/components/authorize/adapters/index.js +0 -1
- package/dist/components/authorize/common/constants.js +10 -13
- package/dist/components/authorize/common/index.js +0 -1
- package/dist/components/authorize/common/keys.js +15 -16
- package/dist/components/authorize/common/types.js +2 -3
- package/dist/components/authorize/component.js +44 -60
- package/dist/components/authorize/decorators/index.d.ts +0 -11
- package/dist/components/authorize/decorators/index.js +1 -15
- package/dist/components/authorize/index.js +0 -1
- package/dist/components/authorize/interceptor.js +76 -81
- package/dist/components/authorize/migrations/0000-create-view-policy.js +3 -15
- package/dist/components/authorize/migrations/index.js +0 -1
- package/dist/components/authorize/models/defs.d.ts +5 -5
- package/dist/components/authorize/models/defs.js +24 -6
- package/dist/components/authorize/models/index.js +0 -1
- package/dist/components/authorize/models/permission-mapping.model.d.ts +1 -1
- package/dist/components/authorize/models/permission-mapping.model.js +0 -1
- package/dist/components/authorize/models/permission.model.d.ts +1 -1
- package/dist/components/authorize/models/permission.model.js +0 -1
- package/dist/components/authorize/models/role.model.d.ts +1 -1
- package/dist/components/authorize/models/role.model.js +1 -2
- package/dist/components/authorize/models/user-role.model.d.ts +1 -1
- package/dist/components/authorize/models/user-role.model.js +0 -2
- package/dist/components/authorize/models/view-authorize-policy.model.js +4 -2
- package/dist/components/authorize/provider.js +81 -97
- package/dist/components/authorize/repositories/authorize.repository.js +3 -7
- package/dist/components/authorize/repositories/index.js +0 -1
- package/dist/components/authorize/services/enforcer.service.js +20 -28
- package/dist/components/authorize/services/generator.service.d.ts +0 -20
- package/dist/components/authorize/services/generator.service.js +62 -97
- package/dist/components/authorize/services/index.js +0 -1
- package/dist/components/crash-report/common/constants.js +0 -1
- package/dist/components/crash-report/common/index.js +0 -1
- package/dist/components/crash-report/common/keys.js +8 -11
- package/dist/components/crash-report/common/types.js +0 -1
- package/dist/components/crash-report/component.js +31 -45
- package/dist/components/crash-report/index.js +0 -1
- package/dist/components/crash-report/providers/index.js +0 -1
- package/dist/components/crash-report/providers/provider.js +1 -1
- package/dist/components/crash-report/providers/third-parties/base.js +2 -3
- package/dist/components/crash-report/providers/third-parties/index.js +0 -1
- package/dist/components/crash-report/services/index.js +0 -1
- package/dist/components/crash-report/services/mt-crash-report.service.js +5 -6
- package/dist/components/grpc/common/constants.js +0 -1
- package/dist/components/grpc/common/index.js +0 -1
- package/dist/components/grpc/common/keys.js +4 -5
- package/dist/components/grpc/common/types.js +0 -1
- package/dist/components/grpc/components/index.js +0 -1
- package/dist/components/grpc/components/server.component.js +9 -10
- package/dist/components/grpc/controllers/base.js +1 -1
- package/dist/components/grpc/controllers/index.js +0 -1
- package/dist/components/grpc/decorators/index.js +0 -1
- package/dist/components/grpc/helpers/grpc-client.js +9 -4
- package/dist/components/grpc/helpers/grpc-server.js +14 -18
- package/dist/components/grpc/helpers/index.js +0 -1
- package/dist/components/grpc/index.js +0 -1
- package/dist/components/grpc/persistents/grpc.connector.js +8 -3
- package/dist/components/grpc/persistents/grpc.datasource.js +2 -4
- package/dist/components/grpc/persistents/grpc.repository.js +3 -3
- package/dist/components/grpc/persistents/index.js +0 -1
- package/dist/components/health-check/component.d.ts +7 -0
- package/dist/components/health-check/component.js +51 -0
- package/dist/components/health-check/index.d.ts +1 -0
- package/dist/components/health-check/index.js +17 -0
- package/dist/components/index.d.ts +2 -1
- package/dist/components/index.js +2 -2
- package/dist/components/migration/common/index.js +0 -1
- package/dist/components/migration/common/keys.js +3 -4
- package/dist/components/migration/common/types.js +0 -1
- package/dist/components/migration/component.js +5 -9
- package/dist/components/migration/index.js +0 -1
- package/dist/components/migration/models/index.js +0 -1
- package/dist/components/migration/models/migration.model.js +2 -1
- package/dist/components/migration/repositories/index.js +0 -1
- package/dist/components/migration/repositories/migration.repository.js +0 -1
- package/dist/components/socket-io/common/constants.js +10 -11
- package/dist/components/socket-io/common/index.js +0 -1
- package/dist/components/socket-io/common/keys.js +6 -7
- package/dist/components/socket-io/component.js +9 -9
- package/dist/components/socket-io/helpers/index.js +0 -1
- package/dist/components/socket-io/helpers/socket-io-client.helper.js +7 -12
- package/dist/components/socket-io/helpers/socket-io-server.helper.js +26 -42
- package/dist/components/socket-io/index.js +0 -1
- package/dist/components/static-asset/common/index.js +0 -1
- package/dist/components/static-asset/common/keys.js +4 -5
- package/dist/components/static-asset/component.js +9 -9
- package/dist/components/static-asset/controllers/asset.controller.d.ts +0 -8
- package/dist/components/static-asset/controllers/asset.controller.js +71 -94
- package/dist/components/static-asset/controllers/index.js +0 -1
- package/dist/components/static-asset/controllers/resource.controller.js +8 -10
- package/dist/components/static-asset/index.js +0 -1
- package/dist/datasources/index.d.ts +1 -1
- package/dist/datasources/index.js +1 -2
- package/dist/datasources/{kvmem → memory}/datasource.js +3 -4
- package/dist/datasources/{kvmem → memory}/index.js +0 -1
- package/dist/datasources/postgres/datasource.js +10 -11
- package/dist/datasources/postgres/index.js +0 -1
- package/dist/datasources/postgres/types.js +0 -1
- package/dist/datasources/redis/connector.js +18 -8
- package/dist/datasources/redis/datasource.js +7 -8
- package/dist/datasources/redis/index.js +0 -1
- package/dist/datasources/redis/types.js +0 -1
- package/dist/helpers/application-environment.helper.js +3 -4
- package/dist/helpers/cron.helper.js +9 -15
- package/dist/helpers/crypto/algorithms/aes.algorithm.js +8 -8
- package/dist/helpers/crypto/algorithms/base.algorithm.js +3 -5
- package/dist/helpers/crypto/algorithms/index.js +0 -1
- package/dist/helpers/crypto/algorithms/rsa.algorithm.js +4 -6
- package/dist/helpers/crypto/common/constants.js +0 -1
- package/dist/helpers/crypto/common/index.js +0 -1
- package/dist/helpers/crypto/common/types.js +0 -1
- package/dist/helpers/crypto/index.js +0 -1
- package/dist/helpers/database/index.js +0 -1
- package/dist/helpers/database/query-builder.helper.js +2 -6
- package/dist/helpers/index.js +0 -1
- package/dist/helpers/logger/application-logger.js +7 -18
- package/dist/helpers/logger/common/index.js +0 -1
- package/dist/helpers/logger/common/types.js +20 -23
- package/dist/helpers/logger/default-logger.js +2 -13
- package/dist/helpers/logger/factory.js +1 -2
- package/dist/helpers/logger/index.js +0 -1
- package/dist/helpers/logger/transports/dgram.transport.js +16 -26
- package/dist/helpers/logger/transports/index.js +0 -1
- package/dist/helpers/network/http-request/base-network-request.helper.d.ts +3 -0
- package/dist/helpers/network/http-request/base-network-request.helper.js +39 -35
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.d.ts +2 -3
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.js +10 -23
- package/dist/helpers/network/http-request/fetcher/base-fetcher.d.ts +5 -1
- package/dist/helpers/network/http-request/fetcher/base-fetcher.js +16 -37
- package/dist/helpers/network/http-request/fetcher/index.js +0 -1
- package/dist/helpers/network/http-request/fetcher/node-fetcher.d.ts +2 -2
- package/dist/helpers/network/http-request/fetcher/node-fetcher.js +28 -13
- package/dist/helpers/network/http-request/index.js +0 -1
- package/dist/helpers/network/http-request/types.d.ts +2 -1
- package/dist/helpers/network/http-request/types.js +0 -1
- package/dist/helpers/network/index.js +0 -1
- package/dist/helpers/network/tcp-socket/base-tcp-client.helper.js +30 -28
- package/dist/helpers/network/tcp-socket/base-tcp-server.helper.js +21 -20
- package/dist/helpers/network/tcp-socket/index.js +0 -1
- package/dist/helpers/network/tcp-socket/network-tcp-client.helper.js +5 -2
- package/dist/helpers/network/tcp-socket/network-tcp-server.helper.js +5 -2
- package/dist/helpers/network/tcp-socket/network-tls-tcp-client.helper.js +5 -2
- package/dist/helpers/network/tcp-socket/network-tls-tcp-server.helper.js +5 -2
- package/dist/helpers/network/udp-socket/index.js +0 -1
- package/dist/helpers/network/udp-socket/network-udp-client.helper.js +21 -19
- package/dist/helpers/queue/bullmq.helper.js +21 -23
- package/dist/helpers/queue/index.js +0 -1
- package/dist/helpers/queue/mqtt.helper.js +15 -18
- package/dist/helpers/queue/queue.helper.js +74 -146
- package/dist/helpers/redis/default.helper.js +117 -163
- package/dist/helpers/redis/index.js +0 -1
- package/dist/helpers/redis/redis-cluster.helper.js +7 -3
- package/dist/helpers/redis/redis.helper.js +8 -6
- package/dist/helpers/redis/types.js +0 -1
- package/dist/helpers/storage/di-container.helper.js +2 -1
- package/dist/helpers/storage/index.js +0 -1
- package/dist/helpers/storage/minio.helper.js +88 -129
- package/dist/helpers/testing/common.js +3 -4
- package/dist/helpers/testing/describe.js +14 -22
- package/dist/helpers/testing/index.js +0 -1
- package/dist/helpers/testing/test-case.js +5 -1
- package/dist/helpers/testing/test-handler.js +23 -31
- package/dist/helpers/testing/test-plan/base.js +9 -7
- package/dist/helpers/testing/test-plan/default.js +0 -1
- package/dist/helpers/testing/test-plan/index.js +0 -1
- package/dist/helpers/testing/types.js +0 -1
- package/dist/helpers/worker-thread/base.js +10 -21
- package/dist/helpers/worker-thread/index.js +0 -1
- package/dist/helpers/worker-thread/types.js +0 -1
- package/dist/helpers/worker-thread/worker-bus.js +11 -13
- package/dist/helpers/worker-thread/worker-pool.js +17 -26
- package/dist/index.js +0 -1
- package/dist/interceptors/content-range.interceptor.js +115 -133
- package/dist/interceptors/index.js +0 -1
- package/dist/middlewares/index.js +0 -1
- package/dist/middlewares/request-body-parser.middleware.js +4 -17
- package/dist/middlewares/request-spy.middleware.js +4 -6
- package/dist/migrations/base-path.js +0 -1
- package/dist/migrations/handler.js +13 -23
- package/dist/migrations/index.js +0 -1
- package/dist/mixins/data-type.mixin.js +5 -1
- package/dist/mixins/deprecated/user-audit.mixin.d.ts +0 -3
- package/dist/mixins/deprecated/user-audit.mixin.js +2 -6
- package/dist/mixins/duplicatable.mixin.js +1 -1
- package/dist/mixins/index.js +0 -1
- package/dist/mixins/object-search.mixin.js +1 -1
- package/dist/mixins/principal.mixin.js +2 -1
- package/dist/mixins/soft-delete.mixin.js +1 -1
- package/dist/mixins/soft-persistent.mixin.js +1 -1
- package/dist/mixins/text-search.mixin.js +1 -1
- package/dist/mixins/tz.mixin.js +2 -1
- package/dist/mixins/user-audit.mixin.js +5 -4
- package/dist/mixins/vector.mixin.js +9 -7
- package/dist/tsconfig.base.json +11 -4
- package/dist/utilities/crypto.utility.js +0 -1
- package/dist/utilities/date.utility.js +5 -24
- package/dist/utilities/error.utility.js +2 -1
- package/dist/utilities/index.js +0 -1
- package/dist/utilities/model.utility.js +2 -7
- package/dist/utilities/parse.utility.d.ts +0 -16
- package/dist/utilities/parse.utility.js +6 -42
- package/dist/utilities/performance.utility.js +1 -3
- package/dist/utilities/promise.utility.d.ts +0 -17
- package/dist/utilities/promise.utility.js +5 -32
- package/dist/utilities/query.utility.js +8 -17
- package/dist/utilities/request.utility.js +2 -9
- package/dist/utilities/url.utility.js +0 -1
- package/package.json +11 -7
- package/dist/base/applications/base.application.js.map +0 -1
- package/dist/base/applications/default.application.js.map +0 -1
- package/dist/base/applications/index.js.map +0 -1
- package/dist/base/base.component.js.map +0 -1
- package/dist/base/base.helper.js.map +0 -1
- package/dist/base/base.provider.js.map +0 -1
- package/dist/base/base.sequence.js.map +0 -1
- package/dist/base/controllers/common.js.map +0 -1
- package/dist/base/controllers/crud.controller.js.map +0 -1
- package/dist/base/controllers/index.js.map +0 -1
- package/dist/base/controllers/kv.controller.js.map +0 -1
- package/dist/base/controllers/relational.controller.js.map +0 -1
- package/dist/base/controllers/service-crud.controller.js.map +0 -1
- package/dist/base/datasources/base.datasource.js.map +0 -1
- package/dist/base/datasources/index.js.map +0 -1
- package/dist/base/datasources/types.js.map +0 -1
- package/dist/base/index.js.map +0 -1
- package/dist/base/loopback/@lb/auth/index.js.map +0 -1
- package/dist/base/loopback/@lb/core/index.js.map +0 -1
- package/dist/base/loopback/@lb/repository/index.js.map +0 -1
- package/dist/base/loopback/@lb/rest/index.js.map +0 -1
- package/dist/base/loopback/authentication/index.js.map +0 -1
- package/dist/base/loopback/authorization/index.js.map +0 -1
- package/dist/base/loopback/boot/index.js.map +0 -1
- package/dist/base/loopback/core/index.js.map +0 -1
- package/dist/base/loopback/filter/index.js.map +0 -1
- package/dist/base/loopback/http-server/index.js.map +0 -1
- package/dist/base/loopback/metadata/index.js.map +0 -1
- package/dist/base/loopback/repository/index.js.map +0 -1
- package/dist/base/loopback/rest/index.js.map +0 -1
- package/dist/base/loopback/security/index.js.map +0 -1
- package/dist/base/loopback/service-proxy/index.js.map +0 -1
- package/dist/base/models/base.model.js.map +0 -1
- package/dist/base/models/index.js.map +0 -1
- package/dist/base/repositories/base.repository.js.map +0 -1
- package/dist/base/repositories/index.js.map +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/decorator.js.map +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/factory.js.map +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/index.js.map +0 -1
- package/dist/base/repositories/relations/has-many-polymorphic/types.js.map +0 -1
- package/dist/base/repositories/relations/index.js.map +0 -1
- package/dist/base/repositories/searchable-tz-crud.repository.js.map +0 -1
- package/dist/base/repositories/tz-crud.repository.js.map +0 -1
- package/dist/base/services/base-crud.service.js.map +0 -1
- package/dist/base/services/base.service.js.map +0 -1
- package/dist/base/services/index.js.map +0 -1
- package/dist/common/constants.js.map +0 -1
- package/dist/common/environments.js.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/common/keys.js.map +0 -1
- package/dist/common/statuses.js.map +0 -1
- package/dist/common/types.js.map +0 -1
- package/dist/components/authenticate/common/constants.js.map +0 -1
- package/dist/components/authenticate/common/index.js.map +0 -1
- package/dist/components/authenticate/common/keys.js.map +0 -1
- package/dist/components/authenticate/common/types.js.map +0 -1
- package/dist/components/authenticate/component.js.map +0 -1
- package/dist/components/authenticate/controllers/auth.controller.js.map +0 -1
- package/dist/components/authenticate/controllers/index.js.map +0 -1
- package/dist/components/authenticate/controllers/oauth2.controller.js.map +0 -1
- package/dist/components/authenticate/index.js.map +0 -1
- package/dist/components/authenticate/middleware.js.map +0 -1
- package/dist/components/authenticate/models/index.js.map +0 -1
- package/dist/components/authenticate/models/oauth2-client.model.js.map +0 -1
- package/dist/components/authenticate/models/oauth2-scope.model.js.map +0 -1
- package/dist/components/authenticate/models/oauth2-token.model.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/authorization-code.handler.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/base.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/client-credential.handler.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/index.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/oauth2.js.map +0 -1
- package/dist/components/authenticate/oauth2-handlers/password.handler.js.map +0 -1
- package/dist/components/authenticate/repositories/index.js.map +0 -1
- package/dist/components/authenticate/repositories/oauth2.repository.js.map +0 -1
- package/dist/components/authenticate/services/basic-token.service.js.map +0 -1
- package/dist/components/authenticate/services/basic.strategy.js.map +0 -1
- package/dist/components/authenticate/services/index.js.map +0 -1
- package/dist/components/authenticate/services/jwt-token.service.js.map +0 -1
- package/dist/components/authenticate/services/jwt.strategy.js.map +0 -1
- package/dist/components/authenticate/services/oauth2.service.js.map +0 -1
- package/dist/components/authenticate/services/oauth2.strategy.js.map +0 -1
- package/dist/components/authorize/adapters/adapter-builder.js.map +0 -1
- package/dist/components/authorize/adapters/base.adapter.js.map +0 -1
- package/dist/components/authorize/adapters/casbin-postgres-adapter.helper.js.map +0 -1
- package/dist/components/authorize/adapters/casbin-redis-adapter.helper.js.map +0 -1
- package/dist/components/authorize/adapters/index.js.map +0 -1
- package/dist/components/authorize/common/constants.js.map +0 -1
- package/dist/components/authorize/common/index.js.map +0 -1
- package/dist/components/authorize/common/keys.js.map +0 -1
- package/dist/components/authorize/common/types.js.map +0 -1
- package/dist/components/authorize/component.js.map +0 -1
- package/dist/components/authorize/decorators/index.js.map +0 -1
- package/dist/components/authorize/index.js.map +0 -1
- package/dist/components/authorize/interceptor.js.map +0 -1
- package/dist/components/authorize/migrations/0000-create-view-policy.js.map +0 -1
- package/dist/components/authorize/migrations/index.js.map +0 -1
- package/dist/components/authorize/models/defs.js.map +0 -1
- package/dist/components/authorize/models/index.js.map +0 -1
- package/dist/components/authorize/models/permission-mapping.model.js.map +0 -1
- package/dist/components/authorize/models/permission.model.js.map +0 -1
- package/dist/components/authorize/models/role.model.js.map +0 -1
- package/dist/components/authorize/models/user-role.model.js.map +0 -1
- package/dist/components/authorize/models/view-authorize-policy.model.js.map +0 -1
- package/dist/components/authorize/provider.js.map +0 -1
- package/dist/components/authorize/repositories/authorize.repository.js.map +0 -1
- package/dist/components/authorize/repositories/index.js.map +0 -1
- package/dist/components/authorize/services/enforcer.service.js.map +0 -1
- package/dist/components/authorize/services/generator.service.js.map +0 -1
- package/dist/components/authorize/services/index.js.map +0 -1
- package/dist/components/crash-report/common/constants.js.map +0 -1
- package/dist/components/crash-report/common/index.js.map +0 -1
- package/dist/components/crash-report/common/keys.js.map +0 -1
- package/dist/components/crash-report/common/types.js.map +0 -1
- package/dist/components/crash-report/component.js.map +0 -1
- package/dist/components/crash-report/index.js.map +0 -1
- package/dist/components/crash-report/providers/index.js.map +0 -1
- package/dist/components/crash-report/providers/provider.js.map +0 -1
- package/dist/components/crash-report/providers/third-parties/base.js.map +0 -1
- package/dist/components/crash-report/providers/third-parties/index.js.map +0 -1
- package/dist/components/crash-report/services/index.js.map +0 -1
- package/dist/components/crash-report/services/mt-crash-report.service.js.map +0 -1
- package/dist/components/grpc/common/constants.js.map +0 -1
- package/dist/components/grpc/common/index.js.map +0 -1
- package/dist/components/grpc/common/keys.js.map +0 -1
- package/dist/components/grpc/common/types.js.map +0 -1
- package/dist/components/grpc/components/index.js.map +0 -1
- package/dist/components/grpc/components/server.component.js.map +0 -1
- package/dist/components/grpc/controllers/base.js.map +0 -1
- package/dist/components/grpc/controllers/index.js.map +0 -1
- package/dist/components/grpc/decorators/index.js.map +0 -1
- package/dist/components/grpc/helpers/grpc-client.js.map +0 -1
- package/dist/components/grpc/helpers/grpc-server.js.map +0 -1
- package/dist/components/grpc/helpers/index.js.map +0 -1
- package/dist/components/grpc/index.js.map +0 -1
- package/dist/components/grpc/persistents/grpc.connector.js.map +0 -1
- package/dist/components/grpc/persistents/grpc.datasource.js.map +0 -1
- package/dist/components/grpc/persistents/grpc.repository.js.map +0 -1
- package/dist/components/grpc/persistents/index.js.map +0 -1
- package/dist/components/index.js.map +0 -1
- package/dist/components/migration/common/index.js.map +0 -1
- package/dist/components/migration/common/keys.js.map +0 -1
- package/dist/components/migration/common/types.js.map +0 -1
- package/dist/components/migration/component.js.map +0 -1
- package/dist/components/migration/index.js.map +0 -1
- package/dist/components/migration/models/index.js.map +0 -1
- package/dist/components/migration/models/migration.model.js.map +0 -1
- package/dist/components/migration/repositories/index.js.map +0 -1
- package/dist/components/migration/repositories/migration.repository.js.map +0 -1
- package/dist/components/socket-io/common/constants.js.map +0 -1
- package/dist/components/socket-io/common/index.js.map +0 -1
- package/dist/components/socket-io/common/keys.js.map +0 -1
- package/dist/components/socket-io/component.js.map +0 -1
- package/dist/components/socket-io/helpers/index.js.map +0 -1
- package/dist/components/socket-io/helpers/socket-io-client.helper.js.map +0 -1
- package/dist/components/socket-io/helpers/socket-io-server.helper.js.map +0 -1
- package/dist/components/socket-io/index.js.map +0 -1
- package/dist/components/static-asset/common/index.js.map +0 -1
- package/dist/components/static-asset/common/keys.js.map +0 -1
- package/dist/components/static-asset/component.js.map +0 -1
- package/dist/components/static-asset/controllers/asset.controller.js.map +0 -1
- package/dist/components/static-asset/controllers/index.js.map +0 -1
- package/dist/components/static-asset/controllers/resource.controller.js.map +0 -1
- package/dist/components/static-asset/index.js.map +0 -1
- package/dist/datasources/index.js.map +0 -1
- package/dist/datasources/kvmem/datasource.js.map +0 -1
- package/dist/datasources/kvmem/index.js.map +0 -1
- package/dist/datasources/postgres/datasource.js.map +0 -1
- package/dist/datasources/postgres/index.js.map +0 -1
- package/dist/datasources/postgres/types.js.map +0 -1
- package/dist/datasources/redis/connector.js.map +0 -1
- package/dist/datasources/redis/datasource.js.map +0 -1
- package/dist/datasources/redis/index.js.map +0 -1
- package/dist/datasources/redis/types.js.map +0 -1
- package/dist/helpers/application-environment.helper.js.map +0 -1
- package/dist/helpers/cron.helper.js.map +0 -1
- package/dist/helpers/crypto/algorithms/aes.algorithm.js.map +0 -1
- package/dist/helpers/crypto/algorithms/base.algorithm.js.map +0 -1
- package/dist/helpers/crypto/algorithms/index.js.map +0 -1
- package/dist/helpers/crypto/algorithms/rsa.algorithm.js.map +0 -1
- package/dist/helpers/crypto/common/constants.js.map +0 -1
- package/dist/helpers/crypto/common/index.js.map +0 -1
- package/dist/helpers/crypto/common/types.js.map +0 -1
- package/dist/helpers/crypto/index.js.map +0 -1
- package/dist/helpers/database/index.js.map +0 -1
- package/dist/helpers/database/query-builder.helper.js.map +0 -1
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/logger/application-logger.js.map +0 -1
- package/dist/helpers/logger/common/index.js.map +0 -1
- package/dist/helpers/logger/common/types.js.map +0 -1
- package/dist/helpers/logger/default-logger.js.map +0 -1
- package/dist/helpers/logger/factory.js.map +0 -1
- package/dist/helpers/logger/index.js.map +0 -1
- package/dist/helpers/logger/transports/dgram.transport.js.map +0 -1
- package/dist/helpers/logger/transports/index.js.map +0 -1
- package/dist/helpers/network/http-request/base-network-request.helper.js.map +0 -1
- package/dist/helpers/network/http-request/fetcher/axios-fetcher.js.map +0 -1
- package/dist/helpers/network/http-request/fetcher/base-fetcher.js.map +0 -1
- package/dist/helpers/network/http-request/fetcher/index.js.map +0 -1
- package/dist/helpers/network/http-request/fetcher/node-fetcher.js.map +0 -1
- package/dist/helpers/network/http-request/index.js.map +0 -1
- package/dist/helpers/network/http-request/types.js.map +0 -1
- package/dist/helpers/network/index.js.map +0 -1
- package/dist/helpers/network/tcp-socket/base-tcp-client.helper.js.map +0 -1
- package/dist/helpers/network/tcp-socket/base-tcp-server.helper.js.map +0 -1
- package/dist/helpers/network/tcp-socket/index.js.map +0 -1
- package/dist/helpers/network/tcp-socket/network-tcp-client.helper.js.map +0 -1
- package/dist/helpers/network/tcp-socket/network-tcp-server.helper.js.map +0 -1
- package/dist/helpers/network/tcp-socket/network-tls-tcp-client.helper.js.map +0 -1
- package/dist/helpers/network/tcp-socket/network-tls-tcp-server.helper.js.map +0 -1
- package/dist/helpers/network/udp-socket/index.js.map +0 -1
- package/dist/helpers/network/udp-socket/network-udp-client.helper.js.map +0 -1
- package/dist/helpers/queue/bullmq.helper.js.map +0 -1
- package/dist/helpers/queue/index.js.map +0 -1
- package/dist/helpers/queue/mqtt.helper.js.map +0 -1
- package/dist/helpers/queue/queue.helper.js.map +0 -1
- package/dist/helpers/redis/default.helper.js.map +0 -1
- package/dist/helpers/redis/index.js.map +0 -1
- package/dist/helpers/redis/redis-cluster.helper.js.map +0 -1
- package/dist/helpers/redis/redis.helper.js.map +0 -1
- package/dist/helpers/redis/types.js.map +0 -1
- package/dist/helpers/storage/di-container.helper.js.map +0 -1
- package/dist/helpers/storage/index.js.map +0 -1
- package/dist/helpers/storage/minio.helper.js.map +0 -1
- package/dist/helpers/testing/common.js.map +0 -1
- package/dist/helpers/testing/describe.js.map +0 -1
- package/dist/helpers/testing/index.js.map +0 -1
- package/dist/helpers/testing/test-case.js.map +0 -1
- package/dist/helpers/testing/test-handler.js.map +0 -1
- package/dist/helpers/testing/test-plan/base.js.map +0 -1
- package/dist/helpers/testing/test-plan/default.js.map +0 -1
- package/dist/helpers/testing/test-plan/index.js.map +0 -1
- package/dist/helpers/testing/types.js.map +0 -1
- package/dist/helpers/worker-thread/base.js.map +0 -1
- package/dist/helpers/worker-thread/index.js.map +0 -1
- package/dist/helpers/worker-thread/types.js.map +0 -1
- package/dist/helpers/worker-thread/worker-bus.js.map +0 -1
- package/dist/helpers/worker-thread/worker-pool.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interceptors/content-range.interceptor.js.map +0 -1
- package/dist/interceptors/index.js.map +0 -1
- package/dist/middlewares/index.js.map +0 -1
- package/dist/middlewares/request-body-parser.middleware.js.map +0 -1
- package/dist/middlewares/request-spy.middleware.js.map +0 -1
- package/dist/migrations/base-path.js.map +0 -1
- package/dist/migrations/handler.js.map +0 -1
- package/dist/migrations/index.js.map +0 -1
- package/dist/mixins/data-type.mixin.js.map +0 -1
- package/dist/mixins/deprecated/user-audit.mixin.js.map +0 -1
- package/dist/mixins/duplicatable.mixin.js.map +0 -1
- package/dist/mixins/index.js.map +0 -1
- package/dist/mixins/object-search.mixin.js.map +0 -1
- package/dist/mixins/principal.mixin.js.map +0 -1
- package/dist/mixins/soft-delete.mixin.js.map +0 -1
- package/dist/mixins/soft-persistent.mixin.js.map +0 -1
- package/dist/mixins/text-search.mixin.js.map +0 -1
- package/dist/mixins/tz.mixin.js.map +0 -1
- package/dist/mixins/user-audit.mixin.js.map +0 -1
- package/dist/mixins/vector.mixin.js.map +0 -1
- package/dist/utilities/crypto.utility.js.map +0 -1
- package/dist/utilities/date.utility.js.map +0 -1
- package/dist/utilities/error.utility.js.map +0 -1
- package/dist/utilities/index.js.map +0 -1
- package/dist/utilities/model.utility.js.map +0 -1
- package/dist/utilities/parse.utility.js.map +0 -1
- package/dist/utilities/performance.utility.js.map +0 -1
- package/dist/utilities/promise.utility.js.map +0 -1
- package/dist/utilities/query.utility.js.map +0 -1
- package/dist/utilities/request.utility.js.map +0 -1
- package/dist/utilities/url.utility.js.map +0 -1
- /package/dist/datasources/{kvmem → memory}/datasource.d.ts +0 -0
- /package/dist/datasources/{kvmem → memory}/index.d.ts +0 -0
|
@@ -8,28 +8,37 @@ const base_helper_1 = require("../../../base/base.helper");
|
|
|
8
8
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
9
9
|
const DEFAULT_MAX_RETRY = 5;
|
|
10
10
|
class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
11
|
+
client;
|
|
12
|
+
options;
|
|
13
|
+
reconnect;
|
|
14
|
+
retry = {
|
|
15
|
+
maxReconnect: DEFAULT_MAX_RETRY,
|
|
16
|
+
currentReconnect: 0,
|
|
17
|
+
};
|
|
18
|
+
reconnectTimeout;
|
|
19
|
+
encoding;
|
|
20
|
+
createClientFn;
|
|
21
|
+
onConnected;
|
|
22
|
+
onData;
|
|
23
|
+
onClosed;
|
|
24
|
+
onError;
|
|
11
25
|
constructor(opts) {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
13
26
|
super({
|
|
14
|
-
scope:
|
|
27
|
+
scope: opts.scope ?? opts.identifier ?? BaseNetworkTcpClient.name,
|
|
15
28
|
identifier: opts.identifier,
|
|
16
29
|
});
|
|
17
|
-
this.retry = {
|
|
18
|
-
maxReconnect: DEFAULT_MAX_RETRY,
|
|
19
|
-
currentReconnect: 0,
|
|
20
|
-
};
|
|
21
30
|
this.options = opts.options;
|
|
22
31
|
this.retry = {
|
|
23
|
-
maxReconnect:
|
|
32
|
+
maxReconnect: opts.maxRetry ?? DEFAULT_MAX_RETRY,
|
|
24
33
|
currentReconnect: 0,
|
|
25
34
|
};
|
|
26
35
|
this.createClientFn = opts.createClientFn;
|
|
27
|
-
this.onConnected =
|
|
28
|
-
this.onData =
|
|
29
|
-
this.onClosed =
|
|
30
|
-
this.onError =
|
|
31
|
-
this.reconnect =
|
|
32
|
-
this.encoding = opts
|
|
36
|
+
this.onConnected = opts?.onConnected ?? this.handleConnected;
|
|
37
|
+
this.onData = opts?.onData ?? this.handleData;
|
|
38
|
+
this.onClosed = opts?.onClosed ?? this.handleClosed;
|
|
39
|
+
this.onError = opts?.onError ?? this.handleError;
|
|
40
|
+
this.reconnect = opts?.reconnect ?? false;
|
|
41
|
+
this.encoding = opts?.encoding;
|
|
33
42
|
}
|
|
34
43
|
getClient() {
|
|
35
44
|
return this.client;
|
|
@@ -53,8 +62,7 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
53
62
|
return;
|
|
54
63
|
}
|
|
55
64
|
this.reconnectTimeout = setTimeout(() => {
|
|
56
|
-
|
|
57
|
-
(_a = this.client) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
65
|
+
this.client?.destroy();
|
|
58
66
|
this.client = null;
|
|
59
67
|
this.logger.info('[handleClosed][%s] Retrying to establish TCP Connection | Options: %j', this.identifier, this.options);
|
|
60
68
|
this.connect({ resetReconnectCounter: false });
|
|
@@ -62,7 +70,6 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
62
70
|
}, 5000);
|
|
63
71
|
}
|
|
64
72
|
connect(opts) {
|
|
65
|
-
var _a;
|
|
66
73
|
if (this.isConnected()) {
|
|
67
74
|
this.logger.info('[connect][%s] NetworkTcpClient is already initialized!', this.identifier);
|
|
68
75
|
return;
|
|
@@ -72,20 +79,19 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
72
79
|
return;
|
|
73
80
|
}
|
|
74
81
|
this.logger.info('[connect][%s] New network tcp client | Options: %s', this.identifier, this.options);
|
|
75
|
-
if (opts
|
|
82
|
+
if (opts?.resetReconnectCounter) {
|
|
76
83
|
this.retry.currentReconnect = 0;
|
|
77
84
|
}
|
|
78
85
|
if (this.client !== null && this.client !== undefined) {
|
|
79
|
-
|
|
86
|
+
this.client?.destroy();
|
|
80
87
|
this.client = null;
|
|
81
88
|
}
|
|
82
89
|
this.client = this.createClientFn(this.options, () => {
|
|
83
|
-
var _a;
|
|
84
90
|
if (!this.client) {
|
|
85
91
|
this.logger.error('[createClientFn] Failed to initialize socket client!');
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
|
-
|
|
94
|
+
this.onConnected?.({ client: this.client });
|
|
89
95
|
});
|
|
90
96
|
if (this.encoding) {
|
|
91
97
|
this.client.setEncoding(this.encoding);
|
|
@@ -94,24 +100,21 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
94
100
|
this.onData({ identifier: this.identifier, message });
|
|
95
101
|
});
|
|
96
102
|
this.client.on('close', () => {
|
|
97
|
-
var _a;
|
|
98
103
|
if (!this.client) {
|
|
99
104
|
return;
|
|
100
105
|
}
|
|
101
|
-
|
|
106
|
+
this.onClosed?.({ client: this.client });
|
|
102
107
|
});
|
|
103
108
|
this.client.on('error', error => {
|
|
104
|
-
|
|
105
|
-
(_a = this.onError) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
109
|
+
this.onError?.(error);
|
|
106
110
|
});
|
|
107
111
|
}
|
|
108
112
|
disconnect() {
|
|
109
|
-
var _a;
|
|
110
113
|
if (!this.client) {
|
|
111
114
|
this.logger.info('[disconnect][%s] NetworkTcpClient is not initialized yet!', this.identifier);
|
|
112
115
|
return;
|
|
113
116
|
}
|
|
114
|
-
|
|
117
|
+
this.client?.destroy();
|
|
115
118
|
this.client = null;
|
|
116
119
|
clearTimeout(this.reconnectTimeout);
|
|
117
120
|
this.reconnectTimeout = null;
|
|
@@ -130,7 +133,7 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
130
133
|
return;
|
|
131
134
|
}
|
|
132
135
|
const { payload } = opts;
|
|
133
|
-
if (!
|
|
136
|
+
if (!payload?.length) {
|
|
134
137
|
this.logger.info('[emit][%s] Invalid payload to write to TCP Socket!', this.identifier);
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
@@ -138,4 +141,3 @@ class BaseNetworkTcpClient extends base_helper_1.BaseHelper {
|
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
exports.BaseNetworkTcpClient = BaseNetworkTcpClient;
|
|
141
|
-
//# sourceMappingURL=base-tcp-client.helper.js.map
|
|
@@ -10,14 +10,23 @@ const date_utility_1 = require("../../../utilities/date.utility");
|
|
|
10
10
|
const parse_utility_1 = require("../../../utilities/parse.utility");
|
|
11
11
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
12
12
|
class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
13
|
+
serverOptions = {};
|
|
14
|
+
listenOptions = {};
|
|
15
|
+
authenticateOptions;
|
|
16
|
+
clients;
|
|
17
|
+
server;
|
|
18
|
+
extraEvents;
|
|
19
|
+
createServerFn;
|
|
20
|
+
onServerReady;
|
|
21
|
+
onClientConnected;
|
|
22
|
+
onClientData;
|
|
23
|
+
onClientClose;
|
|
24
|
+
onClientError;
|
|
13
25
|
constructor(opts) {
|
|
14
|
-
var _a, _b, _c;
|
|
15
26
|
super({
|
|
16
|
-
scope:
|
|
27
|
+
scope: opts.scope ?? opts.identifier ?? BaseNetworkTcpServer.name,
|
|
17
28
|
identifier: opts.identifier,
|
|
18
29
|
});
|
|
19
|
-
this.serverOptions = {};
|
|
20
|
-
this.listenOptions = {};
|
|
21
30
|
this.clients = Object.assign({});
|
|
22
31
|
this.serverOptions = opts.serverOptions;
|
|
23
32
|
this.listenOptions = opts.listenOptions;
|
|
@@ -28,7 +37,7 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
28
37
|
message: 'TCP Server | Invalid authenticate duration | Required duration for authenticateOptions',
|
|
29
38
|
});
|
|
30
39
|
}
|
|
31
|
-
this.extraEvents =
|
|
40
|
+
this.extraEvents = opts.extraEvents ?? {};
|
|
32
41
|
this.createServerFn = opts.createServerFn;
|
|
33
42
|
this.onServerReady = opts.onServerReady;
|
|
34
43
|
this.onClientConnected = opts.onClientConnected;
|
|
@@ -41,29 +50,24 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
41
50
|
this.onNewConnection({ socket });
|
|
42
51
|
});
|
|
43
52
|
this.server.listen(this.listenOptions, () => {
|
|
44
|
-
var _a;
|
|
45
53
|
this.logger.info('[configure] TCP Socket Server is now listening | Options: %j', this.listenOptions);
|
|
46
|
-
|
|
54
|
+
this.onServerReady?.({ server: this.server });
|
|
47
55
|
});
|
|
48
56
|
}
|
|
49
57
|
onNewConnection(opts) {
|
|
50
|
-
var _a;
|
|
51
58
|
const { socket } = opts;
|
|
52
59
|
const id = (0, parse_utility_1.getUID)();
|
|
53
60
|
socket.on('data', (data) => {
|
|
54
|
-
|
|
55
|
-
(_a = this.onClientData) === null || _a === void 0 ? void 0 : _a.call(this, { id, socket, data });
|
|
61
|
+
this.onClientData?.({ id, socket, data });
|
|
56
62
|
});
|
|
57
63
|
socket.on('error', (error) => {
|
|
58
|
-
var _a;
|
|
59
64
|
this.logger.error('[onClientConnect][error] ID: %s | Error: %s', id, error);
|
|
60
|
-
|
|
65
|
+
this.onClientError?.({ id, socket, error });
|
|
61
66
|
socket.end();
|
|
62
67
|
});
|
|
63
68
|
socket.on('close', (hasError) => {
|
|
64
|
-
var _a;
|
|
65
69
|
this.logger.info('[onClientConnect][close] ID: %s | hasError: %s', id, hasError);
|
|
66
|
-
|
|
70
|
+
this.onClientClose?.({ id, socket });
|
|
67
71
|
this.clients = (0, omit_1.default)(this.clients, [id]);
|
|
68
72
|
});
|
|
69
73
|
for (const extraEvent in this.extraEvents) {
|
|
@@ -82,8 +86,7 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
82
86
|
},
|
|
83
87
|
};
|
|
84
88
|
this.logger.info('[onClientConnect] New TCP SocketClient | Client: %s | authenticateOptions: %s %s', `${id} - ${socket.remoteAddress} - ${socket.remotePort} - ${socket.remoteFamily}`, this.authenticateOptions.required, this.authenticateOptions.duration);
|
|
85
|
-
|
|
86
|
-
// Check client authentication
|
|
89
|
+
this.onClientConnected?.({ id, socket });
|
|
87
90
|
if (this.authenticateOptions.required &&
|
|
88
91
|
this.authenticateOptions.duration &&
|
|
89
92
|
this.authenticateOptions.duration > 0) {
|
|
@@ -104,8 +107,7 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
104
107
|
return this.clients;
|
|
105
108
|
}
|
|
106
109
|
getClient(opts) {
|
|
107
|
-
|
|
108
|
-
return (_a = this.clients) === null || _a === void 0 ? void 0 : _a[opts.id];
|
|
110
|
+
return this.clients?.[opts.id];
|
|
109
111
|
}
|
|
110
112
|
getServer() {
|
|
111
113
|
return this.server;
|
|
@@ -145,7 +147,7 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
145
147
|
this.logger.error('[emit][%s] Client %s NOT WRITABLE', clientId);
|
|
146
148
|
return;
|
|
147
149
|
}
|
|
148
|
-
if (!
|
|
150
|
+
if (!payload?.length) {
|
|
149
151
|
this.logger.info('[emit][%s] Client %s | Invalid payload to write to TCP Socket!', this.identifier, clientId);
|
|
150
152
|
return;
|
|
151
153
|
}
|
|
@@ -153,4 +155,3 @@ class BaseNetworkTcpServer extends base_helper_1.BaseHelper {
|
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
exports.BaseNetworkTcpServer = BaseNetworkTcpServer;
|
|
156
|
-
//# sourceMappingURL=base-tcp-server.helper.js.map
|
|
@@ -20,4 +20,3 @@ __exportStar(require("./network-tcp-client.helper"), exports);
|
|
|
20
20
|
__exportStar(require("./network-tcp-server.helper"), exports);
|
|
21
21
|
__exportStar(require("./network-tls-tcp-client.helper"), exports);
|
|
22
22
|
__exportStar(require("./network-tls-tcp-server.helper"), exports);
|
|
23
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,11 @@ const node_net_1 = require("node:net");
|
|
|
5
5
|
const base_tcp_client_helper_1 = require("./base-tcp-client.helper");
|
|
6
6
|
class NetworkTcpClient extends base_tcp_client_helper_1.BaseNetworkTcpClient {
|
|
7
7
|
constructor(opts) {
|
|
8
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
...opts,
|
|
10
|
+
scope: NetworkTcpClient.name,
|
|
11
|
+
createClientFn: node_net_1.connect,
|
|
12
|
+
});
|
|
9
13
|
this.options = opts.options;
|
|
10
14
|
}
|
|
11
15
|
static newInstance(opts) {
|
|
@@ -13,4 +17,3 @@ class NetworkTcpClient extends base_tcp_client_helper_1.BaseNetworkTcpClient {
|
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
exports.NetworkTcpClient = NetworkTcpClient;
|
|
16
|
-
//# sourceMappingURL=network-tcp-client.helper.js.map
|
|
@@ -5,11 +5,14 @@ const node_net_1 = require("node:net");
|
|
|
5
5
|
const base_tcp_server_helper_1 = require("./base-tcp-server.helper");
|
|
6
6
|
class NetworkTcpServer extends base_tcp_server_helper_1.BaseNetworkTcpServer {
|
|
7
7
|
constructor(opts) {
|
|
8
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
...opts,
|
|
10
|
+
scope: NetworkTcpServer.name,
|
|
11
|
+
createServerFn: node_net_1.createServer,
|
|
12
|
+
});
|
|
9
13
|
}
|
|
10
14
|
static newInstance(opts) {
|
|
11
15
|
return new NetworkTcpServer(opts);
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
exports.NetworkTcpServer = NetworkTcpServer;
|
|
15
|
-
//# sourceMappingURL=network-tcp-server.helper.js.map
|
|
@@ -5,7 +5,11 @@ const node_tls_1 = require("node:tls");
|
|
|
5
5
|
const base_tcp_client_helper_1 = require("./base-tcp-client.helper");
|
|
6
6
|
class NetworkTlsTcpClient extends base_tcp_client_helper_1.BaseNetworkTcpClient {
|
|
7
7
|
constructor(opts) {
|
|
8
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
...opts,
|
|
10
|
+
scope: NetworkTlsTcpClient.name,
|
|
11
|
+
createClientFn: node_tls_1.connect,
|
|
12
|
+
});
|
|
9
13
|
this.options = opts.options;
|
|
10
14
|
}
|
|
11
15
|
static newInstance(opts) {
|
|
@@ -13,4 +17,3 @@ class NetworkTlsTcpClient extends base_tcp_client_helper_1.BaseNetworkTcpClient
|
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
exports.NetworkTlsTcpClient = NetworkTlsTcpClient;
|
|
16
|
-
//# sourceMappingURL=network-tls-tcp-client.helper.js.map
|
|
@@ -5,11 +5,14 @@ const node_tls_1 = require("node:tls");
|
|
|
5
5
|
const base_tcp_server_helper_1 = require("./base-tcp-server.helper");
|
|
6
6
|
class NetworkTlsTcpServer extends base_tcp_server_helper_1.BaseNetworkTcpServer {
|
|
7
7
|
constructor(opts) {
|
|
8
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
...opts,
|
|
10
|
+
scope: NetworkTlsTcpServer.name,
|
|
11
|
+
createServerFn: node_tls_1.createServer,
|
|
12
|
+
});
|
|
9
13
|
}
|
|
10
14
|
static newInstance(opts) {
|
|
11
15
|
return new NetworkTlsTcpServer(opts);
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
exports.NetworkTlsTcpServer = NetworkTlsTcpServer;
|
|
15
|
-
//# sourceMappingURL=network-tls-tcp-server.helper.js.map
|
|
@@ -7,18 +7,27 @@ exports.NetworkUdpClient = void 0;
|
|
|
7
7
|
const base_helper_1 = require("../../../base/base.helper");
|
|
8
8
|
const node_dgram_1 = __importDefault(require("node:dgram"));
|
|
9
9
|
class NetworkUdpClient extends base_helper_1.BaseHelper {
|
|
10
|
+
host;
|
|
11
|
+
port;
|
|
12
|
+
reuseAddr;
|
|
13
|
+
multicastAddress;
|
|
14
|
+
onConnected;
|
|
15
|
+
onData;
|
|
16
|
+
onClosed;
|
|
17
|
+
onError;
|
|
18
|
+
onBind;
|
|
19
|
+
client;
|
|
10
20
|
constructor(opts) {
|
|
11
|
-
var _a, _b, _c, _d;
|
|
12
21
|
super({ scope: NetworkUdpClient.name, identifier: opts.identifier });
|
|
13
22
|
this.host = opts.host;
|
|
14
23
|
this.port = opts.port;
|
|
15
24
|
this.reuseAddr = opts.reuseAddr;
|
|
16
25
|
this.multicastAddress = opts.multicastAddress;
|
|
17
|
-
this.onConnected =
|
|
18
|
-
this.onData =
|
|
19
|
-
this.onClosed =
|
|
20
|
-
this.onError =
|
|
21
|
-
this.onBind = opts
|
|
26
|
+
this.onConnected = opts?.onConnected ?? this.handleConnected;
|
|
27
|
+
this.onData = opts?.onData ?? this.handleData;
|
|
28
|
+
this.onClosed = opts?.onClosed ?? this.handleClosed;
|
|
29
|
+
this.onError = opts?.onError ?? this.handleError;
|
|
30
|
+
this.onBind = opts?.onBind;
|
|
22
31
|
}
|
|
23
32
|
static newInstance(opts) {
|
|
24
33
|
return new NetworkUdpClient(opts);
|
|
@@ -64,24 +73,19 @@ class NetworkUdpClient extends base_helper_1.BaseHelper {
|
|
|
64
73
|
this.logger.info('[connect][%s] New network udp client | Host: %s | Port: %s | multicastAddress: %j', this.identifier, this.host, this.port, this.multicastAddress);
|
|
65
74
|
this.client = node_dgram_1.default.createSocket({ type: 'udp4', reuseAddr: this.reuseAddr });
|
|
66
75
|
this.client.on('close', () => {
|
|
67
|
-
|
|
68
|
-
(_a = this.onClosed) === null || _a === void 0 ? void 0 : _a.call(this, { identifier: this.identifier, host: this.host, port: this.port });
|
|
76
|
+
this.onClosed?.({ identifier: this.identifier, host: this.host, port: this.port });
|
|
69
77
|
});
|
|
70
78
|
this.client.on('error', error => {
|
|
71
|
-
|
|
72
|
-
(_a = this.onError) === null || _a === void 0 ? void 0 : _a.call(this, { identifier: this.identifier, host: this.host, port: this.port, error });
|
|
79
|
+
this.onError?.({ identifier: this.identifier, host: this.host, port: this.port, error });
|
|
73
80
|
});
|
|
74
81
|
this.client.on('listening', () => {
|
|
75
|
-
|
|
76
|
-
(_a = this.onConnected) === null || _a === void 0 ? void 0 : _a.call(this, { identifier: this.identifier, host: this.host, port: this.port });
|
|
82
|
+
this.onConnected?.({ identifier: this.identifier, host: this.host, port: this.port });
|
|
77
83
|
});
|
|
78
84
|
this.client.on('message', (message, remoteInfo) => {
|
|
79
|
-
|
|
80
|
-
(_a = this.onData) === null || _a === void 0 ? void 0 : _a.call(this, { identifier: this.identifier, message, remoteInfo });
|
|
85
|
+
this.onData?.({ identifier: this.identifier, message, remoteInfo });
|
|
81
86
|
});
|
|
82
87
|
this.client.bind({ port: this.port, address: this.host }, () => {
|
|
83
|
-
|
|
84
|
-
(_a = this.onBind) === null || _a === void 0 ? void 0 : _a.call(this, {
|
|
88
|
+
this.onBind?.({
|
|
85
89
|
identifier: this.identifier,
|
|
86
90
|
socket: this.client,
|
|
87
91
|
host: this.host,
|
|
@@ -92,12 +96,11 @@ class NetworkUdpClient extends base_helper_1.BaseHelper {
|
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
98
|
disconnect() {
|
|
95
|
-
var _a;
|
|
96
99
|
if (!this.client) {
|
|
97
100
|
this.logger.info('[disconnect][%s] UdpClient is not initialized yet!', this.identifier);
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
100
|
-
|
|
103
|
+
this.client?.close();
|
|
101
104
|
this.client = null;
|
|
102
105
|
this.logger.info('[disconnect][%s] UdpClient is destroyed!', this.identifier);
|
|
103
106
|
}
|
|
@@ -106,4 +109,3 @@ class NetworkUdpClient extends base_helper_1.BaseHelper {
|
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
111
|
exports.NetworkUdpClient = NetworkUdpClient;
|
|
109
|
-
//# sourceMappingURL=network-udp-client.helper.js.map
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.BullMQHelper = void 0;
|
|
13
4
|
const base_helper_1 = require("../../base/base.helper");
|
|
14
5
|
const bullmq_1 = require("bullmq");
|
|
15
6
|
class BullMQHelper extends base_helper_1.BaseHelper {
|
|
7
|
+
queueName;
|
|
8
|
+
role;
|
|
9
|
+
connection;
|
|
10
|
+
queue;
|
|
11
|
+
worker;
|
|
12
|
+
numberOfWorker = 1;
|
|
13
|
+
lockDuration = 90 * 60 * 1000;
|
|
14
|
+
onWorkerData;
|
|
15
|
+
onWorkerDataCompleted;
|
|
16
|
+
onWorkerDataFail;
|
|
16
17
|
constructor(options) {
|
|
17
18
|
super({ scope: BullMQHelper.name, identifier: options.identifier });
|
|
18
|
-
this.numberOfWorker = 1;
|
|
19
|
-
this.lockDuration = 90 * 60 * 1000;
|
|
20
19
|
const { queueName, connection, role, numberOfWorker = 1, lockDuration = 90 * 60 * 1000, onWorkerData, onWorkerDataCompleted, onWorkerDataFail, } = options;
|
|
21
20
|
this.queueName = queueName;
|
|
22
21
|
this.role = role;
|
|
@@ -49,31 +48,31 @@ class BullMQHelper extends base_helper_1.BaseHelper {
|
|
|
49
48
|
this.logger.error('[configureWorkers][%s] Invalid worker name', this.identifier);
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
|
-
this.worker = new bullmq_1.Worker(this.queueName, (job) =>
|
|
51
|
+
this.worker = new bullmq_1.Worker(this.queueName, async (job) => {
|
|
53
52
|
if (this.onWorkerData) {
|
|
54
|
-
const rs =
|
|
53
|
+
const rs = await this.onWorkerData(job);
|
|
55
54
|
return rs;
|
|
56
55
|
}
|
|
57
56
|
const { id, name, data } = job;
|
|
58
57
|
this.logger.info('[onWorkerData][%s] queue: %s | id: %s | name: %s | data: %j', this.identifier, this.queueName, id, name, data);
|
|
59
|
-
}
|
|
58
|
+
}, {
|
|
60
59
|
connection: this.connection,
|
|
61
60
|
concurrency: this.numberOfWorker,
|
|
62
61
|
lockDuration: this.lockDuration,
|
|
63
62
|
});
|
|
64
63
|
this.worker.on('completed', (job, result) => {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
this.onWorkerDataCompleted?.(job, result)
|
|
65
|
+
.then(() => {
|
|
66
|
+
})
|
|
67
|
+
.catch(error => {
|
|
69
68
|
this.logger.error('[Worker][%s][completed] queue: %s | Error while processing completed job! Error: %s', this.identifier, this.queueName, error);
|
|
70
69
|
});
|
|
71
70
|
});
|
|
72
71
|
this.worker.on('failed', (job, reason) => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
this.onWorkerDataFail?.(job, reason)
|
|
73
|
+
.then(() => {
|
|
74
|
+
})
|
|
75
|
+
.catch(error => {
|
|
77
76
|
this.logger.error('[Worker][%s][failed] queue: %s | Error while processing completed job! Error: %s', this.identifier, this.queueName, error);
|
|
78
77
|
});
|
|
79
78
|
});
|
|
@@ -96,4 +95,3 @@ class BullMQHelper extends base_helper_1.BaseHelper {
|
|
|
96
95
|
}
|
|
97
96
|
}
|
|
98
97
|
exports.BullMQHelper = BullMQHelper;
|
|
99
|
-
//# sourceMappingURL=bullmq.helper.js.map
|
|
@@ -9,6 +9,14 @@ const utilities_1 = require("../../utilities");
|
|
|
9
9
|
const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
10
10
|
const mqtt_1 = __importDefault(require("mqtt"));
|
|
11
11
|
class MQTTClientHelper extends base_helper_1.BaseHelper {
|
|
12
|
+
url;
|
|
13
|
+
options;
|
|
14
|
+
client;
|
|
15
|
+
onConnect;
|
|
16
|
+
onDisconnect;
|
|
17
|
+
onError;
|
|
18
|
+
onClose;
|
|
19
|
+
onMessage;
|
|
12
20
|
constructor(opts) {
|
|
13
21
|
super({ scope: MQTTClientHelper.name, identifier: opts.identifier });
|
|
14
22
|
this.url = opts.url;
|
|
@@ -20,7 +28,6 @@ class MQTTClientHelper extends base_helper_1.BaseHelper {
|
|
|
20
28
|
this.onMessage = opts.onMessage;
|
|
21
29
|
this.configure();
|
|
22
30
|
}
|
|
23
|
-
// -------------------------------------------------------------------------------
|
|
24
31
|
configure() {
|
|
25
32
|
if (this.client) {
|
|
26
33
|
this.logger.info('[configure][%s] MQTT Client already established! Client: %j', this.identifier, this.client);
|
|
@@ -35,31 +42,24 @@ class MQTTClientHelper extends base_helper_1.BaseHelper {
|
|
|
35
42
|
this.logger.info('[configure][%s] Start configuring mqtt client | Url: %s | Options: %j', this.identifier, this.url, this.options);
|
|
36
43
|
this.client = mqtt_1.default.connect(this.url, this.options);
|
|
37
44
|
this.client.on('connect', () => {
|
|
38
|
-
|
|
39
|
-
(_a = this.onConnect) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
45
|
+
this.onConnect?.();
|
|
40
46
|
});
|
|
41
47
|
this.client.on('disconnect', () => {
|
|
42
|
-
|
|
43
|
-
(_a = this.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
48
|
+
this.onDisconnect?.();
|
|
44
49
|
});
|
|
45
50
|
this.client.on('message', (topic, message) => {
|
|
46
|
-
|
|
47
|
-
(_a = this.onMessage) === null || _a === void 0 ? void 0 : _a.call(this, { topic, message });
|
|
51
|
+
this.onMessage?.({ topic, message });
|
|
48
52
|
});
|
|
49
53
|
this.client.on('error', error => {
|
|
50
|
-
|
|
51
|
-
(_a = this.onError) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
54
|
+
this.onError?.(error);
|
|
52
55
|
});
|
|
53
56
|
this.client.on('close', (error) => {
|
|
54
|
-
|
|
55
|
-
(_a = this.onClose) === null || _a === void 0 ? void 0 : _a.call(this, error);
|
|
57
|
+
this.onClose?.(error);
|
|
56
58
|
});
|
|
57
59
|
}
|
|
58
|
-
// -------------------------------------------------------------------------------
|
|
59
60
|
subscribe(opts) {
|
|
60
61
|
return new Promise((resolve, reject) => {
|
|
61
|
-
|
|
62
|
-
if (!((_a = this.client) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
62
|
+
if (!this.client?.connected) {
|
|
63
63
|
reject((0, utilities_1.getError)({
|
|
64
64
|
statusCode: 400,
|
|
65
65
|
message: `[subscribe][${this.identifier}] MQTT Client is not available to subscribe topic!`,
|
|
@@ -74,11 +74,9 @@ class MQTTClientHelper extends base_helper_1.BaseHelper {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
}
|
|
77
|
-
// -------------------------------------------------------------------------------
|
|
78
77
|
publish(opts) {
|
|
79
78
|
return new Promise((resolve, reject) => {
|
|
80
|
-
|
|
81
|
-
if (!((_a = this.client) === null || _a === void 0 ? void 0 : _a.connected)) {
|
|
79
|
+
if (!this.client?.connected) {
|
|
82
80
|
reject((0, utilities_1.getError)({
|
|
83
81
|
statusCode: 400,
|
|
84
82
|
message: `[publish][${this.identifier}] MQTT Client is not available to subscribe topic!`,
|
|
@@ -95,4 +93,3 @@ class MQTTClientHelper extends base_helper_1.BaseHelper {
|
|
|
95
93
|
}
|
|
96
94
|
}
|
|
97
95
|
exports.MQTTClientHelper = MQTTClientHelper;
|
|
98
|
-
//# sourceMappingURL=mqtt.helper.js.map
|