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,70 @@
1
+ /**
2
+ * ProtoPedia API Client and Data Fetching Utilities.
3
+ *
4
+ * This module provides a complete fetcher layer for interacting with the
5
+ * ProtoPedia API, including client creation, data fetching, normalization,
6
+ * and error handling. It can be used as a standalone module for custom
7
+ * data pipelines or integrated with the repository layer.
8
+ *
9
+ * ## Core Components
10
+ *
11
+ * - {@link ProtopediaApiCustomClient} — Class-based client with managed logger and high-level methods.
12
+ * - {@link ProtopediaApiCustomClientConfig} — Configuration options including logger and SDK client settings.
13
+ *
14
+ * ### Dependencies
15
+ *
16
+ * Types from `protopedia-api-v2-client` should be imported directly from the package:
17
+ * - `ProtoPediaApiClientOptions` — SDK client options.
18
+ * - `ListPrototypesParams` — Query parameters for listing prototypes.
19
+ *
20
+ * ### Data Fetching & Normalization
21
+ *
22
+ * - {@link FetchPrototypesResult} — Discriminated union result type for fetch operations.
23
+ * - {@link normalizePrototype} — Transform raw API data to {@link NormalizedPrototype}.
24
+ * - {@link UpstreamPrototype} — Raw API response type from protopedia-api-v2-client.
25
+ * - {@link NormalizedPrototype} — Standardized, type-safe prototype data model.
26
+ *
27
+ * ### Logging
28
+ *
29
+ * - {@link Logger} — Logger interface compatible with protopedia-api-v2-client.
30
+ * - {@link LogLevel} — Log level type for controlling logger verbosity.
31
+ *
32
+ * ## Standalone Usage
33
+ *
34
+ * This module is designed to work independently, allowing you to:
35
+ * - Create custom API clients with specific configurations
36
+ * - Build custom data processing pipelines
37
+ * - Integrate with different runtime environments (Node.js, Next.js, etc.)
38
+ *
39
+ * ## API Client Version Compatibility
40
+ *
41
+ * This library supports `protopedia-api-v2-client` v3.0.0 and later.
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * import { ProtopediaApiCustomClient } from 'promidas/fetcher';
46
+ *
47
+ * const client = new ProtopediaApiCustomClient({
48
+ * protoPediaApiClientOptions: {
49
+ * token: process.env.PROTOPEDIA_API_TOKEN,
50
+ * },
51
+ * logLevel: 'debug',
52
+ * });
53
+ *
54
+ * const result = await client.fetchPrototypes({ limit: 10 });
55
+ *
56
+ * if (result.ok) {
57
+ * console.log(`Fetched ${result.data.length} prototypes`);
58
+ * }
59
+ * ```
60
+ *
61
+ * @module
62
+ * @see {@link ../repository/index.js} for high-level repository integration
63
+ */
64
+ // API Client
65
+ export { ProtopediaApiCustomClient } from './client/protopedia-api-custom-client.js';
66
+ // Errors
67
+ export { PromidasTimeoutError } from './errors/fetcher-error.js';
68
+ // Utilities
69
+ export { normalizePrototype } from './utils/normalize-prototype.js';
70
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/fetcher/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAQH,aAAa;AACb,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AAMrF,SAAS;AACT,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAYjE,YAAY;AACZ,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Type definitions for the fetcher module.
3
+ *
4
+ * @module
5
+ */
6
+ export type { FetchProgressEvent, FetchProgressRequestStartEvent, FetchProgressResponseReceivedEvent, FetchProgressDownloadProgressEvent, FetchProgressCompleteEvent, FetchProgressErrorEvent, } from './progress-event.types.js';
7
+ export type { UpstreamPrototype, NetworkFailure, } from './prototype-api.types.js';
8
+ export type { FetchPrototypesResult, FetchPrototypesSuccess, FetchPrototypesFailure, FetchFailureKind, FetcherErrorCode, } from './result.types.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,YAAY,EACV,kBAAkB,EAClB,8BAA8B,EAC9B,kCAAkC,EAClC,kCAAkC,EAClC,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,iBAAiB,EACjB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAElC,YAAY,EACV,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Type definitions for the fetcher module.
3
+ *
4
+ * @module
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/fetcher/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,221 @@
1
+ /**
2
+ * Progress event types for fetch operations.
3
+ *
4
+ * This module defines event types for tracking the complete lifecycle
5
+ * of HTTP requests, from initiation to completion.
6
+ *
7
+ * @module
8
+ */
9
+ /**
10
+ * Event fired when a fetch request starts.
11
+ *
12
+ * This event occurs immediately before the `fetch()` call is made,
13
+ * marking the beginning of the request lifecycle.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * if (event.type === 'request-start') {
18
+ * console.log('Request initiated...');
19
+ * }
20
+ * ```
21
+ */
22
+ export type FetchProgressRequestStartEvent = {
23
+ type: 'request-start';
24
+ };
25
+ /**
26
+ * Event fired when response headers are received.
27
+ *
28
+ * This event occurs after the server responds with headers but before
29
+ * the response body download begins. It includes timing information
30
+ * for the preparation phase and estimated download size.
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * if (event.type === 'response-received') {
35
+ * console.log(`Headers received in ${event.prepareTimeMs}ms`);
36
+ * console.log(`Estimated download: ${event.estimatedTotal} bytes`);
37
+ * }
38
+ * ```
39
+ */
40
+ export type FetchProgressResponseReceivedEvent = {
41
+ type: 'response-received';
42
+ /**
43
+ * Time spent from request start to header reception (milliseconds).
44
+ */
45
+ prepareTimeMs: number;
46
+ /**
47
+ * Estimated total download size in bytes.
48
+ * Derived from Content-Length header or URL parameters.
49
+ */
50
+ estimatedTotal: number;
51
+ /**
52
+ * Number of items being fetched (from URL limit parameter).
53
+ * 0 if limit parameter is not present.
54
+ */
55
+ limit: number;
56
+ };
57
+ /**
58
+ * Event fired during response body download.
59
+ *
60
+ * This event provides real-time progress updates as data is received.
61
+ * Events are throttled to occur at most once every 500ms to avoid overhead.
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * if (event.type === 'download-progress') {
66
+ * console.log(`Progress: ${event.percentage.toFixed(1)}%`);
67
+ * console.log(`${event.received} / ${event.total} bytes`);
68
+ * }
69
+ * ```
70
+ */
71
+ export type FetchProgressDownloadProgressEvent = {
72
+ type: 'download-progress';
73
+ /**
74
+ * Number of bytes received so far.
75
+ */
76
+ received: number;
77
+ /**
78
+ * Total number of bytes to download.
79
+ * May be 0 if Content-Length header is missing.
80
+ */
81
+ total: number;
82
+ /**
83
+ * Download progress as a percentage (0-100).
84
+ * 0 if total is unknown.
85
+ */
86
+ percentage: number;
87
+ };
88
+ /**
89
+ * Event fired when download completes successfully.
90
+ *
91
+ * This event marks the successful completion of the entire request lifecycle,
92
+ * including both preparation and download phases.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * if (event.type === 'complete') {
97
+ * console.log(`Downloaded ${event.received} bytes`);
98
+ * console.log(`Total time: ${event.totalTimeMs}ms`);
99
+ * console.log(`Download time: ${event.downloadTimeMs}ms`);
100
+ * }
101
+ * ```
102
+ */
103
+ export type FetchProgressCompleteEvent = {
104
+ type: 'complete';
105
+ /**
106
+ * Total number of bytes actually received.
107
+ */
108
+ received: number;
109
+ /**
110
+ * Estimated total size in bytes (from headers or URL parameters).
111
+ */
112
+ estimatedTotal: number;
113
+ /**
114
+ * Time spent downloading the response body (milliseconds).
115
+ */
116
+ downloadTimeMs: number;
117
+ /**
118
+ * Total time from request start to completion (milliseconds).
119
+ * Includes both preparation and download time.
120
+ */
121
+ totalTimeMs: number;
122
+ };
123
+ /**
124
+ * Event fired when an error occurs during stream reading.
125
+ *
126
+ * This event is emitted when an error is thrown while reading the
127
+ * response body stream, such as network errors, timeout errors,
128
+ * or authentication failures (e.g., 401 Unauthorized).
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * if (event.type === 'error') {
133
+ * console.error(`Download failed: ${event.error}`);
134
+ * console.log(`Received ${event.received} bytes before error`);
135
+ * console.log(`Failed after ${event.totalTimeMs}ms`);
136
+ * }
137
+ * ```
138
+ */
139
+ export type FetchProgressErrorEvent = {
140
+ type: 'error';
141
+ /**
142
+ * Error message describing what went wrong.
143
+ */
144
+ error: string;
145
+ /**
146
+ * Number of bytes successfully received before the error occurred.
147
+ */
148
+ received: number;
149
+ /**
150
+ * Estimated total size in bytes (from headers or URL parameters).
151
+ */
152
+ estimatedTotal: number;
153
+ /**
154
+ * Time spent on download attempt before error (milliseconds).
155
+ */
156
+ downloadTimeMs: number;
157
+ /**
158
+ * Total time from request start to error (milliseconds).
159
+ * Includes both preparation and download time.
160
+ */
161
+ totalTimeMs: number;
162
+ };
163
+ /**
164
+ * Discriminated union of all fetch progress events.
165
+ *
166
+ * This type represents all possible events that can occur during
167
+ * a fetch request lifecycle. TypeScript's discriminated union feature
168
+ * enables type-safe event handling based on the `type` property.
169
+ *
170
+ * ## Event Lifecycle
171
+ *
172
+ * **Success flow:**
173
+ * 1. `request-start` → Request initiated
174
+ * 2. `response-received` → Headers received
175
+ * 3. `download-progress` (multiple, throttled) → Body streaming
176
+ * 4. `complete` → Download finished successfully
177
+ *
178
+ * **Error flow (stream reading failure):**
179
+ * 1. `request-start` → Request initiated
180
+ * 2. `response-received` → Headers received
181
+ * 3. `download-progress` (optional) → Partial data received
182
+ * 4. `error` → Stream reading failed (e.g., network error, auth failure)
183
+ *
184
+ * Note: `download-progress` events may occur before `error` if some chunks
185
+ * were successfully read before the failure.
186
+ *
187
+ * @example Basic usage
188
+ * ```typescript
189
+ * function handleProgressEvent(event: FetchProgressEvent) {
190
+ * switch (event.type) {
191
+ * case 'request-start':
192
+ * console.log('Starting request...');
193
+ * break;
194
+ * case 'response-received':
195
+ * console.log(`Headers received (${event.prepareTimeMs}ms)`);
196
+ * break;
197
+ * case 'download-progress':
198
+ * console.log(`Progress: ${event.percentage}%`);
199
+ * break;
200
+ * case 'complete':
201
+ * console.log(`Complete (${event.totalTimeMs}ms)`);
202
+ * break;
203
+ * case 'error':
204
+ * console.error(`Error: ${event.error}`);
205
+ * break;
206
+ * }
207
+ * }
208
+ * ```
209
+ *
210
+ * @example Type narrowing
211
+ * ```typescript
212
+ * function handleEvent(event: FetchProgressEvent) {
213
+ * if (event.type === 'download-progress') {
214
+ * // TypeScript knows event has percentage, received, total properties
215
+ * updateProgressBar(event.percentage);
216
+ * }
217
+ * }
218
+ * ```
219
+ */
220
+ export type FetchProgressEvent = FetchProgressRequestStartEvent | FetchProgressResponseReceivedEvent | FetchProgressDownloadProgressEvent | FetchProgressCompleteEvent | FetchProgressErrorEvent;
221
+ //# sourceMappingURL=progress-event.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-event.types.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/types/progress-event.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,mBAAmB,CAAC;IAC1B;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,UAAU,CAAC;IACjB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,MAAM,kBAAkB,GAC1B,8BAA8B,GAC9B,kCAAkC,GAClC,kCAAkC,GAClC,0BAA0B,GAC1B,uBAAuB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Progress event types for fetch operations.
3
+ *
4
+ * This module defines event types for tracking the complete lifecycle
5
+ * of HTTP requests, from initiation to completion.
6
+ *
7
+ * @module
8
+ */
9
+ export {};
10
+ //# sourceMappingURL=progress-event.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"progress-event.types.js","sourceRoot":"","sources":["../../../lib/fetcher/types/progress-event.types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1,106 @@
1
+ import type { ResultOfListPrototypesApiResponse } from 'protopedia-api-v2-client';
2
+ /**
3
+ * Alias for the upstream prototype shape returned by the ProtoPedia SDK.
4
+ *
5
+ * This type represents a single prototype object as delivered by the
6
+ * `listPrototypes` API response. It is the input to normalization functions.
7
+ *
8
+ * **Important:** This is a direct re-export of the SDK's response type.
9
+ * If `protopedia-api-v2-client` changes its response shape in a future
10
+ * version, this type will automatically reflect those changes. The
11
+ * following areas may be affected:
12
+ *
13
+ * - Normalization function implementation (field mappings)
14
+ * - {@link NormalizedPrototype} type definition (may need updates)
15
+ * - Normalization tests (may need new test cases)
16
+ * - Helper functions (pipe-separated string parsing, timestamp normalization)
17
+ *
18
+ * **When upgrading `protopedia-api-v2-client`:**
19
+ * 1. Review the SDK's changelog for new or changed fields
20
+ * 2. Run tests - field coverage tests will fail if new fields are not normalized
21
+ * 3. Update normalization logic to handle new fields
22
+ * 4. Update {@link NormalizedPrototype} type if needed
23
+ * 5. Add test cases for new field transformations
24
+ */
25
+ export type UpstreamPrototype = ResultOfListPrototypesApiResponse;
26
+ /**
27
+ * Structure for network failure responses in Result-type patterns.
28
+ *
29
+ * This type represents error data for Result-type patterns (`{ ok: false, ... }`),
30
+ * distinct from the {@link ProtoPediaApiError} exception class from
31
+ * protopedia-api-v2-client. The structure is designed to be compatible with
32
+ * {@link FetchPrototypesFailure} and maintains consistency with error
33
+ * information from {@link ProtoPediaApiError}.
34
+ *
35
+ * ## Relationship with ProtoPediaApiError
36
+ *
37
+ * **NetworkFailure** is a plain data object, while **ProtoPediaApiError** is an
38
+ * Error subclass:
39
+ * - NetworkFailure: Used in Result types for functional error handling
40
+ * - ProtoPediaApiError: Thrown as exceptions by protopedia-api-v2-client
41
+ * - NetworkFailure: Can represent errors from any source (API, timeout, unexpected)
42
+ * - ProtoPediaApiError: Specifically represents HTTP errors from ProtoPedia API
43
+ *
44
+ * The `details` structure mirrors request/response metadata from
45
+ * {@link ProtoPediaApiError} (`req.url`, `req.method`, `statusText`) to maintain
46
+ * compatibility when converting API exceptions to Result types.
47
+ *
48
+ * ## Details Field
49
+ *
50
+ * The `details` object is always present and may contain:
51
+ * - Empty object `{}` for errors without metadata (AbortError, unexpected errors)
52
+ * - `req` object with URL and HTTP method from the request
53
+ * - `res` object with HTTP status text and optional error code
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * // From ProtoPediaApiError (v2.0.0) - HTTP error with status
58
+ * const failure: NetworkFailure = {
59
+ * status: 404,
60
+ * error: 'Prototype not found',
61
+ * details: {
62
+ * req: { url: 'https://protopedia.cc/api/prototypes/123', method: 'GET' },
63
+ * res: { statusText: 'Not Found' }
64
+ * }
65
+ * };
66
+ *
67
+ * // Network error (ECONNREFUSED) - no status
68
+ * const networkError: NetworkFailure = {
69
+ * error: 'connect ECONNREFUSED',
70
+ * details: {
71
+ * res: { code: 'ECONNREFUSED' }
72
+ * }
73
+ * };
74
+ * ```
75
+ */
76
+ export type NetworkFailure = {
77
+ /** Error message from Error.message or fallback string */
78
+ error: unknown;
79
+ /**
80
+ * HTTP status code from server response (e.g., 404, 500).
81
+ * Undefined for network errors where no server response was received
82
+ * (e.g., ENOTFOUND, ECONNREFUSED, AbortError).
83
+ */
84
+ status?: number;
85
+ /**
86
+ * Additional error details from request and response.
87
+ * Always present, but may be an empty object for errors without metadata.
88
+ */
89
+ details: {
90
+ /** Request information (compatible with ProtoPediaApiError.req from v2.0.0) */
91
+ req?: {
92
+ /** HTTP method (e.g., "GET", "POST") */
93
+ method?: string;
94
+ /** Request URL */
95
+ url?: string;
96
+ };
97
+ /** Response information (compatible with ProtoPediaApiError metadata) */
98
+ res?: {
99
+ /** HTTP status text (e.g., "Not Found", "Internal Server Error") */
100
+ statusText?: string;
101
+ /** Error code from the API (e.g., "RESOURCE_NOT_FOUND") */
102
+ code?: string;
103
+ };
104
+ };
105
+ };
106
+ //# sourceMappingURL=prototype-api.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-api.types.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/types/prototype-api.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,0BAA0B,CAAC;AAElF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,iBAAiB,GAAG,iCAAiC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,0DAA0D;IAC1D,KAAK,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,EAAE;QACP,+EAA+E;QAC/E,GAAG,CAAC,EAAE;YACJ,wCAAwC;YACxC,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,kBAAkB;YAClB,GAAG,CAAC,EAAE,MAAM,CAAC;SACd,CAAC;QACF,yEAAyE;QACzE,GAAG,CAAC,EAAE;YACJ,oEAAoE;YACpE,UAAU,CAAC,EAAE,MAAM,CAAC;YACpB,2DAA2D;YAC3D,IAAI,CAAC,EAAE,MAAM,CAAC;SACf,CAAC;KACH,CAAC;CACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=prototype-api.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prototype-api.types.js","sourceRoot":"","sources":["../../../lib/fetcher/types/prototype-api.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,75 @@
1
+ import type { NormalizedPrototype } from '../../types/index.js';
2
+ import type { NetworkFailure } from './prototype-api.types.js';
3
+ /**
4
+ * Coarse-grained discriminant for fetcher failures.
5
+ *
6
+ * - http: HTTP response was received (status is available)
7
+ * - cors: Browser returned an opaque response (no status/code observable)
8
+ * - network: Network/socket error without HTTP response (ENOTFOUND, ECONNREFUSED, etc.)
9
+ * - timeout: Fetcher-level timeout (no HTTP response)
10
+ * - abort: Caller-driven abort (AbortController)
11
+ * - unknown: Classification failed; fall back to code UNKNOWN
12
+ */
13
+ export type FetchFailureKind = 'http' | 'cors' | 'network' | 'timeout' | 'abort' | 'unknown';
14
+ /**
15
+ * Canonical error codes exposed by the fetcher.
16
+ *
17
+ * HTTP (4xx): CLIENT_UNAUTHORIZED / CLIENT_FORBIDDEN / CLIENT_NOT_FOUND /
18
+ * CLIENT_RATE_LIMITED / CLIENT_BAD_REQUEST / CLIENT_METHOD_NOT_ALLOWED /
19
+ * CLIENT_TIMEOUT / CLIENT_ERROR (other 4xx)
20
+ * HTTP (5xx): SERVER_INTERNAL_ERROR / SERVER_BAD_GATEWAY /
21
+ * SERVER_GATEWAY_TIMEOUT / SERVER_SERVICE_UNAVAILABLE / SERVER_ERROR (other 5xx)
22
+ * Network: NETWORK_ERROR / ECONNREFUSED / ENOTFOUND / ETIMEDOUT
23
+ * Control: TIMEOUT (fetcher timeout), ABORTED (AbortController)
24
+ * CORS: CORS_BLOCKED (opaque response; status/code not observable)
25
+ * Fallback: UNKNOWN
26
+ */
27
+ export type FetcherErrorCode = 'CLIENT_UNAUTHORIZED' | 'CLIENT_FORBIDDEN' | 'CLIENT_NOT_FOUND' | 'CLIENT_RATE_LIMITED' | 'CLIENT_BAD_REQUEST' | 'CLIENT_METHOD_NOT_ALLOWED' | 'CLIENT_TIMEOUT' | 'CLIENT_ERROR' | 'SERVER_INTERNAL_ERROR' | 'SERVER_BAD_GATEWAY' | 'SERVER_GATEWAY_TIMEOUT' | 'SERVER_SERVICE_UNAVAILABLE' | 'SERVER_ERROR' | 'NETWORK_ERROR' | 'ECONNREFUSED' | 'ENOTFOUND' | 'ETIMEDOUT' | 'TIMEOUT' | 'ABORTED' | 'CORS_BLOCKED' | 'UNKNOWN';
28
+ /**
29
+ * Successful response from fetchPrototypes containing an array of prototypes.
30
+ */
31
+ export type FetchPrototypesSuccess = {
32
+ ok: true;
33
+ data: NormalizedPrototype[];
34
+ };
35
+ /**
36
+ * Failed response from fetchPrototypes with error details.
37
+ */
38
+ export type FetchPrototypesFailure = {
39
+ ok: false;
40
+ /** Always fetcher-originated. */
41
+ origin: 'fetcher';
42
+ /** Coarse-grained classification of the failure cause. */
43
+ kind: FetchFailureKind;
44
+ /** Canonicalized error code (in addition to details.res.code). */
45
+ code: FetcherErrorCode;
46
+ /** Human-readable error message. */
47
+ error: string;
48
+ } & Omit<NetworkFailure, 'error'>;
49
+ /**
50
+ * Result type for fetchPrototypes function - either success with data or failure with error.
51
+ */
52
+ export type FetchPrototypesResult = FetchPrototypesSuccess | FetchPrototypesFailure;
53
+ /**
54
+ * Successful response from fetchRandomPrototype containing a single prototype.
55
+ */
56
+ export type FetchRandomPrototypeSuccess = {
57
+ ok: true;
58
+ data: NormalizedPrototype;
59
+ };
60
+ /**
61
+ * Failed response from fetchRandomPrototype (same as FetchPrototypesFailure).
62
+ */
63
+ export type FetchRandomPrototypeFailure = FetchPrototypesFailure;
64
+ /**
65
+ * Result type for fetchRandomPrototype function - either success with single prototype or failure.
66
+ */
67
+ export type FetchRandomPrototypeResult = FetchRandomPrototypeSuccess | FetchRandomPrototypeFailure;
68
+ /**
69
+ * Result type for fetchPrototypeById function - either success with single prototype or failure.
70
+ */
71
+ export type FetchPrototypeByIdResult = {
72
+ ok: true;
73
+ data: NormalizedPrototype;
74
+ } | FetchPrototypesFailure;
75
+ //# sourceMappingURL=result.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.types.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/types/result.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,MAAM,GACN,SAAS,GACT,SAAS,GACT,OAAO,GACP,SAAS,CAAC;AAEd;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB,kBAAkB,GAClB,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,2BAA2B,GAC3B,gBAAgB,GAChB,cAAc,GACd,uBAAuB,GACvB,oBAAoB,GACpB,wBAAwB,GACxB,4BAA4B,GAC5B,cAAc,GACd,eAAe,GACf,cAAc,GACd,WAAW,GACX,WAAW,GACX,SAAS,GACT,SAAS,GACT,cAAc,GACd,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,mBAAmB,EAAE,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,KAAK,CAAC;IACV,iCAAiC;IACjC,MAAM,EAAE,SAAS,CAAC;IAClB,0DAA0D;IAC1D,IAAI,EAAE,gBAAgB,CAAC;IACvB,kEAAkE;IAClE,IAAI,EAAE,gBAAgB,CAAC;IACvB,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,sBAAsB,GACtB,sBAAsB,CAAC;AAE3B;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACxC,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,mBAAmB,CAAC;CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,sBAAsB,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,2BAA2B,GAC3B,2BAA2B,CAAC;AAEhC;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAChC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,mBAAmB,CAAA;CAAE,GACvC,sBAAsB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=result.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.types.js","sourceRoot":"","sources":["../../../lib/fetcher/types/result.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Client fetch function factory.
3
+ *
4
+ * This module provides a factory function that creates a customized fetch function
5
+ * by composing multiple fetch wrappers based on configuration:
6
+ * - Timeout wrapper (if timeoutMs is specified)
7
+ * - Header stripping wrapper (for browser compatibility)
8
+ * - Progress tracking wrapper (if progress features are enabled)
9
+ *
10
+ * @module
11
+ */
12
+ import type { Logger } from '../../logger/index.js';
13
+ import type { FetchProgressEvent } from '../types/progress-event.types.js';
14
+ /**
15
+ * Parameters for creating a customized fetch function.
16
+ */
17
+ export type CreateClientFetchParams = {
18
+ logger: Logger;
19
+ enableProgressLog: boolean;
20
+ progressCallback: ((event: FetchProgressEvent) => void) | undefined;
21
+ timeoutMs: number | undefined;
22
+ providedFetch: typeof fetch | undefined;
23
+ stripHeaders?: string[] | undefined;
24
+ };
25
+ /**
26
+ * Create a customized fetch function with optional features.
27
+ *
28
+ * This function composes multiple fetch wrappers in the following order:
29
+ * 1. Timeout wrapper (if timeoutMs is specified)
30
+ * 2. Header stripping wrapper (if stripHeaders is specified)
31
+ * 3. Progress tracking wrapper (if enableProgressLog or progressCallback is specified)
32
+ *
33
+ * @param params - Configuration parameters for fetch customization
34
+ * @returns Customized fetch function, or undefined to use default fetch
35
+ *
36
+ * @example Basic usage with timeout
37
+ * ```typescript
38
+ * const customFetch = createClientFetch({
39
+ * logger: myLogger,
40
+ * enableProgressLog: false,
41
+ * progressCallback: undefined,
42
+ * timeoutMs: 30000,
43
+ * providedFetch: undefined,
44
+ * });
45
+ * ```
46
+ *
47
+ * @example With progress tracking
48
+ * ```typescript
49
+ * const customFetch = createClientFetch({
50
+ * logger: myLogger,
51
+ * enableProgressLog: true,
52
+ * progressCallback: (event) => {
53
+ * if (event.type === 'download-progress') {
54
+ * console.log(`Progress: ${event.percentage}%`);
55
+ * }
56
+ * },
57
+ * timeoutMs: undefined,
58
+ * providedFetch: undefined,
59
+ * });
60
+ * ```
61
+ */
62
+ export declare function createClientFetch(params: CreateClientFetchParams): typeof fetch | undefined;
63
+ //# sourceMappingURL=create-client-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-client-fetch.d.ts","sourceRoot":"","sources":["../../../lib/fetcher/utils/create-client-fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAI3E;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,CAAC,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACpE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,aAAa,EAAE,OAAO,KAAK,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,KAAK,GAAG,SAAS,CAmD1B"}