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