local-risk-alert-feed 0.1.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 (283) hide show
  1. package/dist/cjs/adapters/index.js +8 -0
  2. package/dist/cjs/adapters/index.js.map +1 -0
  3. package/dist/cjs/adapters/lambda.js +143 -0
  4. package/dist/cjs/adapters/lambda.js.map +1 -0
  5. package/dist/cjs/adapters/vercel.js +119 -0
  6. package/dist/cjs/adapters/vercel.js.map +1 -0
  7. package/dist/cjs/core/alert-aggregator.js +207 -0
  8. package/dist/cjs/core/alert-aggregator.js.map +1 -0
  9. package/dist/cjs/core/alert-feed.js +236 -0
  10. package/dist/cjs/core/alert-feed.js.map +1 -0
  11. package/dist/cjs/core/index.js +22 -0
  12. package/dist/cjs/core/index.js.map +1 -0
  13. package/dist/cjs/core/plugin-registry.js +193 -0
  14. package/dist/cjs/core/plugin-registry.js.map +1 -0
  15. package/dist/cjs/core/plugin-resolver.js +121 -0
  16. package/dist/cjs/core/plugin-resolver.js.map +1 -0
  17. package/dist/cjs/core/time-range.js +67 -0
  18. package/dist/cjs/core/time-range.js.map +1 -0
  19. package/dist/cjs/errors/fetch-error.js +71 -0
  20. package/dist/cjs/errors/fetch-error.js.map +1 -0
  21. package/dist/cjs/errors/index.js +15 -0
  22. package/dist/cjs/errors/index.js.map +1 -0
  23. package/dist/cjs/errors/plugin-error.js +80 -0
  24. package/dist/cjs/errors/plugin-error.js.map +1 -0
  25. package/dist/cjs/errors/validation-error.js +49 -0
  26. package/dist/cjs/errors/validation-error.js.map +1 -0
  27. package/dist/cjs/geo/distance.js +94 -0
  28. package/dist/cjs/geo/distance.js.map +1 -0
  29. package/dist/cjs/geo/index.js +18 -0
  30. package/dist/cjs/geo/index.js.map +1 -0
  31. package/dist/cjs/geo/point-in-radius.js +86 -0
  32. package/dist/cjs/geo/point-in-radius.js.map +1 -0
  33. package/dist/cjs/index.js +90 -0
  34. package/dist/cjs/index.js.map +1 -0
  35. package/dist/cjs/plugins/air-quality/airnow.plugin.js +343 -0
  36. package/dist/cjs/plugins/air-quality/airnow.plugin.js.map +1 -0
  37. package/dist/cjs/plugins/air-quality/index.js +6 -0
  38. package/dist/cjs/plugins/air-quality/index.js.map +1 -0
  39. package/dist/cjs/plugins/base-plugin.js +213 -0
  40. package/dist/cjs/plugins/base-plugin.js.map +1 -0
  41. package/dist/cjs/plugins/events/index.js +6 -0
  42. package/dist/cjs/plugins/events/index.js.map +1 -0
  43. package/dist/cjs/plugins/events/phoenix-events.plugin.js +382 -0
  44. package/dist/cjs/plugins/events/phoenix-events.plugin.js.map +1 -0
  45. package/dist/cjs/plugins/fire-emt/index.js +6 -0
  46. package/dist/cjs/plugins/fire-emt/index.js.map +1 -0
  47. package/dist/cjs/plugins/fire-emt/phoenix-fire.plugin.js +262 -0
  48. package/dist/cjs/plugins/fire-emt/phoenix-fire.plugin.js.map +1 -0
  49. package/dist/cjs/plugins/index.js +28 -0
  50. package/dist/cjs/plugins/index.js.map +1 -0
  51. package/dist/cjs/plugins/police-blotter/index.js +6 -0
  52. package/dist/cjs/plugins/police-blotter/index.js.map +1 -0
  53. package/dist/cjs/plugins/police-blotter/phoenix-police.plugin.js +198 -0
  54. package/dist/cjs/plugins/police-blotter/phoenix-police.plugin.js.map +1 -0
  55. package/dist/cjs/plugins/pulsepoint/index.js +6 -0
  56. package/dist/cjs/plugins/pulsepoint/index.js.map +1 -0
  57. package/dist/cjs/plugins/pulsepoint/pulsepoint.plugin.js +275 -0
  58. package/dist/cjs/plugins/pulsepoint/pulsepoint.plugin.js.map +1 -0
  59. package/dist/cjs/plugins/traffic/arizona-traffic.plugin.js +391 -0
  60. package/dist/cjs/plugins/traffic/arizona-traffic.plugin.js.map +1 -0
  61. package/dist/cjs/plugins/traffic/index.js +6 -0
  62. package/dist/cjs/plugins/traffic/index.js.map +1 -0
  63. package/dist/cjs/plugins/weather/index.js +6 -0
  64. package/dist/cjs/plugins/weather/index.js.map +1 -0
  65. package/dist/cjs/plugins/weather/nws-weather.plugin.js +180 -0
  66. package/dist/cjs/plugins/weather/nws-weather.plugin.js.map +1 -0
  67. package/dist/cjs/schemas/alert.schema.js +93 -0
  68. package/dist/cjs/schemas/alert.schema.js.map +1 -0
  69. package/dist/cjs/schemas/index.js +24 -0
  70. package/dist/cjs/schemas/index.js.map +1 -0
  71. package/dist/cjs/schemas/query.schema.js +76 -0
  72. package/dist/cjs/schemas/query.schema.js.map +1 -0
  73. package/dist/cjs/types/alert.js +35 -0
  74. package/dist/cjs/types/alert.js.map +1 -0
  75. package/dist/cjs/types/config.js +13 -0
  76. package/dist/cjs/types/config.js.map +1 -0
  77. package/dist/cjs/types/geo.js +3 -0
  78. package/dist/cjs/types/geo.js.map +1 -0
  79. package/dist/cjs/types/index.js +16 -0
  80. package/dist/cjs/types/index.js.map +1 -0
  81. package/dist/cjs/types/plugin.js +3 -0
  82. package/dist/cjs/types/plugin.js.map +1 -0
  83. package/dist/cjs/types/query.js +28 -0
  84. package/dist/cjs/types/query.js.map +1 -0
  85. package/dist/cjs/utils/cache.js +188 -0
  86. package/dist/cjs/utils/cache.js.map +1 -0
  87. package/dist/cjs/utils/csv.js +189 -0
  88. package/dist/cjs/utils/csv.js.map +1 -0
  89. package/dist/cjs/utils/date.js +153 -0
  90. package/dist/cjs/utils/date.js.map +1 -0
  91. package/dist/cjs/utils/index.js +28 -0
  92. package/dist/cjs/utils/index.js.map +1 -0
  93. package/dist/cjs/utils/retry.js +109 -0
  94. package/dist/cjs/utils/retry.js.map +1 -0
  95. package/dist/esm/adapters/index.js +3 -0
  96. package/dist/esm/adapters/index.js.map +1 -0
  97. package/dist/esm/adapters/lambda.js +140 -0
  98. package/dist/esm/adapters/lambda.js.map +1 -0
  99. package/dist/esm/adapters/vercel.js +116 -0
  100. package/dist/esm/adapters/vercel.js.map +1 -0
  101. package/dist/esm/core/alert-aggregator.js +203 -0
  102. package/dist/esm/core/alert-aggregator.js.map +1 -0
  103. package/dist/esm/core/alert-feed.js +232 -0
  104. package/dist/esm/core/alert-feed.js.map +1 -0
  105. package/dist/esm/core/index.js +6 -0
  106. package/dist/esm/core/index.js.map +1 -0
  107. package/dist/esm/core/plugin-registry.js +189 -0
  108. package/dist/esm/core/plugin-registry.js.map +1 -0
  109. package/dist/esm/core/plugin-resolver.js +117 -0
  110. package/dist/esm/core/plugin-resolver.js.map +1 -0
  111. package/dist/esm/core/time-range.js +57 -0
  112. package/dist/esm/core/time-range.js.map +1 -0
  113. package/dist/esm/errors/fetch-error.js +67 -0
  114. package/dist/esm/errors/fetch-error.js.map +1 -0
  115. package/dist/esm/errors/index.js +4 -0
  116. package/dist/esm/errors/index.js.map +1 -0
  117. package/dist/esm/errors/plugin-error.js +71 -0
  118. package/dist/esm/errors/plugin-error.js.map +1 -0
  119. package/dist/esm/errors/validation-error.js +45 -0
  120. package/dist/esm/errors/validation-error.js.map +1 -0
  121. package/dist/esm/geo/distance.js +85 -0
  122. package/dist/esm/geo/distance.js.map +1 -0
  123. package/dist/esm/geo/index.js +3 -0
  124. package/dist/esm/geo/index.js.map +1 -0
  125. package/dist/esm/geo/point-in-radius.js +79 -0
  126. package/dist/esm/geo/point-in-radius.js.map +1 -0
  127. package/dist/esm/index.js +30 -0
  128. package/dist/esm/index.js.map +1 -0
  129. package/dist/esm/plugins/air-quality/airnow.plugin.js +339 -0
  130. package/dist/esm/plugins/air-quality/airnow.plugin.js.map +1 -0
  131. package/dist/esm/plugins/air-quality/index.js +2 -0
  132. package/dist/esm/plugins/air-quality/index.js.map +1 -0
  133. package/dist/esm/plugins/base-plugin.js +209 -0
  134. package/dist/esm/plugins/base-plugin.js.map +1 -0
  135. package/dist/esm/plugins/events/index.js +2 -0
  136. package/dist/esm/plugins/events/index.js.map +1 -0
  137. package/dist/esm/plugins/events/phoenix-events.plugin.js +378 -0
  138. package/dist/esm/plugins/events/phoenix-events.plugin.js.map +1 -0
  139. package/dist/esm/plugins/fire-emt/index.js +2 -0
  140. package/dist/esm/plugins/fire-emt/index.js.map +1 -0
  141. package/dist/esm/plugins/fire-emt/phoenix-fire.plugin.js +258 -0
  142. package/dist/esm/plugins/fire-emt/phoenix-fire.plugin.js.map +1 -0
  143. package/dist/esm/plugins/index.js +17 -0
  144. package/dist/esm/plugins/index.js.map +1 -0
  145. package/dist/esm/plugins/police-blotter/index.js +2 -0
  146. package/dist/esm/plugins/police-blotter/index.js.map +1 -0
  147. package/dist/esm/plugins/police-blotter/phoenix-police.plugin.js +194 -0
  148. package/dist/esm/plugins/police-blotter/phoenix-police.plugin.js.map +1 -0
  149. package/dist/esm/plugins/pulsepoint/index.js +2 -0
  150. package/dist/esm/plugins/pulsepoint/index.js.map +1 -0
  151. package/dist/esm/plugins/pulsepoint/pulsepoint.plugin.js +271 -0
  152. package/dist/esm/plugins/pulsepoint/pulsepoint.plugin.js.map +1 -0
  153. package/dist/esm/plugins/traffic/arizona-traffic.plugin.js +387 -0
  154. package/dist/esm/plugins/traffic/arizona-traffic.plugin.js.map +1 -0
  155. package/dist/esm/plugins/traffic/index.js +2 -0
  156. package/dist/esm/plugins/traffic/index.js.map +1 -0
  157. package/dist/esm/plugins/weather/index.js +2 -0
  158. package/dist/esm/plugins/weather/index.js.map +1 -0
  159. package/dist/esm/plugins/weather/nws-weather.plugin.js +176 -0
  160. package/dist/esm/plugins/weather/nws-weather.plugin.js.map +1 -0
  161. package/dist/esm/schemas/alert.schema.js +90 -0
  162. package/dist/esm/schemas/alert.schema.js.map +1 -0
  163. package/dist/esm/schemas/index.js +5 -0
  164. package/dist/esm/schemas/index.js.map +1 -0
  165. package/dist/esm/schemas/query.schema.js +72 -0
  166. package/dist/esm/schemas/query.schema.js.map +1 -0
  167. package/dist/esm/types/alert.js +32 -0
  168. package/dist/esm/types/alert.js.map +1 -0
  169. package/dist/esm/types/config.js +10 -0
  170. package/dist/esm/types/config.js.map +1 -0
  171. package/dist/esm/types/geo.js +2 -0
  172. package/dist/esm/types/geo.js.map +1 -0
  173. package/dist/esm/types/index.js +4 -0
  174. package/dist/esm/types/index.js.map +1 -0
  175. package/dist/esm/types/plugin.js +2 -0
  176. package/dist/esm/types/plugin.js.map +1 -0
  177. package/dist/esm/types/query.js +25 -0
  178. package/dist/esm/types/query.js.map +1 -0
  179. package/dist/esm/utils/cache.js +181 -0
  180. package/dist/esm/utils/cache.js.map +1 -0
  181. package/dist/esm/utils/csv.js +185 -0
  182. package/dist/esm/utils/csv.js.map +1 -0
  183. package/dist/esm/utils/date.js +142 -0
  184. package/dist/esm/utils/date.js.map +1 -0
  185. package/dist/esm/utils/index.js +5 -0
  186. package/dist/esm/utils/index.js.map +1 -0
  187. package/dist/esm/utils/retry.js +102 -0
  188. package/dist/esm/utils/retry.js.map +1 -0
  189. package/dist/types/adapters/index.d.ts +5 -0
  190. package/dist/types/adapters/index.d.ts.map +1 -0
  191. package/dist/types/adapters/lambda.d.ts +37 -0
  192. package/dist/types/adapters/lambda.d.ts.map +1 -0
  193. package/dist/types/adapters/vercel.d.ts +54 -0
  194. package/dist/types/adapters/vercel.d.ts.map +1 -0
  195. package/dist/types/core/alert-aggregator.d.ts +81 -0
  196. package/dist/types/core/alert-aggregator.d.ts.map +1 -0
  197. package/dist/types/core/alert-feed.d.ts +80 -0
  198. package/dist/types/core/alert-feed.d.ts.map +1 -0
  199. package/dist/types/core/index.d.ts +8 -0
  200. package/dist/types/core/index.d.ts.map +1 -0
  201. package/dist/types/core/plugin-registry.d.ts +91 -0
  202. package/dist/types/core/plugin-registry.d.ts.map +1 -0
  203. package/dist/types/core/plugin-resolver.d.ts +78 -0
  204. package/dist/types/core/plugin-resolver.d.ts.map +1 -0
  205. package/dist/types/core/time-range.d.ts +40 -0
  206. package/dist/types/core/time-range.d.ts.map +1 -0
  207. package/dist/types/errors/fetch-error.d.ts +46 -0
  208. package/dist/types/errors/fetch-error.d.ts.map +1 -0
  209. package/dist/types/errors/index.d.ts +5 -0
  210. package/dist/types/errors/index.d.ts.map +1 -0
  211. package/dist/types/errors/plugin-error.d.ts +42 -0
  212. package/dist/types/errors/plugin-error.d.ts.map +1 -0
  213. package/dist/types/errors/validation-error.d.ts +34 -0
  214. package/dist/types/errors/validation-error.d.ts.map +1 -0
  215. package/dist/types/geo/distance.d.ts +50 -0
  216. package/dist/types/geo/distance.d.ts.map +1 -0
  217. package/dist/types/geo/index.d.ts +3 -0
  218. package/dist/types/geo/index.d.ts.map +1 -0
  219. package/dist/types/geo/point-in-radius.d.ts +44 -0
  220. package/dist/types/geo/point-in-radius.d.ts.map +1 -0
  221. package/dist/types/index.d.ts +32 -0
  222. package/dist/types/index.d.ts.map +1 -0
  223. package/dist/types/plugins/air-quality/airnow.plugin.d.ts +84 -0
  224. package/dist/types/plugins/air-quality/airnow.plugin.d.ts.map +1 -0
  225. package/dist/types/plugins/air-quality/index.d.ts +3 -0
  226. package/dist/types/plugins/air-quality/index.d.ts.map +1 -0
  227. package/dist/types/plugins/base-plugin.d.ts +99 -0
  228. package/dist/types/plugins/base-plugin.d.ts.map +1 -0
  229. package/dist/types/plugins/events/index.d.ts +3 -0
  230. package/dist/types/plugins/events/index.d.ts.map +1 -0
  231. package/dist/types/plugins/events/phoenix-events.plugin.d.ts +71 -0
  232. package/dist/types/plugins/events/phoenix-events.plugin.d.ts.map +1 -0
  233. package/dist/types/plugins/fire-emt/index.d.ts +3 -0
  234. package/dist/types/plugins/fire-emt/index.d.ts.map +1 -0
  235. package/dist/types/plugins/fire-emt/phoenix-fire.plugin.d.ts +47 -0
  236. package/dist/types/plugins/fire-emt/phoenix-fire.plugin.d.ts.map +1 -0
  237. package/dist/types/plugins/index.d.ts +17 -0
  238. package/dist/types/plugins/index.d.ts.map +1 -0
  239. package/dist/types/plugins/police-blotter/index.d.ts +3 -0
  240. package/dist/types/plugins/police-blotter/index.d.ts.map +1 -0
  241. package/dist/types/plugins/police-blotter/phoenix-police.plugin.d.ts +49 -0
  242. package/dist/types/plugins/police-blotter/phoenix-police.plugin.d.ts.map +1 -0
  243. package/dist/types/plugins/pulsepoint/index.d.ts +3 -0
  244. package/dist/types/plugins/pulsepoint/index.d.ts.map +1 -0
  245. package/dist/types/plugins/pulsepoint/pulsepoint.plugin.d.ts +61 -0
  246. package/dist/types/plugins/pulsepoint/pulsepoint.plugin.d.ts.map +1 -0
  247. package/dist/types/plugins/traffic/arizona-traffic.plugin.d.ts +83 -0
  248. package/dist/types/plugins/traffic/arizona-traffic.plugin.d.ts.map +1 -0
  249. package/dist/types/plugins/traffic/index.d.ts +3 -0
  250. package/dist/types/plugins/traffic/index.d.ts.map +1 -0
  251. package/dist/types/plugins/weather/index.d.ts +3 -0
  252. package/dist/types/plugins/weather/index.d.ts.map +1 -0
  253. package/dist/types/plugins/weather/nws-weather.plugin.d.ts +50 -0
  254. package/dist/types/plugins/weather/nws-weather.plugin.d.ts.map +1 -0
  255. package/dist/types/schemas/alert.schema.d.ts +266 -0
  256. package/dist/types/schemas/alert.schema.d.ts.map +1 -0
  257. package/dist/types/schemas/index.d.ts +5 -0
  258. package/dist/types/schemas/index.d.ts.map +1 -0
  259. package/dist/types/schemas/query.schema.d.ts +150 -0
  260. package/dist/types/schemas/query.schema.d.ts.map +1 -0
  261. package/dist/types/types/alert.d.ts +96 -0
  262. package/dist/types/types/alert.d.ts.map +1 -0
  263. package/dist/types/types/config.d.ts +63 -0
  264. package/dist/types/types/config.d.ts.map +1 -0
  265. package/dist/types/types/geo.d.ts +33 -0
  266. package/dist/types/types/geo.d.ts.map +1 -0
  267. package/dist/types/types/index.d.ts +9 -0
  268. package/dist/types/types/index.d.ts.map +1 -0
  269. package/dist/types/types/plugin.d.ts +125 -0
  270. package/dist/types/types/plugin.d.ts.map +1 -0
  271. package/dist/types/types/query.d.ts +86 -0
  272. package/dist/types/types/query.d.ts.map +1 -0
  273. package/dist/types/utils/cache.d.ts +112 -0
  274. package/dist/types/utils/cache.d.ts.map +1 -0
  275. package/dist/types/utils/csv.d.ts +38 -0
  276. package/dist/types/utils/csv.d.ts.map +1 -0
  277. package/dist/types/utils/date.d.ts +47 -0
  278. package/dist/types/utils/date.d.ts.map +1 -0
  279. package/dist/types/utils/index.d.ts +7 -0
  280. package/dist/types/utils/index.d.ts.map +1 -0
  281. package/dist/types/utils/retry.d.ts +51 -0
  282. package/dist/types/utils/retry.d.ts.map +1 -0
  283. package/package.json +115 -0
