@venizia/ignis-helpers 0.4.7 → 0.4.8-0

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.
Files changed (401) hide show
  1. package/README.md +2 -2
  2. package/dist/esm/common/constants/mime.js.map +1 -1
  3. package/dist/esm/common/redact.js.map +1 -1
  4. package/dist/esm/common/resolvers.js.map +1 -1
  5. package/dist/esm/modules/base.js.map +1 -1
  6. package/dist/esm/modules/cron/helper.js.map +1 -1
  7. package/dist/esm/modules/crypto/algorithms/aes.algorithm.js.map +1 -1
  8. package/dist/esm/modules/crypto/algorithms/aes.engine.js.map +1 -1
  9. package/dist/esm/modules/crypto/algorithms/base.algorithm.js.map +1 -1
  10. package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.js.map +1 -1
  11. package/dist/esm/modules/crypto/algorithms/hash.algorithm.js.map +1 -1
  12. package/dist/esm/modules/crypto/algorithms/rsa.algorithm.js.map +1 -1
  13. package/dist/esm/modules/env/app-env.js.map +1 -1
  14. package/dist/esm/modules/logger/base/base.js.map +1 -1
  15. package/dist/esm/modules/logger/base/console.js.map +1 -1
  16. package/dist/esm/modules/logger/common/constants.js.map +1 -1
  17. package/dist/esm/modules/logger/common/debug-gate.js.map +1 -1
  18. package/dist/esm/modules/logger/factory.js.map +1 -1
  19. package/dist/esm/modules/logger/formatting/error-prettier.js.map +1 -1
  20. package/dist/esm/modules/logger/hf/flusher.js.map +1 -1
  21. package/dist/esm/modules/logger/hf/logger.js.map +1 -1
  22. package/dist/esm/modules/logger/hf/ring.js.map +1 -1
  23. package/dist/esm/modules/logger/pino/backing.js.map +1 -1
  24. package/dist/esm/modules/logger/pino/destination.js.map +1 -1
  25. package/dist/esm/modules/logger/pino/logger.js.map +1 -1
  26. package/dist/esm/modules/logger/winston/formats.js.map +1 -1
  27. package/dist/esm/modules/logger/winston/logger-factory.js.map +1 -1
  28. package/dist/esm/modules/logger/winston/logger.js.map +1 -1
  29. package/dist/esm/modules/logger/winston/transports/dgram.transport.js.map +1 -1
  30. package/dist/esm/modules/network/http-request/base-network-request.helper.js.map +1 -1
  31. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.js.map +1 -1
  32. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.js.map +1 -1
  33. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.js.map +1 -1
  34. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.js.map +1 -1
  35. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.js.map +1 -1
  36. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.js.map +1 -1
  37. package/dist/esm/modules/network/utilities/query-string.js.map +1 -1
  38. package/dist/esm/modules/network/utilities/url-safety/ingest.js.map +1 -1
  39. package/dist/esm/modules/network/utilities/url-safety/policy.js.map +1 -1
  40. package/dist/esm/modules/pool/abstract.js.map +1 -1
  41. package/dist/esm/modules/queue/bullmq/helper.js.map +1 -1
  42. package/dist/esm/modules/queue/internal/hf/helper.js.map +1 -1
  43. package/dist/esm/modules/queue/internal/sequential/helper.js.map +1 -1
  44. package/dist/esm/modules/queue/kafka/base.js.map +1 -1
  45. package/dist/esm/modules/queue/kafka/consumer.js.map +1 -1
  46. package/dist/esm/modules/queue/mqtt/helper.js.map +1 -1
  47. package/dist/esm/modules/redis/base/abstract.helper.js.map +1 -1
  48. package/dist/esm/modules/redis/utility.js.map +1 -1
  49. package/dist/esm/modules/retry/helper.js.map +1 -1
  50. package/dist/esm/modules/secrets/base/abstract.helper.js.map +1 -1
  51. package/dist/esm/modules/secrets/dotenv/dotenv.helper.js.map +1 -1
  52. package/dist/esm/modules/secrets/factory.js.map +1 -1
  53. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.js.map +1 -1
  54. package/dist/esm/modules/secrets/system-envs/system-envs.helper.js.map +1 -1
  55. package/dist/esm/modules/socket/socket-io/client/browser-helper.js.map +1 -1
  56. package/dist/esm/modules/socket/socket-io/server/helper.js.map +1 -1
  57. package/dist/esm/modules/socket/websocket/server/delivery.js.map +1 -1
  58. package/dist/esm/modules/socket/websocket/server/helper.js.map +1 -1
  59. package/dist/esm/modules/storage/base.js.map +1 -1
  60. package/dist/esm/modules/storage/bun-s3/helper.js.map +1 -1
  61. package/dist/esm/modules/storage/bun-s3/utility.js.map +1 -1
  62. package/dist/esm/modules/storage/disk/helper.js.map +1 -1
  63. package/dist/esm/modules/temporal/abstract.js.map +1 -1
  64. package/dist/esm/modules/temporal/adapters/dayjs.js.map +1 -1
  65. package/dist/esm/modules/temporal/adapters/intl.js.map +1 -1
  66. package/dist/esm/modules/temporal/adapters/luxon.js.map +1 -1
  67. package/dist/esm/modules/temporal/adapters/native.js.map +1 -1
  68. package/dist/esm/modules/temporal/calendar/calendar.js.map +1 -1
  69. package/dist/esm/modules/temporal/common/types.js.map +1 -1
  70. package/dist/esm/modules/temporal/duration/duration.js.map +1 -1
  71. package/dist/esm/modules/temporal/helper.js.map +1 -1
  72. package/dist/esm/modules/temporal/locale/locale.js.map +1 -1
  73. package/dist/esm/modules/temporal/pattern/pattern.js.map +1 -1
  74. package/dist/esm/modules/temporal/pattern/tokens.js.map +1 -1
  75. package/dist/esm/modules/tree/builder.js.map +1 -1
  76. package/dist/esm/modules/uid/helper.js.map +1 -1
  77. package/dist/esm/modules/uid/opaque.js.map +1 -1
  78. package/dist/esm/modules/uid/uuid/helper.js.map +1 -1
  79. package/dist/esm/modules/uid/uuid/sha1.js.map +1 -1
  80. package/dist/esm/modules/uid/uuid/v4.js.map +1 -1
  81. package/dist/esm/modules/uid/uuid/v5.js.map +1 -1
  82. package/dist/esm/modules/uid/uuid/v7.js.map +1 -1
  83. package/dist/esm/modules/worker-thread/bus/base.js.map +1 -1
  84. package/dist/esm/modules/worker-thread/thread/base.js.map +1 -1
  85. package/dist/esm/modules/worker-thread/worker/base.js.map +1 -1
  86. package/dist/esm/modules/worker-thread/worker-pool.js.map +1 -1
  87. package/dist/esm/utilities/error.utility.js.map +1 -1
  88. package/dist/esm/utilities/form-body.utility.js.map +1 -1
  89. package/dist/esm/utilities/hr-time.utility.js.map +1 -1
  90. package/dist/esm/utilities/module.utility.js.map +1 -1
  91. package/dist/esm/utilities/parse.utility.js.map +1 -1
  92. package/dist/esm/utilities/performance.utility.js.map +1 -1
  93. package/dist/esm/utilities/promise.utility.js.map +1 -1
  94. package/dist/esm/utilities/request.utility.js.map +1 -1
  95. package/package.json +4 -4
  96. package/dist/esm/common/constants/app.d.ts.map +0 -1
  97. package/dist/esm/common/constants/duration.d.ts.map +0 -1
  98. package/dist/esm/common/constants/grpc.d.ts.map +0 -1
  99. package/dist/esm/common/constants/http.d.ts.map +0 -1
  100. package/dist/esm/common/constants/index.d.ts.map +0 -1
  101. package/dist/esm/common/constants/mime.d.ts.map +0 -1
  102. package/dist/esm/common/index.d.ts.map +0 -1
  103. package/dist/esm/common/jsx.d.ts.map +0 -1
  104. package/dist/esm/common/redact.d.ts.map +0 -1
  105. package/dist/esm/common/resolvers.d.ts.map +0 -1
  106. package/dist/esm/common/types/class.d.ts.map +0 -1
  107. package/dist/esm/common/types/const-value.d.ts.map +0 -1
  108. package/dist/esm/common/types/field-mapping.d.ts.map +0 -1
  109. package/dist/esm/common/types/index.d.ts.map +0 -1
  110. package/dist/esm/common/types/injection.d.ts.map +0 -1
  111. package/dist/esm/common/types/resolver.d.ts.map +0 -1
  112. package/dist/esm/common/types/utility.d.ts.map +0 -1
  113. package/dist/esm/core.d.ts.map +0 -1
  114. package/dist/esm/index.d.ts.map +0 -1
  115. package/dist/esm/modules/base.d.ts.map +0 -1
  116. package/dist/esm/modules/cron/helper.d.ts.map +0 -1
  117. package/dist/esm/modules/cron/index.d.ts.map +0 -1
  118. package/dist/esm/modules/crypto/algorithms/abstract.algorithm.d.ts.map +0 -1
  119. package/dist/esm/modules/crypto/algorithms/aes.algorithm.d.ts.map +0 -1
  120. package/dist/esm/modules/crypto/algorithms/aes.constants.d.ts.map +0 -1
  121. package/dist/esm/modules/crypto/algorithms/aes.engine.d.ts.map +0 -1
  122. package/dist/esm/modules/crypto/algorithms/base.algorithm.d.ts.map +0 -1
  123. package/dist/esm/modules/crypto/algorithms/credential.algorithm.d.ts.map +0 -1
  124. package/dist/esm/modules/crypto/algorithms/ecdh.algorithm.d.ts.map +0 -1
  125. package/dist/esm/modules/crypto/algorithms/hash.algorithm.d.ts.map +0 -1
  126. package/dist/esm/modules/crypto/algorithms/index.d.ts.map +0 -1
  127. package/dist/esm/modules/crypto/algorithms/rsa.algorithm.d.ts.map +0 -1
  128. package/dist/esm/modules/crypto/common/constants.d.ts.map +0 -1
  129. package/dist/esm/modules/crypto/common/index.d.ts.map +0 -1
  130. package/dist/esm/modules/crypto/common/types.d.ts.map +0 -1
  131. package/dist/esm/modules/crypto/index.d.ts.map +0 -1
  132. package/dist/esm/modules/env/app-env.d.ts.map +0 -1
  133. package/dist/esm/modules/env/common/index.d.ts.map +0 -1
  134. package/dist/esm/modules/env/common/types.d.ts.map +0 -1
  135. package/dist/esm/modules/env/index.d.ts.map +0 -1
  136. package/dist/esm/modules/env/names.d.ts.map +0 -1
  137. package/dist/esm/modules/error/index.d.ts.map +0 -1
  138. package/dist/esm/modules/index.d.ts.map +0 -1
  139. package/dist/esm/modules/logger/base/abstract.d.ts.map +0 -1
  140. package/dist/esm/modules/logger/base/base.d.ts.map +0 -1
  141. package/dist/esm/modules/logger/base/console.d.ts.map +0 -1
  142. package/dist/esm/modules/logger/base/index.d.ts.map +0 -1
  143. package/dist/esm/modules/logger/common/constants.d.ts.map +0 -1
  144. package/dist/esm/modules/logger/common/debug-gate.d.ts.map +0 -1
  145. package/dist/esm/modules/logger/common/index.d.ts.map +0 -1
  146. package/dist/esm/modules/logger/common/types.d.ts.map +0 -1
  147. package/dist/esm/modules/logger/factory.d.ts.map +0 -1
  148. package/dist/esm/modules/logger/formatting/deep-splat.d.ts.map +0 -1
  149. package/dist/esm/modules/logger/formatting/error-prettier.d.ts.map +0 -1
  150. package/dist/esm/modules/logger/formatting/index.d.ts.map +0 -1
  151. package/dist/esm/modules/logger/hf/common/constants.d.ts.map +0 -1
  152. package/dist/esm/modules/logger/hf/common/index.d.ts.map +0 -1
  153. package/dist/esm/modules/logger/hf/common/types.d.ts.map +0 -1
  154. package/dist/esm/modules/logger/hf/flusher.d.ts.map +0 -1
  155. package/dist/esm/modules/logger/hf/index.d.ts.map +0 -1
  156. package/dist/esm/modules/logger/hf/logger.d.ts.map +0 -1
  157. package/dist/esm/modules/logger/hf/ring.d.ts.map +0 -1
  158. package/dist/esm/modules/logger/index.d.ts.map +0 -1
  159. package/dist/esm/modules/logger/pino/backing.d.ts.map +0 -1
  160. package/dist/esm/modules/logger/pino/common/constants.d.ts.map +0 -1
  161. package/dist/esm/modules/logger/pino/common/index.d.ts.map +0 -1
  162. package/dist/esm/modules/logger/pino/common/types.d.ts.map +0 -1
  163. package/dist/esm/modules/logger/pino/destination.d.ts.map +0 -1
  164. package/dist/esm/modules/logger/pino/index.d.ts.map +0 -1
  165. package/dist/esm/modules/logger/pino/logger.d.ts.map +0 -1
  166. package/dist/esm/modules/logger/winston/common/constants.d.ts.map +0 -1
  167. package/dist/esm/modules/logger/winston/common/index.d.ts.map +0 -1
  168. package/dist/esm/modules/logger/winston/common/types.d.ts.map +0 -1
  169. package/dist/esm/modules/logger/winston/define.d.ts.map +0 -1
  170. package/dist/esm/modules/logger/winston/formats.d.ts.map +0 -1
  171. package/dist/esm/modules/logger/winston/index.d.ts.map +0 -1
  172. package/dist/esm/modules/logger/winston/logger-factory.d.ts.map +0 -1
  173. package/dist/esm/modules/logger/winston/logger.d.ts.map +0 -1
  174. package/dist/esm/modules/logger/winston/transports/dgram.transport.d.ts.map +0 -1
  175. package/dist/esm/modules/logger/winston/transports/index.d.ts.map +0 -1
  176. package/dist/esm/modules/network/http-request/base-network-request.helper.d.ts.map +0 -1
  177. package/dist/esm/modules/network/http-request/common/constants.d.ts.map +0 -1
  178. package/dist/esm/modules/network/http-request/common/index.d.ts.map +0 -1
  179. package/dist/esm/modules/network/http-request/fetcher/axios-fetcher.d.ts.map +0 -1
  180. package/dist/esm/modules/network/http-request/fetcher/base-fetcher.d.ts.map +0 -1
  181. package/dist/esm/modules/network/http-request/fetcher/common/index.d.ts.map +0 -1
  182. package/dist/esm/modules/network/http-request/fetcher/common/types.d.ts.map +0 -1
  183. package/dist/esm/modules/network/http-request/fetcher/index.d.ts.map +0 -1
  184. package/dist/esm/modules/network/http-request/fetcher/node-fetcher.d.ts.map +0 -1
  185. package/dist/esm/modules/network/http-request/index.d.ts.map +0 -1
  186. package/dist/esm/modules/network/index.d.ts.map +0 -1
  187. package/dist/esm/modules/network/tcp-socket/base-tcp-client.helper.d.ts.map +0 -1
  188. package/dist/esm/modules/network/tcp-socket/base-tcp-server.helper.d.ts.map +0 -1
  189. package/dist/esm/modules/network/tcp-socket/index.d.ts.map +0 -1
  190. package/dist/esm/modules/network/tcp-socket/network-tcp-client.helper.d.ts.map +0 -1
  191. package/dist/esm/modules/network/tcp-socket/network-tcp-server.helper.d.ts.map +0 -1
  192. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-client.helper.d.ts.map +0 -1
  193. package/dist/esm/modules/network/tcp-socket/network-tls-tcp-server.helper.d.ts.map +0 -1
  194. package/dist/esm/modules/network/udp-socket/index.d.ts.map +0 -1
  195. package/dist/esm/modules/network/udp-socket/network-udp-client.helper.d.ts.map +0 -1
  196. package/dist/esm/modules/network/utilities/index.d.ts.map +0 -1
  197. package/dist/esm/modules/network/utilities/query-string.d.ts.map +0 -1
  198. package/dist/esm/modules/network/utilities/url-safety/common/constants.d.ts.map +0 -1
  199. package/dist/esm/modules/network/utilities/url-safety/common/errors.d.ts.map +0 -1
  200. package/dist/esm/modules/network/utilities/url-safety/common/index.d.ts.map +0 -1
  201. package/dist/esm/modules/network/utilities/url-safety/common/types.d.ts.map +0 -1
  202. package/dist/esm/modules/network/utilities/url-safety/index.d.ts.map +0 -1
  203. package/dist/esm/modules/network/utilities/url-safety/ingest.d.ts.map +0 -1
  204. package/dist/esm/modules/network/utilities/url-safety/policy.d.ts.map +0 -1
  205. package/dist/esm/modules/pool/abstract.d.ts.map +0 -1
  206. package/dist/esm/modules/pool/base.d.ts.map +0 -1
  207. package/dist/esm/modules/pool/common/index.d.ts.map +0 -1
  208. package/dist/esm/modules/pool/common/types.d.ts.map +0 -1
  209. package/dist/esm/modules/pool/index.d.ts.map +0 -1
  210. package/dist/esm/modules/queue/bullmq/helper.d.ts.map +0 -1
  211. package/dist/esm/modules/queue/bullmq/index.d.ts.map +0 -1
  212. package/dist/esm/modules/queue/common/constants.d.ts.map +0 -1
  213. package/dist/esm/modules/queue/common/hook.d.ts.map +0 -1
  214. package/dist/esm/modules/queue/common/index.d.ts.map +0 -1
  215. package/dist/esm/modules/queue/index.d.ts.map +0 -1
  216. package/dist/esm/modules/queue/internal/hf/common/index.d.ts.map +0 -1
  217. package/dist/esm/modules/queue/internal/hf/common/types.d.ts.map +0 -1
  218. package/dist/esm/modules/queue/internal/hf/helper.d.ts.map +0 -1
  219. package/dist/esm/modules/queue/internal/hf/index.d.ts.map +0 -1
  220. package/dist/esm/modules/queue/internal/index.d.ts.map +0 -1
  221. package/dist/esm/modules/queue/internal/sequential/common/index.d.ts.map +0 -1
  222. package/dist/esm/modules/queue/internal/sequential/common/types.d.ts.map +0 -1
  223. package/dist/esm/modules/queue/internal/sequential/helper.d.ts.map +0 -1
  224. package/dist/esm/modules/queue/internal/sequential/index.d.ts.map +0 -1
  225. package/dist/esm/modules/queue/kafka/admin.d.ts.map +0 -1
  226. package/dist/esm/modules/queue/kafka/base.d.ts.map +0 -1
  227. package/dist/esm/modules/queue/kafka/bundler/common/constants.d.ts.map +0 -1
  228. package/dist/esm/modules/queue/kafka/bundler/common/index.d.ts.map +0 -1
  229. package/dist/esm/modules/queue/kafka/bundler/index.d.ts.map +0 -1
  230. package/dist/esm/modules/queue/kafka/bundler/plugins.d.ts.map +0 -1
  231. package/dist/esm/modules/queue/kafka/common/constants.d.ts.map +0 -1
  232. package/dist/esm/modules/queue/kafka/common/index.d.ts.map +0 -1
  233. package/dist/esm/modules/queue/kafka/common/types/admin.d.ts.map +0 -1
  234. package/dist/esm/modules/queue/kafka/common/types/callbacks.d.ts.map +0 -1
  235. package/dist/esm/modules/queue/kafka/common/types/connection.d.ts.map +0 -1
  236. package/dist/esm/modules/queue/kafka/common/types/consumer.d.ts.map +0 -1
  237. package/dist/esm/modules/queue/kafka/common/types/index.d.ts.map +0 -1
  238. package/dist/esm/modules/queue/kafka/common/types/producer.d.ts.map +0 -1
  239. package/dist/esm/modules/queue/kafka/consumer.d.ts.map +0 -1
  240. package/dist/esm/modules/queue/kafka/index.d.ts.map +0 -1
  241. package/dist/esm/modules/queue/kafka/producer.d.ts.map +0 -1
  242. package/dist/esm/modules/queue/kafka/schema/index.d.ts.map +0 -1
  243. package/dist/esm/modules/queue/kafka/schema/registry.d.ts.map +0 -1
  244. package/dist/esm/modules/queue/mqtt/helper.d.ts.map +0 -1
  245. package/dist/esm/modules/queue/mqtt/index.d.ts.map +0 -1
  246. package/dist/esm/modules/redis/base/abstract.helper.d.ts.map +0 -1
  247. package/dist/esm/modules/redis/base/index.d.ts.map +0 -1
  248. package/dist/esm/modules/redis/cluster/cluster.helper.d.ts.map +0 -1
  249. package/dist/esm/modules/redis/cluster/index.d.ts.map +0 -1
  250. package/dist/esm/modules/redis/common/constants.d.ts.map +0 -1
  251. package/dist/esm/modules/redis/common/index.d.ts.map +0 -1
  252. package/dist/esm/modules/redis/common/interfaces.d.ts.map +0 -1
  253. package/dist/esm/modules/redis/common/types.d.ts.map +0 -1
  254. package/dist/esm/modules/redis/factory.d.ts.map +0 -1
  255. package/dist/esm/modules/redis/index.d.ts.map +0 -1
  256. package/dist/esm/modules/redis/sentinel/index.d.ts.map +0 -1
  257. package/dist/esm/modules/redis/sentinel/sentinel.helper.d.ts.map +0 -1
  258. package/dist/esm/modules/redis/single/index.d.ts.map +0 -1
  259. package/dist/esm/modules/redis/single/single.helper.d.ts.map +0 -1
  260. package/dist/esm/modules/redis/utility.d.ts.map +0 -1
  261. package/dist/esm/modules/retry/common/constants.d.ts.map +0 -1
  262. package/dist/esm/modules/retry/common/index.d.ts.map +0 -1
  263. package/dist/esm/modules/retry/common/types.d.ts.map +0 -1
  264. package/dist/esm/modules/retry/helper.d.ts.map +0 -1
  265. package/dist/esm/modules/retry/index.d.ts.map +0 -1
  266. package/dist/esm/modules/secrets/base/abstract.helper.d.ts.map +0 -1
  267. package/dist/esm/modules/secrets/base/index.d.ts.map +0 -1
  268. package/dist/esm/modules/secrets/common/constants.d.ts.map +0 -1
  269. package/dist/esm/modules/secrets/common/index.d.ts.map +0 -1
  270. package/dist/esm/modules/secrets/common/types/helper.d.ts.map +0 -1
  271. package/dist/esm/modules/secrets/common/types/index.d.ts.map +0 -1
  272. package/dist/esm/modules/secrets/common/types/lease.d.ts.map +0 -1
  273. package/dist/esm/modules/secrets/common/types/registration.d.ts.map +0 -1
  274. package/dist/esm/modules/secrets/common/types/timer.d.ts.map +0 -1
  275. package/dist/esm/modules/secrets/dotenv/dotenv.helper.d.ts.map +0 -1
  276. package/dist/esm/modules/secrets/dotenv/index.d.ts.map +0 -1
  277. package/dist/esm/modules/secrets/factory.d.ts.map +0 -1
  278. package/dist/esm/modules/secrets/hashicorp/auth.d.ts.map +0 -1
  279. package/dist/esm/modules/secrets/hashicorp/hashicorp.helper.d.ts.map +0 -1
  280. package/dist/esm/modules/secrets/hashicorp/index.d.ts.map +0 -1
  281. package/dist/esm/modules/secrets/index.d.ts.map +0 -1
  282. package/dist/esm/modules/secrets/system-envs/index.d.ts.map +0 -1
  283. package/dist/esm/modules/secrets/system-envs/system-envs.helper.d.ts.map +0 -1
  284. package/dist/esm/modules/slug/common/constants.d.ts.map +0 -1
  285. package/dist/esm/modules/slug/common/index.d.ts.map +0 -1
  286. package/dist/esm/modules/slug/helper.d.ts.map +0 -1
  287. package/dist/esm/modules/slug/index.d.ts.map +0 -1
  288. package/dist/esm/modules/socket/index.d.ts.map +0 -1
  289. package/dist/esm/modules/socket/socket-io/browser.d.ts.map +0 -1
  290. package/dist/esm/modules/socket/socket-io/client/browser-helper.d.ts.map +0 -1
  291. package/dist/esm/modules/socket/socket-io/client/helper.d.ts.map +0 -1
  292. package/dist/esm/modules/socket/socket-io/client/index.d.ts.map +0 -1
  293. package/dist/esm/modules/socket/socket-io/common/constants.d.ts.map +0 -1
  294. package/dist/esm/modules/socket/socket-io/common/index.d.ts.map +0 -1
  295. package/dist/esm/modules/socket/socket-io/common/types/client.d.ts.map +0 -1
  296. package/dist/esm/modules/socket/socket-io/common/types/hooks.d.ts.map +0 -1
  297. package/dist/esm/modules/socket/socket-io/common/types/index.d.ts.map +0 -1
  298. package/dist/esm/modules/socket/socket-io/common/types/server.d.ts.map +0 -1
  299. package/dist/esm/modules/socket/socket-io/index.d.ts.map +0 -1
  300. package/dist/esm/modules/socket/socket-io/server/helper.d.ts.map +0 -1
  301. package/dist/esm/modules/socket/socket-io/server/index.d.ts.map +0 -1
  302. package/dist/esm/modules/socket/websocket/common/constants.d.ts.map +0 -1
  303. package/dist/esm/modules/socket/websocket/common/index.d.ts.map +0 -1
  304. package/dist/esm/modules/socket/websocket/common/types/client.d.ts.map +0 -1
  305. package/dist/esm/modules/socket/websocket/common/types/hooks.d.ts.map +0 -1
  306. package/dist/esm/modules/socket/websocket/common/types/index.d.ts.map +0 -1
  307. package/dist/esm/modules/socket/websocket/common/types/message.d.ts.map +0 -1
  308. package/dist/esm/modules/socket/websocket/common/types/server.d.ts.map +0 -1
  309. package/dist/esm/modules/socket/websocket/emitter/helper.d.ts.map +0 -1
  310. package/dist/esm/modules/socket/websocket/emitter/index.d.ts.map +0 -1
  311. package/dist/esm/modules/socket/websocket/index.d.ts.map +0 -1
  312. package/dist/esm/modules/socket/websocket/server/delivery.d.ts.map +0 -1
  313. package/dist/esm/modules/socket/websocket/server/helper.d.ts.map +0 -1
  314. package/dist/esm/modules/socket/websocket/server/index.d.ts.map +0 -1
  315. package/dist/esm/modules/storage/base.d.ts.map +0 -1
  316. package/dist/esm/modules/storage/bun-s3/helper.d.ts.map +0 -1
  317. package/dist/esm/modules/storage/bun-s3/index.d.ts.map +0 -1
  318. package/dist/esm/modules/storage/bun-s3/utility.d.ts.map +0 -1
  319. package/dist/esm/modules/storage/common/constants.d.ts.map +0 -1
  320. package/dist/esm/modules/storage/common/errors.d.ts.map +0 -1
  321. package/dist/esm/modules/storage/common/index.d.ts.map +0 -1
  322. package/dist/esm/modules/storage/common/types.d.ts.map +0 -1
  323. package/dist/esm/modules/storage/common/utility.d.ts.map +0 -1
  324. package/dist/esm/modules/storage/disk/helper.d.ts.map +0 -1
  325. package/dist/esm/modules/storage/disk/index.d.ts.map +0 -1
  326. package/dist/esm/modules/storage/in-memory/helper.d.ts.map +0 -1
  327. package/dist/esm/modules/storage/in-memory/index.d.ts.map +0 -1
  328. package/dist/esm/modules/storage/index.d.ts.map +0 -1
  329. package/dist/esm/modules/temporal/abstract.d.ts.map +0 -1
  330. package/dist/esm/modules/temporal/adapters/dayjs.d.ts.map +0 -1
  331. package/dist/esm/modules/temporal/adapters/index.d.ts.map +0 -1
  332. package/dist/esm/modules/temporal/adapters/intl.d.ts.map +0 -1
  333. package/dist/esm/modules/temporal/adapters/luxon.d.ts.map +0 -1
  334. package/dist/esm/modules/temporal/adapters/native.d.ts.map +0 -1
  335. package/dist/esm/modules/temporal/calendar/calendar.d.ts.map +0 -1
  336. package/dist/esm/modules/temporal/calendar/index.d.ts.map +0 -1
  337. package/dist/esm/modules/temporal/common/constants.d.ts.map +0 -1
  338. package/dist/esm/modules/temporal/common/index.d.ts.map +0 -1
  339. package/dist/esm/modules/temporal/common/types.d.ts.map +0 -1
  340. package/dist/esm/modules/temporal/duration/duration.d.ts.map +0 -1
  341. package/dist/esm/modules/temporal/duration/index.d.ts.map +0 -1
  342. package/dist/esm/modules/temporal/helper.d.ts.map +0 -1
  343. package/dist/esm/modules/temporal/index.d.ts.map +0 -1
  344. package/dist/esm/modules/temporal/locale/index.d.ts.map +0 -1
  345. package/dist/esm/modules/temporal/locale/locale.d.ts.map +0 -1
  346. package/dist/esm/modules/temporal/pattern/common/constants.d.ts.map +0 -1
  347. package/dist/esm/modules/temporal/pattern/common/index.d.ts.map +0 -1
  348. package/dist/esm/modules/temporal/pattern/common/types.d.ts.map +0 -1
  349. package/dist/esm/modules/temporal/pattern/index.d.ts.map +0 -1
  350. package/dist/esm/modules/temporal/pattern/pattern.d.ts.map +0 -1
  351. package/dist/esm/modules/temporal/pattern/tokens.d.ts.map +0 -1
  352. package/dist/esm/modules/tree/builder.d.ts.map +0 -1
  353. package/dist/esm/modules/tree/common/index.d.ts.map +0 -1
  354. package/dist/esm/modules/tree/common/types.d.ts.map +0 -1
  355. package/dist/esm/modules/tree/index.d.ts.map +0 -1
  356. package/dist/esm/modules/tree/walk.d.ts.map +0 -1
  357. package/dist/esm/modules/uid/common/constants.d.ts.map +0 -1
  358. package/dist/esm/modules/uid/common/index.d.ts.map +0 -1
  359. package/dist/esm/modules/uid/common/types.d.ts.map +0 -1
  360. package/dist/esm/modules/uid/helper.d.ts.map +0 -1
  361. package/dist/esm/modules/uid/index.d.ts.map +0 -1
  362. package/dist/esm/modules/uid/opaque.d.ts.map +0 -1
  363. package/dist/esm/modules/uid/request-id.d.ts.map +0 -1
  364. package/dist/esm/modules/uid/uuid/common/constants.d.ts.map +0 -1
  365. package/dist/esm/modules/uid/uuid/common/index.d.ts.map +0 -1
  366. package/dist/esm/modules/uid/uuid/common/types.d.ts.map +0 -1
  367. package/dist/esm/modules/uid/uuid/helper.d.ts.map +0 -1
  368. package/dist/esm/modules/uid/uuid/index.d.ts.map +0 -1
  369. package/dist/esm/modules/uid/uuid/sha1.d.ts.map +0 -1
  370. package/dist/esm/modules/uid/uuid/v4.d.ts.map +0 -1
  371. package/dist/esm/modules/uid/uuid/v5.d.ts.map +0 -1
  372. package/dist/esm/modules/uid/uuid/v7.d.ts.map +0 -1
  373. package/dist/esm/modules/worker-thread/bus/abstract.d.ts.map +0 -1
  374. package/dist/esm/modules/worker-thread/bus/base.d.ts.map +0 -1
  375. package/dist/esm/modules/worker-thread/bus/handler/abstract.d.ts.map +0 -1
  376. package/dist/esm/modules/worker-thread/bus/handler/base.d.ts.map +0 -1
  377. package/dist/esm/modules/worker-thread/bus/handler/index.d.ts.map +0 -1
  378. package/dist/esm/modules/worker-thread/bus/index.d.ts.map +0 -1
  379. package/dist/esm/modules/worker-thread/common/index.d.ts.map +0 -1
  380. package/dist/esm/modules/worker-thread/common/types.d.ts.map +0 -1
  381. package/dist/esm/modules/worker-thread/index.d.ts.map +0 -1
  382. package/dist/esm/modules/worker-thread/thread/abstract.d.ts.map +0 -1
  383. package/dist/esm/modules/worker-thread/thread/base.d.ts.map +0 -1
  384. package/dist/esm/modules/worker-thread/thread/index.d.ts.map +0 -1
  385. package/dist/esm/modules/worker-thread/worker/abstract.d.ts.map +0 -1
  386. package/dist/esm/modules/worker-thread/worker/base.d.ts.map +0 -1
  387. package/dist/esm/modules/worker-thread/worker/index.d.ts.map +0 -1
  388. package/dist/esm/modules/worker-thread/worker-pool.d.ts.map +0 -1
  389. package/dist/esm/temporal.d.ts.map +0 -1
  390. package/dist/esm/utilities/build-info.utility.d.ts.map +0 -1
  391. package/dist/esm/utilities/error.utility.d.ts.map +0 -1
  392. package/dist/esm/utilities/form-body.utility.d.ts.map +0 -1
  393. package/dist/esm/utilities/hr-time.utility.d.ts.map +0 -1
  394. package/dist/esm/utilities/index.d.ts.map +0 -1
  395. package/dist/esm/utilities/module.utility.d.ts.map +0 -1
  396. package/dist/esm/utilities/parse.utility.d.ts.map +0 -1
  397. package/dist/esm/utilities/performance.utility.d.ts.map +0 -1
  398. package/dist/esm/utilities/project-root.utility.d.ts.map +0 -1
  399. package/dist/esm/utilities/promise.utility.d.ts.map +0 -1
  400. package/dist/esm/utilities/request.utility.d.ts.map +0 -1
  401. package/dist/esm/uuid.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"dayjs.js","s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EAAE,MAAM,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACxI,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["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 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
