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,46 @@
1
+ import type { FetchPrototypesResult, FetchPrototypesSuccess } from '../../fetcher/types/result.types.js';
2
+ import type { SnapshotOperationResult } from '../types/snapshot-operation.types.js';
3
+ /**
4
+ * Convert FetchPrototypesResult to SnapshotOperationResult.
5
+ *
6
+ * For success cases, returns the result as-is (type-compatible).
7
+ * For failure cases, preserves all error information (origin, kind, code, message, status, details)
8
+ * from the fetcher layer for use in the repository layer.
9
+ *
10
+ * @param result - Fetch result to convert
11
+ * @returns Snapshot operation result (success pass-through or converted failure)
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * // Success case - pass through
16
+ * const fetchSuccess: FetchPrototypesSuccess = {
17
+ * ok: true,
18
+ * data: [{ id: 1, ... }]
19
+ * };
20
+ * const snapshotResult = convertFetchResult(fetchSuccess);
21
+ * // { ok: true, data: [{ id: 1, ... }] } - same object
22
+ *
23
+ * // Failure case - convert
24
+ * const fetchFailure: FetchPrototypesFailure = {
25
+ * ok: false,
26
+ * origin: 'fetcher',
27
+ * kind: 'http',
28
+ * error: 'Not Found',
29
+ * code: 'CLIENT_NOT_FOUND',
30
+ * status: 404,
31
+ * details: { res: { code: 'RESOURCE_NOT_FOUND' } }
32
+ * };
33
+ * const snapshotFailure = convertFetchResult(fetchFailure);
34
+ * // {
35
+ * // ok: false,
36
+ * // origin: 'fetcher',
37
+ * // kind: 'http',
38
+ * // code: 'CLIENT_NOT_FOUND',
39
+ * // message: 'Not Found',
40
+ * // status: 404,
41
+ * // details: { res: { code: 'RESOURCE_NOT_FOUND' } }
42
+ * // }
43
+ * ```
44
+ */
45
+ export declare function convertFetchResult(result: FetchPrototypesResult): SnapshotOperationResult | FetchPrototypesSuccess;
46
+ //# sourceMappingURL=convert-fetch-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-fetch-result.d.ts","sourceRoot":"","sources":["../../../lib/repository/utils/convert-fetch-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAEV,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,GAC5B,uBAAuB,GAAG,sBAAsB,CAgBlD"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Convert FetchPrototypesResult to SnapshotOperationResult.
3
+ *
4
+ * For success cases, returns the result as-is (type-compatible).
5
+ * For failure cases, preserves all error information (origin, kind, code, message, status, details)
6
+ * from the fetcher layer for use in the repository layer.
7
+ *
8
+ * @param result - Fetch result to convert
9
+ * @returns Snapshot operation result (success pass-through or converted failure)
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // Success case - pass through
14
+ * const fetchSuccess: FetchPrototypesSuccess = {
15
+ * ok: true,
16
+ * data: [{ id: 1, ... }]
17
+ * };
18
+ * const snapshotResult = convertFetchResult(fetchSuccess);
19
+ * // { ok: true, data: [{ id: 1, ... }] } - same object
20
+ *
21
+ * // Failure case - convert
22
+ * const fetchFailure: FetchPrototypesFailure = {
23
+ * ok: false,
24
+ * origin: 'fetcher',
25
+ * kind: 'http',
26
+ * error: 'Not Found',
27
+ * code: 'CLIENT_NOT_FOUND',
28
+ * status: 404,
29
+ * details: { res: { code: 'RESOURCE_NOT_FOUND' } }
30
+ * };
31
+ * const snapshotFailure = convertFetchResult(fetchFailure);
32
+ * // {
33
+ * // ok: false,
34
+ * // origin: 'fetcher',
35
+ * // kind: 'http',
36
+ * // code: 'CLIENT_NOT_FOUND',
37
+ * // message: 'Not Found',
38
+ * // status: 404,
39
+ * // details: { res: { code: 'RESOURCE_NOT_FOUND' } }
40
+ * // }
41
+ * ```
42
+ */
43
+ export function convertFetchResult(result) {
44
+ if (result.ok) {
45
+ // Success case: pass through as-is for caller to access data field
46
+ return result;
47
+ }
48
+ const failure = {
49
+ ok: false,
50
+ origin: 'fetcher',
51
+ kind: result.kind,
52
+ code: result.code,
53
+ message: result.error,
54
+ ...(result.status !== undefined && { status: result.status }),
55
+ details: result.details,
56
+ };
57
+ return failure;
58
+ }
59
+ //# sourceMappingURL=convert-fetch-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-fetch-result.js","sourceRoot":"","sources":["../../../lib/repository/utils/convert-fetch-result.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA6B;IAE7B,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;QACd,mEAAmE;QACnE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,OAAO,GAA2B;QACtC,EAAE,EAAE,KAAK;QACT,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,OAAO,EAAE,MAAM,CAAC,KAAK;QACrB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QAC7D,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;IACF,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { SetResult } from '../../store/types/result.types.js';
2
+ import type { SnapshotOperationResult } from '../types/snapshot-operation.types.js';
3
+ /**
4
+ * Convert SetResult to SnapshotOperationResult.
5
+ *
6
+ * SetResult and SnapshotOperationResult are type-compatible,
7
+ * so this function simply returns the input result without transformation.
8
+ *
9
+ * @param result - Store operation result to convert
10
+ * @returns Snapshot operation result (same as input)
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Success case
15
+ * const storeSuccess: SetResult = {
16
+ * ok: true,
17
+ * stats: { size: 100, cachedAt: new Date(), ... }
18
+ * };
19
+ * const snapshotResult = convertStoreResult(storeSuccess);
20
+ * // { ok: true, stats: { size: 100, cachedAt: ..., ... } } - same object
21
+ *
22
+ * // Failure case
23
+ * const storeFailure: SetResult = {
24
+ * ok: false,
25
+ * origin: 'store',
26
+ * kind: 'storage_limit',
27
+ * code: 'STORE_CAPACITY_EXCEEDED',
28
+ * message: 'Data size exceeds limit',
29
+ * dataState: 'UNCHANGED'
30
+ * };
31
+ * const snapshotFailure = convertStoreResult(storeFailure);
32
+ * // { ok: false, origin: 'store', kind: 'storage_limit', ... } - same object
33
+ * ```
34
+ */
35
+ export declare function convertStoreResult(result: SetResult): SnapshotOperationResult;
36
+ //# sourceMappingURL=convert-store-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-store-result.d.ts","sourceRoot":"","sources":["../../../lib/repository/utils/convert-store-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,uBAAuB,CAE7E"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Convert SetResult to SnapshotOperationResult.
3
+ *
4
+ * SetResult and SnapshotOperationResult are type-compatible,
5
+ * so this function simply returns the input result without transformation.
6
+ *
7
+ * @param result - Store operation result to convert
8
+ * @returns Snapshot operation result (same as input)
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Success case
13
+ * const storeSuccess: SetResult = {
14
+ * ok: true,
15
+ * stats: { size: 100, cachedAt: new Date(), ... }
16
+ * };
17
+ * const snapshotResult = convertStoreResult(storeSuccess);
18
+ * // { ok: true, stats: { size: 100, cachedAt: ..., ... } } - same object
19
+ *
20
+ * // Failure case
21
+ * const storeFailure: SetResult = {
22
+ * ok: false,
23
+ * origin: 'store',
24
+ * kind: 'storage_limit',
25
+ * code: 'STORE_CAPACITY_EXCEEDED',
26
+ * message: 'Data size exceeds limit',
27
+ * dataState: 'UNCHANGED'
28
+ * };
29
+ * const snapshotFailure = convertStoreResult(storeFailure);
30
+ * // { ok: false, origin: 'store', kind: 'storage_limit', ... } - same object
31
+ * ```
32
+ */
33
+ export function convertStoreResult(result) {
34
+ return result;
35
+ }
36
+ //# sourceMappingURL=convert-store-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-store-result.js","sourceRoot":"","sources":["../../../lib/repository/utils/convert-store-result.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { EventEmitter } from 'events';
2
+ import type { Logger } from '../../logger/index.js';
3
+ import type { RepositoryEvents } from '../types/index.js';
4
+ export declare const emitRepositoryEventSafely: <EventName extends keyof RepositoryEvents>(events: EventEmitter | undefined, logger: Logger, eventName: EventName, ...args: Parameters<RepositoryEvents[EventName]>) => void;
5
+ //# sourceMappingURL=emit-repository-event-safely.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-repository-event-safely.d.ts","sourceRoot":"","sources":["../../../lib/repository/utils/emit-repository-event-safely.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,eAAO,MAAM,yBAAyB,GACpC,SAAS,SAAS,MAAM,gBAAgB,EAExC,QAAQ,YAAY,GAAG,SAAS,EAChC,QAAQ,MAAM,EACd,WAAW,SAAS,EACpB,GAAG,MAAM,UAAU,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,KAC/C,IAcF,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { sanitizeDataForLogging } from '../../utils/logger-utils.js';
2
+ export const emitRepositoryEventSafely = (events, logger, eventName, ...args) => {
3
+ if (!events) {
4
+ return;
5
+ }
6
+ try {
7
+ events.emit(eventName, ...args);
8
+ }
9
+ catch (error) {
10
+ logger.error('Repository event emission failed', {
11
+ eventName,
12
+ error: sanitizeDataForLogging(error),
13
+ args: sanitizeDataForLogging(args),
14
+ });
15
+ }
16
+ };
17
+ //# sourceMappingURL=emit-repository-event-safely.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit-repository-event-safely.js","sourceRoot":"","sources":["../../../lib/repository/utils/emit-repository-event-safely.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAGrE,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAGvC,MAAgC,EAChC,MAAc,EACd,SAAoB,EACpB,GAAG,IAA6C,EAC1C,EAAE;IACR,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,IAAI,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,KAAK,CAAC,kCAAkC,EAAE;YAC/C,SAAS;YACT,KAAK,EAAE,sBAAsB,CAAC,KAAK,CAAC;YACpC,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC;SACnC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { convertFetchResult } from './convert-fetch-result.js';
2
+ export { convertStoreResult } from './convert-store-result.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/repository/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { convertFetchResult } from './convert-fetch-result.js';
2
+ export { convertStoreResult } from './convert-store-result.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/repository/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Validation utilities for repository operations.
3
+ *
4
+ * This module provides validation functions and schemas for repository data
5
+ * and method parameters.
6
+ */
7
+ export { RepositoryParamsValidator } from './params-validators.js';
8
+ export { validateSerializableSnapshot } from './serializable-snapshot.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/repository/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Validation utilities for repository operations.
3
+ *
4
+ * This module provides validation functions and schemas for repository data
5
+ * and method parameters.
6
+ */
7
+ // Validators
8
+ export { RepositoryParamsValidator } from './params-validators.js';
9
+ export { validateSerializableSnapshot } from './serializable-snapshot.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/repository/validation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,aAAa;AACb,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Validator class for repository operations.
3
+ *
4
+ * Provides centralized static validation methods for method parameters.
5
+ * All methods throw {@link ValidationError} on invalid input.
6
+ *
7
+ * @remarks
8
+ * This class separates validation concerns from business logic in
9
+ * ProtopediaInMemoryRepositoryImpl, improving testability and maintainability.
10
+ * All methods are static and stateless.
11
+ *
12
+ * For snapshot validation, use {@link validateSerializableSnapshot} directly
13
+ * from './validation/index.js'.
14
+ */
15
+ export declare class RepositoryParamsValidator {
16
+ /**
17
+ * Validate prototype ID parameter.
18
+ *
19
+ * @param id - Prototype ID to validate
20
+ * @throws {ValidationError} If ID is invalid
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * RepositoryParamsValidator.validatePrototypeId(123); // OK
25
+ * RepositoryParamsValidator.validatePrototypeId(0); // throws ValidationError
26
+ * RepositoryParamsValidator.validatePrototypeId(-1); // throws ValidationError
27
+ * ```
28
+ */
29
+ static validatePrototypeId(id: number): void;
30
+ /**
31
+ * Validate sample size parameter.
32
+ *
33
+ * @param size - Sample size to validate
34
+ * @throws {ValidationError} If size is invalid
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * RepositoryParamsValidator.validateSampleSize(10); // OK
39
+ * RepositoryParamsValidator.validateSampleSize(0); // OK
40
+ * RepositoryParamsValidator.validateSampleSize(-5); // OK (handled by caller)
41
+ * RepositoryParamsValidator.validateSampleSize(1.5); // throws ValidationError
42
+ * ```
43
+ */
44
+ static validateSampleSize(size: number): void;
45
+ }
46
+ //# sourceMappingURL=params-validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-validators.d.ts","sourceRoot":"","sources":["../../../lib/repository/validation/params-validators.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;GAaG;AACH,qBAAa,yBAAyB;IACpC;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAW5C;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAU9C"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Repository validator utilities.
3
+ *
4
+ * This module provides the RepositoryParamsValidator class for validating
5
+ * repository method parameters in a centralized manner.
6
+ *
7
+ * @remarks
8
+ * For snapshot validation, use {@link validateSerializableSnapshot} directly
9
+ * from './validation/index.js' instead of methods in this class.
10
+ */
11
+ import { ValidationError } from '../errors/validation-error.js';
12
+ import { prototypeIdSchema, sampleSizeSchema } from '../schemas/params.js';
13
+ /**
14
+ * Validator class for repository operations.
15
+ *
16
+ * Provides centralized static validation methods for method parameters.
17
+ * All methods throw {@link ValidationError} on invalid input.
18
+ *
19
+ * @remarks
20
+ * This class separates validation concerns from business logic in
21
+ * ProtopediaInMemoryRepositoryImpl, improving testability and maintainability.
22
+ * All methods are static and stateless.
23
+ *
24
+ * For snapshot validation, use {@link validateSerializableSnapshot} directly
25
+ * from './validation/index.js'.
26
+ */
27
+ export class RepositoryParamsValidator {
28
+ /**
29
+ * Validate prototype ID parameter.
30
+ *
31
+ * @param id - Prototype ID to validate
32
+ * @throws {ValidationError} If ID is invalid
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * RepositoryParamsValidator.validatePrototypeId(123); // OK
37
+ * RepositoryParamsValidator.validatePrototypeId(0); // throws ValidationError
38
+ * RepositoryParamsValidator.validatePrototypeId(-1); // throws ValidationError
39
+ * ```
40
+ */
41
+ static validatePrototypeId(id) {
42
+ const validation = prototypeIdSchema.safeParse(id);
43
+ if (!validation.success) {
44
+ throw new ValidationError('Invalid prototype ID: must be a positive integer', 'prototypeId', { cause: validation.error });
45
+ }
46
+ }
47
+ /**
48
+ * Validate sample size parameter.
49
+ *
50
+ * @param size - Sample size to validate
51
+ * @throws {ValidationError} If size is invalid
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * RepositoryParamsValidator.validateSampleSize(10); // OK
56
+ * RepositoryParamsValidator.validateSampleSize(0); // OK
57
+ * RepositoryParamsValidator.validateSampleSize(-5); // OK (handled by caller)
58
+ * RepositoryParamsValidator.validateSampleSize(1.5); // throws ValidationError
59
+ * ```
60
+ */
61
+ static validateSampleSize(size) {
62
+ const validation = sampleSizeSchema.safeParse(size);
63
+ if (!validation.success) {
64
+ throw new ValidationError('Invalid sample size: must be an integer', 'size', { cause: validation.error });
65
+ }
66
+ }
67
+ }
68
+ //# sourceMappingURL=params-validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"params-validators.js","sourceRoot":"","sources":["../../../lib/repository/validation/params-validators.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,yBAAyB;IACpC;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,mBAAmB,CAAC,EAAU;QACnC,MAAM,UAAU,GAAG,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CACvB,kDAAkD,EAClD,aAAa,EACb,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAC5B,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,kBAAkB,CAAC,IAAY;QACpC,MAAM,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;YACxB,MAAM,IAAI,eAAe,CACvB,yCAAyC,EACzC,MAAM,EACN,EAAE,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,CAC5B,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Repository data validators.
3
+ *
4
+ * This module provides validation utilities for repository operations,
5
+ * primarily for validating external data before processing (e.g., snapshot imports).
6
+ *
7
+ * These validators return Result types (ValidationResult) instead of throwing errors.
8
+ * For parameter validation at repository API boundaries, use ValidationError with Zod schemas.
9
+ */
10
+ import type { Logger } from '../../logger/logger.types.js';
11
+ import type { ValidationResult } from '../../utils/validation/types.js';
12
+ import type { SerializableSnapshot } from '../types/index.js';
13
+ /**
14
+ * Serializable snapshot validation error code.
15
+ */
16
+ type SerializableSnapshotValidationErrorCode = 'SERIALIZABLE_SNAPSHOT_VALIDATION_ERROR';
17
+ /**
18
+ * Validate a SerializableSnapshot object.
19
+ *
20
+ * Validates the structure of snapshot data for import operations,
21
+ * ensuring version compatibility and data integrity.
22
+ *
23
+ * Validation steps:
24
+ * 1. Check data is a plain object
25
+ * 2. Validate version field (semver format: x.y.z)
26
+ * 3. Validate serializedAt field (ISO-8601 UTC timestamp)
27
+ * 4. Validate prototypes array using {@link validateNormalizedPrototypeArray}
28
+ *
29
+ * @param data - Data to validate
30
+ * @param logger - Optional logger for validation events
31
+ * @returns Validation result with typed data or error details
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const result = validateSerializableSnapshot(data, logger);
36
+ * if (result.ok) {
37
+ * // data is SerializableSnapshot
38
+ * console.log(`Version: ${result.data.version}`);
39
+ * console.log(`Prototypes: ${result.data.prototypes.length}`);
40
+ * } else {
41
+ * console.error(`Invalid snapshot: ${result.message}`);
42
+ * }
43
+ * ```
44
+ */
45
+ export declare function validateSerializableSnapshot(data: unknown, logger?: Logger): ValidationResult<SerializableSnapshot, SerializableSnapshotValidationErrorCode>;
46
+ export {};
47
+ //# sourceMappingURL=serializable-snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializable-snapshot.d.ts","sourceRoot":"","sources":["../../../lib/repository/validation/serializable-snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;GAEG;AACH,KAAK,uCAAuC,GAC1C,wCAAwC,CAAC;AAS3C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,OAAO,EACb,MAAM,CAAC,EAAE,MAAM,GACd,gBAAgB,CACjB,oBAAoB,EACpB,uCAAuC,CACxC,CAkFA"}
@@ -0,0 +1,104 @@
1
+ import { validateNormalizedPrototypeArray } from '../../utils/validation/index.js';
2
+ import { serializedAtSchema, versionSchema, } from '../schemas/serializable-snapshot.js';
3
+ /**
4
+ * Check if value is a plain object.
5
+ */
6
+ function isPlainObject(value) {
7
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
8
+ }
9
+ /**
10
+ * Validate a SerializableSnapshot object.
11
+ *
12
+ * Validates the structure of snapshot data for import operations,
13
+ * ensuring version compatibility and data integrity.
14
+ *
15
+ * Validation steps:
16
+ * 1. Check data is a plain object
17
+ * 2. Validate version field (semver format: x.y.z)
18
+ * 3. Validate serializedAt field (ISO-8601 UTC timestamp)
19
+ * 4. Validate prototypes array using {@link validateNormalizedPrototypeArray}
20
+ *
21
+ * @param data - Data to validate
22
+ * @param logger - Optional logger for validation events
23
+ * @returns Validation result with typed data or error details
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * const result = validateSerializableSnapshot(data, logger);
28
+ * if (result.ok) {
29
+ * // data is SerializableSnapshot
30
+ * console.log(`Version: ${result.data.version}`);
31
+ * console.log(`Prototypes: ${result.data.prototypes.length}`);
32
+ * } else {
33
+ * console.error(`Invalid snapshot: ${result.message}`);
34
+ * }
35
+ * ```
36
+ */
37
+ export function validateSerializableSnapshot(data, logger) {
38
+ // Step 1: Check data is a plain object
39
+ if (!isPlainObject(data)) {
40
+ logger?.warn('Snapshot data validation failed', {
41
+ reason: 'not a plain object',
42
+ type: typeof data,
43
+ });
44
+ return {
45
+ ok: false,
46
+ code: 'SERIALIZABLE_SNAPSHOT_VALIDATION_ERROR',
47
+ message: 'Invalid input: expected object, received ' + typeof data,
48
+ };
49
+ }
50
+ // Step 2: Validate version field using Zod schema
51
+ const versionValidation = versionSchema.safeParse(data.version);
52
+ if (!versionValidation.success) {
53
+ logger?.warn('Snapshot data validation failed', {
54
+ reason: 'invalid version format',
55
+ version: data.version,
56
+ });
57
+ return {
58
+ ok: false,
59
+ code: 'SERIALIZABLE_SNAPSHOT_VALIDATION_ERROR',
60
+ message: data.version === undefined
61
+ ? 'version: Invalid input: expected string, received undefined'
62
+ : 'version: ' + versionValidation.error.issues[0].message,
63
+ };
64
+ }
65
+ // Step 3: Validate serializedAt field using Zod schema
66
+ const serializedAtValidation = serializedAtSchema.safeParse(data.serializedAt);
67
+ if (!serializedAtValidation.success) {
68
+ logger?.warn('Snapshot data validation failed', {
69
+ reason: 'invalid serializedAt format',
70
+ serializedAt: data.serializedAt,
71
+ });
72
+ return {
73
+ ok: false,
74
+ code: 'SERIALIZABLE_SNAPSHOT_VALIDATION_ERROR',
75
+ message: data.serializedAt === undefined
76
+ ? 'serializedAt: Invalid input: expected string, received undefined'
77
+ : 'serializedAt: ' + serializedAtValidation.error.issues[0].message,
78
+ };
79
+ }
80
+ // Step 4: Validate prototypes array using shared validation
81
+ const prototypesValidation = validateNormalizedPrototypeArray(data.prototypes, logger);
82
+ if (!prototypesValidation.ok) {
83
+ // Logger already called by validateNormalizedPrototypeArray
84
+ return {
85
+ ok: false,
86
+ code: 'SERIALIZABLE_SNAPSHOT_VALIDATION_ERROR',
87
+ message: 'prototypes: ' + prototypesValidation.message,
88
+ };
89
+ }
90
+ logger?.info('Snapshot data validated successfully', {
91
+ version: versionValidation.data,
92
+ serializedAt: serializedAtValidation.data,
93
+ prototypeCount: prototypesValidation.data.length,
94
+ });
95
+ return {
96
+ ok: true,
97
+ data: {
98
+ version: versionValidation.data,
99
+ serializedAt: serializedAtValidation.data,
100
+ prototypes: prototypesValidation.data,
101
+ },
102
+ };
103
+ }
104
+ //# sourceMappingURL=serializable-snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializable-snapshot.js","sourceRoot":"","sources":["../../../lib/repository/validation/serializable-snapshot.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Common validation schemas.
3
+ *
4
+ * This module provides Zod schemas for validating common data structures
5
+ * used across multiple modules (fetcher, repository, store).
6
+ */
7
+ export { normalizedPrototypeSchema } from './normalized-prototype.js';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Common validation schemas.
3
+ *
4
+ * This module provides Zod schemas for validating common data structures
5
+ * used across multiple modules (fetcher, repository, store).
6
+ */
7
+ export { normalizedPrototypeSchema } from './normalized-prototype.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/schemas/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Validation schema for NormalizedPrototype.
3
+ *
4
+ * This module provides a Zod schema for validating the structure
5
+ * of normalized prototype objects.
6
+ */
7
+ import { z } from 'zod';
8
+ /**
9
+ * Validation schema for NormalizedPrototype.
10
+ *
11
+ * This schema validates the structure of a single prototype object.
12
+ * Used internally for validating deserialized snapshot data.
13
+ *
14
+ * @remarks
15
+ * This is a comprehensive schema covering all fields of NormalizedPrototype.
16
+ * Optional fields are marked with .optional() and must be undefined (not null)
17
+ * due to exactOptionalPropertyTypes: true.
18
+ */
19
+ export declare const normalizedPrototypeSchema: z.ZodObject<{
20
+ id: z.ZodNumber;
21
+ createDate: z.ZodString;
22
+ updateDate: z.ZodOptional<z.ZodString>;
23
+ releaseDate: z.ZodOptional<z.ZodString>;
24
+ createId: z.ZodOptional<z.ZodNumber>;
25
+ updateId: z.ZodOptional<z.ZodNumber>;
26
+ releaseFlg: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>;
27
+ status: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
28
+ prototypeNm: z.ZodString;
29
+ summary: z.ZodString;
30
+ freeComment: z.ZodString;
31
+ systemDescription: z.ZodString;
32
+ users: z.ZodArray<z.ZodString>;
33
+ teamNm: z.ZodString;
34
+ tags: z.ZodArray<z.ZodString>;
35
+ materials: z.ZodArray<z.ZodString>;
36
+ events: z.ZodArray<z.ZodString>;
37
+ awards: z.ZodArray<z.ZodString>;
38
+ officialLink: z.ZodOptional<z.ZodString>;
39
+ videoUrl: z.ZodOptional<z.ZodString>;
40
+ mainUrl: z.ZodString;
41
+ relatedLink: z.ZodOptional<z.ZodString>;
42
+ relatedLink2: z.ZodOptional<z.ZodString>;
43
+ relatedLink3: z.ZodOptional<z.ZodString>;
44
+ relatedLink4: z.ZodOptional<z.ZodString>;
45
+ relatedLink5: z.ZodOptional<z.ZodString>;
46
+ viewCount: z.ZodNumber;
47
+ goodCount: z.ZodNumber;
48
+ commentCount: z.ZodNumber;
49
+ uuid: z.ZodOptional<z.ZodString>;
50
+ nid: z.ZodOptional<z.ZodString>;
51
+ revision: z.ZodOptional<z.ZodNumber>;
52
+ licenseType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>>;
53
+ thanksFlg: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<0>, z.ZodLiteral<1>]>>;
54
+ slideMode: z.ZodOptional<z.ZodNumber>;
55
+ }, z.core.$strip>;
56
+ //# sourceMappingURL=normalized-prototype.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalized-prototype.d.ts","sourceRoot":"","sources":["../../lib/schemas/normalized-prototype.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAoHpC,CAAC"}