@oneuptime/common 10.2.2 → 10.2.3

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 (54) hide show
  1. package/Models/DatabaseModels/Index.ts +4 -0
  2. package/Models/DatabaseModels/UserNotificationRule.ts +49 -0
  3. package/Models/DatabaseModels/UserNotificationSetting.ts +17 -0
  4. package/Models/DatabaseModels/UserOnCallLogTimeline.ts +48 -0
  5. package/Models/DatabaseModels/UserWebhook.ts +290 -0
  6. package/Models/DatabaseModels/WebhookLog.ts +992 -0
  7. package/Server/API/UserWebhookAPI.ts +159 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/1778506655291-AddProjectOIDC.ts +1 -1
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.ts +259 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  11. package/Server/Services/UserNotificationRuleService.ts +213 -1
  12. package/Server/Services/UserNotificationSettingService.ts +95 -0
  13. package/Server/Services/UserWebhookService.ts +208 -0
  14. package/Server/Services/WebhookLogService.ts +15 -0
  15. package/Server/Services/WebhookService.ts +126 -0
  16. package/Types/Permission.ts +12 -0
  17. package/Types/Webhook/WebhookMessage.ts +8 -0
  18. package/Types/WebhookStatus.ts +6 -0
  19. package/build/dist/Models/DatabaseModels/Index.js +4 -0
  20. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  21. package/build/dist/Models/DatabaseModels/UserNotificationRule.js +49 -0
  22. package/build/dist/Models/DatabaseModels/UserNotificationRule.js.map +1 -1
  23. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js +19 -0
  24. package/build/dist/Models/DatabaseModels/UserNotificationSetting.js.map +1 -1
  25. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js +48 -0
  26. package/build/dist/Models/DatabaseModels/UserOnCallLogTimeline.js.map +1 -1
  27. package/build/dist/Models/DatabaseModels/UserWebhook.js +307 -0
  28. package/build/dist/Models/DatabaseModels/UserWebhook.js.map +1 -0
  29. package/build/dist/Models/DatabaseModels/WebhookLog.js +1021 -0
  30. package/build/dist/Models/DatabaseModels/WebhookLog.js.map +1 -0
  31. package/build/dist/Server/API/UserWebhookAPI.js +99 -0
  32. package/build/dist/Server/API/UserWebhookAPI.js.map +1 -0
  33. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778506655291-AddProjectOIDC.js.map +1 -1
  34. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.js +94 -0
  35. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1778514515756-MigrationName.js.map +1 -0
  36. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  37. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  38. package/build/dist/Server/Services/UserNotificationRuleService.js +178 -21
  39. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  40. package/build/dist/Server/Services/UserNotificationSettingService.js +84 -1
  41. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  42. package/build/dist/Server/Services/UserWebhookService.js +190 -0
  43. package/build/dist/Server/Services/UserWebhookService.js.map +1 -0
  44. package/build/dist/Server/Services/WebhookLogService.js +13 -0
  45. package/build/dist/Server/Services/WebhookLogService.js.map +1 -0
  46. package/build/dist/Server/Services/WebhookService.js +92 -0
  47. package/build/dist/Server/Services/WebhookService.js.map +1 -0
  48. package/build/dist/Types/Permission.js +10 -0
  49. package/build/dist/Types/Permission.js.map +1 -1
  50. package/build/dist/Types/Webhook/WebhookMessage.js +2 -0
  51. package/build/dist/Types/Webhook/WebhookMessage.js.map +1 -0
  52. package/build/dist/Types/WebhookStatus.js +7 -0
  53. package/build/dist/Types/WebhookStatus.js.map +1 -0
  54. package/package.json +1 -1
@@ -148,6 +148,7 @@ import ShortLink from "./ShortLink";
148
148
  import SmsLog from "./SmsLog";
149
149
  import WhatsAppLog from "./WhatsAppLog";
150
150
  import TelegramLog from "./TelegramLog";
151
+ import WebhookLog from "./WebhookLog";
151
152
  import PushNotificationLog from "./PushNotificationLog";
152
153
  import WorkspaceNotificationLog from "./WorkspaceNotificationLog";
153
154
  // Status Page
@@ -185,6 +186,7 @@ import UserEmail from "./UserEmail";
185
186
  import UserPush from "./UserPush";
