promidas 2.0.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 (295) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +179 -0
  3. package/dist/builder.d.ts +158 -0
  4. package/dist/builder.d.ts.map +1 -0
  5. package/dist/builder.js +255 -0
  6. package/dist/builder.js.map +1 -0
  7. package/dist/factory.d.ts +154 -0
  8. package/dist/factory.d.ts.map +1 -0
  9. package/dist/factory.js +243 -0
  10. package/dist/factory.js.map +1 -0
  11. package/dist/fetcher/client/config.d.ts +140 -0
  12. package/dist/fetcher/client/config.d.ts.map +1 -0
  13. package/dist/fetcher/client/config.js +2 -0
  14. package/dist/fetcher/client/config.js.map +1 -0
  15. package/dist/fetcher/client/fetch-with-progress.d.ts +156 -0
  16. package/dist/fetcher/client/fetch-with-progress.d.ts.map +1 -0
  17. package/dist/fetcher/client/fetch-with-progress.js +313 -0
  18. package/dist/fetcher/client/fetch-with-progress.js.map +1 -0
  19. package/dist/fetcher/client/fetch-with-timeout.d.ts +6 -0
  20. package/dist/fetcher/client/fetch-with-timeout.d.ts.map +1 -0
  21. package/dist/fetcher/client/fetch-with-timeout.js +48 -0
  22. package/dist/fetcher/client/fetch-with-timeout.js.map +1 -0
  23. package/dist/fetcher/client/protopedia-api-custom-client.d.ts +141 -0
  24. package/dist/fetcher/client/protopedia-api-custom-client.d.ts.map +1 -0
  25. package/dist/fetcher/client/protopedia-api-custom-client.js +268 -0
  26. package/dist/fetcher/client/protopedia-api-custom-client.js.map +1 -0
  27. package/dist/fetcher/client/select-custom-fetch.d.ts +58 -0
  28. package/dist/fetcher/client/select-custom-fetch.d.ts.map +1 -0
  29. package/dist/fetcher/client/select-custom-fetch.js +58 -0
  30. package/dist/fetcher/client/select-custom-fetch.js.map +1 -0
  31. package/dist/fetcher/errors/fetcher-error.d.ts +10 -0
  32. package/dist/fetcher/errors/fetcher-error.d.ts.map +1 -0
  33. package/dist/fetcher/errors/fetcher-error.js +15 -0
  34. package/dist/fetcher/errors/fetcher-error.js.map +1 -0
  35. package/dist/fetcher/index.d.ts +73 -0
  36. package/dist/fetcher/index.d.ts.map +1 -0
  37. package/dist/fetcher/index.js +70 -0
  38. package/dist/fetcher/index.js.map +1 -0
  39. package/dist/fetcher/types/index.d.ts +9 -0
  40. package/dist/fetcher/types/index.d.ts.map +1 -0
  41. package/dist/fetcher/types/index.js +7 -0
  42. package/dist/fetcher/types/index.js.map +1 -0
  43. package/dist/fetcher/types/progress-event.types.d.ts +221 -0
  44. package/dist/fetcher/types/progress-event.types.d.ts.map +1 -0
  45. package/dist/fetcher/types/progress-event.types.js +10 -0
  46. package/dist/fetcher/types/progress-event.types.js.map +1 -0
  47. package/dist/fetcher/types/prototype-api.types.d.ts +106 -0
  48. package/dist/fetcher/types/prototype-api.types.d.ts.map +1 -0
  49. package/dist/fetcher/types/prototype-api.types.js +2 -0
  50. package/dist/fetcher/types/prototype-api.types.js.map +1 -0
  51. package/dist/fetcher/types/result.types.d.ts +75 -0
  52. package/dist/fetcher/types/result.types.d.ts.map +1 -0
  53. package/dist/fetcher/types/result.types.js +2 -0
  54. package/dist/fetcher/types/result.types.js.map +1 -0
  55. package/dist/fetcher/utils/create-client-fetch.d.ts +63 -0
  56. package/dist/fetcher/utils/create-client-fetch.d.ts.map +1 -0
  57. package/dist/fetcher/utils/create-client-fetch.js +89 -0
  58. package/dist/fetcher/utils/create-client-fetch.js.map +1 -0
  59. package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts +6 -0
  60. package/dist/fetcher/utils/create-fetch-with-stripped-headers.d.ts.map +1 -0
  61. package/dist/fetcher/utils/create-fetch-with-stripped-headers.js +40 -0
  62. package/dist/fetcher/utils/create-fetch-with-stripped-headers.js.map +1 -0
  63. package/dist/fetcher/utils/errors/handler.d.ts +58 -0
  64. package/dist/fetcher/utils/errors/handler.d.ts.map +1 -0
  65. package/dist/fetcher/utils/errors/handler.js +243 -0
  66. package/dist/fetcher/utils/errors/handler.js.map +1 -0
  67. package/dist/fetcher/utils/errors/messages.d.ts +75 -0
  68. package/dist/fetcher/utils/errors/messages.d.ts.map +1 -0
  69. package/dist/fetcher/utils/errors/messages.js +88 -0
  70. package/dist/fetcher/utils/errors/messages.js.map +1 -0
  71. package/dist/fetcher/utils/index.d.ts +13 -0
  72. package/dist/fetcher/utils/index.d.ts.map +1 -0
  73. package/dist/fetcher/utils/index.js +12 -0
  74. package/dist/fetcher/utils/index.js.map +1 -0
  75. package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts +10 -0
  76. package/dist/fetcher/utils/log-timestamp-normalization-warnings.d.ts.map +1 -0
  77. package/dist/fetcher/utils/log-timestamp-normalization-warnings.js +32 -0
  78. package/dist/fetcher/utils/log-timestamp-normalization-warnings.js.map +1 -0
  79. package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts +59 -0
  80. package/dist/fetcher/utils/normalize-protopedia-timestamp.d.ts.map +1 -0
  81. package/dist/fetcher/utils/normalize-protopedia-timestamp.js +81 -0
  82. package/dist/fetcher/utils/normalize-protopedia-timestamp.js.map +1 -0
  83. package/dist/fetcher/utils/normalize-prototype.d.ts +56 -0
  84. package/dist/fetcher/utils/normalize-prototype.d.ts.map +1 -0
  85. package/dist/fetcher/utils/normalize-prototype.js +113 -0
  86. package/dist/fetcher/utils/normalize-prototype.js.map +1 -0
  87. package/dist/fetcher/utils/sanitize-options.d.ts +14 -0
  88. package/dist/fetcher/utils/sanitize-options.d.ts.map +1 -0
  89. package/dist/fetcher/utils/sanitize-options.js +16 -0
  90. package/dist/fetcher/utils/sanitize-options.js.map +1 -0
  91. package/dist/fetcher/utils/string-parsers.d.ts +45 -0
  92. package/dist/fetcher/utils/string-parsers.d.ts.map +1 -0
  93. package/dist/fetcher/utils/string-parsers.js +53 -0
  94. package/dist/fetcher/utils/string-parsers.js.map +1 -0
  95. package/dist/index.d.ts +66 -0
  96. package/dist/index.d.ts.map +1 -0
  97. package/dist/index.js +70 -0
  98. package/dist/index.js.map +1 -0
  99. package/dist/logger/console-logger.d.ts +74 -0
  100. package/dist/logger/console-logger.d.ts.map +1 -0
  101. package/dist/logger/console-logger.js +113 -0
  102. package/dist/logger/console-logger.js.map +1 -0
  103. package/dist/logger/factory.d.ts +88 -0
  104. package/dist/logger/factory.d.ts.map +1 -0
  105. package/dist/logger/factory.js +94 -0
  106. package/dist/logger/factory.js.map +1 -0
  107. package/dist/logger/index.d.ts +42 -0
  108. package/dist/logger/index.d.ts.map +1 -0
  109. package/dist/logger/index.js +41 -0
  110. package/dist/logger/index.js.map +1 -0
  111. package/dist/logger/logger.types.d.ts +49 -0
  112. package/dist/logger/logger.types.d.ts.map +1 -0
  113. package/dist/logger/logger.types.js +2 -0
  114. package/dist/logger/logger.types.js.map +1 -0
  115. package/dist/repository/errors/validation-error.d.ts +24 -0
  116. package/dist/repository/errors/validation-error.d.ts.map +1 -0
  117. package/dist/repository/errors/validation-error.js +26 -0
  118. package/dist/repository/errors/validation-error.js.map +1 -0
  119. package/dist/repository/index.d.ts +122 -0
  120. package/dist/repository/index.d.ts.map +1 -0
  121. package/dist/repository/index.js +44 -0
  122. package/dist/repository/index.js.map +1 -0
  123. package/dist/repository/protopedia-in-memory-repository.d.ts +560 -0
  124. package/dist/repository/protopedia-in-memory-repository.d.ts.map +1 -0
  125. package/dist/repository/protopedia-in-memory-repository.js +929 -0
  126. package/dist/repository/protopedia-in-memory-repository.js.map +1 -0
  127. package/dist/repository/schemas/index.d.ts +9 -0
  128. package/dist/repository/schemas/index.d.ts.map +1 -0
  129. package/dist/repository/schemas/index.js +11 -0
  130. package/dist/repository/schemas/index.js.map +1 -0
  131. package/dist/repository/schemas/params.d.ts +44 -0
  132. package/dist/repository/schemas/params.d.ts.map +1 -0
  133. package/dist/repository/schemas/params.js +44 -0
  134. package/dist/repository/schemas/params.js.map +1 -0
  135. package/dist/repository/schemas/serializable-snapshot.d.ts +33 -0
  136. package/dist/repository/schemas/serializable-snapshot.d.ts.map +1 -0
  137. package/dist/repository/schemas/serializable-snapshot.js +45 -0
  138. package/dist/repository/schemas/serializable-snapshot.js.map +1 -0
  139. package/dist/repository/types/analysis.types.d.ts +89 -0
  140. package/dist/repository/types/analysis.types.d.ts.map +1 -0
  141. package/dist/repository/types/analysis.types.js +2 -0
  142. package/dist/repository/types/analysis.types.js.map +1 -0
  143. package/dist/repository/types/index.d.ts +12 -0
  144. package/dist/repository/types/index.d.ts.map +1 -0
  145. package/dist/repository/types/index.js +7 -0
  146. package/dist/repository/types/index.js.map +1 -0
  147. package/dist/repository/types/repository-events.types.d.ts +110 -0
  148. package/dist/repository/types/repository-events.types.d.ts.map +1 -0
  149. package/dist/repository/types/repository-events.types.js +2 -0
  150. package/dist/repository/types/repository-events.types.js.map +1 -0
  151. package/dist/repository/types/repository.types.d.ts +330 -0
  152. package/dist/repository/types/repository.types.d.ts.map +1 -0
  153. package/dist/repository/types/repository.types.js +2 -0
  154. package/dist/repository/types/repository.types.js.map +1 -0
  155. package/dist/repository/types/result.types.d.ts +55 -0
  156. package/dist/repository/types/result.types.d.ts.map +1 -0
  157. package/dist/repository/types/result.types.js +2 -0
  158. package/dist/repository/types/result.types.js.map +1 -0
  159. package/dist/repository/types/serialization.types.d.ts +61 -0
  160. package/dist/repository/types/serialization.types.d.ts.map +1 -0
  161. package/dist/repository/types/serialization.types.js +2 -0
  162. package/dist/repository/types/serialization.types.js.map +1 -0
  163. package/dist/repository/types/snapshot-operation.types.d.ts +140 -0
  164. package/dist/repository/types/snapshot-operation.types.d.ts.map +1 -0
  165. package/dist/repository/types/snapshot-operation.types.js +2 -0
  166. package/dist/repository/types/snapshot-operation.types.js.map +1 -0
  167. package/dist/repository/utils/convert-fetch-result.d.ts +46 -0
  168. package/dist/repository/utils/convert-fetch-result.d.ts.map +1 -0
  169. package/dist/repository/utils/convert-fetch-result.js +59 -0
  170. package/dist/repository/utils/convert-fetch-result.js.map +1 -0
  171. package/dist/repository/utils/convert-store-result.d.ts +36 -0
  172. package/dist/repository/utils/convert-store-result.d.ts.map +1 -0
  173. package/dist/repository/utils/convert-store-result.js +36 -0
  174. package/dist/repository/utils/convert-store-result.js.map +1 -0
  175. package/dist/repository/utils/emit-repository-event-safely.d.ts +5 -0
  176. package/dist/repository/utils/emit-repository-event-safely.d.ts.map +1 -0
  177. package/dist/repository/utils/emit-repository-event-safely.js +17 -0
  178. package/dist/repository/utils/emit-repository-event-safely.js.map +1 -0
  179. package/dist/repository/utils/index.d.ts +3 -0
  180. package/dist/repository/utils/index.d.ts.map +1 -0
  181. package/dist/repository/utils/index.js +3 -0
  182. package/dist/repository/utils/index.js.map +1 -0
  183. package/dist/repository/validation/index.d.ts +9 -0
  184. package/dist/repository/validation/index.d.ts.map +1 -0
  185. package/dist/repository/validation/index.js +10 -0
  186. package/dist/repository/validation/index.js.map +1 -0
  187. package/dist/repository/validation/params-validators.d.ts +46 -0
  188. package/dist/repository/validation/params-validators.d.ts.map +1 -0
  189. package/dist/repository/validation/params-validators.js +68 -0
  190. package/dist/repository/validation/params-validators.js.map +1 -0
  191. package/dist/repository/validation/serializable-snapshot.d.ts +47 -0
  192. package/dist/repository/validation/serializable-snapshot.d.ts.map +1 -0
  193. package/dist/repository/validation/serializable-snapshot.js +104 -0
  194. package/dist/repository/validation/serializable-snapshot.js.map +1 -0
  195. package/dist/schemas/index.d.ts +8 -0
  196. package/dist/schemas/index.d.ts.map +1 -0
  197. package/dist/schemas/index.js +8 -0
  198. package/dist/schemas/index.js.map +1 -0
  199. package/dist/schemas/normalized-prototype.d.ts +56 -0
  200. package/dist/schemas/normalized-prototype.d.ts.map +1 -0
  201. package/dist/schemas/normalized-prototype.js +123 -0
  202. package/dist/schemas/normalized-prototype.js.map +1 -0
  203. package/dist/store/errors/store-error.d.ts +148 -0
  204. package/dist/store/errors/store-error.d.ts.map +1 -0
  205. package/dist/store/errors/store-error.js +156 -0
  206. package/dist/store/errors/store-error.js.map +1 -0
  207. package/dist/store/index.d.ts +84 -0
  208. package/dist/store/index.d.ts.map +1 -0
  209. package/dist/store/index.js +83 -0
  210. package/dist/store/index.js.map +1 -0
  211. package/dist/store/store.d.ts +295 -0
  212. package/dist/store/store.d.ts.map +1 -0
  213. package/dist/store/store.js +411 -0
  214. package/dist/store/store.js.map +1 -0
  215. package/dist/store/types/index.d.ts +2 -0
  216. package/dist/store/types/index.d.ts.map +1 -0
  217. package/dist/store/types/index.js +2 -0
  218. package/dist/store/types/index.js.map +1 -0
  219. package/dist/store/types/result.types.d.ts +67 -0
  220. package/dist/store/types/result.types.d.ts.map +1 -0
  221. package/dist/store/types/result.types.js +2 -0
  222. package/dist/store/types/result.types.js.map +1 -0
  223. package/dist/types/codes.d.ts +44 -0
  224. package/dist/types/codes.d.ts.map +1 -0
  225. package/dist/types/codes.js +9 -0
  226. package/dist/types/codes.js.map +1 -0
  227. package/dist/types/index.d.ts +61 -0
  228. package/dist/types/index.d.ts.map +1 -0
  229. package/dist/types/index.js +60 -0
  230. package/dist/types/index.js.map +1 -0
  231. package/dist/types/normalized-prototype.d.ts +95 -0
  232. package/dist/types/normalized-prototype.d.ts.map +1 -0
  233. package/dist/types/normalized-prototype.js +2 -0
  234. package/dist/types/normalized-prototype.js.map +1 -0
  235. package/dist/utils/converters/index.d.ts +15 -0
  236. package/dist/utils/converters/index.d.ts.map +1 -0
  237. package/dist/utils/converters/index.js +15 -0
  238. package/dist/utils/converters/index.js.map +1 -0
  239. package/dist/utils/converters/license-type.d.ts +23 -0
  240. package/dist/utils/converters/license-type.d.ts.map +1 -0
  241. package/dist/utils/converters/license-type.js +38 -0
  242. package/dist/utils/converters/license-type.js.map +1 -0
  243. package/dist/utils/converters/release-flag.d.ts +24 -0
  244. package/dist/utils/converters/release-flag.d.ts.map +1 -0
  245. package/dist/utils/converters/release-flag.js +40 -0
  246. package/dist/utils/converters/release-flag.js.map +1 -0
  247. package/dist/utils/converters/status.d.ts +23 -0
  248. package/dist/utils/converters/status.d.ts.map +1 -0
  249. package/dist/utils/converters/status.js +40 -0
  250. package/dist/utils/converters/status.js.map +1 -0
  251. package/dist/utils/converters/thanks-flag.d.ts +25 -0
  252. package/dist/utils/converters/thanks-flag.d.ts.map +1 -0
  253. package/dist/utils/converters/thanks-flag.js +41 -0
  254. package/dist/utils/converters/thanks-flag.js.map +1 -0
  255. package/dist/utils/deep-merge.d.ts +38 -0
  256. package/dist/utils/deep-merge.d.ts.map +1 -0
  257. package/dist/utils/deep-merge.js +85 -0
  258. package/dist/utils/deep-merge.js.map +1 -0
  259. package/dist/utils/index.d.ts +80 -0
  260. package/dist/utils/index.d.ts.map +1 -0
  261. package/dist/utils/index.js +85 -0
  262. package/dist/utils/index.js.map +1 -0
  263. package/dist/utils/logger-utils.d.ts +100 -0
  264. package/dist/utils/logger-utils.d.ts.map +1 -0
  265. package/dist/utils/logger-utils.js +265 -0
  266. package/dist/utils/logger-utils.js.map +1 -0
  267. package/dist/utils/time/constants.d.ts +14 -0
  268. package/dist/utils/time/constants.d.ts.map +1 -0
  269. package/dist/utils/time/constants.js +14 -0
  270. package/dist/utils/time/constants.js.map +1 -0
  271. package/dist/utils/time/index.d.ts +28 -0
  272. package/dist/utils/time/index.d.ts.map +1 -0
  273. package/dist/utils/time/index.js +28 -0
  274. package/dist/utils/time/index.js.map +1 -0
  275. package/dist/utils/time/parser.d.ts +91 -0
  276. package/dist/utils/time/parser.d.ts.map +1 -0
  277. package/dist/utils/time/parser.js +143 -0
  278. package/dist/utils/time/parser.js.map +1 -0
  279. package/dist/utils/validation/index.d.ts +8 -0
  280. package/dist/utils/validation/index.d.ts.map +1 -0
  281. package/dist/utils/validation/index.js +7 -0
  282. package/dist/utils/validation/index.js.map +1 -0
  283. package/dist/utils/validation/normalized-prototype.d.ts +64 -0
  284. package/dist/utils/validation/normalized-prototype.d.ts.map +1 -0
  285. package/dist/utils/validation/normalized-prototype.js +97 -0
  286. package/dist/utils/validation/normalized-prototype.js.map +1 -0
  287. package/dist/utils/validation/types.d.ts +62 -0
  288. package/dist/utils/validation/types.d.ts.map +1 -0
  289. package/dist/utils/validation/types.js +8 -0
  290. package/dist/utils/validation/types.js.map +1 -0
  291. package/dist/version.d.ts +6 -0
  292. package/dist/version.d.ts.map +1 -0
  293. package/dist/version.js +6 -0
  294. package/dist/version.js.map +1 -0
  295. package/package.json +138 -0
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Utility Functions and Data Converters.
3
+ *
4
+ * This module provides a comprehensive set of utility functions for working with
5
+ * ProtoPedia data, including type-safe converters, time parsing, configuration
6
+ * merging, and secure logging utilities.
7
+ *
8
+ * ## Data Converters
9
+ *
10
+ * Transform ProtoPedia API numeric codes into human-readable labels:
11
+ *
12
+ * - {@link getPrototypeStatusLabel} — Convert status code to label (e.g., `1` → `'公開'`)
13
+ * - {@link getPrototypeReleaseFlagLabel} — Convert release flag to label (e.g., `1` → `'フリー'`)
14
+ * - {@link getPrototypeThanksFlagLabel} — Convert thanks flag to label (e.g., `1` → `'受付中'`)
15
+ * - {@link getPrototypeLicenseTypeLabel} — Convert license type to label (e.g., `1` → `'CC BY'`)
16
+ *
17
+ * ## Time Utilities
18
+ *
19
+ * Parse and normalize ProtoPedia timestamps:
20
+ *
21
+ * - {@link parseProtoPediaTimestamp} — Parse JST timestamps to UTC ISO-8601
22
+ * - {@link parseW3cDtfTimestamp} — Parse W3C-DTF timestamps to UTC ISO-8601
23
+ * - {@link JST_OFFSET_MS} — JST timezone offset constant (9 hours in milliseconds)
24
+ *
25
+ * ## Configuration Utilities
26
+ *
27
+ * Deep merge configuration objects safely:
28
+ *
29
+ * - {@link deepMerge} — Deep merge with circular reference protection and prototype pollution prevention
30
+ * - {@link isPlainObject} — Type guard for plain JavaScript objects
31
+ *
32
+ * ## Logging Utilities
33
+ *
34
+ * Sanitize data for secure logging:
35
+ *
36
+ * - {@link sanitizeDataForLogging} — Redact sensitive data and handle circular references
37
+ *
38
+ * ## Dependencies
39
+ *
40
+ * This module intentionally depends on `lib/types` for data structures. This is
41
+ * a correct architectural dependency, as utilities often operate on defined data
42
+ * types. This design ensures type-safe utility operations.
43
+ *
44
+ * ## Standalone Usage
45
+ *
46
+ * All utilities can be used independently without the full repository layer:
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import {
51
+ * getPrototypeStatusLabel,
52
+ * parseProtoPediaTimestamp,
53
+ * deepMerge,
54
+ * sanitizeDataForLogging,
55
+ * } from 'promidas/utils';
56
+ *
57
+ * // Convert status code
58
+ * const label = getPrototypeStatusLabel(1); // => '公開'
59
+ *
60
+ * // Parse timestamp
61
+ * const isoDate = parseProtoPediaTimestamp('2025-11-14 12:03:07.0');
62
+ * // => '2025-11-14T03:03:07.000Z'
63
+ *
64
+ * // Merge configurations
65
+ * const config = deepMerge(defaults, overrides);
66
+ *
67
+ * // Sanitize for logging
68
+ * const safe = sanitizeDataForLogging({ token: 'secret', data: 'visible' });
69
+ * // => { token: '[REDACTED]', data: 'visible' }
70
+ * ```
71
+ *
72
+ * @module
73
+ * @see https://protopedia.gitbook.io/helpcenter/info/2022.05.23 for ProtoPedia field specifications
74
+ */
75
+ export { getPrototypeStatusLabel, getPrototypeReleaseFlagLabel, getPrototypeThanksFlagLabel, getPrototypeLicenseTypeLabel, } from './converters/index.js';
76
+ export { JST_OFFSET_MS, parseProtoPediaTimestamp, parseW3cDtfTimestamp, } from './time/index.js';
77
+ export { deepMerge, isPlainObject } from './deep-merge.js';
78
+ export { sanitizeDataForLogging } from './logger-utils.js';
79
+ export { validateNormalizedPrototype, validateNormalizedPrototypeArray, type ValidationErrorCode, type ValidationResult, type ValidationSuccess, type ValidationFailure, } from './validation/index.js';
80
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AAGH,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,EAChC,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Utility Functions and Data Converters.
3
+ *
4
+ * This module provides a comprehensive set of utility functions for working with
5
+ * ProtoPedia data, including type-safe converters, time parsing, configuration
6
+ * merging, and secure logging utilities.
7
+ *
8
+ * ## Data Converters
9
+ *
10
+ * Transform ProtoPedia API numeric codes into human-readable labels:
11
+ *
12
+ * - {@link getPrototypeStatusLabel} — Convert status code to label (e.g., `1` → `'公開'`)
13
+ * - {@link getPrototypeReleaseFlagLabel} — Convert release flag to label (e.g., `1` → `'フリー'`)
14
+ * - {@link getPrototypeThanksFlagLabel} — Convert thanks flag to label (e.g., `1` → `'受付中'`)
15
+ * - {@link getPrototypeLicenseTypeLabel} — Convert license type to label (e.g., `1` → `'CC BY'`)
16
+ *
17
+ * ## Time Utilities
18
+ *
19
+ * Parse and normalize ProtoPedia timestamps:
20
+ *
21
+ * - {@link parseProtoPediaTimestamp} — Parse JST timestamps to UTC ISO-8601
22
+ * - {@link parseW3cDtfTimestamp} — Parse W3C-DTF timestamps to UTC ISO-8601
23
+ * - {@link JST_OFFSET_MS} — JST timezone offset constant (9 hours in milliseconds)
24
+ *
25
+ * ## Configuration Utilities
26
+ *
27
+ * Deep merge configuration objects safely:
28
+ *
29
+ * - {@link deepMerge} — Deep merge with circular reference protection and prototype pollution prevention
30
+ * - {@link isPlainObject} — Type guard for plain JavaScript objects
31
+ *
32
+ * ## Logging Utilities
33
+ *
34
+ * Sanitize data for secure logging:
35
+ *
36
+ * - {@link sanitizeDataForLogging} — Redact sensitive data and handle circular references
37
+ *
38
+ * ## Dependencies
39
+ *
40
+ * This module intentionally depends on `lib/types` for data structures. This is
41
+ * a correct architectural dependency, as utilities often operate on defined data
42
+ * types. This design ensures type-safe utility operations.
43
+ *
44
+ * ## Standalone Usage
45
+ *
46
+ * All utilities can be used independently without the full repository layer:
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * import {
51
+ * getPrototypeStatusLabel,
52
+ * parseProtoPediaTimestamp,
53
+ * deepMerge,
54
+ * sanitizeDataForLogging,
55
+ * } from 'promidas/utils';
56
+ *
57
+ * // Convert status code
58
+ * const label = getPrototypeStatusLabel(1); // => '公開'
59
+ *
60
+ * // Parse timestamp
61
+ * const isoDate = parseProtoPediaTimestamp('2025-11-14 12:03:07.0');
62
+ * // => '2025-11-14T03:03:07.000Z'
63
+ *
64
+ * // Merge configurations
65
+ * const config = deepMerge(defaults, overrides);
66
+ *
67
+ * // Sanitize for logging
68
+ * const safe = sanitizeDataForLogging({ token: 'secret', data: 'visible' });
69
+ * // => { token: '[REDACTED]', data: 'visible' }
70
+ * ```
71
+ *
72
+ * @module
73
+ * @see https://protopedia.gitbook.io/helpcenter/info/2022.05.23 for ProtoPedia field specifications
74
+ */
75
+ // Data Converters
76
+ export { getPrototypeStatusLabel, getPrototypeReleaseFlagLabel, getPrototypeThanksFlagLabel, getPrototypeLicenseTypeLabel, } from './converters/index.js';
77
+ // Time Utilities
78
+ export { JST_OFFSET_MS, parseProtoPediaTimestamp, parseW3cDtfTimestamp, } from './time/index.js';
79
+ // Configuration Utilities
80
+ export { deepMerge, isPlainObject } from './deep-merge.js';
81
+ // Logging Utilities
82
+ export { sanitizeDataForLogging } from './logger-utils.js';
83
+ // Validation Utilities
84
+ export { validateNormalizedPrototype, validateNormalizedPrototypeArray, } from './validation/index.js';
85
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AAEH,kBAAkB;AAClB,OAAO,EACL,uBAAuB,EACvB,4BAA4B,EAC5B,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAE/B,iBAAiB;AACjB,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,0BAA0B;AAC1B,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,oBAAoB;AACpB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAE3D,uBAAuB;AACvB,OAAO,EACL,2BAA2B,EAC3B,gCAAgC,GAKjC,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Utility functions for secure logging operations.
3
+ *
4
+ * This module provides utilities for sanitizing data before logging to prevent
5
+ * sensitive information leakage. It handles circular references, prototype pollution,
6
+ * and provides protection against DoS attacks through depth limiting.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * Options for customizing data sanitization behavior.
12
+ */
13
+ export interface SanitizeOptions {
14
+ /**
15
+ * Additional key patterns to treat as sensitive and redact.
16
+ * These are added to the default list of sensitive keys.
17
+ */
18
+ additionalSensitiveKeys?: string[];
19
+ }
20
+ /**
21
+ * Sanitizes data for secure logging by redacting sensitive information.
22
+ *
23
+ * This function deeply traverses objects, arrays, and errors to redact sensitive
24
+ * fields while preserving structure for debugging. It provides multiple layers of
25
+ * protection against common security and reliability issues:
26
+ *
27
+ * **Security Features:**
28
+ * - Redacts sensitive keys (token, password, secret, auth, credential)
29
+ * - Prevents prototype pollution by skipping dangerous keys
30
+ * - Uses case-insensitive pattern matching for sensitive data detection
31
+ *
32
+ * **Reliability Features:**
33
+ * - Handles circular references using WeakSet tracking
34
+ * - Limits recursion depth to prevent stack overflow (max 100 levels)
35
+ * - Preserves non-serializable types (functions, symbols, bigints)
36
+ *
37
+ * **Type Support:**
38
+ * - Primitives: returned as-is (strings, numbers, booleans, null, undefined)
39
+ * - Functions: converted to `[Function: name]` strings
40
+ * - Symbols: converted to string representation
41
+ * - BigInts: converted to string with 'n' suffix
42
+ * - Errors: extracts name, message, stack, and other properties
43
+ * - Arrays: recursively sanitized element by element
44
+ * - Maps: converted to object with `__type` and `entries`; if key is sensitive, both key and value are redacted
45
+ * - Sets: converted to object with `__type` and `values`
46
+ * - Objects: recursively sanitized key by key with sensitive data redacted
47
+ *
48
+ * @param data - The data to sanitize (any type)
49
+ * @param options - Optional configuration for sanitization
50
+ * @returns A new sanitized version with sensitive information redacted
51
+ *
52
+ * @example
53
+ * Basic usage with sensitive data:
54
+ * ```typescript
55
+ * const data = {
56
+ * username: 'john',
57
+ * apiToken: 'secret-key-123',
58
+ * settings: { theme: 'dark' }
59
+ * };
60
+ *
61
+ * const sanitized = sanitizeDataForLogging(data);
62
+ * // Result: { username: 'john', apiToken: '***', settings: { theme: 'dark' } }
63
+ * ```
64
+ *
65
+ * @example
66
+ * Usage with custom sensitive keys:
67
+ * ```typescript
68
+ * const data = {
69
+ * apiKey: 'secret',
70
+ * ssn: '123-45-6789'
71
+ * };
72
+ *
73
+ * const sanitized = sanitizeDataForLogging(data, {
74
+ * additionalSensitiveKeys: ['ssn']
75
+ * });
76
+ * // Result: { apiKey: '***', ssn: '***' } // 'apiKey' contains 'key' which might not match default, but 'ssn' will match.
77
+ * ```
78
+ *
79
+ * @example
80
+ * Handling circular references:
81
+ * ```typescript
82
+ * const obj: any = { name: 'test' };
83
+ * obj.self = obj;
84
+ *
85
+ * const sanitized = sanitizeDataForLogging(obj);
86
+ * // Result: { name: 'test', self: '[Circular]' }
87
+ * ```
88
+ *
89
+ * @example
90
+ * Error object sanitization:
91
+ * ```typescript
92
+ * const error = new Error('Failed to authenticate');
93
+ * error.apiToken = 'secret';
94
+ *
95
+ * const sanitized = sanitizeDataForLogging(error);
96
+ * // Result: { name: 'Error', message: 'Failed...', stack: '...', apiToken: '***' }
97
+ * ```
98
+ */
99
+ export declare function sanitizeDataForLogging(data: unknown, options?: SanitizeOptions): unknown;
100
+ //# sourceMappingURL=logger-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-utils.d.ts","sourceRoot":"","sources":["../../lib/utils/logger-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA6BH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;CACpC;AAsED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,OAAO,EACb,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAmHT"}
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Utility functions for secure logging operations.
3
+ *
4
+ * This module provides utilities for sanitizing data before logging to prevent
5
+ * sensitive information leakage. It handles circular references, prototype pollution,
6
+ * and provides protection against DoS attacks through depth limiting.
7
+ *
8
+ * @module
9
+ */
10
+ /**
11
+ * List of sensitive key patterns to redact in logged data.
12
+ * These patterns are matched case-insensitively.
13
+ */
14
+ const SENSITIVE_KEYS = ['token', 'auth', 'password', 'secret', 'credential'];
15
+ /**
16
+ * Pre-compiled regular expression for efficient sensitive key detection.
17
+ * Matches any key containing tokens like 'token', 'auth', 'password', etc.
18
+ */
19
+ const SENSITIVE_KEY_PATTERN = new RegExp(SENSITIVE_KEYS.join('|'), 'i');
20
+ /**
21
+ * Keys that are dangerous for prototype pollution attacks.
22
+ * These keys are always skipped during sanitization to prevent security vulnerabilities.
23
+ */
24
+ const DANGEROUS_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
25
+ /**
26
+ * Maximum recursion depth to prevent stack overflow from deeply nested objects.
27
+ * This protects against DoS attacks using maliciously crafted data structures.
28
+ */
29
+ const MAX_DEPTH = 100;
30
+ /**
31
+ * Cache for compiled RegExp patterns to avoid recompilation on every call.
32
+ * Key is the sorted, joined list of sensitive keys.
33
+ */
34
+ const regexCache = new Map();
35
+ /**
36
+ * Maximum allowed length for individual custom sensitive key pattern.
37
+ * This prevents ReDoS attacks from excessively long or complex patterns.
38
+ */
39
+ const MAX_PATTERN_LENGTH = 100;
40
+ /**
41
+ * Validates custom sensitive keys to prevent ReDoS attacks.
42
+ * @param keys - Array of custom sensitive key patterns
43
+ * @throws {TypeError} If any key is invalid
44
+ */
45
+ function validateSensitiveKeys(keys) {
46
+ for (const key of keys) {
47
+ if (typeof key !== 'string') {
48
+ throw new TypeError(`Invalid sensitive key: expected string, got ${typeof key}`);
49
+ }
50
+ if (key.length === 0) {
51
+ throw new TypeError('Sensitive key cannot be empty');
52
+ }
53
+ if (key.length > MAX_PATTERN_LENGTH) {
54
+ throw new TypeError(`Sensitive key too long (max ${MAX_PATTERN_LENGTH} characters): ${key.slice(0, 20)}...`);
55
+ }
56
+ // Check for potentially dangerous regex patterns
57
+ if (/[*+{].*[*+{]/.test(key)) {
58
+ throw new TypeError(`Potentially dangerous regex pattern detected: ${key}`);
59
+ }
60
+ }
61
+ }
62
+ /**
63
+ * Gets or creates a cached RegExp for the given sensitive keys.
64
+ * @param additionalKeys - Additional keys to include in the pattern
65
+ * @returns Compiled RegExp for matching sensitive keys
66
+ */
67
+ function getSensitivePattern(additionalKeys = []) {
68
+ if (additionalKeys.length === 0) {
69
+ return SENSITIVE_KEY_PATTERN;
70
+ }
71
+ // Validate custom keys before using them
72
+ validateSensitiveKeys(additionalKeys);
73
+ // Create cache key from sorted list of all keys
74
+ const allKeys = [...SENSITIVE_KEYS, ...additionalKeys].sort();
75
+ const cacheKey = allKeys.join('|');
76
+ // Return cached pattern if available
77
+ let pattern = regexCache.get(cacheKey);
78
+ if (!pattern) {
79
+ pattern = new RegExp(cacheKey, 'i');
80
+ regexCache.set(cacheKey, pattern);
81
+ }
82
+ return pattern;
83
+ }
84
+ /**
85
+ * Sanitizes data for secure logging by redacting sensitive information.
86
+ *
87
+ * This function deeply traverses objects, arrays, and errors to redact sensitive
88
+ * fields while preserving structure for debugging. It provides multiple layers of
89
+ * protection against common security and reliability issues:
90
+ *
91
+ * **Security Features:**
92
+ * - Redacts sensitive keys (token, password, secret, auth, credential)
93
+ * - Prevents prototype pollution by skipping dangerous keys
94
+ * - Uses case-insensitive pattern matching for sensitive data detection
95
+ *
96
+ * **Reliability Features:**
97
+ * - Handles circular references using WeakSet tracking
98
+ * - Limits recursion depth to prevent stack overflow (max 100 levels)
99
+ * - Preserves non-serializable types (functions, symbols, bigints)
100
+ *
101
+ * **Type Support:**
102
+ * - Primitives: returned as-is (strings, numbers, booleans, null, undefined)
103
+ * - Functions: converted to `[Function: name]` strings
104
+ * - Symbols: converted to string representation
105
+ * - BigInts: converted to string with 'n' suffix
106
+ * - Errors: extracts name, message, stack, and other properties
107
+ * - Arrays: recursively sanitized element by element
108
+ * - Maps: converted to object with `__type` and `entries`; if key is sensitive, both key and value are redacted
109
+ * - Sets: converted to object with `__type` and `values`
110
+ * - Objects: recursively sanitized key by key with sensitive data redacted
111
+ *
112
+ * @param data - The data to sanitize (any type)
113
+ * @param options - Optional configuration for sanitization
114
+ * @returns A new sanitized version with sensitive information redacted
115
+ *
116
+ * @example
117
+ * Basic usage with sensitive data:
118
+ * ```typescript
119
+ * const data = {
120
+ * username: 'john',
121
+ * apiToken: 'secret-key-123',
122
+ * settings: { theme: 'dark' }
123
+ * };
124
+ *
125
+ * const sanitized = sanitizeDataForLogging(data);
126
+ * // Result: { username: 'john', apiToken: '***', settings: { theme: 'dark' } }
127
+ * ```
128
+ *
129
+ * @example
130
+ * Usage with custom sensitive keys:
131
+ * ```typescript
132
+ * const data = {
133
+ * apiKey: 'secret',
134
+ * ssn: '123-45-6789'
135
+ * };
136
+ *
137
+ * const sanitized = sanitizeDataForLogging(data, {
138
+ * additionalSensitiveKeys: ['ssn']
139
+ * });
140
+ * // Result: { apiKey: '***', ssn: '***' } // 'apiKey' contains 'key' which might not match default, but 'ssn' will match.
141
+ * ```
142
+ *
143
+ * @example
144
+ * Handling circular references:
145
+ * ```typescript
146
+ * const obj: any = { name: 'test' };
147
+ * obj.self = obj;
148
+ *
149
+ * const sanitized = sanitizeDataForLogging(obj);
150
+ * // Result: { name: 'test', self: '[Circular]' }
151
+ * ```
152
+ *
153
+ * @example
154
+ * Error object sanitization:
155
+ * ```typescript
156
+ * const error = new Error('Failed to authenticate');
157
+ * error.apiToken = 'secret';
158
+ *
159
+ * const sanitized = sanitizeDataForLogging(error);
160
+ * // Result: { name: 'Error', message: 'Failed...', stack: '...', apiToken: '***' }
161
+ * ```
162
+ */
163
+ export function sanitizeDataForLogging(data, options = {}) {
164
+ const seen = new WeakSet();
165
+ // Get cached regex pattern for sensitive key detection
166
+ const sensitivePattern = getSensitivePattern(options.additionalSensitiveKeys);
167
+ function isSensitive(key) {
168
+ return sensitivePattern.test(key);
169
+ }
170
+ // Pre-define Error property exclusion Set for performance
171
+ const ERROR_BASE_PROPS = new Set(['name', 'message', 'stack']);
172
+ function sanitize(value, depth = 0) {
173
+ // Depth limit check
174
+ if (depth >= MAX_DEPTH) {
175
+ return '[Max Depth Exceeded]';
176
+ }
177
+ // Primitives and null
178
+ if (value === null || typeof value !== 'object') {
179
+ if (typeof value === 'function') {
180
+ return `[Function: ${value.name || 'anonymous'}]`;
181
+ }
182
+ if (typeof value === 'symbol') {
183
+ return value.toString();
184
+ }
185
+ if (typeof value === 'bigint') {
186
+ return `${value.toString()}n`;
187
+ }
188
+ return value;
189
+ }
190
+ // Circular reference check
191
+ if (seen.has(value)) {
192
+ return '[Circular]';
193
+ }
194
+ seen.add(value);
195
+ // Handle Error objects
196
+ if (value instanceof Error) {
197
+ const errorObj = {
198
+ name: value.name,
199
+ message: value.message,
200
+ stack: value.stack,
201
+ };
202
+ // Copy other properties (using getOwnPropertyNames to include non-enumerable properties)
203
+ for (const key of Object.getOwnPropertyNames(value)) {
204
+ if (!ERROR_BASE_PROPS.has(key)) {
205
+ if (isSensitive(key)) {
206
+ errorObj[key] = '***';
207
+ }
208
+ else {
209
+ const errorValue = value;
210
+ errorObj[key] = sanitize(errorValue[key], depth + 1);
211
+ }
212
+ }
213
+ }
214
+ return errorObj;
215
+ }
216
+ // Handle Map (preserve type information and check keys for sensitive data)
217
+ if (value instanceof Map) {
218
+ return {
219
+ __type: 'Map',
220
+ entries: Array.from(value.entries()).map(([k, v]) => {
221
+ // Check if key itself is sensitive (when it's a string)
222
+ const isKeySensitive = typeof k === 'string' && isSensitive(k);
223
+ const sanitizedKey = isKeySensitive ? '***' : sanitize(k, depth + 1);
224
+ // If key is sensitive, redact the value as well to prevent leakage
225
+ const sanitizedValue = isKeySensitive
226
+ ? '***'
227
+ : sanitize(v, depth + 1);
228
+ return [sanitizedKey, sanitizedValue];
229
+ }),
230
+ };
231
+ }
232
+ // Handle Set (preserve type information)
233
+ if (value instanceof Set) {
234
+ return {
235
+ __type: 'Set',
236
+ values: Array.from(value).map((v) => sanitize(v, depth + 1)),
237
+ };
238
+ }
239
+ // Handle Arrays
240
+ if (Array.isArray(value)) {
241
+ return value.map((item) => sanitize(item, depth + 1));
242
+ }
243
+ // Handle Plain Objects
244
+ const sanitizedObj = {};
245
+ const obj = value;
246
+ // Iterate over own enumerable properties
247
+ for (const key of Object.keys(obj)) {
248
+ // Skip dangerous prototype pollution keys
249
+ if (DANGEROUS_KEYS.has(key)) {
250
+ continue;
251
+ }
252
+ // Redact sensitive keys
253
+ if (isSensitive(key)) {
254
+ sanitizedObj[key] = '***';
255
+ }
256
+ else {
257
+ // Recursively sanitize
258
+ sanitizedObj[key] = sanitize(obj[key], depth + 1);
259
+ }
260
+ }
261
+ return sanitizedObj;
262
+ }
263
+ return sanitize(data);
264
+ }
265
+ //# sourceMappingURL=logger-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger-utils.js","sourceRoot":"","sources":["../../lib/utils/logger-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC;AAE7E;;;GAGG;AACH,MAAM,qBAAqB,GAAG,IAAI,MAAM,CACtC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EACxB,GAAG,CACJ,CAAC;AAEF;;;GAGG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAE1E;;;GAGG;AACH,MAAM,SAAS,GAAG,GAAG,CAAC;AAatB;;;GAGG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;AAE7C;;;GAGG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,IAAc;IAC3C,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,MAAM,IAAI,SAAS,CACjB,+CAA+C,OAAO,GAAG,EAAE,CAC5D,CAAC;QACJ,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;QACvD,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CACjB,+BAA+B,kBAAkB,iBAAiB,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CACxF,CAAC;QACJ,CAAC;QACD,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AC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;aAC7D,CAAC;QACJ,CAAC;QAED,gBAAgB;QAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;QACxD,CAAC;QAED,uBAAuB;QACvB,MAAM,YAAY,GAA4B,EAAE,CAAC;QACjD,MAAM,GAAG,GAAG,KAAgC,CAAC;QAE7C,yCAAyC;QACzC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;YACnC,0CAA0C;YAC1C,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5B,SAAS;YACX,CAAC;YAED,wBAAwB;YACxB,IAAI,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC;gBACrB,YAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YAC5B,CAAC;iBAAM,CAAC;gBACN,uBAAuB;gBACvB,YAAY,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Time-related constants for ProtoPedia timestamp handling.
3
+ *
4
+ * @module utils/time/constants
5
+ */
6
+ /**
7
+ * JST (Japan Standard Time) offset in milliseconds.
8
+ *
9
+ * JST is UTC+9, which corresponds to 9 hours * 60 minutes * 60 seconds * 1000 ms.
10
+ * This constant is used to convert JST timestamps (without explicit offset)
11
+ * to UTC.
12
+ */
13
+ export declare const JST_OFFSET_MS: number;
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../lib/utils/time/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,QAAqB,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Time-related constants for ProtoPedia timestamp handling.
3
+ *
4
+ * @module utils/time/constants
5
+ */
6
+ /**
7
+ * JST (Japan Standard Time) offset in milliseconds.
8
+ *
9
+ * JST is UTC+9, which corresponds to 9 hours * 60 minutes * 60 seconds * 1000 ms.
10
+ * This constant is used to convert JST timestamps (without explicit offset)
11
+ * to UTC.
12
+ */
13
+ export const JST_OFFSET_MS = 9 * 60 * 60 * 1000;
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../lib/utils/time/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Time utilities for ProtoPedia timestamp handling.
3
+ *
4
+ * Provides parsers and normalizers for ProtoPedia-specific JST timestamps
5
+ * and W3C-DTF (W3C Date and Time Formats) compliant timestamps.
6
+ *
7
+ * @module utils/time
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import {
12
+ * parseProtoPediaTimestamp,
13
+ * parseW3cDtfTimestamp,
14
+ * JST_OFFSET_MS,
15
+ * } from 'promidas/utils/time';
16
+ *
17
+ * // Parse ProtoPedia format (JST)
18
+ * parseProtoPediaTimestamp('2025-11-14 12:03:07.0');
19
+ * // => '2025-11-14T03:03:07.000Z'
20
+ *
21
+ * // Parse W3C-DTF format
22
+ * parseW3cDtfTimestamp('2025-11-14T12:03:07+09:00');
23
+ * // => '2025-11-14T03:03:07.000Z'
24
+ * ```
25
+ */
26
+ export { JST_OFFSET_MS } from './constants.js';
27
+ export { parseProtoPediaTimestamp, parseW3cDtfTimestamp } from './parser.js';
28
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/utils/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Time utilities for ProtoPedia timestamp handling.
3
+ *
4
+ * Provides parsers and normalizers for ProtoPedia-specific JST timestamps
5
+ * and W3C-DTF (W3C Date and Time Formats) compliant timestamps.
6
+ *
7
+ * @module utils/time
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import {
12
+ * parseProtoPediaTimestamp,
13
+ * parseW3cDtfTimestamp,
14
+ * JST_OFFSET_MS,
15
+ * } from 'promidas/utils/time';
16
+ *
17
+ * // Parse ProtoPedia format (JST)
18
+ * parseProtoPediaTimestamp('2025-11-14 12:03:07.0');
19
+ * // => '2025-11-14T03:03:07.000Z'
20
+ *
21
+ * // Parse W3C-DTF format
22
+ * parseW3cDtfTimestamp('2025-11-14T12:03:07+09:00');
23
+ * // => '2025-11-14T03:03:07.000Z'
24
+ * ```
25
+ */
26
+ export { JST_OFFSET_MS } from './constants.js';
27
+ export { parseProtoPediaTimestamp, parseW3cDtfTimestamp } from './parser.js';
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/utils/time/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}