@venizia/ignis-helpers 0.4.7 → 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/README.md +2 -2
- 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/aes.engine.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/hash.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/base/base.js.map +1 -1
- package/dist/esm/modules/logger/base/console.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/debug-gate.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/factory.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/formatting/error-prettier.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/hf/flusher.js.map +1 -1
- package/dist/esm/modules/logger/hf/logger.js.map +1 -1
- package/dist/esm/modules/logger/hf/ring.js.map +1 -1
- package/dist/esm/modules/logger/pino/backing.js.map +1 -1
- package/dist/esm/modules/logger/pino/destination.js.map +1 -1
- package/dist/esm/modules/logger/pino/logger.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/formats.js.map +1 -1
- package/dist/esm/modules/logger/winston/logger-factory.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/network/utilities/url-safety/ingest.js.map +1 -1
- package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
- package/dist/esm/modules/pool/abstract.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/hf/helper.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/kafka/consumer.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/client/browser-helper.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/delivery.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/bun-s3/utility.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/adapters/dayjs.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/intl.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/luxon.js.map +1 -1
- package/dist/esm/modules/temporal/adapters/native.js.map +1 -1
- package/dist/esm/modules/temporal/calendar/calendar.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/temporal/common/types.js.map +1 -1
- package/dist/esm/modules/temporal/duration/duration.js.map +1 -1
- package/dist/esm/modules/temporal/helper.js.map +1 -1
- package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/pattern.js.map +1 -1
- package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
- package/dist/esm/modules/tree/builder.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/opaque.js.map +1 -1
- package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
- package/dist/esm/modules/uid/uuid/sha1.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/module.utility.js.map +1 -1
- package/dist/esm/utilities/parse.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 +4 -4
- package/dist/esm/common/constants/app.d.ts.map +0 -1
- package/dist/esm/common/constants/duration.d.ts.map +0 -1
- package/dist/esm/common/constants/grpc.d.ts.map +0 -1
- package/dist/esm/common/constants/http.d.ts.map +0 -1
- package/dist/esm/common/constants/index.d.ts.map +0 -1
- package/dist/esm/common/constants/mime.d.ts.map +0 -1
- package/dist/esm/common/index.d.ts.map +0 -1
- package/dist/esm/common/jsx.d.ts.map +0 -1
- package/dist/esm/common/redact.d.ts.map +0 -1
- package/dist/esm/common/resolvers.d.ts.map +0 -1
- package/dist/esm/common/types/class.d.ts.map +0 -1
- package/dist/esm/common/types/const-value.d.ts.map +0 -1
- package/dist/esm/common/types/field-mapping.d.ts.map +0 -1
- package/dist/esm/common/types/index.d.ts.map +0 -1
- package/dist/esm/common/types/injection.d.ts.map +0 -1
- package/dist/esm/common/types/resolver.d.ts.map +0 -1
- package/dist/esm/common/types/utility.d.ts.map +0 -1
- package/dist/esm/core.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/modules/base.d.ts.map +0 -1
- package/dist/esm/modules/cron/helper.d.ts.map +0 -1
- package/dist/esm/modules/cron/index.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/abstract.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/aes.engine.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/base.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/index.d.ts.map +0 -1
- package/dist/esm/modules/crypto/algorithms/rsa.algorithm.d.ts.map +0 -1
- package/dist/esm/modules/crypto/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/crypto/common/index.d.ts.map +0 -1
- package/dist/esm/modules/crypto/common/types.d.ts.map +0 -1
- package/dist/esm/modules/crypto/index.d.ts.map +0 -1
- package/dist/esm/modules/env/app-env.d.ts.map +0 -1
- package/dist/esm/modules/env/common/index.d.ts.map +0 -1
- package/dist/esm/modules/env/common/types.d.ts.map +0 -1
- package/dist/esm/modules/env/index.d.ts.map +0 -1
- package/dist/esm/modules/env/names.d.ts.map +0 -1
- package/dist/esm/modules/error/index.d.ts.map +0 -1
- package/dist/esm/modules/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/base/abstract.d.ts.map +0 -1
- package/dist/esm/modules/logger/base/base.d.ts.map +0 -1
- package/dist/esm/modules/logger/base/console.d.ts.map +0 -1
- package/dist/esm/modules/logger/base/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/logger/common/debug-gate.d.ts.map +0 -1
- package/dist/esm/modules/logger/common/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/common/types.d.ts.map +0 -1
- package/dist/esm/modules/logger/factory.d.ts.map +0 -1
- package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +0 -1
- package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +0 -1
- package/dist/esm/modules/logger/formatting/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/common/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/common/types.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/flusher.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/logger.d.ts.map +0 -1
- package/dist/esm/modules/logger/hf/ring.d.ts.map +0 -1
- package/dist/esm/modules/logger/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/backing.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/common/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/common/types.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/destination.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/pino/logger.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/common/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/common/types.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/define.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/formats.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/index.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/logger-factory.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/logger.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts.map +0 -1
- package/dist/esm/modules/logger/winston/transports/index.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/base-network-request.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/common/index.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/common/index.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/index.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +0 -1
- package/dist/esm/modules/network/http-request/index.d.ts.map +0 -1
- package/dist/esm/modules/network/index.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/index.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/udp-socket/index.d.ts.map +0 -1
- package/dist/esm/modules/network/udp-socket/network-udp-client.helper.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/index.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/query-string.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/common/index.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/common/types.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/index.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/ingest.d.ts.map +0 -1
- package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +0 -1
- package/dist/esm/modules/pool/abstract.d.ts.map +0 -1
- package/dist/esm/modules/pool/base.d.ts.map +0 -1
- package/dist/esm/modules/pool/common/index.d.ts.map +0 -1
- package/dist/esm/modules/pool/common/types.d.ts.map +0 -1
- package/dist/esm/modules/pool/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/bullmq/helper.d.ts.map +0 -1
- package/dist/esm/modules/queue/bullmq/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/queue/common/hook.d.ts.map +0 -1
- package/dist/esm/modules/queue/common/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/hf/common/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/hf/common/types.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/hf/helper.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/hf/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/sequential/common/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/sequential/common/types.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/sequential/helper.d.ts.map +0 -1
- package/dist/esm/modules/queue/internal/sequential/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/admin.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/base.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/common/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/admin.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/callbacks.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/connection.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/consumer.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/common/types/producer.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/consumer.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/producer.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/schema/index.d.ts.map +0 -1
- package/dist/esm/modules/queue/kafka/schema/registry.d.ts.map +0 -1
- package/dist/esm/modules/queue/mqtt/helper.d.ts.map +0 -1
- package/dist/esm/modules/queue/mqtt/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/base/abstract.helper.d.ts.map +0 -1
- package/dist/esm/modules/redis/base/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/cluster/cluster.helper.d.ts.map +0 -1
- package/dist/esm/modules/redis/cluster/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/redis/common/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/common/interfaces.d.ts.map +0 -1
- package/dist/esm/modules/redis/common/types.d.ts.map +0 -1
- package/dist/esm/modules/redis/factory.d.ts.map +0 -1
- package/dist/esm/modules/redis/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/sentinel/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts.map +0 -1
- package/dist/esm/modules/redis/single/index.d.ts.map +0 -1
- package/dist/esm/modules/redis/single/single.helper.d.ts.map +0 -1
- package/dist/esm/modules/redis/utility.d.ts.map +0 -1
- package/dist/esm/modules/retry/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/retry/common/index.d.ts.map +0 -1
- package/dist/esm/modules/retry/common/types.d.ts.map +0 -1
- package/dist/esm/modules/retry/helper.d.ts.map +0 -1
- package/dist/esm/modules/retry/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/base/abstract.helper.d.ts.map +0 -1
- package/dist/esm/modules/secrets/base/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/types/helper.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/types/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/types/lease.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/types/registration.d.ts.map +0 -1
- package/dist/esm/modules/secrets/common/types/timer.d.ts.map +0 -1
- package/dist/esm/modules/secrets/dotenv/dotenv.helper.d.ts.map +0 -1
- package/dist/esm/modules/secrets/dotenv/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/factory.d.ts.map +0 -1
- package/dist/esm/modules/secrets/hashicorp/auth.d.ts.map +0 -1
- package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts.map +0 -1
- package/dist/esm/modules/secrets/hashicorp/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/system-envs/index.d.ts.map +0 -1
- package/dist/esm/modules/secrets/system-envs/system-envs.helper.d.ts.map +0 -1
- package/dist/esm/modules/slug/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/slug/common/index.d.ts.map +0 -1
- package/dist/esm/modules/slug/helper.d.ts.map +0 -1
- package/dist/esm/modules/slug/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/browser.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/client/browser-helper.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/client/helper.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/client/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/types/client.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/types/hooks.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/types/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/common/types/server.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +0 -1
- package/dist/esm/modules/socket/socket-io/server/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/types/client.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/types/hooks.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/types/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/types/message.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/common/types/server.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/emitter/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/index.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +0 -1
- package/dist/esm/modules/socket/websocket/server/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/base.d.ts.map +0 -1
- package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +0 -1
- package/dist/esm/modules/storage/bun-s3/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +0 -1
- package/dist/esm/modules/storage/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/storage/common/errors.d.ts.map +0 -1
- package/dist/esm/modules/storage/common/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/common/types.d.ts.map +0 -1
- package/dist/esm/modules/storage/common/utility.d.ts.map +0 -1
- package/dist/esm/modules/storage/disk/helper.d.ts.map +0 -1
- package/dist/esm/modules/storage/disk/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/in-memory/helper.d.ts.map +0 -1
- package/dist/esm/modules/storage/in-memory/index.d.ts.map +0 -1
- package/dist/esm/modules/storage/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/abstract.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/dayjs.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/intl.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/luxon.d.ts.map +0 -1
- package/dist/esm/modules/temporal/adapters/native.d.ts.map +0 -1
- package/dist/esm/modules/temporal/calendar/calendar.d.ts.map +0 -1
- package/dist/esm/modules/temporal/calendar/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/temporal/common/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/common/types.d.ts.map +0 -1
- package/dist/esm/modules/temporal/duration/duration.d.ts.map +0 -1
- package/dist/esm/modules/temporal/duration/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/helper.d.ts.map +0 -1
- package/dist/esm/modules/temporal/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/locale/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/locale/locale.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/index.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/pattern.d.ts.map +0 -1
- package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +0 -1
- package/dist/esm/modules/tree/builder.d.ts.map +0 -1
- package/dist/esm/modules/tree/common/index.d.ts.map +0 -1
- package/dist/esm/modules/tree/common/types.d.ts.map +0 -1
- package/dist/esm/modules/tree/index.d.ts.map +0 -1
- package/dist/esm/modules/tree/walk.d.ts.map +0 -1
- package/dist/esm/modules/uid/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/uid/common/index.d.ts.map +0 -1
- package/dist/esm/modules/uid/common/types.d.ts.map +0 -1
- package/dist/esm/modules/uid/helper.d.ts.map +0 -1
- package/dist/esm/modules/uid/index.d.ts.map +0 -1
- package/dist/esm/modules/uid/opaque.d.ts.map +0 -1
- package/dist/esm/modules/uid/request-id.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/common/constants.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/common/index.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/common/types.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/helper.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/index.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/sha1.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/v4.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/v5.d.ts.map +0 -1
- package/dist/esm/modules/uid/uuid/v7.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/abstract.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/base.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/handler/abstract.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/handler/base.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/handler/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/bus/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/common/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/common/types.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/thread/abstract.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/thread/base.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/thread/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/worker/abstract.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/worker/base.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/worker/index.d.ts.map +0 -1
- package/dist/esm/modules/worker-thread/worker-pool.d.ts.map +0 -1
- package/dist/esm/temporal.d.ts.map +0 -1
- package/dist/esm/utilities/build-info.utility.d.ts.map +0 -1
- package/dist/esm/utilities/error.utility.d.ts.map +0 -1
- package/dist/esm/utilities/form-body.utility.d.ts.map +0 -1
- package/dist/esm/utilities/hr-time.utility.d.ts.map +0 -1
- package/dist/esm/utilities/index.d.ts.map +0 -1
- package/dist/esm/utilities/module.utility.d.ts.map +0 -1
- package/dist/esm/utilities/parse.utility.d.ts.map +0 -1
- package/dist/esm/utilities/performance.utility.d.ts.map +0 -1
- package/dist/esm/utilities/project-root.utility.d.ts.map +0 -1
- package/dist/esm/utilities/promise.utility.d.ts.map +0 -1
- package/dist/esm/utilities/request.utility.d.ts.map +0 -1
- package/dist/esm/uuid.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../../src/modules/storage/disk/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAA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AAC;wBAC7B,MAAM,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;oBAC5E,CAAC;oBACD,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;oBAChE,SAAS;gBACX,CAAC;gBAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;gBAC1D,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,SAAS;gBACX,CAAC;gBAED,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { ErrorPrettier } from '@/modules/logger';\nimport fs from 'node:fs';\nimport fsp from 'node:fs/promises';\nimport type { Stats } from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\nimport { BaseStorageHelper } from '../base';\nimport {\n type IBucketInfo,\n type IBucketRef,\n type IFileStat,\n type IListObjectsOptions,\n type IObjectInfo,\n type IObjectLocation,\n type IObjectRef,\n type IStorageHelperOptions,\n type IUploadFile,\n StorageErrors,\n} from '../common';\n\nexport interface IDiskHelperOptions extends IStorageHelperOptions {\n /** Base directory every bucket lives under. */\n basePath: string;\n}\n\nexport class DiskHelper extends BaseStorageHelper {\n private basePath: string;\n\n constructor(options: IDiskHelperOptions) {\n super({\n scope: options.scope ?? DiskHelper.name,\n identifier: options.identifier ?? DiskHelper.name,\n });\n this.basePath = path.resolve(options.basePath);\n\n if (!fs.existsSync(this.basePath)) {\n fs.mkdirSync(this.basePath, { recursive: true });\n }\n }\n\n private getBucketPath(opts: { bucket: IBucketRef }): string {\n return path.join(this.basePath, opts.bucket.name);\n }\n\n private getObjectPath(opts: IObjectLocation): string {\n return path.join(this.getBucketPath({ bucket: opts.bucket }), opts.object.key);\n }\n\n /** Validates the name AND the resolved path: containment survives a naming rule we get wrong. */\n private resolveObjectPath(opts: IObjectLocation): string {\n const { bucket, object } = opts;\n\n if (!this.isValidBucketName({ bucket })) {\n throw getError({ message: `[storage] Invalid bucket name | bucket: ${bucket.name}` });\n }\n\n if (!this.isValidObjectKey({ object, maxDepth: Number.MAX_SAFE_INTEGER })) {\n throw getError({ message: `[storage] Invalid object name | key: ${object.key}` });\n }\n\n const bucketPath = this.getBucketPath({ bucket });\n const objectPath = path.resolve(bucketPath, object.key);\n\n if (objectPath !== bucketPath && !objectPath.startsWith(`${bucketPath}${path.sep}`)) {\n throw getError({ message: `[storage] Invalid object name | key: ${object.key}` });\n }\n\n return objectPath;\n }\n\n /** `null` means not there. Anything but ENOENT is logged: it may exist and be unreadable. */\n private async statOrNull(opts: { target: string }): Promise<Stats | null> {\n const { target } = opts;\n\n try {\n const result = await fsp.stat(target);\n return result;\n } catch (error) {\n if ((error as NodeJS.ErrnoException)?.code !== 'ENOENT') {\n this.logger.warn(\n '[statOrNull] Cannot determine existence, reporting missing | path: %s | %s',\n target,\n ErrorPrettier.format({ error }),\n );\n }\n\n return null;\n }\n }\n\n private async exists(opts: { target: string }): Promise<boolean> {\n const result = await this.statOrNull(opts);\n return result !== null;\n }\n\n /** One `stat` answers existence and type. */\n async hasBucket(opts: { bucket: IBucketRef }): Promise<boolean> {\n if (!this.isValidBucketName(opts)) {\n return false;\n }\n\n const stat = await this.statOrNull({ target: this.getBucketPath(opts) });\n return stat?.isDirectory() ?? false;\n }\n\n async getBuckets(): Promise<IBucketInfo[]> {\n const result = await this.exists({ target: this.basePath });\n if (!result) {\n return [];\n }\n\n const entries = await fsp.readdir(this.basePath, { withFileTypes: true });\n const buckets: IBucketInfo[] = [];\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const bucketPath = path.join(this.basePath, entry.name);\n const stat = await fsp.stat(bucketPath);\n buckets.push({\n name: entry.name,\n creationDate: stat.birthtime,\n });\n }\n }\n\n return buckets;\n }\n\n async getBucket(opts: { bucket: IBucketRef }): Promise<IBucketInfo | null> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n return null;\n }\n\n const stat = await this.statOrNull({ target: this.getBucketPath(opts) });\n\n if (!stat?.isDirectory()) {\n return null;\n }\n\n return { name, creationDate: stat.birthtime };\n }\n\n async createBucket(opts: { bucket: IBucketRef }): Promise<IBucketInfo | null> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n throw getError({\n message: '[createBucket] Invalid name to create bucket!',\n });\n }\n\n const bucketPath = this.getBucketPath(opts);\n\n const result = await this.exists({ target: bucketPath });\n if (result) {\n throw getError({\n message: `[createBucket] Bucket already exists | name: ${name}`,\n });\n }\n\n await fsp.mkdir(bucketPath, { recursive: true });\n return this.getBucket(opts);\n }\n\n async removeBucket(opts: { bucket: IBucketRef }): Promise<boolean> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n throw getError({\n message: '[removeBucket] Invalid name to remove bucket!',\n });\n }\n\n const bucketPath = this.getBucketPath(opts);\n\n const result = await this.exists({ target: bucketPath });\n if (!result) {\n throw getError({\n message: `[removeBucket] Bucket does not exist | name: ${name}`,\n });\n }\n\n const files = await fsp.readdir(bucketPath);\n if (files.length > 0) {\n throw getError({\n message: `[removeBucket] Bucket is not empty | name: ${name}`,\n });\n }\n\n await fsp.rmdir(bucketPath);\n return true;\n }\n\n protected get defaultLinkPrefix(): string {\n return '/static-resources/';\n }\n\n protected async writeObject(opts: IObjectLocation & { file: IUploadFile }): Promise<void> {\n const { bucket, object, file } = opts;\n const objectPath = this.getObjectPath({ bucket, object });\n\n // `recursive` succeeds on an existing directory; probing first wastes a syscall per file.\n await fsp.mkdir(path.dirname(objectPath), { recursive: true });\n await fsp.writeFile(objectPath, file.buffer);\n }\n\n async getObject(opts: IObjectLocation & { options?: any }): Promise<Readable> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getObject] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n return fs.createReadStream(objectPath);\n }\n\n /** `createReadStream` seeks natively, so a range never reads the bytes before it. */\n override async getObjectStream(\n opts: IObjectLocation & { range?: { start: number; end?: number } },\n ): Promise<ReadableStream<Uint8Array>> {\n const { bucket, object, range } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getObjectStream] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n const source = fs.createReadStream(\n objectPath,\n range ? { start: range.start, end: range.end } : {},\n );\n\n return Readable.toWeb(source) as ReadableStream<Uint8Array>;\n }\n\n async getStat(opts: IObjectLocation): Promise<IFileStat> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n const stat = await this.statOrNull({ target: objectPath });\n\n if (!stat) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getStat] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n return {\n size: stat.size,\n lastModified: stat.mtime,\n metadata: {\n mimetype: this.getMimeType({ filename: object.key }),\n },\n };\n }\n\n async removeObject(opts: IObjectLocation): Promise<void> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[removeObject] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n await fsp.unlink(objectPath);\n }\n\n // Bounded concurrency; one failure stops the batch.\n async removeObjects(opts: { bucket: IBucketRef; objects: IObjectRef[] }): Promise<void> {\n const { bucket, objects } = opts;\n\n await this.mapWithConcurrency({\n items: objects,\n task: ({ item: object }) => this.removeObject({ bucket, object }),\n });\n }\n\n async listObjects(opts: IListObjectsOptions): Promise<IObjectInfo[]> {\n const { bucket, prefix = '', useRecursive = false, maxKeys } = opts;\n\n if (!this.isValidBucketName({ bucket })) {\n throw getError({ message: `[listObjects] Invalid bucket name | bucket: ${bucket.name}` });\n }\n\n // `maxKeys: 0` means zero, not unlimited.\n const limit = maxKeys ?? Number.POSITIVE_INFINITY;\n if (limit <= 0) {\n return [];\n }\n\n const bucketPath = this.getBucketPath({ bucket });\n const result = await this.exists({ target: bucketPath });\n if (!result) {\n return [];\n }\n\n const objects: IObjectInfo[] = [];\n\n const scanDirectory = async (scanOptions: {\n directory: { path: string; prefix?: string };\n }): Promise<void> => {\n const { directory } = scanOptions;\n\n if (objects.length >= limit) {\n return;\n }\n\n const entries = await fsp.readdir(directory.path, { withFileTypes: true });\n\n for (const entry of entries) {\n if (objects.length >= limit) {\n return;\n }\n\n // An object key always joins on '/'; `path.join` would emit '\\' on Windows.\n const entryKey = directory.prefix ? `${directory.prefix}/${entry.name}` : entry.name;\n const entryPath = path.join(directory.path, entry.name);\n\n if (entry.isDirectory()) {\n // A prefix that cannot match below here makes descending pointless.\n const canMatch = !prefix || prefix.startsWith(entryKey) || entryKey.startsWith(prefix);\n if (useRecursive && canMatch) {\n await scanDirectory({ directory: { path: entryPath, prefix: entryKey } });\n }\n continue;\n }\n\n if (!entry.isFile() || (prefix && !entryKey.startsWith(prefix))) {\n continue;\n }\n\n const stat = await this.statOrNull({ target: entryPath });\n if (!stat) {\n continue;\n }\n\n objects.push({ name: entryKey, size: stat.size, lastModified: stat.mtime });\n }\n };\n\n await scanDirectory({ directory: { path: bucketPath } });\n return objects;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../../src/modules/storage/disk/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,GAAG,MAAM,kBAAkB,CAAC;AAEnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAUL,aAAa,GACd,MAAM,WAAW,CAAC;AAQnB,kNAAkN;AAClN,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAG/C,YAAY,OAA2B;QACrC,KAAK,CAAC;YACJ,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,UAAU,CAAC,IAAI;YACvC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI;SAClD,CAAC,CAAC;QACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAEO,aAAa,CAAC,IAA4B;QAChD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAEO,aAAa,CAAC,I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AAI,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;gBAExD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;oBACxB,oEAAoE;oBACpE,MAAM,QAAQ,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;oBAEvF,IAAI,YAAY,IAAI,QAAQ,EAAE,CAAC;wBAC7B,MAAM,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;oBAC5E,CAAC;oBAED,SAAS;gBACX,CAAC;gBAED,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;oBAChE,SAAS;gBACX,CAAC;gBAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;gBAE1D,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,SAAS;gBACX,CAAC;gBAED,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YAC9E,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,EAAE,CAAC,CAAC;QAEzD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["import { getError } from '@/modules/error';\nimport { ErrorPrettier } from '@/modules/logger';\nimport fs from 'node:fs';\nimport fsp from 'node:fs/promises';\nimport type { Stats } from 'node:fs';\nimport path from 'node:path';\nimport { Readable } from 'node:stream';\nimport { BaseStorageHelper } from '../base';\nimport {\n type IBucketInfo,\n type IBucketRef,\n type IFileStat,\n type IListObjectsOptions,\n type IObjectInfo,\n type IObjectLocation,\n type IObjectRef,\n type IStorageHelperOptions,\n type IUploadFile,\n StorageErrors,\n} from '../common';\n\n/** Options for `DiskHelper`; `basePath` is created when missing. */\nexport interface IDiskHelperOptions extends IStorageHelperOptions {\n /** Base directory every bucket lives under. */\n basePath: string;\n}\n\n/** Storage backed by the local filesystem: each bucket is a directory under `basePath`, each object a file whose key is its relative path. Names are validated and resolved paths must stay inside the bucket. */\nexport class DiskHelper extends BaseStorageHelper {\n private basePath: string;\n\n constructor(options: IDiskHelperOptions) {\n super({\n scope: options.scope ?? DiskHelper.name,\n identifier: options.identifier ?? DiskHelper.name,\n });\n this.basePath = path.resolve(options.basePath);\n\n if (!fs.existsSync(this.basePath)) {\n fs.mkdirSync(this.basePath, { recursive: true });\n }\n }\n\n private getBucketPath(opts: { bucket: IBucketRef }): string {\n return path.join(this.basePath, opts.bucket.name);\n }\n\n private getObjectPath(opts: IObjectLocation): string {\n return path.join(this.getBucketPath({ bucket: opts.bucket }), opts.object.key);\n }\n\n /** Validates the name AND the resolved path: containment survives a naming rule we get wrong. */\n private resolveObjectPath(opts: IObjectLocation): string {\n const { bucket, object } = opts;\n\n if (!this.isValidBucketName({ bucket })) {\n throw getError({ message: `[storage] Invalid bucket name | bucket: ${bucket.name}` });\n }\n\n if (!this.isValidObjectKey({ object, maxDepth: Number.MAX_SAFE_INTEGER })) {\n throw getError({ message: `[storage] Invalid object name | key: ${object.key}` });\n }\n\n const bucketPath = this.getBucketPath({ bucket });\n const objectPath = path.resolve(bucketPath, object.key);\n\n if (objectPath !== bucketPath && !objectPath.startsWith(`${bucketPath}${path.sep}`)) {\n throw getError({ message: `[storage] Invalid object name | key: ${object.key}` });\n }\n\n return objectPath;\n }\n\n /** `null` means not there. Anything but ENOENT is logged: it may exist and be unreadable. */\n private async statOrNull(opts: { target: string }): Promise<Stats | null> {\n const { target } = opts;\n\n try {\n const result = await fsp.stat(target);\n\n return result;\n } catch (error) {\n if ((error as NodeJS.ErrnoException)?.code !== 'ENOENT') {\n this.logger.warn(\n '[statOrNull] Cannot determine existence, reporting missing | path: %s | %s',\n target,\n ErrorPrettier.format({ error }),\n );\n }\n\n return null;\n }\n }\n\n private async exists(opts: { target: string }): Promise<boolean> {\n const result = await this.statOrNull(opts);\n\n return result !== null;\n }\n\n /** One `stat` answers existence and type. */\n async hasBucket(opts: { bucket: IBucketRef }): Promise<boolean> {\n if (!this.isValidBucketName(opts)) {\n return false;\n }\n\n const stat = await this.statOrNull({ target: this.getBucketPath(opts) });\n\n return stat?.isDirectory() ?? false;\n }\n\n async getBuckets(): Promise<IBucketInfo[]> {\n const result = await this.exists({ target: this.basePath });\n\n if (!result) {\n return [];\n }\n\n const entries = await fsp.readdir(this.basePath, { withFileTypes: true });\n const buckets: IBucketInfo[] = [];\n\n for (const entry of entries) {\n if (entry.isDirectory()) {\n const bucketPath = path.join(this.basePath, entry.name);\n const stat = await fsp.stat(bucketPath);\n buckets.push({\n name: entry.name,\n creationDate: stat.birthtime,\n });\n }\n }\n\n return buckets;\n }\n\n async getBucket(opts: { bucket: IBucketRef }): Promise<IBucketInfo | null> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n return null;\n }\n\n const stat = await this.statOrNull({ target: this.getBucketPath(opts) });\n\n if (!stat?.isDirectory()) {\n return null;\n }\n\n return { name, creationDate: stat.birthtime };\n }\n\n async createBucket(opts: { bucket: IBucketRef }): Promise<IBucketInfo | null> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n throw getError({\n message: '[createBucket] Invalid name to create bucket!',\n });\n }\n\n const bucketPath = this.getBucketPath(opts);\n\n const result = await this.exists({ target: bucketPath });\n\n if (result) {\n throw getError({\n message: `[createBucket] Bucket already exists | name: ${name}`,\n });\n }\n\n await fsp.mkdir(bucketPath, { recursive: true });\n\n return this.getBucket(opts);\n }\n\n async removeBucket(opts: { bucket: IBucketRef }): Promise<boolean> {\n const { name } = opts.bucket;\n\n if (!this.isValidBucketName(opts)) {\n throw getError({\n message: '[removeBucket] Invalid name to remove bucket!',\n });\n }\n\n const bucketPath = this.getBucketPath(opts);\n\n const result = await this.exists({ target: bucketPath });\n\n if (!result) {\n throw getError({\n message: `[removeBucket] Bucket does not exist | name: ${name}`,\n });\n }\n\n const files = await fsp.readdir(bucketPath);\n\n if (files.length > 0) {\n throw getError({\n message: `[removeBucket] Bucket is not empty | name: ${name}`,\n });\n }\n\n await fsp.rmdir(bucketPath);\n\n return true;\n }\n\n protected get defaultLinkPrefix(): string {\n return '/static-resources/';\n }\n\n protected async writeObject(opts: IObjectLocation & { file: IUploadFile }): Promise<void> {\n const { bucket, object, file } = opts;\n const objectPath = this.getObjectPath({ bucket, object });\n\n // `recursive` succeeds on an existing directory; probing first wastes a syscall per file.\n await fsp.mkdir(path.dirname(objectPath), { recursive: true });\n await fsp.writeFile(objectPath, file.buffer);\n }\n\n async getObject(opts: IObjectLocation & { options?: any }): Promise<Readable> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getObject] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n return fs.createReadStream(objectPath);\n }\n\n /** `createReadStream` seeks natively, so a range never reads the bytes before it. */\n override async getObjectStream(\n opts: IObjectLocation & { range?: { start: number; end?: number } },\n ): Promise<ReadableStream<Uint8Array>> {\n const { bucket, object, range } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getObjectStream] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n const source = fs.createReadStream(\n objectPath,\n range ? { start: range.start, end: range.end } : {},\n );\n\n return Readable.toWeb(source) as ReadableStream<Uint8Array>;\n }\n\n async getStat(opts: IObjectLocation): Promise<IFileStat> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n const stat = await this.statOrNull({ target: objectPath });\n\n if (!stat) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[getStat] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n return {\n size: stat.size,\n lastModified: stat.mtime,\n metadata: {\n mimetype: this.getMimeType({ filename: object.key }),\n },\n };\n }\n\n async removeObject(opts: IObjectLocation): Promise<void> {\n const { bucket, object } = opts;\n const objectPath = this.resolveObjectPath({ bucket, object });\n\n const result = await this.exists({ target: objectPath });\n\n if (!result) {\n throw getError({\n error: StorageErrors.OBJECT_NOT_FOUND,\n message: `[removeObject] Object not found | bucket: ${bucket.name} | key: ${object.key}`,\n });\n }\n\n await fsp.unlink(objectPath);\n }\n\n // Bounded concurrency; one failure stops the batch.\n async removeObjects(opts: { bucket: IBucketRef; objects: IObjectRef[] }): Promise<void> {\n const { bucket, objects } = opts;\n\n await this.mapWithConcurrency({\n items: objects,\n task: ({ item: object }) => this.removeObject({ bucket, object }),\n });\n }\n\n async listObjects(opts: IListObjectsOptions): Promise<IObjectInfo[]> {\n const { bucket, prefix = '', useRecursive = false, maxKeys } = opts;\n\n if (!this.isValidBucketName({ bucket })) {\n throw getError({ message: `[listObjects] Invalid bucket name | bucket: ${bucket.name}` });\n }\n\n // `maxKeys: 0` means zero, not unlimited.\n const limit = maxKeys ?? Number.POSITIVE_INFINITY;\n\n if (limit <= 0) {\n return [];\n }\n\n const bucketPath = this.getBucketPath({ bucket });\n const result = await this.exists({ target: bucketPath });\n\n if (!result) {\n return [];\n }\n\n const objects: IObjectInfo[] = [];\n\n const scanDirectory = async (scanOptions: {\n directory: { path: string; prefix?: string };\n }): Promise<void> => {\n const { directory } = scanOptions;\n\n if (objects.length >= limit) {\n return;\n }\n\n const entries = await fsp.readdir(directory.path, { withFileTypes: true });\n\n for (const entry of entries) {\n if (objects.length >= limit) {\n return;\n }\n\n // An object key always joins on '/'; `path.join` would emit '\\' on Windows.\n const entryKey = directory.prefix ? `${directory.prefix}/${entry.name}` : entry.name;\n const entryPath = path.join(directory.path, entry.name);\n\n if (entry.isDirectory()) {\n // A prefix that cannot match below here makes descending pointless.\n const canMatch = !prefix || prefix.startsWith(entryKey) || entryKey.startsWith(prefix);\n\n if (useRecursive && canMatch) {\n await scanDirectory({ directory: { path: entryPath, prefix: entryKey } });\n }\n\n continue;\n }\n\n if (!entry.isFile() || (prefix && !entryKey.startsWith(prefix))) {\n continue;\n }\n\n const stat = await this.statOrNull({ target: entryPath });\n\n if (!stat) {\n continue;\n }\n\n objects.push({ name: entryKey, size: stat.size, lastModified: stat.mtime });\n }\n };\n\n await scanDirectory({ directory: { path: bucketPath } });\n\n return objects;\n }\n}\n"]}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { BaseHelper } from '../base.js';
|
|
2
2
|
import type { TTemporalDurationStyle, TTemporalInclusivity, TTemporalUnit } from './common/constants.js';
|
|
3
3
|
import type { ITemporalAdapter, ITemporalDurationParts, ITemporalLocaleNames, ITemporalParts, TTemporalFields, IZonedTemporalParts, TTemporalInput, ITemporalHelper } from './common/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The machinery every temporal helper shares: the adapter, the zone and locale it holds, reading a
|
|
6
|
+
* zone's offset, turning wall clocks into instants across daylight-saving gaps and repeats, and the
|
|
7
|
+
* input checks. A helper extends this and supplies the operations in `ITemporalHelper`.
|
|
8
|
+
*/
|
|
4
9
|
export declare abstract class AbstractTemporalHelper extends BaseHelper implements ITemporalHelper {
|
|
5
10
|
/** Validated once per process: `Intl` answers the same for a zone name every time. */
|
|
6
11
|
protected static readonly knownTzs: Set<string>;
|
|
@@ -20,7 +20,8 @@ const NAME_LENGTHS = {
|
|
|
20
20
|
weekdaysMin: 7,
|
|
21
21
|
meridiem: 2,
|
|
22
22
|
};
|
|
23
|
-
const OUT_OF_RANGE = `outside the years ${TemporalCalendar.MIN_YEAR}-${TemporalCalendar.MAX_YEAR}`;
|
|
23
|
+
const OUT_OF_RANGE = `outside the years ${TemporalCalendar.MIN_YEAR}-${TemporalCalendar.MAX_YEAR}`;
|
|
24
|
+
/**
|
|
24
25
|
* The machinery every temporal helper shares: the adapter, the zone and locale it holds, reading a
|
|
25
26
|
* zone's offset, turning wall clocks into instants across daylight-saving gaps and repeats, and the
|
|
26
27
|
* input checks. A helper extends this and supplies the operations in `ITemporalHelper`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/modules/temporal/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,IAAI,mBAAmB,EAC1C,aAAa,GACd,MAAM,oBAAoB,CAAC;AAgB5B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,6DAA6D;AAC7D,MAAM,WAAW,GAAG,CAAC,kBAAkB,CAAC;AACxC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,oDAAoD;AACpD,MAAM,YAAY,GAA+C;IAC/D,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,CAAC;IACX,aAAa,E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IAAI,CAAC;QACnC,MAAM,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC;YACrC,KAAK,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAAE,KAAK,EAAE,CAAC;YAC9C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,aAAa,CAAC,KAAK;SAC1B,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { BaseHelper } from '@/modules/base';\nimport { getError, isApplicationError } from '@/modules/error';\nimport { IntlTemporalAdapter } from './adapters/intl';\nimport { NativeTemporalAdapter } from './adapters/native';\nimport { TemporalCalendar } from './calendar';\nimport {\n DEFAULT_TEMPORAL_LOCALE,\n DEFAULT_TEMPORAL_TZ as DEFAULT_TEMPORAL_TZ,\n TemporalUnits,\n} from './common/constants';\nimport type {\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './common/constants';\nimport type {\n ITemporalAdapter,\n ITemporalDurationParts,\n ITemporalLocaleNames,\n ITemporalParts,\n TTemporalFields,\n IZonedTemporalParts,\n TTemporalInput,\n ITemporalHelper,\n} from './common/types';\nimport { TemporalLocale } from './locale';\n\nconst DAY_MILLISECONDS = 86_400_000;\n\n/** 0001-01-01T00:00:00.000Z and 9999-12-31T23:59:59.999Z. */\nconst MIN_INSTANT = -62_135_596_800_000;\nconst MAX_INSTANT = 253_402_300_799_999;\n\nconst MAX_KNOWN_TIME_ZONES = 256;\n\n/** How many entries each `names` list must hold. */\nconst NAME_LENGTHS: Record<keyof ITemporalLocaleNames, number> = {\n months: 12,\n monthsShort: 12,\n weekdays: 7,\n weekdaysShort: 7,\n weekdaysMin: 7,\n meridiem: 2,\n};\n\nconst OUT_OF_RANGE = `outside the years ${TemporalCalendar.MIN_YEAR}-${TemporalCalendar.MAX_YEAR}`; /**\n * The machinery every temporal helper shares: the adapter, the zone and locale it holds, reading a\n * zone's offset, turning wall clocks into instants across daylight-saving gaps and repeats, and the\n * input checks. A helper extends this and supplies the operations in `ITemporalHelper`.\n */\nexport abstract class AbstractTemporalHelper extends BaseHelper implements ITemporalHelper {\n /** Validated once per process: `Intl` answers the same for a zone name every time. */\n protected static readonly knownTzs = new Set<string>();\n\n protected readonly adapter: ITemporalAdapter;\n protected readonly tz: string;\n protected readonly locale: string;\n protected readonly names: Record<string, ITemporalLocaleNames>;\n protected readonly fallback?: string;\n /** Which `names` entry each locale a call wrote in resolved to - `names` never changes after construction. */\n private readonly namesByLocale = new Map<string, ITemporalLocaleNames | undefined>();\n\n /**\n * `locale` (default `en-US`) spells month and weekday names, AM/PM, relative time and durations,\n * unless a call passes its own. `names` replaces `Intl`'s wording for a locale - month and weekday\n * names, the AM/PM marker - keyed by a locale tag; a call in another tag of the same language (`vi`\n * for a `vi-VN` entry) uses it too. `fallback` is what `format` and `formatIntl` write for a value\n * that is not a date when a call gives none; without it, such a value is a 400.\n */\n constructor(opts?: {\n adapter?: ITemporalAdapter;\n tz?: string;\n locale?: string;\n names?: Record<string, ITemporalLocaleNames>;\n fallback?: string;\n scope?: string;\n }) {\n super({ scope: opts?.scope ?? new.target.name });\n\n this.tz = AbstractTemporalHelper.ensureTz({\n tz: opts?.tz ?? DEFAULT_TEMPORAL_TZ,\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n });\n this.locale = AbstractTemporalHelper.ensureLocale({\n locale: opts?.locale ?? DEFAULT_TEMPORAL_LOCALE,\n });\n this.adapter = opts?.adapter ?? AbstractTemporalHelper.defaultAdapter();\n this.names = AbstractTemporalHelper.ensureNames({ names: opts?.names ?? {} });\n this.fallback = opts?.fallback;\n }\n\n /**\n * The zone a `Date`'s local getters use on this runtime - the browser's or the server's. The one\n * place this helper reads the host zone, and only when a wall-clock bridge is not given one.\n */\n static getHostTz(): string {\n return new Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /** The instant whose wall clock in `to` reads what `value`'s wall clock reads in `from`. */\n protected moveWallClock(opts: { value: TTemporalInput; from: string; to: string }): Date {\n const from = this.resolveTz({ tz: opts.from });\n const to = this.resolveTz({ tz: opts.to });\n const date = this.toDate({ value: opts.value, tz: from });\n\n const wall = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz: from }),\n });\n return AbstractTemporalHelper.ensureInstant({\n epoch: this.earliestOf({ parts: wall, tz: to }),\n });\n }\n\n /** Every list the right length, so a bad table fails when the helper is built, not on a screen. */\n protected static ensureNames(opts: {\n names: Record<string, ITemporalLocaleNames>;\n }): Record<string, ITemporalLocaleNames> {\n for (const [locale, names] of Object.entries(opts.names)) {\n AbstractTemporalHelper.ensureLocale({ locale });\n for (const [key, length] of Object.entries(NAME_LENGTHS)) {\n const list: unknown = Reflect.get(names, key);\n if (list === undefined) {\n continue;\n }\n if (\n !Array.isArray(list) ||\n list.length !== length ||\n !list.every((entry) => typeof entry === 'string')\n ) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalHelper] names['${locale}'].${key} must hold ${length} strings`,\n });\n }\n }\n }\n return opts.names;\n }\n\n /** The wording this helper holds for `locale`, if any. */\n protected namesOf(opts: { locale: string }): ITemporalLocaleNames | undefined {\n const { locale } = opts;\n if (Object.hasOwn(this.names, locale)) {\n return this.names[locale];\n }\n\n if (this.namesByLocale.has(locale)) {\n return this.namesByLocale.get(locale);\n }\n // A malformed tag is the caller's 400, before it reaches `Intl.Locale`.\n AbstractTemporalHelper.ensureLocale({ locale });\n\n // No entry for the exact tag: one for the same language serves - `vi` reads a `vi-VN` entry.\n const language = new Intl.Locale(locale).language;\n const match = Object.keys(this.names).find((key) => new Intl.Locale(key).language === language);\n const names = match === undefined ? undefined : this.names[match];\n this.namesByLocale.set(locale, names);\n return names;\n }\n\n /**\n * The value as a date for a writer: with a fallback - the call's, else the helper's - a value that\n * is not a date answers `null`; without one it is a 400, null included.\n */\n protected readDate(opts: {\n value: TTemporalInput | null | undefined;\n tz: string;\n fallback?: string;\n }): Date | null {\n const { value, tz } = opts;\n if ((opts.fallback ?? this.fallback) !== undefined) {\n return this.tryToDate({ value, tz });\n }\n if (value === null || value === undefined) {\n throw AbstractTemporalHelper.notADate({ value });\n }\n return this.toDate({ value, tz });\n }\n\n /** The runtime's `Temporal` where it has one; `Intl`, which every runtime has, everywhere else. */\n protected static defaultAdapter(): ITemporalAdapter {\n return NativeTemporalAdapter.isTemporalNamespace(Reflect.get(globalThis, 'Temporal'))\n ? new NativeTemporalAdapter()\n : new IntlTemporalAdapter();\n }\n\n protected static ensureLocale(opts: { locale: string }): string {\n TemporalLocale.of({ locale: opts.locale });\n return opts.locale;\n }\n\n /** A parse or input error the caller may treat as \"not a date\"; anything else is a bug and still throws. */\n protected static isRefusal(error: unknown): boolean {\n return isApplicationError(error) && error.statusCode === HTTP.ResultCodes.RS_4.BadRequest;\n }\n\n protected static ensureTz(opts: { tz: string; statusCode: number }): string {\n const { tz, statusCode } = opts;\n if (AbstractTemporalHelper.knownTzs.has(tz)) {\n return tz;\n }\n\n try {\n new Intl.DateTimeFormat('en-US', { timeZone: tz });\n } catch (error) {\n throw getError({\n statusCode,\n message: `[TemporalHelper] unknown time zone '${tz}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n if (AbstractTemporalHelper.knownTzs.size < MAX_KNOWN_TIME_ZONES) {\n AbstractTemporalHelper.knownTzs.add(tz);\n }\n return tz;\n }\n\n protected static ensureUnit(opts: { unit: string; amount?: number }): void {\n const { unit, amount } = opts;\n if (!TemporalUnits.isValid(unit)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] unknown unit '${unit}' | Supported: ${[...TemporalUnits.SCHEME_SET].join(', ')}`,\n });\n }\n if (amount === undefined) {\n return;\n }\n // Elapsed time takes a fraction (1.5 hours is 90 minutes); a calendar unit has no half.\n const isElapsed = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit] !== undefined;\n if (isElapsed ? !Number.isFinite(amount) : !Number.isInteger(amount)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: isElapsed\n ? `[TemporalHelper] amount must be a finite number - received ${amount}`\n : `[TemporalHelper] amount must be an integer for '${unit}' - received ${amount}`,\n });\n }\n }\n\n /** Every result passes here: an overflowing `add` is refused, never an Invalid Date. */\n protected static ensureInstant(opts: { epoch: number }): Date {\n const { epoch } = opts;\n if (!(epoch >= MIN_INSTANT && epoch <= MAX_INSTANT)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] ${Number.isNaN(epoch) ? 'invalid date' : OUT_OF_RANGE} - received ${epoch}`,\n });\n }\n return new Date(epoch);\n }\n\n protected static ensureYear(opts: { parts: ITemporalParts }): void {\n if (!TemporalCalendar.isSupportedYear({ year: opts.parts.year })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] year ${opts.parts.year} is ${OUT_OF_RANGE}`,\n });\n }\n }\n\n protected resolveTz(opts: { tz?: string }): string {\n return opts.tz === undefined\n ? this.tz\n : AbstractTemporalHelper.ensureTz({\n tz: opts.tz,\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n });\n }\n\n /** The adapter's one answer, rounded: an offset is whole milliseconds, a library's float may not be. */\n protected offsetAt(opts: { epoch: number; tz: string }): number {\n return Math.round(\n this.adapter.getOffsetMilliseconds({ value: new Date(opts.epoch), tz: opts.tz }),\n );\n }\n\n protected zonedParts(opts: { epoch: number; tz: string }): IZonedTemporalParts {\n const parts = TemporalCalendar.wallClockAt({\n epoch: opts.epoch,\n offsetMilliseconds: this.offsetAt(opts),\n });\n AbstractTemporalHelper.ensureYear({ parts });\n return parts;\n }\n\n /**\n * Every instant whose wall clock reads `parts` in the zone, earliest first: one as a rule, two\n * when the clock goes back, none when it jumps forward. `forward` is where a skipped time lands -\n * read with the offset from before the jump, so it moves past the gap.\n */\n protected instantsOf(opts: { parts: ITemporalParts; tz: string }): {\n instants: Array<number>;\n forward: number;\n } {\n const { parts, tz } = opts;\n const local = TemporalCalendar.epochAtOffset({ parts, offsetMilliseconds: 0 });\n const before = this.offsetAt({ epoch: local - DAY_MILLISECONDS, tz });\n const after = this.offsetAt({ epoch: local + DAY_MILLISECONDS, tz });\n\n const offsets = before === after ? [before] : [before, after];\n const instants: Array<number> = [];\n for (const offset of offsets) {\n const candidate = local - offset;\n if (this.offsetAt({ epoch: candidate, tz }) === offset) {\n instants.push(candidate);\n }\n }\n instants.sort((left, right) => left - right);\n\n return { instants, forward: local - before };\n }\n\n /** The instant wall-clock `parts` name: a skipped time moves forward, a repeated one takes the earlier. */\n protected earliestOf(opts: { parts: ITemporalParts; tz: string }): number {\n const { instants, forward } = this.instantsOf(opts);\n return instants[0] ?? forward;\n }\n\n /**\n * `[start, end)` of the unit holding `epoch`. A day or longer starts at its first instant. An hour\n * or less repeats when the clock goes back, so it starts at the latest start not after `epoch`,\n * and ends where the wall clock next shows either the following unit or this one's start again.\n */\n protected unitBounds(opts: { epoch: number; unit: TTemporalUnit; tz: string }): {\n start: number;\n end: number;\n } {\n const { epoch, unit, tz } = opts;\n const startParts = TemporalCalendar.truncate({\n parts: this.zonedParts({ epoch, tz }),\n unit,\n });\n const nextParts = TemporalCalendar.shift({ parts: startParts, amount: 1, unit });\n AbstractTemporalHelper.ensureYear({ parts: nextParts });\n\n const starts = this.instantsOf({ parts: startParts, tz });\n if (TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit] === undefined) {\n const start = starts.instants[0] ?? starts.forward;\n return { start, end: this.earliestOf({ parts: nextParts, tz }) };\n }\n\n const started = starts.instants.filter((instant) => instant <= epoch);\n const start = started.at(-1) ?? starts.instants[0] ?? starts.forward;\n\n const nexts = this.instantsOf({ parts: nextParts, tz });\n const following = nexts.instants.find((instant) => instant > start) ?? nexts.forward;\n const repeated = starts.instants.find((instant) => instant > start);\n return { start, end: repeated === undefined ? following : Math.min(repeated, following) };\n }\n\n getTz(): string {\n return this.tz;\n }\n\n getLocale(): string {\n return this.locale;\n }\n\n now(): Date {\n return new Date();\n }\n\n /** The instant a value names. An ISO string without an offset is read as wall clock in the zone. */\n toDate(opts: { value: TTemporalInput; tz?: string }): Date {\n const { value } = opts;\n\n if (typeof value === 'string') {\n return this.parse({ value, tz: opts.tz });\n }\n if (value instanceof Date) {\n return AbstractTemporalHelper.ensureInstant({ epoch: value.getTime() });\n }\n if (typeof value === 'number') {\n return AbstractTemporalHelper.ensureInstant({ epoch: value });\n }\n\n // `null` above all: read as a number it would be 1970, a date nobody meant.\n throw AbstractTemporalHelper.notADate({ value });\n }\n\n protected static notADate(opts: { value: unknown }) {\n const { value } = opts;\n return getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] not a date - received ${value === null ? 'null' : typeof value}`,\n });\n }\n\n /** `toDate`, answering `null` where `toDate` refuses the value: null, undefined, bad text, NaN. */\n tryToDate(opts: { value: TTemporalInput | null | undefined; tz?: string }): Date | null {\n const { value } = opts;\n // Outside the try: a bad zone is the caller's bug, not an unreadable value.\n const tz = this.resolveTz({ tz: opts.tz });\n if (value === null || value === undefined) {\n return null;\n }\n\n try {\n return this.toDate({ value, tz });\n } catch (error) {\n if (AbstractTemporalHelper.isRefusal(error)) {\n return null;\n }\n throw error;\n }\n }\n\n /** The wall clock the value shows in the zone, with its ISO weekday and UTC offset. */\n parts(opts: { value: TTemporalInput; tz?: string }): IZonedTemporalParts {\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n return this.zonedParts({ epoch: date.getTime(), tz });\n }\n\n /**\n * Fractional months from `other` to `value` (dayjs and moment's month difference): anchored on the\n * date with the later day of the month, whole months by `add`, the rest as a share of the month\n * it falls in.\n */\n protected monthGap(opts: { value: number; other: number; tz: string }): number {\n const { value, other, tz } = opts;\n const valueParts = this.zonedParts({ epoch: value, tz });\n const otherParts = this.zonedParts({ epoch: other, tz });\n if (valueParts.day < otherParts.day) {\n return -this.monthGap({ value: other, other: value, tz });\n }\n\n const whole = (otherParts.year - valueParts.year) * 12 + (otherParts.month - valueParts.month);\n const anchor = this.shiftMonthsFrom({ parts: valueParts, months: whole, tz });\n const isBelow = other - anchor < 0;\n const nextAnchor = this.shiftMonthsFrom({\n parts: valueParts,\n months: whole + (isBelow ? -1 : 1),\n tz,\n });\n const span = isBelow ? anchor - nextAnchor : nextAnchor - anchor;\n\n return -(whole + (other - anchor) / span) || 0;\n }\n\n /** `add` by months without the 1-9999 check: an anchor one month past the range is still a number. */\n protected shiftMonthsFrom(opts: {\n parts: IZonedTemporalParts;\n months: number;\n tz: string;\n }): number {\n const { parts, months, tz } = opts;\n const shifted = TemporalCalendar.shift({\n parts: TemporalCalendar.wallClockOf({ parts }),\n amount: months,\n unit: TemporalUnits.MONTH,\n });\n return this.earliestOf({ parts: shifted, tz });\n }\n\n abstract fromWallClock(opts: { value: TTemporalInput; sourceTz?: string; tz?: string }): Date;\n\n abstract toWallClock(opts: { value: TTemporalInput; targetTz?: string; tz?: string }): Date;\n\n abstract clone(opts: { locale?: string; tz?: string }): ITemporalHelper;\n\n abstract parse(opts: { value: string; pattern?: string; tz?: string }): Date;\n\n abstract tryParse(opts: { value: string; pattern?: string; tz?: string }): Date | null;\n\n abstract isValid(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n }): boolean;\n\n abstract format(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n abstract formatIntl(opts: {\n value: TTemporalInput;\n options?: Omit<Intl.DateTimeFormatOptions, 'timeZone'>;\n tz?: string;\n locale?: string;\n }): string;\n\n abstract add(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date;\n\n abstract subtract(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date;\n\n abstract startOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n abstract endOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n abstract isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean;\n\n abstract nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n abstract previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n abstract set(opts: { value: TTemporalInput; tz?: string } & TTemporalFields): Date;\n\n abstract isBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSame(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isBetween(opts: {\n value: TTemporalInput;\n from: TTemporalInput;\n to: TTemporalInput;\n unit?: TTemporalUnit;\n inclusivity?: TTemporalInclusivity;\n tz?: string;\n }): boolean;\n\n abstract diff(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit: TTemporalUnit;\n tz?: string;\n }): number;\n\n abstract compare(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): -1 | 0 | 1;\n\n abstract relative(opts: {\n value: TTemporalInput;\n base?: TTemporalInput;\n unit?: TTemporalUnit;\n numeric?: Intl.RelativeTimeFormatNumeric;\n style?: Intl.RelativeTimeFormatStyle;\n tz?: string;\n locale?: string;\n }): string;\n\n abstract durationParts(opts: { milliseconds: number }): ITemporalDurationParts;\n\n abstract formatDuration(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n /** A clock face instead of words: `HH:mm:ss`, `mm:ss`, `D[d] HH:mm`. The largest token carries the rest. */\n pattern?: string;\n /** Only the largest units that are not zero: `1` writes `2 giờ` for 2 hours 5 minutes. */\n maxUnits?: number;\n locale?: string;\n }): string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/modules/temporal/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,IAAI,mBAAmB,EAC1C,aAAa,GACd,MAAM,oBAAoB,CAAC;AAgB5B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,6DAA6D;AAC7D,MAAM,WAAW,GAAG,CAAC,kBAAkB,CAAC;AACxC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAEjC,oDAAoD;AACpD,MAAM,YAAY,GAA+C;IAC/D,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;IACf,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,CAAC;IAChB,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE,CAAC;CACZ,CAAC;AAEF,MAAM,YAAY,GAAG,qBAAqB,gBAAgB,CAAC,QAAQ,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC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E,MAAM;YACd,IAAI,EAAE,aAAa,CAAC,KAAK;SAC1B,CAAC,CAAC;QAEH,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IACjD,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { BaseHelper } from '@/modules/base';\nimport { getError, isApplicationError } from '@/modules/error';\nimport { IntlTemporalAdapter } from './adapters/intl';\nimport { NativeTemporalAdapter } from './adapters/native';\nimport { TemporalCalendar } from './calendar';\nimport {\n DEFAULT_TEMPORAL_LOCALE,\n DEFAULT_TEMPORAL_TZ as DEFAULT_TEMPORAL_TZ,\n TemporalUnits,\n} from './common/constants';\nimport type {\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './common/constants';\nimport type {\n ITemporalAdapter,\n ITemporalDurationParts,\n ITemporalLocaleNames,\n ITemporalParts,\n TTemporalFields,\n IZonedTemporalParts,\n TTemporalInput,\n ITemporalHelper,\n} from './common/types';\nimport { TemporalLocale } from './locale';\n\nconst DAY_MILLISECONDS = 86_400_000;\n\n/** 0001-01-01T00:00:00.000Z and 9999-12-31T23:59:59.999Z. */\nconst MIN_INSTANT = -62_135_596_800_000;\nconst MAX_INSTANT = 253_402_300_799_999;\n\nconst MAX_KNOWN_TIME_ZONES = 256;\n\n/** How many entries each `names` list must hold. */\nconst NAME_LENGTHS: Record<keyof ITemporalLocaleNames, number> = {\n months: 12,\n monthsShort: 12,\n weekdays: 7,\n weekdaysShort: 7,\n weekdaysMin: 7,\n meridiem: 2,\n};\n\nconst OUT_OF_RANGE = `outside the years ${TemporalCalendar.MIN_YEAR}-${TemporalCalendar.MAX_YEAR}`;\n\n/**\n * The machinery every temporal helper shares: the adapter, the zone and locale it holds, reading a\n * zone's offset, turning wall clocks into instants across daylight-saving gaps and repeats, and the\n * input checks. A helper extends this and supplies the operations in `ITemporalHelper`.\n */\nexport abstract class AbstractTemporalHelper extends BaseHelper implements ITemporalHelper {\n /** Validated once per process: `Intl` answers the same for a zone name every time. */\n protected static readonly knownTzs = new Set<string>();\n\n protected readonly adapter: ITemporalAdapter;\n protected readonly tz: string;\n protected readonly locale: string;\n protected readonly names: Record<string, ITemporalLocaleNames>;\n protected readonly fallback?: string;\n /** Which `names` entry each locale a call wrote in resolved to - `names` never changes after construction. */\n private readonly namesByLocale = new Map<string, ITemporalLocaleNames | undefined>();\n\n /**\n * `locale` (default `en-US`) spells month and weekday names, AM/PM, relative time and durations,\n * unless a call passes its own. `names` replaces `Intl`'s wording for a locale - month and weekday\n * names, the AM/PM marker - keyed by a locale tag; a call in another tag of the same language (`vi`\n * for a `vi-VN` entry) uses it too. `fallback` is what `format` and `formatIntl` write for a value\n * that is not a date when a call gives none; without it, such a value is a 400.\n */\n constructor(opts?: {\n adapter?: ITemporalAdapter;\n tz?: string;\n locale?: string;\n names?: Record<string, ITemporalLocaleNames>;\n fallback?: string;\n scope?: string;\n }) {\n super({ scope: opts?.scope ?? new.target.name });\n\n this.tz = AbstractTemporalHelper.ensureTz({\n tz: opts?.tz ?? DEFAULT_TEMPORAL_TZ,\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n });\n this.locale = AbstractTemporalHelper.ensureLocale({\n locale: opts?.locale ?? DEFAULT_TEMPORAL_LOCALE,\n });\n this.adapter = opts?.adapter ?? AbstractTemporalHelper.defaultAdapter();\n this.names = AbstractTemporalHelper.ensureNames({ names: opts?.names ?? {} });\n this.fallback = opts?.fallback;\n }\n\n /**\n * The zone a `Date`'s local getters use on this runtime - the browser's or the server's. The one\n * place this helper reads the host zone, and only when a wall-clock bridge is not given one.\n */\n static getHostTz(): string {\n return new Intl.DateTimeFormat().resolvedOptions().timeZone;\n }\n\n /** The instant whose wall clock in `to` reads what `value`'s wall clock reads in `from`. */\n protected moveWallClock(opts: { value: TTemporalInput; from: string; to: string }): Date {\n const from = this.resolveTz({ tz: opts.from });\n const to = this.resolveTz({ tz: opts.to });\n const date = this.toDate({ value: opts.value, tz: from });\n\n const wall = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz: from }),\n });\n\n return AbstractTemporalHelper.ensureInstant({\n epoch: this.earliestOf({ parts: wall, tz: to }),\n });\n }\n\n /** Every list the right length, so a bad table fails when the helper is built, not on a screen. */\n protected static ensureNames(opts: {\n names: Record<string, ITemporalLocaleNames>;\n }): Record<string, ITemporalLocaleNames> {\n for (const [locale, names] of Object.entries(opts.names)) {\n AbstractTemporalHelper.ensureLocale({ locale });\n\n for (const [key, length] of Object.entries(NAME_LENGTHS)) {\n const list: unknown = Reflect.get(names, key);\n\n if (list === undefined) {\n continue;\n }\n\n if (\n !Array.isArray(list) ||\n list.length !== length ||\n !list.every((entry) => typeof entry === 'string')\n ) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalHelper] names['${locale}'].${key} must hold ${length} strings`,\n });\n }\n }\n }\n\n return opts.names;\n }\n\n /** The wording this helper holds for `locale`, if any. */\n protected namesOf(opts: { locale: string }): ITemporalLocaleNames | undefined {\n const { locale } = opts;\n\n if (Object.hasOwn(this.names, locale)) {\n return this.names[locale];\n }\n\n if (this.namesByLocale.has(locale)) {\n return this.namesByLocale.get(locale);\n }\n\n // A malformed tag is the caller's 400, before it reaches `Intl.Locale`.\n AbstractTemporalHelper.ensureLocale({ locale });\n\n // No entry for the exact tag: one for the same language serves - `vi` reads a `vi-VN` entry.\n const language = new Intl.Locale(locale).language;\n const match = Object.keys(this.names).find((key) => new Intl.Locale(key).language === language);\n const names = match === undefined ? undefined : this.names[match];\n this.namesByLocale.set(locale, names);\n\n return names;\n }\n\n /**\n * The value as a date for a writer: with a fallback - the call's, else the helper's - a value that\n * is not a date answers `null`; without one it is a 400, null included.\n */\n protected readDate(opts: {\n value: TTemporalInput | null | undefined;\n tz: string;\n fallback?: string;\n }): Date | null {\n const { value, tz } = opts;\n\n if ((opts.fallback ?? this.fallback) !== undefined) {\n return this.tryToDate({ value, tz });\n }\n\n if (value === null || value === undefined) {\n throw AbstractTemporalHelper.notADate({ value });\n }\n\n return this.toDate({ value, tz });\n }\n\n /** The runtime's `Temporal` where it has one; `Intl`, which every runtime has, everywhere else. */\n protected static defaultAdapter(): ITemporalAdapter {\n return NativeTemporalAdapter.isTemporalNamespace(Reflect.get(globalThis, 'Temporal'))\n ? new NativeTemporalAdapter()\n : new IntlTemporalAdapter();\n }\n\n protected static ensureLocale(opts: { locale: string }): string {\n TemporalLocale.of({ locale: opts.locale });\n\n return opts.locale;\n }\n\n /** A parse or input error the caller may treat as \"not a date\"; anything else is a bug and still throws. */\n protected static isRefusal(error: unknown): boolean {\n return isApplicationError(error) && error.statusCode === HTTP.ResultCodes.RS_4.BadRequest;\n }\n\n protected static ensureTz(opts: { tz: string; statusCode: number }): string {\n const { tz, statusCode } = opts;\n\n if (AbstractTemporalHelper.knownTzs.has(tz)) {\n return tz;\n }\n\n try {\n new Intl.DateTimeFormat('en-US', { timeZone: tz });\n } catch (error) {\n throw getError({\n statusCode,\n message: `[TemporalHelper] unknown time zone '${tz}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n if (AbstractTemporalHelper.knownTzs.size < MAX_KNOWN_TIME_ZONES) {\n AbstractTemporalHelper.knownTzs.add(tz);\n }\n\n return tz;\n }\n\n protected static ensureUnit(opts: { unit: string; amount?: number }): void {\n const { unit, amount } = opts;\n\n if (!TemporalUnits.isValid(unit)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] unknown unit '${unit}' | Supported: ${[...TemporalUnits.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (amount === undefined) {\n return;\n }\n\n // Elapsed time takes a fraction (1.5 hours is 90 minutes); a calendar unit has no half.\n const isElapsed = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit] !== undefined;\n\n if (isElapsed ? !Number.isFinite(amount) : !Number.isInteger(amount)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: isElapsed\n ? `[TemporalHelper] amount must be a finite number - received ${amount}`\n : `[TemporalHelper] amount must be an integer for '${unit}' - received ${amount}`,\n });\n }\n }\n\n /** Every result passes here: an overflowing `add` is refused, never an Invalid Date. */\n protected static ensureInstant(opts: { epoch: number }): Date {\n const { epoch } = opts;\n\n if (!(epoch >= MIN_INSTANT && epoch <= MAX_INSTANT)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] ${Number.isNaN(epoch) ? 'invalid date' : OUT_OF_RANGE} - received ${epoch}`,\n });\n }\n\n return new Date(epoch);\n }\n\n protected static ensureYear(opts: { parts: ITemporalParts }): void {\n if (!TemporalCalendar.isSupportedYear({ year: opts.parts.year })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] year ${opts.parts.year} is ${OUT_OF_RANGE}`,\n });\n }\n }\n\n protected resolveTz(opts: { tz?: string }): string {\n return opts.tz === undefined\n ? this.tz\n : AbstractTemporalHelper.ensureTz({\n tz: opts.tz,\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n });\n }\n\n /** The adapter's one answer, rounded: an offset is whole milliseconds, a library's float may not be. */\n protected offsetAt(opts: { epoch: number; tz: string }): number {\n return Math.round(\n this.adapter.getOffsetMilliseconds({ value: new Date(opts.epoch), tz: opts.tz }),\n );\n }\n\n protected zonedParts(opts: { epoch: number; tz: string }): IZonedTemporalParts {\n const parts = TemporalCalendar.wallClockAt({\n epoch: opts.epoch,\n offsetMilliseconds: this.offsetAt(opts),\n });\n AbstractTemporalHelper.ensureYear({ parts });\n\n return parts;\n }\n\n /**\n * Every instant whose wall clock reads `parts` in the zone, earliest first: one as a rule, two\n * when the clock goes back, none when it jumps forward. `forward` is where a skipped time lands -\n * read with the offset from before the jump, so it moves past the gap.\n */\n protected instantsOf(opts: { parts: ITemporalParts; tz: string }): {\n instants: Array<number>;\n forward: number;\n } {\n const { parts, tz } = opts;\n const local = TemporalCalendar.epochAtOffset({ parts, offsetMilliseconds: 0 });\n const before = this.offsetAt({ epoch: local - DAY_MILLISECONDS, tz });\n const after = this.offsetAt({ epoch: local + DAY_MILLISECONDS, tz });\n\n const offsets = before === after ? [before] : [before, after];\n const instants: Array<number> = [];\n\n for (const offset of offsets) {\n const candidate = local - offset;\n\n if (this.offsetAt({ epoch: candidate, tz }) === offset) {\n instants.push(candidate);\n }\n }\n\n instants.sort((left, right) => left - right);\n\n return { instants, forward: local - before };\n }\n\n /** The instant wall-clock `parts` name: a skipped time moves forward, a repeated one takes the earlier. */\n protected earliestOf(opts: { parts: ITemporalParts; tz: string }): number {\n const { instants, forward } = this.instantsOf(opts);\n\n return instants[0] ?? forward;\n }\n\n /**\n * `[start, end)` of the unit holding `epoch`. A day or longer starts at its first instant. An hour\n * or less repeats when the clock goes back, so it starts at the latest start not after `epoch`,\n * and ends where the wall clock next shows either the following unit or this one's start again.\n */\n protected unitBounds(opts: { epoch: number; unit: TTemporalUnit; tz: string }): {\n start: number;\n end: number;\n } {\n const { epoch, unit, tz } = opts;\n const startParts = TemporalCalendar.truncate({\n parts: this.zonedParts({ epoch, tz }),\n unit,\n });\n const nextParts = TemporalCalendar.shift({ parts: startParts, amount: 1, unit });\n AbstractTemporalHelper.ensureYear({ parts: nextParts });\n\n const starts = this.instantsOf({ parts: startParts, tz });\n\n if (TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit] === undefined) {\n const start = starts.instants[0] ?? starts.forward;\n\n return { start, end: this.earliestOf({ parts: nextParts, tz }) };\n }\n\n const started = starts.instants.filter((instant) => instant <= epoch);\n const start = started.at(-1) ?? starts.instants[0] ?? starts.forward;\n\n const nexts = this.instantsOf({ parts: nextParts, tz });\n const following = nexts.instants.find((instant) => instant > start) ?? nexts.forward;\n const repeated = starts.instants.find((instant) => instant > start);\n\n return { start, end: repeated === undefined ? following : Math.min(repeated, following) };\n }\n\n getTz(): string {\n return this.tz;\n }\n\n getLocale(): string {\n return this.locale;\n }\n\n now(): Date {\n return new Date();\n }\n\n /** The instant a value names. An ISO string without an offset is read as wall clock in the zone. */\n toDate(opts: { value: TTemporalInput; tz?: string }): Date {\n const { value } = opts;\n\n if (typeof value === 'string') {\n return this.parse({ value, tz: opts.tz });\n }\n\n if (value instanceof Date) {\n return AbstractTemporalHelper.ensureInstant({ epoch: value.getTime() });\n }\n\n if (typeof value === 'number') {\n return AbstractTemporalHelper.ensureInstant({ epoch: value });\n }\n\n // `null` above all: read as a number it would be 1970, a date nobody meant.\n throw AbstractTemporalHelper.notADate({ value });\n }\n\n protected static notADate(opts: { value: unknown }) {\n const { value } = opts;\n\n return getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] not a date - received ${value === null ? 'null' : typeof value}`,\n });\n }\n\n /** `toDate`, answering `null` where `toDate` refuses the value: null, undefined, bad text, NaN. */\n tryToDate(opts: { value: TTemporalInput | null | undefined; tz?: string }): Date | null {\n const { value } = opts;\n // Outside the try: a bad zone is the caller's bug, not an unreadable value.\n const tz = this.resolveTz({ tz: opts.tz });\n\n if (value === null || value === undefined) {\n return null;\n }\n\n try {\n return this.toDate({ value, tz });\n } catch (error) {\n if (AbstractTemporalHelper.isRefusal(error)) {\n return null;\n }\n\n throw error;\n }\n }\n\n /** The wall clock the value shows in the zone, with its ISO weekday and UTC offset. */\n parts(opts: { value: TTemporalInput; tz?: string }): IZonedTemporalParts {\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n\n return this.zonedParts({ epoch: date.getTime(), tz });\n }\n\n /**\n * Fractional months from `other` to `value` (dayjs and moment's month difference): anchored on the\n * date with the later day of the month, whole months by `add`, the rest as a share of the month\n * it falls in.\n */\n protected monthGap(opts: { value: number; other: number; tz: string }): number {\n const { value, other, tz } = opts;\n const valueParts = this.zonedParts({ epoch: value, tz });\n const otherParts = this.zonedParts({ epoch: other, tz });\n\n if (valueParts.day < otherParts.day) {\n return -this.monthGap({ value: other, other: value, tz });\n }\n\n const whole = (otherParts.year - valueParts.year) * 12 + (otherParts.month - valueParts.month);\n const anchor = this.shiftMonthsFrom({ parts: valueParts, months: whole, tz });\n const isBelow = other - anchor < 0;\n const nextAnchor = this.shiftMonthsFrom({\n parts: valueParts,\n months: whole + (isBelow ? -1 : 1),\n tz,\n });\n const span = isBelow ? anchor - nextAnchor : nextAnchor - anchor;\n\n return -(whole + (other - anchor) / span) || 0;\n }\n\n /** `add` by months without the 1-9999 check: an anchor one month past the range is still a number. */\n protected shiftMonthsFrom(opts: {\n parts: IZonedTemporalParts;\n months: number;\n tz: string;\n }): number {\n const { parts, months, tz } = opts;\n const shifted = TemporalCalendar.shift({\n parts: TemporalCalendar.wallClockOf({ parts }),\n amount: months,\n unit: TemporalUnits.MONTH,\n });\n\n return this.earliestOf({ parts: shifted, tz });\n }\n\n abstract fromWallClock(opts: { value: TTemporalInput; sourceTz?: string; tz?: string }): Date;\n\n abstract toWallClock(opts: { value: TTemporalInput; targetTz?: string; tz?: string }): Date;\n\n abstract clone(opts: { locale?: string; tz?: string }): ITemporalHelper;\n\n abstract parse(opts: { value: string; pattern?: string; tz?: string }): Date;\n\n abstract tryParse(opts: { value: string; pattern?: string; tz?: string }): Date | null;\n\n abstract isValid(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n }): boolean;\n\n abstract format(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n abstract formatIntl(opts: {\n value: TTemporalInput;\n options?: Omit<Intl.DateTimeFormatOptions, 'timeZone'>;\n tz?: string;\n locale?: string;\n }): string;\n\n abstract add(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date;\n\n abstract subtract(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date;\n\n abstract startOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n abstract endOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n abstract isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean;\n\n abstract nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n abstract previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n abstract set(opts: { value: TTemporalInput; tz?: string } & TTemporalFields): Date;\n\n abstract isBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSame(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n abstract isBetween(opts: {\n value: TTemporalInput;\n from: TTemporalInput;\n to: TTemporalInput;\n unit?: TTemporalUnit;\n inclusivity?: TTemporalInclusivity;\n tz?: string;\n }): boolean;\n\n abstract diff(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit: TTemporalUnit;\n tz?: string;\n }): number;\n\n abstract compare(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): -1 | 0 | 1;\n\n abstract relative(opts: {\n value: TTemporalInput;\n base?: TTemporalInput;\n unit?: TTemporalUnit;\n numeric?: Intl.RelativeTimeFormatNumeric;\n style?: Intl.RelativeTimeFormatStyle;\n tz?: string;\n locale?: string;\n }): string;\n\n abstract durationParts(opts: { milliseconds: number }): ITemporalDurationParts;\n\n abstract formatDuration(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n /** A clock face instead of words: `HH:mm:ss`, `mm:ss`, `D[d] HH:mm`. The largest token carries the rest. */\n pattern?: string;\n /** Only the largest units that are not zero: `1` writes `2 giờ` for 2 hours 5 minutes. */\n maxUnits?: number;\n locale?: string;\n }): string;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/dayjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,kFAAkF;AAClF,MAAM,4BAA4B,GAAG,OAAO,GAAG,UAAU,CAAC;AAE1D,+GAA+G;AAC/G,MAAM,gBAAgB,GAAG,CAAC,kBAAkB,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,OAAO,oBAAoB;IAG/B,YAAY,IAA8B;QACxC,IAAI,OAAO,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,UAAU,EAAE,CAAC;YACzC,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EACL,sIAAsI;aACzI,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;IAC1B,CAAC;IAED,qBAAqB,CAAC,IAAiC;QACrD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAE3B,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"dayjs.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/dayjs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AA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":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport type { IDayjsFactory, ITemporalAdapter } from '../common/types';\n\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** The Gregorian calendar repeats every 400 years, to the day and the weekday. */\nconst GREGORIAN_CYCLE_MILLISECONDS = 146_097 * 86_400_000;\n\n/** 1000-01-01T00:00:00Z. dayjs reads a year below 100 as 19xx; no zone changed its offset before the 1800s. */\nconst FIRST_SAFE_EPOCH = -30_610_224_000_000;\n\n/**\n * Time zones through your own `dayjs`, passed in rather than imported: this package never loads\n * dayjs, and you keep whatever plugins, locale and default zone you configured.\n *\n * Only `utcOffset()` is read, which stays right whatever the host zone; dayjs's own `format()`\n * near the host's daylight-saving change does not, and is never used here. dayjs does misread a\n * local mean time offset under one hour (London before 1848 reads `-01:15`, not `-00:01:15`);\n * for such dates use `NativeTemporalAdapter` or `LuxonTemporalAdapter`.\n */\nexport class DayjsTemporalAdapter implements ITemporalAdapter {\n private readonly dayjs: IDayjsFactory;\n\n constructor(opts: { dayjs: IDayjsFactory }) {\n if (typeof opts.dayjs?.tz !== 'function') {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message:\n '[DayjsTemporalAdapter] dayjs has no `tz` | Extend the utc and timezone plugins first: dayjs.extend(utc), then dayjs.extend(timezone)',\n });\n }\n\n this.dayjs = opts.dayjs;\n }\n\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number {\n const { value, tz } = opts;\n\n let epoch = value.getTime();\n\n while (epoch < FIRST_SAFE_EPOCH) {\n epoch += GREGORIAN_CYCLE_MILLISECONDS;\n }\n\n try {\n return this.dayjs(epoch).tz(tz).utcOffset() * MILLISECONDS_PER_MINUTE;\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[DayjsTemporalAdapter] no offset for ${tz} at ${value.getTime()} | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intl.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,+FAA+F;AAC/F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;aACN,eAAU,GAAG,IAAI,GAAG,EAGzC,CAAC;IAEJ,gIAAgI;IACxH,MAAM,CAAC,WAAW,CAAC,IAAoB;QAI7C,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QACpB,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"intl.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/intl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,+FAA+F;AAC/F,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,mBAAmB,GAAG,IAAI,CAAC;AAEjC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;aACN,eAAU,GAAG,IAAI,GAAG,EAGzC,CAAC;IAEJ,gIAAgI;IACxH,MAAM,CAAC,WAAW,CAAC,IAAoB;QAI7C,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QACpB,MAAM,MAAM,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAEtD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,SAA8B,CAAC;QAEnC,IAAI,CAAC;YACH,SA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AI,IAAI,CAAC,CAAC,CAAC,CAAC;QAC9B,SAAS,CAAC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;QAC7D,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAE7D,0FAA0F;QAC1F,MAAM,WAAW,GACf,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,mBAAmB,CAAC,GAAG,mBAAmB,CAAC,GAAG,mBAAmB,CAAC,CAAC;QAExF,OAAO,SAAS,CAAC,OAAO,EAAE,GAAG,WAAW,CAAC;IAC3C,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport type { ITemporalAdapter } from '../common/types';\n\n/** One formatter per zone: building an `Intl.DateTimeFormat` costs far more than using one. */\nconst MAX_CACHED_FORMATTERS = 256;\n\nconst SECOND_MILLISECONDS = 1000;\n\n/**\n * Time zones through `Intl.DateTimeFormat` alone - no `Temporal`, no polyfill, no date library - so\n * it runs in every browser and every server runtime. The offset is the zone's wall clock at the\n * instant, read field by field, minus the instant itself.\n */\nexport class IntlTemporalAdapter implements ITemporalAdapter {\n private static readonly formatters = new Map<\n string,\n { formatter: Intl.DateTimeFormat; commonEra: string | undefined }\n >();\n\n /** The zone's formatter, and how it spells the common era - so any other era is before year 1, whatever the engine calls it. */\n private static formatterOf(opts: { tz: string }): {\n formatter: Intl.DateTimeFormat;\n commonEra: string | undefined;\n } {\n const { tz } = opts;\n const cached = IntlTemporalAdapter.formatters.get(tz);\n\n if (cached) {\n return cached;\n }\n\n let formatter: Intl.DateTimeFormat;\n\n try {\n formatter = new Intl.DateTimeFormat('en-US', {\n timeZone: tz,\n hourCycle: 'h23',\n era: 'short',\n year: 'numeric',\n month: 'numeric',\n day: 'numeric',\n hour: 'numeric',\n minute: 'numeric',\n second: 'numeric',\n });\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[IntlTemporalAdapter] unknown time zone '${tz}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n const commonEra = formatter\n .formatToParts(new Date(0))\n .find((part) => part.type === 'era')?.value;\n\n // Full: the oldest zone makes room, so zone 257 is not rebuilt on every call.\n if (IntlTemporalAdapter.formatters.size >= MAX_CACHED_FORMATTERS) {\n const oldest = IntlTemporalAdapter.formatters.keys().next().value;\n\n if (oldest !== undefined) {\n IntlTemporalAdapter.formatters.delete(oldest);\n }\n }\n\n const entry = { formatter, commonEra };\n IntlTemporalAdapter.formatters.set(tz, entry);\n\n return entry;\n }\n\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number {\n const { value, tz } = opts;\n const epoch = value.getTime();\n\n const fields = { year: 0, month: 1, day: 1, hour: 0, minute: 0, second: 0 };\n let isBeforeCommonEra = false;\n const { formatter, commonEra } = IntlTemporalAdapter.formatterOf({ tz });\n\n for (const part of formatter.formatToParts(value)) {\n if (part.type === 'era') {\n isBeforeCommonEra = commonEra !== undefined && part.value !== commonEra;\n continue;\n }\n\n if (part.type in fields) {\n Reflect.set(fields, part.type, Number(part.value));\n }\n }\n\n // Before year 1 the formatter counts eras: 1 BC is year 0 on the proleptic calendar.\n const year = isBeforeCommonEra ? 1 - fields.year : fields.year;\n // Some engines still write midnight as hour 24 under h23.\n const hour = fields.hour === 24 ? 0 : fields.hour;\n\n const wallClock = new Date(0);\n wallClock.setUTCFullYear(year, fields.month - 1, fields.day);\n wallClock.setUTCHours(hour, fields.minute, fields.second, 0);\n\n // The formatter writes whole seconds: compare against the instant truncated the same way.\n const wholeSecond =\n epoch - (((epoch % SECOND_MILLISECONDS) + SECOND_MILLISECONDS) % SECOND_MILLISECONDS);\n\n return wallClock.getTime() - wholeSecond;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"luxon.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/luxon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,oFAAoF;AACpF,MAAM,OAAO,oBAAoB;IAG/B,YAAY,IAAyC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,qBAAqB,CAAC,IAAiC;QACrD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAEtE,iFAAiF;QACjF,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;gBAC5C,OAAO,EAAE,wCAAwC,EAAE,OAAO,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,CAAC,aAAa,IAAI,SAAS,EAAE;aAClH,CAAC,CAAC;QACL,CAAC;
|
|
1
|
+
{"version":3,"file":"luxon.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/luxon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAEvC,oFAAoF;AACpF,MAAM,OAAO,oBAAoB;IAG/B,YAAY,IAAyC;QACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAChC,CAAC;IAED,qBAAqB,CAAC,IAAiC;QACrD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QAEtE,iFAAiF;QACjF,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACnB,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;gBAC5C,OAAO,EAAE,wCAAwC,EAAE,OAAO,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,CAAC,aAAa,IAAI,SAAS,EAAE;aAClH,CAAC,CAAC;QACL,CAAC;QAED,OAAO,KAAK,CAAC,MAAM,GAAG,uBAAuB,CAAC;IAChD,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport type { ILuxonDateTimeFactory, ITemporalAdapter } from '../common/types';\n\nconst MILLISECONDS_PER_MINUTE = 60_000;\n\n/** Time zones through your own Luxon `DateTime`, passed in rather than imported. */\nexport class LuxonTemporalAdapter implements ITemporalAdapter {\n private readonly dateTime: ILuxonDateTimeFactory;\n\n constructor(opts: { DateTime: ILuxonDateTimeFactory }) {\n this.dateTime = opts.DateTime;\n }\n\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number {\n const { value, tz } = opts;\n const zoned = this.dateTime.fromMillis(value.getTime(), { zone: tz });\n\n // Luxon answers an unusable zone with an invalid `DateTime` rather than a throw.\n if (!zoned.isValid) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[LuxonTemporalAdapter] no offset for ${tz} at ${value.getTime()} | ${zoned.invalidReason ?? 'invalid'}`,\n });\n }\n\n return zoned.offset * MILLISECONDS_PER_MINUTE;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAGhC,4GAA4G;IAC5G,MAAM,CAAC,mBAAmB,CAAC,KAAc;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/adapters/native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG3C,MAAM,2BAA2B,GAAG,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IAGhC,4GAA4G;IAC5G,MAAM,CAAC,mBAAmB,CAAC,KAAc;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,KAAK,CAAC,EAAE,CAAC;YACzE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAE9B,OAAO,CACL,CAAC,OAAO,OAAO,KAAK,UAAU,IAAI,CAAC,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,CAAC,CAAC;YACpF,OAAO,OAAO,CAAC,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAC,KAAK,UAAU,CACpE,CAAC;IACJ,CAAC;IAED,YAAY,IAAwC;QAClD,MAAM,QAAQ,GAAY,IAAI,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAEhF,IAAI,CAAC,qBAAqB,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC;YACzD,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EACL,uJAAuJ;aAC1J,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,qBAAqB,CAAC,IAAiC;QACrD,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,IAAI,CAAC;QAE3B,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,qBAAqB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,kBAAkB,CAC3F,EAAE,CACH,CAAC;YAEF,OAAO,KAAK,CAAC,iBAAiB,GAAG,2BAA2B,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU;gBAC5C,OAAO,EAAE,yCAAyC,EAAE,OAAO,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACzI,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport type { ITemporalAdapter, ITemporalNamespace } from '../common/types';\n\nconst NANOSECONDS_PER_MILLISECOND = 1_000_000;\n\n/**\n * Time zones through the TC39 `Temporal` API: the runtime's global (Bun has it, as do current\n * browsers), or a polyfill's namespace passed as `temporal`.\n */\nexport class NativeTemporalAdapter implements ITemporalAdapter {\n private readonly temporal: ITemporalNamespace;\n\n /** A `Temporal` namespace - the runtime's global or a polyfill's - by the one member the adapter drives. */\n static isTemporalNamespace(value: unknown): value is ITemporalNamespace {\n if (typeof value !== 'object' || value === null || !('Instant' in value)) {\n return false;\n }\n\n const instant = value.Instant;\n\n return (\n (typeof instant === 'function' || (typeof instant === 'object' && instant !== null)) &&\n typeof Reflect.get(instant, 'fromEpochMilliseconds') === 'function'\n );\n }\n\n constructor(opts?: { temporal?: ITemporalNamespace }) {\n const temporal: unknown = opts?.temporal ?? Reflect.get(globalThis, 'Temporal');\n\n if (!NativeTemporalAdapter.isTemporalNamespace(temporal)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message:\n '[NativeTemporalAdapter] Temporal is not available on this runtime | Pass a polyfill as `temporal`, or use DayjsTemporalAdapter / LuxonTemporalAdapter',\n });\n }\n\n this.temporal = temporal;\n }\n\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number {\n const { value, tz } = opts;\n\n try {\n const zoned = this.temporal.Instant.fromEpochMilliseconds(value.getTime()).toZonedDateTimeISO(\n tz,\n );\n\n return zoned.offsetNanoseconds / NANOSECONDS_PER_MILLISECOND;\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[NativeTemporalAdapter] no offset for ${tz} at ${value.getTime()} | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;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C,IAAI,GAAG,eAAe,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,aAAa,CAAC;QACxF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,eAAe,CAAC,CAAC;QACjD,MAAM,KAAK,GAAG,KAAK,GAAG,IAAI,GAAG,eAAe,GAAG,CAAC,CAAC;QAEjD,OAAO;YACL,GAAG,KAAK;YACR,IAAI;YACJ,KAAK;YACL,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,gBAAgB,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;SACxE,CAAC;IACJ,CAAC","sourcesContent":["import { TemporalUnits } from '../common/constants';\nimport type { TTemporalUnit } from '../common/constants';\nimport type { ITemporalParts, IZonedTemporalParts } from '../common/types';\n\nconst MILLISECONDS_PER_MINUTE = 60_000;\nconst MONTHS_PER_YEAR = 12;\nconst DAYS_PER_WEEK = 7;\n\n/**\n * Calendar arithmetic on wall-clock fields, at a fixed offset or none at all - never a time zone,\n * never the host's. `TemporalHelper` brings the zone.\n */\nexport class TemporalCalendar {\n /** The years a four-digit `YYYY` spells - the range every method reads and writes. */\n static readonly MIN_YEAR = 1;\n static readonly MAX_YEAR = 9999;\n\n /** Units that measure elapsed time rather than the calendar - 24 hours is not always a day. */\n static readonly EXACT_UNIT_MILLISECONDS: Partial<Record<TTemporalUnit, number>> = {\n [TemporalUnits.MILLISECOND]: 1,\n [TemporalUnits.SECOND]: 1_000,\n [TemporalUnits.MINUTE]: 60_000,\n [TemporalUnits.HOUR]: 3_600_000,\n };\n\n /** A UTC scratch date - `Date.UTC` maps years 0-99 onto 1900-1999, `setUTCFullYear` does not. */\n private static scratch(opts: { year: number; month: number; day: number }): Date {\n const date = new Date(0);\n date.setUTCFullYear(opts.year, opts.month - 1, opts.day);\n return date;\n }\n\n static isSupportedYear(opts: { year: number }): boolean {\n return opts.year >= TemporalCalendar.MIN_YEAR && opts.year <= TemporalCalendar.MAX_YEAR;\n }\n\n static daysInMonth(opts: { year: number; month: number }): number {\n return TemporalCalendar.scratch({\n year: opts.year,\n month: opts.month + 1,\n day: 0,\n }).getUTCDate();\n }\n\n /** Whether the fields name a day and a time the calendar has - Feb 30, 24:00 and year 0 do not. */\n static isRealDateTime(opts: { parts: ITemporalParts }): boolean {\n const { year, month, day, hour, minute, second, millisecond } = opts.parts;\n\n return (\n TemporalCalendar.isSupportedYear({ year }) &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= TemporalCalendar.daysInMonth({ year, month }) &&\n hour >= 0 &&\n hour <= 23 &&\n minute >= 0 &&\n minute <= 59 &&\n second >= 0 &&\n second <= 59 &&\n millisecond >= 0 &&\n millisecond <= 999\n );\n }\n\n /** Epoch milliseconds of wall-clock fields read at a fixed offset. */\n static epochAtOffset(opts: { parts: ITemporalParts; offsetMilliseconds: number }): number {\n const { parts, offsetMilliseconds } = opts;\n const date = TemporalCalendar.scratch({\n year: parts.year,\n month: parts.month,\n day: parts.day,\n });\n date.setUTCHours(parts.hour, parts.minute, parts.second, parts.millisecond);\n return date.getTime() - offsetMilliseconds;\n }\n\n /** The wall clock an instant shows at a fixed offset - pure arithmetic, never the host's zone. */\n static wallClockAt(opts: { epoch: number; offsetMilliseconds: number }): IZonedTemporalParts {\n const { epoch, offsetMilliseconds } = opts;\n const date = new Date(epoch + offsetMilliseconds);\n\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n hour: date.getUTCHours(),\n minute: date.getUTCMinutes(),\n second: date.getUTCSeconds(),\n millisecond: date.getUTCMilliseconds(),\n // `getUTCDay` counts Sunday as 0; ISO counts Monday as 1 and Sunday as 7.\n dayOfWeek: ((date.getUTCDay() + 6) % 7) + 1,\n offsetMinutes: offsetMilliseconds / MILLISECONDS_PER_MINUTE,\n };\n }\n\n /** The wall-clock fields alone, without the weekday and the offset. */\n static wallClockOf(opts: { parts: ITemporalParts }): ITemporalParts {\n const { year, month, day, hour, minute, second, millisecond } = opts.parts;\n return { year, month, day, hour, minute, second, millisecond };\n }\n\n /** The wall-clock start of the unit holding `parts`. Weeks start on Monday; quarters in Jan, Apr, Jul, Oct. */\n static truncate(opts: { parts: IZonedTemporalParts; unit: TTemporalUnit }): ITemporalParts {\n const { parts, unit } = opts;\n const wall = TemporalCalendar.wallClockOf({ parts });\n const midnight = { ...wall, hour: 0, minute: 0, second: 0, millisecond: 0 };\n\n switch (unit) {\n case TemporalUnits.SECOND: {\n return { ...wall, millisecond: 0 };\n }\n case TemporalUnits.MINUTE: {\n return { ...wall, second: 0, millisecond: 0 };\n }\n case TemporalUnits.HOUR: {\n return { ...wall, minute: 0, second: 0, millisecond: 0 };\n }\n case TemporalUnits.DAY: {\n return midnight;\n }\n case TemporalUnits.WEEK: {\n return TemporalCalendar.shift({\n parts: midnight,\n amount: 1 - parts.dayOfWeek,\n unit: TemporalUnits.DAY,\n });\n }\n case TemporalUnits.MONTH: {\n return { ...midnight, day: 1 };\n }\n case TemporalUnits.QUARTER: {\n return { ...midnight, month: Math.floor((wall.month - 1) / 3) * 3 + 1, day: 1 };\n }\n default: {\n return { ...midnight, month: 1, day: 1 };\n }\n }\n }\n\n /**\n * `parts` moved by whole units on the wall clock - no time zone involved. Hours and smaller move\n * elapsed time; days and weeks move the calendar date, wall time untouched; months, quarters and\n * years move the month, the day clamped to the target month: Jan 31 + 1 month is Feb 28.\n */\n static shift(opts: {\n parts: ITemporalParts;\n amount: number;\n unit: TTemporalUnit;\n }): ITemporalParts {\n const { parts, amount, unit } = opts;\n\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n if (exact !== undefined) {\n const epoch =\n TemporalCalendar.epochAtOffset({ parts, offsetMilliseconds: 0 }) + amount * exact;\n return TemporalCalendar.wallClockOf({\n parts: TemporalCalendar.wallClockAt({ epoch, offsetMilliseconds: 0 }),\n });\n }\n\n if (unit === TemporalUnits.DAY || unit === TemporalUnits.WEEK) {\n const days = unit === TemporalUnits.WEEK ? amount * DAYS_PER_WEEK : amount;\n const date = TemporalCalendar.scratch({\n year: parts.year,\n month: parts.month,\n day: parts.day + days,\n });\n return {\n ...parts,\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n };\n }\n\n const monthsPerUnit =\n unit === TemporalUnits.QUARTER ? 3 : unit === TemporalUnits.YEAR ? MONTHS_PER_YEAR : 1;\n const total = parts.year * MONTHS_PER_YEAR + (parts.month - 1) + amount * monthsPerUnit;\n const year = Math.floor(total / MONTHS_PER_YEAR);\n const month = total - year * MONTHS_PER_YEAR + 1;\n\n return {\n ...parts,\n year,\n month,\n day: Math.min(parts.day, TemporalCalendar.daysInMonth({ year, month })),\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"calendar.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/calendar/calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAC3B,sFAAsF;aACtE,aAAQ,GAAG,CAAC,CAAC;aACb,aAAQ,GAAG,IAAI,CAAC;IAEhC,+FAA+F;aAC/E,4BAAuB,GAA2C;QAChF,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9B,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK;QAC7B,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM;QAC9B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,SAAS;KAChC,CAAC;IAEF,iGAAiG;IACzF,MAAM,CAAC,OAAO,CAAC,IAAkD;QACvE,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAA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J,CAAC","sourcesContent":["import { TemporalUnits } from '../common/constants';\nimport type { TTemporalUnit } from '../common/constants';\nimport type { ITemporalParts, IZonedTemporalParts } from '../common/types';\n\nconst MILLISECONDS_PER_MINUTE = 60_000;\nconst MONTHS_PER_YEAR = 12;\nconst DAYS_PER_WEEK = 7;\n\n/**\n * Calendar arithmetic on wall-clock fields, at a fixed offset or none at all - never a time zone,\n * never the host's. `TemporalHelper` brings the zone.\n */\nexport class TemporalCalendar {\n /** The years a four-digit `YYYY` spells - the range every method reads and writes. */\n static readonly MIN_YEAR = 1;\n static readonly MAX_YEAR = 9999;\n\n /** Units that measure elapsed time rather than the calendar - 24 hours is not always a day. */\n static readonly EXACT_UNIT_MILLISECONDS: Partial<Record<TTemporalUnit, number>> = {\n [TemporalUnits.MILLISECOND]: 1,\n [TemporalUnits.SECOND]: 1_000,\n [TemporalUnits.MINUTE]: 60_000,\n [TemporalUnits.HOUR]: 3_600_000,\n };\n\n /** A UTC scratch date - `Date.UTC` maps years 0-99 onto 1900-1999, `setUTCFullYear` does not. */\n private static scratch(opts: { year: number; month: number; day: number }): Date {\n const date = new Date(0);\n date.setUTCFullYear(opts.year, opts.month - 1, opts.day);\n\n return date;\n }\n\n static isSupportedYear(opts: { year: number }): boolean {\n return opts.year >= TemporalCalendar.MIN_YEAR && opts.year <= TemporalCalendar.MAX_YEAR;\n }\n\n static daysInMonth(opts: { year: number; month: number }): number {\n return TemporalCalendar.scratch({\n year: opts.year,\n month: opts.month + 1,\n day: 0,\n }).getUTCDate();\n }\n\n /** Whether the fields name a day and a time the calendar has - Feb 30, 24:00 and year 0 do not. */\n static isRealDateTime(opts: { parts: ITemporalParts }): boolean {\n const { year, month, day, hour, minute, second, millisecond } = opts.parts;\n\n return (\n TemporalCalendar.isSupportedYear({ year }) &&\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= TemporalCalendar.daysInMonth({ year, month }) &&\n hour >= 0 &&\n hour <= 23 &&\n minute >= 0 &&\n minute <= 59 &&\n second >= 0 &&\n second <= 59 &&\n millisecond >= 0 &&\n millisecond <= 999\n );\n }\n\n /** Epoch milliseconds of wall-clock fields read at a fixed offset. */\n static epochAtOffset(opts: { parts: ITemporalParts; offsetMilliseconds: number }): number {\n const { parts, offsetMilliseconds } = opts;\n const date = TemporalCalendar.scratch({\n year: parts.year,\n month: parts.month,\n day: parts.day,\n });\n date.setUTCHours(parts.hour, parts.minute, parts.second, parts.millisecond);\n\n return date.getTime() - offsetMilliseconds;\n }\n\n /** The wall clock an instant shows at a fixed offset - pure arithmetic, never the host's zone. */\n static wallClockAt(opts: { epoch: number; offsetMilliseconds: number }): IZonedTemporalParts {\n const { epoch, offsetMilliseconds } = opts;\n const date = new Date(epoch + offsetMilliseconds);\n\n return {\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n hour: date.getUTCHours(),\n minute: date.getUTCMinutes(),\n second: date.getUTCSeconds(),\n millisecond: date.getUTCMilliseconds(),\n // `getUTCDay` counts Sunday as 0; ISO counts Monday as 1 and Sunday as 7.\n dayOfWeek: ((date.getUTCDay() + 6) % 7) + 1,\n offsetMinutes: offsetMilliseconds / MILLISECONDS_PER_MINUTE,\n };\n }\n\n /** The wall-clock fields alone, without the weekday and the offset. */\n static wallClockOf(opts: { parts: ITemporalParts }): ITemporalParts {\n const { year, month, day, hour, minute, second, millisecond } = opts.parts;\n\n return { year, month, day, hour, minute, second, millisecond };\n }\n\n /** The wall-clock start of the unit holding `parts`. Weeks start on Monday; quarters in Jan, Apr, Jul, Oct. */\n static truncate(opts: { parts: IZonedTemporalParts; unit: TTemporalUnit }): ITemporalParts {\n const { parts, unit } = opts;\n const wall = TemporalCalendar.wallClockOf({ parts });\n const midnight = { ...wall, hour: 0, minute: 0, second: 0, millisecond: 0 };\n\n switch (unit) {\n case TemporalUnits.SECOND: {\n return { ...wall, millisecond: 0 };\n }\n case TemporalUnits.MINUTE: {\n return { ...wall, second: 0, millisecond: 0 };\n }\n case TemporalUnits.HOUR: {\n return { ...wall, minute: 0, second: 0, millisecond: 0 };\n }\n case TemporalUnits.DAY: {\n return midnight;\n }\n case TemporalUnits.WEEK: {\n return TemporalCalendar.shift({\n parts: midnight,\n amount: 1 - parts.dayOfWeek,\n unit: TemporalUnits.DAY,\n });\n }\n case TemporalUnits.MONTH: {\n return { ...midnight, day: 1 };\n }\n case TemporalUnits.QUARTER: {\n return { ...midnight, month: Math.floor((wall.month - 1) / 3) * 3 + 1, day: 1 };\n }\n default: {\n return { ...midnight, month: 1, day: 1 };\n }\n }\n }\n\n /**\n * `parts` moved by whole units on the wall clock - no time zone involved. Hours and smaller move\n * elapsed time; days and weeks move the calendar date, wall time untouched; months, quarters and\n * years move the month, the day clamped to the target month: Jan 31 + 1 month is Feb 28.\n */\n static shift(opts: {\n parts: ITemporalParts;\n amount: number;\n unit: TTemporalUnit;\n }): ITemporalParts {\n const { parts, amount, unit } = opts;\n\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n\n if (exact !== undefined) {\n const epoch =\n TemporalCalendar.epochAtOffset({ parts, offsetMilliseconds: 0 }) + amount * exact;\n\n return TemporalCalendar.wallClockOf({\n parts: TemporalCalendar.wallClockAt({ epoch, offsetMilliseconds: 0 }),\n });\n }\n\n if (unit === TemporalUnits.DAY || unit === TemporalUnits.WEEK) {\n const days = unit === TemporalUnits.WEEK ? amount * DAYS_PER_WEEK : amount;\n const date = TemporalCalendar.scratch({\n year: parts.year,\n month: parts.month,\n day: parts.day + days,\n });\n\n return {\n ...parts,\n year: date.getUTCFullYear(),\n month: date.getUTCMonth() + 1,\n day: date.getUTCDate(),\n };\n }\n\n const monthsPerUnit =\n unit === TemporalUnits.QUARTER ? 3 : unit === TemporalUnits.YEAR ? MONTHS_PER_YEAR : 1;\n const total = parts.year * MONTHS_PER_YEAR + (parts.month - 1) + amount * monthsPerUnit;\n const year = Math.floor(total / MONTHS_PER_YEAR);\n const month = total - year * MONTHS_PER_YEAR + 1;\n\n return {\n ...parts,\n year,\n month,\n day: Math.min(parts.day, TemporalCalendar.daysInMonth({ year, month })),\n };\n }\n}\n"]}
|
|
@@ -13,6 +13,7 @@ export declare class TemporalUnits {
|
|
|
13
13
|
static readonly SCHEME_SET: Set<string>;
|
|
14
14
|
static isValid(input: string): input is TTemporalUnit;
|
|
15
15
|
}
|
|
16
|
+
/** A value of {@link TemporalUnits}. */
|
|
16
17
|
export type TTemporalUnit = TConstValue<typeof TemporalUnits>;
|
|
17
18
|
/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */
|
|
18
19
|
export declare const DEFAULT_TEMPORAL_TZ = "UTC";
|
|
@@ -29,6 +30,7 @@ export declare class TemporalDurationStyles {
|
|
|
29
30
|
static readonly SCHEME_SET: Set<string>;
|
|
30
31
|
static isValid(input: string): input is TTemporalDurationStyle;
|
|
31
32
|
}
|
|
33
|
+
/** A value of {@link TemporalDurationStyles}. */
|
|
32
34
|
export type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;
|
|
33
35
|
/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */
|
|
34
36
|
export declare class TemporalInclusivities {
|
|
@@ -39,6 +41,7 @@ export declare class TemporalInclusivities {
|
|
|
39
41
|
static readonly SCHEME_SET: Set<string>;
|
|
40
42
|
static isValid(input: string): input is TTemporalInclusivity;
|
|
41
43
|
}
|
|
44
|
+
/** A value of {@link TemporalInclusivities}. */
|
|
42
45
|
export type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;
|
|
43
46
|
/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */
|
|
44
47
|
export declare class TemporalNameWidths {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,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,YAAO,GAAG,SAAS,CAAC;aACpB,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,OAAO;QACZ,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;;
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/constants.ts"],"names":[],"mappings":"AAEA,kLAAkL;AAClL,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,YAAO,GAAG,SAAS,CAAC;aACpB,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,OAAO;QACZ,IAA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AAM,OAAO,kBAAkB;aACb,WAAM,GAAG,QAAQ,CAAC;aAClB,UAAK,GAAG,OAAO,CAAC;aAChB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnF,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AASH,4FAA4F;AAC5F,MAAM,OAAO,yBAAyB;aACpB,YAAO,GAAG,SAAS,CAAC;aACpB,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAS,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAExE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@/common/types';\n\n/** Units `add`, `subtract`, `startOf` and `endOf` accept. Weeks are ISO weeks - they start on Monday; a quarter is three calendar months from January, April, July or October. */\nexport class TemporalUnits {\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 QUARTER = 'quarter';\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.QUARTER,\n this.YEAR,\n ]);\n\n static isValid(input: string): input is TTemporalUnit {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A value of {@link TemporalUnits}. */\nexport type TTemporalUnit = TConstValue<typeof TemporalUnits>;\n\n/** A helper built without a `tz` computes in UTC - never in the host's zone, which differs per machine. */\nexport const DEFAULT_TEMPORAL_TZ = 'UTC';\n\n/** `format` with no pattern writes ISO 8601 with the zone's offset: `2026-09-19T12:00:00.000+07:00`. */\nexport const DEFAULT_TEMPORAL_PATTERN = 'YYYY-MM-DDTHH:mm:ss.SSSZ';\n\n/** The locale name tokens and `formatIntl` write in when a helper is built without one. */\nexport const DEFAULT_TEMPORAL_LOCALE = 'en-US';\n\n/** How `formatDuration` writes: `compact` is `1d1h30m`; the others are the locale's own unit words. */\nexport class TemporalDurationStyles {\n static readonly COMPACT = 'compact';\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set([this.COMPACT, this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(input: string): input is TTemporalDurationStyle {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A value of {@link TemporalDurationStyles}. */\nexport type TTemporalDurationStyle = TConstValue<typeof TemporalDurationStyles>;\n\n/** Which ends of the range `isBetween` counts: `[` includes an end, `(` leaves it out. */\nexport class TemporalInclusivities {\n static readonly EXCLUSIVE = '()';\n static readonly INCLUSIVE = '[]';\n static readonly START_ONLY = '[)';\n static readonly END_ONLY = '(]';\n\n static readonly SCHEME_SET = new Set([\n this.EXCLUSIVE,\n this.INCLUSIVE,\n this.START_ONLY,\n this.END_ONLY,\n ]);\n\n static isValid(input: string): input is TTemporalInclusivity {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A value of {@link TemporalInclusivities}. */\nexport type TTemporalInclusivity = TConstValue<typeof TemporalInclusivities>;\n\n/** How long a month or weekday name is written: NARROW (`M`), SHORT (`Mon`) or LONG (`Monday`). */\nexport class TemporalNameWidths {\n static readonly NARROW = 'narrow';\n static readonly SHORT = 'short';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NARROW, this.SHORT, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid name width values. */\nexport type TTemporalNameWidth = TConstValue<typeof TemporalNameWidths>;\n\n/** A month name has no narrow form here: SHORT or LONG. */\nexport type TTemporalMonthNameWidth = Exclude<TTemporalNameWidth, typeof TemporalNameWidths.NARROW>;\n\n/** How `writtenDate` writes a date: NUMERIC is `10/14/2026`, LONG is `October 14, 2026`. */\nexport class TemporalWrittenDateStyles {\n static readonly NUMERIC = 'numeric';\n static readonly LONG = 'long';\n\n static readonly SCHEME_SET = new Set<string>([this.NUMERIC, this.LONG]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid written date style values. */\nexport type TTemporalWrittenDateStyle = TConstValue<typeof TemporalWrittenDateStyles>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n TemporalUnits,\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './constants';\n/** What a date-taking method accepts: a `Date`, epoch milliseconds, or an ISO 8601 string. */\nexport type TTemporalInput = Date | number | string;\n\n/** Wall-clock fields. `month` is 1-12, `day` 1-31 - never zero-based. */\nexport interface ITemporalParts {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n millisecond: number;\n}\n\n/** The wall clock an instant shows in one time zone. `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\nexport interface IZonedTemporalParts extends ITemporalParts {\n dayOfWeek: number;\n /** Minutes east of UTC: `420` for `+07:00`. Historic local mean time carries seconds, as a fraction. */\n offsetMinutes: number;\n}\n\n/**\n * The one question a date library answers: which UTC offset a time zone observes at an instant.\n * Everything else - the wall clock, a time a daylight-saving jump skips or repeats, adding a month,\n * the start of a week, a pattern - `TemporalHelper` works out once from these answers, so every\n * adapter shares one behaviour.\n */\nexport interface ITemporalAdapter {\n /** Milliseconds east of UTC that `tz` observes at `value`: `25_200_000` for `+07:00`. */\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number;\n}\n\n// ----- The slices of each library an adapter drives: structural, so no library type ships with this package.\n\n/** The part of a `Temporal.ZonedDateTime` this adapter reads. */\nexport interface ITemporalZonedDateTime {\n readonly offsetNanoseconds: number;\n}\n\n/**\n * The part of the `Temporal` namespace this adapter drives - structural, so neither this package\n * nor its consumers need Temporal's type definitions, and a polyfill's namespace fits as well.\n */\nexport interface ITemporalNamespace {\n Instant: {\n fromEpochMilliseconds(epochMilliseconds: number): {\n toZonedDateTimeISO(tz: string): ITemporalZonedDateTime;\n };\n };\n}\n\n/** The part of a `Dayjs` object this adapter reads. */\nexport interface IDayjsInstance {\n utcOffset(): number;\n tz(tz: string): IDayjsInstance;\n}\n\n/** The part of the `dayjs` factory this adapter drives - with the `utc` and `timezone` plugins extended. */\nexport interface IDayjsFactory {\n (value?: Date | number): IDayjsInstance;\n tz: (value: string, tz: string) => IDayjsInstance;\n}\n\n/** The part of a Luxon `DateTime` this adapter reads. */\nexport interface ILuxonDateTime {\n readonly isValid: boolean;\n readonly invalidReason: string | null;\n readonly offset: number;\n}\n\n/** The part of Luxon's `DateTime` class this adapter drives. */\nexport interface ILuxonDateTimeFactory {\n fromMillis(milliseconds: number, options: { zone: string }): ILuxonDateTime;\n}\n\n/** A span of time split into whole units, every field non-negative; `isNegative` carries the sign. */\nexport interface ITemporalDurationParts {\n isNegative: boolean;\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n milliseconds: number;\n}\n\n/**\n * A locale's own wording, over what `Intl` writes for it: month names (January first), weekday\n * names in ISO order (Monday first), and the AM and PM markers. Any list left out stays `Intl`'s.\n */\nexport interface ITemporalLocaleNames {\n months?: ReadonlyArray<string>;\n monthsShort?: ReadonlyArray<string>;\n weekdays?: ReadonlyArray<string>;\n weekdaysShort?: ReadonlyArray<string>;\n weekdaysMin?: ReadonlyArray<string>;\n meridiem?: readonly [string, string];\n}\n\n/** The fields `set` replaces on the wall clock: `month` is 1-12. */\nexport type TTemporalFields = Partial<ITemporalParts>;\n\n/** The units `Intl.RelativeTimeFormat` speaks: every temporal unit but the millisecond. */\nexport type TRelativeUnit = Exclude<TTemporalUnit, typeof TemporalUnits.MILLISECOND>;\n\n/** What a temporal helper does: dates in one time zone, through an adapter. `TemporalHelper` is the implementation. */\nexport interface ITemporalHelper {\n /**\n * A date picker hands back a `Date` meaning \"this wall clock in the host's zone\". This returns the\n * instant that shows the same year, month, day and time in the helper's zone. `sourceTz` defaults\n * to the host's. A skipped wall time resolves forward, a repeated one to the earlier instant.\n */\n fromWallClock(opts: { value: TTemporalInput; sourceTz?: string; tz?: string }): Date;\n\n /**\n * The reverse of `fromWallClock`, to feed a picker: a `Date` whose wall clock in `targetTz` (default:\n * the host's) reads what the helper's zone reads for `value`.\n */\n toWallClock(opts: { value: TTemporalInput; targetTz?: string; tz?: string }): Date;\n\n /** A helper like this one, with another locale or zone: same adapter, same `names`. */\n clone(opts: { locale?: string; tz?: string }): ITemporalHelper;\n\n getTz(): string;\n\n getLocale(): string;\n\n now(): Date;\n\n /** The instant a value names. An ISO string without an offset is read as wall clock in the zone. */\n toDate(opts: { value: TTemporalInput; tz?: string }): Date;\n\n /** `toDate`, answering `null` where `toDate` refuses the value: null, undefined, bad text, NaN. */\n tryToDate(opts: { value: TTemporalInput | null | undefined; tz?: string }): Date | null;\n\n /** The wall clock the value shows in the zone, with its ISO weekday and UTC offset. */\n parts(opts: { value: TTemporalInput; tz?: string }): IZonedTemporalParts;\n\n /**\n * Reads a string. With a `pattern` (`YYYY YY MM M DD D HH H mm m ss s SSS Z ZZ`, text in\n * `[brackets]`), the value must match it exactly; without one it must be ISO 8601. An offset in\n * the value wins; otherwise the fields are wall clock in the zone.\n */\n parse(opts: { value: string; pattern?: string; tz?: string }): Date;\n\n /** `parse`, answering `null` where `parse` refuses the value. A pattern that does not compile still throws. */\n tryParse(opts: { value: string; pattern?: string; tz?: string }): Date | null;\n\n /** Whether the value names an instant in years 1-9999 - a string read as `parse` reads it. */\n isValid(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n }): boolean;\n\n /**\n * Writes the value in the zone. Without a `pattern`: ISO 8601 with the zone's offset. The tokens\n * `MMMM MMM dddd ddd dd A a hh h LL L` are spelled in `locale`. With a `fallback`, a value that is\n * not a date - null included - writes the fallback; without one, it is a 400.\n */\n format(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n /** Writes the value with `Intl.DateTimeFormat` options, in the zone - for what the pattern tokens cannot say. */\n formatIntl(opts: {\n value: TTemporalInput | null | undefined;\n options?: Omit<Intl.DateTimeFormatOptions, 'timeZone'>;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n /**\n * Moves the value by whole units. Hours and smaller are elapsed time; days and larger move the\n * calendar in the zone, so a day across a daylight-saving jump keeps the wall time, and a month\n * past a shorter month clamps to its last day.\n */\n add(opts: { value: TTemporalInput; amount: number; unit: TTemporalUnit; tz?: string }): Date;\n\n subtract(opts: { value: TTemporalInput; amount: number; unit: TTemporalUnit; tz?: string }): Date;\n\n /** The first instant of the unit containing the value, in the zone. Weeks start on Monday. */\n startOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n /** The last millisecond of the unit containing the value, in the zone. */\n endOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n /** Monday to Friday, read on the wall clock of the zone. */\n isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean;\n\n nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n /**\n * The value with wall-clock fields replaced in the zone - `{ hour: 9, minute: 0 }` is 09:00 that day.\n * `month` is 1-12. The day is clamped to the month's last day, so setting February on the 31st\n * lands on the 28th or 29th. A wall time a daylight-saving jump skips resolves forward, as `parse` does.\n */\n set(opts: { value: TTemporalInput; tz?: string } & TTemporalFields): Date;\n\n /** `value` is before `other` - at the unit's granularity in the zone when `unit` is given. */\n isBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n /** In the same unit - `unit: 'day'` is the same calendar day in the zone. */\n isSame(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n /**\n * Whether `value` lies between `from` and `to`, in either order. `inclusivity` says which ends count:\n * `()` (the default) neither, `[]` both, `[)` the start, `(]` the end.\n */\n isBetween(opts: {\n value: TTemporalInput;\n from: TTemporalInput;\n to: TTemporalInput;\n unit?: TTemporalUnit;\n inclusivity?: TTemporalInclusivity;\n tz?: string;\n }): boolean;\n\n /**\n * How many whole units `value` is past `other` - negative when it is before - truncated toward\n * zero, counted as dayjs counts. Hours and smaller are elapsed time. Days and weeks are calendar\n * days in the zone: the wall clocks' difference, so a 23-hour daylight-saving day is one day.\n * Months, quarters and years are anchored on the date with the later day of the month, then\n * truncated, so `diff(a, b)` is always `-diff(b, a)`.\n */\n diff(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit: TTemporalUnit;\n tz?: string;\n }): number;\n\n /**\n * `-1`, `0` or `1` as `value` is before, in, or after the unit that holds `other`, in the zone.\n * Without a unit the two instants are compared to the millisecond.\n */\n compare(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): -1 | 0 | 1;\n\n /**\n * `value` relative to `base` (default: now) in words, through `Intl.RelativeTimeFormat`:\n * `3 hours ago`, `in 2 days`. With a `unit`, it counts the unit's boundaries in the zone, so\n * 23:00 yesterday seen at 01:00 is `yesterday` under `numeric: 'auto'`. Without one it says the\n * largest whole unit that has elapsed, from years down to seconds.\n */\n relative(opts: {\n value: TTemporalInput;\n base?: TTemporalInput;\n unit?: TTemporalUnit;\n numeric?: Intl.RelativeTimeFormatNumeric;\n style?: Intl.RelativeTimeFormatStyle;\n tz?: string;\n locale?: string;\n }): string;\n\n /** A span of milliseconds as days, hours, minutes, seconds and milliseconds. A day is 24 hours. */\n durationParts(opts: { milliseconds: number }): ITemporalDurationParts;\n\n /**\n * A span of milliseconds written out: `compact` (the default) is `1d1h30m`; `narrow`, `short` and\n * `long` use the locale's unit words. Zero units are left out and milliseconds dropped.\n */\n formatDuration(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n /** A clock face instead of words: `HH:mm:ss`, `mm:ss`, `D[d] HH:mm`. The largest token carries the rest. */\n pattern?: string;\n /** Only the largest units that are not zero: `1` writes `2 giờ` for 2 hours 5 minutes. */\n maxUnits?: number;\n locale?: string;\n }): string;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n TemporalUnits,\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './constants';\n\n/** What a date-taking method accepts: a `Date`, epoch milliseconds, or an ISO 8601 string. */\nexport type TTemporalInput = Date | number | string;\n\n/** Wall-clock fields. `month` is 1-12, `day` 1-31 - never zero-based. */\nexport interface ITemporalParts {\n year: number;\n month: number;\n day: number;\n hour: number;\n minute: number;\n second: number;\n millisecond: number;\n}\n\n/** The wall clock an instant shows in one time zone. `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\nexport interface IZonedTemporalParts extends ITemporalParts {\n dayOfWeek: number;\n /** Minutes east of UTC: `420` for `+07:00`. Historic local mean time carries seconds, as a fraction. */\n offsetMinutes: number;\n}\n\n/**\n * The one question a date library answers: which UTC offset a time zone observes at an instant.\n * Everything else - the wall clock, a time a daylight-saving jump skips or repeats, adding a month,\n * the start of a week, a pattern - `TemporalHelper` works out once from these answers, so every\n * adapter shares one behaviour.\n */\nexport interface ITemporalAdapter {\n /** Milliseconds east of UTC that `tz` observes at `value`: `25_200_000` for `+07:00`. */\n getOffsetMilliseconds(opts: { value: Date; tz: string }): number;\n}\n\n// ----- The slices of each library an adapter drives: structural, so no library type ships with this package.\n\n/** The part of a `Temporal.ZonedDateTime` this adapter reads. */\nexport interface ITemporalZonedDateTime {\n readonly offsetNanoseconds: number;\n}\n\n/**\n * The part of the `Temporal` namespace this adapter drives - structural, so neither this package\n * nor its consumers need Temporal's type definitions, and a polyfill's namespace fits as well.\n */\nexport interface ITemporalNamespace {\n Instant: {\n fromEpochMilliseconds(epochMilliseconds: number): {\n toZonedDateTimeISO(tz: string): ITemporalZonedDateTime;\n };\n };\n}\n\n/** The part of a `Dayjs` object this adapter reads. */\nexport interface IDayjsInstance {\n utcOffset(): number;\n tz(tz: string): IDayjsInstance;\n}\n\n/** The part of the `dayjs` factory this adapter drives - with the `utc` and `timezone` plugins extended. */\nexport interface IDayjsFactory {\n (value?: Date | number): IDayjsInstance;\n tz: (value: string, tz: string) => IDayjsInstance;\n}\n\n/** The part of a Luxon `DateTime` this adapter reads. */\nexport interface ILuxonDateTime {\n readonly isValid: boolean;\n readonly invalidReason: string | null;\n readonly offset: number;\n}\n\n/** The part of Luxon's `DateTime` class this adapter drives. */\nexport interface ILuxonDateTimeFactory {\n fromMillis(milliseconds: number, options: { zone: string }): ILuxonDateTime;\n}\n\n/** A span of time split into whole units, every field non-negative; `isNegative` carries the sign. */\nexport interface ITemporalDurationParts {\n isNegative: boolean;\n days: number;\n hours: number;\n minutes: number;\n seconds: number;\n milliseconds: number;\n}\n\n/**\n * A locale's own wording, over what `Intl` writes for it: month names (January first), weekday\n * names in ISO order (Monday first), and the AM and PM markers. Any list left out stays `Intl`'s.\n */\nexport interface ITemporalLocaleNames {\n months?: ReadonlyArray<string>;\n monthsShort?: ReadonlyArray<string>;\n weekdays?: ReadonlyArray<string>;\n weekdaysShort?: ReadonlyArray<string>;\n weekdaysMin?: ReadonlyArray<string>;\n meridiem?: readonly [string, string];\n}\n\n/** The fields `set` replaces on the wall clock: `month` is 1-12. */\nexport type TTemporalFields = Partial<ITemporalParts>;\n\n/** The units `Intl.RelativeTimeFormat` speaks: every temporal unit but the millisecond. */\nexport type TRelativeUnit = Exclude<TTemporalUnit, typeof TemporalUnits.MILLISECOND>;\n\n/** What a temporal helper does: dates in one time zone, through an adapter. `TemporalHelper` is the implementation. */\nexport interface ITemporalHelper {\n /**\n * A date picker hands back a `Date` meaning \"this wall clock in the host's zone\". This returns the\n * instant that shows the same year, month, day and time in the helper's zone. `sourceTz` defaults\n * to the host's. A skipped wall time resolves forward, a repeated one to the earlier instant.\n */\n fromWallClock(opts: { value: TTemporalInput; sourceTz?: string; tz?: string }): Date;\n\n /**\n * The reverse of `fromWallClock`, to feed a picker: a `Date` whose wall clock in `targetTz` (default:\n * the host's) reads what the helper's zone reads for `value`.\n */\n toWallClock(opts: { value: TTemporalInput; targetTz?: string; tz?: string }): Date;\n\n /** A helper like this one, with another locale or zone: same adapter, same `names`. */\n clone(opts: { locale?: string; tz?: string }): ITemporalHelper;\n\n getTz(): string;\n\n getLocale(): string;\n\n now(): Date;\n\n /** The instant a value names. An ISO string without an offset is read as wall clock in the zone. */\n toDate(opts: { value: TTemporalInput; tz?: string }): Date;\n\n /** `toDate`, answering `null` where `toDate` refuses the value: null, undefined, bad text, NaN. */\n tryToDate(opts: { value: TTemporalInput | null | undefined; tz?: string }): Date | null;\n\n /** The wall clock the value shows in the zone, with its ISO weekday and UTC offset. */\n parts(opts: { value: TTemporalInput; tz?: string }): IZonedTemporalParts;\n\n /**\n * Reads a string. With a `pattern` (`YYYY YY MM M DD D HH H mm m ss s SSS Z ZZ`, text in\n * `[brackets]`), the value must match it exactly; without one it must be ISO 8601. An offset in\n * the value wins; otherwise the fields are wall clock in the zone.\n */\n parse(opts: { value: string; pattern?: string; tz?: string }): Date;\n\n /** `parse`, answering `null` where `parse` refuses the value. A pattern that does not compile still throws. */\n tryParse(opts: { value: string; pattern?: string; tz?: string }): Date | null;\n\n /** Whether the value names an instant in years 1-9999 - a string read as `parse` reads it. */\n isValid(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n }): boolean;\n\n /**\n * Writes the value in the zone. Without a `pattern`: ISO 8601 with the zone's offset. The tokens\n * `MMMM MMM dddd ddd dd A a hh h LL L` are spelled in `locale`. With a `fallback`, a value that is\n * not a date - null included - writes the fallback; without one, it is a 400.\n */\n format(opts: {\n value: TTemporalInput | null | undefined;\n pattern?: string;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n /** Writes the value with `Intl.DateTimeFormat` options, in the zone - for what the pattern tokens cannot say. */\n formatIntl(opts: {\n value: TTemporalInput | null | undefined;\n options?: Omit<Intl.DateTimeFormatOptions, 'timeZone'>;\n tz?: string;\n locale?: string;\n fallback?: string;\n }): string;\n\n /**\n * Moves the value by whole units. Hours and smaller are elapsed time; days and larger move the\n * calendar in the zone, so a day across a daylight-saving jump keeps the wall time, and a month\n * past a shorter month clamps to its last day.\n */\n add(opts: { value: TTemporalInput; amount: number; unit: TTemporalUnit; tz?: string }): Date;\n\n subtract(opts: { value: TTemporalInput; amount: number; unit: TTemporalUnit; tz?: string }): Date;\n\n /** The first instant of the unit containing the value, in the zone. Weeks start on Monday. */\n startOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n /** The last millisecond of the unit containing the value, in the zone. */\n endOf(opts: { value: TTemporalInput; unit: TTemporalUnit; tz?: string }): Date;\n\n /** Monday to Friday, read on the wall clock of the zone. */\n isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean;\n\n nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date;\n\n /**\n * The value with wall-clock fields replaced in the zone - `{ hour: 9, minute: 0 }` is 09:00 that day.\n * `month` is 1-12. The day is clamped to the month's last day, so setting February on the 31st\n * lands on the 28th or 29th. A wall time a daylight-saving jump skips resolves forward, as `parse` does.\n */\n set(opts: { value: TTemporalInput; tz?: string } & TTemporalFields): Date;\n\n /** `value` is before `other` - at the unit's granularity in the zone when `unit` is given. */\n isBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n /** In the same unit - `unit: 'day'` is the same calendar day in the zone. */\n isSame(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean;\n\n /**\n * Whether `value` lies between `from` and `to`, in either order. `inclusivity` says which ends count:\n * `()` (the default) neither, `[]` both, `[)` the start, `(]` the end.\n */\n isBetween(opts: {\n value: TTemporalInput;\n from: TTemporalInput;\n to: TTemporalInput;\n unit?: TTemporalUnit;\n inclusivity?: TTemporalInclusivity;\n tz?: string;\n }): boolean;\n\n /**\n * How many whole units `value` is past `other` - negative when it is before - truncated toward\n * zero, counted as dayjs counts. Hours and smaller are elapsed time. Days and weeks are calendar\n * days in the zone: the wall clocks' difference, so a 23-hour daylight-saving day is one day.\n * Months, quarters and years are anchored on the date with the later day of the month, then\n * truncated, so `diff(a, b)` is always `-diff(b, a)`.\n */\n diff(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit: TTemporalUnit;\n tz?: string;\n }): number;\n\n /**\n * `-1`, `0` or `1` as `value` is before, in, or after the unit that holds `other`, in the zone.\n * Without a unit the two instants are compared to the millisecond.\n */\n compare(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): -1 | 0 | 1;\n\n /**\n * `value` relative to `base` (default: now) in words, through `Intl.RelativeTimeFormat`:\n * `3 hours ago`, `in 2 days`. With a `unit`, it counts the unit's boundaries in the zone, so\n * 23:00 yesterday seen at 01:00 is `yesterday` under `numeric: 'auto'`. Without one it says the\n * largest whole unit that has elapsed, from years down to seconds.\n */\n relative(opts: {\n value: TTemporalInput;\n base?: TTemporalInput;\n unit?: TTemporalUnit;\n numeric?: Intl.RelativeTimeFormatNumeric;\n style?: Intl.RelativeTimeFormatStyle;\n tz?: string;\n locale?: string;\n }): string;\n\n /** A span of milliseconds as days, hours, minutes, seconds and milliseconds. A day is 24 hours. */\n durationParts(opts: { milliseconds: number }): ITemporalDurationParts;\n\n /**\n * A span of milliseconds written out: `compact` (the default) is `1d1h30m`; `narrow`, `short` and\n * `long` use the locale's unit words. Zero units are left out and milliseconds dropped.\n */\n formatDuration(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n /** A clock face instead of words: `HH:mm:ss`, `mm:ss`, `D[d] HH:mm`. The largest token carries the rest. */\n pattern?: string;\n /** Only the largest units that are not zero: `1` writes `2 giờ` for 2 hours 5 minutes. */\n maxUnits?: number;\n locale?: string;\n }): string;\n}\n"]}
|