@oneuptime/common 7.0.3617 → 7.0.3652
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/Alert.ts +29 -0
- package/Models/DatabaseModels/Index.ts +10 -0
- package/Models/DatabaseModels/ScheduledMaintenance.ts +29 -0
- package/Models/DatabaseModels/WorkspaceNotificationRule.ts +461 -0
- package/Models/DatabaseModels/WorkspaceProjectAuthToken.ts +379 -0
- package/Models/DatabaseModels/WorkspaceSetting.ts +230 -0
- package/Models/DatabaseModels/WorkspaceUserAuthToken.ts +312 -0
- package/Server/API/SlackAPI.ts +368 -0
- package/Server/EnvironmentConfig.ts +23 -2
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.ts +147 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.ts +19 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.ts +23 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
- package/Server/Middleware/SlackAuthorization.ts +60 -0
- package/Server/Services/AlertService.ts +38 -2
- package/Server/Services/Index.ts +9 -0
- package/Server/Services/ProjectService.ts +177 -16
- package/Server/Services/ScheduledMaintenanceService.ts +39 -2
- package/Server/Services/UserService.ts +4 -4
- package/Server/Services/WorkspaceCommunicationTools/Slack.ts +0 -0
- package/Server/Services/WorkspaceCommunicationTools/Teams.ts +0 -0
- package/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.ts +0 -0
- package/Server/Services/WorkspaceNotificationRuleService.ts +22 -0
- package/Server/Services/WorkspaceProjectAuthTokenService.ts +84 -0
- package/Server/Services/WorkspaceSettingService.ts +78 -0
- package/Server/Services/WorkspaceUserAuthTokenService.ts +89 -0
- package/Server/Types/Workflow/Components/Slack/SendMessageToChannel.ts +1 -1
- package/Server/Utils/Express.ts +2 -1
- package/Server/Utils/Monitor/MonitorResource.ts +2 -5
- package/Server/Utils/{Slack.ts → Slack/Slack.ts} +40 -0
- package/Server/Utils/Slack/app-manifest-temp.json +198 -0
- package/Server/Utils/Slack/app-manifest.json +67 -0
- package/Server/Utils/StartServer.ts +2 -1
- package/Types/Filter/FilterCondition.ts +2 -2
- package/Types/Monitor/CriteriaFilter.ts +31 -5
- package/Types/Monitor/MonitorCriteriaInstance.ts +40 -10
- package/Types/Monitor/MonitorStep.ts +1 -1
- package/Types/Permission.ts +34 -0
- package/Types/Workspace/NotificationRules/BaseNotificationRule.ts +3 -0
- package/Types/Workspace/NotificationRules/EventType.ts +8 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.ts +355 -0
- package/Types/Workspace/NotificationRules/SlackNotificationRule.ts +19 -0
- package/Types/Workspace/WorkspaceNotificationPayload.ts +3 -0
- package/Types/Workspace/WorkspaceType.ts +6 -0
- package/UI/Components/Forms/BasicForm.tsx +9 -0
- package/UI/Components/Forms/Fields/FormField.tsx +36 -1
- package/UI/Components/Forms/Types/Field.ts +2 -0
- package/UI/Components/Forms/Types/FormFieldSchemaType.ts +1 -1
- package/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.ts +2 -2
- package/UI/Components/Icon/Icon.tsx +18 -5
- package/UI/Components/Radio/Radio.tsx +12 -10
- package/UI/Config.ts +3 -0
- package/build/dist/Models/DatabaseModels/Alert.js +31 -0
- package/build/dist/Models/DatabaseModels/Alert.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +8 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +31 -0
- package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js +481 -0
- package/build/dist/Models/DatabaseModels/WorkspaceNotificationRule.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js +390 -0
- package/build/dist/Models/DatabaseModels/WorkspaceProjectAuthToken.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceSetting.js +236 -0
- package/build/dist/Models/DatabaseModels/WorkspaceSetting.js.map +1 -0
- package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js +326 -0
- package/build/dist/Models/DatabaseModels/WorkspaceUserAuthToken.js.map +1 -0
- package/build/dist/Server/API/SlackAPI.js +237 -0
- package/build/dist/Server/API/SlackAPI.js.map +1 -0
- package/build/dist/Server/EnvironmentConfig.js +11 -2
- package/build/dist/Server/EnvironmentConfig.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js +58 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739209832500-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739210586538-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1739217257089-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/SlackAuthorization.js +28 -0
- package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -0
- package/build/dist/Server/Services/AlertService.js +31 -5
- package/build/dist/Server/Services/AlertService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +8 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +144 -15
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/ScheduledMaintenanceService.js +30 -3
- package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
- package/build/dist/Server/Services/UserService.js +4 -4
- package/build/dist/Server/Services/UserService.js.map +1 -1
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Slack.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/Teams.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js +2 -0
- package/build/dist/Server/Services/WorkspaceCommunicationTools/WorkspaceCommunicationBaseService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +14 -0
- package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js +63 -0
- package/build/dist/Server/Services/WorkspaceProjectAuthTokenService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceSettingService.js +59 -0
- package/build/dist/Server/Services/WorkspaceSettingService.js.map +1 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js +66 -0
- package/build/dist/Server/Services/WorkspaceUserAuthTokenService.js.map +1 -0
- package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js +1 -1
- package/build/dist/Server/Types/Workflow/Components/Slack/SendMessageToChannel.js.map +1 -1
- package/build/dist/Server/Utils/Express.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +2 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Slack/Slack.js +49 -0
- package/build/dist/Server/Utils/Slack/Slack.js.map +1 -0
- package/build/dist/Server/Utils/Slack/app-manifest.json +67 -0
- package/build/dist/Server/Utils/StartServer.js.map +1 -1
- package/build/dist/Types/Filter/FilterCondition.js +2 -2
- package/build/dist/Types/Filter/FilterCondition.js.map +1 -1
- package/build/dist/Types/Monitor/CriteriaFilter.js +19 -5
- package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js +33 -10
- package/build/dist/Types/Monitor/MonitorCriteriaInstance.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js +1 -1
- package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
- package/build/dist/Types/Permission.js +32 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/BaseNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js +9 -0
- package/build/dist/Types/Workspace/NotificationRules/EventType.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js +275 -0
- package/build/dist/Types/Workspace/NotificationRules/NotificationRuleCondition.js.map +1 -0
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js +2 -0
- package/build/dist/Types/Workspace/NotificationRules/SlackNotificationRule.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js +2 -0
- package/build/dist/Types/Workspace/WorkspaceNotificationPayload.js.map +1 -0
- package/build/dist/Types/Workspace/WorkspaceType.js +7 -0
- package/build/dist/Types/Workspace/WorkspaceType.js.map +1 -0
- package/build/dist/UI/Components/Forms/BasicForm.js +7 -0
- package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
- package/build/dist/UI/Components/Forms/Fields/FormField.js +21 -4
- package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js +1 -1
- package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js.map +1 -1
- package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js +2 -2
- package/build/dist/UI/Components/Forms/Utils/FormFieldSchemaTypeUtil.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +5 -1
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/Radio/Radio.js +4 -4
- package/build/dist/UI/Components/Radio/Radio.js.map +1 -1
- package/build/dist/UI/Config.js +1 -0
- package/build/dist/UI/Config.js.map +1 -1
- package/package.json +2 -2
- package/build/dist/Server/Utils/Slack.js +0 -20
- package/build/dist/Server/Utils/Slack.js.map +0 -1
|
@@ -61,6 +61,32 @@ export class Service extends DatabaseService<Model> {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
public async getExistingScheduledMaintenanceNumberForProject(data: {
|
|
65
|
+
projectId: ObjectID;
|
|
66
|
+
}): Promise<number> {
|
|
67
|
+
// get last scheduledMaintenance number.
|
|
68
|
+
const lastScheduledMaintenance: Model | null = await this.findOneBy({
|
|
69
|
+
query: {
|
|
70
|
+
projectId: data.projectId,
|
|
71
|
+
},
|
|
72
|
+
select: {
|
|
73
|
+
scheduledMaintenanceNumber: true,
|
|
74
|
+
},
|
|
75
|
+
sort: {
|
|
76
|
+
createdAt: SortOrder.Descending,
|
|
77
|
+
},
|
|
78
|
+
props: {
|
|
79
|
+
isRoot: true,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (!lastScheduledMaintenance) {
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return lastScheduledMaintenance.scheduledMaintenanceNumber || 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
64
90
|
public async notififySubscribersOnEventScheduled(
|
|
65
91
|
scheduledEvents: Array<Model>,
|
|
66
92
|
): Promise<void> {
|
|
@@ -395,10 +421,13 @@ export class Service extends DatabaseService<Model> {
|
|
|
395
421
|
);
|
|
396
422
|
}
|
|
397
423
|
|
|
424
|
+
const projectId: ObjectID =
|
|
425
|
+
createBy.props.tenantId || createBy.data.projectId!;
|
|
426
|
+
|
|
398
427
|
const scheduledMaintenanceState: ScheduledMaintenanceState | null =
|
|
399
428
|
await ScheduledMaintenanceStateService.findOneBy({
|
|
400
429
|
query: {
|
|
401
|
-
projectId:
|
|
430
|
+
projectId: projectId,
|
|
402
431
|
isScheduledState: true,
|
|
403
432
|
},
|
|
404
433
|
select: {
|
|
@@ -418,6 +447,14 @@ export class Service extends DatabaseService<Model> {
|
|
|
418
447
|
createBy.data.currentScheduledMaintenanceStateId =
|
|
419
448
|
scheduledMaintenanceState.id;
|
|
420
449
|
|
|
450
|
+
const scheduledMaintenanceNumberForThisScheduledMaintenance: number =
|
|
451
|
+
(await this.getExistingScheduledMaintenanceNumberForProject({
|
|
452
|
+
projectId: projectId,
|
|
453
|
+
})) + 1;
|
|
454
|
+
|
|
455
|
+
createBy.data.scheduledMaintenanceNumber =
|
|
456
|
+
scheduledMaintenanceNumberForThisScheduledMaintenance;
|
|
457
|
+
|
|
421
458
|
// get next notification date.
|
|
422
459
|
|
|
423
460
|
if (
|
|
@@ -455,7 +492,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
455
492
|
scheduledMaintenanceFeedEventType:
|
|
456
493
|
ScheduledMaintenanceFeedEventType.ScheduledMaintenanceCreated,
|
|
457
494
|
displayColor: Red500,
|
|
458
|
-
feedInfoInMarkdown: `**Scheduled Maintenance Created**:
|
|
495
|
+
feedInfoInMarkdown: `**Scheduled Maintenance #${createdItem.scheduledMaintenanceNumber?.toString()} Created**:
|
|
459
496
|
|
|
460
497
|
**Scheduled Maintenance Title**:
|
|
461
498
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import DatabaseConfig from "../DatabaseConfig";
|
|
2
2
|
import {
|
|
3
3
|
IsBillingEnabled,
|
|
4
|
-
|
|
4
|
+
NotificationSlackWebhookOnCreateUser,
|
|
5
5
|
} from "../EnvironmentConfig";
|
|
6
6
|
import { OnCreate, OnUpdate } from "../Types/Database/Hooks";
|
|
7
7
|
import UpdateBy from "../Types/Database/UpdateBy";
|
|
@@ -28,7 +28,7 @@ import Text from "../../Types/Text";
|
|
|
28
28
|
import EmailVerificationToken from "Common/Models/DatabaseModels/EmailVerificationToken";
|
|
29
29
|
import TeamMember from "Common/Models/DatabaseModels/TeamMember";
|
|
30
30
|
import Model from "Common/Models/DatabaseModels/User";
|
|
31
|
-
import SlackUtil from "../Utils/Slack";
|
|
31
|
+
import SlackUtil from "../Utils/Slack/Slack";
|
|
32
32
|
import UserTwoFactorAuth from "Common/Models/DatabaseModels/UserTwoFactorAuth";
|
|
33
33
|
import UserTwoFactorAuthService from "./UserTwoFactorAuthService";
|
|
34
34
|
import BadDataException from "../../Types/Exception/BadDataException";
|
|
@@ -42,9 +42,9 @@ export class Service extends DatabaseService<Model> {
|
|
|
42
42
|
_onCreate: OnCreate<Model>,
|
|
43
43
|
createdItem: Model,
|
|
44
44
|
): Promise<Model> {
|
|
45
|
-
if (
|
|
45
|
+
if (NotificationSlackWebhookOnCreateUser) {
|
|
46
46
|
SlackUtil.sendMessageToChannel({
|
|
47
|
-
url: URL.fromString(
|
|
47
|
+
url: URL.fromString(NotificationSlackWebhookOnCreateUser),
|
|
48
48
|
text: `*New OneUptime User:*
|
|
49
49
|
*Email:* ${createdItem.email?.toString() || "N/A"}
|
|
50
50
|
*Name:* ${createdItem.name?.toString() || "N/A"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import NotificationRuleEventType from "../../Types/Workspace/NotificationRules/EventType";
|
|
2
|
+
import { WorkspaceNotificationPayload } from "../../Types/Workspace/WorkspaceNotificationPayload";
|
|
3
|
+
import WorkspaceType from "../../Types/Workspace/WorkspaceType";
|
|
4
|
+
import logger from "../Utils/Logger";
|
|
5
|
+
import DatabaseService from "./DatabaseService";
|
|
6
|
+
import Model from "Common/Models/DatabaseModels/WorkspaceNotificationRule";
|
|
7
|
+
|
|
8
|
+
export class Service extends DatabaseService<Model> {
|
|
9
|
+
public constructor() {
|
|
10
|
+
super(Model);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async notifyWorkspace(data: {
|
|
14
|
+
workspaceType: WorkspaceType;
|
|
15
|
+
notificationRuleEventType: NotificationRuleEventType;
|
|
16
|
+
workspaceNotificationPayload: WorkspaceNotificationPayload;
|
|
17
|
+
}): Promise<void> {
|
|
18
|
+
logger.debug("Notify Workspace");
|
|
19
|
+
logger.debug(data);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export default new Service();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import ObjectID from "../../Types/ObjectID";
|
|
2
|
+
import WorkspaceType from "../../Types/Workspace/WorkspaceType";
|
|
3
|
+
import DatabaseService from "./DatabaseService";
|
|
4
|
+
import Model, {
|
|
5
|
+
SlackMiscData,
|
|
6
|
+
} from "Common/Models/DatabaseModels/WorkspaceProjectAuthToken";
|
|
7
|
+
|
|
8
|
+
export class Service extends DatabaseService<Model> {
|
|
9
|
+
public constructor() {
|
|
10
|
+
super(Model);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async doesExist(data: {
|
|
14
|
+
projectId: ObjectID;
|
|
15
|
+
workspaceType: WorkspaceType;
|
|
16
|
+
}): Promise<boolean> {
|
|
17
|
+
return (
|
|
18
|
+
(
|
|
19
|
+
await this.countBy({
|
|
20
|
+
query: {
|
|
21
|
+
projectId: data.projectId,
|
|
22
|
+
workspaceType: data.workspaceType,
|
|
23
|
+
},
|
|
24
|
+
skip: 0,
|
|
25
|
+
limit: 1,
|
|
26
|
+
props: {
|
|
27
|
+
isRoot: true,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
).toNumber() > 0
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async refreshAuthToken(data: {
|
|
35
|
+
projectId: ObjectID;
|
|
36
|
+
workspaceType: WorkspaceType;
|
|
37
|
+
authToken: string;
|
|
38
|
+
workspaceProjectId: string;
|
|
39
|
+
miscData: SlackMiscData;
|
|
40
|
+
}): Promise<void> {
|
|
41
|
+
let projectAuth: Model | null = await this.findOneBy({
|
|
42
|
+
query: {
|
|
43
|
+
projectId: data.projectId,
|
|
44
|
+
workspaceType: data.workspaceType,
|
|
45
|
+
},
|
|
46
|
+
select: {
|
|
47
|
+
_id: true,
|
|
48
|
+
},
|
|
49
|
+
props: {
|
|
50
|
+
isRoot: true,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if (!projectAuth) {
|
|
55
|
+
projectAuth = new Model();
|
|
56
|
+
|
|
57
|
+
projectAuth.projectId = data.projectId;
|
|
58
|
+
projectAuth.authToken = data.authToken;
|
|
59
|
+
projectAuth.workspaceType = data.workspaceType;
|
|
60
|
+
projectAuth.workspaceProjectId = data.workspaceProjectId;
|
|
61
|
+
projectAuth.miscData = data.miscData;
|
|
62
|
+
|
|
63
|
+
await this.create({
|
|
64
|
+
data: projectAuth,
|
|
65
|
+
props: {
|
|
66
|
+
isRoot: true,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
await this.updateOneById({
|
|
71
|
+
id: projectAuth.id!,
|
|
72
|
+
data: {
|
|
73
|
+
authToken: data.authToken,
|
|
74
|
+
workspaceProjectId: data.workspaceProjectId,
|
|
75
|
+
miscData: data.miscData,
|
|
76
|
+
},
|
|
77
|
+
props: {
|
|
78
|
+
isRoot: true,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export default new Service();
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import ObjectID from "../../Types/ObjectID";
|
|
2
|
+
import WorkspaceType from "../../Types/Workspace/WorkspaceType";
|
|
3
|
+
import DatabaseService from "./DatabaseService";
|
|
4
|
+
import Model, {
|
|
5
|
+
SlackSettings,
|
|
6
|
+
} from "Common/Models/DatabaseModels/WorkspaceSetting";
|
|
7
|
+
|
|
8
|
+
export class Service extends DatabaseService<Model> {
|
|
9
|
+
public constructor() {
|
|
10
|
+
super(Model);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async doesExist(data: {
|
|
14
|
+
projectId: ObjectID;
|
|
15
|
+
workspaceType: WorkspaceType;
|
|
16
|
+
}): Promise<boolean> {
|
|
17
|
+
return (
|
|
18
|
+
(
|
|
19
|
+
await this.countBy({
|
|
20
|
+
query: {
|
|
21
|
+
projectId: data.projectId,
|
|
22
|
+
workspaceType: data.workspaceType,
|
|
23
|
+
},
|
|
24
|
+
skip: 0,
|
|
25
|
+
limit: 1,
|
|
26
|
+
props: {
|
|
27
|
+
isRoot: true,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
).toNumber() > 0
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public async refreshSetting(data: {
|
|
35
|
+
projectId: ObjectID;
|
|
36
|
+
workspaceType: WorkspaceType;
|
|
37
|
+
settings: SlackSettings;
|
|
38
|
+
}): Promise<void> {
|
|
39
|
+
let workspaceSetting: Model | null = await this.findOneBy({
|
|
40
|
+
query: {
|
|
41
|
+
projectId: data.projectId,
|
|
42
|
+
workspaceType: data.workspaceType,
|
|
43
|
+
},
|
|
44
|
+
select: {
|
|
45
|
+
_id: true,
|
|
46
|
+
},
|
|
47
|
+
props: {
|
|
48
|
+
isRoot: true,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (!workspaceSetting) {
|
|
53
|
+
workspaceSetting = new Model();
|
|
54
|
+
|
|
55
|
+
workspaceSetting.projectId = data.projectId;
|
|
56
|
+
workspaceSetting.settings = data.settings;
|
|
57
|
+
workspaceSetting.workspaceType = data.workspaceType;
|
|
58
|
+
|
|
59
|
+
await this.create({
|
|
60
|
+
data: workspaceSetting,
|
|
61
|
+
props: {
|
|
62
|
+
isRoot: true,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
} else {
|
|
66
|
+
await this.updateOneById({
|
|
67
|
+
id: workspaceSetting.id!,
|
|
68
|
+
data: {
|
|
69
|
+
settings: data.settings,
|
|
70
|
+
},
|
|
71
|
+
props: {
|
|
72
|
+
isRoot: true,
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export default new Service();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import ObjectID from "../../Types/ObjectID";
|
|
2
|
+
import WorkspaceType from "../../Types/Workspace/WorkspaceType";
|
|
3
|
+
import DatabaseService from "./DatabaseService";
|
|
4
|
+
import Model, {
|
|
5
|
+
SlackMiscData,
|
|
6
|
+
} from "Common/Models/DatabaseModels/WorkspaceUserAuthToken";
|
|
7
|
+
|
|
8
|
+
export class Service extends DatabaseService<Model> {
|
|
9
|
+
public constructor() {
|
|
10
|
+
super(Model);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public async doesExist(data: {
|
|
14
|
+
projectId: ObjectID;
|
|
15
|
+
userId: ObjectID;
|
|
16
|
+
workspaceType: WorkspaceType;
|
|
17
|
+
}): Promise<boolean> {
|
|
18
|
+
return (
|
|
19
|
+
(
|
|
20
|
+
await this.countBy({
|
|
21
|
+
query: {
|
|
22
|
+
projectId: data.projectId,
|
|
23
|
+
userId: data.userId,
|
|
24
|
+
workspaceType: data.workspaceType,
|
|
25
|
+
},
|
|
26
|
+
skip: 0,
|
|
27
|
+
limit: 1,
|
|
28
|
+
props: {
|
|
29
|
+
isRoot: true,
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
).toNumber() > 0
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async refreshAuthToken(data: {
|
|
37
|
+
projectId: ObjectID;
|
|
38
|
+
userId: ObjectID;
|
|
39
|
+
workspaceType: WorkspaceType;
|
|
40
|
+
authToken: string;
|
|
41
|
+
workspaceUserId: string;
|
|
42
|
+
miscData: SlackMiscData;
|
|
43
|
+
}): Promise<void> {
|
|
44
|
+
let userAuth: Model | null = await this.findOneBy({
|
|
45
|
+
query: {
|
|
46
|
+
projectId: data.projectId,
|
|
47
|
+
userId: data.userId,
|
|
48
|
+
workspaceType: data.workspaceType,
|
|
49
|
+
},
|
|
50
|
+
select: {
|
|
51
|
+
_id: true,
|
|
52
|
+
},
|
|
53
|
+
props: {
|
|
54
|
+
isRoot: true,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
if (!userAuth) {
|
|
59
|
+
userAuth = new Model();
|
|
60
|
+
|
|
61
|
+
userAuth.projectId = data.projectId;
|
|
62
|
+
userAuth.userId = data.userId;
|
|
63
|
+
userAuth.authToken = data.authToken;
|
|
64
|
+
userAuth.workspaceType = data.workspaceType;
|
|
65
|
+
userAuth.workspaceUserId = data.workspaceUserId;
|
|
66
|
+
userAuth.miscData = data.miscData;
|
|
67
|
+
|
|
68
|
+
await this.create({
|
|
69
|
+
data: userAuth,
|
|
70
|
+
props: {
|
|
71
|
+
isRoot: true,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
} else {
|
|
75
|
+
await this.updateOneById({
|
|
76
|
+
id: userAuth.id!,
|
|
77
|
+
data: {
|
|
78
|
+
authToken: data.authToken,
|
|
79
|
+
workspaceUserId: data.workspaceUserId,
|
|
80
|
+
miscData: data.miscData,
|
|
81
|
+
},
|
|
82
|
+
props: {
|
|
83
|
+
isRoot: true,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export default new Service();
|
|
@@ -8,7 +8,7 @@ import { JSONObject } from "Common/Types/JSON";
|
|
|
8
8
|
import ComponentMetadata, { Port } from "Common/Types/Workflow/Component";
|
|
9
9
|
import ComponentID from "Common/Types/Workflow/ComponentID";
|
|
10
10
|
import SlackComponents from "Common/Types/Workflow/Components/Slack";
|
|
11
|
-
import SlackUtil from "../../../../Utils/Slack";
|
|
11
|
+
import SlackUtil from "../../../../Utils/Slack/Slack";
|
|
12
12
|
|
|
13
13
|
export default class SendMessageToChannel extends ComponentCode {
|
|
14
14
|
public constructor() {
|
package/Server/Utils/Express.ts
CHANGED
|
@@ -37,7 +37,8 @@ export interface OneUptimeRequest extends express.Request {
|
|
|
37
37
|
userAuthorization?: JSONWebTokenData;
|
|
38
38
|
tenantId?: ObjectID;
|
|
39
39
|
userGlobalAccessPermission?: UserGlobalAccessPermission;
|
|
40
|
-
userTenantAccessPermission?: Dictionary<UserTenantAccessPermission>; // tenantId <-> UserTenantAccessPermission
|
|
40
|
+
userTenantAccessPermission?: Dictionary<UserTenantAccessPermission>; // tenantId <-> UserTenantAccessPermission;
|
|
41
|
+
rawBody?: string; // raw body of the request before json parsing.
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export interface OneUptimeResponse extends express.Response {
|
|
@@ -16,11 +16,7 @@ import BadDataException from "Common/Types/Exception/BadDataException";
|
|
|
16
16
|
import BasicInfrastructureMetrics from "Common/Types/Infrastructure/BasicMetrics";
|
|
17
17
|
import ReturnResult from "Common/Types/IsolatedVM/ReturnResult";
|
|
18
18
|
import { JSONObject } from "Common/Types/JSON";
|
|
19
|
-
import {
|
|
20
|
-
CheckOn,
|
|
21
|
-
CriteriaFilter,
|
|
22
|
-
FilterCondition,
|
|
23
|
-
} from "Common/Types/Monitor/CriteriaFilter";
|
|
19
|
+
import { CheckOn, CriteriaFilter } from "Common/Types/Monitor/CriteriaFilter";
|
|
24
20
|
import IncomingMonitorRequest from "Common/Types/Monitor/IncomingMonitor/IncomingMonitorRequest";
|
|
25
21
|
import MonitorCriteria from "Common/Types/Monitor/MonitorCriteria";
|
|
26
22
|
import MonitorCriteriaInstance from "Common/Types/Monitor/MonitorCriteriaInstance";
|
|
@@ -57,6 +53,7 @@ import MonitorMetricType from "../../../Types/Monitor/MonitorMetricType";
|
|
|
57
53
|
import TelemetryUtil from "../Telemetry/Telemetry";
|
|
58
54
|
import MetricMonitorCriteria from "./Criteria/MetricMonitorCriteria";
|
|
59
55
|
import MetricMonitorResponse from "../../../Types/Monitor/MetricMonitor/MetricMonitorResponse";
|
|
56
|
+
import FilterCondition from "../../../Types/Filter/FilterCondition";
|
|
60
57
|
|
|
61
58
|
export default class MonitorResourceUtil {
|
|
62
59
|
public static async monitorResource(
|
|
@@ -5,6 +5,46 @@ import { JSONObject } from "Common/Types/JSON";
|
|
|
5
5
|
import API from "Common/Utils/API";
|
|
6
6
|
|
|
7
7
|
export default class SlackUtil {
|
|
8
|
+
public async getTextboxField(data: {
|
|
9
|
+
title: string;
|
|
10
|
+
placeholder: string;
|
|
11
|
+
actionId: string;
|
|
12
|
+
initialValue?: string;
|
|
13
|
+
}): Promise<JSONObject> {
|
|
14
|
+
return {
|
|
15
|
+
type: "input",
|
|
16
|
+
element: {
|
|
17
|
+
type: "plain_text_input",
|
|
18
|
+
action_id: data.actionId,
|
|
19
|
+
placeholder: {
|
|
20
|
+
type: "plain_text",
|
|
21
|
+
text: data.placeholder,
|
|
22
|
+
},
|
|
23
|
+
initial_value: data.initialValue,
|
|
24
|
+
},
|
|
25
|
+
label: {
|
|
26
|
+
type: "plain_text",
|
|
27
|
+
text: data.title,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public getButtonField(data: {
|
|
33
|
+
text: string;
|
|
34
|
+
actionId: string;
|
|
35
|
+
value: string;
|
|
36
|
+
}): JSONObject {
|
|
37
|
+
return {
|
|
38
|
+
type: "button",
|
|
39
|
+
text: {
|
|
40
|
+
type: "plain_text",
|
|
41
|
+
text: data.text,
|
|
42
|
+
},
|
|
43
|
+
action_id: data.actionId,
|
|
44
|
+
value: data.value,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
8
48
|
public static async sendMessageToChannel(data: {
|
|
9
49
|
url: URL;
|
|
10
50
|
text: string;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
{
|
|
2
|
+
"display_information": {
|
|
3
|
+
"name": "OneUptime",
|
|
4
|
+
"description": "The Complete Open-Source Observability Platform",
|
|
5
|
+
"background_color": "#000000",
|
|
6
|
+
"long_description": "OneUptime is a comprehensive solution for monitoring and managing your online services. Whether you need to check the availability of your website, dashboard, API, or any other online resource, OneUptime can alert your team when downtime happens and keep your customers informed with a status page. OneUptime also helps you handle incidents, set up on-call rotations, run tests, secure your services, analyze logs, track performance, and debug errors."
|
|
7
|
+
},
|
|
8
|
+
"features": {
|
|
9
|
+
"app_home": {
|
|
10
|
+
"home_tab_enabled": true,
|
|
11
|
+
"messages_tab_enabled": false,
|
|
12
|
+
"messages_tab_read_only_enabled": false
|
|
13
|
+
},
|
|
14
|
+
"bot_user": {
|
|
15
|
+
"display_name": "OneUptime",
|
|
16
|
+
"always_online": true
|
|
17
|
+
},
|
|
18
|
+
"shortcuts": [
|
|
19
|
+
{
|
|
20
|
+
"name": "Create Scheduled Event",
|
|
21
|
+
"type": "global",
|
|
22
|
+
"callback_id": "create-scheduled-maintenance",
|
|
23
|
+
"description": "Create a new scheduled event in OneUptime"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Create New Incident",
|
|
27
|
+
"type": "global",
|
|
28
|
+
"callback_id": "create-incident",
|
|
29
|
+
"description": "Creates a new incident in OneUptime"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"slash_commands": [
|
|
33
|
+
{
|
|
34
|
+
"command": "/oneuptime",
|
|
35
|
+
"url": "https://local.genosyn.com/api/slack/command",
|
|
36
|
+
"description": "OneUptime command",
|
|
37
|
+
"usage_hint": "incident, scheduled event.",
|
|
38
|
+
"should_escape": false
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"oauth_config": {
|
|
43
|
+
"redirect_urls": [
|
|
44
|
+
"https://local.genosyn.com/api/slack/auth"
|
|
45
|
+
],
|
|
46
|
+
"scopes": {
|
|
47
|
+
"user": [
|
|
48
|
+
"users:read",
|
|
49
|
+
"users:read.email",
|
|
50
|
+
"bookmarks:read",
|
|
51
|
+
"workflows.templates:write",
|
|
52
|
+
"workflows.templates:read",
|
|
53
|
+
"users:write",
|
|
54
|
+
"users.profile:write",
|
|
55
|
+
"users.profile:read",
|
|
56
|
+
"usergroups:write",
|
|
57
|
+
"usergroups:read",
|
|
58
|
+
"team:read",
|
|
59
|
+
"team.preferences:read",
|
|
60
|
+
"team.billing:read",
|
|
61
|
+
"stars:write",
|
|
62
|
+
"stars:read",
|
|
63
|
+
"search:read",
|
|
64
|
+
"remote_files:share",
|
|
65
|
+
"reminders:read",
|
|
66
|
+
"remote_files:read",
|
|
67
|
+
"reminders:write",
|
|
68
|
+
"reactions:write",
|
|
69
|
+
"reactions:read",
|
|
70
|
+
"profile",
|
|
71
|
+
"pins:write",
|
|
72
|
+
"pins:read",
|
|
73
|
+
"openid",
|
|
74
|
+
"mpim:write.topic",
|
|
75
|
+
"mpim:write",
|
|
76
|
+
"mpim:read",
|
|
77
|
+
"mpim:history",
|
|
78
|
+
"links:write",
|
|
79
|
+
"links:read",
|
|
80
|
+
"links.embed:write",
|
|
81
|
+
"im:write.topic",
|
|
82
|
+
"im:write",
|
|
83
|
+
"im:read",
|
|
84
|
+
"im:history",
|
|
85
|
+
"identity.team",
|
|
86
|
+
"identity.email",
|
|
87
|
+
"identity.basic",
|
|
88
|
+
"identity.avatar",
|
|
89
|
+
"identify",
|
|
90
|
+
"groups:write.topic",
|
|
91
|
+
"groups:write.invites",
|
|
92
|
+
"groups:write",
|
|
93
|
+
"groups:read",
|
|
94
|
+
"groups:history",
|
|
95
|
+
"files:write",
|
|
96
|
+
"files:read",
|
|
97
|
+
"emoji:read",
|
|
98
|
+
"email",
|
|
99
|
+
"dnd:write",
|
|
100
|
+
"dnd:read",
|
|
101
|
+
"chat:write",
|
|
102
|
+
"channels:write.topic",
|
|
103
|
+
"channels:write.invites",
|
|
104
|
+
"channels:write",
|
|
105
|
+
"channels:read",
|
|
106
|
+
"channels:history",
|
|
107
|
+
"canvases:write",
|
|
108
|
+
"canvases:read",
|
|
109
|
+
"calls:write",
|
|
110
|
+
"calls:read",
|
|
111
|
+
"bookmarks:write"
|
|
112
|
+
],
|
|
113
|
+
"bot": [
|
|
114
|
+
"app_mentions:read",
|
|
115
|
+
"assistant:write",
|
|
116
|
+
"bookmarks:read",
|
|
117
|
+
"bookmarks:write",
|
|
118
|
+
"calls:write",
|
|
119
|
+
"calls:read",
|
|
120
|
+
"canvases:read",
|
|
121
|
+
"canvases:write",
|
|
122
|
+
"channels:history",
|
|
123
|
+
"channels:join",
|
|
124
|
+
"channels:manage",
|
|
125
|
+
"channels:read",
|
|
126
|
+
"channels:write.invites",
|
|
127
|
+
"channels:write.topic",
|
|
128
|
+
"chat:write",
|
|
129
|
+
"chat:write.customize",
|
|
130
|
+
"chat:write.public",
|
|
131
|
+
"commands",
|
|
132
|
+
"conversations.connect:manage",
|
|
133
|
+
"conversations.connect:read",
|
|
134
|
+
"files:read",
|
|
135
|
+
"conversations.connect:write",
|
|
136
|
+
"dnd:read",
|
|
137
|
+
"emoji:read",
|
|
138
|
+
"files:write",
|
|
139
|
+
"groups:history",
|
|
140
|
+
"groups:read",
|
|
141
|
+
"groups:write",
|
|
142
|
+
"groups:write.invites",
|
|
143
|
+
"groups:write.topic",
|
|
144
|
+
"im:read",
|
|
145
|
+
"im:history",
|
|
146
|
+
"incoming-webhook",
|
|
147
|
+
"links.embed:write",
|
|
148
|
+
"im:write.topic",
|
|
149
|
+
"im:write",
|
|
150
|
+
"links:read",
|
|
151
|
+
"links:write",
|
|
152
|
+
"metadata.message:read",
|
|
153
|
+
"mpim:history",
|
|
154
|
+
"pins:read",
|
|
155
|
+
"users:read.email",
|
|
156
|
+
"users:read",
|
|
157
|
+
"mpim:read",
|
|
158
|
+
"mpim:write",
|
|
159
|
+
"mpim:write.topic",
|
|
160
|
+
"pins:write",
|
|
161
|
+
"reactions:write",
|
|
162
|
+
"reactions:read",
|
|
163
|
+
"reminders:read",
|
|
164
|
+
"search:read.files",
|
|
165
|
+
"remote_files:write",
|
|
166
|
+
"remote_files:share",
|
|
167
|
+
"reminders:write",
|
|
168
|
+
"remote_files:read",
|
|
169
|
+
"search:read.im",
|
|
170
|
+
"team.billing:read",
|
|
171
|
+
"team.preferences:read",
|
|
172
|
+
"search:read.mpim",
|
|
173
|
+
"search:read.private",
|
|
174
|
+
"search:read.public",
|
|
175
|
+
"usergroups:read",
|
|
176
|
+
"usergroups:write",
|
|
177
|
+
"triggers:write",
|
|
178
|
+
"team:read",
|
|
179
|
+
"triggers:read",
|
|
180
|
+
"users.profile:read",
|
|
181
|
+
"users:write",
|
|
182
|
+
"workflows.templates:read",
|
|
183
|
+
"workflow.steps:execute",
|
|
184
|
+
"workflows.templates:write"
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"settings": {
|
|
189
|
+
"interactivity": {
|
|
190
|
+
"is_enabled": true,
|
|
191
|
+
"request_url": "https://local.genosyn.com/api/slack/interactive",
|
|
192
|
+
"message_menu_options_url": "https://local.genosyn.com/api/slack/options-load"
|
|
193
|
+
},
|
|
194
|
+
"org_deploy_enabled": true,
|
|
195
|
+
"socket_mode_enabled": false,
|
|
196
|
+
"token_rotation_enabled": false
|
|
197
|
+
}
|
|
198
|
+
}
|