@buoy-gg/events 2.1.1

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 (84) hide show
  1. package/LICENSE +58 -0
  2. package/README.md +55 -0
  3. package/lib/commonjs/components/EventsCopySettingsView.js +645 -0
  4. package/lib/commonjs/components/EventsModal.js +263 -0
  5. package/lib/commonjs/components/ReactQueryEventDetail.js +428 -0
  6. package/lib/commonjs/components/UnifiedEventDetail.js +370 -0
  7. package/lib/commonjs/components/UnifiedEventFilters.js +113 -0
  8. package/lib/commonjs/components/UnifiedEventItem.js +349 -0
  9. package/lib/commonjs/components/UnifiedEventList.js +154 -0
  10. package/lib/commonjs/components/UnifiedEventViewer.js +126 -0
  11. package/lib/commonjs/hooks/useUnifiedEvents.js +237 -0
  12. package/lib/commonjs/index.js +205 -0
  13. package/lib/commonjs/package.json +1 -0
  14. package/lib/commonjs/preset.js +66 -0
  15. package/lib/commonjs/stores/unifiedEventStore.js +413 -0
  16. package/lib/commonjs/types/copySettings.js +220 -0
  17. package/lib/commonjs/types/index.js +17 -0
  18. package/lib/commonjs/utils/autoDiscoverEventSources.js +640 -0
  19. package/lib/commonjs/utils/badgeSelectionStorage.js +58 -0
  20. package/lib/commonjs/utils/copySettingsStorage.js +66 -0
  21. package/lib/commonjs/utils/correlationUtils.js +130 -0
  22. package/lib/commonjs/utils/eventExportFormatter.js +1095 -0
  23. package/lib/commonjs/utils/eventTransformers.js +496 -0
  24. package/lib/module/components/EventsCopySettingsView.js +641 -0
  25. package/lib/module/components/EventsModal.js +259 -0
  26. package/lib/module/components/ReactQueryEventDetail.js +424 -0
  27. package/lib/module/components/UnifiedEventDetail.js +366 -0
  28. package/lib/module/components/UnifiedEventFilters.js +109 -0
  29. package/lib/module/components/UnifiedEventItem.js +345 -0
  30. package/lib/module/components/UnifiedEventList.js +150 -0
  31. package/lib/module/components/UnifiedEventViewer.js +122 -0
  32. package/lib/module/hooks/useUnifiedEvents.js +234 -0
  33. package/lib/module/index.js +77 -0
  34. package/lib/module/preset.js +62 -0
  35. package/lib/module/stores/unifiedEventStore.js +387 -0
  36. package/lib/module/types/copySettings.js +215 -0
  37. package/lib/module/types/index.js +37 -0
  38. package/lib/module/utils/autoDiscoverEventSources.js +633 -0
  39. package/lib/module/utils/badgeSelectionStorage.js +52 -0
  40. package/lib/module/utils/copySettingsStorage.js +61 -0
  41. package/lib/module/utils/correlationUtils.js +120 -0
  42. package/lib/module/utils/eventExportFormatter.js +1085 -0
  43. package/lib/module/utils/eventTransformers.js +487 -0
  44. package/lib/typescript/components/EventsCopySettingsView.d.ts +16 -0
  45. package/lib/typescript/components/EventsModal.d.ts +16 -0
  46. package/lib/typescript/components/ReactQueryEventDetail.d.ts +15 -0
  47. package/lib/typescript/components/UnifiedEventDetail.d.ts +15 -0
  48. package/lib/typescript/components/UnifiedEventFilters.d.ts +21 -0
  49. package/lib/typescript/components/UnifiedEventItem.d.ts +26 -0
  50. package/lib/typescript/components/UnifiedEventList.d.ts +27 -0
  51. package/lib/typescript/components/UnifiedEventViewer.d.ts +8 -0
  52. package/lib/typescript/hooks/useUnifiedEvents.d.ts +30 -0
  53. package/lib/typescript/index.d.ts +28 -0
  54. package/lib/typescript/preset.d.ts +62 -0
  55. package/lib/typescript/stores/unifiedEventStore.d.ts +146 -0
  56. package/lib/typescript/types/copySettings.d.ts +179 -0
  57. package/lib/typescript/types/index.d.ts +73 -0
  58. package/lib/typescript/utils/autoDiscoverEventSources.d.ts +74 -0
  59. package/lib/typescript/utils/badgeSelectionStorage.d.ts +21 -0
  60. package/lib/typescript/utils/copySettingsStorage.d.ts +21 -0
  61. package/lib/typescript/utils/correlationUtils.d.ts +36 -0
  62. package/lib/typescript/utils/eventExportFormatter.d.ts +49 -0
  63. package/lib/typescript/utils/eventTransformers.d.ts +119 -0
  64. package/package.json +91 -0
  65. package/src/components/EventsCopySettingsView.tsx +742 -0
  66. package/src/components/EventsModal.tsx +328 -0
  67. package/src/components/ReactQueryEventDetail.tsx +413 -0
  68. package/src/components/UnifiedEventDetail.tsx +371 -0
  69. package/src/components/UnifiedEventFilters.tsx +156 -0
  70. package/src/components/UnifiedEventItem.tsx +396 -0
  71. package/src/components/UnifiedEventList.tsx +197 -0
  72. package/src/components/UnifiedEventViewer.tsx +132 -0
  73. package/src/hooks/useUnifiedEvents.ts +288 -0
  74. package/src/index.tsx +112 -0
  75. package/src/preset.tsx +57 -0
  76. package/src/stores/unifiedEventStore.ts +405 -0
  77. package/src/types/copySettings.ts +269 -0
  78. package/src/types/index.ts +96 -0
  79. package/src/utils/autoDiscoverEventSources.ts +690 -0
  80. package/src/utils/badgeSelectionStorage.ts +51 -0
  81. package/src/utils/copySettingsStorage.ts +61 -0
  82. package/src/utils/correlationUtils.ts +146 -0
  83. package/src/utils/eventExportFormatter.ts +1233 -0
  84. package/src/utils/eventTransformers.ts +567 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.clearCopySettings = clearCopySettings;