186
187
  import UserWhatsApp from "./UserWhatsApp";
187
188
  import UserTelegram from "./UserTelegram";
189
+ import UserWebhook from "./UserWebhook";
188
190
  // User Notification Rules
189
191
  import UserNotificationRule from "./UserNotificationRule";
190
192
  import UserNotificationSetting from "./UserNotificationSetting";
@@ -458,6 +460,7 @@ const AllModelTypes: Array<{
458
460
  SmsLog,
459
461
  WhatsAppLog,
460
462
  TelegramLog,
463
+ WebhookLog,
461
464
  PushNotificationLog,
462
465
  WorkspaceNotificationLog,
463
466
  CallLog,
@@ -469,6 +472,7 @@ const AllModelTypes: Array<{
469
472
  UserPush,
470
473
  UserWhatsApp,
471
474
  UserTelegram,
475
+ UserWebhook,
472
476
  UserIncomingCallNumber,
473
477
 
474
478
  UserNotificationRule,
@@ -7,6 +7,7 @@ import UserEmail from "./UserEmail";
7
7
  import UserPush from "./UserPush";
8
8
  import UserSMS from "./UserSMS";
9
9
  import UserTelegram from "./UserTelegram";
10
+ import UserWebhook from "./UserWebhook";
10
11
  import UserWhatsApp from "./UserWhatsApp";
11
12
  import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
12
13
  import Route from "../../Types/API/Route";
@@ -489,6 +490,54 @@ class UserNotificationRule extends BaseModel {
489
490
  })
490
491
  public userTelegramId?: ObjectID = undefined;
491
492
 
493
+ @ColumnAccessControl({
494
+ create: [Permission.CurrentUser],
495
+ read: [Permission.CurrentUser],
496
+ update: [],
497
+ })
498
+ @TableColumn({
499
+ manyToOneRelationColumn: "userWebhookId",
500
+ type: TableColumnType.Entity,
501
+ modelType: UserWebhook,
502
+ title: "User Webhook",
503
+ description:
504
+ "Relation to User Webhook Resource in which this object belongs",
505
+ })
506
+ @ManyToOne(
507
+ () => {
508
+ return UserWebhook;
509
+ },
510
+ {
511
+ eager: false,
512
+ nullable: true,
513
+ onDelete: "CASCADE",
514
+ orphanedRowAction: "nullify",
515
+ },
516
+ )
517
+ @JoinColumn({ name: "userWebhookId" })
518
+ public userWebhook?: UserWebhook = undefined;
519
+
520
+ @ColumnAccessControl({
521
+ create: [Permission.CurrentUser],
522
+ read: [Permission.CurrentUser],
523
+ update: [],
524
+ })
525
+ @Index()
526
+ @TableColumn({
527
+ type: TableColumnType.ObjectID,
528
+ required: false,
529
+ canReadOnRelationQuery: true,
530
+ title: "User Webhook ID",
531
+ description: "ID of User Webhook in which this object belongs",
532
+ example: "9e8d7c6b-5a4f-3e2d-1c0b-9a8f7e6d5c4b",
533
+ })
534
+ @Column({
535
+ type: ColumnType.ObjectID,
536
+ nullable: true,
537
+ transformer: ObjectID.getDatabaseTransformer(),
538
+ })
539
+ public userWebhookId?: ObjectID = undefined;
540
+
492
541
  @ColumnAccessControl({
493
542
  create: [Permission.CurrentUser],
494
543
  read: [Permission.CurrentUser],
@@ -347,6 +347,23 @@ class UserNotificationSetting extends BaseModel {
347
347
  default: false,
348
348
  })
349
349
  public alertByPush?: boolean = undefined;
350
+
351
+ @ColumnAccessControl({
352
+ create: [Permission.CurrentUser],
353
+ read: [Permission.CurrentUser],
354
+ update: [Permission.CurrentUser],
355
+ })
356
+ @TableColumn({
357
+ isDefaultValueColumn: true,
358
+ type: TableColumnType.Boolean,
359
+ defaultValue: false,
360
+ example: false,
361
+ })
362
+ @Column({
363
+ type: ColumnType.Boolean,
364
+ default: false,
365
+ })
366
+ public alertByWebhook?: boolean = undefined;
350
367
  }
351
368
 
352
369
  export default UserNotificationSetting;
@@ -16,6 +16,7 @@ import UserPush from "./UserPush";
16
16
  import UserOnCallLog from "./UserOnCallLog";
17
17
  import UserSMS from "./UserSMS";
18
18
  import UserTelegram from "./UserTelegram";
19
+ import UserWebhook from "./UserWebhook";
19
20
  import UserWhatsApp from "./UserWhatsApp";
20
21
  import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
21
22
  import Route from "../../Types/API/Route";
@@ -1028,6 +1029,53 @@ export default class UserOnCallLogTimeline extends BaseModel {
1028
1029
  })