@@ -0,0 +1,189 @@
1
+ import { DuplicatePluginError, PluginNotFoundError, PluginInitializationError, } from '../errors';
2
+ /**
3
+ * Registry for managing alert plugins.
4
+ *
5
+ * Handles registration, initialization, and lifecycle of plugins.
6
+ */
7
+ export class PluginRegistry {
8
+ plugins = new Map();
9
+ /**
10
+ * Register a single plugin.
11
+ *
12
+ * @param registration - Plugin registration details
13
+ * @throws DuplicatePluginError if a plugin with the same ID is already registered
14
+ */
15
+ async register(registration) {
16
+ const { plugin, config, enabled = true } = registration;
17
+ const pluginId = plugin.metadata.id;
18
+ if (this.plugins.has(pluginId)) {
19
+ throw new DuplicatePluginError(pluginId);
20
+ }
21
+ const entry = {
22
+ plugin,
23
+ config,
24
+ enabled,
25
+ initialized: false,
26
+ };
27
+ this.plugins.set(pluginId, entry);
28
+ // Initialize if enabled
29
+ if (enabled) {
30
+ await this.initializePlugin(entry);
31
+ }
32
+ }
33
+ /**
34
+ * Register multiple plugins at once.
35
+ *
36
+ * @param registrations - Array of plugin registrations
37
+ */
38
+ async registerAll(registrations) {
39
+ for (const registration of registrations) {
40
+ await this.register(registration);
41
+ }
42
+ }
43
+ /**
44
+ * Unregister a plugin by ID.
45
+ *
46
+ * @param pluginId - The plugin ID to unregister
47
+ * @throws PluginNotFoundError if the plugin is not registered
48
+ */
49
+ async unregister(pluginId) {
50
+ const entry = this.plugins.get(pluginId);
51
+ if (!entry) {
52
+ throw new PluginNotFoundError(pluginId);
53
+ }
54
+ // Dispose if initialized
55
+ if (entry.initialized && entry.plugin.dispose) {
56
+ await entry.plugin.dispose();
57
+ }
58
+ this.plugins.delete(pluginId);
59
+ }
60
+ /**
61
+ * Get a plugin by ID.
62
+ *
63
+ * @param pluginId - The plugin ID to retrieve
64
+ * @returns The plugin instance or undefined if not found
65
+ */
66
+ get(pluginId) {
67
+ return this.plugins.get(pluginId)?.plugin;
68
+ }
69
+ /**
70
+ * Get all registered plugins.
71
+ *
72
+ * @param enabledOnly - If true, only return enabled plugins (default: true)
73
+ * @returns Array of plugin instances
74
+ */
75
+ getAll(enabledOnly = true) {
76
+ const plugins = [];
77
+ for (const entry of this.plugins.values()) {
78
+ if (!enabledOnly || entry.enabled) {
79
+ plugins.push(entry.plugin);
80
+ }
81
+ }
82
+ return plugins;
83
+ }
84
+ /**
85
+ * Get metadata for all registered plugins.
86
+ *
87
+ * @param enabledOnly - If true, only return enabled plugins
88
+ * @returns Array of plugin metadata
89
+ */
90
+ getMetadata(enabledOnly = true) {
91
+ return this.getAll(enabledOnly).map((p) => p.metadata);
92
+ }
93
+ /**
94
+ * Check if a plugin is registered.
95
+ *
96
+ * @param pluginId - The plugin ID to check
97
+ * @returns true if the plugin is registered
98
+ */
99
+ has(pluginId) {
100
+ return this.plugins.has(pluginId);
101
+ }
102
+ /**
103
+ * Enable a registered plugin.
104
+ *
105
+ * @param pluginId - The plugin ID to enable
106
+ */
107
+ async enable(pluginId) {
108
+ const entry = this.plugins.get(pluginId);
109
+ if (!entry) {
110
+ throw new PluginNotFoundError(pluginId);
111
+ }
112
+ entry.enabled = true;
113
+ if (!entry.initialized) {
114
+ await this.initializePlugin(entry);
115
+ }
116
+ }
117
+ /**
118
+ * Disable a registered plugin.
119
+ *
120
+ * @param pluginId - The plugin ID to disable
121
+ */
122
+ disable(pluginId) {
123
+ const entry = this.plugins.get(pluginId);
124
+ if (!entry) {
125
+ throw new PluginNotFoundError(pluginId);
126
+ }
127
+ entry.enabled = false;
128
+ }
129
+ /**
130
+ * Check if a plugin is enabled.
131
+ *
132
+ * @param pluginId - The plugin ID to check
133
+ * @returns true if the plugin is enabled
134
+ */
135
+ isEnabled(pluginId) {
136
+ return this.plugins.get(pluginId)?.enabled ?? false;
137
+ }
138
+ /**
139
+ * Get the number of registered plugins.
140
+ *
141
+ * @param enabledOnly - If true, only count enabled plugins
142
+ */
143
+ size(enabledOnly = false) {
144
+ if (!enabledOnly) {
145
+ return this.plugins.size;
146
+ }
147
+ let count = 0;
148
+ for (const entry of this.plugins.values()) {
149
+ if (entry.enabled)
150
+ count++;
151
+ }
152
+ return count;
153
+ }
154
+ /**
155
+ * Dispose all plugins and clear the registry.
156
+ */
157
+ async dispose() {
158
+ for (const entry of this.plugins.values()) {
159
+ if (entry.initialized && entry.plugin.dispose) {
160
+ try {
161
+ await entry.plugin.dispose();
162
+ }
163
+ catch {
164
+ // Ignore disposal errors
165
+ }
166
+ }
167
+ }
168
+ this.plugins.clear();
169
+ }
170
+ /**
171
+ * Initialize a plugin.
172
+ */
173
+ async initializePlugin(entry) {
174
+ if (entry.initialized)
175
+ return;
176
+ const pluginId = entry.plugin.metadata.id;
177
+ try {
178
+ if (entry.plugin.initialize) {
179
+ await entry.plugin.initialize(entry.config);
180
+ }
181
+ entry.initialized = true;
182
+ }
183
+ catch (error) {
184
+ const message = error instanceof Error ? error.message : String(error);
185
+ throw new PluginInitializationError(pluginId, message, error instanceof Error ? error : undefined);
186
+ }
187
+ }
188
+ }
189
+ //# sourceMappingURL=plugin-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-registry.js","sourceRoot":"","sources":["../../../src/core/plugin-registry.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AAYnB;;;;GAIG;AACH,MAAM,OAAO,cAAc;IACjB,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAEjD;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,YAAgC;QAC7C,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,EAAE,GAAG,YAAY,CAAC;QACxD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE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AC;gBAC5B,MAAM,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC9C,CAAC;YACD,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,MAAM,IAAI,yBAAyB,CACjC,QAAQ,EACR,OAAO,EACP,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,117 @@
1
+ /**
2
+ * Resolves which plugins are applicable for a given query.
3
+ *
4
+ * Determines plugin coverage based on:
5
+ * - Geographic coverage (global or regional with center + radius)
6
+ * - Supported alert categories
7
+ * - Supported temporal types
8
+ */
9
+ export class PluginResolver {
10
+ /**
11
+ * Resolve which plugins cover the given location and match the filters.
12
+ *
13
+ * @param plugins - Available plugins to check
14
+ * @param options - Resolution options including location and filters
15
+ * @returns Array of plugins that match all criteria
16
+ */
17
+ resolve(plugins, options) {
18
+ const { location, categories, temporalTypes } = options;
19
+ return plugins.filter((plugin) => {
20
+ // Check location coverage
21
+ if (!plugin.coversLocation(location)) {
22
+ return false;
23
+ }
24
+ // Check category support
25
+ if (categories && categories.length > 0) {
26
+ const supported = plugin.metadata.supportedCategories;
27
+ const hasCategory = categories.some((c) => supported.includes(c));
28
+ if (!hasCategory) {
29
+ return false;
30
+ }
31
+ }
32
+ // Check temporal type support
33
+ if (temporalTypes && temporalTypes.length > 0) {
34
+ const supported = plugin.metadata.supportedTemporalTypes;
35
+ const hasTemporalType = temporalTypes.some((t) => supported.includes(t));
36
+ if (!hasTemporalType) {
37
+ return false;
38
+ }
39
+ }
40
+ return true;
41
+ });
42
+ }
43
+ /**
44
+ * Resolve plugins with detailed coverage information.
45
+ *
46
+ * @param plugins - Available plugins to check
47
+ * @param options - Resolution options
48
+ * @returns Array of resolved plugins with coverage details
49
+ */
50
+ resolveWithDetails(plugins, options) {
51
+ const { location, categories, temporalTypes } = options;
52
+ return plugins.map((plugin) => {
53
+ const coversLocation = plugin.coversLocation(location);
54
+ let supportsCategories = true;
55
+ if (categories && categories.length > 0) {
56
+ const supported = plugin.metadata.supportedCategories;
57
+ supportsCategories = categories.some((c) => supported.includes(c));
58
+ }
59
+ let supportsTemporalTypes = true;
60
+ if (temporalTypes && temporalTypes.length > 0) {
61
+ const supported = plugin.metadata.supportedTemporalTypes;
62
+ supportsTemporalTypes = temporalTypes.some((t) => supported.includes(t));
63
+ }
64
+ return {
65
+ plugin,
66
+ coversLocation,
67
+ supportsCategories,
68
+ supportsTemporalTypes,
69
+ };
70
+ });
71
+ }
72
+ /**
73
+ * Get plugins that cover a specific location (regardless of category/temporal filters).
74
+ *
75
+ * @param plugins - Available plugins
76
+ * @param location - The location to check
77
+ * @returns Plugins that cover the location
78
+ */
79
+ getPluginsForLocation(plugins, location) {
80
+ return plugins.filter((plugin) => plugin.coversLocation(location));
81
+ }
82
+ /**
83
+ * Get plugins that support specific categories.
84
+ *
85
+ * @param plugins - Available plugins
86
+ * @param categories - Categories to filter by
87
+ * @returns Plugins that support at least one of the specified categories
88
+ */
89
+ getPluginsForCategories(plugins, categories) {
90
+ if (categories.length === 0) {
91
+ return plugins;
92
+ }
93
+ return plugins.filter((plugin) => {
94
+ const supported = plugin.metadata.supportedCategories;
95
+ return categories.some((c) => supported.includes(c));
96
+ });
97
+ }
98
+ /**
99
+ * Get global plugins (plugins that cover all locations).
100
+ *
101
+ * @param plugins - Available plugins
102
+ * @returns Plugins with global coverage
103
+ */
104
+ getGlobalPlugins(plugins) {
105
+ return plugins.filter((plugin) => plugin.metadata.coverage.type === 'global');
106
+ }
107
+ /**
108
+ * Get regional plugins (plugins that cover specific geographic areas).
109
+ *
110
+ * @param plugins - Available plugins
111
+ * @returns Plugins with regional coverage
112
+ */
113
+ getRegionalPlugins(plugins) {
114
+ return plugins.filter((plugin) => plugin.metadata.coverage.type === 'regional');
115
+ }
116
+ }
117
+ //# sourceMappingURL=plugin-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-resolver.js","sourceRoot":"","sources":["../../../src/core/plugin-resolver.ts"],"names":[],"mappings":"AAwBA;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IACzB;;;;;;OAMG;IACH,OAAO,CAAC,OAAsB,EAAE,OAA6B;QAC3D,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;QAExD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/B,0BAA0B;YAC1B,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,yBAAyB;YACzB,IAAI,UAAU,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACxC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;gBACtD,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClE,IAAI,CAAC,WAAW,EAAE,CAAC;oBACjB,OAAO,KAAK,CAAC;gBACf,CAAC;YACH,CAAC;YAED,8BAA8B;YAC9B,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,sBAAsB,CAAC;gBACzD,MAAM,eAAe,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC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AAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;OAMG;IACH,uBAAuB,CAAC,OAAsB,EAAE,UAA2B;QACzE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE;YAC/B,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAC;YACtD,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,gBAAgB,CAAC,OAAsB;QACrC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC;IAChF,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,OAAsB;QACvC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IAClF,CAAC;CACF"}
@@ -0,0 +1,57 @@
1
+ import { resolveTimeRange as resolveTimeRangeUtil, resolveTimeRangePreset } from '../utils';
2
+ /**
3
+ * Re-export time range utilities for use in core module.
4
+ */
5
+ export const resolveTimeRange = resolveTimeRangeUtil;
6
+ export { resolveTimeRangePreset };
7
+ /**
8
+ * Get the default time range preset.
9
+ */
10
+ export function getDefaultTimeRangePreset() {
11
+ return 'next-24h';
12
+ }
13
+ /**
14
+ * Get the default resolved time range.
15
+ */
16
+ export function getDefaultTimeRange() {
17
+ return resolveTimeRangePreset(getDefaultTimeRangePreset(), new Date());
18
+ }
19
+ /**
20
+ * Normalize a time range input to an explicit TimeRange.
21
+ *
22
+ * @param input - Time range input (preset or explicit)
23
+ * @param defaultPreset - Default preset to use if input is undefined
24
+ * @returns Normalized TimeRange
25
+ */
26
+ export function normalizeTimeRange(input, defaultPreset = 'next-24h') {
27
+ if (!input) {
28
+ return resolveTimeRangePreset(defaultPreset, new Date());
29
+ }
30
+ return resolveTimeRangeUtil(input, new Date());
31
+ }
32
+ /**
33
+ * Get the duration of a time range in milliseconds.
34
+ */
35
+ export function getTimeRangeDuration(range) {
36
+ return new Date(range.end).getTime() - new Date(range.start).getTime();
37
+ }
38
+ /**
39
+ * Check if a time range is in the past.
40
+ */
41
+ export function isTimeRangeInPast(range) {
42
+ return new Date(range.end).getTime() < Date.now();
43
+ }
44
+ /**
45
+ * Check if a time range is in the future.
46
+ */
47
+ export function isTimeRangeInFuture(range) {
48
+ return new Date(range.start).getTime() > Date.now();
49
+ }
50
+ /**
51
+ * Check if a time range spans the current time.
52
+ */
53
+ export function isTimeRangeCurrent(range) {
54
+ const now = Date.now();
55
+ return new Date(range.start).getTime() <= now && new Date(range.end).getTime() >= now;
56
+ }
57
+ //# sourceMappingURL=time-range.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-range.js","sourceRoot":"","sources":["../../../src/core/time-range.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAE5F;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,CAAC;AAElC;;GAEG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,sBAAsB,CAAC,yBAAyB,EAAE,EAAE,IAAI,IAAI,EAAE,CAA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ROR';
6
+ url;
7
+ statusCode;
8
+ statusText;
9
+ cause;
10
+ constructor(message, url, options) {
11
+ super(message);
12
+ this.name = 'FetchError';
13
+ this.url = url;
14
+ this.statusCode = options?.statusCode;
15
+ this.statusText = options?.statusText;
16
+ this.cause = options?.cause;
17
+ Object.setPrototypeOf(this, FetchError.prototype);
18
+ }
19
+ /**
20
+ * Create a FetchError from a failed Response object.
21
+ */
22
+ static fromResponse(url, response) {
23
+ return new FetchError(`HTTP ${response.status}: ${response.statusText}`, url, {
24
+ statusCode: response.status,
25
+ statusText: response.statusText,
26
+ });
27
+ }
28
+ /**
29
+ * Create a FetchError from a network error.
30
+ */
31
+ static fromNetworkError(url, error) {
32
+ return new FetchError(`Network error: ${error.message}`, url, {
33
+ cause: error,
34
+ });
35
+ }
36
+ /**
37
+ * Check if this is a client error (4xx status code).
38
+ */
39
+ isClientError() {
40
+ return this.statusCode !== undefined && this.statusCode >= 400 && this.statusCode < 500;
41
+ }
42
+ /**
43
+ * Check if this is a server error (5xx status code).
44
+ */
45
+ isServerError() {
46
+ return this.statusCode !== undefined && this.statusCode >= 500;
47
+ }
48
+ /**
49
+ * Check if this error is retryable (network error or 5xx status).
50
+ */
51
+ isRetryable() {
52
+ return this.statusCode === undefined || this.isServerError() || this.statusCode === 429;
53
+ }
54
+ /**
55
+ * Convert to a plain object for serialization.
56
+ */
57
+ toJSON() {
58
+ return {
59
+ code: this.code,
60
+ message: this.message,
61
+ url: this.url,
62
+ statusCode: this.statusCode,
63
+ statusText: this.statusText,
64
+ };
65
+ }
66
+ }
67
+ //# sourceMappingURL=fetch-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-error.js","sourceRoot":"","sources":["../../../src/errors/fetch-error.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,IAAI,GAAG,aAAa,CAAC;IACrB,GAAG,CAAS;IACZ,UAAU,CAAU;IACpB,UAAU,CAAU;IACpB,KA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AAC,aAAa,EAAE,IAAI,IAAI,CAAC,UAAU,KAAK,GAAG,CAAC;IAC1F,CAAC;IAED;;OAEG;IACH,MAAM;QAOJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;SAC5B,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { PluginError, PluginInitializationError, PluginFetchError, PluginTimeoutError, DuplicatePluginError, PluginNotFoundError, } from './plugin-error';
2
+ export { ValidationError } from './validation-error';
3
+ export { FetchError } from './fetch-error';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Base error class for plugin-related errors.
3
+ */
4
+ export class PluginError extends Error {
5
+ pluginId;
6
+ code;
7
+ constructor(message, pluginId, code = 'PLUGIN_ERROR') {
8
+ super(message);
9
+ this.name = 'PluginError';
10
+ this.pluginId = pluginId;
11
+ this.code = code;
12
+ Object.setPrototypeOf(this, PluginError.prototype);
13
+ }
14
+ }
15
+ /**
16
+ * Error thrown when a plugin fails to initialize.
17
+ */
18
+ export class PluginInitializationError extends PluginError {
19
+ cause;
20
+ constructor(pluginId, message, cause) {
21
+ super(`Plugin "${pluginId}" failed to initialize: ${message}`, pluginId, 'PLUGIN_INIT_ERROR');
22
+ this.name = 'PluginInitializationError';
23
+ this.cause = cause;
24
+ Object.setPrototypeOf(this, PluginInitializationError.prototype);
25
+ }
26
+ }
27
+ /**
28
+ * Error thrown when a plugin fetch operation fails.
29
+ */
30
+ export class PluginFetchError extends PluginError {
31
+ cause;
32
+ constructor(pluginId, message, cause) {
33
+ super(`Plugin "${pluginId}" fetch failed: ${message}`, pluginId, 'PLUGIN_FETCH_ERROR');
34
+ this.name = 'PluginFetchError';
35
+ this.cause = cause;
36
+ Object.setPrototypeOf(this, PluginFetchError.prototype);
37
+ }
38
+ }
39
+ /**
40
+ * Error thrown when a plugin operation times out.
41
+ */
42
+ export class PluginTimeoutError extends PluginError {
43
+ timeoutMs;
44
+ constructor(pluginId, timeoutMs) {
45
+ super(`Plugin "${pluginId}" timed out after ${timeoutMs}ms`, pluginId, 'PLUGIN_TIMEOUT_ERROR');
46
+ this.name = 'PluginTimeoutError';
47
+ this.timeoutMs = timeoutMs;
48
+ Object.setPrototypeOf(this, PluginTimeoutError.prototype);
49
+ }
50
+ }
51
+ /**
52
+ * Error thrown when trying to register a plugin with a duplicate ID.
53
+ */
54
+ export class DuplicatePluginError extends PluginError {
55
+ constructor(pluginId) {
56
+ super(`Plugin with ID "${pluginId}" is already registered`, pluginId, 'DUPLICATE_PLUGIN_ERROR');
57
+ this.name = 'DuplicatePluginError';
58
+ Object.setPrototypeOf(this, DuplicatePluginError.prototype);
59
+ }
60
+ }
61
+ /**
62
+ * Error thrown when a referenced plugin is not found.
63
+ */
64
+ export class PluginNotFoundError extends PluginError {
65
+ constructor(pluginId) {
66
+ super(`Plugin with ID "${pluginId}" not found`, pluginId, 'PLUGIN_NOT_FOUND_ERROR');
67
+ this.name = 'PluginNotFoundError';
68
+ Object.setPrototypeOf(this, PluginNotFoundError.prototype);
69
+ }
70
+ }
71
+ //# sourceMappingURL=plugin-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-error.js","sourceRoot":"","sources":["../../../src/errors/plugin-error.ts"],"names":[],"mappings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AS,CAAS;IAE3B,YAAY,QAAgB,EAAE,SAAiB;QAC7C,KAAK,CACH,WAAW,QAAQ,qBAAqB,SAAS,IAAI,EACrD,QAAQ,EACR,sBAAsB,CACvB,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAC5D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IACnD,YAAY,QAAgB;QAC1B,KAAK,CAAC,mBAAmB,QAAQ,yBAAyB,EAAE,QAAQ,EAAE,wBAAwB,CAAC,CAAC;QAChG,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;QACnC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IAClD,YAAY,QAAgB;QAC1B,KAAK,CAAC,mBAAmB,QAAQ,aAAa,EAAE,QAAQ,EAAE,wBAAwB,CAAC,CAAC;QACpF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;CACF"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Error thrown when input validation fails.
3
+ */
4
+ export class ValidationError extends Error {
5
+ code = 'VALIDATION_ERROR';
6
+ issues;
7
+ constructor(message, issues) {
8
+ super(message);
9
+ this.name = 'ValidationError';
10
+ this.issues = issues;
11
+ Object.setPrototypeOf(this, ValidationError.prototype);
12
+ }
13
+ /**
14
+ * Create a ValidationError from a Zod error.
15
+ */
16
+ static fromZodError(error) {
17
+ const issues = error.issues.map((issue) => ({
18
+ path: issue.path.join('.'),
19
+ message: issue.message,
20
+ code: issue.code,
21
+ }));
22
+ const paths = issues.map((i) => i.path || 'value').join(', ');
23
+ const message = `Validation failed for: ${paths}`;
24
+ return new ValidationError(message, issues);
25
+ }
26
+ /**
27
+ * Get a formatted string representation of all issues.
28
+ */
29
+ getFormattedIssues() {
30
+ return this.issues
31
+ .map((issue) => ` - ${issue.path || 'value'}: ${issue.message}`)
32
+ .join('\n');
33
+ }
34
+ /**
35
+ * Convert to a plain object for serialization.
36
+ */
37
+ toJSON() {
38
+ return {
39
+ code: this.code,
40
+ message: this.message,
41
+ issues: this.issues,
42
+ };
43
+ }
44
+ }
45
+ //# sourceMappingURL=validation-error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation-error.js","sourceRoot":"","sources":["../../../src/errors/validation-error.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,GAAG,kBAAkB,CAAC;IAC1B,MAAM,CAAoB;IAEnC,YAAY,OAAe,EAAE,MAAyB;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,KAAe;QACjC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAe,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;SACjB,CAAC,CAAC,CAAC;QAEJ,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,C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