@oneuptime/common 9.2.11 → 9.2.14
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/Models/DatabaseModels/AlertInternalNote.ts +29 -0
- package/Models/DatabaseModels/IncidentInternalNote.ts +29 -0
- package/Models/DatabaseModels/IncidentPublicNote.ts +29 -0
- package/Models/DatabaseModels/Index.ts +3 -11
- package/Models/DatabaseModels/{CopilotPullRequest.ts → LlmProvider.ts} +243 -248
- package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts +29 -0
- package/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +29 -0
- package/Server/API/LlmProviderAPI.ts +57 -0
- package/Server/API/MicrosoftTeamsAPI.ts +2 -146
- package/Server/API/SlackAPI.ts +105 -0
- package/Server/API/StatusPageAPI.ts +6 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.ts +71 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.ts +45 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.ts +61 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.ts +35 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Middleware/SlackAuthorization.ts +4 -1
- package/Server/Services/AlertInternalNoteService.ts +26 -0
- package/Server/Services/IncidentInternalNoteService.ts +26 -0
- package/Server/Services/IncidentPublicNoteService.ts +26 -0
- package/Server/Services/Index.ts +2 -11
- package/Server/Services/LlmProviderService.ts +100 -0
- package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +26 -0
- package/Server/Services/ScheduledMaintenancePublicNoteService.ts +26 -0
- package/Server/Services/StatusPageService.ts +3 -0
- package/Server/Utils/Express.ts +1 -0
- package/Server/Utils/StartServer.ts +5 -0
- package/Server/Utils/StatusPageResource.ts +89 -0
- package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +96 -55
- package/Server/Utils/Workspace/Slack/Actions/ActionTypes.ts +16 -0
- package/Server/Utils/Workspace/Slack/Actions/Alert.ts +184 -1
- package/Server/Utils/Workspace/Slack/Actions/Incident.ts +224 -1
- package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +232 -1
- package/Server/Utils/Workspace/Slack/Slack.ts +113 -0
- package/Server/Utils/Workspace/Slack/app-manifest.json +13 -2
- package/Tests/Server/Utils/StatusPageResource.test.ts +161 -0
- package/Types/Icon/IconProp.ts +1 -0
- package/Types/LLM/Index.ts +4 -0
- package/Types/LLM/LlmType.ts +7 -0
- package/Types/Monitor/MonitorStep.ts +14 -0
- package/Types/Permission.ts +38 -113
- package/UI/Components/Icon/Icon.tsx +8 -0
- package/UI/Components/Link/Link.tsx +5 -1
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js +30 -0
- package/build/dist/Models/DatabaseModels/AlertInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentInternalNote.js +30 -0
- package/build/dist/Models/DatabaseModels/IncidentInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js +30 -0
- package/build/dist/Models/DatabaseModels/IncidentPublicNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -10
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/{CopilotPullRequest.js → LlmProvider.js} +263 -255
- package/build/dist/Models/DatabaseModels/LlmProvider.js.map +1 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +30 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +30 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js.map +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +36 -0
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -0
- package/build/dist/Server/API/MicrosoftTeamsAPI.js +2 -91
- package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
- package/build/dist/Server/API/SlackAPI.js +74 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -1
- package/build/dist/Server/API/StatusPageAPI.js +6 -0
- package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765477339178-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.js +22 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540325149-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.js +39 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765540549739-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.js +18 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1765544010078-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js +4 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AlertInternalNoteService.js +24 -0
- package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentInternalNoteService.js +24 -0
- package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/IncidentPublicNoteService.js +24 -0
- package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -10
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/LlmProviderService.js +85 -0
- package/build/dist/Server/Services/LlmProviderService.js.map +1 -0
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +24 -0
- package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +24 -0
- package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +3 -0
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Utils/Express.js.map +1 -1
- package/build/dist/Server/Utils/StartServer.js +5 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Server/Utils/StatusPageResource.js +68 -0
- package/build/dist/Server/Utils/StatusPageResource.js.map +1 -0
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +73 -42
- package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js +13 -0
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ActionTypes.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +143 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +173 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +173 -1
- package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js +92 -0
- package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
- package/build/dist/Server/Utils/Workspace/Slack/app-manifest.json +12 -2
- package/build/dist/Tests/Server/Utils/StatusPageResource.test.js +122 -0
- package/build/dist/Tests/Server/Utils/StatusPageResource.test.js.map +1 -0
- package/build/dist/Types/Icon/IconProp.js +1 -0
- package/build/dist/Types/Icon/IconProp.js.map +1 -1
- package/build/dist/Types/LLM/Index.js +4 -0
- package/build/dist/Types/LLM/Index.js.map +1 -0
- package/build/dist/Types/LLM/LlmType.js +8 -0
- package/build/dist/Types/LLM/LlmType.js.map +1 -0
- package/build/dist/Types/Monitor/MonitorStep.js +10 -0
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Permission.js +32 -97
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +3 -0
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Link/Link.js +4 -1
- package/build/dist/UI/Components/Link/Link.js.map +1 -1
- package/package.json +5 -1
- package/Models/DatabaseModels/CopilotAction.ts +0 -772
- package/Models/DatabaseModels/CopilotActionTypePriority.ts +0 -340
- package/Models/DatabaseModels/CopilotCodeRepository.ts +0 -637
- package/Models/DatabaseModels/ServiceCopilotCodeRepository.ts +0 -544
- package/Server/API/CopilotActionAPI.ts +0 -418
- package/Server/API/CopilotCodeRepositoryAPI.ts +0 -127
- package/Server/API/CopilotPullRequestAPI.ts +0 -243
- package/Server/Docs/CodeRepository.md +0 -43
- package/Server/Middleware/CodeRepositoryAuthorization.ts +0 -50
- package/Server/Services/CopilotActionService.ts +0 -10
- package/Server/Services/CopilotActionTypePriorityService.ts +0 -67
- package/Server/Services/CopilotCodeRepositoryService.ts +0 -62
- package/Server/Services/CopilotPullRequestService.ts +0 -10
- package/Server/Services/ServiceCopilotCodeRepositoryService.ts +0 -10
- package/Types/Copilot/CopilotActionProps/DirectoryActionProp.ts +0 -3
- package/Types/Copilot/CopilotActionProps/ExceptionActionProp.ts +0 -4
- package/Types/Copilot/CopilotActionProps/FileActionProp.ts +0 -7
- package/Types/Copilot/CopilotActionProps/FunctionActionProp.ts +0 -5
- package/Types/Copilot/CopilotActionProps/Index.ts +0 -96
- package/Types/Copilot/CopilotActionProps/SpanActionProp.ts +0 -4
- package/Types/Copilot/CopilotActionStatus.ts +0 -114
- package/Types/Copilot/CopilotActionType.ts +0 -212
- package/build/dist/Models/DatabaseModels/CopilotAction.js +0 -793
- package/build/dist/Models/DatabaseModels/CopilotAction.js.map +0 -1
- package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +0 -358
- package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +0 -1
- package/build/dist/Models/DatabaseModels/CopilotCodeRepository.js +0 -656
- package/build/dist/Models/DatabaseModels/CopilotCodeRepository.js.map +0 -1
- package/build/dist/Models/DatabaseModels/CopilotPullRequest.js.map +0 -1
- package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js +0 -561
- package/build/dist/Models/DatabaseModels/ServiceCopilotCodeRepository.js.map +0 -1
- package/build/dist/Server/API/CopilotActionAPI.js +0 -295
- package/build/dist/Server/API/CopilotActionAPI.js.map +0 -1
- package/build/dist/Server/API/CopilotCodeRepositoryAPI.js +0 -91
- package/build/dist/Server/API/CopilotCodeRepositoryAPI.js.map +0 -1
- package/build/dist/Server/API/CopilotPullRequestAPI.js +0 -166
- package/build/dist/Server/API/CopilotPullRequestAPI.js.map +0 -1
- package/build/dist/Server/Middleware/CodeRepositoryAuthorization.js +0 -48
- package/build/dist/Server/Middleware/CodeRepositoryAuthorization.js.map +0 -1
- package/build/dist/Server/Services/CopilotActionService.js +0 -9
- package/build/dist/Server/Services/CopilotActionService.js.map +0 -1
- package/build/dist/Server/Services/CopilotActionTypePriorityService.js +0 -61
- package/build/dist/Server/Services/CopilotActionTypePriorityService.js.map +0 -1
- package/build/dist/Server/Services/CopilotCodeRepositoryService.js +0 -61
- package/build/dist/Server/Services/CopilotCodeRepositoryService.js.map +0 -1
- package/build/dist/Server/Services/CopilotPullRequestService.js +0 -9
- package/build/dist/Server/Services/CopilotPullRequestService.js.map +0 -1
- package/build/dist/Server/Services/ServiceCopilotCodeRepositoryService.js +0 -9
- package/build/dist/Server/Services/ServiceCopilotCodeRepositoryService.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js +0 -2
- package/build/dist/Types/Copilot/CopilotActionProps/DirectoryActionProp.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js +0 -2
- package/build/dist/Types/Copilot/CopilotActionProps/ExceptionActionProp.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js +0 -2
- package/build/dist/Types/Copilot/CopilotActionProps/FileActionProp.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js +0 -2
- package/build/dist/Types/Copilot/CopilotActionProps/FunctionActionProp.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/Index.js +0 -64
- package/build/dist/Types/Copilot/CopilotActionProps/Index.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js +0 -2
- package/build/dist/Types/Copilot/CopilotActionProps/SpanActionProp.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionStatus.js +0 -96
- package/build/dist/Types/Copilot/CopilotActionStatus.js.map +0 -1
- package/build/dist/Types/Copilot/CopilotActionType.js +0 -175
- package/build/dist/Types/Copilot/CopilotActionType.js.map +0 -1
|
@@ -1,418 +0,0 @@
|
|
|
1
|
-
import CopilotCodeRepository from "../../Models/DatabaseModels/CopilotCodeRepository";
|
|
2
|
-
import CopilotActionService, {
|
|
3
|
-
Service as CopilotActionServiceType,
|
|
4
|
-
} from "../Services/CopilotActionService";
|
|
5
|
-
import {
|
|
6
|
-
ExpressRequest,
|
|
7
|
-
ExpressResponse,
|
|
8
|
-
NextFunction,
|
|
9
|
-
} from "../Utils/Express";
|
|
10
|
-
import Response from "../Utils/Response";
|
|
11
|
-
import BaseAPI from "./BaseAPI";
|
|
12
|
-
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
|
|
13
|
-
import BadDataException from "../../Types/Exception/BadDataException";
|
|
14
|
-
import ObjectID from "../../Types/ObjectID";
|
|
15
|
-
import CopilotAction from "../../Models/DatabaseModels/CopilotAction";
|
|
16
|
-
import CopilotCodeRepositoryService from "../Services/CopilotCodeRepositoryService";
|
|
17
|
-
import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
|
|
18
|
-
import CopilotActionStatus from "../../Types/Copilot/CopilotActionStatus";
|
|
19
|
-
import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
|
|
20
|
-
import CopilotActionTypePriorityService from "../Services/CopilotActionTypePriorityService";
|
|
21
|
-
import SortOrder from "../../Types/BaseDatabase/SortOrder";
|
|
22
|
-
import JSONFunctions from "../../Types/JSONFunctions";
|
|
23
|
-
import CopilotActionType from "../../Types/Copilot/CopilotActionType";
|
|
24
|
-
import { JSONObject } from "../../Types/JSON";
|
|
25
|
-
import OneUptimeDate from "../../Types/Date";
|
|
26
|
-
|
|
27
|
-
export default class CopilotActionAPI extends BaseAPI<
|
|
28
|
-
CopilotAction,
|
|
29
|
-
CopilotActionServiceType
|
|
30
|
-
> {
|
|
31
|
-
public constructor() {
|
|
32
|
-
super(CopilotAction, CopilotActionService);
|
|
33
|
-
|
|
34
|
-
this.router.get(
|
|
35
|
-
`${new this.entityType()
|
|
36
|
-
.getCrudApiPath()
|
|
37
|
-
?.toString()}/copilot-action-types-by-priority/:secretkey`,
|
|
38
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
39
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
40
|
-
try {
|
|
41
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
42
|
-
|
|
43
|
-
if (!secretkey) {
|
|
44
|
-
throw new BadDataException("Secret key is required");
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
48
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
49
|
-
query: {
|
|
50
|
-
secretToken: new ObjectID(secretkey),
|
|
51
|
-
},
|
|
52
|
-
select: {
|
|
53
|
-
_id: true,
|
|
54
|
-
},
|
|
55
|
-
props: {
|
|
56
|
-
isRoot: true,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
if (!codeRepository) {
|
|
61
|
-
throw new BadDataException(
|
|
62
|
-
"Code repository not found. Secret key is invalid.",
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const copilotActionTypes: Array<CopilotActionTypePriority> =
|
|
67
|
-
await CopilotActionTypePriorityService.findBy({
|
|
68
|
-
query: {
|
|
69
|
-
codeRepositoryId: codeRepository.id!,
|
|
70
|
-
},
|
|
71
|
-
select: {
|
|
72
|
-
_id: true,
|
|
73
|
-
actionType: true,
|
|
74
|
-
priority: true,
|
|
75
|
-
},
|
|
76
|
-
skip: 0,
|
|
77
|
-
sort: {
|
|
78
|
-
priority: SortOrder.Ascending,
|
|
79
|
-
},
|
|
80
|
-
limit: LIMIT_PER_PROJECT,
|
|
81
|
-
props: {
|
|
82
|
-
isRoot: true,
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
return Response.sendJsonObjectResponse(req, res, {
|
|
87
|
-
actionTypes: CopilotActionTypePriority.toJSONArray(
|
|
88
|
-
copilotActionTypes,
|
|
89
|
-
CopilotActionTypePriority,
|
|
90
|
-
),
|
|
91
|
-
});
|
|
92
|
-
} catch (err) {
|
|
93
|
-
next(err);
|
|
94
|
-
}
|
|
95
|
-
},
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
this.router.get(
|
|
99
|
-
`${new this.entityType()
|
|
100
|
-
.getCrudApiPath()
|
|
101
|
-
?.toString()}/copilot-actions-in-queue/:secretkey`,
|
|
102
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
103
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
104
|
-
try {
|
|
105
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
106
|
-
|
|
107
|
-
if (!secretkey) {
|
|
108
|
-
throw new BadDataException("Secret key is required");
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const serviceCatalogId: string = req.body["serviceCatalogId"]!;
|
|
112
|
-
|
|
113
|
-
if (!serviceCatalogId) {
|
|
114
|
-
throw new BadDataException("Service catalog id is required");
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
118
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
119
|
-
query: {
|
|
120
|
-
secretToken: new ObjectID(secretkey),
|
|
121
|
-
},
|
|
122
|
-
select: {
|
|
123
|
-
_id: true,
|
|
124
|
-
},
|
|
125
|
-
props: {
|
|
126
|
-
isRoot: true,
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!codeRepository) {
|
|
131
|
-
throw new BadDataException(
|
|
132
|
-
"Code repository not found. Secret key is invalid.",
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const copilotActions: Array<CopilotAction> =
|
|
137
|
-
await CopilotActionService.findBy({
|
|
138
|
-
query: {
|
|
139
|
-
codeRepositoryId: codeRepository.id!,
|
|
140
|
-
serviceCatalogId: new ObjectID(serviceCatalogId),
|
|
141
|
-
copilotActionStatus: CopilotActionStatus.IN_QUEUE,
|
|
142
|
-
},
|
|
143
|
-
select: {
|
|
144
|
-
_id: true,
|
|
145
|
-
codeRepositoryId: true,
|
|
146
|
-
serviceCatalogId: true,
|
|
147
|
-
copilotActionStatus: true,
|
|
148
|
-
copilotActionType: true,
|
|
149
|
-
copilotActionProp: true,
|
|
150
|
-
createdAt: true,
|
|
151
|
-
copilotPullRequest: {
|
|
152
|
-
_id: true,
|
|
153
|
-
pullRequestId: true,
|
|
154
|
-
copilotPullRequestStatus: true,
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
skip: 0,
|
|
158
|
-
limit: LIMIT_PER_PROJECT,
|
|
159
|
-
props: {
|
|
160
|
-
isRoot: true,
|
|
161
|
-
},
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
return Response.sendJsonObjectResponse(req, res, {
|
|
165
|
-
copilotActions: CopilotAction.toJSONArray(
|
|
166
|
-
copilotActions,
|
|
167
|
-
CopilotAction,
|
|
168
|
-
),
|
|
169
|
-
});
|
|
170
|
-
} catch (err) {
|
|
171
|
-
next(err);
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
);
|
|
175
|
-
|
|
176
|
-
this.router.get(
|
|
177
|
-
`${new this.entityType()
|
|
178
|
-
.getCrudApiPath()
|
|
179
|
-
?.toString()}/get-copilot-action/:secretkey`,
|
|
180
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
181
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
182
|
-
try {
|
|
183
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
184
|
-
|
|
185
|
-
if (!secretkey) {
|
|
186
|
-
throw new BadDataException("Secret key is required");
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
const serviceCatalogId: string = req.body["serviceCatalogId"]!;
|
|
190
|
-
|
|
191
|
-
if (!serviceCatalogId) {
|
|
192
|
-
throw new BadDataException("Service catalog id is required");
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
196
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
197
|
-
query: {
|
|
198
|
-
secretToken: new ObjectID(secretkey),
|
|
199
|
-
},
|
|
200
|
-
select: {
|
|
201
|
-
_id: true,
|
|
202
|
-
},
|
|
203
|
-
props: {
|
|
204
|
-
isRoot: true,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
if (!codeRepository) {
|
|
209
|
-
throw new BadDataException(
|
|
210
|
-
"Code repository not found. Secret key is invalid.",
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
const actionType: CopilotActionType = req.body["actionType"]!;
|
|
215
|
-
|
|
216
|
-
if (!actionType) {
|
|
217
|
-
throw new BadDataException("Action type is required");
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const actionProps: JSONObject = req.body["actionProps"]!;
|
|
221
|
-
|
|
222
|
-
const copilotAction: CopilotAction | null =
|
|
223
|
-
await CopilotActionService.findOneBy({
|
|
224
|
-
query: {
|
|
225
|
-
codeRepositoryId: codeRepository.id!,
|
|
226
|
-
serviceCatalogId: new ObjectID(serviceCatalogId),
|
|
227
|
-
copilotActionType: actionType,
|
|
228
|
-
copilotActionProp: actionProps as any,
|
|
229
|
-
},
|
|
230
|
-
select: {
|
|
231
|
-
_id: true,
|
|
232
|
-
codeRepositoryId: true,
|
|
233
|
-
serviceCatalogId: true,
|
|
234
|
-
copilotActionStatus: true,
|
|
235
|
-
copilotActionType: true,
|
|
236
|
-
createdAt: true,
|
|
237
|
-
copilotPullRequest: {
|
|
238
|
-
_id: true,
|
|
239
|
-
pullRequestId: true,
|
|
240
|
-
copilotPullRequestStatus: true,
|
|
241
|
-
},
|
|
242
|
-
},
|
|
243
|
-
sort: {
|
|
244
|
-
createdAt: SortOrder.Descending,
|
|
245
|
-
},
|
|
246
|
-
props: {
|
|
247
|
-
isRoot: true,
|
|
248
|
-
},
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
return Response.sendJsonObjectResponse(req, res, {
|
|
252
|
-
copilotAction: copilotAction
|
|
253
|
-
? CopilotAction.toJSONObject(copilotAction, CopilotAction)
|
|
254
|
-
: null,
|
|
255
|
-
});
|
|
256
|
-
} catch (err) {
|
|
257
|
-
next(err);
|
|
258
|
-
}
|
|
259
|
-
},
|
|
260
|
-
);
|
|
261
|
-
|
|
262
|
-
this.router.post(
|
|
263
|
-
`${new this.entityType()
|
|
264
|
-
.getCrudApiPath()
|
|
265
|
-
?.toString()}/create-copilot-action/:secretkey`,
|
|
266
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
267
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
268
|
-
try {
|
|
269
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
270
|
-
|
|
271
|
-
if (!secretkey) {
|
|
272
|
-
throw new BadDataException("Secret key is required");
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
276
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
277
|
-
query: {
|
|
278
|
-
secretToken: new ObjectID(secretkey),
|
|
279
|
-
},
|
|
280
|
-
select: {
|
|
281
|
-
_id: true,
|
|
282
|
-
projectId: true,
|
|
283
|
-
},
|
|
284
|
-
props: {
|
|
285
|
-
isRoot: true,
|
|
286
|
-
},
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
if (!codeRepository) {
|
|
290
|
-
throw new BadDataException(
|
|
291
|
-
"Code repository not found. Secret key is invalid.",
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
const copilotAction: CopilotAction = CopilotAction.fromJSON(
|
|
296
|
-
req.body["copilotAction"],
|
|
297
|
-
CopilotAction,
|
|
298
|
-
) as CopilotAction;
|
|
299
|
-
|
|
300
|
-
copilotAction.codeRepositoryId = codeRepository.id!;
|
|
301
|
-
copilotAction.projectId = codeRepository.projectId!;
|
|
302
|
-
copilotAction.copilotActionStatus = CopilotActionStatus.IN_QUEUE;
|
|
303
|
-
|
|
304
|
-
const createdAction: CopilotAction =
|
|
305
|
-
await CopilotActionService.create({
|
|
306
|
-
data: copilotAction,
|
|
307
|
-
props: {
|
|
308
|
-
isRoot: true,
|
|
309
|
-
},
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
return Response.sendEntityResponse(
|
|
313
|
-
req,
|
|
314
|
-
res,
|
|
315
|
-
createdAction,
|
|
316
|
-
CopilotAction,
|
|
317
|
-
);
|
|
318
|
-
} catch (err) {
|
|
319
|
-
next(err);
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
|
-
);
|
|
323
|
-
|
|
324
|
-
this.router.post(
|
|
325
|
-
`${new this.entityType()
|
|
326
|
-
.getCrudApiPath()
|
|
327
|
-
?.toString()}/update-copilot-action/:secretkey`,
|
|
328
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
329
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
330
|
-
try {
|
|
331
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
332
|
-
|
|
333
|
-
if (!secretkey) {
|
|
334
|
-
throw new BadDataException("Secret key is required");
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
338
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
339
|
-
query: {
|
|
340
|
-
secretToken: new ObjectID(secretkey),
|
|
341
|
-
},
|
|
342
|
-
select: {
|
|
343
|
-
_id: true,
|
|
344
|
-
projectId: true,
|
|
345
|
-
},
|
|
346
|
-
props: {
|
|
347
|
-
isRoot: true,
|
|
348
|
-
},
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
if (!codeRepository) {
|
|
352
|
-
throw new BadDataException(
|
|
353
|
-
"Code repository not found. Secret key is invalid.",
|
|
354
|
-
);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
req.body = JSONFunctions.deserialize(req.body);
|
|
358
|
-
|
|
359
|
-
const {
|
|
360
|
-
actionStatus,
|
|
361
|
-
pullRequestId,
|
|
362
|
-
commitHash,
|
|
363
|
-
statusMessage,
|
|
364
|
-
logs,
|
|
365
|
-
actionId,
|
|
366
|
-
}: {
|
|
367
|
-
actionStatus: CopilotActionStatus;
|
|
368
|
-
pullRequestId?: ObjectID | undefined;
|
|
369
|
-
commitHash?: string | undefined;
|
|
370
|
-
statusMessage?: string | undefined;
|
|
371
|
-
logs?: Array<string> | undefined;
|
|
372
|
-
actionId: ObjectID;
|
|
373
|
-
} = req.body;
|
|
374
|
-
|
|
375
|
-
const exisingAction: CopilotAction | null =
|
|
376
|
-
await CopilotActionService.findOneBy({
|
|
377
|
-
query: {
|
|
378
|
-
_id: actionId,
|
|
379
|
-
codeRepositoryId: codeRepository.id!,
|
|
380
|
-
},
|
|
381
|
-
select: {
|
|
382
|
-
_id: true,
|
|
383
|
-
},
|
|
384
|
-
props: {
|
|
385
|
-
isRoot: true,
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
|
|
389
|
-
if (!exisingAction) {
|
|
390
|
-
throw new BadDataException("Action not found");
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
await CopilotActionService.updateOneBy({
|
|
394
|
-
query: {
|
|
395
|
-
_id: actionId,
|
|
396
|
-
codeRepositoryId: codeRepository.id!,
|
|
397
|
-
},
|
|
398
|
-
data: {
|
|
399
|
-
copilotActionStatus: actionStatus!,
|
|
400
|
-
copilotPullRequestId: pullRequestId!,
|
|
401
|
-
commitHash: commitHash!,
|
|
402
|
-
statusMessage: statusMessage!,
|
|
403
|
-
statusChangedAt: OneUptimeDate.getCurrentDate(),
|
|
404
|
-
logs: logs?.join("\n") || "",
|
|
405
|
-
},
|
|
406
|
-
props: {
|
|
407
|
-
isRoot: true,
|
|
408
|
-
},
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
return Response.sendEmptySuccessResponse(req, res);
|
|
412
|
-
} catch (err) {
|
|
413
|
-
next(err);
|
|
414
|
-
}
|
|
415
|
-
},
|
|
416
|
-
);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import OneUptimeDate from "../../Types/Date";
|
|
2
|
-
import CodeRepositoryAuthorization from "../Middleware/CodeRepositoryAuthorization";
|
|
3
|
-
import CopilotCodeRepositoryService, {
|
|
4
|
-
Service as CopilotCodeRepositoryServiceType,
|
|
5
|
-
} from "../Services/CopilotCodeRepositoryService";
|
|
6
|
-
import ServiceCopilotCodeRepositoryService from "../Services/ServiceCopilotCodeRepositoryService";
|
|
7
|
-
import {
|
|
8
|
-
ExpressRequest,
|
|
9
|
-
ExpressResponse,
|
|
10
|
-
NextFunction,
|
|
11
|
-
} from "../Utils/Express";
|
|
12
|
-
import Response from "../Utils/Response";
|
|
13
|
-
import BaseAPI from "./BaseAPI";
|
|
14
|
-
import { LIMIT_PER_PROJECT } from "../../Types/Database/LimitMax";
|
|
15
|
-
import BadDataException from "../../Types/Exception/BadDataException";
|
|
16
|
-
import ObjectID from "../../Types/ObjectID";
|
|
17
|
-
import CopilotCodeRepository from "../../Models/DatabaseModels/CopilotCodeRepository";
|
|
18
|
-
import ServiceCopilotCodeRepository from "../../Models/DatabaseModels/ServiceCopilotCodeRepository";
|
|
19
|
-
|
|
20
|
-
export default class CopilotCodeRepositoryAPI extends BaseAPI<
|
|
21
|
-
CopilotCodeRepository,
|
|
22
|
-
CopilotCodeRepositoryServiceType
|
|
23
|
-
> {
|
|
24
|
-
public constructor() {
|
|
25
|
-
super(CopilotCodeRepository, CopilotCodeRepositoryService);
|
|
26
|
-
|
|
27
|
-
this.router.get(
|
|
28
|
-
`${new this.entityType()
|
|
29
|
-
.getCrudApiPath()
|
|
30
|
-
?.toString()}/is-valid/:secretkey`,
|
|
31
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
32
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
33
|
-
try {
|
|
34
|
-
return Response.sendEmptySuccessResponse(req, res);
|
|
35
|
-
} catch (err) {
|
|
36
|
-
next(err);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
this.router.get(
|
|
42
|
-
`${new this.entityType()
|
|
43
|
-
.getCrudApiPath()
|
|
44
|
-
?.toString()}/get-code-repository/:secretkey`,
|
|
45
|
-
CodeRepositoryAuthorization.isAuthorizedRepository,
|
|
46
|
-
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
47
|
-
try {
|
|
48
|
-
const secretkey: string = req.params["secretkey"]!;
|
|
49
|
-
|
|
50
|
-
if (!secretkey) {
|
|
51
|
-
throw new BadDataException("Secret key is required");
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const codeRepository: CopilotCodeRepository | null =
|
|
55
|
-
await CopilotCodeRepositoryService.findOneBy({
|
|
56
|
-
query: {
|
|
57
|
-
secretToken: new ObjectID(secretkey),
|
|
58
|
-
},
|
|
59
|
-
select: {
|
|
60
|
-
name: true,
|
|
61
|
-
mainBranchName: true,
|
|
62
|
-
organizationName: true,
|
|
63
|
-
repositoryHostedAt: true,
|
|
64
|
-
repositoryName: true,
|
|
65
|
-
},
|
|
66
|
-
props: {
|
|
67
|
-
isRoot: true,
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
if (!codeRepository) {
|
|
72
|
-
throw new BadDataException(
|
|
73
|
-
"Code repository not found. Secret key is invalid.",
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// update last run time.
|
|
78
|
-
|
|
79
|
-
await CopilotCodeRepositoryService.updateOneById({
|
|
80
|
-
id: codeRepository.id!,
|
|
81
|
-
data: {
|
|
82
|
-
lastCopilotRunDateTime: OneUptimeDate.getCurrentDate(),
|
|
83
|
-
},
|
|
84
|
-
props: {
|
|
85
|
-
isRoot: true,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
const servicesRepository: Array<ServiceCopilotCodeRepository> =
|
|
90
|
-
await ServiceCopilotCodeRepositoryService.findBy({
|
|
91
|
-
query: {
|
|
92
|
-
codeRepositoryId: codeRepository.id!,
|
|
93
|
-
enablePullRequests: true,
|
|
94
|
-
},
|
|
95
|
-
select: {
|
|
96
|
-
serviceCatalog: {
|
|
97
|
-
name: true,
|
|
98
|
-
_id: true,
|
|
99
|
-
techStack: true,
|
|
100
|
-
},
|
|
101
|
-
servicePathInRepository: true,
|
|
102
|
-
limitNumberOfOpenPullRequestsCount: true,
|
|
103
|
-
},
|
|
104
|
-
limit: LIMIT_PER_PROJECT,
|
|
105
|
-
skip: 0,
|
|
106
|
-
props: {
|
|
107
|
-
isRoot: true,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
return Response.sendJsonObjectResponse(req, res, {
|
|
112
|
-
codeRepository: CopilotCodeRepository.toJSON(
|
|
113
|
-
codeRepository,
|
|
114
|
-
CopilotCodeRepository,
|
|
115
|
-
),
|
|
116
|
-
servicesRepository: ServiceCopilotCodeRepository.toJSONArray(
|
|
117
|
-
servicesRepository,
|
|
118
|
-
ServiceCopilotCodeRepository,
|
|
119
|
-
),
|
|
120
|
-
});
|
|
121
|
-
} catch (err) {
|
|
122
|
-
next(err);
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
}
|