+ {"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;QAE5B,OAAO,KAAK,GAAG,gBAAgB,EAAE,CAAC;YAChC,KAAK,IAAI,4BAA4B,CAAC;QACxC,CAAC;QAED,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,GAAG,uBAAuB,CAAC;QACxE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,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,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;aACxI,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF","sourcesContent":["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;QACtD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,SAA8B,CAAC;QACnC,IAAI,CAAC;YACH,SAAS,GAAG,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE;gBAC3C,QAAQ,EAAE,EAAE;gBACZ,SAAS,EAAE,KAAK;gBAChB,GAAG,EAAE,OAAO;gBACZ,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,SAAS;gBAChB,GAAG,EAAE,SAAS;gBACd,IAAI,EAAE,SAAS;gB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E,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;QACxF,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 if (cached) {\n return cached;\n }\n\n let formatter: Intl.DateTimeFormat;\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 if (oldest !== undefined) {\n IntlTemporalAdapter.formatters.delete(oldest);\n }\n }\n const entry = { formatter, commonEra };\n IntlTemporalAdapter.formatters.set(tz, entry);\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 for (const part of formatter.formatToParts(value)) {\n if (part.type === 'era') {\n isBeforeCommonEra = commonEra !== undefined && part.value !== commonEra;\n continue;\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 return wallClock.getTime() - wholeSecond;\n }\n}\n"]}
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,mBAAm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AK,CAAC,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;QAED,qFAAqF;QACrF,MAAM,IAAI,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAC/D,0DAA0D;QAC1D,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAElD,MAAM,SAAS,GAAG,IAAI,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;QACD,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 return zoned.offset * MILLISECONDS_PER_MINUTE;\n }\n}\n"]}
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;IAG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AC;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 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 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
+ {"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;;;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,CAA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,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,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAEzD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,IAAsB;QAC3C,OAAO,IAAI,CAAC,IAAI,IAAI,gBAAgB,CAAC,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,gBAAgB,CAAC,QAAQ,CAAC;I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AAK,CAAC,GAAG,GAAG,IAAI;aACtB,CAAC,CAAC;YAEH,OAAO;gBACL,GAAG,KAAK;gBACR,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE;gBAC3B,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC;gBAC7B,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE;aACvB,CAAC;QACJ,CAAC;QAED,MAAM,aAAa,GACjB,IAAI,KAAK,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;QACzF,MAAM,KAAK,GAAG,KAAK,CAAC,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\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"]}
@@ -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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/duration/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,EAAE,GAAG,mBAAmB,CAAC;AACrD,MAAM,iBAAiB,GAAG,EAAE,GAAG,mBAAmB,CAAC;AACnD,MAAM,gBAAgB,GAAG,EAAE,GAAG,iBAAiB,CAAC;AAEhD,iGAAiG;AACjG,MAAM,WAAW,GAAG,IAAI,GAAG,CAAkD;IAC3E,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACpD,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACnD,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACrD,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACpD,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACvD,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,mBAAmB,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IACtD,CAAC,IAAI,EAAE,EAAE,YAAY,EAAE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1B,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,IAAI,CAAC,CAAC;YACd,CAAC;YAED,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAC5C,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YACnC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;oBAC/B,MAAM,QAAQ,CAAC;wBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;wBACrD,OAAO,EAAE,qCAAqC,GAAG,iBAAiB,OAAO,kBAAkB,CAAC,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,2BAA2B;qBACxJ,CAAC,CAAC;gBACL,CAAC;gBACD,IAAI,IAAI,GAAG,CAAC;gBACZ,QAAQ,GAAG,MAAM,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;YAC1D,SAAS,IAAI,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;YACzC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAClD,QAAQ,GAAG,MAAM,CAAC;QACpB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport { TemporalDurationStyles } from '../common/constants';\nimport type { TTemporalDurationStyle } from '../common/constants';\nimport type { ITemporalDurationParts } from '../common/types';\n\nconst SECOND_MILLISECONDS = 1000;\nconst MINUTE_MILLISECONDS = 60 * SECOND_MILLISECONDS;\nconst HOUR_MILLISECONDS = 60 * MINUTE_MILLISECONDS;\nconst DAY_MILLISECONDS = 24 * HOUR_MILLISECONDS;\n\n/** Clock-face tokens, largest first: how many milliseconds each counts, and how wide it pads. */\nconst FACE_TOKENS = new Map<string, { milliseconds: number; width: number }>([\n ['DD', { milliseconds: DAY_MILLISECONDS, width: 2 }],\n ['D', { milliseconds: DAY_MILLISECONDS, width: 1 }],\n ['HH', { milliseconds: HOUR_MILLISECONDS, width: 2 }],\n ['H', { milliseconds: HOUR_MILLISECONDS, width: 1 }],\n ['mm', { milliseconds: MINUTE_MILLISECONDS, width: 2 }],\n ['m', { milliseconds: MINUTE_MILLISECONDS, width: 1 }],\n ['ss', { milliseconds: SECOND_MILLISECONDS, width: 2 }],\n ['s', { milliseconds: SECOND_MILLISECONDS, width: 1 }],\n ['SSS', { milliseconds: 1, width: 3 }],\n]);\n\n/** Largest first: the order a written duration reads in. */\nconst FIELDS = [\n { field: 'days', unit: 'day', letter: 'd' },\n { field: 'hours', unit: 'hour', letter: 'h' },\n { field: 'minutes', unit: 'minute', letter: 'm' },\n { field: 'seconds', unit: 'second', letter: 's' },\n] as const;\n\n/** A span of milliseconds, split into days to milliseconds and written out. A day is always 24 hours here. */\nexport class TemporalDuration {\n static parts(opts: { milliseconds: number }): ITemporalDurationParts {\n const { milliseconds } = opts;\n if (!Number.isSafeInteger(milliseconds)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] milliseconds must be a safe integer - received ${milliseconds}`,\n });\n }\n\n const total = Math.abs(milliseconds);\n return {\n isNegative: milliseconds < 0,\n days: Math.floor(total / DAY_MILLISECONDS),\n hours: Math.floor((total % DAY_MILLISECONDS) / HOUR_MILLISECONDS),\n minutes: Math.floor((total % HOUR_MILLISECONDS) / MINUTE_MILLISECONDS),\n seconds: Math.floor((total % MINUTE_MILLISECONDS) / SECOND_MILLISECONDS),\n milliseconds: total % SECOND_MILLISECONDS,\n };\n }\n\n /**\n * Days, hours, minutes and seconds, zero units left out and milliseconds dropped: `compact` is\n * `1d1h30m`, the other styles use the locale's unit words (`1 ngày 1 giờ 30 phút`). Under a\n * second writes `0s` or `0 seconds`.\n */\n static format(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n pattern?: string;\n maxUnits?: number;\n locale: string;\n }): string {\n const { style = TemporalDurationStyles.COMPACT, pattern, maxUnits, locale } = opts;\n if (pattern !== undefined) {\n return TemporalDuration.formatFace({ milliseconds: opts.milliseconds, pattern });\n }\n\n if (maxUnits !== undefined && !(Number.isInteger(maxUnits) && maxUnits > 0)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] maxUnits must be a positive integer - received ${maxUnits}`,\n });\n }\n\n if (!TemporalDurationStyles.isValid(style)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] unknown style '${style}' | Supported: ${[...TemporalDurationStyles.SCHEME_SET].join(', ')}`,\n });\n }\n\n const parts = TemporalDuration.parts({ milliseconds: opts.milliseconds });\n const present = FIELDS.filter(({ field }) => parts[field] > 0).slice(0, maxUnits);\n const written = present.length > 0 ? present : [FIELDS[FIELDS.length - 1]];\n // Under a second writes `0s` whatever the sign: there is no negative zero to show.\n const sign = parts.isNegative && present.length > 0 ? '-' : '';\n\n if (style === TemporalDurationStyles.COMPACT) {\n return sign + written.map(({ field, letter }) => `${parts[field]}${letter}`).join('');\n }\n\n const words = written.map(({ field, unit }) =>\n new Intl.NumberFormat(locale, { style: 'unit', unit, unitDisplay: style }).format(\n parts[field],\n ),\n );\n return sign + new Intl.ListFormat(locale, { type: 'unit', style }).format(words);\n }\n\n /**\n * A clock face: `HH:mm:ss` writes 3,723,000 ms as `01:02:03`. The largest token present carries\n * everything above it, so `mm:ss` writes 75 minutes as `75:00`. Text goes in `[brackets]`.\n */\n private static formatFace(opts: { milliseconds: number; pattern: string }): string {\n const { pattern } = opts;\n const parts = TemporalDuration.parts({ milliseconds: opts.milliseconds });\n let remaining =\n ((parts.days * 24 + parts.hours) * 60 + parts.minutes) * MINUTE_MILLISECONDS +\n parts.seconds * SECOND_MILLISECONDS +\n parts.milliseconds;\n\n let text = parts.isNegative ? '-' : '';\n let position = 0;\n while (position < pattern.length) {\n const character = pattern[position];\n if (character === '[') {\n const close = pattern.indexOf(']', position + 1);\n if (close < 0) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalDuration] unclosed [ in pattern '${pattern}'`,\n });\n }\n text += pattern.slice(position + 1, close);\n position = close + 1;\n continue;\n }\n\n let runEnd = position + 1;\n while (pattern[runEnd] === character) {\n runEnd += 1;\n }\n\n const run = pattern.slice(position, runEnd);\n const token = FACE_TOKENS.get(run);\n if (token === undefined) {\n if (/[A-Za-z]/.test(character)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalDuration] unknown token '${run}' in pattern '${pattern}' | Supported: ${[...FACE_TOKENS.keys()].join(' ')}; wrap text in [brackets]`,\n });\n }\n text += run;\n position = runEnd;\n continue;\n }\n\n const amount = Math.floor(remaining / token.milliseconds);\n remaining -= amount * token.milliseconds;\n text += String(amount).padStart(token.width, '0');\n position = runEnd;\n }\n return text;\n }\n}\n"]}
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/duration/duration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAI7D,MAAM,mBAAmB,GAAG,IAAI,CAAC;AACjC,MAAM,mBAAmB,GAAG,EAAE,GAAG,mBAAmB,CAAC;AACrD,MAAM,iBAAiB,GAAG,EAAE,GAAG,mBAAmB,CAAC;AACnD,MAAM,gBAAgB,GAAG,EAAE,GAAG,i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CAAC;gBACL,CAAC;gBAED,IAAI,IAAI,GAAG,CAAC;gBACZ,QAAQ,GAAG,MAAM,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;YAC1D,SAAS,IAAI,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC;YACzC,IAAI,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAClD,QAAQ,GAAG,MAAM,CAAC;QACpB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport { TemporalDurationStyles } from '../common/constants';\nimport type { TTemporalDurationStyle } from '../common/constants';\nimport type { ITemporalDurationParts } from '../common/types';\n\nconst SECOND_MILLISECONDS = 1000;\nconst MINUTE_MILLISECONDS = 60 * SECOND_MILLISECONDS;\nconst HOUR_MILLISECONDS = 60 * MINUTE_MILLISECONDS;\nconst DAY_MILLISECONDS = 24 * HOUR_MILLISECONDS;\n\n/** Clock-face tokens, largest first: how many milliseconds each counts, and how wide it pads. */\nconst FACE_TOKENS = new Map<string, { milliseconds: number; width: number }>([\n ['DD', { milliseconds: DAY_MILLISECONDS, width: 2 }],\n ['D', { milliseconds: DAY_MILLISECONDS, width: 1 }],\n ['HH', { milliseconds: HOUR_MILLISECONDS, width: 2 }],\n ['H', { milliseconds: HOUR_MILLISECONDS, width: 1 }],\n ['mm', { milliseconds: MINUTE_MILLISECONDS, width: 2 }],\n ['m', { milliseconds: MINUTE_MILLISECONDS, width: 1 }],\n ['ss', { milliseconds: SECOND_MILLISECONDS, width: 2 }],\n ['s', { milliseconds: SECOND_MILLISECONDS, width: 1 }],\n ['SSS', { milliseconds: 1, width: 3 }],\n]);\n\n/** Largest first: the order a written duration reads in. */\nconst FIELDS = [\n { field: 'days', unit: 'day', letter: 'd' },\n { field: 'hours', unit: 'hour', letter: 'h' },\n { field: 'minutes', unit: 'minute', letter: 'm' },\n { field: 'seconds', unit: 'second', letter: 's' },\n] as const;\n\n/** A span of milliseconds, split into days to milliseconds and written out. A day is always 24 hours here. */\nexport class TemporalDuration {\n static parts(opts: { milliseconds: number }): ITemporalDurationParts {\n const { milliseconds } = opts;\n\n if (!Number.isSafeInteger(milliseconds)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] milliseconds must be a safe integer - received ${milliseconds}`,\n });\n }\n\n const total = Math.abs(milliseconds);\n\n return {\n isNegative: milliseconds < 0,\n days: Math.floor(total / DAY_MILLISECONDS),\n hours: Math.floor((total % DAY_MILLISECONDS) / HOUR_MILLISECONDS),\n minutes: Math.floor((total % HOUR_MILLISECONDS) / MINUTE_MILLISECONDS),\n seconds: Math.floor((total % MINUTE_MILLISECONDS) / SECOND_MILLISECONDS),\n milliseconds: total % SECOND_MILLISECONDS,\n };\n }\n\n /**\n * Days, hours, minutes and seconds, zero units left out and milliseconds dropped: `compact` is\n * `1d1h30m`, the other styles use the locale's unit words (`1 ngày 1 giờ 30 phút`). Under a\n * second writes `0s` or `0 seconds`.\n */\n static format(opts: {\n milliseconds: number;\n style?: TTemporalDurationStyle;\n pattern?: string;\n maxUnits?: number;\n locale: string;\n }): string {\n const { style = TemporalDurationStyles.COMPACT, pattern, maxUnits, locale } = opts;\n\n if (pattern !== undefined) {\n return TemporalDuration.formatFace({ milliseconds: opts.milliseconds, pattern });\n }\n\n if (maxUnits !== undefined && !(Number.isInteger(maxUnits) && maxUnits > 0)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] maxUnits must be a positive integer - received ${maxUnits}`,\n });\n }\n\n if (!TemporalDurationStyles.isValid(style)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalDuration] unknown style '${style}' | Supported: ${[...TemporalDurationStyles.SCHEME_SET].join(', ')}`,\n });\n }\n\n const parts = TemporalDuration.parts({ milliseconds: opts.milliseconds });\n const present = FIELDS.filter(({ field }) => parts[field] > 0).slice(0, maxUnits);\n const written = present.length > 0 ? present : [FIELDS[FIELDS.length - 1]];\n // Under a second writes `0s` whatever the sign: there is no negative zero to show.\n const sign = parts.isNegative && present.length > 0 ? '-' : '';\n\n if (style === TemporalDurationStyles.COMPACT) {\n return sign + written.map(({ field, letter }) => `${parts[field]}${letter}`).join('');\n }\n\n const words = written.map(({ field, unit }) =>\n new Intl.NumberFormat(locale, { style: 'unit', unit, unitDisplay: style }).format(\n parts[field],\n ),\n );\n\n return sign + new Intl.ListFormat(locale, { type: 'unit', style }).format(words);\n }\n\n /**\n * A clock face: `HH:mm:ss` writes 3,723,000 ms as `01:02:03`. The largest token present carries\n * everything above it, so `mm:ss` writes 75 minutes as `75:00`. Text goes in `[brackets]`.\n */\n private static formatFace(opts: { milliseconds: number; pattern: string }): string {\n const { pattern } = opts;\n const parts = TemporalDuration.parts({ milliseconds: opts.milliseconds });\n let remaining =\n ((parts.days * 24 + parts.hours) * 60 + parts.minutes) * MINUTE_MILLISECONDS +\n parts.seconds * SECOND_MILLISECONDS +\n parts.milliseconds;\n\n let text = parts.isNegative ? '-' : '';\n let position = 0;\n\n while (position < pattern.length) {\n const character = pattern[position];\n\n if (character === '[') {\n const close = pattern.indexOf(']', position + 1);\n\n if (close < 0) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalDuration] unclosed [ in pattern '${pattern}'`,\n });\n }\n\n text += pattern.slice(position + 1, close);\n position = close + 1;\n continue;\n }\n\n let runEnd = position + 1;\n\n while (pattern[runEnd] === character) {\n runEnd += 1;\n }\n\n const run = pattern.slice(position, runEnd);\n const token = FACE_TOKENS.get(run);\n\n if (token === undefined) {\n if (/[A-Za-z]/.test(character)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[TemporalDuration] unknown token '${run}' in pattern '${pattern}' | Supported: ${[...FACE_TOKENS.keys()].join(' ')}; wrap text in [brackets]`,\n });\n }\n\n text += run;\n position = runEnd;\n continue;\n }\n\n const amount = Math.floor(remaining / token.milliseconds);\n remaining -= amount * token.milliseconds;\n text += String(amount).padStart(token.width, '0');\n position = runEnd;\n }\n\n return text;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/modules/temporal/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAapG,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,+GAA+G;AAC/G,MAAM,QAAQ,GACZ,uHAAuH,CAAC;AAE1H,8EAA8E;AAC9E,MAAM,UAAU,GAAG,6CAA6C,CAAC;AAEjE,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,6DAA6D;AAC7D,MAAM,WAAW,GAAG,CAAC,kBAAkB,CAAC;AACxC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,4DAA4D;AAC5D,MAAM,SAAS,GAA2C;IACxD,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;IACxB,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1B,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE;CACzB,CAAC;AAEF,0FAA0F;AAC1F,MAAM,YAAY,GAAmD;IACnE,IAAI,EAAE,C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aAAa,CAAC,IAA8B;QAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,IAQd;QACC,MAAM,MAAM,GACV,IAAI,CAAC,MAAM,KAAK,SAAS;YACvB,CAAC,CAAC,IAAI,CAAC,MAAM;YACb,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC,MAAM,CAAC;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM;SACP,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport { AbstractTemporalHelper } from './abstract';\nimport { TemporalCalendar } from './calendar';\nimport { DEFAULT_TEMPORAL_PATTERN, TemporalInclusivities, TemporalUnits } from './common/constants';\nimport type {\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './common/constants';\nimport type {\n ITemporalDurationParts,\n ITemporalParts,\n TRelativeUnit,\n TTemporalFields,\n TTemporalInput,\n} from './common/types';\nimport { TemporalDuration } from './duration';\nimport { TemporalPattern } from './pattern';\n\n/** `2026-09-19`, `2026-09-19T12:00`, `2026-09-19 12:00:00.021+07:00`, `...Z` - an offset only after a time. */\nconst ISO_8601 =\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,9}))?)?(Z|[+-]\\d{2}(?::?\\d{2}(?::?\\d{2})?)?)?)?$/i;\n\n/** The offset of an ISO 8601 value: `+07`, `+07:00`, `+0700`, `+07:06:40`. */\nconst ISO_OFFSET = /^([+-])(\\d{2})(?::?(\\d{2})(?::?(\\d{2}))?)?$/;\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\n/** Months in each calendar unit `diff` counts by months. */\nconst MONTHS_IN: Partial<Record<TTemporalUnit, number>> = {\n [TemporalUnits.MONTH]: 1,\n [TemporalUnits.QUARTER]: 3,\n [TemporalUnits.YEAR]: 12,\n};\n\n/** What each wall-clock field `set` takes. The day is clamped to the month separately. */\nconst FIELD_RANGES: Record<keyof ITemporalParts, [number, number]> = {\n year: [TemporalCalendar.MIN_YEAR, TemporalCalendar.MAX_YEAR],\n month: [1, 12],\n day: [1, 31],\n hour: [0, 23],\n minute: [0, 59],\n second: [0, 59],\n millisecond: [0, 999],\n};\n\n/** `formatIntl` builds one formatter per locale, options and zone; capped so caller-fed options cannot grow it. */\nconst MAX_INTL_FORMATTERS = 128;\n\n/** `relative` without a unit says it in the largest whole one, down to seconds. */\nconst RELATIVE_UNITS: Array<TRelativeUnit> = [\n TemporalUnits.YEAR,\n TemporalUnits.MONTH,\n TemporalUnits.WEEK,\n TemporalUnits.DAY,\n TemporalUnits.HOUR,\n TemporalUnits.MINUTE,\n TemporalUnits.SECOND,\n];\n\n/**\n * Dates in one time zone, through whichever library you choose: pass an adapter - the runtime's\n * `Temporal` (the default where the runtime has it, `Intl` everywhere else), your own dayjs, your own Luxon. The adapter only reports a zone's UTC\n * offset at an instant; the wall clock, daylight-saving gaps and repeats, and the calendar math all\n * live here, so every adapter shares one behaviour.\n *\n * Values go in as a `Date`, epoch milliseconds or an ISO 8601 string, and come out as a `Date`, so\n * swapping the adapter never touches a call site. The zone is yours to set: without one this helper\n * computes in UTC, never in the host's zone. Years run from 1 to 9999.\n */\nexport class TemporalHelper extends AbstractTemporalHelper {\n private static readonly intlFormatters = new Map<string, Intl.DateTimeFormat>();\n\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 return this.moveWallClock({\n value: opts.value,\n from: opts.sourceTz ?? TemporalHelper.getHostTz(),\n to: this.resolveTz({ tz: opts.tz }),\n });\n }\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 return this.moveWallClock({\n value: opts.value,\n from: this.resolveTz({ tz: opts.tz }),\n to: opts.targetTz ?? TemporalHelper.getHostTz(),\n });\n }\n\n /** A helper like this one, with another locale or zone: same adapter, `names` and `fallback`. */\n clone(opts: { locale?: string; tz?: string }): TemporalHelper {\n return new TemporalHelper({\n adapter: this.adapter,\n tz: opts.tz ?? this.tz,\n locale: opts.locale ?? this.locale,\n names: this.names,\n fallback: this.fallback,\n scope: this.scope,\n });\n }\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 const { value, pattern } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n\n const read = pattern ? TemporalPattern.parse({ pattern, value }) : this.readIso({ value });\n if (!read) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: pattern\n ? `[TemporalHelper] '${value}' does not match pattern '${pattern}'`\n : `[TemporalHelper] '${value}' is not ISO 8601 | Pass a pattern for any other shape`,\n });\n }\n\n if (!TemporalCalendar.isRealDateTime({ parts: read.parts })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] '${value}' is not a real date and time`,\n });\n }\n\n const epoch =\n read.offsetMilliseconds === undefined\n ? this.earliestOf({ parts: read.parts, tz })\n : TemporalCalendar.epochAtOffset({\n parts: read.parts,\n offsetMilliseconds: read.offsetMilliseconds,\n });\n return TemporalHelper.ensureInstant({ epoch });\n }\n\n private readIso(opts: {\n value: string;\n }): { parts: ITemporalParts; offsetMilliseconds?: number } | undefined {\n const match = ISO_8601.exec(opts.value);\n if (!match) {\n return undefined;\n }\n\n const [, year, month, day, hour, minute, second, fraction, offset] = match;\n const parts: ITemporalParts = {\n year: Number(year),\n month: Number(month),\n day: Number(day),\n hour: Number(hour ?? 0),\n minute: Number(minute ?? 0),\n second: Number(second ?? 0),\n millisecond: Number((fraction ?? '0').padEnd(3, '0').slice(0, 3)),\n };\n\n if (!offset) {\n return { parts };\n }\n if (offset.toUpperCase() === 'Z') {\n return { parts, offsetMilliseconds: 0 };\n }\n\n const [, sign, offsetHours, offsetMinutes, offsetSeconds] = ISO_OFFSET.exec(offset) ?? [];\n const hours = Number(offsetHours);\n const minutes = Number(offsetMinutes ?? 0);\n const seconds = Number(offsetSeconds ?? 0);\n if (!(hours <= 23 && minutes <= 59 && seconds <= 59)) {\n return undefined;\n }\n\n const milliseconds = ((hours * 60 + minutes) * 60 + seconds) * 1000;\n return { parts, offsetMilliseconds: sign === '-' ? -milliseconds : milliseconds };\n }\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 // Outside the try: a bad zone is the caller's bug, as a broken pattern is.\n const tz = this.resolveTz({ tz: opts.tz });\n try {\n return this.parse({ ...opts, tz });\n } catch (error) {\n if (TemporalHelper.isRefusal(error)) {\n return null;\n }\n throw error;\n }\n }\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 const { value, pattern, tz } = opts;\n if (typeof value === 'string') {\n return this.tryParse({ value, pattern, tz }) !== null;\n }\n if (!(value instanceof Date) && typeof value !== 'number') {\n return false;\n }\n\n const epoch = value instanceof Date ? value.getTime() : value;\n return epoch >= MIN_INSTANT && epoch <= MAX_INSTANT;\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const locale = opts.locale ?? this.locale;\n\n const date = this.readDate({ value: opts.value, tz, fallback: opts.fallback });\n if (date === null) {\n return opts.fallback ?? this.fallback ?? '';\n }\n\n return TemporalPattern.format({\n pattern: opts.pattern ?? DEFAULT_TEMPORAL_PATTERN,\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n locale,\n names: this.namesOf({ locale }),\n });\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n const date = this.readDate({ value: opts.value, tz, fallback: opts.fallback });\n if (date === null) {\n return opts.fallback ?? this.fallback ?? '';\n }\n\n const key = `${locale}|${tz}|${JSON.stringify(opts.options ?? {})}`;\n let formatter = TemporalHelper.intlFormatters.get(key);\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, { ...opts.options, timeZone: tz });\n if (TemporalHelper.intlFormatters.size < MAX_INTL_FORMATTERS) {\n TemporalHelper.intlFormatters.set(key, formatter);\n }\n }\n return formatter.format(date);\n }\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 const { amount, unit } = opts;\n TemporalHelper.ensureUnit({ unit, amount });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n if (amount === 0) {\n return date;\n }\n\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n if (exact !== undefined) {\n return TemporalHelper.ensureInstant({ epoch: date.getTime() + amount * exact });\n }\n\n const parts = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n });\n const shifted = TemporalCalendar.shift({ parts, amount, unit });\n TemporalHelper.ensureYear({ parts: shifted });\n\n return TemporalHelper.ensureInstant({ epoch: this.earliestOf({ parts: shifted, tz }) });\n }\n\n subtract(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date {\n return this.add({ ...opts, amount: -opts.amount });\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n if (unit === TemporalUnits.MILLISECOND) {\n return date;\n }\n\n const { start } = this.unitBounds({ epoch: date.getTime(), unit, tz });\n return TemporalHelper.ensureInstant({ epoch: start });\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n if (unit === TemporalUnits.MILLISECOND) {\n return date;\n }\n\n const { end } = this.unitBounds({ epoch: date.getTime(), unit, tz });\n return TemporalHelper.ensureInstant({ epoch: end - 1 });\n }\n\n /** Monday to Friday, read on the wall clock of the zone. */\n isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean {\n return this.parts(opts).dayOfWeek <= 5;\n }\n\n nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date {\n return this.stepToWeekday({ ...opts, step: 1 });\n }\n\n previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date {\n return this.stepToWeekday({ ...opts, step: -1 });\n }\n\n private stepToWeekday(opts: { value: TTemporalInput; tz?: string; step: number }): Date {\n let candidate = this.add({\n value: opts.value,\n amount: opts.step,\n unit: TemporalUnits.DAY,\n tz: opts.tz,\n });\n\n while (!this.isWeekday({ value: candidate, tz: opts.tz })) {\n candidate = this.add({\n value: candidate,\n amount: opts.step,\n unit: TemporalUnits.DAY,\n tz: opts.tz,\n });\n }\n return candidate;\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n const wall = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n });\n\n const next: ITemporalParts = { ...wall };\n for (const [field, [min, max]] of Object.entries(FIELD_RANGES)) {\n const given: unknown = Reflect.get(opts, field);\n if (given === undefined) {\n continue;\n }\n if (typeof given !== 'number' || !Number.isInteger(given) || given < min || given > max) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] ${field} must be an integer from ${min} to ${max} - received ${String(given)}`,\n });\n }\n Reflect.set(next, field, given);\n }\n next.day = Math.min(\n next.day,\n TemporalCalendar.daysInMonth({ year: next.year, month: next.month }),\n );\n\n return TemporalHelper.ensureInstant({ epoch: this.earliestOf({ parts: next, tz }) });\n }\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 return this.compare(opts) < 0;\n }\n\n isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) > 0;\n }\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 return this.compare(opts) === 0;\n }\n\n isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) <= 0;\n }\n\n isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) >= 0;\n }\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 const { value, from, to, unit, inclusivity = TemporalInclusivities.EXCLUSIVE, tz } = opts;\n if (!TemporalInclusivities.isValid(inclusivity)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] unknown inclusivity '${inclusivity}' | Supported: ${[...TemporalInclusivities.SCHEME_SET].join(', ')}`,\n });\n }\n\n const isStartIncluded = inclusivity.startsWith('[');\n const isEndIncluded = inclusivity.endsWith(']');\n const fromOrder = this.compare({ value, other: from, unit, tz });\n const toOrder = this.compare({ value, other: to, unit, tz });\n\n const isAfterStart = isStartIncluded ? fromOrder >= 0 : fromOrder > 0;\n const isBeforeEnd = isEndIncluded ? toOrder <= 0 : toOrder < 0;\n // The range given backwards: `to` is the earlier end.\n const isAfterEnd = isEndIncluded ? toOrder >= 0 : toOrder > 0;\n const isBeforeStart = isStartIncluded ? fromOrder <= 0 : fromOrder < 0;\n return (isAfterStart && isBeforeEnd) || (isAfterEnd && isBeforeStart);\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const value = this.toDate({ value: opts.value, tz }).getTime();\n const other = this.toDate({ value: opts.other, tz }).getTime();\n\n // `+ 0` turns a truncated `-0` into `0`.\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n if (exact !== undefined) {\n return Math.trunc((value - other) / exact) + 0;\n }\n\n const months = MONTHS_IN[unit];\n if (months !== undefined) {\n return Math.trunc(this.monthGap({ value, other, tz }) / months) + 0;\n }\n\n const wallClocks =\n TemporalCalendar.epochAtOffset({\n parts: TemporalCalendar.wallClockOf({ parts: this.zonedParts({ epoch: value, tz }) }),\n offsetMilliseconds: 0,\n }) -\n TemporalCalendar.epochAtOffset({\n parts: TemporalCalendar.wallClockOf({ parts: this.zonedParts({ epoch: other, tz }) }),\n offsetMilliseconds: 0,\n });\n const days = wallClocks / DAY_MILLISECONDS;\n return Math.trunc(unit === TemporalUnits.WEEK ? days / 7 : days) + 0;\n }\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 const { unit } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n\n const value =\n unit === undefined\n ? this.toDate({ value: opts.value, tz })\n : this.startOf({ value: opts.value, unit, tz });\n const other =\n unit === undefined\n ? this.toDate({ value: opts.other, tz })\n : this.startOf({ value: opts.other, unit, tz });\n\n const delta = value.getTime() - other.getTime();\n return delta < 0 ? -1 : delta > 0 ? 1 : 0;\n }\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 const { unit, numeric = 'always', style = 'long' } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n const value = this.toDate({ value: opts.value, tz });\n const base = opts.base === undefined ? this.now() : this.toDate({ value: opts.base, tz });\n\n let amount = 0;\n let said: TRelativeUnit = TemporalUnits.SECOND;\n if (unit !== undefined) {\n TemporalHelper.ensureUnit({ unit });\n if (unit === TemporalUnits.MILLISECOND) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: '[TemporalHelper] relative time has no millisecond unit | Use second or larger',\n });\n }\n amount = this.diff({\n value: this.startOf({ value, unit, tz }),\n other: this.startOf({ value: base, unit, tz }),\n unit,\n tz,\n });\n said = unit;\n } else {\n for (const candidate of RELATIVE_UNITS) {\n const counted = this.diff({ value, other: base, unit: candidate, tz });\n if (counted !== 0 || candidate === TemporalUnits.SECOND) {\n amount = counted;\n said = candidate;\n break;\n }\n }\n }\n\n return new Intl.RelativeTimeFormat(locale, { numeric, style }).format(amount, said);\n }\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 return TemporalDuration.parts(opts);\n }\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 const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n return TemporalDuration.format({\n milliseconds: opts.milliseconds,\n style: opts.style,\n pattern: opts.pattern,\n maxUnits: opts.maxUnits,\n locale,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/modules/temporal/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAapG,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,+GAA+G;AAC/G,MAAM,QAAQ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AM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC;gBAEvE,IAAI,OAAO,KAAK,CAAC,IAAI,SAAS,KAAK,aAAa,CAAC,MAAM,EAAE,CAAC;oBACxD,MAAM,GAAG,OAAO,CAAC;oBACjB,IAAI,GAAG,SAAS,CAAC;oBACjB,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACtF,CAAC;IAED,mGAAmG;IACnG,aAAa,CAAC,IAA8B;QAC1C,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,cAAc,CAAC,IAQd;QACC,MAAM,MAAM,GACV,IAAI,CAAC,MAAM,KAAK,SAAS;YACvB,CAAC,CAAC,IAAI,CAAC,MAAM;YACb,CAAC,CAAC,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;QAE3D,OAAO,gBAAgB,CAAC,MAAM,CAAC;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM;SACP,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport { AbstractTemporalHelper } from './abstract';\nimport { TemporalCalendar } from './calendar';\nimport { DEFAULT_TEMPORAL_PATTERN, TemporalInclusivities, TemporalUnits } from './common/constants';\nimport type {\n TTemporalDurationStyle,\n TTemporalInclusivity,\n TTemporalUnit,\n} from './common/constants';\nimport type {\n ITemporalDurationParts,\n ITemporalParts,\n TRelativeUnit,\n TTemporalFields,\n TTemporalInput,\n} from './common/types';\nimport { TemporalDuration } from './duration';\nimport { TemporalPattern } from './pattern';\n\n/** `2026-09-19`, `2026-09-19T12:00`, `2026-09-19 12:00:00.021+07:00`, `...Z` - an offset only after a time. */\nconst ISO_8601 =\n /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2})(?:\\.(\\d{1,9}))?)?(Z|[+-]\\d{2}(?::?\\d{2}(?::?\\d{2})?)?)?)?$/i;\n\n/** The offset of an ISO 8601 value: `+07`, `+07:00`, `+0700`, `+07:06:40`. */\nconst ISO_OFFSET = /^([+-])(\\d{2})(?::?(\\d{2})(?::?(\\d{2}))?)?$/;\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\n/** Months in each calendar unit `diff` counts by months. */\nconst MONTHS_IN: Partial<Record<TTemporalUnit, number>> = {\n [TemporalUnits.MONTH]: 1,\n [TemporalUnits.QUARTER]: 3,\n [TemporalUnits.YEAR]: 12,\n};\n\n/** What each wall-clock field `set` takes. The day is clamped to the month separately. */\nconst FIELD_RANGES: Record<keyof ITemporalParts, [number, number]> = {\n year: [TemporalCalendar.MIN_YEAR, TemporalCalendar.MAX_YEAR],\n month: [1, 12],\n day: [1, 31],\n hour: [0, 23],\n minute: [0, 59],\n second: [0, 59],\n millisecond: [0, 999],\n};\n\n/** `formatIntl` builds one formatter per locale, options and zone; capped so caller-fed options cannot grow it. */\nconst MAX_INTL_FORMATTERS = 128;\n\n/** `relative` without a unit says it in the largest whole one, down to seconds. */\nconst RELATIVE_UNITS: Array<TRelativeUnit> = [\n TemporalUnits.YEAR,\n TemporalUnits.MONTH,\n TemporalUnits.WEEK,\n TemporalUnits.DAY,\n TemporalUnits.HOUR,\n TemporalUnits.MINUTE,\n TemporalUnits.SECOND,\n];\n\n/**\n * Dates in one time zone, through whichever library you choose: pass an adapter - the runtime's\n * `Temporal` (the default where the runtime has it, `Intl` everywhere else), your own dayjs, your own Luxon. The adapter only reports a zone's UTC\n * offset at an instant; the wall clock, daylight-saving gaps and repeats, and the calendar math all\n * live here, so every adapter shares one behaviour.\n *\n * Values go in as a `Date`, epoch milliseconds or an ISO 8601 string, and come out as a `Date`, so\n * swapping the adapter never touches a call site. The zone is yours to set: without one this helper\n * computes in UTC, never in the host's zone. Years run from 1 to 9999.\n */\nexport class TemporalHelper extends AbstractTemporalHelper {\n private static readonly intlFormatters = new Map<string, Intl.DateTimeFormat>();\n\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 return this.moveWallClock({\n value: opts.value,\n from: opts.sourceTz ?? TemporalHelper.getHostTz(),\n to: this.resolveTz({ tz: opts.tz }),\n });\n }\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 return this.moveWallClock({\n value: opts.value,\n from: this.resolveTz({ tz: opts.tz }),\n to: opts.targetTz ?? TemporalHelper.getHostTz(),\n });\n }\n\n /** A helper like this one, with another locale or zone: same adapter, `names` and `fallback`. */\n clone(opts: { locale?: string; tz?: string }): TemporalHelper {\n return new TemporalHelper({\n adapter: this.adapter,\n tz: opts.tz ?? this.tz,\n locale: opts.locale ?? this.locale,\n names: this.names,\n fallback: this.fallback,\n scope: this.scope,\n });\n }\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 const { value, pattern } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n\n const read = pattern ? TemporalPattern.parse({ pattern, value }) : this.readIso({ value });\n\n if (!read) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: pattern\n ? `[TemporalHelper] '${value}' does not match pattern '${pattern}'`\n : `[TemporalHelper] '${value}' is not ISO 8601 | Pass a pattern for any other shape`,\n });\n }\n\n if (!TemporalCalendar.isRealDateTime({ parts: read.parts })) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] '${value}' is not a real date and time`,\n });\n }\n\n const epoch =\n read.offsetMilliseconds === undefined\n ? this.earliestOf({ parts: read.parts, tz })\n : TemporalCalendar.epochAtOffset({\n parts: read.parts,\n offsetMilliseconds: read.offsetMilliseconds,\n });\n\n return TemporalHelper.ensureInstant({ epoch });\n }\n\n private readIso(opts: {\n value: string;\n }): { parts: ITemporalParts; offsetMilliseconds?: number } | undefined {\n const match = ISO_8601.exec(opts.value);\n\n if (!match) {\n return undefined;\n }\n\n const [, year, month, day, hour, minute, second, fraction, offset] = match;\n const parts: ITemporalParts = {\n year: Number(year),\n month: Number(month),\n day: Number(day),\n hour: Number(hour ?? 0),\n minute: Number(minute ?? 0),\n second: Number(second ?? 0),\n millisecond: Number((fraction ?? '0').padEnd(3, '0').slice(0, 3)),\n };\n\n if (!offset) {\n return { parts };\n }\n\n if (offset.toUpperCase() === 'Z') {\n return { parts, offsetMilliseconds: 0 };\n }\n\n const [, sign, offsetHours, offsetMinutes, offsetSeconds] = ISO_OFFSET.exec(offset) ?? [];\n const hours = Number(offsetHours);\n const minutes = Number(offsetMinutes ?? 0);\n const seconds = Number(offsetSeconds ?? 0);\n\n if (!(hours <= 23 && minutes <= 59 && seconds <= 59)) {\n return undefined;\n }\n\n const milliseconds = ((hours * 60 + minutes) * 60 + seconds) * 1000;\n\n return { parts, offsetMilliseconds: sign === '-' ? -milliseconds : milliseconds };\n }\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 // Outside the try: a bad zone is the caller's bug, as a broken pattern is.\n const tz = this.resolveTz({ tz: opts.tz });\n\n try {\n return this.parse({ ...opts, tz });\n } catch (error) {\n if (TemporalHelper.isRefusal(error)) {\n return null;\n }\n\n throw error;\n }\n }\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 const { value, pattern, tz } = opts;\n\n if (typeof value === 'string') {\n return this.tryParse({ value, pattern, tz }) !== null;\n }\n\n if (!(value instanceof Date) && typeof value !== 'number') {\n return false;\n }\n\n const epoch = value instanceof Date ? value.getTime() : value;\n\n return epoch >= MIN_INSTANT && epoch <= MAX_INSTANT;\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const locale = opts.locale ?? this.locale;\n\n const date = this.readDate({ value: opts.value, tz, fallback: opts.fallback });\n\n if (date === null) {\n return opts.fallback ?? this.fallback ?? '';\n }\n\n return TemporalPattern.format({\n pattern: opts.pattern ?? DEFAULT_TEMPORAL_PATTERN,\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n locale,\n names: this.namesOf({ locale }),\n });\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n const date = this.readDate({ value: opts.value, tz, fallback: opts.fallback });\n\n if (date === null) {\n return opts.fallback ?? this.fallback ?? '';\n }\n\n const key = `${locale}|${tz}|${JSON.stringify(opts.options ?? {})}`;\n let formatter = TemporalHelper.intlFormatters.get(key);\n\n if (!formatter) {\n formatter = new Intl.DateTimeFormat(locale, { ...opts.options, timeZone: tz });\n\n if (TemporalHelper.intlFormatters.size < MAX_INTL_FORMATTERS) {\n TemporalHelper.intlFormatters.set(key, formatter);\n }\n }\n\n return formatter.format(date);\n }\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 const { amount, unit } = opts;\n TemporalHelper.ensureUnit({ unit, amount });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n\n if (amount === 0) {\n return date;\n }\n\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n\n if (exact !== undefined) {\n return TemporalHelper.ensureInstant({ epoch: date.getTime() + amount * exact });\n }\n\n const parts = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n });\n const shifted = TemporalCalendar.shift({ parts, amount, unit });\n TemporalHelper.ensureYear({ parts: shifted });\n\n return TemporalHelper.ensureInstant({ epoch: this.earliestOf({ parts: shifted, tz }) });\n }\n\n subtract(opts: {\n value: TTemporalInput;\n amount: number;\n unit: TTemporalUnit;\n tz?: string;\n }): Date {\n return this.add({ ...opts, amount: -opts.amount });\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n\n if (unit === TemporalUnits.MILLISECOND) {\n return date;\n }\n\n const { start } = this.unitBounds({ epoch: date.getTime(), unit, tz });\n\n return TemporalHelper.ensureInstant({ epoch: start });\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n\n if (unit === TemporalUnits.MILLISECOND) {\n return date;\n }\n\n const { end } = this.unitBounds({ epoch: date.getTime(), unit, tz });\n\n return TemporalHelper.ensureInstant({ epoch: end - 1 });\n }\n\n /** Monday to Friday, read on the wall clock of the zone. */\n isWeekday(opts: { value: TTemporalInput; tz?: string }): boolean {\n return this.parts(opts).dayOfWeek <= 5;\n }\n\n nextWeekday(opts: { value: TTemporalInput; tz?: string }): Date {\n return this.stepToWeekday({ ...opts, step: 1 });\n }\n\n previousWeekday(opts: { value: TTemporalInput; tz?: string }): Date {\n return this.stepToWeekday({ ...opts, step: -1 });\n }\n\n private stepToWeekday(opts: { value: TTemporalInput; tz?: string; step: number }): Date {\n let candidate = this.add({\n value: opts.value,\n amount: opts.step,\n unit: TemporalUnits.DAY,\n tz: opts.tz,\n });\n\n while (!this.isWeekday({ value: candidate, tz: opts.tz })) {\n candidate = this.add({\n value: candidate,\n amount: opts.step,\n unit: TemporalUnits.DAY,\n tz: opts.tz,\n });\n }\n\n return candidate;\n }\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 const tz = this.resolveTz({ tz: opts.tz });\n const date = this.toDate({ value: opts.value, tz });\n const wall = TemporalCalendar.wallClockOf({\n parts: this.zonedParts({ epoch: date.getTime(), tz }),\n });\n\n const next: ITemporalParts = { ...wall };\n\n for (const [field, [min, max]] of Object.entries(FIELD_RANGES)) {\n const given: unknown = Reflect.get(opts, field);\n\n if (given === undefined) {\n continue;\n }\n\n if (typeof given !== 'number' || !Number.isInteger(given) || given < min || given > max) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] ${field} must be an integer from ${min} to ${max} - received ${String(given)}`,\n });\n }\n\n Reflect.set(next, field, given);\n }\n\n next.day = Math.min(\n next.day,\n TemporalCalendar.daysInMonth({ year: next.year, month: next.month }),\n );\n\n return TemporalHelper.ensureInstant({ epoch: this.earliestOf({ parts: next, tz }) });\n }\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 return this.compare(opts) < 0;\n }\n\n isAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) > 0;\n }\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 return this.compare(opts) === 0;\n }\n\n isSameOrBefore(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) <= 0;\n }\n\n isSameOrAfter(opts: {\n value: TTemporalInput;\n other: TTemporalInput;\n unit?: TTemporalUnit;\n tz?: string;\n }): boolean {\n return this.compare(opts) >= 0;\n }\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 const { value, from, to, unit, inclusivity = TemporalInclusivities.EXCLUSIVE, tz } = opts;\n\n if (!TemporalInclusivities.isValid(inclusivity)) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalHelper] unknown inclusivity '${inclusivity}' | Supported: ${[...TemporalInclusivities.SCHEME_SET].join(', ')}`,\n });\n }\n\n const isStartIncluded = inclusivity.startsWith('[');\n const isEndIncluded = inclusivity.endsWith(']');\n const fromOrder = this.compare({ value, other: from, unit, tz });\n const toOrder = this.compare({ value, other: to, unit, tz });\n\n const isAfterStart = isStartIncluded ? fromOrder >= 0 : fromOrder > 0;\n const isBeforeEnd = isEndIncluded ? toOrder <= 0 : toOrder < 0;\n // The range given backwards: `to` is the earlier end.\n const isAfterEnd = isEndIncluded ? toOrder >= 0 : toOrder > 0;\n const isBeforeStart = isStartIncluded ? fromOrder <= 0 : fromOrder < 0;\n\n return (isAfterStart && isBeforeEnd) || (isAfterEnd && isBeforeStart);\n }\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 const { unit } = opts;\n TemporalHelper.ensureUnit({ unit });\n\n const tz = this.resolveTz({ tz: opts.tz });\n const value = this.toDate({ value: opts.value, tz }).getTime();\n const other = this.toDate({ value: opts.other, tz }).getTime();\n\n // `+ 0` turns a truncated `-0` into `0`.\n const exact = TemporalCalendar.EXACT_UNIT_MILLISECONDS[unit];\n\n if (exact !== undefined) {\n return Math.trunc((value - other) / exact) + 0;\n }\n\n const months = MONTHS_IN[unit];\n\n if (months !== undefined) {\n return Math.trunc(this.monthGap({ value, other, tz }) / months) + 0;\n }\n\n const wallClocks =\n TemporalCalendar.epochAtOffset({\n parts: TemporalCalendar.wallClockOf({ parts: this.zonedParts({ epoch: value, tz }) }),\n offsetMilliseconds: 0,\n }) -\n TemporalCalendar.epochAtOffset({\n parts: TemporalCalendar.wallClockOf({ parts: this.zonedParts({ epoch: other, tz }) }),\n offsetMilliseconds: 0,\n });\n const days = wallClocks / DAY_MILLISECONDS;\n\n return Math.trunc(unit === TemporalUnits.WEEK ? days / 7 : days) + 0;\n }\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 const { unit } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n\n const value =\n unit === undefined\n ? this.toDate({ value: opts.value, tz })\n : this.startOf({ value: opts.value, unit, tz });\n const other =\n unit === undefined\n ? this.toDate({ value: opts.other, tz })\n : this.startOf({ value: opts.other, unit, tz });\n\n const delta = value.getTime() - other.getTime();\n\n return delta < 0 ? -1 : delta > 0 ? 1 : 0;\n }\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 const { unit, numeric = 'always', style = 'long' } = opts;\n const tz = this.resolveTz({ tz: opts.tz });\n const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n const value = this.toDate({ value: opts.value, tz });\n const base = opts.base === undefined ? this.now() : this.toDate({ value: opts.base, tz });\n\n let amount = 0;\n let said: TRelativeUnit = TemporalUnits.SECOND;\n\n if (unit !== undefined) {\n TemporalHelper.ensureUnit({ unit });\n\n if (unit === TemporalUnits.MILLISECOND) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: '[TemporalHelper] relative time has no millisecond unit | Use second or larger',\n });\n }\n\n amount = this.diff({\n value: this.startOf({ value, unit, tz }),\n other: this.startOf({ value: base, unit, tz }),\n unit,\n tz,\n });\n said = unit;\n } else {\n for (const candidate of RELATIVE_UNITS) {\n const counted = this.diff({ value, other: base, unit: candidate, tz });\n\n if (counted !== 0 || candidate === TemporalUnits.SECOND) {\n amount = counted;\n said = candidate;\n break;\n }\n }\n }\n\n return new Intl.RelativeTimeFormat(locale, { numeric, style }).format(amount, said);\n }\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 return TemporalDuration.parts(opts);\n }\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 const locale =\n opts.locale === undefined\n ? this.locale\n : TemporalHelper.ensureLocale({ locale: opts.locale });\n\n return TemporalDuration.format({\n milliseconds: opts.milliseconds,\n style: opts.style,\n pattern: opts.pattern,\n maxUnits: opts.maxUnits,\n locale,\n });\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/locale/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,yBAAyB,GAI1B,MAAM,qBAAqB,CAAC;AAG7B,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAE9B,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,QAAQ,GAAG,CAAC,CAAC;AACnB,MAAM,IAAI,GAAG,EAAE,CAAC;AAEhB,gEAAgE;AAChE,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACpC,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC;;;;GAIG;AACH,MAAM,OAAO,cAAc;aACD,YAAO,GAAG,IAAI,GAAG,EAA0B,AAApC,CAAqC;IAMpE,YAAoB,IAAwB;QAH3B,WAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC1C,eAAU,GAAG,IAAI,GAAG,EAA+B,CAAC;QAGnE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,oDAAoD;IACpD,MAAM,CAAC,EAAE,CAAC,IAAwB;QAChC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAClD,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,IAAI,CAAC;YACH,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACnC,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,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAC3E,CAAC;IAED,iHAAiH;IACjH,WAAW,CAAC,IAAiE;QAC3E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAC9B,MAAM,SAAS,GACb,KAAK,KAAK,yBAAyB,CAAC,OAAO;YACzC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACzE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport {\n TemporalWrittenDateStyles,\n type TTemporalMonthNameWidth,\n type TTemporalNameWidth,\n type TTemporalWrittenDateStyle,\n} from '../common/constants';\nimport type { ITemporalParts } from '../common/types';\n\n/** A service writes a handful of locales; capped so caller-fed locales cannot grow it. */\nconst MAX_CACHED_LOCALES = 32;\n\nconst MONTHS = 12;\nconst WEEKDAYS = 7;\nconst NOON = 12;\n\n/** A Monday: ISO weekday `n` is this date plus `n - 1` days. */\nconst MONDAY = Date.UTC(2024, 0, 1);\nconst DAY_MILLISECONDS = 86_400_000;\n\n/**\n * Month and weekday names, the AM/PM marker and the written date of one locale, as `Intl` spells\n * them. Every table is read once, on first use, from a fixed UTC date: the names belong to the\n * calendar, not to a time zone, so the wall clock is formatted as if it were UTC.\n */\nexport class TemporalLocale {\n private static readonly locales = new Map<string, TemporalLocale>();\n\n private readonly locale: string;\n private readonly tables = new Map<string, Array<string>>();\n private readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private constructor(opts: { locale: string }) {\n this.locale = opts.locale;\n }\n\n /** The locale's names; a malformed tag is a 400. */\n static of(opts: { locale: string }): TemporalLocale {\n const { locale } = opts;\n const cached = TemporalLocale.locales.get(locale);\n if (cached) {\n return cached;\n }\n\n try {\n Intl.getCanonicalLocales(locale);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalLocale] invalid locale '${locale}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Full: the oldest locale makes room, so the 33rd locale is not rebuilt on every call.\n if (TemporalLocale.locales.size >= MAX_CACHED_LOCALES) {\n const oldest = TemporalLocale.locales.keys().next().value;\n if (oldest !== undefined) {\n TemporalLocale.locales.delete(oldest);\n }\n }\n const created = new TemporalLocale({ locale });\n TemporalLocale.locales.set(locale, created);\n return created;\n }\n\n private formatterOf(opts: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify(opts);\n const cached = this.formatters.get(key);\n if (cached) {\n return cached;\n }\n\n // Gregorian always: the numeric tokens are, and a name from another calendar would sit beside them.\n const formatter = new Intl.DateTimeFormat(this.locale, {\n ...opts,\n calendar: 'gregory',\n timeZone: 'UTC',\n });\n this.formatters.set(key, formatter);\n return formatter;\n }\n\n private tableOf(opts: {\n key: string;\n size: number;\n read: (index: number) => string;\n }): Array<string> {\n const cached = this.tables.get(opts.key);\n if (cached) {\n return cached;\n }\n\n const table = Array.from({ length: opts.size }, (_, index) => opts.read(index));\n this.tables.set(opts.key, table);\n return table;\n }\n\n /** `month` is 1-12. */\n monthName(opts: { month: number; width: TTemporalMonthNameWidth }): string {\n const { month, width } = opts;\n const formatter = this.formatterOf({ month: width });\n const table = this.tableOf({\n key: `month-${width}`,\n size: MONTHS,\n read: (index) => formatter.format(Date.UTC(2024, index, 15)),\n });\n return table[month - 1];\n }\n\n /** `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\n weekdayName(opts: { dayOfWeek: number; width: TTemporalNameWidth }): string {\n const { dayOfWeek, width } = opts;\n const formatter = this.formatterOf({ weekday: width });\n const table = this.tableOf({\n key: `weekday-${width}`,\n size: WEEKDAYS,\n read: (index) => formatter.format(MONDAY + index * DAY_MILLISECONDS),\n });\n return table[dayOfWeek - 1];\n }\n\n /** The AM or PM marker the locale writes for `hour` (0-23), lower-cased by the locale's own rules when asked. */\n dayPeriod(opts: {\n hour: number;\n meridiem?: readonly [string, string];\n isLowerCase?: boolean;\n }): string {\n const formatter = this.formatterOf({ hour: 'numeric', hourCycle: 'h12' });\n const table = this.tableOf({\n key: 'day-period',\n size: 2,\n read: (index) =>\n formatter\n .formatToParts(Date.UTC(2024, 0, 1, index === 0 ? 1 : NOON + 1))\n .find((part) => part.type === 'dayPeriod')?.value ?? (index === 0 ? 'AM' : 'PM'),\n });\n const marker = (opts.meridiem ?? table)[opts.hour < NOON ? 0 : 1];\n return opts.isLowerCase ? marker.toLocaleLowerCase(this.locale) : marker;\n }\n\n /** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */\n writtenDate(opts: { parts: ITemporalParts; style: TTemporalWrittenDateStyle }): string {\n const { parts, style } = opts;\n const formatter =\n style === TemporalWrittenDateStyles.NUMERIC\n ? this.formatterOf({ year: 'numeric', month: '2-digit', day: '2-digit' })\n : this.formatterOf({ dateStyle: 'long' });\n\n const date = new Date(0);\n date.setUTCFullYear(parts.year, parts.month - 1, parts.day);\n return formatter.format(date);\n }\n}\n"]}
1
+ {"version":3,"file":"locale.js","sourceRoot":"","sources":["../../../../../src/modules/temporal/locale/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EACL,y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AAE,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;YACzE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;QAE9C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QAE5D,OAAO,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC","sourcesContent":["import { HTTP } from '@/common/constants/http';\nimport { getError } from '@/modules/error';\nimport {\n TemporalWrittenDateStyles,\n type TTemporalMonthNameWidth,\n type TTemporalNameWidth,\n type TTemporalWrittenDateStyle,\n} from '../common/constants';\nimport type { ITemporalParts } from '../common/types';\n\n/** A service writes a handful of locales; capped so caller-fed locales cannot grow it. */\nconst MAX_CACHED_LOCALES = 32;\n\nconst MONTHS = 12;\nconst WEEKDAYS = 7;\nconst NOON = 12;\n\n/** A Monday: ISO weekday `n` is this date plus `n - 1` days. */\nconst MONDAY = Date.UTC(2024, 0, 1);\nconst DAY_MILLISECONDS = 86_400_000;\n\n/**\n * Month and weekday names, the AM/PM marker and the written date of one locale, as `Intl` spells\n * them. Every table is read once, on first use, from a fixed UTC date: the names belong to the\n * calendar, not to a time zone, so the wall clock is formatted as if it were UTC.\n */\nexport class TemporalLocale {\n private static readonly locales = new Map<string, TemporalLocale>();\n\n private readonly locale: string;\n private readonly tables = new Map<string, Array<string>>();\n private readonly formatters = new Map<string, Intl.DateTimeFormat>();\n\n private constructor(opts: { locale: string }) {\n this.locale = opts.locale;\n }\n\n /** The locale's names; a malformed tag is a 400. */\n static of(opts: { locale: string }): TemporalLocale {\n const { locale } = opts;\n const cached = TemporalLocale.locales.get(locale);\n\n if (cached) {\n return cached;\n }\n\n try {\n Intl.getCanonicalLocales(locale);\n } catch (error) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_4.BadRequest,\n message: `[TemporalLocale] invalid locale '${locale}' | ${error instanceof Error ? error.message : String(error)}`,\n });\n }\n\n // Full: the oldest locale makes room, so the 33rd locale is not rebuilt on every call.\n if (TemporalLocale.locales.size >= MAX_CACHED_LOCALES) {\n const oldest = TemporalLocale.locales.keys().next().value;\n\n if (oldest !== undefined) {\n TemporalLocale.locales.delete(oldest);\n }\n }\n\n const created = new TemporalLocale({ locale });\n TemporalLocale.locales.set(locale, created);\n\n return created;\n }\n\n private formatterOf(opts: Intl.DateTimeFormatOptions): Intl.DateTimeFormat {\n const key = JSON.stringify(opts);\n const cached = this.formatters.get(key);\n\n if (cached) {\n return cached;\n }\n\n // Gregorian always: the numeric tokens are, and a name from another calendar would sit beside them.\n const formatter = new Intl.DateTimeFormat(this.locale, {\n ...opts,\n calendar: 'gregory',\n timeZone: 'UTC',\n });\n this.formatters.set(key, formatter);\n\n return formatter;\n }\n\n private tableOf(opts: {\n key: string;\n size: number;\n read: (index: number) => string;\n }): Array<string> {\n const cached = this.tables.get(opts.key);\n\n if (cached) {\n return cached;\n }\n\n const table = Array.from({ length: opts.size }, (_, index) => opts.read(index));\n this.tables.set(opts.key, table);\n\n return table;\n }\n\n /** `month` is 1-12. */\n monthName(opts: { month: number; width: TTemporalMonthNameWidth }): string {\n const { month, width } = opts;\n const formatter = this.formatterOf({ month: width });\n const table = this.tableOf({\n key: `month-${width}`,\n size: MONTHS,\n read: (index) => formatter.format(Date.UTC(2024, index, 15)),\n });\n\n return table[month - 1];\n }\n\n /** `dayOfWeek` is ISO: 1 Monday - 7 Sunday. */\n weekdayName(opts: { dayOfWeek: number; width: TTemporalNameWidth }): string {\n const { dayOfWeek, width } = opts;\n const formatter = this.formatterOf({ weekday: width });\n const table = this.tableOf({\n key: `weekday-${width}`,\n size: WEEKDAYS,\n read: (index) => formatter.format(MONDAY + index * DAY_MILLISECONDS),\n });\n\n return table[dayOfWeek - 1];\n }\n\n /** The AM or PM marker the locale writes for `hour` (0-23), lower-cased by the locale's own rules when asked. */\n dayPeriod(opts: {\n hour: number;\n meridiem?: readonly [string, string];\n isLowerCase?: boolean;\n }): string {\n const formatter = this.formatterOf({ hour: 'numeric', hourCycle: 'h12' });\n const table = this.tableOf({\n key: 'day-period',\n size: 2,\n read: (index) =>\n formatter\n .formatToParts(Date.UTC(2024, 0, 1, index === 0 ? 1 : NOON + 1))\n .find((part) => part.type === 'dayPeriod')?.value ?? (index === 0 ? 'AM' : 'PM'),\n });\n const marker = (opts.meridiem ?? table)[opts.hour < NOON ? 0 : 1];\n\n return opts.isLowerCase ? marker.toLocaleLowerCase(this.locale) : marker;\n }\n\n /** The wall-clock date the way the locale writes it: `numeric` is `10/14/2026`, `long` is `October 14, 2026`. */\n writtenDate(opts: { parts: ITemporalParts; style: TTemporalWrittenDateStyle }): string {\n const { parts, style } = opts;\n const formatter =\n style === TemporalWrittenDateStyles.NUMERIC\n ? this.formatterOf({ year: 'numeric', month: '2-digit', day: '2-digit' })\n : this.formatterOf({ dateStyle: 'long' });\n\n const date = new Date(0);\n date.setUTCFullYear(parts.year, parts.month - 1, parts.day);\n\n return formatter.format(date);\n }\n}\n"]}