@venizia/ignis-helpers 0.4.8-0 → 0.4.8-2
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 +1 -0
- package/dist/esm/common/constants/app.d.ts +15 -0
- package/dist/esm/common/constants/app.js +14 -0
- package/dist/esm/common/constants/app.js.map +1 -1
- package/dist/esm/common/constants/duration.d.ts +2 -0
- package/dist/esm/common/constants/duration.js.map +1 -1
- package/dist/esm/common/constants/grpc.d.ts +3 -0
- package/dist/esm/common/constants/grpc.js +1 -0
- package/dist/esm/common/constants/grpc.js.map +1 -1
- package/dist/esm/common/constants/http.d.ts +4 -0
- package/dist/esm/common/constants/http.js +1 -0
- package/dist/esm/common/constants/http.js.map +1 -1
- package/dist/esm/common/constants/mime.d.ts +4 -0
- package/dist/esm/common/constants/mime.js +1 -0
- package/dist/esm/common/constants/mime.js.map +1 -1
- package/dist/esm/common/redact.d.ts +2 -0
- package/dist/esm/common/redact.js +2 -0
- package/dist/esm/common/redact.js.map +1 -1
- package/dist/esm/common/resolvers.d.ts +1 -0
- package/dist/esm/common/resolvers.js +1 -0
- package/dist/esm/common/resolvers.js.map +1 -1
- package/dist/esm/common/types/class.d.ts +6 -0
- package/dist/esm/common/types/class.js.map +1 -1
- package/dist/esm/common/types/const-value.d.ts +3 -0
- package/dist/esm/common/types/const-value.js.map +1 -1
- package/dist/esm/common/types/field-mapping.d.ts +3 -0
- package/dist/esm/common/types/field-mapping.js.map +1 -1
- package/dist/esm/common/types/injection.d.ts +2 -0
- package/dist/esm/common/types/injection.js.map +1 -1
- package/dist/esm/common/types/utility.d.ts +9 -0
- package/dist/esm/common/types/utility.js.map +1 -1
- package/dist/esm/modules/base.d.ts +1 -0
- package/dist/esm/modules/base.js +1 -0
- package/dist/esm/modules/base.js.map +1 -1
- package/dist/esm/modules/cron/helper.d.ts +7 -0
- package/dist/esm/modules/cron/helper.js +1 -0
- package/dist/esm/modules/cron/helper.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts +2 -0
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/base.algorithm.d.ts +1 -0
- package/dist/esm/modules/crypto/algorithms/base.algorithm.js +1 -0
- package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts +12 -4
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.js +4 -4
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.d.ts +3 -0
- package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/algorithms/rsa.algorithm.d.ts +1 -0
- package/dist/esm/modules/crypto/algorithms/rsa.algorithm.js.map +1 -1
- package/dist/esm/modules/crypto/common/constants.d.ts +12 -1
- package/dist/esm/modules/crypto/common/constants.js +9 -1
- package/dist/esm/modules/crypto/common/constants.js.map +1 -1
- package/dist/esm/modules/crypto/common/types.d.ts +1 -0
- package/dist/esm/modules/crypto/common/types.js.map +1 -1
- package/dist/esm/modules/env/app-env.d.ts +3 -0
- package/dist/esm/modules/env/app-env.js +3 -0
- package/dist/esm/modules/env/app-env.js.map +1 -1
- package/dist/esm/modules/env/common/types.d.ts +1 -0
- package/dist/esm/modules/env/common/types.js.map +1 -1
- package/dist/esm/modules/logger/common/constants.d.ts +3 -0
- package/dist/esm/modules/logger/common/constants.js +2 -0
- package/dist/esm/modules/logger/common/constants.js.map +1 -1
- package/dist/esm/modules/logger/common/types.d.ts +2 -0
- package/dist/esm/modules/logger/common/types.js +1 -0
- package/dist/esm/modules/logger/common/types.js.map +1 -1
- package/dist/esm/modules/logger/formatting/deep-splat.d.ts +1 -0
- package/dist/esm/modules/logger/formatting/deep-splat.js +1 -0
- package/dist/esm/modules/logger/formatting/deep-splat.js.map +1 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts +7 -2
- package/dist/esm/modules/logger/hf/common/types.js.map +1 -1
- package/dist/esm/modules/logger/winston/common/types.d.ts +31 -3
- package/dist/esm/modules/logger/winston/common/types.js.map +1 -1
- package/dist/esm/modules/logger/winston/define.d.ts +1 -0
- package/dist/esm/modules/logger/winston/define.js +1 -0
- package/dist/esm/modules/logger/winston/define.js.map +1 -1
- package/dist/esm/modules/logger/winston/logger.d.ts +1 -0
- package/dist/esm/modules/logger/winston/logger.js +1 -0
- package/dist/esm/modules/logger/winston/logger.js.map +1 -1
- package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts +1 -0
- package/dist/esm/modules/logger/winston/transports/dgram.transport.js +1 -0
- package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
- package/dist/esm/modules/network/http-request/base-network-request.helper.d.ts +1 -0
- package/dist/esm/modules/network/http-request/base-network-request.helper.js +1 -0
- package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts +8 -8
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js +2 -0
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts +2 -0
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts +5 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js +2 -0
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts +11 -0
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts +3 -0
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.d.ts +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.d.ts +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.d.ts +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.d.ts +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.js +1 -0
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.js.map +1 -1
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.d.ts +4 -0
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js +4 -0
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
- package/dist/esm/modules/network/utilities/query-string.d.ts +13 -2
- package/dist/esm/modules/network/utilities/query-string.js +2 -1
- package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts +2 -1
- package/dist/esm/modules/network/utilities/url-safety/common/constants.js +1 -1
- package/dist/esm/modules/network/utilities/url-safety/common/constants.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/common/types.d.ts +18 -5
- package/dist/esm/modules/network/utilities/url-safety/common/types.js.map +1 -1
- package/dist/esm/modules/pool/common/types.d.ts +5 -1
- package/dist/esm/modules/pool/common/types.js.map +1 -1
- package/dist/esm/modules/queue/bullmq/helper.d.ts +13 -0
- package/dist/esm/modules/queue/bullmq/helper.js +4 -0
- package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
- package/dist/esm/modules/queue/common/hook.d.ts +1 -0
- package/dist/esm/modules/queue/common/hook.js +1 -0
- package/dist/esm/modules/queue/common/hook.js.map +1 -1
- package/dist/esm/modules/queue/internal/sequential/common/types.d.ts +8 -0
- package/dist/esm/modules/queue/internal/sequential/common/types.js +1 -0
- package/dist/esm/modules/queue/internal/sequential/common/types.js.map +1 -1
- package/dist/esm/modules/queue/internal/sequential/helper.d.ts +4 -0
- package/dist/esm/modules/queue/internal/sequential/helper.js +4 -0
- package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
- package/dist/esm/modules/queue/kafka/base.d.ts +5 -0
- package/dist/esm/modules/queue/kafka/base.js.map +1 -1
- package/dist/esm/modules/queue/kafka/bundler/common/constants.d.ts +3 -0
- package/dist/esm/modules/queue/kafka/bundler/common/constants.js +3 -0
- package/dist/esm/modules/queue/kafka/bundler/common/constants.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/constants.d.ts +8 -0
- package/dist/esm/modules/queue/kafka/common/constants.js +5 -0
- package/dist/esm/modules/queue/kafka/common/constants.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/types/admin.d.ts +1 -0
- package/dist/esm/modules/queue/kafka/common/types/admin.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/types/callbacks.d.ts +12 -0
- package/dist/esm/modules/queue/kafka/common/types/callbacks.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/types/connection.d.ts +2 -0
- package/dist/esm/modules/queue/kafka/common/types/connection.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/types/consumer.d.ts +62 -0
- package/dist/esm/modules/queue/kafka/common/types/consumer.js.map +1 -1
- package/dist/esm/modules/queue/kafka/common/types/producer.d.ts +1 -0
- package/dist/esm/modules/queue/kafka/common/types/producer.js.map +1 -1
- package/dist/esm/modules/queue/mqtt/helper.d.ts +2 -0
- package/dist/esm/modules/queue/mqtt/helper.js +1 -0
- package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
- package/dist/esm/modules/redis/base/abstract.helper.d.ts +2 -0
- package/dist/esm/modules/redis/base/abstract.helper.js +2 -0
- package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
- package/dist/esm/modules/redis/cluster/cluster.helper.d.ts +1 -0
- package/dist/esm/modules/redis/cluster/cluster.helper.js +1 -0
- package/dist/esm/modules/redis/cluster/cluster.helper.js.map +1 -1
- package/dist/esm/modules/redis/common/constants.d.ts +4 -0
- package/dist/esm/modules/redis/common/constants.js +2 -0
- package/dist/esm/modules/redis/common/constants.js.map +1 -1
- package/dist/esm/modules/redis/common/interfaces.d.ts +12 -0
- package/dist/esm/modules/redis/common/interfaces.js.map +1 -1
- package/dist/esm/modules/redis/common/types.d.ts +21 -1
- package/dist/esm/modules/redis/common/types.js.map +1 -1
- package/dist/esm/modules/redis/factory.d.ts +2 -0
- package/dist/esm/modules/redis/factory.js +1 -0
- package/dist/esm/modules/redis/factory.js.map +1 -1
- package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts +1 -0
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js +1 -0
- package/dist/esm/modules/redis/sentinel/sentinel.helper.js.map +1 -1
- package/dist/esm/modules/redis/single/single.helper.d.ts +1 -0
- package/dist/esm/modules/redis/single/single.helper.js +1 -0
- package/dist/esm/modules/redis/single/single.helper.js.map +1 -1
- package/dist/esm/modules/redis/utility.d.ts +1 -0
- package/dist/esm/modules/redis/utility.js +1 -0
- package/dist/esm/modules/redis/utility.js.map +1 -1
- package/dist/esm/modules/retry/common/constants.d.ts +4 -0
- package/dist/esm/modules/retry/common/constants.js +2 -0
- package/dist/esm/modules/retry/common/constants.js.map +1 -1
- package/dist/esm/modules/retry/common/types.d.ts +19 -5
- package/dist/esm/modules/retry/common/types.js.map +1 -1
- package/dist/esm/modules/retry/helper.d.ts +4 -4
- package/dist/esm/modules/retry/helper.js.map +1 -1
- package/dist/esm/modules/secrets/base/abstract.helper.d.ts +1 -0
- package/dist/esm/modules/secrets/base/abstract.helper.js +1 -0
- package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
- package/dist/esm/modules/secrets/common/constants.d.ts +4 -0
- package/dist/esm/modules/secrets/common/constants.js +2 -0
- package/dist/esm/modules/secrets/common/constants.js.map +1 -1
- package/dist/esm/modules/secrets/common/types/helper.d.ts +13 -0
- package/dist/esm/modules/secrets/common/types/helper.js.map +1 -1
- package/dist/esm/modules/secrets/common/types/lease.d.ts +2 -0
- package/dist/esm/modules/secrets/common/types/lease.js.map +1 -1
- package/dist/esm/modules/secrets/common/types/registration.d.ts +13 -2
- package/dist/esm/modules/secrets/common/types/registration.js.map +1 -1
- package/dist/esm/modules/secrets/common/types/timer.d.ts +1 -0
- package/dist/esm/modules/secrets/common/types/timer.js.map +1 -1
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.d.ts +8 -0
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.js +1 -0
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
- package/dist/esm/modules/secrets/factory.d.ts +1 -0
- package/dist/esm/modules/secrets/factory.js +1 -0
- package/dist/esm/modules/secrets/factory.js.map +1 -1
- package/dist/esm/modules/secrets/hashicorp/auth.d.ts +2 -0
- package/dist/esm/modules/secrets/hashicorp/auth.js +1 -0
- package/dist/esm/modules/secrets/hashicorp/auth.js.map +1 -1
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts +2 -0
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js +1 -0
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
- package/dist/esm/modules/secrets/system-envs/system-envs.helper.d.ts +1 -0
- package/dist/esm/modules/secrets/system-envs/system-envs.helper.js +1 -0
- package/dist/esm/modules/secrets/system-envs/system-envs.helper.js.map +1 -1
- package/dist/esm/modules/slug/common/constants.d.ts +1 -0
- package/dist/esm/modules/slug/common/constants.js +1 -0
- package/dist/esm/modules/slug/common/constants.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/constants.d.ts +2 -0
- package/dist/esm/modules/socket/socket-io/common/constants.js +2 -0
- package/dist/esm/modules/socket/socket-io/common/constants.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/types/client.d.ts +5 -0
- package/dist/esm/modules/socket/socket-io/common/types/client.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/types/hooks.d.ts +4 -0
- package/dist/esm/modules/socket/socket-io/common/types/hooks.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/common/types/server.d.ts +6 -0
- package/dist/esm/modules/socket/socket-io/common/types/server.js.map +1 -1
- package/dist/esm/modules/socket/socket-io/server/helper.d.ts +1 -0
- package/dist/esm/modules/socket/socket-io/server/helper.js +1 -0
- package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
- package/dist/esm/modules/socket/websocket/common/constants.d.ts +7 -0
- package/dist/esm/modules/socket/websocket/common/constants.js +5 -0
- package/dist/esm/modules/socket/websocket/common/constants.js.map +1 -1
- package/dist/esm/modules/socket/websocket/common/types/client.d.ts +4 -0
- package/dist/esm/modules/socket/websocket/common/types/client.js.map +1 -1
- package/dist/esm/modules/socket/websocket/common/types/hooks.d.ts +7 -0
- package/dist/esm/modules/socket/websocket/common/types/hooks.js.map +1 -1
- package/dist/esm/modules/socket/websocket/common/types/server.d.ts +30 -0
- package/dist/esm/modules/socket/websocket/common/types/server.js.map +1 -1
- package/dist/esm/modules/socket/websocket/emitter/helper.d.ts +1 -0
- package/dist/esm/modules/socket/websocket/emitter/helper.js +1 -0
- package/dist/esm/modules/socket/websocket/emitter/helper.js.map +1 -1
- package/dist/esm/modules/socket/websocket/server/helper.d.ts +1 -0
- package/dist/esm/modules/socket/websocket/server/helper.js +1 -0
- package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
- package/dist/esm/modules/storage/base.d.ts +6 -1
- package/dist/esm/modules/storage/base.js +1 -0
- package/dist/esm/modules/storage/base.js.map +1 -1
- package/dist/esm/modules/storage/bun-s3/helper.d.ts +9 -1
- package/dist/esm/modules/storage/bun-s3/helper.js +2 -1
- package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
- package/dist/esm/modules/storage/common/constants.d.ts +1 -0
- package/dist/esm/modules/storage/common/constants.js.map +1 -1
- package/dist/esm/modules/storage/common/types.d.ts +17 -1
- package/dist/esm/modules/storage/common/types.js.map +1 -1
- package/dist/esm/modules/storage/common/utility.d.ts +1 -0
- package/dist/esm/modules/storage/common/utility.js +1 -0
- package/dist/esm/modules/storage/common/utility.js.map +1 -1
- package/dist/esm/modules/storage/disk/helper.d.ts +2 -0
- package/dist/esm/modules/storage/disk/helper.js +1 -0
- package/dist/esm/modules/storage/disk/helper.js.map +1 -1
- package/dist/esm/modules/temporal/abstract.d.ts +5 -0
- package/dist/esm/modules/temporal/abstract.js +2 -1
- package/dist/esm/modules/temporal/abstract.js.map +1 -1
- package/dist/esm/modules/temporal/common/constants.d.ts +3 -0
- package/dist/esm/modules/temporal/common/constants.js.map +1 -1
- package/dist/esm/modules/tree/common/types.d.ts +6 -0
- package/dist/esm/modules/tree/common/types.js.map +1 -1
- package/dist/esm/modules/uid/common/constants.d.ts +1 -0
- package/dist/esm/modules/uid/common/constants.js.map +1 -1
- package/dist/esm/modules/uid/common/types.d.ts +28 -7
- package/dist/esm/modules/uid/common/types.js.map +1 -1
- package/dist/esm/modules/uid/helper.d.ts +12 -0
- package/dist/esm/modules/uid/helper.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v4.d.ts +1 -0
- package/dist/esm/modules/uid/uuid/v4.js +1 -0
- package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v5.d.ts +1 -0
- package/dist/esm/modules/uid/uuid/v5.js +1 -0
- package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
- package/dist/esm/modules/uid/uuid/v7.d.ts +1 -0
- package/dist/esm/modules/uid/uuid/v7.js +1 -0
- package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
- package/dist/esm/modules/worker-thread/bus/abstract.d.ts +1 -0
- package/dist/esm/modules/worker-thread/bus/abstract.js +1 -0
- package/dist/esm/modules/worker-thread/bus/abstract.js.map +1 -1
- package/dist/esm/modules/worker-thread/bus/base.d.ts +1 -0
- package/dist/esm/modules/worker-thread/bus/base.js +1 -0
- package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
- package/dist/esm/modules/worker-thread/bus/handler/abstract.d.ts +1 -0
- package/dist/esm/modules/worker-thread/bus/handler/abstract.js +1 -0
- package/dist/esm/modules/worker-thread/bus/handler/abstract.js.map +1 -1
- package/dist/esm/modules/worker-thread/bus/handler/base.d.ts +1 -0
- package/dist/esm/modules/worker-thread/bus/handler/base.js +1 -0
- package/dist/esm/modules/worker-thread/bus/handler/base.js.map +1 -1
- package/dist/esm/modules/worker-thread/common/types.d.ts +4 -0
- package/dist/esm/modules/worker-thread/common/types.js.map +1 -1
- package/dist/esm/modules/worker-thread/thread/abstract.d.ts +1 -0
- package/dist/esm/modules/worker-thread/thread/abstract.js +1 -0
- package/dist/esm/modules/worker-thread/thread/abstract.js.map +1 -1
- package/dist/esm/modules/worker-thread/thread/base.d.ts +1 -0
- package/dist/esm/modules/worker-thread/thread/base.js +1 -0
- package/dist/esm/modules/worker-thread/thread/base.js.map +1 -1
- package/dist/esm/modules/worker-thread/worker/abstract.d.ts +1 -0
- package/dist/esm/modules/worker-thread/worker/abstract.js +1 -0
- package/dist/esm/modules/worker-thread/worker/abstract.js.map +1 -1
- package/dist/esm/modules/worker-thread/worker/base.d.ts +1 -0
- package/dist/esm/modules/worker-thread/worker/base.js +1 -0
- package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
- package/dist/esm/modules/worker-thread/worker-pool.d.ts +1 -0
- package/dist/esm/modules/worker-thread/worker-pool.js +1 -0
- package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
- package/dist/esm/utilities/error.utility.d.ts +1 -0
- package/dist/esm/utilities/error.utility.js +1 -0
- package/dist/esm/utilities/error.utility.js.map +1 -1
- package/dist/esm/utilities/form-body.utility.d.ts +1 -0
- package/dist/esm/utilities/form-body.utility.js +1 -0
- package/dist/esm/utilities/form-body.utility.js.map +1 -1
- package/dist/esm/utilities/hr-time.utility.d.ts +1 -0
- package/dist/esm/utilities/hr-time.utility.js +1 -0
- package/dist/esm/utilities/hr-time.utility.js.map +1 -1
- package/dist/esm/utilities/performance.utility.d.ts +1 -0
- package/dist/esm/utilities/performance.utility.js +1 -0
- package/dist/esm/utilities/performance.utility.js.map +1 -1
- package/dist/esm/utilities/promise.utility.d.ts +1 -0
- package/dist/esm/utilities/promise.utility.js.map +1 -1
- package/dist/esm/utilities/request.utility.d.ts +2 -0
- package/dist/esm/utilities/request.utility.js +1 -0
- package/dist/esm/utilities/request.utility.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Key size in bits assumed when an algorithm name carries no size suffix (see `getAlgorithmKeySize`). */
|
|
1
2
|
export const DEFAULT_CIPHER_BITS = 256;
|
|
2
3
|
/**
|
|
3
4
|
* Public and identical across every deployment, so it stops a bare dictionary attack but not a
|
|
@@ -5,12 +6,15 @@ export const DEFAULT_CIPHER_BITS = 256;
|
|
|
5
6
|
* change this: every ciphertext already encrypted under it becomes undecryptable.
|
|
6
7
|
*/
|
|
7
8
|
export const DEFAULT_KDF_SALT = 'ignis-kdf-salt-v1';
|
|
9
|
+
/** PBKDF2 iteration count used when `kdfIterations` is omitted. Changing it makes ciphertext encrypted under the old count undecryptable. */
|
|
8
10
|
export const DEFAULT_KDF_ITERATIONS = 100_000;
|
|
11
|
+
/** PBKDF2 digest for key derivation; it is not configurable per call. */
|
|
9
12
|
export const DEFAULT_KDF_DIGEST = 'sha256';
|
|
10
13
|
/** NIST SP 800-132 minimum recommended salt size (128 bits) for a caller-supplied `kdfSalt`. */
|
|
11
14
|
export const MINIMUM_KDF_SALT_BYTES = 16;
|
|
12
15
|
/** NIST SP 800-57 Part 1 floor for RSA past 2030. */
|
|
13
16
|
export const MINIMUM_RSA_MODULUS_BITS = 2048;
|
|
17
|
+
/** Digest names the hash algorithm accepts. `isValid` narrows a string to `THashAlgorithm`. */
|
|
14
18
|
export class HashAlgorithms {
|
|
15
19
|
/** Cryptographically broken - kept only for wire-protocol compatibility (VNPay checksums); never use for security decisions. */
|
|
16
20
|
static { this.MD5 = 'md5'; }
|
|
@@ -30,6 +34,7 @@ export class HashAlgorithms {
|
|
|
30
34
|
return this.SCHEME_SET.has(value);
|
|
31
35
|
}
|
|
32
36
|
}
|
|
37
|
+
/** Text encodings a digest can be written in. `isValid` narrows a string to `THashOutputEncoding`. */
|
|
33
38
|
export class HashOutputEncodings {
|
|
34
39
|
static { this.HEX = 'hex'; }
|
|
35
40
|
static { this.BASE64 = 'base64'; }
|
|
@@ -39,9 +44,11 @@ export class HashOutputEncodings {
|
|
|
39
44
|
return this.SCHEME_SET.has(value);
|
|
40
45
|
}
|
|
41
46
|
}
|
|
47
|
+
/** Encoding used when `outputEncoding` is omitted. */
|
|
42
48
|
export const DEFAULT_HASH_OUTPUT_ENCODING = HashOutputEncodings.HEX;
|
|
49
|
+
/** Password-hash schemes `CredentialHelper` accepts. `isValid` narrows a string to `TCredentialAlgorithm`. */
|
|
43
50
|
export class CredentialAlgorithms {
|
|
44
|
-
/** What `Bun.password` writes
|
|
51
|
+
/** What `Bun.password` writes with its default parameters; the scheme `hash` uses unless told otherwise. */
|
|
45
52
|
static { this.ARGON2ID = 'argon2id'; }
|
|
46
53
|
static { this.BCRYPT = 'bcrypt'; }
|
|
47
54
|
static { this.SCHEME_SET = new Set([this.ARGON2ID, this.BCRYPT]); }
|
|
@@ -49,5 +56,6 @@ export class CredentialAlgorithms {
|
|
|
49
56
|
return this.SCHEME_SET.has(value);
|
|
50
57
|
}
|
|
51
58
|
}
|
|
59
|
+
/** Scheme `CredentialHelper.hash` uses when `algorithm` is omitted. */
|
|
52
60
|
export const DEFAULT_CREDENTIAL_ALGORITHM = CredentialAlgorithms.ARGON2ID;
|
|
53
61
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/common/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AACpD,MAAM,CAAC,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE3C,gGAAgG;AAChG,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAE7C,MAAM,OAAO,cAAc;IACzB,gIAAgI;aAChH,QAAG,GAAG,KAAK,CAAC;IAE5B,gIAAgI;aAChH,SAAI,GAAG,MAAM,CAAC;aAEd,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;KACZ,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/common/constants.ts"],"names":[],"mappings":"AAEA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;GAIG;AACH,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,MAAM,4BAA4B,GAAwB,mBAAmB,CAAC,GAAG,CAAC;AAEzF,8GAA8G;AAC9G,MAAM,OAAO,oBAAoB;IAC/B,4GAA4G;aAC5F,aAAQ,GAAG,UAAU,CAAC;aACtB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,uEAAuE;AACvE,MAAM,CAAC,MAAM,4BAA4B,GAAyB,oBAAoB,CAAC,QAAQ,CAAC","sourcesContent":["import type { TConstValue } from '@/common';\n\n/** Key size in bits assumed when an algorithm name carries no size suffix (see `getAlgorithmKeySize`). */\nexport const DEFAULT_CIPHER_BITS = 256;\n\n/**\n * Public and identical across every deployment, so it stops a bare dictionary attack but not a\n * table precomputed against this value - pass `kdfSalt` for per-deployment isolation. Never\n * change this: every ciphertext already encrypted under it becomes undecryptable.\n */\nexport const DEFAULT_KDF_SALT = 'ignis-kdf-salt-v1';\n/** PBKDF2 iteration count used when `kdfIterations` is omitted. Changing it makes ciphertext encrypted under the old count undecryptable. */\nexport const DEFAULT_KDF_ITERATIONS = 100_000;\n/** PBKDF2 digest for key derivation; it is not configurable per call. */\nexport const DEFAULT_KDF_DIGEST = 'sha256';\n\n/** NIST SP 800-132 minimum recommended salt size (128 bits) for a caller-supplied `kdfSalt`. */\nexport const MINIMUM_KDF_SALT_BYTES = 16;\n\n/** NIST SP 800-57 Part 1 floor for RSA past 2030. */\nexport const MINIMUM_RSA_MODULUS_BITS = 2048;\n\n/** Digest names the hash algorithm accepts. `isValid` narrows a string to `THashAlgorithm`. */\nexport class HashAlgorithms {\n /** Cryptographically broken - kept only for wire-protocol compatibility (VNPay checksums); never use for security decisions. */\n static readonly MD5 = 'md5';\n\n /** Cryptographically weak - kept for wire-protocol compatibility with legacy integrations; never use for security decisions. */\n static readonly SHA1 = 'sha1';\n\n static readonly SHA256 = 'sha256';\n static readonly SHA384 = 'sha384';\n static readonly SHA512 = 'sha512';\n\n static readonly SCHEME_SET = new Set<string>([\n this.MD5,\n this.SHA1,\n this.SHA256,\n this.SHA384,\n this.SHA512,\n ]);\n\n static isValid(value: string): value is THashAlgorithm {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** One of the `HashAlgorithms` values. */\nexport type THashAlgorithm = TConstValue<typeof HashAlgorithms>;\n\n/** Text encodings a digest can be written in. `isValid` narrows a string to `THashOutputEncoding`. */\nexport class HashOutputEncodings {\n static readonly HEX = 'hex';\n static readonly BASE64 = 'base64';\n static readonly BASE64URL = 'base64url';\n\n static readonly SCHEME_SET = new Set<string>([this.HEX, this.BASE64, this.BASE64URL]);\n\n static isValid(value: string): value is THashOutputEncoding {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** One of the `HashOutputEncodings` values. */\nexport type THashOutputEncoding = TConstValue<typeof HashOutputEncodings>;\n\n/** Encoding used when `outputEncoding` is omitted. */\nexport const DEFAULT_HASH_OUTPUT_ENCODING: THashOutputEncoding = HashOutputEncodings.HEX;\n\n/** Password-hash schemes `CredentialHelper` accepts. `isValid` narrows a string to `TCredentialAlgorithm`. */\nexport class CredentialAlgorithms {\n /** What `Bun.password` writes with its default parameters; the scheme `hash` uses unless told otherwise. */\n static readonly ARGON2ID = 'argon2id';\n static readonly BCRYPT = 'bcrypt';\n\n static readonly SCHEME_SET = new Set<string>([this.ARGON2ID, this.BCRYPT]);\n\n static isValid(value: string): value is TCredentialAlgorithm {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** One of the `CredentialAlgorithms` values. */\nexport type TCredentialAlgorithm = TConstValue<typeof CredentialAlgorithms>;\n\n/** Scheme `CredentialHelper.hash` uses when `algorithm` is omitted. */\nexport const DEFAULT_CREDENTIAL_ALGORITHM: TCredentialAlgorithm = CredentialAlgorithms.ARGON2ID;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Contract of an encryption algorithm: `encrypt` and `decrypt` take one options object holding `message`, `secret` and optional algorithm-specific `opts`. The type parameters set the input, secret and return types of each side. */
|
|
1
2
|
export interface ICryptoAlgorithm<AlgorithmNameType extends string, EncryptInputType = unknown, DecryptInputType = unknown, SecretKeyType = unknown, EncryptReturnType = unknown, DecryptReturnType = unknown, ExtraOptions = unknown> {
|
|
2
3
|
algorithm: AlgorithmNameType;
|
|
3
4
|
encrypt(opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/common/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/crypto/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Contract of an encryption algorithm: `encrypt` and `decrypt` take one options object holding `message`, `secret` and optional algorithm-specific `opts`. The type parameters set the input, secret and return types of each side. */\nexport interface ICryptoAlgorithm<\n AlgorithmNameType extends string,\n EncryptInputType = unknown,\n DecryptInputType = unknown,\n SecretKeyType = unknown,\n EncryptReturnType = unknown,\n DecryptReturnType = unknown,\n ExtraOptions = unknown,\n> {\n algorithm: AlgorithmNameType;\n\n encrypt(opts: {\n message: EncryptInputType;\n secret: SecretKeyType;\n opts?: ExtraOptions;\n }): EncryptReturnType;\n decrypt(opts: {\n message: DecryptInputType;\n secret: SecretKeyType;\n opts?: ExtraOptions;\n }): DecryptReturnType;\n}\n"]}
|
|
@@ -10,6 +10,7 @@ export declare class Environment extends EnvironmentNames {
|
|
|
10
10
|
name: string;
|
|
11
11
|
}): boolean;
|
|
12
12
|
}
|
|
13
|
+
/** Key-value store of the environment entries whose key starts with `prefix`; other keys are dropped at construction. `get` applies a default and an optional transform. Use the shared `applicationEnvironment` instance rather than constructing one. */
|
|
13
14
|
export declare class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {
|
|
14
15
|
private prefix;
|
|
15
16
|
private arguments;
|
|
@@ -39,6 +40,8 @@ export declare class ApplicationEnvironment extends BaseHelper implements IAppli
|
|
|
39
40
|
isDevelopment(): boolean;
|
|
40
41
|
keys(): string[];
|
|
41
42
|
}
|
|
43
|
+
/** The process-wide environment store, built from `process.env` with the prefix in `APPLICATION_ENV_PREFIX` (`APP_ENV` when unset). One instance is shared by every copy of this module in the process. */
|
|
42
44
|
export declare const applicationEnvironment: ApplicationEnvironment;
|
|
45
|
+
/** Alias of `applicationEnvironment`. */
|
|
43
46
|
export declare const AppEnvs: ApplicationEnvironment;
|
|
44
47
|
//# sourceMappingURL=app-env.d.ts.map
|
|
@@ -15,6 +15,7 @@ export class Environment extends EnvironmentNames {
|
|
|
15
15
|
return this.current === opts.name;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
/** Key-value store of the environment entries whose key starts with `prefix`; other keys are dropped at construction. `get` applies a default and an optional transform. Use the shared `applicationEnvironment` instance rather than constructing one. */
|
|
18
19
|
export class ApplicationEnvironment extends BaseHelper {
|
|
19
20
|
constructor(opts) {
|
|
20
21
|
super({ scope: ApplicationEnvironment.name });
|
|
@@ -78,6 +79,8 @@ const resolveApplicationEnvironment = () => {
|
|
|
78
79
|
Reflect.set(globalThis, INSTANCE_SLOT, created);
|
|
79
80
|
return created;
|
|
80
81
|
};
|
|
82
|
+
/** The process-wide environment store, built from `process.env` with the prefix in `APPLICATION_ENV_PREFIX` (`APP_ENV` when unset). One instance is shared by every copy of this module in the process. */
|
|
81
83
|
export const applicationEnvironment = resolveApplicationEnvironment();
|
|
84
|
+
/** Alias of `applicationEnvironment`. */
|
|
82
85
|
export const AppEnvs = applicationEnvironment;
|
|
83
86
|
//# sourceMappingURL=app-env.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":"AAAA,OA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AC;IAE1F,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM,EACJ,YAAY,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,IAAI,SAAS;QAC3F,IAAI,EAAE,OAAO,CAAC,GAAG;KAClB,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,EAAE,CAAC;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC","sourcesContent":["import { ParseUtility } from '@/utilities/parse.utility';\nimport { BaseHelper } from '@/modules/base';\nimport { EnvironmentNames } from './names';\nimport { type IApplicationEnvironment } from './common';\n\n/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */\nexport class Environment extends EnvironmentNames {\n /** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */\n static get ambient(): string | undefined {\n const { NODE_ENV } = process.env;\n\n return NODE_ENV;\n }\n\n static get current(): string {\n return Environment.ambient ?? Environment.DEVELOPMENT;\n }\n\n static is(opts: { name: string }) {\n return this.current === opts.name;\n }\n}\n\nexport class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {\n private prefix: string;\n private arguments: Record<string, any> = Object.create(null);\n\n constructor(opts: { prefix: string; envs: Record<string, string | number | undefined> }) {\n super({ scope: ApplicationEnvironment.name });\n\n this.prefix = opts.prefix;\n\n for (const key in opts.envs) {\n if (!key.startsWith(this.prefix)) {\n continue;\n }\n\n this.arguments[key] = opts.envs[key];\n }\n }\n\n /**\n * Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand\n * edit - is a pipeline that forgot to export the value, not a value: it is normalised to\n * `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than\n * the empty string.\n *\n * The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site\n * has already declared what it wants when the name carries nothing. A caller without one still\n * receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and\n * are never normalised.\n */\n get<ReturnType, BeforeTransformType = unknown>(\n key: string,\n opts?: {\n defaultValue?: ReturnType;\n transform?: (value: BeforeTransformType) => ReturnType;\n },\n ): ReturnType {\n const raw = this.arguments[key];\n\n const isBlank = raw === undefined || raw === null || (typeof raw === 'string' && !raw.trim());\n const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;\n\n if (!opts?.transform) {\n return (rs ?? opts?.defaultValue) as ReturnType;\n }\n\n const transformed = opts.transform(rs);\n\n return (transformed ?? opts?.defaultValue) as ReturnType;\n }\n\n set<ValueType>(key: string, value: ValueType) {\n this.arguments[key] = value;\n }\n\n merge(opts: { envs: Record<string, string> }) {\n const envsEntries = Object.entries(opts.envs);\n\n for (const [key, value] of envsEntries) {\n this.arguments[key] = value;\n }\n }\n\n isDevelopment() {\n return Environment.ambient === 'development';\n }\n\n keys() {\n return Object.keys(this.arguments);\n }\n}\n\n/** A process can carry two copies of this module - an application's ESM import beside a CommonJS require. The instance lives in this globalThis slot so a `set()` through one copy is read through the other. */\nconst INSTANCE_SLOT = Symbol.for('ignis:application-environment');\n\nconst resolveApplicationEnvironment = (): ApplicationEnvironment => {\n const shared: ApplicationEnvironment | undefined = Reflect.get(globalThis, INSTANCE_SLOT);\n\n if (shared) {\n return shared;\n }\n\n const created = new ApplicationEnvironment({\n prefix:\n ParseUtility.blankToUndefined({ input: process.env.APPLICATION_ENV_PREFIX }) ?? 'APP_ENV',\n envs: process.env,\n });\n Reflect.set(globalThis, INSTANCE_SLOT, created);\n\n return created;\n};\n\nexport const applicationEnvironment = resolveApplicationEnvironment();\n\nexport const AppEnvs = applicationEnvironment;\n"]}
|
|
1
|
+
{"version":3,"file":"app-env.js","sourceRoot":"","sources":["../../../../src/modules/env/app-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAG3C,sPAAsP;AACtP,MAAM,OAAO,WAAY,SAAQ,gBAAgB;IAC/C,gNAAgN;IAChN,MAAM,KAAK,OAAO;QAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QAEjC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,OAAO;QAChB,OAAO,WAAW,CAAC,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,EAAE,CAAC,IAAsB;QAC9B,OAAO,IAAI,CAAC,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AAED,2PAA2P;AAC3P,MAAM,OAAO,sBAAuB,SAAQ,UAAU;IAIpD,YAAY,IAA2E;QACrF,KAAK,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;QAHxC,cAAS,GAAwB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAK3D,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAE1B,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBACjC,SAAS;YACX,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG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,CAAC;IACrC,CAAC;CACF;AAED,iNAAiN;AACjN,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;AAElE,MAAM,6BAA6B,GAAG,GAA2B,EAAE;IACjE,MAAM,MAAM,GAAuC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAE1F,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,sBAAsB,CAAC;QACzC,MAAM,EACJ,YAAY,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,IAAI,SAAS;QAC3F,IAAI,EAAE,OAAO,CAAC,GAAG;KAClB,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,aAAa,EAAE,OAAO,CAAC,CAAC;IAEhD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,2MAA2M;AAC3M,MAAM,CAAC,MAAM,sBAAsB,GAAG,6BAA6B,EAAE,CAAC;AAEtE,yCAAyC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,sBAAsB,CAAC","sourcesContent":["import { ParseUtility } from '@/utilities/parse.utility';\nimport { BaseHelper } from '@/modules/base';\nimport { EnvironmentNames } from './names';\nimport { type IApplicationEnvironment } from './common';\n\n/** Adds the `NODE_ENV` reads to {@link EnvironmentNames}. Every name and set is inherited, so `Environment.PRODUCTION`, `Environment.COMMON_ENVS` and `Environment.DEVELOPMENT_ENVS` keep resolving here; only these two members need a `process`. */\nexport class Environment extends EnvironmentNames {\n /** `NODE_ENV` exactly as the host has it, `undefined` when unset. Destructured on purpose: `bun build` rewrites `process.env.NODE_ENV` to a literal at build time, a destructured read stays a runtime read. */\n static get ambient(): string | undefined {\n const { NODE_ENV } = process.env;\n\n return NODE_ENV;\n }\n\n static get current(): string {\n return Environment.ambient ?? Environment.DEVELOPMENT;\n }\n\n static is(opts: { name: string }) {\n return this.current === opts.name;\n }\n}\n\n/** Key-value store of the environment entries whose key starts with `prefix`; other keys are dropped at construction. `get` applies a default and an optional transform. Use the shared `applicationEnvironment` instance rather than constructing one. */\nexport class ApplicationEnvironment extends BaseHelper implements IApplicationEnvironment {\n private prefix: string;\n private arguments: Record<string, any> = Object.create(null);\n\n constructor(opts: { prefix: string; envs: Record<string, string | number | undefined> }) {\n super({ scope: ApplicationEnvironment.name });\n\n this.prefix = opts.prefix;\n\n for (const key in opts.envs) {\n if (!key.startsWith(this.prefix)) {\n continue;\n }\n\n this.arguments[key] = opts.envs[key];\n }\n }\n\n /**\n * Reads one name. A line that is present but empty - `KEY=`, or padded to `KEY= ` by a hand\n * edit - is a pipeline that forgot to export the value, not a value: it is normalised to\n * `undefined` so `defaultValue` applies, and `transform` is handed that `undefined` rather than\n * the empty string.\n *\n * The normalisation runs ONLY when the caller supplied a `defaultValue`, because that call site\n * has already declared what it wants when the name carries nothing. A caller without one still\n * receives `''` unchanged, so no existing read changes shape. `'0'` and `'false'` are values and\n * are never normalised.\n */\n get<ReturnType, BeforeTransformType = unknown>(\n key: string,\n opts?: {\n defaultValue?: ReturnType;\n transform?: (value: BeforeTransformType) => ReturnType;\n },\n ): ReturnType {\n const raw = this.arguments[key];\n\n const isBlank = raw === undefined || raw === null || (typeof raw === 'string' && !raw.trim());\n const rs = opts?.defaultValue !== undefined && isBlank ? undefined : raw;\n\n if (!opts?.transform) {\n return (rs ?? opts?.defaultValue) as ReturnType;\n }\n\n const transformed = opts.transform(rs);\n\n return (transformed ?? opts?.defaultValue) as ReturnType;\n }\n\n set<ValueType>(key: string, value: ValueType) {\n this.arguments[key] = value;\n }\n\n merge(opts: { envs: Record<string, string> }) {\n const envsEntries = Object.entries(opts.envs);\n\n for (const [key, value] of envsEntries) {\n this.arguments[key] = value;\n }\n }\n\n isDevelopment() {\n return Environment.ambient === 'development';\n }\n\n keys() {\n return Object.keys(this.arguments);\n }\n}\n\n/** A process can carry two copies of this module - an application's ESM import beside a CommonJS require. The instance lives in this globalThis slot so a `set()` through one copy is read through the other. */\nconst INSTANCE_SLOT = Symbol.for('ignis:application-environment');\n\nconst resolveApplicationEnvironment = (): ApplicationEnvironment => {\n const shared: ApplicationEnvironment | undefined = Reflect.get(globalThis, INSTANCE_SLOT);\n\n if (shared) {\n return shared;\n }\n\n const created = new ApplicationEnvironment({\n prefix:\n ParseUtility.blankToUndefined({ input: process.env.APPLICATION_ENV_PREFIX }) ?? 'APP_ENV',\n envs: process.env,\n });\n Reflect.set(globalThis, INSTANCE_SLOT, created);\n\n return created;\n};\n\n/** The process-wide environment store, built from `process.env` with the prefix in `APPLICATION_ENV_PREFIX` (`APP_ENV` when unset). One instance is shared by every copy of this module in the process. */\nexport const applicationEnvironment = resolveApplicationEnvironment();\n\n/** Alias of `applicationEnvironment`. */\nexport const AppEnvs = applicationEnvironment;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/env/common/types.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/env/common/types.ts"],"names":[],"mappings":"","sourcesContent":["/** Read and write contract of the application environment store; `get` returns `defaultValue` when the key is absent. */\nexport interface IApplicationEnvironment {\n get<ReturnType, BeforeTransformType = unknown>(\n key: string,\n opts?: {\n defaultValue?: ReturnType;\n transform?: (value: BeforeTransformType) => ReturnType;\n },\n ): ReturnType;\n set<ValueType>(key: string, value: ValueType): any;\n}\n"]}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { type TConstValue } from '../../../common/types/index.js';
|
|
2
2
|
import { type TLogLevel } from './types.js';
|
|
3
|
+
/** Output shapes of a log line. `isValid` narrows a string to `TLoggerFormat`. */
|
|
3
4
|
export declare class LoggerFormats {
|
|
4
5
|
static readonly JSON = "json";
|
|
5
6
|
static readonly TEXT = "text";
|
|
6
7
|
static readonly SCHEME_SET: Set<string>;
|
|
7
8
|
static isValid(input: string): input is TLoggerFormat;
|
|
8
9
|
}
|
|
10
|
+
/** One of the `LoggerFormats` values. */
|
|
9
11
|
export type TLoggerFormat = TConstValue<typeof LoggerFormats>;
|
|
12
|
+
/** Resolves logger settings (level, color) from configured values and the environment. */
|
|
10
13
|
export declare class LoggerConfigUtility {
|
|
11
14
|
/** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */
|
|
12
15
|
static resolveLevel(opts: {
|
|
@@ -2,6 +2,7 @@ import { Environment } from '../../env/index.js';
|
|
|
2
2
|
import { ParseUtility } from '../../../utilities/parse.utility.js';
|
|
3
3
|
import { LogLevels } from './types.js';
|
|
4
4
|
// -------------------------------------------------------------
|
|
5
|
+
/** Output shapes of a log line. `isValid` narrows a string to `TLoggerFormat`. */
|
|
5
6
|
export class LoggerFormats {
|
|
6
7
|
static { this.JSON = 'json'; }
|
|
7
8
|
static { this.TEXT = 'text'; }
|
|
@@ -11,6 +12,7 @@ export class LoggerFormats {
|
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
// -------------------------------------------------------------
|
|
15
|
+
/** Resolves logger settings (level, color) from configured values and the environment. */
|
|
14
16
|
export class LoggerConfigUtility {
|
|
15
17
|
/** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */
|
|
16
18
|
static resolveLevel(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,SAAS,EAAkB,MAAM,SAAS,CAAC;AAEpD,gEAAgE;AA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IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YACnC,gJAAgJ;YAChJ,OAAO,CAAC,IAAI,CACV,mFAAmF,EACnF,UAAU,EACV,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,EACzB,SAAS,CAAC,KAAK,CAChB,CAAC;YAEF,OAAO,SAAS,CAAC,KAAK,CAAC;QACzB,CAAC;QAED,OAAO,UAAuB,CAAC;IACjC,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,eAAe,CAAC,IAGtB;QACC,MAAM,UAAU,GAAG,IAAI,EAAE,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;QAExE,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,OAAO,YAAY,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAErC,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YAC5C,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,EAAE,WAAW,IAAI,WAAW,CAAC,OAAO,CAAC;QAE7D,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACnD,OAAO,KAAK,CAAC;QACf,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { type TConstValue } from '@/common/types';\nimport { Environment } from '@/modules/env';\nimport { ParseUtility } from '@/utilities/parse.utility';\nimport { LogLevels, type TLogLevel } from './types';\n\n// -------------------------------------------------------------\n/** Output shapes of a log line. `isValid` narrows a string to `TLoggerFormat`. */\nexport class LoggerFormats {\n static readonly JSON = 'json';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set([this.JSON, this.TEXT]);\n\n static isValid(input: string): input is TLoggerFormat {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** One of the `LoggerFormats` values. */\nexport type TLoggerFormat = TConstValue<typeof LoggerFormats>;\n\n// -------------------------------------------------------------\n/** Resolves logger settings (level, color) from configured values and the environment. */\nexport class LoggerConfigUtility {\n /** The logger's own level, below which a line never reaches ANY transport. Defaults to `debug` - level gating belongs to the wrapper and each transport, and a stricter default here would silently drop lines the wrapper already let through. */\n static resolveLevel(opts: { configured?: string }): TLogLevel {\n const { configured } = opts;\n\n if (!configured || configured.trim() === '') {\n return LogLevels.DEBUG;\n }\n\n const normalized = configured.trim().toLowerCase();\n\n if (!LogLevels.isValid(normalized)) {\n // console, not Logger: the logger is being built - routing this warning through it would re-enter the very pipeline that is not configured yet.\n console.warn(\n '[resolveLoggerLevel] Invalid logger level | value: %s | valids: %s | fallback: %s',\n configured,\n [...LogLevels.SCHEME_SET],\n LogLevels.DEBUG,\n );\n\n return LogLevels.DEBUG;\n }\n\n return normalized as TLogLevel;\n }\n\n /**\n * Whether log lines may carry ANSI color, resolved at CALL time. First match wins:\n *\n * 1. `APP_ENV_LOGGER_COLOR` - an explicit yes or no from the operator.\n * 2. `NO_COLOR`, set to anything non-empty - the no-color.org convention.\n * 3. `NODE_ENV` outside {@link Environment.DEVELOPMENT_ENVS} - production, staging, uat and any\n * unrecognized name. Fail-closed, the same boundary the error sanitizer draws: colors are a\n * terminal affordance, and in a deployed environment the same bytes land in a file or an\n * aggregator as escape noise every grep then has to strip.\n *\n * `undefined` means the framework has no opinion, so a provider that detects a terminal itself\n * keeps deciding - which is why the pino path forwards nothing in that case.\n */\n static resolveColorize(opts?: {\n configured?: string;\n environment?: string;\n }): boolean | undefined {\n const configured = opts?.configured ?? process.env.APP_ENV_LOGGER_COLOR;\n\n if (configured !== undefined && configured.trim() !== '') {\n return ParseUtility.toBoolean({ input: configured.trim().toLowerCase() });\n }\n\n const noColor = process.env.NO_COLOR;\n\n if (noColor !== undefined && noColor !== '') {\n return false;\n }\n\n const environment = opts?.environment ?? Environment.current;\n\n if (!Environment.DEVELOPMENT_ENVS.has(environment)) {\n return false;\n }\n\n return undefined;\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AnyType, type TConstValue } from '../../../common/types/index.js';
|
|
2
|
+
/** Log severities. `ORDER` runs from most to least severe, and `isEnabled` tests a level against a threshold. */
|
|
2
3
|
export declare class LogLevels {
|
|
3
4
|
static readonly ERROR = "error";
|
|
4
5
|
static readonly EMERG = "emerg";
|
|
@@ -15,6 +16,7 @@ export declare class LogLevels {
|
|
|
15
16
|
threshold: string;
|
|
16
17
|
}): boolean;
|
|
17
18
|
}
|
|
19
|
+
/** One of the `LogLevels` values. */
|
|
18
20
|
export type TLogLevel = TConstValue<typeof LogLevels>;
|
|
19
21
|
/** The logging contract every consumer types against; which provider produced the logger is invisible behind it - only `factory.ts` and a provider's back-compat aliases may name a concrete logger class. */
|
|
20
22
|
export interface ILogger {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/types.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,SAAS;aACJ,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjG,2GAA2G;aAC3F,UAAK,GAA0B;QAC7C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;KACX,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,yHAAyH;IACzH,MAAM,CAAC,SAAS,CAAC,IAA0C;QACzD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,gFAAgF;QAChF,OAAO,SAAS,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC,IAAI,SAAS,IAAI,aAAa,CAAC;IAC1E,CAAC","sourcesContent":["import { type AnyType, type TConstValue } from '@/common/types';\n\nexport class LogLevels {\n static readonly ERROR = 'error';\n static readonly EMERG = 'emerg';\n static readonly WARN = 'warn';\n static readonly INFO = 'info';\n static readonly DEBUG = 'debug';\n\n static readonly SCHEME_SET = new Set([this.ERROR, this.EMERG, this.WARN, this.INFO, this.DEBUG]);\n\n /** From the most to the least severe: a threshold lets through its own level and every level before it. */\n static readonly ORDER: ReadonlyArray<string> = [\n this.EMERG,\n this.ERROR,\n this.WARN,\n this.INFO,\n this.DEBUG,\n ];\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n\n /** Whether a line of `level` passes a `threshold`: `debug` lets everything through, `error` only `error` and `emerg`. */\n static isEnabled(opts: { level: string; threshold: string }): boolean {\n const { level, threshold } = opts;\n const levelRank = this.ORDER.indexOf(level);\n const thresholdRank = this.ORDER.indexOf(threshold);\n\n // An unknown level or threshold is never silenced: a typo must not hide a line.\n return levelRank < 0 || thresholdRank < 0 || levelRank <= thresholdRank;\n }\n}\n\nexport type TLogLevel = TConstValue<typeof LogLevels>;\n\n/** The logging contract every consumer types against; which provider produced the logger is invisible behind it - only `factory.ts` and a provider's back-compat aliases may name a concrete logger class. */\nexport interface ILogger {\n debug(message: string, ...args: AnyType[]): void;\n info(message: string, ...args: AnyType[]): void;\n warn(message: string, ...args: AnyType[]): void;\n error(message: string, ...args: AnyType[]): void;\n emerg(message: string, ...args: AnyType[]): void;\n log(level: TLogLevel, message: string, ...args: AnyType[]): void;\n for(methodName: string): ILogger;\n}\n\n/** Static-side contract a provider class satisfies - WinstonLogger and PinoLogger both do. */\nexport interface ILoggerProvider {\n get(scope: string): ILogger;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/logger/common/types.ts"],"names":[],"mappings":"AAEA,iHAAiH;AACjH,MAAM,OAAO,SAAS;aACJ,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAEhB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEjG,2GAA2G;aAC3F,UAAK,GAA0B;QAC7C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;KACX,CAAC;IAEF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,yHAAyH;IACzH,MAAM,CAAC,SAAS,CAAC,IAA0C;QACzD,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;QAClC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAEpD,gFAAgF;QAChF,OAAO,SAAS,GAAG,CAAC,IAAI,aAAa,GAAG,CAAC,IAAI,SAAS,IAAI,aAAa,CAAC;IAC1E,CAAC","sourcesContent":["import { type AnyType, type TConstValue } from '@/common/types';\n\n/** Log severities. `ORDER` runs from most to least severe, and `isEnabled` tests a level against a threshold. */\nexport class LogLevels {\n static readonly ERROR = 'error';\n static readonly EMERG = 'emerg';\n static readonly WARN = 'warn';\n static readonly INFO = 'info';\n static readonly DEBUG = 'debug';\n\n static readonly SCHEME_SET = new Set([this.ERROR, this.EMERG, this.WARN, this.INFO, this.DEBUG]);\n\n /** From the most to the least severe: a threshold lets through its own level and every level before it. */\n static readonly ORDER: ReadonlyArray<string> = [\n this.EMERG,\n this.ERROR,\n this.WARN,\n this.INFO,\n this.DEBUG,\n ];\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n\n /** Whether a line of `level` passes a `threshold`: `debug` lets everything through, `error` only `error` and `emerg`. */\n static isEnabled(opts: { level: string; threshold: string }): boolean {\n const { level, threshold } = opts;\n const levelRank = this.ORDER.indexOf(level);\n const thresholdRank = this.ORDER.indexOf(threshold);\n\n // An unknown level or threshold is never silenced: a typo must not hide a line.\n return levelRank < 0 || thresholdRank < 0 || levelRank <= thresholdRank;\n }\n}\n\n/** One of the `LogLevels` values. */\nexport type TLogLevel = TConstValue<typeof LogLevels>;\n\n/** The logging contract every consumer types against; which provider produced the logger is invisible behind it - only `factory.ts` and a provider's back-compat aliases may name a concrete logger class. */\nexport interface ILogger {\n debug(message: string, ...args: AnyType[]): void;\n info(message: string, ...args: AnyType[]): void;\n warn(message: string, ...args: AnyType[]): void;\n error(message: string, ...args: AnyType[]): void;\n emerg(message: string, ...args: AnyType[]): void;\n log(level: TLogLevel, message: string, ...args: AnyType[]): void;\n for(methodName: string): ILogger;\n}\n\n/** Static-side contract a provider class satisfies - WinstonLogger and PinoLogger both do. */\nexport interface ILoggerProvider {\n get(scope: string): ILogger;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
|
+
/** Renders a log message and its arguments to one string, redacting secret keys and inspecting objects to a bounded depth (`APP_ENV_LOGGER_INSPECT_DEPTH`, default 5). */
|
|
2
3
|
export declare class LogFormatUtility {
|
|
3
4
|
private static resolveDepth;
|
|
4
5
|
private static buildInspectOptions;
|
|
@@ -5,6 +5,7 @@ import { ErrorPrettier } from './error-prettier.js';
|
|
|
5
5
|
const PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;
|
|
6
6
|
/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */
|
|
7
7
|
const DEFAULT_INSPECT_DEPTH = 5;
|
|
8
|
+
/** Renders a log message and its arguments to one string, redacting secret keys and inspecting objects to a bounded depth (`APP_ENV_LOGGER_INSPECT_DEPTH`, default 5). */
|
|
8
9
|
export class LogFormatUtility {
|
|
9
10
|
static resolveDepth() {
|
|
10
11
|
const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,uQAAuQ;AACvQ,MAAM,qBAAqB,GAAG,CAAC,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f,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { RedactUtility } from '@/common/redact';\nimport util from 'node:util';\nimport { ErrorPrettier } from './error-prettier';\n\n/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */\nconst PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;\n\n/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */\nconst DEFAULT_INSPECT_DEPTH = 5;\n\nexport class LogFormatUtility {\n private static resolveDepth(): number {\n const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;\n\n // Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean \"depth 0\" - the one setting that hides everything.\n if (configured === undefined || configured.trim() === '') {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n const parsed = Number.parseInt(configured, 10);\n\n // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as \"unlimited\".\n if (Number.isNaN(parsed) || parsed < 0) {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n return parsed;\n }\n\n private static buildInspectOptions(): util.InspectOptions {\n return {\n depth: LogFormatUtility.resolveDepth(),\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n }\n\n /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */\n static formatMessage(opts: {\n message: string;\n args: Array<unknown>;\n inspectOptions?: util.InspectOptions;\n }): string {\n const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;\n\n const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter(\n (token) => token !== '%%',\n );\n\n const widened = args.map((arg, index) => {\n const placeholder = placeholders[index];\n const isInspectable = typeof arg === 'object' && arg !== null;\n\n if (!isInspectable) {\n return arg;\n }\n\n // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.\n if (placeholder === '%j') {\n return RedactUtility.toJsonSafe({\n value: arg,\n depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),\n });\n }\n\n // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but\n // left as objects, so `util.formatWithOptions` still renders them the way that placeholder\n // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string\n // instead of an object. Only the redaction is added; the rendering is unchanged.\n //\n // Before this, `logger.info('login failed', { password })` printed the password verbatim: the\n // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.\n //\n // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep\n // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a\n // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.\n if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {\n return RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n });\n }\n\n if (placeholder !== '%s') {\n return arg;\n }\n\n // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.\n if (arg instanceof Error) {\n return `\\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;\n }\n\n // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly\n // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a\n // QUOTED `'[Object]'` instead of its own bare `[Object]`.\n return util.inspect(\n RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n }),\n inspectOptions,\n );\n });\n\n return util.formatWithOptions(inspectOptions, message, ...widened);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"deep-splat.js","sourceRoot":"","sources":["../../../../../src/modules/logger/formatting/deep-splat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,wFAAwF;AACxF,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAE5C,uQAAuQ;AACvQ,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEhC,0KAA0K;AAC1K,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,YAAY;QACzB,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;QAE5D,6IAA6I;QAC7I,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACzD,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAE/C,mJAAmJ;QACnJ,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YACvC,OAAO,qBAAqB,CAAC;QAC/B,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,MAAM,CAAC,mBAAmB;QAChC,OAAO;YACL,KAAK,EAAE,gBAAgB,CAAC,YAAY,EAAE;YACtC,cAAc,EAAE,IAAI;YACpB,eAAe,EAAE,IAAI;YACrB,WAAW,EAAE,QAAQ;SACtB,CAAC;IACJ,CAAC;IAED,2TAA2T;IAC3T,MAAM,CAAC,aAAa,CAAC,IAIpB;QACC,MAAM,EAAE,OAAO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CAAC;gBACzB,OAAO,GAAG,CAAC;YACb,CAAC;YAED,kOAAkO;YAClO,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;gBACzB,OAAO,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,CAAC,EAAE,CAAC;YACrE,CAAC;YAED,4FAA4F;YAC5F,4FAA4F;YAC5F,0DAA0D;YAC1D,OAAO,IAAI,CAAC,OAAO,CACjB,aAAa,CAAC,aAAa,CAAC;gBAC1B,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,CAAC,cAAc,CAAC,KAAK,IAAI,gBAAgB,CAAC,YAAY,EAAE,CAAC,GAAG,CAAC;aACrE,CAAC,EACF,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,CAAC;IACrE,CAAC;CACF","sourcesContent":["import { RedactUtility } from '@/common/redact';\nimport util from 'node:util';\nimport { ErrorPrettier } from './error-prettier';\n\n/** The placeholders `util.format` understands. `%%` is an escape, not a placeholder. */\nconst PLACEHOLDER_PATTERN = /%[sjdifoOc%]/g;\n\n/** How deep an object is inspected before it collapses to `[Object]`: Node's default of 2 hides nested data (e.g. wrapped `cause`), 5 reaches it while staying bounded. `APP_ENV_LOGGER_INSPECT_DEPTH` overrides with a NON-NEGATIVE number - no unlimited setting. */\nconst DEFAULT_INSPECT_DEPTH = 5;\n\n/** Renders a log message and its arguments to one string, redacting secret keys and inspecting objects to a bounded depth (`APP_ENV_LOGGER_INSPECT_DEPTH`, default 5). */\nexport class LogFormatUtility {\n private static resolveDepth(): number {\n const configured = process.env.APP_ENV_LOGGER_INSPECT_DEPTH;\n\n // Not `ParseUtility.toInt()`: it answers 0 for an ABSENT value, which would silently mean \"depth 0\" - the one setting that hides everything.\n if (configured === undefined || configured.trim() === '') {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n const parsed = Number.parseInt(configured, 10);\n\n // A negative or unparseable value is a misconfiguration, not a request: fall back rather than hand `util.inspect` a depth it reads as \"unlimited\".\n if (Number.isNaN(parsed) || parsed < 0) {\n return DEFAULT_INSPECT_DEPTH;\n }\n\n return parsed;\n }\n\n private static buildInspectOptions(): util.InspectOptions {\n return {\n depth: LogFormatUtility.resolveDepth(),\n maxArrayLength: null,\n maxStringLength: null,\n breakLength: Infinity,\n };\n }\n\n /** Formats like `util.format`, but `%s` inspects to configured depth instead of Node's hard-coded `depth: 0` (no inspect option overrides that), and `%j` is projected into a JSON-safe shape first. Per-placeholder only - handing `%j` the widened STRING would emit a JSON-quoted inspect dump instead of an object. */\n static formatMessage(opts: {\n message: string;\n args: Array<unknown>;\n inspectOptions?: util.InspectOptions;\n }): string {\n const { message, args, inspectOptions = LogFormatUtility.buildInspectOptions() } = opts;\n\n const placeholders = (message.match(PLACEHOLDER_PATTERN) ?? []).filter(\n (token) => token !== '%%',\n );\n\n const widened = args.map((arg, index) => {\n const placeholder = placeholders[index];\n const isInspectable = typeof arg === 'object' && arg !== null;\n\n if (!isInspectable) {\n return arg;\n }\n\n // `%j` runs JSON.stringify, which answers `[Circular]` for the WHOLE argument when one cycle sits anywhere inside it - a transaction handle in the payload wipes out every other field. It also has no notion of secret keys, and no depth limit of its own. Project the value first, under the same depth cap `%s` gets.\n if (placeholder === '%j') {\n return RedactUtility.toJsonSafe({\n value: arg,\n depth: inspectOptions.depth ?? LogFormatUtility.resolveDepth(),\n });\n }\n\n // `%o`, `%O` and arguments with NO placeholder (`util.format` appends those) are redacted but\n // left as objects, so `util.formatWithOptions` still renders them the way that placeholder\n // means. Pre-inspecting them into a string here would make `%o` print a quoted, escaped string\n // instead of an object. Only the redaction is added; the rendering is unchanged.\n //\n // Before this, `logger.info('login failed', { password })` printed the password verbatim: the\n // redactor only ever saw `%s`, while the reference docs recommend `%o` for data objects.\n //\n // Bounded like the `%s` path below, and for the same reason: an unbounded walk on a very deep\n // graph is work whose result the renderer discards, and deep enough it is a `RangeError` on a\n // call that could not throw before. `%o` renders at `depth`, so `+2` covers what is shown.\n if (placeholder === undefined || placeholder === '%o' || placeholder === '%O') {\n return RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n });\n }\n\n if (placeholder !== '%s') {\n return arg;\n }\n\n // Inspecting an Error dumps every own property - a `jose` failure carries the whole JWT payload, a driver failure the whole query. Project it instead, onto its own line so it never trails off the end of the caller's sentence.\n if (arg instanceof Error) {\n return `\\n${ErrorPrettier.format({ error: arg, inspectOptions })}`;\n }\n\n // Bounded to just past what `util.inspect` will actually render. `+2`, not `+1`: at exactly\n // `depth + 1` the redactor replaces the last level with a string, and inspect then prints a\n // QUOTED `'[Object]'` instead of its own bare `[Object]`.\n return util.inspect(\n RedactUtility.redactSecrets({\n value: arg,\n depth: (inspectOptions.depth ?? LogFormatUtility.resolveDepth()) + 2,\n }),\n inspectOptions,\n );\n });\n\n return util.formatWithOptions(inspectOptions, message, ...widened);\n }\n}\n"]}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
import type { TLogLevel } from '../../common/index.js';
|
|
2
2
|
/** The levels the high-frequency logger writes: the shared log levels. */
|
|
3
3
|
export type THfLogLevel = TLogLevel;
|
|
4
|
+
/** One batch handed to a sink: the rendered `lines`, and `dropped`, the number of entries overwritten in the ring before they could be read. */
|
|
4
5
|
export type THfSinkBatch = {
|
|
5
6
|
lines: Array<string>;
|
|
6
7
|
dropped: number;
|
|
7
8
|
};
|
|
8
9
|
/** Declared `=> void` ON PURPOSE: TS's void-return exemption lets both sync and `async` sinks assign to it (`void | Promise<void>` would reject the sync form); the flusher still awaits a returned thenable, so a rejection is caught and logged, never unhandled. */
|
|
9
10
|
export type THfSink = (batch: THfSinkBatch) => void;
|
|
11
|
+
/** Where the high-frequency logger flusher delivers batches: a custom `sink`, a `filePath`, or stdout when neither is set. */
|
|
10
12
|
export interface IHfLogFlusherOptions {
|
|
11
13
|
/** Full custom delivery. Overrides filePath. */
|
|
12
14
|
sink?: THfSink;
|
|
13
|
-
/**
|
|
15
|
+
/** File the default sink appends to instead of writing to stdout. */
|
|
14
16
|
filePath?: string;
|
|
15
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Entries rendered per batch before yielding.
|
|
19
|
+
* @default HF_DEFAULT_BATCH_SIZE
|
|
20
|
+
*/
|
|
16
21
|
batchSize?: number;
|
|
17
22
|
}
|
|
18
23
|
export type TRingState = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TLogLevel } from '../../common';\n\n/** The levels the high-frequency logger writes: the shared log levels. */\nexport type THfLogLevel = TLogLevel;\n\nexport type THfSinkBatch = { lines: Array<string>; dropped: number };\n\n/** Declared `=> void` ON PURPOSE: TS's void-return exemption lets both sync and `async` sinks assign to it (`void | Promise<void>` would reject the sync form); the flusher still awaits a returned thenable, so a rejection is caught and logged, never unhandled. */\nexport type THfSink = (batch: THfSinkBatch) => void;\n\nexport interface IHfLogFlusherOptions {\n /** Full custom delivery. Overrides filePath. */\n sink?: THfSink;\n /**
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/hf/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TLogLevel } from '../../common';\n\n/** The levels the high-frequency logger writes: the shared log levels. */\nexport type THfLogLevel = TLogLevel;\n\n/** One batch handed to a sink: the rendered `lines`, and `dropped`, the number of entries overwritten in the ring before they could be read. */\nexport type THfSinkBatch = { lines: Array<string>; dropped: number };\n\n/** Declared `=> void` ON PURPOSE: TS's void-return exemption lets both sync and `async` sinks assign to it (`void | Promise<void>` would reject the sync form); the flusher still awaits a returned thenable, so a rejection is caught and logged, never unhandled. */\nexport type THfSink = (batch: THfSinkBatch) => void;\n\n/** Where the high-frequency logger flusher delivers batches: a custom `sink`, a `filePath`, or stdout when neither is set. */\nexport interface IHfLogFlusherOptions {\n /** Full custom delivery. Overrides filePath. */\n sink?: THfSink;\n /** File the default sink appends to instead of writing to stdout. */\n filePath?: string;\n /**\n * Entries rendered per batch before yielding.\n * @default HF_DEFAULT_BATCH_SIZE\n */\n batchSize?: number;\n}\n\nexport type TRingState = { bytes: Uint8Array; f64: Float64Array; writeIndex: number };\n"]}
|
|
@@ -2,6 +2,7 @@ import type dgram from 'node:dgram';
|
|
|
2
2
|
import type winston from 'winston';
|
|
3
3
|
import type Transport from 'winston-transport';
|
|
4
4
|
import { type TLogLevel, type TLoggerFormat } from '../../common/index.js';
|
|
5
|
+
/** Options of `DgramTransport`. Only lines whose level is in `levels` are sent, as UDP datagrams to `host:port`, tagged with `label`; `socketOptions` go to `dgram.createSocket`. */
|
|
5
6
|
export interface IDgramTransportOptions extends Transport.TransportStreamOptions {
|
|
6
7
|
label: string;
|
|
7
8
|
host: string;
|
|
@@ -9,14 +10,32 @@ export interface IDgramTransportOptions extends Transport.TransportStreamOptions
|
|
|
9
10
|
levels: Array<string>;
|
|
10
11
|
socketOptions: dgram.SocketOptions;
|
|
11
12
|
}
|
|
13
|
+
/** Daily-rotating log file written to `<folder>/<prefix>-<level>-%DATE%.log`. */
|
|
12
14
|
export interface IFileTransportOptions {
|
|
13
15
|
prefix: string;
|
|
14
16
|
folder: string;
|
|
17
|
+
/**
|
|
18
|
+
* How often the file rotates.
|
|
19
|
+
* @default the `APP_ENV_LOGGER_FILE_FREQUENCY` setting, else `'1h'`
|
|
20
|
+
*/
|
|
15
21
|
frequency?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Size at which a file rotates.
|
|
24
|
+
* @default the `APP_ENV_LOGGER_FILE_MAX_SIZE` setting, else `'100m'`
|
|
25
|
+
*/
|
|
16
26
|
maxSize?: string;
|
|
27
|
+
/**
|
|
28
|
+
* How many files, or days of files, are kept.
|
|
29
|
+
* @default the `APP_ENV_LOGGER_FILE_MAX_FILES` setting, else `'5d'`
|
|
30
|
+
*/
|
|
17
31
|
maxFiles?: string;
|
|
32
|
+
/**
|
|
33
|
+
* The date format in the file name.
|
|
34
|
+
* @default the `APP_ENV_LOGGER_FILE_DATE_PATTERN` setting, else `'YYYYMMDD_HH'`
|
|
35
|
+
*/
|
|
18
36
|
datePattern?: string;
|
|
19
37
|
}
|
|
38
|
+
/** Options for building a winston logger; `transports.info` and `transports.error` each take an optional file and datagram transport. */
|
|
20
39
|
export interface ICustomLoggerOptions {
|
|
21
40
|
levels?: {
|
|
22
41
|
[name: string | symbol]: number;
|
|
@@ -26,11 +45,20 @@ export interface ICustomLoggerOptions {
|
|
|
26
45
|
};
|
|
27
46
|
/** Full override of the logger-level format; when provided, transports get NO format of their own - the override is applied once for every transport, exactly as it produces the line. */
|
|
28
47
|
formatter?: ReturnType<typeof winston.format.combine>;
|
|
29
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Output shape per transport.
|
|
50
|
+
* @default the `APP_ENV_LOGGER_FORMAT` setting, else `'text'`
|
|
51
|
+
*/
|
|
30
52
|
format?: TLoggerFormat;
|
|
31
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Logger-level floor.
|
|
55
|
+
* @default the `APP_ENV_LOGGER_LEVEL` setting, else `'debug'`
|
|
56
|
+
*/
|
|
32
57
|
level?: TLogLevel;
|
|
33
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* ANSI color on the console transport in `text` mode. Ignored when `formatter` is set - that override owns the whole line.
|
|
60
|
+
* @default the `APP_ENV_LOGGER_COLOR` setting; else `false` under `NO_COLOR` or outside a development `NODE_ENV`; else `true`
|
|
61
|
+
*/
|
|
34
62
|
colorize?: boolean;
|
|
35
63
|
transports: {
|
|
36
64
|
info: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/winston/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type dgram from 'node:dgram';\nimport type winston from 'winston';\nimport type Transport from 'winston-transport';\nimport { type TLogLevel, type TLoggerFormat } from '../../common';\n\nexport interface IDgramTransportOptions extends Transport.TransportStreamOptions {\n label: string;\n host: string;\n port: number;\n levels: Array<string>;\n socketOptions: dgram.SocketOptions;\n}\n\nexport interface IFileTransportOptions {\n prefix: string;\n folder: string;\n frequency?: string;\n maxSize?: string;\n maxFiles?: string;\n datePattern?: string;\n}\n\nexport interface ICustomLoggerOptions {\n levels?: { [name: string | symbol]: number };\n colors?: { [name: string | symbol]: string };\n\n /** Full override of the logger-level format; when provided, transports get NO format of their own - the override is applied once for every transport, exactly as it produces the line. */\n formatter?: ReturnType<typeof winston.format.combine>;\n\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/winston/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type dgram from 'node:dgram';\nimport type winston from 'winston';\nimport type Transport from 'winston-transport';\nimport { type TLogLevel, type TLoggerFormat } from '../../common';\n\n/** Options of `DgramTransport`. Only lines whose level is in `levels` are sent, as UDP datagrams to `host:port`, tagged with `label`; `socketOptions` go to `dgram.createSocket`. */\nexport interface IDgramTransportOptions extends Transport.TransportStreamOptions {\n label: string;\n host: string;\n port: number;\n levels: Array<string>;\n socketOptions: dgram.SocketOptions;\n}\n\n/** Daily-rotating log file written to `<folder>/<prefix>-<level>-%DATE%.log`. */\nexport interface IFileTransportOptions {\n prefix: string;\n folder: string;\n /**\n * How often the file rotates.\n * @default the `APP_ENV_LOGGER_FILE_FREQUENCY` setting, else `'1h'`\n */\n frequency?: string;\n /**\n * Size at which a file rotates.\n * @default the `APP_ENV_LOGGER_FILE_MAX_SIZE` setting, else `'100m'`\n */\n maxSize?: string;\n /**\n * How many files, or days of files, are kept.\n * @default the `APP_ENV_LOGGER_FILE_MAX_FILES` setting, else `'5d'`\n */\n maxFiles?: string;\n /**\n * The date format in the file name.\n * @default the `APP_ENV_LOGGER_FILE_DATE_PATTERN` setting, else `'YYYYMMDD_HH'`\n */\n datePattern?: string;\n}\n\n/** Options for building a winston logger; `transports.info` and `transports.error` each take an optional file and datagram transport. */\nexport interface ICustomLoggerOptions {\n levels?: { [name: string | symbol]: number };\n colors?: { [name: string | symbol]: string };\n\n /** Full override of the logger-level format; when provided, transports get NO format of their own - the override is applied once for every transport, exactly as it produces the line. */\n formatter?: ReturnType<typeof winston.format.combine>;\n\n /**\n * Output shape per transport.\n * @default the `APP_ENV_LOGGER_FORMAT` setting, else `'text'`\n */\n format?: TLoggerFormat;\n\n /**\n * Logger-level floor.\n * @default the `APP_ENV_LOGGER_LEVEL` setting, else `'debug'`\n */\n level?: TLogLevel;\n\n /**\n * ANSI color on the console transport in `text` mode. Ignored when `formatter` is set - that override owns the whole line.\n * @default the `APP_ENV_LOGGER_COLOR` setting; else `false` under `NO_COLOR` or outside a development `NODE_ENV`; else `true`\n */\n colorize?: boolean;\n\n transports: {\n info: {\n file?: IFileTransportOptions;\n dgram?: Partial<IDgramTransportOptions>;\n };\n error: {\n file?: IFileTransportOptions;\n dgram?: Partial<IDgramTransportOptions>;\n };\n };\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type winston from 'winston';
|
|
2
|
+
/** The winston format that renders an application log line; the default logger uses it. */
|
|
2
3
|
export declare const applicationLogFormatter: winston.Logform.Format;
|
|
3
4
|
/** Module-internal only - NOT re-exported from `winston/index.ts`; the default winston backing WinstonLogger falls back to. */
|
|
4
5
|
export declare const defaultWinstonLogger: winston.Logger;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WinstonFormatFactory } from './formats.js';
|
|
2
2
|
import { WinstonLoggerFactory } from './logger-factory.js';
|
|
3
|
+
/** The winston format that renders an application log line; the default logger uses it. */
|
|
3
4
|
export const applicationLogFormatter = WinstonFormatFactory.applicationLogFormatter;
|
|
4
5
|
/** Module-internal only - NOT re-exported from `winston/index.ts`; the default winston backing WinstonLogger falls back to. */
|
|
5
6
|
export const defaultWinstonLogger = WinstonLoggerFactory.defaultLogger();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../../../src/modules/logger/winston/define.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,MAAM,CAAC,MAAM,uBAAuB,GAClC,oBAAoB,CAAC,uBAAuB,CAAC;AAE/C,+HAA+H;AAC/H,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,aAAa,EAAE,CAAC","sourcesContent":["import type winston from 'winston';\nimport { WinstonFormatFactory } from './formats';\nimport { WinstonLoggerFactory } from './logger-factory';\n\nexport const applicationLogFormatter: winston.Logform.Format =\n WinstonFormatFactory.applicationLogFormatter;\n\n/** Module-internal only - NOT re-exported from `winston/index.ts`; the default winston backing WinstonLogger falls back to. */\nexport const defaultWinstonLogger = WinstonLoggerFactory.defaultLogger();\n"]}
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../../../../../src/modules/logger/winston/define.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,2FAA2F;AAC3F,MAAM,CAAC,MAAM,uBAAuB,GAClC,oBAAoB,CAAC,uBAAuB,CAAC;AAE/C,+HAA+H;AAC/H,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,aAAa,EAAE,CAAC","sourcesContent":["import type winston from 'winston';\nimport { WinstonFormatFactory } from './formats';\nimport { WinstonLoggerFactory } from './logger-factory';\n\n/** The winston format that renders an application log line; the default logger uses it. */\nexport const applicationLogFormatter: winston.Logform.Format =\n WinstonFormatFactory.applicationLogFormatter;\n\n/** Module-internal only - NOT re-exported from `winston/index.ts`; the default winston backing WinstonLogger falls back to. */\nexport const defaultWinstonLogger = WinstonLoggerFactory.defaultLogger();\n"]}
|
|
@@ -2,6 +2,7 @@ import type winston from 'winston';
|
|
|
2
2
|
import { type AnyType } from '../../../common/types/index.js';
|
|
3
3
|
import { BaseLogger } from '../base/index.js';
|
|
4
4
|
import { type ILogger, type TLogLevel } from '../common/index.js';
|
|
5
|
+
/** `ILogger` backed by winston, obtained with `get(scope)`; also exported as `Logger`. Lines below the winston logger level are skipped before formatting. */
|
|
5
6
|
export declare class WinstonLogger extends BaseLogger {
|
|
6
7
|
private static cache;
|
|
7
8
|
private readonly _logger;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseLogger } from '../base/index.js';
|
|
2
2
|
import { defaultWinstonLogger } from './define.js';
|
|
3
|
+
/** `ILogger` backed by winston, obtained with `get(scope)`; also exported as `Logger`. Lines below the winston logger level are skipped before formatting. */
|
|
3
4
|
export class WinstonLogger extends BaseLogger {
|
|
4
5
|
static { this.cache = new Map(); }
|
|
5
6
|
constructor(scope, logger) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../src/modules/logger/winston/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC5B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAGxD,YAAoB,KAAa,EAAE,MAAsB;QACvD,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,4KAA4K;IAC5K,MAAM,CAAC,GAAG,CAAC,KAAa,EAAE,YAA6B;QACrD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;YACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,IAAiE;QAC/E,mFAAmF;QACnF,+FAA+F;QAC/F,6FAA6F;QAC7F,oCAAoC;QACpC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACnF,CAAC;IAES,KAAK,CAAC,IAAuB;QACrC,IAAI,IAAI,CAAC,OAAO,KAAK,oBAAoB,EAAE,CAAC;YAC1C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;;AAGH,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,CAAC","sourcesContent":["import type winston from 'winston';\nimport { type AnyType } from '@/common/types';\nimport { BaseLogger } from '../base';\nimport { type ILogger, type TLogLevel } from '../common';\nimport { defaultWinstonLogger } from './define';\n\nexport class WinstonLogger extends BaseLogger {\n private static cache = new Map<string, WinstonLogger>();\n private readonly _logger: winston.Logger;\n\n private constructor(scope: string, logger: winston.Logger) {\n super({ scope });\n this._logger = logger;\n }\n\n /** Default-backed loggers are cached per scope; a custom-backed logger is a fresh wrapper every call - a scope-keyed cache can't tell different winston instances apart. */\n static get(scope: string, customLogger?: winston.Logger): WinstonLogger {\n if (customLogger) {\n return new WinstonLogger(scope, customLogger);\n }\n\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new WinstonLogger(scope, defaultWinstonLogger);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n\n protected write(opts: { level: TLogLevel; message: string; args: Array<AnyType> }) {\n // Asked BEFORE handing the line to winston. The deep-splat format - redaction plus\n // `util.inspect` over the whole argument graph - runs as part of winston's pipeline, so a line\n // the level was going to discard was formatted in full first. Measured: 3.6 us per discarded\n // line, against 0.08 us once gated.\n if (!this._logger.isLevelEnabled(opts.level)) {\n return;\n }\n\n this._logger.log(opts.level, this._formattedPrefix + opts.message, ...opts.args);\n }\n\n protected child(opts: { scope: string }): ILogger {\n if (this._logger === defaultWinstonLogger) {\n return WinstonLogger.get(opts.scope);\n }\n\n return new WinstonLogger(opts.scope, this._logger);\n }\n}\n\nexport { WinstonLogger as Logger };\n"]}
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../../src/modules/logger/winston/logger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,8JAA8J;AAC9J,MAAM,OAAO,aAAc,SAAQ,UAAU;aAC5B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;IAGxD,YAAoB,KAAa,EAAE,MAAsB;QACvD,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,4KAA4K;IAC5K,MAAM,CAAC,GAAG,CAAC,KAAa,EAAE,YAA6B;QACrD,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,aAAa,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;YACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,KAAK,CAAC,IAAiE;QAC/E,mFAAmF;QACnF,+FAA+F;QAC/F,6FAA6F;QAC7F,oCAAoC;QACpC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,OAAO;QACT,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACnF,CAAC;IAES,KAAK,CAAC,IAAuB;QACrC,IAAI,IAAI,CAAC,OAAO,KAAK,oBAAoB,EAAE,CAAC;YAC1C,OAAO,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;;AAGH,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,CAAC","sourcesContent":["import type winston from 'winston';\nimport { type AnyType } from '@/common/types';\nimport { BaseLogger } from '../base';\nimport { type ILogger, type TLogLevel } from '../common';\nimport { defaultWinstonLogger } from './define';\n\n/** `ILogger` backed by winston, obtained with `get(scope)`; also exported as `Logger`. Lines below the winston logger level are skipped before formatting. */\nexport class WinstonLogger extends BaseLogger {\n private static cache = new Map<string, WinstonLogger>();\n private readonly _logger: winston.Logger;\n\n private constructor(scope: string, logger: winston.Logger) {\n super({ scope });\n this._logger = logger;\n }\n\n /** Default-backed loggers are cached per scope; a custom-backed logger is a fresh wrapper every call - a scope-keyed cache can't tell different winston instances apart. */\n static get(scope: string, customLogger?: winston.Logger): WinstonLogger {\n if (customLogger) {\n return new WinstonLogger(scope, customLogger);\n }\n\n let cached = this.cache.get(scope);\n\n if (!cached) {\n cached = new WinstonLogger(scope, defaultWinstonLogger);\n this.cache.set(scope, cached);\n }\n\n return cached;\n }\n\n protected write(opts: { level: TLogLevel; message: string; args: Array<AnyType> }) {\n // Asked BEFORE handing the line to winston. The deep-splat format - redaction plus\n // `util.inspect` over the whole argument graph - runs as part of winston's pipeline, so a line\n // the level was going to discard was formatted in full first. Measured: 3.6 us per discarded\n // line, against 0.08 us once gated.\n if (!this._logger.isLevelEnabled(opts.level)) {\n return;\n }\n\n this._logger.log(opts.level, this._formattedPrefix + opts.message, ...opts.args);\n }\n\n protected child(opts: { scope: string }): ILogger {\n if (this._logger === defaultWinstonLogger) {\n return WinstonLogger.get(opts.scope);\n }\n\n return new WinstonLogger(opts.scope, this._logger);\n }\n}\n\nexport { WinstonLogger as Logger };\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Transport from 'winston-transport';
|
|
2
2
|
import { type IDgramTransportOptions } from '../common/index.js';
|
|
3
|
+
/** Winston transport that sends the lines of the configured levels as UDP datagrams. A send failure is reported to the console and the socket is reopened on the next line; it never throws. `fromPartial` returns `null` when `label`, `host`, `port`, `levels` or `socketOptions` is missing. */
|
|
3
4
|
export declare class DgramTransport extends Transport {
|
|
4
5
|
private label;
|
|
5
6
|
private host;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import dgram from 'node:dgram';
|
|
2
2
|
import Transport from 'winston-transport';
|
|
3
|
+
/** Winston transport that sends the lines of the configured levels as UDP datagrams. A send failure is reported to the console and the socket is reopened on the next line; it never throws. `fromPartial` returns `null` when `label`, `host`, `port`, `levels` or `socketOptions` is missing. */
|
|
3
4
|
export class DgramTransport extends Transport {
|
|
4
5
|
constructor(opts) {
|
|
5
6
|
const { label, host, port, levels, socketOptions, ...defaultTransportOptions } = opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dgram.transport.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/winston/transports/dgram.transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAS3C,YAAY,IAA4B;QACtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,uBAAuB,EAAE,GAAG,IAAI,CAAC;QACtF,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAsC;QACvD,IACE,CAAC,IAAI,EAAE,KAAK;YACZ,CAAC,IAAI,EAAE,IAAI;YACX,CAAC,IAAI,EAAE,IAAI;YACX,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM;YACrB,CAAC,IAAI,EAAE,aAAa,EACpB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,IAAI,cAAc,CAAC,IAA8B,CAAC,CAAC;IAC5D,CAAC;IAEO,SAAS,CAAC,IAA4C;QAC5D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,YAAY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I,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACzD,IAAI,KAAK,EAAE,CAAC;gBACV,6PAA6P;gBAC7P,OAAO,CAAC,KAAK,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;gBAChF,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACrB,CAAC;YAED,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import dgram from 'node:dgram';\nimport Transport from 'winston-transport';\nimport { type IDgramTransportOptions } from '../common';\n\nexport class DgramTransport extends Transport {\n private label: string;\n private host: string;\n private port: number;\n private triggerLevels: Set<string>;\n private socketOptions: dgram.SocketOptions;\n\n private client: dgram.Socket | null;\n\n constructor(opts: IDgramTransportOptions) {\n const { label, host, port, levels, socketOptions, ...defaultTransportOptions } = opts;\n super(defaultTransportOptions);\n\n this.label = label;\n this.host = host;\n this.port = port;\n this.triggerLevels = new Set(levels);\n this.socketOptions = socketOptions;\n\n this.establish({ socketOptions: this.socketOptions });\n }\n\n static fromPartial(opts?: Partial<IDgramTransportOptions>): DgramTransport | null {\n if (\n !opts?.label ||\n !opts?.host ||\n !opts?.port ||\n !opts?.levels?.length ||\n !opts?.socketOptions\n ) {\n return null;\n }\n\n return new DgramTransport(opts as IDgramTransportOptions);\n }\n\n private establish(opts: { socketOptions: dgram.SocketOptions }) {\n this.client = dgram.createSocket(opts.socketOptions);\n\n this.client.on('error', (error) => {\n this.client?.close();\n this.client = null;\n\n console.error('[dgram][error] Error: ', error);\n });\n }\n\n private formatMessage(opts: { [extra: string | symbol]: any }) {\n const { timestamp, label, message, ...rest } = opts;\n\n return [timestamp, `[${this.label ?? label}]`, rest[Symbol.for('level')], message].join(' ');\n }\n\n override log(\n opts: {\n level: string;\n message: string;\n label?: string;\n timestamp?: string;\n [extra: symbol]: any;\n },\n callback: () => void,\n ) {\n setImmediate(() => {\n this.emit('logged', opts);\n });\n\n const logLevel = opts[Symbol.for('level')];\n\n if (!this.triggerLevels.has(logLevel)) {\n callback();\n\n return;\n }\n\n if (!this.client) {\n this.establish({ socketOptions: this.socketOptions });\n }\n\n const message = this.formatMessage(opts);\n this.client?.send(message, this.port, this.host, (error) => {\n if (error) {\n // console, not the Logger and not an 'error' EVENT: routing through the Logger would re-enter this very transport, and emitting 'error' with no listener attached kills the process over one lost UDP log line. Drop the socket so the next line reconnects.\n console.error('[DgramTransport][log] Failed to ship log line | error: ', error);\n this.client?.close();\n this.client = null;\n }\n\n callback();\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dgram.transport.js","sourceRoot":"","sources":["../../../../../../src/modules/logger/winston/transports/dgram.transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAG1C,mSAAmS;AACnS,MAAM,OAAO,cAAe,SAAQ,SAAS;IAS3C,YAAY,IAA4B;QACtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,uBAAuB,EAAE,GAAG,IAAI,CAAC;QACtF,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAE/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QAEnC,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAAsC;QACvD,IACE,CAAC,IAAI,EAAE,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,QAAQ,CAAC,EAAE,CAAC;YACtC,QAAQ,EAAE,CAAC;YAEX,OAAO;QACT,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE;YACzD,IAAI,KAAK,EAAE,CAAC;gBACV,6PAA6P;gBAC7P,OAAO,CAAC,KAAK,CAAC,yDAAyD,EAAE,KAAK,CAAC,CAAC;gBAChF,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC;gBACrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACrB,CAAC;YAED,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import dgram from 'node:dgram';\nimport Transport from 'winston-transport';\nimport { type IDgramTransportOptions } from '../common';\n\n/** Winston transport that sends the lines of the configured levels as UDP datagrams. A send failure is reported to the console and the socket is reopened on the next line; it never throws. `fromPartial` returns `null` when `label`, `host`, `port`, `levels` or `socketOptions` is missing. */\nexport class DgramTransport extends Transport {\n private label: string;\n private host: string;\n private port: number;\n private triggerLevels: Set<string>;\n private socketOptions: dgram.SocketOptions;\n\n private client: dgram.Socket | null;\n\n constructor(opts: IDgramTransportOptions) {\n const { label, host, port, levels, socketOptions, ...defaultTransportOptions } = opts;\n super(defaultTransportOptions);\n\n this.label = label;\n this.host = host;\n this.port = port;\n this.triggerLevels = new Set(levels);\n this.socketOptions = socketOptions;\n\n this.establish({ socketOptions: this.socketOptions });\n }\n\n static fromPartial(opts?: Partial<IDgramTransportOptions>): DgramTransport | null {\n if (\n !opts?.label ||\n !opts?.host ||\n !opts?.port ||\n !opts?.levels?.length ||\n !opts?.socketOptions\n ) {\n return null;\n }\n\n return new DgramTransport(opts as IDgramTransportOptions);\n }\n\n private establish(opts: { socketOptions: dgram.SocketOptions }) {\n this.client = dgram.createSocket(opts.socketOptions);\n\n this.client.on('error', (error) => {\n this.client?.close();\n this.client = null;\n\n console.error('[dgram][error] Error: ', error);\n });\n }\n\n private formatMessage(opts: { [extra: string | symbol]: any }) {\n const { timestamp, label, message, ...rest } = opts;\n\n return [timestamp, `[${this.label ?? label}]`, rest[Symbol.for('level')], message].join(' ');\n }\n\n override log(\n opts: {\n level: string;\n message: string;\n label?: string;\n timestamp?: string;\n [extra: symbol]: any;\n },\n callback: () => void,\n ) {\n setImmediate(() => {\n this.emit('logged', opts);\n });\n\n const logLevel = opts[Symbol.for('level')];\n\n if (!this.triggerLevels.has(logLevel)) {\n callback();\n\n return;\n }\n\n if (!this.client) {\n this.establish({ socketOptions: this.socketOptions });\n }\n\n const message = this.formatMessage(opts);\n this.client?.send(message, this.port, this.host, (error) => {\n if (error) {\n // console, not the Logger and not an 'error' EVENT: routing through the Logger would re-enter this very transport, and emitting 'error' with no listener attached kills the process over one lost UDP log line. Drop the socket so the next line reconnects.\n console.error('[DgramTransport][log] Failed to ship log line | error: ', error);\n this.client?.close();\n this.client = null;\n }\n\n callback();\n });\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { BaseHelper } from '../../base.js';
|
|
|
2
2
|
import { type TFetcherVariant } from './common/index.js';
|
|
3
3
|
import { type IFetchable, type IRequestOptions } from './fetcher/base-fetcher.js';
|
|
4
4
|
import { type TFetcherResponse, type TFetcherWorker } from './fetcher/common/index.js';
|
|
5
|
+
/** Base of a client for one third-party HTTP API: holds the `baseUrl` and a fetcher, and builds request urls from path segments. `getRequestUrl` throws a 500 error when no base url is set. */
|
|
5
6
|
export declare class BaseNetworkRequest<T extends TFetcherVariant> extends BaseHelper {
|
|
6
7
|
protected baseUrl: string;
|
|
7
8
|
protected fetcher: IFetchable<T, IRequestOptions, TFetcherResponse<T>, TFetcherWorker<T>>;
|
|
@@ -2,6 +2,7 @@ import { HTTP } from '../../../common/constants/http.js';
|
|
|
2
2
|
import { ObjectUtility } from '@venizia/ignis-inversion';
|
|
3
3
|
import { BaseHelper } from '../../base.js';
|
|
4
4
|
import { getError } from '../../error/index.js';
|
|
5
|
+
/** Base of a client for one third-party HTTP API: holds the `baseUrl` and a fetcher, and builds request urls from path segments. `getRequestUrl` throws a 500 error when no base url is set. */
|
|
5
6
|
export class BaseNetworkRequest extends BaseHelper {
|
|
6
7
|
constructor(opts) {
|
|
7
8
|
super({ scope: opts.name, identifier: opts.name });
|