@autobe/ui 0.29.2 → 0.30.0-dev.20260315

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 (151) hide show
  1. package/LICENSE +661 -661
  2. package/README.md +261 -0
  3. package/lib/components/AutoBeChatMain.js +5 -5
  4. package/lib/components/AutoBeChatMain.js.map +1 -1
  5. package/lib/components/AutoBeConfigModal.js +9 -9
  6. package/lib/components/AutoBeStatusModal.js +4 -4
  7. package/lib/components/AutoBeStatusModal.js.map +1 -1
  8. package/lib/components/AutoBeUserMessageMovie.d.ts +2 -2
  9. package/lib/components/common/ChatBubble.d.ts +2 -2
  10. package/lib/components/common/openai/OpenAIContent.d.ts +2 -2
  11. package/lib/components/common/openai/OpenAIContent.js.map +1 -1
  12. package/lib/components/common/openai/OpenAIUserAudioContent.js +1 -1
  13. package/lib/components/common/openai/OpenAIUserAudioContent.js.map +1 -1
  14. package/lib/components/common/openai/OpenAIUserFileContent.js +1 -1
  15. package/lib/components/common/openai/OpenAIUserFileContent.js.map +1 -1
  16. package/lib/components/common/openai/OpenAIUserImageContent.d.ts +2 -2
  17. package/lib/components/events/AutoBeCompleteEventMovie.d.ts +2 -2
  18. package/lib/components/events/AutoBeCompleteEventMovie.js +5 -5
  19. package/lib/components/events/AutoBeCompleteEventMovie.js.map +1 -1
  20. package/lib/components/events/AutoBeCorrectEventMovie.d.ts +2 -2
  21. package/lib/components/events/AutoBeCorrectEventMovie.js +4 -4
  22. package/lib/components/events/AutoBeCorrectEventMovie.js.map +1 -1
  23. package/lib/components/events/AutoBeEventMovie.js +38 -17
  24. package/lib/components/events/AutoBeEventMovie.js.map +1 -1
  25. package/lib/components/events/AutoBeProgressEventMovie.js +73 -13
  26. package/lib/components/events/AutoBeProgressEventMovie.js.map +1 -1
  27. package/lib/components/events/AutoBeScenarioEventMovie.d.ts +2 -2
  28. package/lib/components/events/AutoBeScenarioEventMovie.js +18 -5
  29. package/lib/components/events/AutoBeScenarioEventMovie.js.map +1 -1
  30. package/lib/components/events/AutoBeStartEventMovie.d.ts +2 -2
  31. package/lib/components/events/AutoBeStartEventMovie.js +2 -2
  32. package/lib/components/events/AutoBeStartEventMovie.js.map +1 -1
  33. package/lib/components/events/AutoBeValidateEventMovie.d.ts +2 -2
  34. package/lib/components/events/AutoBeValidateEventMovie.js +3 -11
  35. package/lib/components/events/AutoBeValidateEventMovie.js.map +1 -1
  36. package/lib/components/events/groups/CorrectEventGroup.d.ts +2 -2
  37. package/lib/components/events/groups/CorrectEventGroup.js +1 -1
  38. package/lib/components/events/groups/CorrectEventGroup.js.map +1 -1
  39. package/lib/components/events/groups/ValidateEventGroup.d.ts +2 -2
  40. package/lib/components/events/groups/ValidateEventGroup.js +1 -2
  41. package/lib/components/events/groups/ValidateEventGroup.js.map +1 -1
  42. package/lib/components/events/utils/eventGrouper.js +1 -2
  43. package/lib/components/events/utils/eventGrouper.js.map +1 -1
  44. package/lib/components/upload/AutoBeChatUploadBox.d.ts +3 -4
  45. package/lib/components/upload/AutoBeChatUploadBox.js +2 -1
  46. package/lib/components/upload/AutoBeChatUploadBox.js.map +1 -1
  47. package/lib/components/upload/AutoBeChatUploadSendButton.js +1 -1
  48. package/lib/components/upload/AutoBeChatUploadSendButton.js.map +1 -1
  49. package/lib/context/AutoBeAgentContext.d.ts +1 -3
  50. package/lib/context/AutoBeAgentContext.js +0 -4
  51. package/lib/context/AutoBeAgentContext.js.map +1 -1
  52. package/lib/hooks/useSessionStorage.d.ts +4 -0
  53. package/lib/hooks/useSessionStorage.js +16 -0
  54. package/lib/hooks/useSessionStorage.js.map +1 -0
  55. package/lib/index.d.ts +1 -0
  56. package/lib/index.js +1 -0
  57. package/lib/index.js.map +1 -1
  58. package/lib/strategy/AutoBeAgentSessionStorageStrategy.d.ts +10 -0
  59. package/lib/strategy/AutoBeAgentSessionStorageStrategy.js +117 -0
  60. package/lib/strategy/AutoBeAgentSessionStorageStrategy.js.map +1 -0
  61. package/lib/structure/AutoBeListener.js +91 -23
  62. package/lib/structure/AutoBeListener.js.map +1 -1
  63. package/lib/structure/AutoBeListenerState.d.ts +3 -3
  64. package/lib/structure/AutoBeListenerState.js +4 -4
  65. package/lib/structure/AutoBeListenerState.js.map +1 -1
  66. package/lib/structure/IAutoBeAgentSessionStorageStrategy.js +1 -1
  67. package/lib/structure/IAutoBeAgentSessionStorageStrategy.js.map +1 -1
  68. package/lib/utils/AutoBeFileUploader.d.ts +2 -2
  69. package/lib/utils/AutoBeFileUploader.js.map +1 -1
  70. package/package.json +3 -4
  71. package/src/components/AutoBeAssistantMessageMovie.tsx +22 -22
  72. package/src/components/AutoBeChatMain.tsx +376 -376
  73. package/src/components/AutoBeChatSidebar.tsx +414 -414
  74. package/src/components/AutoBeConfigButton.tsx +83 -83
  75. package/src/components/AutoBeConfigModal.tsx +443 -443
  76. package/src/components/AutoBeStatusButton.tsx +75 -75
  77. package/src/components/AutoBeStatusModal.tsx +486 -484
  78. package/src/components/AutoBeUserMessageMovie.tsx +27 -27
  79. package/src/components/common/ActionButton.tsx +205 -205
  80. package/src/components/common/ActionButtonGroup.tsx +80 -80
  81. package/src/components/common/AutoBeConfigInput.tsx +185 -185
  82. package/src/components/common/ChatBubble.tsx +119 -119
  83. package/src/components/common/Collapsible.tsx +95 -95
  84. package/src/components/common/CompactSessionIndicator.tsx +73 -73
  85. package/src/components/common/CompactSessionList.tsx +82 -82
  86. package/src/components/common/index.ts +8 -8
  87. package/src/components/common/openai/OpenAIContent.tsx +53 -53
  88. package/src/components/common/openai/OpenAIUserAudioContent.tsx +70 -70
  89. package/src/components/common/openai/OpenAIUserFileContent.tsx +76 -76
  90. package/src/components/common/openai/OpenAIUserImageContent.tsx +34 -34
  91. package/src/components/common/openai/OpenAIUserTextContent.tsx +15 -15
  92. package/src/components/common/openai/index.ts +5 -5
  93. package/src/components/events/AutoBeCompleteEventMovie.tsx +402 -402
  94. package/src/components/events/AutoBeCorrectEventMovie.tsx +354 -368
  95. package/src/components/events/AutoBeEventGroupMovie.tsx +18 -18
  96. package/src/components/events/AutoBeEventMovie.tsx +158 -139
  97. package/src/components/events/AutoBeProgressEventMovie.tsx +217 -157
  98. package/src/components/events/AutoBeScenarioEventMovie.tsx +135 -95
  99. package/src/components/events/AutoBeStartEventMovie.tsx +82 -82
  100. package/src/components/events/AutoBeValidateEventMovie.tsx +249 -286
  101. package/src/components/events/README.md +300 -300
  102. package/src/components/events/common/CollapsibleEventGroup.tsx +211 -211
  103. package/src/components/events/common/EventCard.tsx +61 -61
  104. package/src/components/events/common/EventContent.tsx +31 -31
  105. package/src/components/events/common/EventHeader.tsx +85 -85
  106. package/src/components/events/common/EventIcon.tsx +82 -82
  107. package/src/components/events/common/ProgressBar.tsx +64 -64
  108. package/src/components/events/common/index.ts +13 -13
  109. package/src/components/events/groups/CorrectEventGroup.tsx +183 -183
  110. package/src/components/events/groups/ValidateEventGroup.tsx +143 -146
  111. package/src/components/events/groups/index.ts +8 -8
  112. package/src/components/events/index.ts +16 -16
  113. package/src/components/events/utils/eventGrouper.tsx +116 -117
  114. package/src/components/events/utils/index.ts +1 -1
  115. package/src/components/index.ts +13 -13
  116. package/src/components/upload/AutoBeChatUploadBox.tsx +425 -424
  117. package/src/components/upload/AutoBeChatUploadSendButton.tsx +66 -66
  118. package/src/components/upload/AutoBeFileUploadBox.tsx +123 -123
  119. package/src/components/upload/AutoBeUploadConfig.ts +5 -5
  120. package/src/components/upload/AutoBeVoiceRecoderButton.tsx +100 -100
  121. package/src/components/upload/index.ts +5 -5
  122. package/src/constant/color.ts +28 -28
  123. package/src/context/AutoBeAgentContext.tsx +245 -258
  124. package/src/context/AutoBeAgentSessionList.tsx +58 -58
  125. package/src/context/SearchParamsContext.tsx +49 -49
  126. package/src/hooks/index.ts +3 -3
  127. package/src/hooks/useEscapeKey.ts +24 -24
  128. package/src/hooks/useIsomorphicLayoutEffect.ts +8 -8
  129. package/src/hooks/useMediaQuery.ts +73 -73
  130. package/src/hooks/useSessionStorage.ts +10 -0
  131. package/src/icons/Receipt.tsx +74 -74
  132. package/src/index.ts +9 -8
  133. package/src/strategy/AutoBeAgentSessionStorageStrategy.ts +127 -0
  134. package/src/structure/AutoBeListener.ts +373 -304
  135. package/src/structure/AutoBeListenerState.ts +53 -53
  136. package/src/structure/IAutoBeAgentSessionStorageStrategy.ts +87 -87
  137. package/src/structure/IAutoBeEventGroup.ts +6 -6
  138. package/src/structure/index.ts +4 -4
  139. package/src/types/config.ts +44 -44
  140. package/src/types/index.ts +1 -1
  141. package/src/utils/AutoBeFileUploader.ts +279 -279
  142. package/src/utils/AutoBeVoiceRecorder.ts +95 -95
  143. package/src/utils/__tests__/crypto.test.ts +286 -286
  144. package/src/utils/__tests__/storage.test.ts +229 -229
  145. package/src/utils/crypto.ts +95 -95
  146. package/src/utils/index.ts +6 -6
  147. package/src/utils/number.ts +17 -17
  148. package/src/utils/storage.ts +96 -96
  149. package/src/utils/time.ts +14 -14
  150. package/tsconfig.json +9 -9
  151. package/vitest.config.ts +15 -15
