@oneuptime/common 9.2.16 → 9.2.17

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 (115) hide show
  1. package/Models/DatabaseModels/CodeRepository.ts +664 -0
  2. package/Models/DatabaseModels/Index.ts +8 -0
  3. package/Models/DatabaseModels/LlmLog.ts +818 -0
  4. package/Models/DatabaseModels/LlmProvider.ts +21 -0
  5. package/Models/DatabaseModels/Project.ts +206 -0
  6. package/Models/DatabaseModels/ServiceCatalogCodeRepository.ts +549 -0
  7. package/Server/API/AIBillingAPI.ts +126 -0
  8. package/Server/API/GitHubAPI.ts +360 -0
  9. package/Server/API/IncidentAPI.ts +126 -0
  10. package/Server/EnvironmentConfig.ts +44 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.ts +79 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.ts +75 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.ts +32 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.ts +69 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.ts +111 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.ts +39 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +12 -0
  18. package/Server/Services/AIBillingService.ts +247 -0
  19. package/Server/Services/AIService.ts +239 -0
  20. package/Server/Services/CodeRepositoryService.ts +10 -0
  21. package/Server/Services/IncidentService.ts +89 -0
  22. package/Server/Services/Index.ts +2 -0
  23. package/Server/Services/LlmLogService.ts +14 -0
  24. package/Server/Services/LlmProviderService.ts +58 -0
  25. package/Server/Services/ServiceCatalogCodeRepositoryService.ts +55 -0
  26. package/Server/Utils/AI/IncidentAIContextBuilder.ts +498 -0
  27. package/Server/Utils/CodeRepository/GitHub/GitHub.ts +226 -0
  28. package/Server/Utils/LLM/LLMService.ts +276 -0
  29. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +166 -0
  30. package/Server/Utils/Workspace/Slack/Slack.ts +134 -0
  31. package/Server/Utils/Workspace/Workspace.ts +126 -0
  32. package/Types/CodeRepository/CodeRepositoryType.ts +1 -1
  33. package/Types/LlmLogStatus.ts +7 -0
  34. package/Types/Permission.ts +87 -0
  35. package/Types/ServiceCatalog/CodeRepositoryImprovementAction.ts +9 -0
  36. package/UI/Components/AI/AILoader.tsx +95 -0
  37. package/UI/Components/AI/GenerateFromAIModal.tsx +295 -0
  38. package/UI/Components/Modal/Modal.tsx +6 -1
  39. package/build/dist/Models/DatabaseModels/CodeRepository.js +689 -0
  40. package/build/dist/Models/DatabaseModels/CodeRepository.js.map +1 -0
  41. package/build/dist/Models/DatabaseModels/Index.js +7 -0
  42. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  43. package/build/dist/Models/DatabaseModels/LlmLog.js +856 -0
  44. package/build/dist/Models/DatabaseModels/LlmLog.js.map +1 -0
  45. package/build/dist/Models/DatabaseModels/LlmProvider.js +22 -0
  46. package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -1
  47. package/build/dist/Models/DatabaseModels/Project.js +220 -0
  48. package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
  49. package/build/dist/Models/DatabaseModels/ServiceCatalogCodeRepository.js +565 -0
  50. package/build/dist/Models/DatabaseModels/ServiceCatalogCodeRepository.js.map +1 -0
  51. package/build/dist/Server/API/AIBillingAPI.js +58 -0
  52. package/build/dist/Server/API/AIBillingAPI.js.map +1 -0
  53. package/build/dist/Server/API/GitHubAPI.js +207 -0
  54. package/build/dist/Server/API/GitHubAPI.js.map +1 -0
  55. package/build/dist/Server/API/IncidentAPI.js +84 -1
  56. package/build/dist/Server/API/IncidentAPI.js.map +1 -1
  57. package/build/dist/Server/EnvironmentConfig.js +31 -0
  58. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  59. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.js +34 -0
  60. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765580181582-MigrationName.js.map +1 -0
  61. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.js +32 -0
  62. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765633554715-MigrationName.js.map +1 -0
  63. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.js +38 -0
  64. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765801357168-MigrationName.js.map +1 -0
  65. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.js +30 -0
  66. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765810218488-MigrationName.js.map +1 -0
  67. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.js +44 -0
  68. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765830758857-MigrationName.js.map +1 -0
  69. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.js +22 -0
  70. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765834537501-MigrationName.js.map +1 -0
  71. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +12 -0
  72. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  73. package/build/dist/Server/Services/AIBillingService.js +187 -0
  74. package/build/dist/Server/Services/AIBillingService.js.map +1 -0
  75. package/build/dist/Server/Services/AIService.js +185 -0
  76. package/build/dist/Server/Services/AIService.js.map +1 -0
  77. package/build/dist/Server/Services/CodeRepositoryService.js +9 -0
  78. package/build/dist/Server/Services/CodeRepositoryService.js.map +1 -0
  79. package/build/dist/Server/Services/IncidentService.js +61 -0
  80. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  81. package/build/dist/Server/Services/Index.js +2 -0
  82. package/build/dist/Server/Services/Index.js.map +1 -1
  83. package/build/dist/Server/Services/LlmLogService.js +13 -0
  84. package/build/dist/Server/Services/LlmLogService.js.map +1 -0
  85. package/build/dist/Server/Services/LlmProviderService.js +65 -0
  86. package/build/dist/Server/Services/LlmProviderService.js.map +1 -1
  87. package/build/dist/Server/Services/ServiceCatalogCodeRepositoryService.js +54 -0
  88. package/build/dist/Server/Services/ServiceCatalogCodeRepositoryService.js.map +1 -0
  89. package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js +408 -0
  90. package/build/dist/Server/Utils/AI/IncidentAIContextBuilder.js.map +1 -0
  91. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js +163 -0
  92. package/build/dist/Server/Utils/CodeRepository/GitHub/GitHub.js.map +1 -1
  93. package/build/dist/Server/Utils/LLM/LLMService.js +225 -0
  94. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -0
  95. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +110 -0
  96. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  97. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +89 -0
  98. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  99. package/build/dist/Server/Utils/Workspace/Workspace.js +80 -0
  100. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  101. package/build/dist/Types/CodeRepository/CodeRepositoryType.js +1 -1
  102. package/build/dist/Types/CodeRepository/CodeRepositoryType.js.map +1 -1
  103. package/build/dist/Types/LlmLogStatus.js +8 -0
  104. package/build/dist/Types/LlmLogStatus.js.map +1 -0
  105. package/build/dist/Types/Permission.js +74 -0
  106. package/build/dist/Types/Permission.js.map +1 -1
  107. package/build/dist/Types/ServiceCatalog/CodeRepositoryImprovementAction.js +10 -0
  108. package/build/dist/Types/ServiceCatalog/CodeRepositoryImprovementAction.js.map +1 -0
  109. package/build/dist/UI/Components/AI/AILoader.js +64 -0
  110. package/build/dist/UI/Components/AI/AILoader.js.map +1 -0
  111. package/build/dist/UI/Components/AI/GenerateFromAIModal.js +207 -0
  112. package/build/dist/UI/Components/AI/GenerateFromAIModal.js.map +1 -0
  113. package/build/dist/UI/Components/Modal/Modal.js +6 -1
  114. package/build/dist/UI/Components/Modal/Modal.js.map +1 -1
  115. package/package.json +1 -1