1029
1030
  public userTelegramId?: ObjectID = undefined;
1030
1031
 
1032
+ @ColumnAccessControl({
1033
+ create: [],
1034
+ read: [Permission.CurrentUser],
1035
+ update: [],
1036
+ })
1037
+ @TableColumn({
1038
+ manyToOneRelationColumn: "userWebhookId",
1039
+ type: TableColumnType.Entity,
1040
+ modelType: UserWebhook,
1041
+ title: "User Webhook",
1042
+ description:
1043
+ "Relation to User Webhook Resource in which this object belongs",
1044
+ })
1045
+ @ManyToOne(
1046
+ () => {
1047
+ return UserWebhook;
1048
+ },
1049
+ {
1050
+ eager: false,
1051
+ nullable: true,
1052
+ onDelete: "CASCADE",
1053
+ orphanedRowAction: "nullify",
1054
+ },
1055
+ )
1056
+ @JoinColumn({ name: "userWebhookId" })
1057
+ public userWebhook?: UserWebhook = undefined;
1058
+
1059
+ @ColumnAccessControl({
1060
+ create: [],
1061
+ read: [Permission.CurrentUser],
1062
+ update: [],
1063
+ })
1064
+ @Index()
1065
+ @TableColumn({
1066
+ type: TableColumnType.ObjectID,
1067
+ required: false,
1068
+ canReadOnRelationQuery: true,
1069
+ title: "User Webhook ID",
1070
+ description: "ID of User Webhook in which this object belongs",
1071
+ })
1072
+ @Column({
1073
+ type: ColumnType.ObjectID,
1074
+ nullable: true,
1075
+ transformer: ObjectID.getDatabaseTransformer(),
1076
+ })
1077
+ public userWebhookId?: ObjectID = undefined;
1078
+
1031
1079
  @ColumnAccessControl({
1032
1080
  create: [],
1033
1081
  read: [Permission.CurrentUser],
@@ -0,0 +1,290 @@
1
+ import Project from "./Project";
2
+ import User from "./User";
3
+ import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
4
+ import Route from "../../Types/API/Route";
5
+ import AllowAccessIfSubscriptionIsUnpaid from "../../Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid";
6
+ import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
7
+ import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
8
+ import ColumnLength from "../../Types/Database/ColumnLength";
9
+ import ColumnType from "../../Types/Database/ColumnType";
10
+ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
11
+ import CurrentUserCanAccessRecordBy from "../../Types/Database/CurrentUserCanAccessRecordBy";
12
+ import TableColumn from "../../Types/Database/TableColumn";
13
+ import TableColumnType from "../../Types/Database/TableColumnType";
14
+ import TableMetadata from "../../Types/Database/TableMetadata";
15
+ import TenantColumn from "../../Types/Database/TenantColumn";
16
+ import IconProp from "../../Types/Icon/IconProp";
17
+ import ObjectID from "../../Types/ObjectID";
18
+ import Permission from "../../Types/Permission";
19
+ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
20
+
21
+ @TenantColumn("projectId")
22
+ @AllowAccessIfSubscriptionIsUnpaid()
23
+ @TableAccessControl({
24
+ create: [Permission.CurrentUser],
25
+ read: [Permission.CurrentUser],
26
+ delete: [Permission.CurrentUser],
27
+ update: [Permission.CurrentUser],
28
+ })
29
+ @CrudApiEndpoint(new Route("/user-webhook"))
30
+ @Entity({
31
+ name: "UserWebhook",
32
+ })
33
+ @TableMetadata({
34
+ tableName: "UserWebhook",
35
+ singularName: "Webhook",
36
+ pluralName: "Webhooks",
37
+ icon: IconProp.Webhook,
38
+ tableDescription:
39
+ "Webhook URLs used for outbound HTTP notifications to your own services.",
40
+ })
41
+ @CurrentUserCanAccessRecordBy("userId")
42
+ class UserWebhook extends BaseModel {
43
+ @ColumnAccessControl({
44
+ create: [Permission.CurrentUser],
45
+ read: [Permission.CurrentUser],
46
+ update: [],
47
+ })
48
+ @TableColumn({
49
+ manyToOneRelationColumn: "projectId",
50
+ type: TableColumnType.Entity,
51
+ modelType: Project,
52
+ title: "Project",
53
+ description: "Relation to Project Resource in which this object belongs",
54
+ })
55
+ @ManyToOne(
56
+ () => {
57
+ return Project;
58
+ },
59
+ {
60
+ eager: false,
61
+ nullable: true,
62
+ onDelete: "CASCADE",
63
+ orphanedRowAction: "nullify",
64
+ },
65
+ )
66
+ @JoinColumn({ name: "projectId" })
67
+ public project?: Project = undefined;
68
+
69
+ @ColumnAccessControl({
70
+ create: [Permission.CurrentUser],
71
+ read: [Permission.CurrentUser],
72
+ update: [],
73
+ })
74
+ @Index()
75
+ @TableColumn({
76
+ type: TableColumnType.ObjectID,
77
+ required: true,
78
+ canReadOnRelationQuery: true,
79
+ title: "Project ID",
80
+ description: "ID of your OneUptime Project in which this object belongs",
81
+ })
82
+ @Column({
83
+ type: ColumnType.ObjectID,
84
+ nullable: false,
85
+ transformer: ObjectID.getDatabaseTransformer(),
86
+ })
87
+ public projectId?: ObjectID = undefined;
88
+
89
+ @ColumnAccessControl({
90
+ create: [Permission.CurrentUser],
91
+ read: [Permission.CurrentUser],
92
+ update: [Permission.CurrentUser],
93
+ })
94
+ @TableColumn({
95
+ title: "Name",
96
+ required: true,
97
+ unique: false,
98
+ type: TableColumnType.ShortText,
99
+ canReadOnRelationQuery: true,
100
+ description: "Label for this webhook (e.g. 'My Slack', 'Internal alerts').",
101
+ })
102
+ @Column({
103
+ type: ColumnType.ShortText,
104
+ length: ColumnLength.ShortText,
105
+ unique: false,
106
+ nullable: false,
107
+ })
108
+ public name?: string = undefined;
109
+
110
+ @ColumnAccessControl({
111
+ create: [Permission.CurrentUser],
112
+ read: [Permission.CurrentUser],
113
+ update: [Permission.CurrentUser],
114
+ })
115
+ @TableColumn({
116
+ title: "Webhook URL",
117
+ required: true,
118
+ unique: false,
119
+ type: TableColumnType.LongText,
120
+ canReadOnRelationQuery: true,
121
+ description:
122
+ "HTTPS endpoint that will receive POST requests with notification payloads.",
123
+ })
124
+ @Column({
125
+ type: ColumnType.LongText,
126
+ length: ColumnLength.LongText,
127
+ unique: false,
128
+ nullable: false,
129
+ })
130
+ public webhookUrl?: string = undefined;
131
+
132
+ @ColumnAccessControl({
133
+ create: [Permission.CurrentUser],
134
+ read: [Permission.CurrentUser],
135
+ update: [Permission.CurrentUser],
136
+ })
137
+ @TableColumn({
138
+ title: "Signing Secret",
139
+ required: false,
140
+ unique: false,
141
+ type: TableColumnType.ShortText,
142
+ canReadOnRelationQuery: false,
143
+ description:
144
+ "Optional shared secret used to compute an HMAC-SHA256 signature for each request (sent in X-OneUptime-Signature).",
145
+ })
146
+ @Column({
147
+ type: ColumnType.ShortText,
148
+ length: ColumnLength.ShortText,
149
+ unique: false,
150
+ nullable: true,
151
+ })
152
+ public secret?: string = undefined;
153
+
154
+ @ColumnAccessControl({
155
+ create: [Permission.CurrentUser],
156
+ read: [Permission.CurrentUser],
157
+ update: [],
158
+ })
159
+ @TableColumn({
160
+ manyToOneRelationColumn: "user",
161
+ type: TableColumnType.Entity,
162
+ modelType: User,
163
+ title: "User",
164
+ description: "Relation to User who this Webhook belongs to",
165
+ })
166
+ @ManyToOne(
167
+ () => {
168
+ return User;
169
+ },
170
+ {
171
+ eager: false,
172
+ nullable: true,
173
+ onDelete: "CASCADE",
174
+ orphanedRowAction: "nullify",
175
+ },
176
+ )
177
+ @JoinColumn({ name: "userId" })
178
+ public user?: User = undefined;
179
+
180
+ @ColumnAccessControl({
181
+ create: [Permission.CurrentUser],
182
+ read: [Permission.CurrentUser],
183
+ update: [],
184
+ })
185
+ @TableColumn({
186
+ type: TableColumnType.ObjectID,
187
+ title: "User ID",
188
+ description: "User ID who this Webhook belongs to",
189
+ })
190
+ @Column({
191
+ type: ColumnType.ObjectID,
192
+ nullable: true,
193
+ transformer: ObjectID.getDatabaseTransformer(),
194
+ })
195
+ @Index()
196
+ public userId?: ObjectID = undefined;
197
+
198
+ @ColumnAccessControl({
199
+ create: [Permission.CurrentUser],
200
+ read: [Permission.CurrentUser],
201
+ update: [],
202
+ })
203
+ @TableColumn({
204
+ manyToOneRelationColumn: "createdByUserId",
205
+ type: TableColumnType.Entity,
206
+ modelType: User,
207
+ title: "Created by User",
208
+ description:
209
+ "Relation to User who created this object (if this object was created by a User)",
210
+ })
211
+ @ManyToOne(
212
+ () => {
213
+ return User;
214
+ },
215
+ {
216
+ eager: false,
217
+ nullable: true,
218
+ onDelete: "SET NULL",
219
+ orphanedRowAction: "nullify",
220
+ },
221
+ )
222
+ @JoinColumn({ name: "createdByUserId" })
223
+ public createdByUser?: User = undefined;
224
+
225
+ @ColumnAccessControl({
226
+ create: [Permission.CurrentUser],
227
+ read: [Permission.CurrentUser],
228
+ update: [],
229
+ })
230
+ @TableColumn({
231
+ type: TableColumnType.ObjectID,
232
+ title: "Created by User ID",
233
+ description:
234
+ "User ID who created this object (if this object was created by a User)",
235
+ })
236
+ @Column({
237
+ type: ColumnType.ObjectID,
238
+ nullable: true,
239
+ transformer: ObjectID.getDatabaseTransformer(),
240
+ })
241
+ public createdByUserId?: ObjectID = undefined;
242
+
243
+ @ColumnAccessControl({
244
+ create: [],
245
+ read: [],
246
+ update: [],
247
+ })
248
+ @TableColumn({
249
+ manyToOneRelationColumn: "deletedByUserId",
250
+ type: TableColumnType.Entity,
251
+ title: "Deleted by User",
252
+ modelType: User,
253
+ description:
254
+ "Relation to User who deleted this object (if this object was deleted by a User)",
255
+ })
256
+ @ManyToOne(
257
+ () => {
258
+ return User;
259
+ },
260
+ {
261
+ cascade: false,
262
+ eager: false,
263
+ nullable: true,
264
+ onDelete: "SET NULL",
265
+ orphanedRowAction: "nullify",
266
+ },
267
+ )
268
+ @JoinColumn({ name: "deletedByUserId" })
269
+ public deletedByUser?: User = undefined;
270
+
271
+ @ColumnAccessControl({
272
+ create: [],
273
+ read: [],
274
+ update: [],
275
+ })
276
+ @TableColumn({
277
+ type: TableColumnType.ObjectID,
278
+ title: "Deleted by User ID",
279
+ description:
280
+ "User ID who deleted this object (if this object was deleted by a User)",
281
+ })
282
+ @Column({
283
+ type: ColumnType.ObjectID,
284
+ nullable: true,
285
+ transformer: ObjectID.getDatabaseTransformer(),
286
+ })
287
+ public deletedByUserId?: ObjectID = undefined;
288
+ }
289
+
290
+ export default UserWebhook;