@@ -1,183 +1,183 @@
1
- import {
2
- AutoBePrismaCorrectEvent,
3
- AutoBeRealizeAuthorizationCorrectEvent,
4
- AutoBeRealizeCorrectEvent,
5
- AutoBeTestCorrectEvent,
6
- } from "@autobe/interface";
7
-
8
- import { AutoBeCorrectEventMovie } from "../AutoBeCorrectEventMovie";
9
- import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
10
-
11
- type CorrectEvent =
12
- | AutoBePrismaCorrectEvent
13
- | AutoBeTestCorrectEvent
14
- | AutoBeRealizeCorrectEvent
15
- | AutoBeRealizeAuthorizationCorrectEvent;
16
-
17
- export interface ICorrectEventGroupProps {
18
- events: CorrectEvent[];
19
- defaultCollapsed?: boolean;
20
- }
21
-
22
- /**
23
- * Specialized group component for correction events Shows correction summary
24
- * and statistics
25
- */
26
- export const CorrectEventGroup = (props: ICorrectEventGroupProps) => {
27
- const { events, defaultCollapsed = true } = props;
28
-
29
- if (events.length === 0) {
30
- return null;
31
- }
32
-
33
- // Calculate correction statistics
34
- const eventTypes = Array.from(new Set(events.map((e) => e.type)));
35
- const eventTypeCounts = eventTypes.reduce(
36
- (acc, type) => {
37
- acc[type] = events.filter((e) => e.type === type).length;
38
- return acc;
39
- },
40
- {} as Record<string, number>,
41
- );
42
-
43
- // Get latest step numbers for each event type
44
- const latestSteps = eventTypes.reduce(
45
- (acc, type) => {
46
- const eventsOfType = events.filter((e) => e.type === type);
47
- acc[type] = Math.max(...eventsOfType.map((e) => e.step));
48
- return acc;
49
- },
50
- {} as Record<string, number>,
51
- );
52
-
53
- const renderSummary = (events: CorrectEvent[]) => (
54
- <>
55
- Correction events showing AI self-improvement feedback loop
56
- <br />
57
- <br />
58
- <strong>Success Rate:</strong> 100% (All corrections applied successfully)
59
- <br />
60
- <strong>Total Corrections:</strong> {events.length} events
61
- <br />
62
- <strong>Event Types:</strong> {eventTypes.join(", ")}
63
- <br />
64
- <br />
65
- <div
66
- style={{
67
- display: "flex",
68
- flexDirection: "column",
69
- gap: "0.5rem",
70
- }}
71
- >
72
- {eventTypes.map((type) => {
73
- const typeDisplayNames = {
74
- prismaCorrect: "🗄️ Database Schema",
75
- testCorrect: "🧪 Test Suite",
76
- realizeCorrect: "⚙️ Implementation",
77
- realizeAuthorizationCorrect: "🔐 Authorization",
78
- };
79
-
80
- return (
81
- <div
82
- key={type}
83
- style={{
84
- display: "flex",
85
- justifyContent: "space-between",
86
- alignItems: "center",
87
- padding: "0.5rem",
88
- backgroundColor: "#f0fdf4",
89
- borderRadius: "0.25rem",
90
- border: "1px solid #bbf7d0",
91
- }}
92
- >
93
- <span style={{ fontSize: "0.75rem", fontWeight: "500" }}>
94
- {typeDisplayNames[type as keyof typeof typeDisplayNames] ||
95
- type}
96
- </span>
97
- <div
98
- style={{ display: "flex", gap: "1rem", alignItems: "center" }}
99
- >
100
- <span style={{ fontSize: "0.75rem", color: "#16a34a" }}>
101
- {eventTypeCounts[type]} corrections
102
- </span>
103
- <span
104
- style={{
105
- fontSize: "0.625rem",
106
- color: "#64748b",
107
- fontFamily: "monospace",
108
- backgroundColor: "#e2e8f0",
109
- padding: "0.125rem 0.375rem",
110
- borderRadius: "0.25rem",
111
- }}
112
- >
113
- Step {latestSteps[type]}
114
- </span>
115
- </div>
116
- </div>
117
- );
118
- })}
119
- </div>
120
- <br />
121
- <div
122
- style={{
123
- display: "flex",
124
- gap: "0.5rem",
125
- alignItems: "center",
126
- }}
127
- >
128
- <div
129
- style={{
130
- display: "flex",
131
- alignItems: "center",
132
- gap: "0.25rem",
133
- }}
134
- >
135
- <div
136
- style={{
137
- width: "12px",
138
- height: "12px",
139
- backgroundColor: "#16a34a",
140
- borderRadius: "2px",
141
- }}
142
- />
143
- <span style={{ fontSize: "0.75rem" }}>
144
- Corrected: {events.length}
145
- </span>
146
- </div>
147
- <div
148
- style={{
149
- display: "flex",
150
- alignItems: "center",
151
- gap: "0.25rem",
152
- }}
153
- >
154
- <div
155
- style={{
156
- width: "12px",
157
- height: "12px",
158
- backgroundColor: "#10b981",
159
- borderRadius: "2px",
160
- }}
161
- />
162
- <span style={{ fontSize: "0.75rem" }}>Self-Improvement Active</span>
163
- </div>
164
- </div>
165
- </>
166
- );
167
-
168
- return (
169
- <CollapsibleEventGroup
170
- events={events}
171
- title="Correction Events"
172
- iconType="success"
173
- variant="success"
174
- getTimestamp={(event) => event.created_at}
175
- renderEvent={(event) => <AutoBeCorrectEventMovie event={event} />}
176
- renderSummary={renderSummary}
177
- defaultCollapsed={defaultCollapsed}
178
- description="AI self-correction and improvement events"
179
- />
180
- );
181
- };
182
-
183
- export default CorrectEventGroup;
1
+ import {
2
+ AutoBeDatabaseCorrectEvent,
3
+ AutoBeRealizeAuthorizationCorrectEvent,
4
+ AutoBeRealizeCorrectEvent,
5
+ AutoBeTestCorrectEvent,
6
+ } from "@autobe/interface";
7
+
8
+ import { AutoBeCorrectEventMovie } from "../AutoBeCorrectEventMovie";
9
+ import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
10
+
11
+ type CorrectEvent =
12
+ | AutoBeDatabaseCorrectEvent
13
+ | AutoBeTestCorrectEvent
14
+ | AutoBeRealizeCorrectEvent
15
+ | AutoBeRealizeAuthorizationCorrectEvent;
16
+
17
+ export interface ICorrectEventGroupProps {
18
+ events: CorrectEvent[];
19
+ defaultCollapsed?: boolean;
20
+ }
21
+
22
+ /**
23
+ * Specialized group component for correction events Shows correction summary
24
+ * and statistics
25
+ */
26
+ export const CorrectEventGroup = (props: ICorrectEventGroupProps) => {
27
+ const { events, defaultCollapsed = true } = props;
28
+
29
+ if (events.length === 0) {
30
+ return null;
31
+ }
32
+
33
+ // Calculate correction statistics
34
+ const eventTypes = Array.from(new Set(events.map((e) => e.type)));
35
+ const eventTypeCounts = eventTypes.reduce(
36
+ (acc, type) => {
37
+ acc[type] = events.filter((e) => e.type === type).length;
38
+ return acc;
39
+ },
40
+ {} as Record<string, number>,
41
+ );
42
+
43
+ // Get latest step numbers for each event type
44
+ const latestSteps = eventTypes.reduce(
45
+ (acc, type) => {
46
+ const eventsOfType = events.filter((e) => e.type === type);
47
+ acc[type] = Math.max(...eventsOfType.map((e) => e.step));
48
+ return acc;
49
+ },
50
+ {} as Record<string, number>,
51
+ );
52
+
53
+ const renderSummary = (events: CorrectEvent[]) => (
54
+ <>
55
+ Correction events showing AI self-improvement feedback loop
56
+ <br />
57
+ <br />
58
+ <strong>Success Rate:</strong> 100% (All corrections applied successfully)
59
+ <br />
60
+ <strong>Total Corrections:</strong> {events.length} events
61
+ <br />
62
+ <strong>Event Types:</strong> {eventTypes.join(", ")}
63
+ <br />
64
+ <br />
65
+ <div
66
+ style={{
67
+ display: "flex",
68
+ flexDirection: "column",
69
+ gap: "0.5rem",
70
+ }}
71
+ >
72
+ {eventTypes.map((type) => {
73
+ const typeDisplayNames = {
74
+ databaseCorrect: "🗄️ Database Schema",
75
+ testCorrect: "🧪 Test Suite",
76
+ realizeCorrect: "⚙️ Implementation",
77
+ realizeAuthorizationCorrect: "🔐 Authorization",
78
+ };
79
+
80
+ return (
81
+ <div
82
+ key={type}
83
+ style={{
84
+ display: "flex",
85
+ justifyContent: "space-between",
86
+ alignItems: "center",
87
+ padding: "0.5rem",
88
+ backgroundColor: "#f0fdf4",
89
+ borderRadius: "0.25rem",
90
+ border: "1px solid #bbf7d0",
91
+ }}
92
+ >
93
+ <span style={{ fontSize: "0.75rem", fontWeight: "500" }}>
94
+ {typeDisplayNames[type as keyof typeof typeDisplayNames] ||
95
+ type}
96
+ </span>
97
+ <div
98
+ style={{ display: "flex", gap: "1rem", alignItems: "center" }}
99
+ >
100
+ <span style={{ fontSize: "0.75rem", color: "#16a34a" }}>
101
+ {eventTypeCounts[type]} corrections
102
+ </span>
103
+ <span
104
+ style={{
105
+ fontSize: "0.625rem",
106
+ color: "#64748b",
107
+ fontFamily: "monospace",
108
+ backgroundColor: "#e2e8f0",
109
+ padding: "0.125rem 0.375rem",
110
+ borderRadius: "0.25rem",
111
+ }}
112
+ >
113
+ Step {latestSteps[type]}
114
+ </span>
115
+ </div>
116
+ </div>
117
+ );
118
+ })}
119
+ </div>
120
+ <br />
121
+ <div
122
+ style={{
123
+ display: "flex",
124
+ gap: "0.5rem",
125
+ alignItems: "center",
126
+ }}
127
+ >
128
+ <div
129
+ style={{
130
+ display: "flex",
131
+ alignItems: "center",
132
+ gap: "0.25rem",
133
+ }}
134
+ >
135
+ <div
136
+ style={{
137
+ width: "12px",
138
+ height: "12px",
139
+ backgroundColor: "#16a34a",
140
+ borderRadius: "2px",
141
+ }}
142
+ />
143
+ <span style={{ fontSize: "0.75rem" }}>
144
+ Corrected: {events.length}
145
+ </span>
146
+ </div>
147
+ <div
148
+ style={{
149
+ display: "flex",
150
+ alignItems: "center",
151
+ gap: "0.25rem",
152
+ }}
153
+ >
154
+ <div
155
+ style={{
156
+ width: "12px",
157
+ height: "12px",
158
+ backgroundColor: "#10b981",
159
+ borderRadius: "2px",
160
+ }}
161
+ />
162
+ <span style={{ fontSize: "0.75rem" }}>Self-Improvement Active</span>
163
+ </div>
164
+ </div>
165
+ </>
166
+ );
167
+
168
+ return (
169
+ <CollapsibleEventGroup
170
+ events={events}
171
+ title="Correction Events"
172
+ iconType="success"
173
+ variant="success"
174
+ getTimestamp={(event) => event.created_at}
175
+ renderEvent={(event) => <AutoBeCorrectEventMovie event={event} />}
176
+ renderSummary={renderSummary}
177
+ defaultCollapsed={defaultCollapsed}
178
+ description="AI self-correction and improvement events"
179
+ />
180
+ );
181
+ };
182
+
183
+ export default CorrectEventGroup;
@@ -1,146 +1,143 @@
1
- import {
2
- AutoBeInterfaceOperationReviewEvent,
3
- AutoBePrismaInsufficientEvent,
4
- AutoBePrismaValidateEvent,
5
- AutoBeRealizeAuthorizationValidateEvent,
6
- AutoBeRealizeValidateEvent,
7
- AutoBeTestValidateEvent,
8
- } from "@autobe/interface";
9
-
10
- import { AutoBeValidateEventMovie } from "../AutoBeValidateEventMovie";
11
- import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
12
-
13
- export type ValidateEvent =
14
- | AutoBePrismaInsufficientEvent
15
- | AutoBePrismaValidateEvent
16
- | AutoBeInterfaceOperationReviewEvent
17
- | AutoBeTestValidateEvent
18
- | AutoBeRealizeValidateEvent
19
- | AutoBeRealizeAuthorizationValidateEvent;
20
-
21
- export interface IValidateEventGroupProps {
22
- events: ValidateEvent[];
23
- defaultCollapsed?: boolean;
24
- }
25
-
26
- /**
27
- * Specialized group component for validation events Shows validation summary
28
- * and error statistics
29
- */
30
- export const ValidateEventGroup = (props: IValidateEventGroupProps) => {
31
- const { events, defaultCollapsed = true } = props;
32
-
33
- if (events.length === 0) {
34
- return null;
35
- }
36
-
37
- // Calculate validation statistics
38
- const errorEvents = events.filter((event) => {
39
- switch (event.type) {
40
- case "prismaValidate":
41
- case "realizeValidate":
42
- case "prismaInsufficient":
43
- return true;
44
- case "testValidate":
45
- case "realizeAuthorizationValidate":
46
- return event.result.type !== "success";
47
- case "interfaceOperationReview":
48
- default:
49
- return false;
50
- }
51
- }).length;
52
-
53
- const successEvents = events.length - errorEvents;
54
- const eventTypes = Array.from(new Set(events.map((e) => e.type)));
55
-
56
- const renderSummary = (events: ValidateEvent[]) => (
57
- <>
58
- Validation and review events from various components
59
- <br />
60
- <br />
61
- <strong>Success Rate:</strong>{" "}
62
- {events.length > 0
63
- ? Math.round((successEvents / events.length) * 100)
64
- : 0}
65
- %
66
- <br />
67
- <strong>Successful:</strong> {successEvents} events
68
- <br />
69
- <strong>Failed/Issues:</strong> {errorEvents} events
70
- <br />
71
- <strong>Event Types:</strong> {eventTypes.join(", ")}
72
- <br />
73
- <br />
74
- <div
75
- style={{
76
- display: "flex",
77
- gap: "0.5rem",
78
- alignItems: "center",
79
- }}
80
- >
81
- <div
82
- style={{
83
- display: "flex",
84
- alignItems: "center",
85
- gap: "0.25rem",
86
- }}
87
- >
88
- <div
89
- style={{
90
- width: "12px",
91
- height: "12px",
92
- backgroundColor: "#4caf50",
93
- borderRadius: "2px",
94
- }}
95
- />
96
- <span style={{ fontSize: "0.75rem" }}>Success: {successEvents}</span>
97
- </div>
98
- <div
99
- style={{
100
- display: "flex",
101
- alignItems: "center",
102
- gap: "0.25rem",
103
- }}
104
- >
105
- <div
106
- style={{
107
- width: "12px",
108
- height: "12px",
109
- backgroundColor: "#f59e0b",
110
- borderRadius: "2px",
111
- }}
112
- />
113
- <span style={{ fontSize: "0.75rem" }}>Issues: {errorEvents}</span>
114
- </div>
115
- </div>
116
- </>
117
- );
118
-
119
- const getGroupIconType = () => {
120
- if (errorEvents === 0) return "success"; // All successful
121
- if (successEvents === 0) return "warning"; // All failed
122
- return "warning"; // Mixed results
123
- };
124
-
125
- const getGroupVariant = () => {
126
- if (errorEvents === 0) return "success"; // All successful
127
- if (successEvents === 0) return "warning"; // All failed
128
- return "warning"; // Mixed results
129
- };
130
-
131
- return (
132
- <CollapsibleEventGroup
133
- events={events}
134
- title="Validation Events"
135
- iconType={getGroupIconType()}
136
- variant={getGroupVariant()}
137
- getTimestamp={(event) => event.created_at}
138
- renderEvent={(event) => <AutoBeValidateEventMovie event={event} />}
139
- renderSummary={renderSummary}
140
- defaultCollapsed={defaultCollapsed}
141
- description="Validation and review events"
142
- />
143
- );
144
- };
145
-
146
- export default ValidateEventGroup;
1
+ import {
2
+ AutoBeDatabaseValidateEvent,
3
+ AutoBeInterfaceOperationReviewEvent,
4
+ AutoBeRealizeAuthorizationValidateEvent,
5
+ AutoBeRealizeValidateEvent,
6
+ AutoBeTestValidateEvent,
7
+ } from "@autobe/interface";
8
+
9
+ import { AutoBeValidateEventMovie } from "../AutoBeValidateEventMovie";
10
+ import { CollapsibleEventGroup } from "../common/CollapsibleEventGroup";
11
+
12
+ export type ValidateEvent =
13
+ | AutoBeDatabaseValidateEvent
14
+ | AutoBeInterfaceOperationReviewEvent
15
+ | AutoBeTestValidateEvent
16
+ | AutoBeRealizeValidateEvent
17
+ | AutoBeRealizeAuthorizationValidateEvent;
18
+
19
+ export interface IValidateEventGroupProps {
20
+ events: ValidateEvent[];
21
+ defaultCollapsed?: boolean;
22
+ }
23
+
24
+ /**
25
+ * Specialized group component for validation events Shows validation summary
26
+ * and error statistics
27
+ */
28
+ export const ValidateEventGroup = (props: IValidateEventGroupProps) => {
29
+ const { events, defaultCollapsed = true } = props;
30
+
31
+ if (events.length === 0) {
32
+ return null;
33
+ }
34
+
35
+ // Calculate validation statistics
36
+ const errorEvents = events.filter((event) => {
37
+ switch (event.type) {
38
+ case "databaseValidate":
39
+ case "realizeValidate":
40
+ return true;
41
+ case "testValidate":
42
+ case "realizeAuthorizationValidate":
43
+ return event.result.type !== "success";
44
+ case "interfaceOperationReview":
45
+ default:
46
+ return false;
47
+ }
48
+ }).length;
49
+
50
+ const successEvents = events.length - errorEvents;
51
+ const eventTypes = Array.from(new Set(events.map((e) => e.type)));
52
+
53
+ const renderSummary = (events: ValidateEvent[]) => (
54
+ <>
55
+ Validation and review events from various components
56
+ <br />
57
+ <br />
58
+ <strong>Success Rate:</strong>{" "}
59
+ {events.length > 0
60
+ ? Math.round((successEvents / events.length) * 100)
61
+ : 0}
62
+ %
63
+ <br />
64
+ <strong>Successful:</strong> {successEvents} events
65
+ <br />
66
+ <strong>Failed/Issues:</strong> {errorEvents} events
67
+ <br />
68
+ <strong>Event Types:</strong> {eventTypes.join(", ")}
69
+ <br />
70
+ <br />
71
+ <div
72
+ style={{
73
+ display: "flex",
74
+ gap: "0.5rem",
75
+ alignItems: "center",
76
+ }}
77
+ >
78
+ <div
79
+ style={{
80
+ display: "flex",
81
+ alignItems: "center",
82
+ gap: "0.25rem",
83
+ }}
84
+ >
85
+ <div
86
+ style={{
87
+ width: "12px",
88
+ height: "12px",
89
+ backgroundColor: "#4caf50",
90
+ borderRadius: "2px",
91
+ }}
92
+ />
93
+ <span style={{ fontSize: "0.75rem" }}>Success: {successEvents}</span>
94
+ </div>
95
+ <div
96
+ style={{
97
+ display: "flex",
98
+ alignItems: "center",
99
+ gap: "0.25rem",
100
+ }}
101
+ >
102
+ <div
103
+ style={{
104
+ width: "12px",
105
+ height: "12px",
106
+ backgroundColor: "#f59e0b",
107
+ borderRadius: "2px",
108
+ }}
109
+ />
110
+ <span style={{ fontSize: "0.75rem" }}>Issues: {errorEvents}</span>
111
+ </div>
112
+ </div>
113
+ </>
114
+ );
115
+
116
+ const getGroupIconType = () => {
117
+ if (errorEvents === 0) return "success"; // All successful
118
+ if (successEvents === 0) return "warning"; // All failed
119
+ return "warning"; // Mixed results
120
+ };
121
+
122
+ const getGroupVariant = () => {
123
+ if (errorEvents === 0) return "success"; // All successful
124
+ if (successEvents === 0) return "warning"; // All failed
125
+ return "warning"; // Mixed results
126
+ };
127
+
128
+ return (
129
+ <CollapsibleEventGroup
130
+ events={events}
131
+ title="Validation Events"
132
+ iconType={getGroupIconType()}
133
+ variant={getGroupVariant()}
134
+ getTimestamp={(event) => event.created_at}
135
+ renderEvent={(event) => <AutoBeValidateEventMovie event={event} />}
136
+ renderSummary={renderSummary}
137
+ defaultCollapsed={defaultCollapsed}
138
+ description="Validation and review events"
139
+ />
140
+ );
141
+ };
142
+
143
+ export default ValidateEventGroup;