@@ -0,0 +1,295 @@
1
+ import React, {
2
+ FunctionComponent,
3
+ ReactElement,
4
+ useState,
5
+ useEffect,
6
+ } from "react";
7
+ import Modal, { ModalWidth } from "../Modal/Modal";
8
+ import AILoader from "./AILoader";
9
+ import ErrorMessage from "../ErrorMessage/ErrorMessage";
10
+ import ButtonType from "../Button/ButtonTypes";
11
+ import { ButtonStyleType } from "../Button/Button";
12
+ import IconProp from "../../../Types/Icon/IconProp";
13
+ import Dropdown, { DropdownOption, DropdownValue } from "../Dropdown/Dropdown";
14
+ import MarkdownEditor from "../Markdown.tsx/MarkdownEditor";
15
+
16
+ export interface GenerateFromAIModalProps {
17
+ title: string;
18
+ description?: string;
19
+ onClose: () => void;
20
+ onGenerate: (data: GenerateAIRequestData) => Promise<string>;
21
+ onSuccess: (generatedContent: string) => void;
22
+ templates?: Array<{ id: string; name: string; content?: string }>;
23
+ }
24
+
25
+ export interface GenerateAIRequestData {
26
+ template?: string;
27
+ templateId?: string;
28
+ }
29
+
30
+ // Default hardcoded templates for incident postmortem
31
+ const DEFAULT_TEMPLATES: Array<{ id: string; name: string; content: string }> =
32
+ [
33
+ {
34
+ id: "default-standard",
35
+ name: "Standard Postmortem",
36
+ content: `## Executive Summary
37
+ [Brief overview of the incident, its impact, and resolution]
38
+
39
+ ## Incident Timeline
40
+ | Time | Event |
41
+ |------|-------|
42
+ | [Time] | [Event description] |
43
+
44
+ ## Root Cause Analysis
45
+ [Detailed analysis of what caused the incident]
46
+
47
+ ## Impact Assessment
48
+ - **Duration**: [How long the incident lasted]
49
+ - **Users Affected**: [Number or percentage of affected users]
50
+ - **Services Affected**: [List of affected services]
51
+
52
+ ## Resolution
53
+ [Steps taken to resolve the incident]
54
+
55
+ ## Action Items
56
+ - [ ] [Action item 1]
57
+ - [ ] [Action item 2]
58
+ - [ ] [Action item 3]
59
+
60
+ ## Lessons Learned
61
+ [Key takeaways and improvements identified]`,
62
+ },
63
+ {
64
+ id: "default-detailed",
65
+ name: "Detailed Technical Postmortem",
66
+ content: `## Incident Overview
67
+ **Incident Title**: [Title]
68
+ **Severity**: [P1/P2/P3/P4]
69
+ **Duration**: [Start time] - [End time]
70
+ **Authors**: [Names]
71
+
72
+ ## Summary
73
+ [2-3 sentence summary of the incident]
74
+
75
+ ## Detection
76
+ - **How was the incident detected?** [Monitoring alert / Customer report / etc.]
77
+ - **Time to detection**: [Duration from start to detection]
78
+
79
+ ## Timeline
80
+ | Timestamp | Action | Owner |
81
+ |-----------|--------|-------|
82
+ | [Time] | [What happened] | [Who did it] |
83
+
84
+ ## Root Cause
85
+ ### Primary Cause
86
+ [Detailed explanation of the root cause]
87
+
88
+ ### Contributing Factors
89
+ 1. [Factor 1]
90
+ 2. [Factor 2]
91
+
92
+ ## Impact
93
+ ### Customer Impact
94
+ [Description of how customers were affected]
95
+
96
+ ### Business Impact
97
+ [Description of business consequences]
98
+
99
+ ### Technical Impact
100
+ [Systems and services affected]
101
+
102
+ ## Mitigation & Resolution
103
+ ### Immediate Actions
104
+ [Steps taken to stop the bleeding]
105
+
106
+ ### Permanent Fix
107
+ [Long-term solution implemented]
108
+
109
+ ## Prevention
110
+ ### What Went Well
111
+ - [Item 1]
112
+ - [Item 2]
113
+
114
+ ### What Went Wrong
115
+ - [Item 1]
116
+ - [Item 2]
117
+
118
+ ### Where We Got Lucky
119
+ - [Item 1]
120
+
121
+ ## Action Items
122
+ | Action | Owner | Priority | Due Date |
123
+ |--------|-------|----------|----------|
124
+ | [Action] | [Name] | [High/Medium/Low] | [Date] |
125
+
126
+ ## Appendix
127
+ [Any additional technical details, logs, or graphs]`,
128
+ },
129
+ {
130
+ id: "default-brief",
131
+ name: "Brief Postmortem",
132
+ content: `## What Happened
133
+ [Concise description of the incident]
134
+
135
+ ## Why It Happened
136
+ [Root cause explanation]
137
+
138
+ ## How We Fixed It
139
+ [Resolution steps]
140
+
141
+ ## How We Prevent It
142
+ - [ ] [Prevention action 1]
143
+ - [ ] [Prevention action 2]`,
144
+ },
145
+ ];
146
+
147
+ const GenerateFromAIModal: FunctionComponent<GenerateFromAIModalProps> = (
148
+ props: GenerateFromAIModalProps,
149
+ ): ReactElement => {
150
+ const [isGenerating, setIsGenerating] = useState<boolean>(false);
151
+ const [error, setError] = useState<string>("");
152
+ const [selectedTemplateId, setSelectedTemplateId] = useState<string>(
153
+ DEFAULT_TEMPLATES[0]?.id || "",
154
+ );
155
+ const [templateContent, setTemplateContent] = useState<string>("");
156
+
157
+ // Combine default templates with custom templates
158
+ const allTemplates: Array<{ id: string; name: string; content?: string }> = [
159
+ ...DEFAULT_TEMPLATES,
160
+ ...(props.templates || []),
161
+ ];
162
+
163
+ // Build dropdown options
164
+ const templateOptions: Array<DropdownOption> = allTemplates.map(
165
+ (template: { id: string; name: string; content?: string }) => {
166
+ return {
167
+ label: template.name,
168
+ value: template.id,
169
+ };
170
+ },
171
+ );
172
+
173
+ // Update template content when selection changes
174
+ useEffect(() => {
175
+ if (selectedTemplateId) {
176
+ const selectedTemplate:
177
+ | { id: string; name: string; content?: string }
178
+ | undefined = allTemplates.find(
179
+ (t: { id: string; name: string; content?: string }) => {
180
+ return t.id === selectedTemplateId;
181
+ },
182
+ );
183
+ setTemplateContent(selectedTemplate?.content || "");
184
+ } else {
185
+ setTemplateContent("");
186
+ }
187
+ }, [selectedTemplateId]);
188
+
189
+ const handleGenerate: () => Promise<void> = async (): Promise<void> => {
190
+ setIsGenerating(true);
191
+ setError("");
192
+
193
+ try {
194
+ const requestData: GenerateAIRequestData = {};
195
+
196
+ // Use the edited template content if a template was selected
197
+ if (selectedTemplateId && templateContent) {
198
+ requestData.template = templateContent;
199
+ requestData.templateId = selectedTemplateId;
200
+ }
201
+
202
+ const generatedContent: string = await props.onGenerate(requestData);
203
+ props.onSuccess(generatedContent);
204
+ } catch (err) {
205
+ if (err instanceof Error) {
206
+ setError(err.message);
207
+ } else {
208
+ setError("An error occurred while generating content.");
209
+ }
210
+ } finally {
211
+ setIsGenerating(false);
212
+ }
213
+ };
214
+
215
+ return (
216
+ <Modal
217
+ title={props.title}
218
+ description={
219
+ props.description ||
220
+ "Generate content using AI based on the available data."
221
+ }
222
+ onClose={() => {
223
+ if (!isGenerating) {
224
+ props.onClose();
225
+ }
226
+ }}
227
+ submitButtonText={isGenerating ? "Generating..." : "Generate with AI"}
228
+ submitButtonStyleType={ButtonStyleType.PRIMARY}
229
+ submitButtonType={ButtonType.Button}
230
+ isLoading={isGenerating}
231
+ disableSubmitButton={isGenerating}
232
+ onSubmit={handleGenerate}
233
+ modalWidth={ModalWidth.Large}
234
+ icon={IconProp.Bolt}
235
+ >
236
+ <>
237
+ {error && <ErrorMessage message={error} />}
238
+
239
+ {isGenerating && <AILoader />}
240
+
241
+ {!isGenerating && (
242
+ <div className="space-y-4">
243
+ {/* Template Selection */}
244
+ <div>
245
+ <label className="block text-sm font-medium text-gray-700 mb-1">
246
+ Select Template
247
+ </label>
248
+ <Dropdown
249
+ options={templateOptions}
250
+ value={templateOptions.find((opt: DropdownOption) => {
251
+ return opt.value === selectedTemplateId;
252
+ })}
253
+ onChange={(
254
+ value: DropdownValue | Array<DropdownValue> | null,
255
+ ) => {
256
+ setSelectedTemplateId((value as string) || "");
257
+ }}
258
+ placeholder="Select a template..."
259
+ />
260
+ <p className="mt-1 text-xs text-gray-500">
261
+ Choose a template to guide the AI generation. You can edit it
262
+ below before generating.
263
+ </p>
264
+ </div>
265
+
266
+ {/* Template Preview/Editor */}
267
+ {selectedTemplateId && (
268
+ <div>
269
+ <label className="block text-sm font-medium text-gray-700 mb-1">
270
+ Template Preview
271
+ </label>
272
+ <p className="text-xs text-gray-500 mb-2">
273
+ Edit the template below. AI will fill in the sections with
274
+ incident data.
275
+ </p>
276
+ <div className="">
277
+ <MarkdownEditor
278
+ key={selectedTemplateId}
279
+ initialValue={templateContent}
280
+ onChange={(value: string) => {
281
+ setTemplateContent(value);
282
+ }}
283
+ placeholder="Template content..."
284
+ />
285
+ </div>
286
+ </div>
287
+ )}
288
+ </div>
289
+ )}
290
+ </>
291
+ </Modal>
292
+ );
293
+ };
294
+
295
+ export default GenerateFromAIModal;
@@ -39,15 +39,20 @@ const Modal: FunctionComponent<ComponentProps> = (
39
39
  props: ComponentProps,
40
40
  ): ReactElement => {
41
41
  let iconBgColor: string = "bg-indigo-100";
42
+ let iconColor: string = "text-indigo-600";
42
43
 
43
44
  if (props.iconType === IconType.Info) {
44
45
  iconBgColor = "bg-indigo-100";
46
+ iconColor = "text-indigo-600";
45
47
  } else if (props.iconType === IconType.Warning) {
46
48
  iconBgColor = "bg-yellow-100";
49
+ iconColor = "text-yellow-600";
47
50
  } else if (props.iconType === IconType.Success) {
48
51
  iconBgColor = "bg-green-100";
52
+ iconColor = "text-green-600";
49
53
  } else if (props.iconType === IconType.Danger) {
50
54
  iconBgColor = "bg-red-100";
55
+ iconColor = "text-red-600";
51
56
  }
52
57
 
53
58
  return (
@@ -98,7 +103,7 @@ const Modal: FunctionComponent<ComponentProps> = (
98
103
  ? IconType.Info
99
104
  : props.iconType
100
105
  }
101
- className={"text-red-600 h-6 w-6 stroke-2"}
106
+ className={`${iconColor} h-6 w-6 stroke-2`}
102
107
  icon={props.icon}
103
108
  size={SizeProp.Large}
104
109
  />