7
+ exports.loadCopySettings = loadCopySettings;
8
+ exports.saveCopySettings = saveCopySettings;
9
+ var _sharedUi = require("@buoy-gg/shared-ui");
10
+ var _copySettings = require("../types/copySettings");
11
+ /**
12
+ * Copy Settings Storage
13
+ *
14
+ * Utilities for persisting and restoring the events copy/export settings.
15
+ * Uses the same storage patterns as other packages (React Query, Network, etc.)
16
+ */
17
+
18
+ /**
19
+ * Save the copy settings to persistent storage
20
+ */
21
+ async function saveCopySettings(settings) {
22
+ try {
23
+ const key = _sharedUi.devToolsStorageKeys.events.copySettings();
24
+ await _sharedUi.persistentStorage.setItem(key, JSON.stringify(settings));
25
+ } catch {
26
+ // Silently fail - persistence is optional
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Load the copy settings from persistent storage
32
+ * Returns null if no saved state exists
33
+ */
34
+ async function loadCopySettings() {
35
+ try {
36
+ const key = _sharedUi.devToolsStorageKeys.events.copySettings();
37
+ const value = await _sharedUi.persistentStorage.getItem(key);
38
+ if (value && value !== "") {
39
+ const parsed = JSON.parse(value);
40
+ // Merge with defaults to handle new fields added in updates
41
+ return {
42
+ ..._copySettings.DEFAULT_COPY_SETTINGS,
43
+ ...parsed,
44
+ // Ensure filterSources is always an array
45
+ filterSources: parsed.filterSources ?? _copySettings.DEFAULT_COPY_SETTINGS.filterSources
46
+ };
47
+ }
48
+ return null;
49
+ } catch {
50
+ // Silently fail - return null to use defaults
51
+ return null;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Clear the saved copy settings
57
+ */
58
+ async function clearCopySettings() {
59
+ try {
60
+ const key = _sharedUi.devToolsStorageKeys.events.copySettings();
61
+ await _sharedUi.persistentStorage.removeItem(key);
62
+ } catch {
63
+ // Silently fail
64
+ }
65
+ }
66
+ //# sourceMappingURL=copySettingsStorage.js.map
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.buildCorrelationCountMap = buildCorrelationCountMap;
7
+ exports.findRelatedEvents = findRelatedEvents;
8
+ exports.getCorrelationColor = getCorrelationColor;
9
+ exports.getCorrelationGroup = getCorrelationGroup;
10
+ exports.getCorrelationLabel = getCorrelationLabel;
11
+ exports.getRelatedEventsCount = getRelatedEventsCount;
12
+ exports.hasRelatedEvents = hasRelatedEvents;
13
+ /**
14
+ * Correlation Utilities
15
+ *
16
+ * Functions for finding and grouping related events based on correlation IDs.
17
+ * Similar to Redux DevTools' async thunk linking feature.
18
+ */
19
+
20
+ /**
21
+ * Find all events related to the given event by correlation ID
22
+ */
23
+ function findRelatedEvents(event, allEvents) {
24
+ if (!event.correlationId) {
25
+ return [];
26
+ }
27
+ return allEvents.filter(e => e.correlationId === event.correlationId && e.id !== event.id).sort((a, b) => a.timestamp - b.timestamp);
28
+ }
29
+
30
+ /**
31
+ * Check if an event has related events
32
+ */
33
+ function hasRelatedEvents(event, allEvents) {
34
+ if (!event.correlationId) {
35
+ return false;
36
+ }
37
+ return allEvents.some(e => e.correlationId === event.correlationId && e.id !== event.id);
38
+ }
39
+
40
+ /**
41
+ * Get count of related events (including the current one)
42
+ */
43
+ function getRelatedEventsCount(event, allEvents) {
44
+ if (!event.correlationId) {
45
+ return 1;
46
+ }
47
+ return allEvents.filter(e => e.correlationId === event.correlationId).length;
48
+ }
49
+
50
+ /**
51
+ * Build a map of correlation ID -> count for efficient lookup
52
+ */
53
+ function buildCorrelationCountMap(events) {
54
+ const countMap = new Map();
55
+ for (const event of events) {
56
+ if (event.correlationId) {
57
+ const current = countMap.get(event.correlationId) || 0;
58
+ countMap.set(event.correlationId, current + 1);
59
+ }
60
+ }
61
+ return countMap;
62
+ }
63
+
64
+ /**
65
+ * Get all events in a correlation group, sorted by sequence
66
+ */
67
+ function getCorrelationGroup(correlationId, allEvents) {
68
+ return allEvents.filter(e => e.correlationId === correlationId).sort((a, b) => {
69
+ // Sort by sequence first, then by timestamp
70
+ const seqA = a.sequenceInGroup ?? 0;
71
+ const seqB = b.sequenceInGroup ?? 0;
72
+ if (seqA !== seqB) {
73
+ return seqA - seqB;
74
+ }
75
+ return a.timestamp - b.timestamp;
76
+ });
77
+ }
78
+
79
+ /**
80
+ * Generate a display label for correlated events (e.g., "1/2" for first of two)
81
+ */
82
+ function getCorrelationLabel(event, allEvents) {
83
+ if (!event.correlationId) {
84
+ return null;
85
+ }
86
+ const group = getCorrelationGroup(event.correlationId, allEvents);
87
+ if (group.length <= 1) {
88
+ return null;
89
+ }
90
+ const index = group.findIndex(e => e.id === event.id);
91
+ if (index === -1) {
92
+ return null;
93
+ }
94
+ return `${index + 1}/${group.length}`;
95
+ }
96
+
97
+ /**
98
+ * Color palette for correlation groups (cycles through for different groups)
99
+ */
100
+ const CORRELATION_COLORS = ["#EC4899",
101
+ // Pink (React Query default)
102
+ "#8B5CF6",
103
+ // Purple
104
+ "#3B82F6",
105
+ // Blue
106
+ "#10B981",
107
+ // Green
108
+ "#F59E0B",
109
+ // Orange
110
+ "#EF4444",
111
+ // Red
112
+ "#06B6D4",
113
+ // Cyan
114
+ "#84CC16" // Lime
115
+ ];
116
+
117
+ /**
118
+ * Get a consistent color for a correlation group
119
+ */
120
+ function getCorrelationColor(correlationId) {
121
+ // Use a simple hash to get a consistent color for each correlation ID
122
+ let hash = 0;
123
+ for (let i = 0; i < correlationId.length; i++) {
124
+ hash = (hash << 5) - hash + correlationId.charCodeAt(i);
125
+ hash |= 0; // Convert to 32bit integer
126
+ }
127
+ const index = Math.abs(hash) % CORRELATION_COLORS.length;
128
+ return CORRELATION_COLORS[index];
129
+ }
130
+ //# sourceMappingURL=correlationUtils.js.map