@venizia/ignis-helpers 0.4.8-0 → 0.4.8-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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,7 +1,20 @@
|
|
|
1
1
|
import { type TConstValue } from '../types/index.js';
|
|
2
|
+
/** Application-wide defaults: the application name and the paging values of a list query. */
|
|
2
3
|
export declare class Defaults {
|
|
4
|
+
/**
|
|
5
|
+
* The application name; reads `APP_ENV_APPLICATION_NAME`.
|
|
6
|
+
* @default 'APP'
|
|
7
|
+
*/
|
|
3
8
|
static readonly APPLICATION_NAME: string;
|
|
9
|
+
/**
|
|
10
|
+
* Rows a list query returns.
|
|
11
|
+
* @default 50
|
|
12
|
+
*/
|
|
4
13
|
static readonly QUERY_LIMIT = 50;
|
|
14
|
+
/**
|
|
15
|
+
* Rows a list query skips.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
5
18
|
static readonly QUERY_OFFSET = 0;
|
|
6
19
|
}
|
|
7
20
|
/** IGNIS runs on Bun only: `detect()` answers `'bun'` there and `undefined` anywhere else (a browser, another runtime). */
|
|
@@ -10,7 +23,9 @@ export declare class RuntimeModules {
|
|
|
10
23
|
static detect(): TRuntimeModule | undefined;
|
|
11
24
|
static isBun(): boolean;
|
|
12
25
|
}
|
|
26
|
+
/** The runtime names `RuntimeModules` holds; only `bun` today. */
|
|
13
27
|
export type TRuntimeModule = TConstValue<typeof RuntimeModules>;
|
|
28
|
+
/** The value kinds a stored field can hold; `isValid` tests a string against them. */
|
|
14
29
|
export declare class DataTypes {
|
|
15
30
|
static readonly NUMBER = "NUMBER";
|
|
16
31
|
static readonly TEXT = "TEXT";
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
/** Application-wide defaults: the application name and the paging values of a list query. */
|
|
1
2
|
export class Defaults {
|
|
3
|
+
/**
|
|
4
|
+
* The application name; reads `APP_ENV_APPLICATION_NAME`.
|
|
5
|
+
* @default 'APP'
|
|
6
|
+
*/
|
|
2
7
|
static { this.APPLICATION_NAME = globalThis.process?.env?.APP_ENV_APPLICATION_NAME ?? 'APP'; }
|
|
8
|
+
/**
|
|
9
|
+
* Rows a list query returns.
|
|
10
|
+
* @default 50
|
|
11
|
+
*/
|
|
3
12
|
static { this.QUERY_LIMIT = 50; }
|
|
13
|
+
/**
|
|
14
|
+
* Rows a list query skips.
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
4
17
|
static { this.QUERY_OFFSET = 0; }
|
|
5
18
|
}
|
|
6
19
|
/** IGNIS runs on Bun only: `detect()` answers `'bun'` there and `undefined` anywhere else (a browser, another runtime). */
|
|
@@ -13,6 +26,7 @@ export class RuntimeModules {
|
|
|
13
26
|
return RuntimeModules.detect() === RuntimeModules.BUN;
|
|
14
27
|
}
|
|
15
28
|
}
|
|
29
|
+
/** The value kinds a stored field can hold; `isValid` tests a string against them. */
|
|
16
30
|
export class DataTypes {
|
|
17
31
|
static { this.NUMBER = 'NUMBER'; }
|
|
18
32
|
static { this.TEXT = 'TEXT'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../../src/common/constants/app.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,QAAQ;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../../src/common/constants/app.ts"],"names":[],"mappings":"AAEA,6FAA6F;AAC7F,MAAM,OAAO,QAAQ;IACnB;;;OAGG;aACa,qBAAgB,GAAG,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,wBAAwB,IAAI,KAAK,CAAC;IAE9F;;;OAGG;aACa,gBAAW,GAAG,EAAE,CAAC;IACjC;;;OAGG;aACa,iBAAY,GAAG,CAAC,CAAC;;AAGnC,2HAA2H;AAC3H,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,KAAK,CAAC;IAE5B,MAAM,CAAC,MAAM;QACX,OAAO,OAAO,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;IACrE,CAAC;IAED,MAAM,CAAC,KAAK;QACV,OAAO,cAAc,CAAC,MAAM,EAAE,KAAK,cAAc,CAAC,GAAG,CAAC;IACxD,CAAC;;AAKH,sFAAsF;AACtF,MAAM,OAAO,SAAS;aACJ,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,SAAI,GAAG,MAAM,CAAC;aACd,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** Application-wide defaults: the application name and the paging values of a list query. */\nexport class Defaults {\n /**\n * The application name; reads `APP_ENV_APPLICATION_NAME`.\n * @default 'APP'\n */\n static readonly APPLICATION_NAME = globalThis.process?.env?.APP_ENV_APPLICATION_NAME ?? 'APP';\n\n /**\n * Rows a list query returns.\n * @default 50\n */\n static readonly QUERY_LIMIT = 50;\n /**\n * Rows a list query skips.\n * @default 0\n */\n static readonly QUERY_OFFSET = 0;\n}\n\n/** IGNIS runs on Bun only: `detect()` answers `'bun'` there and `undefined` anywhere else (a browser, another runtime). */\nexport class RuntimeModules {\n static readonly BUN = 'bun';\n\n static detect(): TRuntimeModule | undefined {\n return typeof Bun !== 'undefined' ? RuntimeModules.BUN : undefined;\n }\n\n static isBun(): boolean {\n return RuntimeModules.detect() === RuntimeModules.BUN;\n }\n}\n/** The runtime names `RuntimeModules` holds; only `bun` today. */\nexport type TRuntimeModule = TConstValue<typeof RuntimeModules>;\n\n/** The value kinds a stored field can hold; `isValid` tests a string against them. */\nexport class DataTypes {\n static readonly NUMBER = 'NUMBER';\n static readonly TEXT = 'TEXT';\n static readonly BYTE = 'BYTE';\n static readonly JSON = 'JSON';\n static readonly BOOLEAN = 'BOOLEAN';\n\n static readonly SCHEME_SET = new Set([\n this.NUMBER,\n this.TEXT,\n this.BYTE,\n this.JSON,\n this.BOOLEAN,\n ]);\n\n static isValid(orgType: string): boolean {\n return this.SCHEME_SET.has(orgType);\n }\n}\n"]}
|
|
@@ -12,6 +12,7 @@ export declare class DurationUnits {
|
|
|
12
12
|
static readonly SCHEME_SET: Set<string>;
|
|
13
13
|
static isValid(input: string): input is TDurationUnit;
|
|
14
14
|
}
|
|
15
|
+
/** One of the `DurationUnits` values, e.g. `'second'`. */
|
|
15
16
|
export type TDurationUnit = TConstValue<typeof DurationUnits>;
|
|
16
17
|
/**
|
|
17
18
|
* Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so
|
|
@@ -55,6 +56,7 @@ export declare class DurationAliases {
|
|
|
55
56
|
/** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */
|
|
56
57
|
static resolve(input: string): TDurationUnit | null;
|
|
57
58
|
}
|
|
59
|
+
/** A parsed duration: a `value` counted in `unit`. The value may be negative or fractional. */
|
|
58
60
|
export interface IDuration {
|
|
59
61
|
unit: TDurationUnit;
|
|
60
62
|
value: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;KACV,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;aACV,OAAE,GAAG,aAAa,CAAC,WAAW,CAAC;aAC/B,SAAI,GAAG,aAAa,CAAC,WAAW,CAAC;aACjC,gBAAW,GAAG,aAAa,CAAC,WAAW,CAAC;aACxC,iBAAY,GAAG,aAAa,CAAC,WAAW,CAAC;aAEzC,MAAC,GAAG,aAAa,CAAC,MAAM,CAAC;aACzB,QAAG,GAAG,aAAa,CAAC,MAAM,CAAC;aAC3B,WAAM,GAAG,aAAa,CAAC,MAAM,CAAC;aAC9B,YAAO,GAAG,aAAa,CAAC,MAAM,CAAC;aAE/B,MAAC,GAAG,aAAa,CAAC,MAAM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AAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TDurationUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /** The multiplier of a known unit, `null` for anything else - inherited property names included. */\n private static multiplierOf(unit: unknown): number | null {\n return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;\n }\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone\n * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.multiplierOf(opts.unit);\n\n if (multiplier === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.multiplierOf(opts?.unit);\n\n if (multiplier === null || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.multiplierOf(opts?.from);\n const target = this.multiplierOf(opts?.to);\n\n if (source === null || target === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../src/common/constants/duration.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,OAAO,aAAa;aACR,gBAAW,GAAG,aAAa,CAAC;aAC5B,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,SAAI,GAAG,MAAM,CAAC;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aACd,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC;QACnC,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,GAAG;QACR,IAAI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QAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAEpD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QAED,MAAM,IAAI,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,qGAAqG;IACrG,MAAM,CAAC,mBAAmB,CAAC,KAAa;QACtC,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChD,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The time units a duration can be expressed in, smallest first. */\nexport class DurationUnits {\n static readonly MILLISECOND = 'millisecond';\n static readonly SECOND = 'second';\n static readonly MINUTE = 'minute';\n static readonly HOUR = 'hour';\n static readonly DAY = 'day';\n static readonly WEEK = 'week';\n static readonly MONTH = 'month';\n static readonly YEAR = 'year';\n\n static readonly SCHEME_SET = new Set([\n this.MILLISECOND,\n this.SECOND,\n this.MINUTE,\n this.HOUR,\n this.DAY,\n this.WEEK,\n this.MONTH,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TDurationUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** One of the `DurationUnits` values, e.g. `'second'`. */\nexport type TDurationUnit = TConstValue<typeof DurationUnits>;\n\n/**\n * Written spellings that resolve to a unit. Member names are the spelling, upper-cased - so\n * {@link resolve} upper-cases its input and reads one property, with no second table to keep in step.\n *\n * `M` is MINUTE and `MO` is MONTH - the same choice every duration library makes, and the one\n * ambiguity a reader will trip on. There is no single-letter month.\n */\nexport class DurationAliases {\n static readonly MS = DurationUnits.MILLISECOND;\n static readonly MSEC = DurationUnits.MILLISECOND;\n static readonly MILLISECOND = DurationUnits.MILLISECOND;\n static readonly MILLISECONDS = DurationUnits.MILLISECOND;\n\n static readonly S = DurationUnits.SECOND;\n static readonly SEC = DurationUnits.SECOND;\n static readonly SECOND = DurationUnits.SECOND;\n static readonly SECONDS = DurationUnits.SECOND;\n\n static readonly M = DurationUnits.MINUTE;\n static readonly MIN = DurationUnits.MINUTE;\n static readonly MINUTE = DurationUnits.MINUTE;\n static readonly MINUTES = DurationUnits.MINUTE;\n\n static readonly H = DurationUnits.HOUR;\n static readonly HR = DurationUnits.HOUR;\n static readonly HOUR = DurationUnits.HOUR;\n static readonly HOURS = DurationUnits.HOUR;\n\n static readonly D = DurationUnits.DAY;\n static readonly DAY = DurationUnits.DAY;\n static readonly DAYS = DurationUnits.DAY;\n\n static readonly W = DurationUnits.WEEK;\n static readonly WK = DurationUnits.WEEK;\n static readonly WEEK = DurationUnits.WEEK;\n static readonly WEEKS = DurationUnits.WEEK;\n\n static readonly MO = DurationUnits.MONTH;\n static readonly MON = DurationUnits.MONTH;\n static readonly MONTH = DurationUnits.MONTH;\n static readonly MONTHS = DurationUnits.MONTH;\n\n static readonly Y = DurationUnits.YEAR;\n static readonly YR = DurationUnits.YEAR;\n static readonly YEAR = DurationUnits.YEAR;\n static readonly YEARS = DurationUnits.YEAR;\n\n /** Resolves a written unit - `'d'`, `'days'`, `'DAY'` - to its canonical name, or `null`. */\n static resolve(input: string): TDurationUnit | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n // Try the input as given first. `trim().toUpperCase()` allocates two strings and costs ~55ns,\n // where the lookup itself is ~1ns - so the spellings callers actually pass (`'day'`, `'d'`,\n // `'DAYS'`) must not pay for it. Measured, both ways.\n //\n // The table is declared below because it is derived FROM this class; it is read at call time,\n // never at class-evaluation time.\n /* eslint-disable @typescript-eslint/no-use-before-define */\n return ALIAS_LOOKUP.get(input) ?? ALIAS_LOOKUP.get(input.trim().toUpperCase()) ?? null;\n /* eslint-enable @typescript-eslint/no-use-before-define */\n }\n}\n\n/**\n * Derived from the class once, never hand-listed, so the two cannot drift. Reading the class\n * directly is slower and would need `name`/`length`/`constructor` guarded out. Each spelling is\n * stored upper and lower so the common call allocates nothing.\n */\nconst ALIAS_LOOKUP: Map<string, TDurationUnit> = new Map(\n Object.entries(DurationAliases)\n .filter((entry): entry is [string, TDurationUnit] => DurationUnits.isValid(entry[1] as string))\n .flatMap(([spelling, unit]): Array<[string, TDurationUnit]> => [\n [spelling, unit],\n [spelling.toLowerCase(), unit],\n ]),\n);\n\n/** A parsed duration: a `value` counted in `unit`. The value may be negative or fractional. */\nexport interface IDuration {\n unit: TDurationUnit;\n value: number;\n}\n\n/** `30d`, `1500 ms`, `-2 Hours`. One number, optional space, one unit. */\nconst DURATION_PATTERN = /^([+-]?\\d+(?:\\.\\d+)?)\\s*([a-z]+)$/i;\n\n/**\n * A month is 30 days and a year 365, nominal. These size a WINDOW - a grace period, a cache TTL, a\n * near-expiry horizon - and must never compute a calendar date: adding `MONTH` to 31 January lands\n * on 2 March in a leap year and 3 March otherwise. Use a date library for calendar arithmetic.\n */\nexport class DurationMultipliers {\n static readonly MILLISECOND = 1;\n static readonly SECOND = 1000 * this.MILLISECOND;\n static readonly MINUTE = 60 * this.SECOND;\n static readonly HOUR = 60 * this.MINUTE;\n static readonly DAY = 24 * this.HOUR;\n static readonly WEEK = 7 * this.DAY;\n static readonly MONTH = 30 * this.DAY;\n static readonly YEAR = 365 * this.DAY;\n\n static readonly BY_UNIT: Record<string, number> = {\n [DurationUnits.MILLISECOND]: this.MILLISECOND,\n [DurationUnits.SECOND]: this.SECOND,\n [DurationUnits.MINUTE]: this.MINUTE,\n [DurationUnits.HOUR]: this.HOUR,\n [DurationUnits.DAY]: this.DAY,\n [DurationUnits.WEEK]: this.WEEK,\n [DurationUnits.MONTH]: this.MONTH,\n [DurationUnits.YEAR]: this.YEAR,\n };\n\n /** The multiplier of a known unit, `null` for anything else - inherited property names included. */\n private static multiplierOf(unit: unknown): number | null {\n return typeof unit === 'string' && DurationUnits.isValid(unit) ? this.BY_UNIT[unit] : null;\n }\n\n /**\n * `null` rather than a throw, so a caller that wants an error raises its own with its own context.\n * Every method here answers the same way.\n *\n * The unit is checked against {@link DurationUnits.SCHEME_SET} first: a plain-object read alone\n * would answer `'constructor'` or `'toString'` with a member of `Object.prototype`, not `undefined`.\n */\n static toMilliseconds(opts: IDuration | null): number | null {\n if (!opts) {\n return null;\n }\n\n const multiplier = this.multiplierOf(opts.unit);\n\n if (multiplier === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return Math.round(opts.value * multiplier);\n }\n\n /** The inverse of {@link toMilliseconds}. Fractional on purpose - rounding here would silently lose a 36-hour window asked for in days. */\n static fromMilliseconds(opts: { milliseconds: number; unit: TDurationUnit }): number | null {\n const multiplier = this.multiplierOf(opts?.unit);\n\n if (multiplier === null || !Number.isFinite(opts.milliseconds)) {\n return null;\n }\n\n return opts.milliseconds / multiplier;\n }\n\n /** Unit to unit, through milliseconds. Fractional, for the reason {@link fromMilliseconds} gives. */\n static convert(opts: { value: number; from: TDurationUnit; to: TDurationUnit }): number | null {\n const source = this.multiplierOf(opts?.from);\n const target = this.multiplierOf(opts?.to);\n\n if (source === null || target === null || !Number.isFinite(opts.value)) {\n return null;\n }\n\n return (opts.value * source) / target;\n }\n\n /** Reads a written duration - `'30d'`, `'1500 ms'`, `'2 hours'` - into {@link IDuration}. Aliases and the `M`/`MO` rule are on {@link DurationAliases}. */\n static parse(input: string): IDuration | null {\n if (typeof input !== 'string') {\n return null;\n }\n\n const matched = DURATION_PATTERN.exec(input.trim());\n\n if (!matched) {\n return null;\n }\n\n const unit = DurationAliases.resolve(matched[2]);\n const value = Number(matched[1]);\n\n if (!unit || !Number.isFinite(value)) {\n return null;\n }\n\n return { unit, value };\n }\n\n /** `'30d'` straight to milliseconds - the shape a TTL or a grace period is usually configured in. */\n static parseToMilliseconds(input: string): number | null {\n return this.toMilliseconds(this.parse(input));\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ValueOf } from '../types/index.js';
|
|
2
|
+
/** gRPC constants: call kinds, protocol headers and header values, and the numeric status codes by name. */
|
|
2
3
|
export declare class GRPC {
|
|
3
4
|
/** Standard gRPC methods (lowercase). */
|
|
4
5
|
static readonly Methods: {
|
|
@@ -55,6 +56,8 @@ export declare class GRPC {
|
|
|
55
56
|
readonly UNAUTHENTICATED: 16;
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
/** A gRPC call kind from `GRPC.Methods`, lowercase. */
|
|
58
60
|
export type TGrpcMethod = ValueOf<typeof GRPC.Methods>;
|
|
61
|
+
/** A numeric gRPC status code from `GRPC.ResultCodes` (`0` is OK). */
|
|
59
62
|
export type TGrpcResultCode = ValueOf<typeof GRPC.ResultCodes>;
|
|
60
63
|
//# sourceMappingURL=grpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../../../src/common/constants/grpc.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,IAAI;IACf,yCAAyC;aACzB,YAAO,GAAG;QACxB,KAAK,EAAE,OAAO;QACd,gBAAgB,EAAE,kBAAkB;QACpC,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;KACxB,CAAC;IAEX,0DAA0D;aAC1C,YAAO,GAAG;QACxB,YAAY,EAAE,cAAc;QAC5B,EAAE,EAAE,IAAI;QACR,UAAU,EAAE,YAAY;QAExB,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe;QAC9B,oBAAoB,EAAE,sBAAsB;QAC5C,iBAAiB,EAAE,mBAAmB;QAEtC,WAAW,EAAE,aAAa;QAC1B,YAAY,EAAE,cAAc;QAC5B,uBAAuB,EAAE,yBAAyB;QAElD,0BAA0B,EAAE,4BAA4B;QACxD,sBAAsB,EAAE,wBAAwB;QAEhD,cAAc,EAAE,gBAAgB;QAChC,aAAa,EAAE,eAAe;KACtB,CAAC;IAEX,uCAAuC;aACvB,iBAAY,GAAG;QAC7B,IAAI,EAAE,kBAAkB;QACxB,UAAU,EAAE,wBAAwB;QACpC,SAAS,EAAE,uBAAuB;QAClC,QAAQ,EAAE,sBAAsB;QAChC,cAAc,EAAE,4BAA4B;QAC5C,aAAa,EAAE,2BAA2B;QAC1C,aAAa,EAAE,2BAA2B;KAClC,CAAC;IAEX,oDAAoD;aACpC,gBAAW,GAAG;QAC5B,EAAE,EAAE,CAAC;QACL,SAAS,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;QACV,gBAAgB,EAAE,CAAC;QACnB,iBAAiB,EAAE,CAAC;QACpB,SAAS,EAAE,CAAC;QACZ,cAAc,EAAE,CAAC;QACjB,iBAAiB,EAAE,CAAC;QACpB,kBAAkB,EAAE,CAAC;QACrB,mBAAmB,EAAE,CAAC;QACtB,OAAO,EAAE,EAAE;QACX,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;QACjB,QAAQ,EAAE,EAAE;QACZ,WAAW,EAAE,EAAE;QACf,SAAS,EAAE,EAAE;QACb,eAAe,EAAE,EAAE;KACX,CAAC","sourcesContent":["import { type ValueOf } from '../types';\n\nexport class GRPC {\n /** Standard gRPC methods (lowercase). */\n static readonly Methods = {\n UNARY: 'unary',\n SERVER_STREAMING: 'server_streaming',\n CLIENT_STREAMING: 'client_streaming',\n BIDI_STREAMING: 'bidi_streaming',\n } as const;\n\n /** Standard gRPC protocol headers (PROTOCOL-HTTP2.md). */\n static readonly Headers = {\n CONTENT_TYPE: 'content-type',\n TE: 'te',\n USER_AGENT: 'user-agent',\n\n GRPC_TIMEOUT: 'grpc-timeout',\n GRPC_ENCODING: 'grpc-encoding',\n GRPC_ACCEPT_ENCODING: 'grpc-accept-encoding',\n GRPC_MESSAGE_TYPE: 'grpc-message-type',\n\n GRPC_STATUS: 'grpc-status',\n GRPC_MESSAGE: 'grpc-message',\n GRPC_STATUS_DETAILS_BIN: 'grpc-status-details-bin',\n\n GRPC_PREVIOUS_RPC_ATTEMPTS: 'grpc-previous-rpc-attempts',\n GRPC_RETRY_PUSHBACK_MS: 'grpc-retry-pushback-ms',\n\n GRPC_TRACE_BIN: 'grpc-trace-bin',\n GRPC_TAGS_BIN: 'grpc-tags-bin',\n } as const;\n\n /** gRPC MIME / Content-Type values. */\n static readonly HeaderValues = {\n GRPC: 'application/grpc',\n GRPC_PROTO: 'application/grpc+proto',\n GRPC_JSON: 'application/grpc+json',\n GRPC_WEB: 'application/grpc-web',\n GRPC_WEB_PROTO: 'application/grpc-web+proto',\n GRPC_WEB_JSON: 'application/grpc-web+json',\n GRPC_WEB_TEXT: 'application/grpc-web-text',\n } as const;\n\n /** Standard gRPC status codes (google.rpc.Code). */\n static readonly ResultCodes = {\n OK: 0,\n CANCELLED: 1,\n UNKNOWN: 2,\n INVALID_ARGUMENT: 3,\n DEADLINE_EXCEEDED: 4,\n NOT_FOUND: 5,\n ALREADY_EXISTS: 6,\n PERMISSION_DENIED: 7,\n RESOURCE_EXHAUSTED: 8,\n FAILED_PRECONDITION: 9,\n ABORTED: 10,\n OUT_OF_RANGE: 11,\n UNIMPLEMENTED: 12,\n INTERNAL: 13,\n UNAVAILABLE: 14,\n DATA_LOSS: 15,\n UNAUTHENTICATED: 16,\n } as const;\n}\n\nexport type TGrpcMethod = ValueOf<typeof GRPC.Methods>;\nexport type TGrpcResultCode = ValueOf<typeof GRPC.ResultCodes>;\n"]}
|
|
1
|
+
{"version":3,"file":"grpc.js","sourceRoot":"","sources":["../../../../src/common/constants/grpc.ts"],"names":[],"mappings":"AAEA,4GAA4G;AAC5G,MAAM,OAAO,IAAI;IACf,yCAAyC;aACzB,YAAO,GAAG;QACxB,KAAK,EAAE,OA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f } from '../types';\n\n/** gRPC constants: call kinds, protocol headers and header values, and the numeric status codes by name. */\nexport class GRPC {\n /** Standard gRPC methods (lowercase). */\n static readonly Methods = {\n UNARY: 'unary',\n SERVER_STREAMING: 'server_streaming',\n CLIENT_STREAMING: 'client_streaming',\n BIDI_STREAMING: 'bidi_streaming',\n } as const;\n\n /** Standard gRPC protocol headers (PROTOCOL-HTTP2.md). */\n static readonly Headers = {\n CONTENT_TYPE: 'content-type',\n TE: 'te',\n USER_AGENT: 'user-agent',\n\n GRPC_TIMEOUT: 'grpc-timeout',\n GRPC_ENCODING: 'grpc-encoding',\n GRPC_ACCEPT_ENCODING: 'grpc-accept-encoding',\n GRPC_MESSAGE_TYPE: 'grpc-message-type',\n\n GRPC_STATUS: 'grpc-status',\n GRPC_MESSAGE: 'grpc-message',\n GRPC_STATUS_DETAILS_BIN: 'grpc-status-details-bin',\n\n GRPC_PREVIOUS_RPC_ATTEMPTS: 'grpc-previous-rpc-attempts',\n GRPC_RETRY_PUSHBACK_MS: 'grpc-retry-pushback-ms',\n\n GRPC_TRACE_BIN: 'grpc-trace-bin',\n GRPC_TAGS_BIN: 'grpc-tags-bin',\n } as const;\n\n /** gRPC MIME / Content-Type values. */\n static readonly HeaderValues = {\n GRPC: 'application/grpc',\n GRPC_PROTO: 'application/grpc+proto',\n GRPC_JSON: 'application/grpc+json',\n GRPC_WEB: 'application/grpc-web',\n GRPC_WEB_PROTO: 'application/grpc-web+proto',\n GRPC_WEB_JSON: 'application/grpc-web+json',\n GRPC_WEB_TEXT: 'application/grpc-web-text',\n } as const;\n\n /** Standard gRPC status codes (google.rpc.Code). */\n static readonly ResultCodes = {\n OK: 0,\n CANCELLED: 1,\n UNKNOWN: 2,\n INVALID_ARGUMENT: 3,\n DEADLINE_EXCEEDED: 4,\n NOT_FOUND: 5,\n ALREADY_EXISTS: 6,\n PERMISSION_DENIED: 7,\n RESOURCE_EXHAUSTED: 8,\n FAILED_PRECONDITION: 9,\n ABORTED: 10,\n OUT_OF_RANGE: 11,\n UNIMPLEMENTED: 12,\n INTERNAL: 13,\n UNAVAILABLE: 14,\n DATA_LOSS: 15,\n UNAUTHENTICATED: 16,\n } as const;\n}\n\n/** A gRPC call kind from `GRPC.Methods`, lowercase. */\nexport type TGrpcMethod = ValueOf<typeof GRPC.Methods>;\n/** A numeric gRPC status code from `GRPC.ResultCodes` (`0` is OK). */\nexport type TGrpcResultCode = ValueOf<typeof GRPC.ResultCodes>;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ValueOf } from '../types/index.js';
|
|
2
|
+
/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */
|
|
2
3
|
export declare class HTTP {
|
|
3
4
|
/** Standard and common HTTP headers (lowercase per HTTP/2 convention). */
|
|
4
5
|
static readonly Headers: {
|
|
@@ -180,7 +181,10 @@ export declare class HTTP {
|
|
|
180
181
|
};
|
|
181
182
|
};
|
|
182
183
|
}
|
|
184
|
+
/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */
|
|
183
185
|
export type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;
|
|
186
|
+
/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */
|
|
184
187
|
export type THttpProtocol = ValueOf<typeof HTTP.Protocols> | Uppercase<ValueOf<typeof HTTP.Protocols>>;
|
|
188
|
+
/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */
|
|
185
189
|
export type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;
|
|
186
190
|
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */
|
|
1
2
|
export class HTTP {
|
|
2
3
|
/** Standard and common HTTP headers (lowercase per HTTP/2 convention). */
|
|
3
4
|
static { this.Headers = {
|
|
@@ -1 +1 @@
|
|
|
1
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E,GAAG;YACd,QAAQ,EAAE,GAAG;YACb,gBAAgB,EAAE,GAAG;YACrB,aAAa,EAAE,GAAG;YAClB,cAAc,EAAE,GAAG;YACnB,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,GAAG;YACT,cAAc,EAAE,GAAG;YACnB,kBAAkB,EAAE,GAAG;YACvB,eAAe,EAAE,GAAG;YACpB,UAAU,EAAE,GAAG;YACf,oBAAoB,EAAE,GAAG;YACzB,mBAAmB,EAAE,GAAG;YACxB,iBAAiB,EAAE,GAAG;YACtB,mBAAmB,EAAE,GAAG;YACxB,MAAM,EAAE,GAAG;YACX,gBAAgB,EAAE,GAAG;YACrB,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,GAAG;YACpB,oBAAoB,EAAE,GAAG;YACzB,eAAe,EAAE,GAAG;YACpB,2BAA2B,EAAE,GAAG;YAChC,0BAA0B,EAAE,GAAG;SAChC;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,mBAAmB,EAAE,GAAG;YACxB,cAAc,EAAE,GAAG;YACnB,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,GAAG;YACvB,cAAc,EAAE,GAAG;YACnB,uBAAuB,EAAE,GAAG;YAC5B,mBAAmB,EAAE,GAAG;YACxB,YAAY,EAAE,GAAG;YACjB,6BAA6B,EAAE,GAAG;SACnC;KACO,CAAC","sourcesContent":["import { type ValueOf } from '../types';\n\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n"]}
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../../src/common/constants/http.ts"],"names":[],"mappings":"AAEA,yJAAyJ;AACzJ,MAAM,OAAO,IAAI;IACf,0EAA0E;aAC1D,YAAO,GAAG;QACxB,UAAU;QACV,mBAAmB,EAAE,qBAAqB;QAC1C,gBAAgB,EAAE,kBAAkB;QACpC,cAAc,EAAE,gBAAgB;QAChC,YAAY,EAAE,cAAc;QAC5B,aAAa,EAAE,eAAe;QAC9B,uBAAuB,EAAE,yBAAyB;QAElD,+CAA+C;QAC/C,MAAM,EAAE,QAAQ;QAChB,eAAe,EAAE,iBAAiB;QAClC,eAAe,EAAE,iBAAiB;QAClC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,iBAAiB,EAAE,mBAAmB;QACtC,aAAa,EAAE,eAAe;QAC9B,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS;QAClB,UAAU,EAAE,YAAY;QAExB,kDAAkD;QAClD,KAAK,EAAE,OAAO;QACd,aAAa,EAAE,eAAe;QAC9B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,UAAU;QACpB,WAAW,EAAE,aAAa;QAC1B,UAAU,EAAE,YAAY;QACxB,IAAI,EAAE,MAAM;QACZ,gBAAgB,EAAE,kBAAkB;QAEpC,+BAA+B;QAC/B,gCAAgC,EAAE,kCAAkC;QACpE,4BAA4B,EAAE,8BAA8B;QAC5D,4BAA4B,EAAE,8BAA8B;QAC5D,2BAA2B,EAAE,6BAA6B;QAC1D,6BAA6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gBAAgB,EAAE,GAAG;YACrB,KAAK,EAAE,GAAG;YACV,WAAW,EAAE,GAAG;YAChB,iBAAiB,EAAE,GAAG;YACtB,iBAAiB,EAAE,GAAG;SACvB;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,UAAU,EAAE,GAAG;YACf,YAAY,EAAE,GAAG;YACjB,eAAe,EAAE,GAAG;YACpB,SAAS,EAAE,GAAG;YACd,QAAQ,EAAE,GAAG;YACb,gBAAgB,EAAE,GAAG;YACrB,aAAa,EAAE,GAAG;YAClB,cAAc,EAAE,GAAG;YACnB,QAAQ,EAAE,GAAG;YACb,IAAI,EAAE,GAAG;YACT,cAAc,EAAE,GAAG;YACnB,kBAAkB,EAAE,GAAG;YACvB,eAAe,EAAE,GAAG;YACpB,UAAU,EAAE,GAAG;YACf,oBAAoB,EAAE,GAAG;YACzB,mBAAmB,EAAE,GAAG;YACxB,iBAAiB,EAAE,GAAG;YACtB,mBAAmB,EAAE,GAAG;YACxB,MAAM,EAAE,GAAG;YACX,gBAAgB,EAAE,GAAG;YACrB,QAAQ,EAAE,GAAG;YACb,eAAe,EAAE,GAAG;YACpB,oBAAoB,EAAE,GAAG;YACzB,eAAe,EAAE,GAAG;YACpB,2BAA2B,EAAE,GAAG;YAChC,0BAA0B,EAAE,GAAG;SAChC;QAED,0BAA0B;QAC1B,IAAI,EAAE;YACJ,mBAAmB,EAAE,GAAG;YACxB,cAAc,EAAE,GAAG;YACnB,UAAU,EAAE,GAAG;YACf,kBAAkB,EAAE,GAAG;YACvB,cAAc,EAAE,GAAG;YACnB,uBAAuB,EAAE,GAAG;YAC5B,mBAAmB,EAAE,GAAG;YACxB,YAAY,EAAE,GAAG;YACjB,6BAA6B,EAAE,GAAG;SACnC;KACO,CAAC","sourcesContent":["import { type ValueOf } from '../types';\n\n/** HTTP constants: header names, CORS headers, header values, methods, protocols and status codes. Header names, methods and protocols are lowercase. */\nexport class HTTP {\n /** Standard and common HTTP headers (lowercase per HTTP/2 convention). */\n static readonly Headers = {\n // Content\n CONTENT_DISPOSITION: 'content-disposition',\n CONTENT_ENCODING: 'content-encoding',\n CONTENT_LENGTH: 'content-length',\n CONTENT_TYPE: 'content-type',\n CONTENT_RANGE: 'content-range',\n CONTENT_SECURITY_POLICY: 'content-security-policy',\n\n // Request - content negotiation & conditionals\n ACCEPT: 'accept',\n ACCEPT_ENCODING: 'accept-encoding',\n ACCEPT_LANGUAGE: 'accept-language',\n AUTHORIZATION: 'authorization',\n COOKIE: 'cookie',\n HOST: 'host',\n IF_MODIFIED_SINCE: 'if-modified-since',\n IF_NONE_MATCH: 'if-none-match',\n ORIGIN: 'origin',\n REFERER: 'referer',\n USER_AGENT: 'user-agent',\n\n // Response - caching, auth challenges & redirects\n ALLOW: 'allow',\n CACHE_CONTROL: 'cache-control',\n ETAG: 'etag',\n LAST_MODIFIED: 'last-modified',\n LOCATION: 'location',\n RETRY_AFTER: 'retry-after',\n SET_COOKIE: 'set-cookie',\n VARY: 'vary',\n WWW_AUTHENTICATE: 'www-authenticate',\n\n // CORS (RFC 6454 / Fetch spec)\n ACCESS_CONTROL_ALLOW_CREDENTIALS: 'access-control-allow-credentials',\n ACCESS_CONTROL_ALLOW_HEADERS: 'access-control-allow-headers',\n ACCESS_CONTROL_ALLOW_METHODS: 'access-control-allow-methods',\n ACCESS_CONTROL_ALLOW_ORIGIN: 'access-control-allow-origin',\n ACCESS_CONTROL_EXPOSE_HEADERS: 'access-control-expose-headers',\n ACCESS_CONTROL_MAX_AGE: 'access-control-max-age',\n ACCESS_CONTROL_REQUEST_HEADERS: 'access-control-request-headers',\n ACCESS_CONTROL_REQUEST_METHOD: 'access-control-request-method',\n\n // Transport\n CONNECTION: 'connection',\n TRANSFER_ENCODING: 'transfer-encoding',\n UPGRADE: 'upgrade',\n\n // Security\n STRICT_TRANSPORT_SECURITY: 'strict-transport-security',\n X_CONTENT_TYPE_OPTIONS: 'x-content-type-options',\n X_FRAME_OPTIONS: 'x-frame-options',\n\n // Proxy / forwarding (de facto standard)\n FORWARDED: 'forwarded',\n X_FORWARDED_FOR: 'x-forwarded-for',\n X_FORWARDED_HOST: 'x-forwarded-host',\n X_FORWARDED_PROTO: 'x-forwarded-proto',\n\n // Rate limiting (de facto standard)\n X_RATELIMIT_LIMIT: 'x-ratelimit-limit',\n X_RATELIMIT_REMAINING: 'x-ratelimit-remaining',\n X_RATELIMIT_RESET: 'x-ratelimit-reset',\n\n // IGNIS custom\n REQUEST_TRACING_ID: 'x-request-id',\n REQUEST_DEVICE_INFO: 'x-device-info',\n REQUEST_CHANNEL: 'x-request-channel',\n REQUEST_COUNT_DATA: 'x-request-count',\n REQUEST_EXTRA: 'x-request-extra',\n RESPONSE_COUNT_DATA: 'x-response-count',\n RESPONSE_FORMAT: 'x-response-format',\n RESPONSE_EXTRA: 'x-response-extra',\n } as const;\n\n /**\n * The headers IGNIS adds to a request and to a response, for a CORS configuration that lists them\n * by hand: spread `ALLOW` into the allowed request headers and `EXPOSE` into the exposed ones, so\n * a header IGNIS adds later needs no change there.\n */\n static readonly CorsHeaders = {\n ALLOW: [\n 'x-request-id',\n 'x-request-count',\n 'x-request-extra',\n 'x-request-channel',\n 'x-device-info',\n ],\n EXPOSE: [\n 'content-range',\n 'x-request-id',\n 'x-response-count',\n 'x-response-format',\n 'x-response-extra',\n ],\n } as const;\n\n /** Common MIME / Content-Type values. */\n static readonly HeaderValues = {\n // Application\n APPLICATION_FORM_URLENCODED: 'application/x-www-form-urlencoded',\n APPLICATION_GRAPHQL_JSON: 'application/graphql+json',\n APPLICATION_GZIP: 'application/gzip',\n APPLICATION_JAVASCRIPT: 'application/javascript',\n APPLICATION_JSON: 'application/json',\n APPLICATION_MSGPACK: 'application/msgpack',\n APPLICATION_NDJSON: 'application/x-ndjson',\n APPLICATION_OCTET_STREAM: 'application/octet-stream',\n APPLICATION_PDF: 'application/pdf',\n APPLICATION_PROTOBUF: 'application/x-protobuf',\n APPLICATION_XML: 'application/xml',\n APPLICATION_ZIP: 'application/zip',\n\n // Multipart\n MULTIPART_FORM_DATA: 'multipart/form-data',\n\n // Text\n TEXT_CSS: 'text/css',\n TEXT_CSV: 'text/csv',\n TEXT_EVENT_STREAM: 'text/event-stream',\n TEXT_HTML: 'text/html',\n TEXT_PLAIN: 'text/plain',\n TEXT_XML: 'text/xml',\n\n // Image\n IMAGE_GIF: 'image/gif',\n IMAGE_JPEG: 'image/jpeg',\n IMAGE_PNG: 'image/png',\n IMAGE_SVG: 'image/svg+xml',\n IMAGE_WEBP: 'image/webp',\n } as const;\n\n /** Standard HTTP methods (lowercase). */\n static readonly Methods = {\n GET: 'get',\n POST: 'post',\n PUT: 'put',\n PATCH: 'patch',\n DELETE: 'delete',\n HEAD: 'head',\n OPTIONS: 'options',\n QUERY: 'query',\n } as const;\n\n /** Standard HTTP protocols (lowercase). */\n static readonly Protocols = {\n HTTP: 'http',\n HTTPS: 'https',\n } as const;\n\n /** HTTP status codes grouped by class (1xx - 5xx). */\n static readonly ResultCodes = {\n /** 1xx - Informational. */\n RS_1: {\n Continue: 100,\n SwitchingProtocols: 101,\n EarlyHints: 103,\n },\n\n /** 2xx - Success. */\n RS_2: {\n Ok: 200,\n Created: 201,\n Accepted: 202,\n NonAuthoritativeInformation: 203,\n NoContent: 204,\n ResetContent: 205,\n PartialContent: 206,\n MultiStatus: 207,\n },\n\n /** 3xx - Redirection. */\n RS_3: {\n MovedPermanently: 301,\n Found: 302,\n NotModified: 304,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n },\n\n /** 4xx - Client error. */\n RS_4: {\n BadRequest: 400,\n Unauthorized: 401,\n PaymentRequired: 402,\n Forbidden: 403,\n NotFound: 404,\n MethodNotAllowed: 405,\n NotAcceptable: 406,\n RequestTimeout: 408,\n Conflict: 409,\n Gone: 410,\n LengthRequired: 411,\n PreconditionFailed: 412,\n ContentTooLarge: 413,\n URITooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n UnprocessableEntity: 422,\n Locked: 423,\n FailedDependency: 424,\n TooEarly: 425,\n UpgradeRequired: 426,\n PreconditionRequired: 428,\n TooManyRequests: 429,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n },\n\n /** 5xx - Server error. */\n RS_5: {\n InternalServerError: 500,\n NotImplemented: 501,\n BadGateway: 502,\n ServiceUnavailable: 503,\n GatewayTimeout: 504,\n HTTPVersionNotSupported: 505,\n InsufficientStorage: 507,\n LoopDetected: 508,\n NetworkAuthenticationRequired: 511,\n },\n } as const;\n}\n\n/** An HTTP method from `HTTP.Methods`, in lowercase or uppercase. */\nexport type THttpMethod = ValueOf<typeof HTTP.Methods> | Uppercase<ValueOf<typeof HTTP.Methods>>;\n/** An HTTP protocol from `HTTP.Protocols`, in lowercase or uppercase. */\nexport type THttpProtocol =\n | ValueOf<typeof HTTP.Protocols>\n | Uppercase<ValueOf<typeof HTTP.Protocols>>;\n/** A numeric HTTP status code from any class in `HTTP.ResultCodes`. */\nexport type THttpResultCode = ValueOf<typeof HTTP.ResultCodes>;\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type TConstValue } from '../types/index.js';
|
|
2
|
+
/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */
|
|
2
3
|
export declare class MimeTypes {
|
|
3
4
|
static readonly UNKNOWN = "unknown";
|
|
4
5
|
static readonly IMAGE = "image";
|
|
@@ -7,6 +8,7 @@ export declare class MimeTypes {
|
|
|
7
8
|
static readonly SCHEME_SET: Set<string>;
|
|
8
9
|
static isValid(value: string): boolean;
|
|
9
10
|
}
|
|
11
|
+
/** One of the `MimeTypes` values. */
|
|
10
12
|
export type TMimeTypes = TConstValue<typeof MimeTypes>;
|
|
11
13
|
/** The leading dot is part of the value: `path.extname` returns one. */
|
|
12
14
|
export declare class FileExtensions {
|
|
@@ -40,6 +42,7 @@ export declare class FileExtensions {
|
|
|
40
42
|
static readonly SCHEME_SET: Set<string>;
|
|
41
43
|
static isValid(value: string): boolean;
|
|
42
44
|
}
|
|
45
|
+
/** One of the `FileExtensions` values, with its leading dot. */
|
|
43
46
|
export type TFileExtension = TConstValue<typeof FileExtensions>;
|
|
44
47
|
/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */
|
|
45
48
|
export declare class ContentTypes {
|
|
@@ -73,6 +76,7 @@ export declare class ContentTypes {
|
|
|
73
76
|
static readonly SCHEME_SET: Set<string>;
|
|
74
77
|
static isValid(value: string): boolean;
|
|
75
78
|
}
|
|
79
|
+
/** One of the `ContentTypes` values. */
|
|
76
80
|
export type TContentType = TConstValue<typeof ContentTypes>;
|
|
77
81
|
/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */
|
|
78
82
|
export declare class ContentTypeTable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhG,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAIH,wEAAwE;AACxE,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aAC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,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set<string>([this.UNKNOWN, this.IMAGE, this.VIDEO, this.TEXT]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n\n static readonly SCHEME_SET = new Set<string>([\n this.PNG,\n this.JPG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.TXT,\n this.HTML,\n this.CSS,\n this.JS,\n this.MP4,\n this.WEBM,\n this.MP3,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n\n static readonly SCHEME_SET = new Set<string>([\n this.OCTET_STREAM,\n this.PNG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.PLAIN_TEXT,\n this.HTML,\n this.CSS,\n this.JAVASCRIPT,\n this.MP4,\n this.WEBM,\n this.MPEG_AUDIO,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
|
|
1
|
+
{"version":3,"file":"mime.js","sourceRoot":"","sources":["../../../../src/common/constants/mime.ts"],"names":[],"mappings":"AAEA,kIAAkI;AAClI,MAAM,OAAO,SAAS;aACJ,YAAO,GAAG,SAAS,CAAC;aACpB,UAAK,GAAG,OAAO,CAAC;aAChB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEhG,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAKH,wEAAwE;AACxE,MAAM,OAAO,cAAc;aACT,QAAG,GAAG,MAAM,CAAC;aACb,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,SAAI,GAAG,OAAO,CAAC;aACf,QAAG,GAAG,MAAM,CAAC;aACb,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Q,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9E,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC,YAAY,CAAC;IACnE,CAAC;;AAGH,gGAAgG;AAChG,MAAM,CAAC,MAAM,yBAAyB,GAAG,gBAAgB,CAAC,YAAY,CAAC","sourcesContent":["import { type TConstValue } from '../types';\n\n/** The top-level part of a MIME type (`image`, `video`, `text`), plus `unknown`. For the full content type see `ContentTypes`. */\nexport class MimeTypes {\n static readonly UNKNOWN = 'unknown';\n static readonly IMAGE = 'image';\n static readonly VIDEO = 'video';\n static readonly TEXT = 'text';\n\n static readonly SCHEME_SET = new Set<string>([this.UNKNOWN, this.IMAGE, this.VIDEO, this.TEXT]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `MimeTypes` values. */\nexport type TMimeTypes = TConstValue<typeof MimeTypes>;\n\n/** The leading dot is part of the value: `path.extname` returns one. */\nexport class FileExtensions {\n static readonly PNG = '.png';\n static readonly JPG = '.jpg';\n static readonly JPEG = '.jpeg';\n static readonly GIF = '.gif';\n static readonly WEBP = '.webp';\n static readonly SVG = '.svg';\n static readonly PDF = '.pdf';\n static readonly JSON = '.json';\n static readonly TXT = '.txt';\n static readonly HTML = '.html';\n static readonly CSS = '.css';\n static readonly JS = '.js';\n static readonly MP4 = '.mp4';\n static readonly WEBM = '.webm';\n static readonly MP3 = '.mp3';\n static readonly WAV = '.wav';\n static readonly ZIP = '.zip';\n static readonly CSV = '.csv';\n static readonly XML = '.xml';\n static readonly XLSX = '.xlsx';\n static readonly XLS = '.xls';\n static readonly DOCX = '.docx';\n static readonly DOC = '.doc';\n static readonly PPTX = '.pptx';\n static readonly PPT = '.ppt';\n static readonly ODT = '.odt';\n static readonly ODS = '.ods';\n\n static readonly SCHEME_SET = new Set<string>([\n this.PNG,\n this.JPG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.TXT,\n this.HTML,\n this.CSS,\n this.JS,\n this.MP4,\n this.WEBM,\n this.MP3,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `FileExtensions` values, with its leading dot. */\nexport type TFileExtension = TConstValue<typeof FileExtensions>;\n\n/** Full content types, as they go on the wire. `MimeTypes` holds only the top-level part. */\nexport class ContentTypes {\n static readonly OCTET_STREAM = 'application/octet-stream';\n static readonly PNG = 'image/png';\n static readonly JPEG = 'image/jpeg';\n static readonly GIF = 'image/gif';\n static readonly WEBP = 'image/webp';\n static readonly SVG = 'image/svg+xml';\n static readonly PDF = 'application/pdf';\n static readonly JSON = 'application/json';\n static readonly PLAIN_TEXT = 'text/plain';\n static readonly HTML = 'text/html';\n static readonly CSS = 'text/css';\n static readonly JAVASCRIPT = 'text/javascript';\n static readonly MP4 = 'video/mp4';\n static readonly WEBM = 'video/webm';\n static readonly MPEG_AUDIO = 'audio/mpeg';\n static readonly WAV = 'audio/wav';\n static readonly ZIP = 'application/zip';\n static readonly CSV = 'text/csv';\n static readonly XML = 'application/xml';\n static readonly XLSX = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';\n static readonly XLS = 'application/vnd.ms-excel';\n static readonly DOCX = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';\n static readonly DOC = 'application/msword';\n static readonly PPTX =\n 'application/vnd.openxmlformats-officedocument.presentationml.presentation';\n\n static readonly PPT = 'application/vnd.ms-powerpoint';\n static readonly ODT = 'application/vnd.oasis.opendocument.text';\n static readonly ODS = 'application/vnd.oasis.opendocument.spreadsheet';\n\n static readonly SCHEME_SET = new Set<string>([\n this.OCTET_STREAM,\n this.PNG,\n this.JPEG,\n this.GIF,\n this.WEBP,\n this.SVG,\n this.PDF,\n this.JSON,\n this.PLAIN_TEXT,\n this.HTML,\n this.CSS,\n this.JAVASCRIPT,\n this.MP4,\n this.WEBM,\n this.MPEG_AUDIO,\n this.WAV,\n this.ZIP,\n this.CSV,\n this.XML,\n this.XLSX,\n this.XLS,\n this.DOCX,\n this.DOC,\n this.PPTX,\n this.PPT,\n this.ODT,\n this.ODS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n/** One of the `ContentTypes` values. */\nexport type TContentType = TConstValue<typeof ContentTypes>;\n\n/** The extension table and the lookup that reads it, together - the `DurationMultipliers` shape. */\nexport class ContentTypeTable {\n /** `satisfies` makes the table total; the declared `string` key keeps a lookup cast-free. */\n static readonly BY_EXTENSION: Readonly<Partial<Record<string, TContentType>>> = {\n [FileExtensions.PNG]: ContentTypes.PNG,\n [FileExtensions.JPG]: ContentTypes.JPEG,\n [FileExtensions.JPEG]: ContentTypes.JPEG,\n [FileExtensions.GIF]: ContentTypes.GIF,\n [FileExtensions.WEBP]: ContentTypes.WEBP,\n [FileExtensions.SVG]: ContentTypes.SVG,\n [FileExtensions.PDF]: ContentTypes.PDF,\n [FileExtensions.JSON]: ContentTypes.JSON,\n [FileExtensions.TXT]: ContentTypes.PLAIN_TEXT,\n [FileExtensions.HTML]: ContentTypes.HTML,\n [FileExtensions.CSS]: ContentTypes.CSS,\n [FileExtensions.JS]: ContentTypes.JAVASCRIPT,\n [FileExtensions.MP4]: ContentTypes.MP4,\n [FileExtensions.WEBM]: ContentTypes.WEBM,\n [FileExtensions.MP3]: ContentTypes.MPEG_AUDIO,\n [FileExtensions.WAV]: ContentTypes.WAV,\n [FileExtensions.ZIP]: ContentTypes.ZIP,\n [FileExtensions.CSV]: ContentTypes.CSV,\n [FileExtensions.XML]: ContentTypes.XML,\n [FileExtensions.XLSX]: ContentTypes.XLSX,\n [FileExtensions.XLS]: ContentTypes.XLS,\n [FileExtensions.DOCX]: ContentTypes.DOCX,\n [FileExtensions.DOC]: ContentTypes.DOC,\n [FileExtensions.PPTX]: ContentTypes.PPTX,\n [FileExtensions.PPT]: ContentTypes.PPT,\n [FileExtensions.ODT]: ContentTypes.ODT,\n [FileExtensions.ODS]: ContentTypes.ODS,\n } satisfies Readonly<Record<TFileExtension, TContentType>>;\n\n /**\n * The content type an object name implies. `node:path` is deliberately not used: this file is\n * reachable from the browser-pure `./common` subpath, and an extension is the tail after the last\n * dot either way.\n */\n static resolve(opts: { filename: string }): TContentType {\n const { filename } = opts;\n const lastDot = filename.lastIndexOf('.');\n const extension = lastDot === -1 ? '' : filename.slice(lastDot).toLowerCase();\n\n return this.BY_EXTENSION[extension] ?? ContentTypes.OCTET_STREAM;\n }\n}\n\n/** Published before the table moved onto the class; kept as the one-line delegate it now is. */\nexport const CONTENT_TYPE_BY_EXTENSION = ContentTypeTable.BY_EXTENSION;\n"]}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/** The placeholder that replaces a secret value in redacted output. */
|
|
1
2
|
export declare const REDACTED = "[REDACTED]";
|
|
3
|
+
/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */
|
|
2
4
|
export declare class RedactUtility {
|
|
3
5
|
/**
|
|
4
6
|
* Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not
|
|
@@ -18,6 +18,7 @@ const SECRET_KEY_PATTERN = new RegExp([
|
|
|
18
18
|
'|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',
|
|
19
19
|
'|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',
|
|
20
20
|
].join(''), 'i');
|
|
21
|
+
/** The placeholder that replaces a secret value in redacted output. */
|
|
21
22
|
export const REDACTED = '[REDACTED]';
|
|
22
23
|
/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. */
|
|
23
24
|
const isRedactionEnabled = () => globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';
|
|
@@ -104,6 +105,7 @@ const deepSanitize = (value, context) => {
|
|
|
104
105
|
}
|
|
105
106
|
return result;
|
|
106
107
|
};
|
|
108
|
+
/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */
|
|
107
109
|
export class RedactUtility {
|
|
108
110
|
/**
|
|
109
111
|
* Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAEA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC;IACE,qDAAqD;IACrD,6EAA6E;IAC7E,0EAA0E;IAC1E,oEAAoE;IAEpE,iKAAiK;IACjK,qCAAqC;IAErC,8MAA8M;IAC9M,yBAAyB;IAEzB,8RAA8R;IAC9R,2BAA2B;IAE3B,4JAA4J;IAC5J,qDAAqD;IAErD,yIAAyI;IACzI,+BAA+B;IAE/B,2MAA2M;IAC3M,gFAAgF;IAChF,6DAA6D;CAC9D,CAAC,IAAI,CAAC,EAAE,CAAC,EACV,GAAG,CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,8KAA8K;AAC9K,MAAM,kBAAkB,GAAG,GAAY,EAAE,CACvC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,wBAAwB,KAAK,OAAO,CAAC;AAEhE,uGAAuG;AACvG,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,sBAAsB,GAAG,GAAW,EAAE;IAC1C,MAAM,UAAU,GAAG,MA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AAI,EAAE,IAAI,OAAO,EAAU;YAC3B,QAAQ,EAAE,kBAAkB,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,QAAQ;YAC7B,iGAAiG;YACjG,qDAAqD;YACrD,eAAe,EAAE,sBAAsB,EAAE;SAC1C,CAAC,CAAC;IACL,CAAC;IAED,oQAAoQ;IACpQ,MAAM,CAAC,oBAAoB,CAAC,IAAqB;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,MAAW,CAAC;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { type AnyObject } from './types';\n\n/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n ].join(''),\n 'i',\n);\n\nexport const REDACTED = '[REDACTED]';\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. */\nconst isRedactionEnabled = (): boolean =>\n globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n return capString({ value, key: context.key, limit: context.maxStringLength });\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: AnyObject = {\n name: value.name,\n message: value.message,\n stack: value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: AnyObject = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n */\n static redactSecrets(opts: { value: unknown; seen?: WeakSet<object>; depth?: number }): unknown {\n const { value, seen, depth = Infinity } = opts;\n\n if (!isRedactionEnabled()) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. */\n static toJsonSafe(opts: { value: unknown; depth?: number }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. */\n static redactUrlCredentials(opts: { url: string }): string {\n const { url } = opts;\n\n if (!isRedactionEnabled()) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../../../src/common/redact.ts"],"names":[],"mappings":"AAEA,gHAAgH;AAChH,MAAM,kBAAkB,GAAG,IAAI,MAAM,CACnC;IACE,qDAAqD;IACrD,6EAA6E;IAC7E,0EAA0E;IAC1E,oEAAoE;IAEpE,iKAAiK;IACjK,qCAAqC;IAErC,8MAA8M;IAC9M,yBAAyB;IAEzB,8RAA8R;IAC9R,2BAA2B;IAE3B,4JAA4J;IAC5J,qDAAqD;IAErD,yIAAyI;IACzI,+BAA+B;IAE/B,2MAA2M;IAC3M,gFAAgF;IAChF,6DAA6D;CAC9D,CAAC,IAAI,CAAC,EAAE,CAAC,EACV,GAAG,CACJ,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAErC,8KAA8K;AAC9K,MAAM,kBAAkB,GAAG,GAAY,EAAE,CACvC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,wBAAwB,KAAK,OAAO,CAAC;AAEhE,uGAAuG;AACvG,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,sBAAsB,GAAG,GAAW,EAAE;IAC1C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,gCAAgC,CAAC,CAAC;IAErF,OAAO,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,yBAAyB,CAAC;AACjG,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,a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,MAAM,CAAC,oBAAoB,CAAC,IAAqB;QAC/C,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YAC1B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,MAAW,CAAC;QAEhB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACxB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC;QACb,CAAC;QAED,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAE3B,OAAO,kBAAkB,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/C,CAAC;CACF","sourcesContent":["import { type AnyObject } from './types';\n\n/** Keys whose VALUES must never reach a log line - matched case-insensitively on the key name, at any depth. */\nconst SECRET_KEY_PATTERN = new RegExp(\n [\n // Options-object spellings (camelCase / snake_case).\n '^(pass|password|passphrase|secret|token|apiKey|api_key|accessKey|access_key',\n '|secretKey|secret_key|privateKey|private_key|key|cert|ca|pfx|credentials',\n '|authorization|auth|jwtSecret|applicationSecret|connectionString)$',\n\n // Vault wire spellings (snake_case): node-vault's AppRole login/response bodies carry these exact keys, and none are matched by the anchored options list above.\n '|^(client_token|secret_id|role_id)$',\n\n // Any `*_token` (snake_case) or `*Token` (camelCase) key; a preceding character is required so the bare word `token` (already covered above) is not the whole match, and so ordinary words are not swallowed.\n '|_token$|[a-z0-9]token$',\n\n // The `*Secret` counterpart the `*Token` rule always lacked. `clientSecret` / `client_secret` is the RFC 6749 parameter name and a live field on the search connector's model options, and `webhookSecret` is the standard spelling everywhere; none of them matched the anchored list above.\n '|_secret$|[a-z0-9]secret$',\n\n // Connection descriptors: `connectionString` was anchored above but its snake_case twin was not, and `dsn` is the third common spelling for the same thing.\n '|^(connection_string|dsn|database_url|databaseUrl)$',\n\n // Any `*_password` / `*Password` key - `dbPassword`, `admin_password`. The bare word is anchored above; this catches the prefixed forms.\n '|_password$|[a-z0-9]password$',\n\n // HTTP HEADER spellings: header names are kebab-case and often `x-`-prefixed, none of which the camelCase list above matches; `vault` is included so `X-Vault-Token` (node-vault's auth header) is caught.\n '|^(x-)?(api|auth|access|secret|session|csrf|xsrf|vault)-(key|token|secret|id)$',\n '|^(cookie|set-cookie|proxy-authorization|www-authenticate)$',\n ].join(''),\n 'i',\n);\n\n/** The placeholder that replaces a secret value in redacted output. */\nexport const REDACTED = '[REDACTED]';\n\n/** Kill-switch for local debugging: only the literal `false` disables redaction (fail-closed); read per call so it can be flipped at runtime. Never disable in production. */\nconst isRedactionEnabled = (): boolean =>\n globalThis.process?.env?.APP_ENV_LOGGER_DO_REDACT !== 'false';\n\n/** Longest string a log line carries whole. `APP_ENV_LOGGER_MAX_STRING_LENGTH=0` turns capping off. */\nconst DEFAULT_MAX_STRING_LENGTH = 2048;\n\nconst resolveMaxStringLength = (): number => {\n const configured = Number(globalThis.process?.env?.APP_ENV_LOGGER_MAX_STRING_LENGTH);\n\n return Number.isFinite(configured) && configured >= 0 ? configured : DEFAULT_MAX_STRING_LENGTH;\n};\n\n/**\n * Keys whose value is long BY NATURE and useless truncated. A stack trace is the whole reason you\n * are reading the line.\n */\nconst UNCAPPED_KEYS = new Set(['stack', 'stacktrace', 'stack_trace']);\n\n/**\n * Caps a long string, keeping the ORIGINAL LENGTH in the marker - that number is what tells you the\n * payload was a 300 KB image rather than a truncated sentence.\n *\n * A base64 body is the case this exists for: one `data:image/png;base64,...` field turns a request\n * log into hundreds of kilobytes, and nothing about it is readable.\n */\nconst capString = (opts: { value: string; key?: string; limit: number }): string => {\n const { value, key, limit } = opts;\n\n if (limit === 0 || value.length <= limit || (key && UNCAPPED_KEYS.has(key.toLowerCase()))) {\n return value;\n }\n\n return `${value.slice(0, limit)}... [truncated, ${value.length} chars total]`;\n};\n\ntype TSanitizeContext = {\n seen: WeakSet<object>;\n doRedact: boolean;\n /** Levels still allowed BELOW the current one; `Infinity` walks the whole graph. */\n depth: number;\n /** Longest string kept whole; 0 keeps every string. */\n maxStringLength: number;\n /** The key this value was found under, so a stack trace can be exempted from capping. */\n key?: string;\n};\n\nconst deepSanitize = (value: unknown, context: TSanitizeContext): unknown => {\n const { seen, doRedact, depth } = context;\n\n if (typeof value === 'string') {\n return capString({ value, key: context.key, limit: context.maxStringLength });\n }\n\n if (value === null || typeof value !== 'object') {\n return value;\n }\n\n // A Date holds its value in an internal slot, so the generic branch below - which reads Object.keys() - would flatten it to `{}`. Checked BEFORE `seen`: a Date cannot carry a cycle, and entering the set would make a second reference to the same instance read as `[Circular]`.\n if (value instanceof Date) {\n return value;\n }\n\n if (seen.has(value)) {\n return '[Circular]';\n }\n\n if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) {\n return `[Binary ${(value as ArrayBufferView).byteLength ?? 0} bytes]`;\n }\n\n if (depth <= 0) {\n return Array.isArray(value) ? '[Array]' : '[Object]';\n }\n\n seen.add(value);\n const nested: TSanitizeContext = {\n seen,\n doRedact,\n depth: depth - 1,\n maxStringLength: context.maxStringLength,\n };\n\n // Error keeps name/message/stack NON-enumerable, so Object.keys() skips them and naive redaction would drop the message - reproject into a plain object carrying those fields plus its redacted enumerable own-props.\n if (value instanceof Error) {\n const source = value;\n const result: AnyObject = {\n name: value.name,\n message: value.message,\n stack: value.stack,\n };\n\n for (const [key, entry] of Object.entries(source)) {\n result[key] =\n doRedact && SECRET_KEY_PATTERN.test(key)\n ? REDACTED\n : deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n }\n\n if (Array.isArray(value)) {\n return value.map((entry) => deepSanitize(entry, nested));\n }\n\n const source = value;\n const result: AnyObject = {};\n\n for (const [key, entry] of Object.entries(source)) {\n if (doRedact && SECRET_KEY_PATTERN.test(key)) {\n result[key] = REDACTED;\n continue;\n }\n\n result[key] = deepSanitize(entry, { ...nested, key });\n }\n\n return result;\n};\n\n/** Makes a log argument safe to print: masks secret-looking keys, breaks cycles, caps long strings and strips URL credentials. `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking only. */\nexport class RedactUtility {\n /**\n * Redacts every secret-looking KEY (not value shape - buffers/typed arrays are summarized, not\n * serialized). `APP_ENV_LOGGER_DO_REDACT=false` makes this the identity function.\n *\n * `depth` bounds the walk, exactly as {@link RedactUtility.toJsonSafe} already does. It defaults to\n * `Infinity` for callers that really do want the whole graph, but the logger passes its own bound:\n * rendering only inspects a handful of levels, so walking to `Infinity` did work whose result was\n * thrown away - 12x on a deep graph, and a `RangeError` on a very deep chain.\n */\n static redactSecrets(opts: { value: unknown; seen?: WeakSet<object>; depth?: number }): unknown {\n const { value, seen, depth = Infinity } = opts;\n\n if (!isRedactionEnabled()) {\n return value;\n }\n\n return deepSanitize(value, {\n seen: seen ?? new WeakSet<object>(),\n doRedact: true,\n depth,\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Projects a value into something `JSON.stringify` can render: it answers `[Circular]` for the WHOLE payload when one cycle sits anywhere inside it, so cycles must be broken per-branch first. `depth` bounds the walk the way `util.inspect` does - a log argument may hold a live connector or request context, whose graph is effectively unbounded. The projection itself is unconditional: `APP_ENV_LOGGER_DO_REDACT=false` turns off the key masking, never the structural pass. */\n static toJsonSafe(opts: { value: unknown; depth?: number }): unknown {\n return deepSanitize(opts.value, {\n seen: new WeakSet<object>(),\n doRedact: isRedactionEnabled(),\n depth: opts.depth ?? Infinity,\n // Capping is STRUCTURAL, like the projection itself: turning redaction off is about key masking,\n // never about letting a 300 KB base64 field through.\n maxStringLength: resolveMaxStringLength(),\n });\n }\n\n /** Strips credentials from a connection URL's authority section (`user:hunter2@host` -> `user:[REDACTED]@host`) - {@link RedactUtility.redactSecrets} matches on KEY names and can't see them there. A value that fails to parse as a URL is returned unchanged. */\n static redactUrlCredentials(opts: { url: string }): string {\n const { url } = opts;\n\n if (!isRedactionEnabled()) {\n return url;\n }\n\n let parsed: URL;\n\n try {\n parsed = new URL(url);\n } catch {\n return url;\n }\n\n if (!parsed.password) {\n return url;\n }\n\n parsed.password = REDACTED;\n\n return decodeURIComponent(parsed.toString());\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TClass, TResolver } from './types/index.js';
|
|
2
2
|
export { isClass, ObjectUtility, ResolverUtility } from '@venizia/ignis-inversion';
|
|
3
|
+
/** Resolves a class reference that may be given directly, lazily through a resolver function, or as a string binding key. */
|
|
3
4
|
export declare class ClassResolver {
|
|
4
5
|
/** Resolves a class reference, passing through string binding keys as-is. */
|
|
5
6
|
static resolveClass<T>(opts: {
|
|
@@ -3,6 +3,7 @@ import { ResolverUtility } from '@venizia/ignis-inversion';
|
|
|
3
3
|
// container branches on them. Re-exported here so the rest of the stack reaches them through the
|
|
4
4
|
// package it already depends on, instead of each layer redeclaring them.
|
|
5
5
|
export { isClass, ObjectUtility, ResolverUtility } from '@venizia/ignis-inversion';
|
|
6
|
+
/** Resolves a class reference that may be given directly, lazily through a resolver function, or as a string binding key. */
|
|
6
7
|
export class ClassResolver {
|
|
7
8
|
/** Resolves a class reference, passing through string binding keys as-is. */
|
|
8
9
|
static resolveClass(opts) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/common/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D,+FAA+F;AAC/F,iGAAiG;AACjG,yEAAyE;AACzE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEnF,MAAM,OAAO,aAAa;IACxB,6EAA6E;IAC7E,MAAM,CAAC,YAAY,CAAI,IAEtB;QACC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,OAAO,eAAe,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { ResolverUtility } from '@venizia/ignis-inversion';\n\nimport type { TClass, TResolver } from './types';\n\n// The resolver vocabulary and its two readers live in inversion, the lowest layer, because the\n// container branches on them. Re-exported here so the rest of the stack reaches them through the\n// package it already depends on, instead of each layer redeclaring them.\nexport { isClass, ObjectUtility, ResolverUtility } from '@venizia/ignis-inversion';\n\nexport class ClassResolver {\n /** Resolves a class reference, passing through string binding keys as-is. */\n static resolveClass<T>(opts: {\n ref: TClass<T> | TResolver<TClass<T>> | string;\n }): TClass<T> | string {\n const { ref } = opts;\n\n if (typeof ref === 'string') {\n return ref;\n }\n\n return ResolverUtility.resolveValue({ value: ref });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/common/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAI3D,+FAA+F;AAC/F,iGAAiG;AACjG,yEAAyE;AACzE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEnF,6HAA6H;AAC7H,MAAM,OAAO,aAAa;IACxB,6EAA6E;IAC7E,MAAM,CAAC,YAAY,CAAI,IAEtB;QACC,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;QAErB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC;QACb,CAAC;QAED,OAAO,eAAe,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { ResolverUtility } from '@venizia/ignis-inversion';\n\nimport type { TClass, TResolver } from './types';\n\n// The resolver vocabulary and its two readers live in inversion, the lowest layer, because the\n// container branches on them. Re-exported here so the rest of the stack reaches them through the\n// package it already depends on, instead of each layer redeclaring them.\nexport { isClass, ObjectUtility, ResolverUtility } from '@venizia/ignis-inversion';\n\n/** Resolves a class reference that may be given directly, lazily through a resolver function, or as a string binding key. */\nexport class ClassResolver {\n /** Resolves a class reference, passing through string binding keys as-is. */\n static resolveClass<T>(opts: {\n ref: TClass<T> | TResolver<TClass<T>> | string;\n }): TClass<T> | string {\n const { ref } = opts;\n\n if (typeof ref === 'string') {\n return ref;\n }\n\n return ResolverUtility.resolveValue({ value: ref });\n }\n}\n"]}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
/** A concrete class constructor producing `T`. */
|
|
1
2
|
export type TConstructor<T> = new (...args: any[]) => T;
|
|
3
|
+
/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */
|
|
2
4
|
export type TAbstractConstructor<T> = abstract new (...args: any[]) => T;
|
|
5
|
+
/** A concrete class producing `T`, with any static members allowed. */
|
|
3
6
|
export type TClass<T> = TConstructor<T> & {
|
|
4
7
|
[property: string]: any;
|
|
5
8
|
};
|
|
9
|
+
/** An abstract class producing `T`, with any static members allowed. */
|
|
6
10
|
export type TAbstractClass<T> = TAbstractConstructor<T> & {
|
|
7
11
|
[property: string]: any;
|
|
8
12
|
};
|
|
13
|
+
/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */
|
|
9
14
|
export type TMixinTarget<T> = TConstructor<{
|
|
10
15
|
[P in keyof T]: T[P];
|
|
11
16
|
}>;
|
|
17
|
+
/** `TMixinTarget` for an abstract base class. */
|
|
12
18
|
export type TAbstractMixinTarget<T> = TAbstractConstructor<{
|
|
13
19
|
[P in keyof T]: T[P];
|
|
14
20
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/common/types/class.ts"],"names":[],"mappings":"","sourcesContent":["/** A concrete class constructor producing `T`. */\nexport type TConstructor<T> = new (...args: any[]) => T;\n/** An abstract class constructor producing `T`; it cannot be called with `new` directly. */\nexport type TAbstractConstructor<T> = abstract new (...args: any[]) => T;\n/** A concrete class producing `T`, with any static members allowed. */\nexport type TClass<T> = TConstructor<T> & { [property: string]: any };\n/** An abstract class producing `T`, with any static members allowed. */\nexport type TAbstractClass<T> = TAbstractConstructor<T> & { [property: string]: any };\n\n/** The constructor type a mixin accepts as its base: it must produce at least the members of `T`. */\nexport type TMixinTarget<T> = TConstructor<{ [P in keyof T]: T[P] }>;\n/** `TMixinTarget` for an abstract base class. */\nexport type TAbstractMixinTarget<T> = TAbstractConstructor<{ [P in keyof T]: T[P] }>;\n"]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { TClass } from './class.js';
|
|
2
2
|
import type { ValueOf } from './utility.js';
|
|
3
|
+
/** The string values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
3
4
|
export type TStringConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string> & {};
|
|
5
|
+
/** The number values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
4
6
|
export type TNumberConstValue<T extends TClass<any>> = Extract<ValueOf<T>, number> & {};
|
|
7
|
+
/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */
|
|
5
8
|
export type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number> & {};
|
|
6
9
|
//# sourceMappingURL=const-value.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\nexport type TStringConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string> & {};\nexport type TNumberConstValue<T extends TClass<any>> = Extract<ValueOf<T>, number> & {};\nexport type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number> & {};\n"]}
|
|
1
|
+
{"version":3,"file":"const-value.js","sourceRoot":"","sources":["../../../../src/common/types/const-value.ts"],"names":[],"mappings":"","sourcesContent":["import type { TClass } from './class';\nimport type { ValueOf } from './utility';\n\n/*\n * `& {}` keeps the same literal set but makes it a regular union. Without it the members of a\n * `static readonly` const class stay widening literals, and a value of these types widens to\n * `string` / `number` in an object literal, a `let`, or a generic inference.\n */\n/** The string values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TStringConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string> & {};\n/** The number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TNumberConstValue<T extends TClass<any>> = Extract<ValueOf<T>, number> & {};\n/** The string and number values held by the `static readonly` members of const class `T`, as a plain union. */\nexport type TConstValue<T extends TClass<any>> = Extract<ValueOf<T>, string | number> & {};\n"]}
|
|
@@ -11,14 +11,17 @@ export declare class FieldMappingDataTypes {
|
|
|
11
11
|
}
|
|
12
12
|
/** Valid field mapping data type values. */
|
|
13
13
|
export type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;
|
|
14
|
+
/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */
|
|
14
15
|
export interface IFieldMapping {
|
|
15
16
|
name: string;
|
|
16
17
|
type: TFieldMappingDataType;
|
|
17
18
|
default?: string | number | Array<string> | Array<number> | boolean;
|
|
18
19
|
}
|
|
20
|
+
/** The union of `name` values in a list of field mappings. */
|
|
19
21
|
export type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<T[number], {
|
|
20
22
|
type: Exclude<T[number]['type'], undefined>;
|
|
21
23
|
}>['name'];
|
|
24
|
+
/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */
|
|
22
25
|
export type TObjectFromFieldMappings<T extends readonly {
|
|
23
26
|
name: string;
|
|
24
27
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n\n static readonly SCHEME_SET = new Set<string>([\n this.STRING,\n this.NUMBER,\n this.STRINGS,\n this.NUMBERS,\n this.BOOLEAN,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: any;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: any;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: any }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: any }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: any }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: any;\n }\n ? number[]\n : never;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"field-mapping.js","sourceRoot":"","sources":["../../../../src/common/types/field-mapping.ts"],"names":[],"mappings":"AAEA,6CAA6C;AAC7C,MAAM,OAAO,qBAAqB;aAChB,WAAM,GAAG,QAAQ,CAAC;aAClB,WAAM,GAAG,QAAQ,CAAC;aAClB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,YAAO,GAAG,SAAS,CAAC;aAEpB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,OAAO;KACb,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from './const-value';\n\n/** The value kinds a field mapping reads. */\nexport class FieldMappingDataTypes {\n static readonly STRING = 'string';\n static readonly NUMBER = 'number';\n static readonly STRINGS = 'strings';\n static readonly NUMBERS = 'numbers';\n static readonly BOOLEAN = 'boolean';\n\n static readonly SCHEME_SET = new Set<string>([\n this.STRING,\n this.NUMBER,\n this.STRINGS,\n this.NUMBERS,\n this.BOOLEAN,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid field mapping data type values. */\nexport type TFieldMappingDataType = TConstValue<typeof FieldMappingDataTypes>;\n\n/** Describes one field to read: its `name`, its value `type`, and an optional `default`. */\nexport interface IFieldMapping {\n name: string;\n type: TFieldMappingDataType;\n default?: string | number | Array<string> | Array<number> | boolean;\n}\n\n/** The union of `name` values in a list of field mappings. */\nexport type TFieldMappingNames<T extends Array<IFieldMapping>> = Extract<\n T[number],\n { type: Exclude<T[number]['type'], undefined> }\n>['name'];\n\n/** The object a list of field mappings yields: one key per `name`, typed from its `type` (`string`, `number`, `boolean`, `strings` or `numbers`). Needs the list typed as a literal (`as const`) to narrow. */\nexport type TObjectFromFieldMappings<\n T extends readonly {\n name: string;\n type: string;\n [extra: string | symbol]: any;\n }[],\n> = {\n [K in T[number]['name']]: T extends {\n name: K;\n type: 'string';\n [extra: string | symbol]: any;\n }\n ? string\n : T extends { name: K; type: 'number'; [extra: string | symbol]: any }\n ? number\n : T extends { name: K; type: 'boolean'; [extra: string | symbol]: any }\n ? boolean\n : T extends { name: K; type: 'strings'; [extra: string | symbol]: any }\n ? string[]\n : T extends {\n name: K;\n type: 'numbers';\n [extra: string | symbol]: any;\n }\n ? number[]\n : never;\n};\n"]}
|