@oneuptime/common 7.0.3699 → 7.0.3705

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.
@@ -35,7 +35,12 @@ import Alert from "./Alert";
35
35
  @EnableDocumentation()
36
36
  @TenantColumn("projectId")
37
37
  @TableAccessControl({
38
- create: [],
38
+ create: [
39
+ Permission.ProjectOwner,
40
+ Permission.ProjectAdmin,
41
+ Permission.ProjectMember,
42
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
43
+ ],
39
44
  read: [
40
45
  Permission.ProjectOwner,
41
46
  Permission.ProjectAdmin,
@@ -58,7 +63,12 @@ import Alert from "./Alert";
58
63
  })
59
64
  export default class OnCallDutyPolicyExecutionLog extends BaseModel {
60
65
  @ColumnAccessControl({
61
- create: [],
66
+ create: [
67
+ Permission.ProjectOwner,
68
+ Permission.ProjectAdmin,
69
+ Permission.ProjectMember,
70
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
71
+ ],
62
72
  read: [
63
73
  Permission.ProjectOwner,
64
74
  Permission.ProjectAdmin,
@@ -89,7 +99,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
89
99
  public project?: Project = undefined;
90
100
 
91
101
  @ColumnAccessControl({
92
- create: [],
102
+ create: [
103
+ Permission.ProjectOwner,
104
+ Permission.ProjectAdmin,
105
+ Permission.ProjectMember,
106
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
107
+ ],
93
108
  read: [
94
109
  Permission.ProjectOwner,
95
110
  Permission.ProjectAdmin,
@@ -114,7 +129,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
114
129
  public projectId?: ObjectID = undefined;
115
130
 
116
131
  @ColumnAccessControl({
117
- create: [],
132
+ create: [
133
+ Permission.ProjectOwner,
134
+ Permission.ProjectAdmin,
135
+ Permission.ProjectMember,
136
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
137
+ ],
118
138
  read: [
119
139
  Permission.ProjectOwner,
120
140
  Permission.ProjectAdmin,
@@ -146,7 +166,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
146
166
  public onCallDutyPolicy?: OnCallDutyPolicy = undefined;
147
167
 
148
168
  @ColumnAccessControl({
149
- create: [],
169
+ create: [
170
+ Permission.ProjectOwner,
171
+ Permission.ProjectAdmin,
172
+ Permission.ProjectMember,
173
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
174
+ ],
150
175
  read: [
151
176
  Permission.ProjectOwner,
152
177
  Permission.ProjectAdmin,
@@ -172,7 +197,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
172
197
  public onCallDutyPolicyId?: ObjectID = undefined;
173
198
 
174
199
  @ColumnAccessControl({
175
- create: [],
200
+ create: [
201
+ Permission.ProjectOwner,
202
+ Permission.ProjectAdmin,
203
+ Permission.ProjectMember,
204
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
205
+ ],
176
206
  read: [
177
207
  Permission.ProjectOwner,
178
208
  Permission.ProjectAdmin,
@@ -204,7 +234,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
204
234
  public triggeredByIncident?: Incident = undefined;
205
235
 
206
236
  @ColumnAccessControl({
207
- create: [],
237
+ create: [
238
+ Permission.ProjectOwner,
239
+ Permission.ProjectAdmin,
240
+ Permission.ProjectMember,
241
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
242
+ ],
208
243
  read: [
209
244
  Permission.ProjectOwner,
210
245
  Permission.ProjectAdmin,
@@ -228,7 +263,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
228
263
  public triggeredByIncidentId?: ObjectID = undefined;
229
264
 
230
265
  @ColumnAccessControl({
231
- create: [],
266
+ create: [
267
+ Permission.ProjectOwner,
268
+ Permission.ProjectAdmin,
269
+ Permission.ProjectMember,
270
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
271
+ ],
232
272
  read: [
233
273
  Permission.ProjectOwner,
234
274
  Permission.ProjectAdmin,
@@ -259,7 +299,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
259
299
  public triggeredByAlert?: Alert = undefined;
260
300
 
261
301
  @ColumnAccessControl({
262
- create: [],
302
+ create: [
303
+ Permission.ProjectOwner,
304
+ Permission.ProjectAdmin,
305
+ Permission.ProjectMember,
306
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
307
+ ],
263
308
  read: [
264
309
  Permission.ProjectOwner,
265
310
  Permission.ProjectAdmin,
@@ -283,7 +328,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
283
328
  public triggeredByAlertId?: ObjectID = undefined;
284
329
 
285
330
  @ColumnAccessControl({
286
- create: [],
331
+ create: [
332
+ Permission.ProjectOwner,
333
+ Permission.ProjectAdmin,
334
+ Permission.ProjectMember,
335
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
336
+ ],
287
337
  read: [
288
338
  Permission.ProjectOwner,
289
339
  Permission.ProjectAdmin,
@@ -307,7 +357,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
307
357
  public status?: OnCallDutyPolicyStatus = undefined;
308
358
 
309
359
  @ColumnAccessControl({
310
- create: [],
360
+ create: [
361
+ Permission.ProjectOwner,
362
+ Permission.ProjectAdmin,
363
+ Permission.ProjectMember,
364
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
365
+ ],
311
366
  read: [
312
367
  Permission.ProjectOwner,
313
368
  Permission.ProjectAdmin,
@@ -331,7 +386,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
331
386
  public statusMessage?: string = undefined;
332
387
 
333
388
  @ColumnAccessControl({
334
- create: [],
389
+ create: [
390
+ Permission.ProjectOwner,
391
+ Permission.ProjectAdmin,
392
+ Permission.ProjectMember,
393
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
394
+ ],
335
395
  read: [
336
396
  Permission.ProjectOwner,
337
397
  Permission.ProjectAdmin,
@@ -355,7 +415,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
355
415
  public userNotificationEventType?: UserNotificationEventType = undefined;
356
416
 
357
417
  @ColumnAccessControl({
358
- create: [],
418
+ create: [
419
+ Permission.ProjectOwner,
420
+ Permission.ProjectAdmin,
421
+ Permission.ProjectMember,
422
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
423
+ ],
359
424
  read: [
360
425
  Permission.ProjectOwner,
361
426
  Permission.ProjectAdmin,
@@ -387,7 +452,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
387
452
  public createdByUser?: User = undefined;
388
453
 
389
454
  @ColumnAccessControl({
390
- create: [],
455
+ create: [
456
+ Permission.ProjectOwner,
457
+ Permission.ProjectAdmin,
458
+ Permission.ProjectMember,
459
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
460
+ ],
391
461
  read: [
392
462
  Permission.ProjectOwner,
393
463
  Permission.ProjectAdmin,
@@ -410,7 +480,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
410
480
  public createdByUserId?: ObjectID = undefined;
411
481
 
412
482
  @ColumnAccessControl({
413
- create: [],
483
+ create: [
484
+ Permission.ProjectOwner,
485
+ Permission.ProjectAdmin,
486
+ Permission.ProjectMember,
487
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
488
+ ],
414
489
  read: [],
415
490
  update: [],
416
491
  })
@@ -437,7 +512,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
437
512
  public deletedByUser?: User = undefined;
438
513
 
439
514
  @ColumnAccessControl({
440
- create: [],
515
+ create: [
516
+ Permission.ProjectOwner,
517
+ Permission.ProjectAdmin,
518
+ Permission.ProjectMember,
519
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
520
+ ],
441
521
  read: [
442
522
  Permission.ProjectOwner,
443
523
  Permission.ProjectAdmin,
@@ -460,7 +540,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
460
540
  public deletedByUserId?: ObjectID = undefined;
461
541
 
462
542
  @ColumnAccessControl({
463
- create: [],
543
+ create: [
544
+ Permission.ProjectOwner,
545
+ Permission.ProjectAdmin,
546
+ Permission.ProjectMember,
547
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
548
+ ],
464
549
  read: [
465
550
  Permission.ProjectOwner,
466
551
  Permission.ProjectAdmin,
@@ -493,7 +578,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
493
578
  public acknowledgedByUser?: User = undefined;
494
579
 
495
580
  @ColumnAccessControl({
496
- create: [],
581
+ create: [
582
+ Permission.ProjectOwner,
583
+ Permission.ProjectAdmin,
584
+ Permission.ProjectMember,
585
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
586
+ ],
497
587
  read: [
498
588
  Permission.ProjectOwner,
499
589
  Permission.ProjectAdmin,
@@ -516,7 +606,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
516
606
  public acknowledgedByUserId?: ObjectID = undefined;
517
607
 
518
608
  @ColumnAccessControl({
519
- create: [],
609
+ create: [
610
+ Permission.ProjectOwner,
611
+ Permission.ProjectAdmin,
612
+ Permission.ProjectMember,
613
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
614
+ ],
520
615
  read: [
521
616
  Permission.ProjectOwner,
522
617
  Permission.ProjectAdmin,
@@ -535,7 +630,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
535
630
  public acknowledgedAt?: Date = undefined;
536
631
 
537
632
  @ColumnAccessControl({
538
- create: [],
633
+ create: [
634
+ Permission.ProjectOwner,
635
+ Permission.ProjectAdmin,
636
+ Permission.ProjectMember,
637
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
638
+ ],
539
639
  read: [],
540
640
  update: [],
541
641
  })
@@ -562,7 +662,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
562
662
  public acknowledgedByTeam?: Team = undefined;
563
663
 
564
664
  @ColumnAccessControl({
565
- create: [],
665
+ create: [
666
+ Permission.ProjectOwner,
667
+ Permission.ProjectAdmin,
668
+ Permission.ProjectMember,
669
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
670
+ ],
566
671
  read: [
567
672
  Permission.ProjectOwner,
568
673
  Permission.ProjectAdmin,
@@ -585,7 +690,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
585
690
  public acknowledgedByTeamId?: ObjectID = undefined;
586
691
 
587
692
  @ColumnAccessControl({
588
- create: [],
693
+ create: [
694
+ Permission.ProjectOwner,
695
+ Permission.ProjectAdmin,
696
+ Permission.ProjectMember,
697
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
698
+ ],
589
699
  read: [],
590
700
  update: [],
591
701
  })
@@ -604,7 +714,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
604
714
  public lastExecutedEscalationRuleOrder?: number = undefined;
605
715
 
606
716
  @ColumnAccessControl({
607
- create: [],
717
+ create: [
718
+ Permission.ProjectOwner,
719
+ Permission.ProjectAdmin,
720
+ Permission.ProjectMember,
721
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
722
+ ],
608
723
  read: [],
609
724
  update: [],
610
725
  })
@@ -623,7 +738,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
623
738
  public lastEscalationRuleExecutedAt?: Date = undefined;
624
739
 
625
740
  @ColumnAccessControl({
626
- create: [],
741
+ create: [
742
+ Permission.ProjectOwner,
743
+ Permission.ProjectAdmin,
744
+ Permission.ProjectMember,
745
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
746
+ ],
627
747
  read: [
628
748
  Permission.ProjectOwner,
629
749
  Permission.ProjectAdmin,
@@ -655,7 +775,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
655
775
  undefined;
656
776
 
657
777
  @ColumnAccessControl({
658
- create: [],
778
+ create: [
779
+ Permission.ProjectOwner,
780
+ Permission.ProjectAdmin,
781
+ Permission.ProjectMember,
782
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
783
+ ],
659
784
  read: [
660
785
  Permission.ProjectOwner,
661
786
  Permission.ProjectAdmin,
@@ -680,7 +805,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
680
805
  public lastExecutedEscalationRuleId?: ObjectID = undefined;
681
806
 
682
807
  @ColumnAccessControl({
683
- create: [],
808
+ create: [
809
+ Permission.ProjectOwner,
810
+ Permission.ProjectAdmin,
811
+ Permission.ProjectMember,
812
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
813
+ ],
684
814
  read: [],
685
815
  update: [],
686
816
  })
@@ -700,7 +830,12 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
700
830
  public executeNextEscalationRuleInMinutes?: number = undefined;
701
831
 
702
832
  @ColumnAccessControl({
703
- create: [],
833
+ create: [
834
+ Permission.ProjectOwner,
835
+ Permission.ProjectAdmin,
836
+ Permission.ProjectMember,
837
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
838
+ ],
704
839
  read: [],
705
840
  update: [],
706
841
  })
@@ -719,4 +854,67 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
719
854
  default: 1,
720
855
  })
721
856
  public onCallPolicyExecutionRepeatCount?: number = undefined;
857
+
858
+ @ColumnAccessControl({
859
+ create: [
860
+ Permission.ProjectOwner,
861
+ Permission.ProjectAdmin,
862
+ Permission.ProjectMember,
863
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
864
+ ],
865
+ read: [
866
+ Permission.ProjectOwner,
867
+ Permission.ProjectAdmin,
868
+ Permission.ProjectMember,
869
+ Permission.ReadProjectOnCallDutyPolicyExecutionLog,
870
+ ],
871
+ update: [],
872
+ })
873
+ @TableColumn({
874
+ manyToOneRelationColumn: "triggeredByUserId",
875
+ type: TableColumnType.Entity,
876
+ modelType: User,
877
+ title: "Triggered by User",
878
+ description: "Relation to User who triggered on-clal policy",
879
+ })
880
+ @ManyToOne(
881
+ () => {
882
+ return User;
883
+ },
884
+ {
885
+ eager: false,
886
+ nullable: true,
887
+ onDelete: "SET NULL",
888
+ orphanedRowAction: "nullify",
889
+ },
890
+ )
891
+ @JoinColumn({ name: "triggeredByUserId" })
892
+ public triggeredByUser?: User = undefined;
893
+
894
+ @ColumnAccessControl({
895
+ create: [
896
+ Permission.ProjectOwner,
897
+ Permission.ProjectAdmin,
898
+ Permission.ProjectMember,
899
+ Permission.CreateProjectOnCallDutyPolicyExecutionLog,
900
+ ],
901
+ read: [
902
+ Permission.ProjectOwner,
903
+ Permission.ProjectAdmin,
904
+ Permission.ProjectMember,
905
+ Permission.ReadProjectOnCallDutyPolicyExecutionLog,
906
+ ],
907
+ update: [],
908
+ })
909
+ @TableColumn({
910
+ type: TableColumnType.ObjectID,
911
+ title: "Triggered by User ID",
912
+ description: "User ID who triggered this on-call policy",
913
+ })
914
+ @Column({
915
+ type: ColumnType.ObjectID,
916
+ nullable: true,
917
+ transformer: ObjectID.getDatabaseTransformer(),
918
+ })
919
+ public triggeredByUserId?: ObjectID = undefined;
722
920
  }
@@ -0,0 +1,23 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1740430229844 implements MigrationInterface {
4
+ public name = "MigrationName1740430229844";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "OnCallDutyPolicyExecutionLog" ADD "triggeredByUserId" uuid`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "OnCallDutyPolicyExecutionLog" ADD CONSTRAINT "FK_0ed55adc637e8ed7a524f942b18" FOREIGN KEY ("triggeredByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
12
+ );
13
+ }
14
+
15
+ public async down(queryRunner: QueryRunner): Promise<void> {
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicyExecutionLog" DROP CONSTRAINT "FK_0ed55adc637e8ed7a524f942b18"`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "OnCallDutyPolicyExecutionLog" DROP COLUMN "triggeredByUserId"`,
21
+ );
22
+ }
23
+ }
@@ -107,6 +107,7 @@ import { MigrationName1739374537088 } from "./1739374537088-MigrationName";
107
107
  import { MigrationName1739569321582 } from "./1739569321582-MigrationName";
108
108
  import { MigrationName1740164199817 } from "./1740164199817-MigrationName";
109
109
  import { MigrationName1740419151825 } from "./1740419151825-MigrationName";
110
+ import { MigrationName1740430229844 } from "./1740430229844-MigrationName";
110
111
 
111
112
  export default [
112
113
  InitialMigration,
@@ -218,4 +219,5 @@ export default [
218
219
  MigrationName1739569321582,
219
220
  MigrationName1740164199817,
220
221
  MigrationName1740419151825,
222
+ MigrationName1740430229844,
221
223
  ];
@@ -33,6 +33,14 @@ export class Service extends DatabaseService<Model> {
33
33
  createBy.data.status = OnCallDutyPolicyStatus.Scheduled;
34
34
  }
35
35
 
36
+ if (!createBy.data.statusMessage) {
37
+ createBy.data.statusMessage = "Scheduled.";
38
+ }
39
+
40
+ if (createBy.props.userId) {
41
+ createBy.data.triggeredByUserId = createBy.props.userId;
42
+ }
43
+
36
44
  createBy.data.onCallPolicyExecutionRepeatCount = 1;
37
45
 
38
46
  return { createBy, carryForward: null };
package/Types/Date.ts CHANGED
@@ -819,26 +819,36 @@ export default class OneUptimeDate {
819
819
  return moment(date).isBefore(endDate);
820
820
  }
821
821
 
822
- public static getCurrentDateAsFormattedString(): string {
823
- return this.getDateAsFormattedString(new Date());
822
+ public static getCurrentDateAsFormattedString(options?: {
823
+ onlyShowDate?: boolean;
824
+ showSeconds?: boolean;
825
+ }): string {
826
+ return this.getDateAsFormattedString(new Date(), options);
824
827
  }
825
828
 
826
829
  public static getDateAsFormattedString(
827
830
  date: string | Date,
828
- onlyShowDate?: boolean,
831
+ options?: {
832
+ onlyShowDate?: boolean;
833
+ showSeconds?: boolean;
834
+ },
829
835
  ): string {
830
836
  date = this.fromString(date);
831
837
 
832
838
  let formatstring: string = "MMM DD YYYY, HH:mm";
833
839
 
834
- if (onlyShowDate) {
840
+ if (options?.showSeconds) {
841
+ formatstring = "MMM DD YYYY, HH:mm:ss";
842
+ }
843
+
844
+ if (options?.onlyShowDate) {
835
845
  formatstring = "MMM DD, YYYY";
836
846
  }
837
847
 
838
848
  return (
839
849
  moment(date).format(formatstring) +
840
850
  " " +
841
- (onlyShowDate ? "" : this.getCurrentTimezoneString())
851
+ (options?.onlyShowDate ? "" : this.getCurrentTimezoneString())
842
852
  );
843
853
  }
844
854
 
@@ -504,6 +504,7 @@ enum Permission {
504
504
 
505
505
  ReadProjectOnCallDutyPolicyExecutionLogTimeline = "ReadProjectOnCallDutyPolicyExecutionLogTimeline",
506
506
  ReadProjectOnCallDutyPolicyExecutionLog = "ReadProjectOnCallDutyPolicyExecutionLog",
507
+ CreateProjectOnCallDutyPolicyExecutionLog = "CreateProjectOnCallDutyPolicyExecutionLog",
507
508
 
508
509
  // Resource Permissions (Team Permission)
509
510
  CreateProjectOnCallDutyPolicyEscalationRule = "CreateProjectOnCallDutyPolicyEscalationRule",
@@ -2200,8 +2201,14 @@ export class PermissionHelper {
2200
2201
  {
2201
2202
  permission: Permission.ReadProjectOnCallDutyPolicyExecutionLog,
2202
2203
  title: "Read On-Call Duty Policy Execution Log",
2203
- description:
2204
- "This permission can read teams in on-call duty execution log.",
2204
+ description: "This permission can read on-call duty execution log.",
2205
+ isAssignableToTenant: true,
2206
+ isAccessControlPermission: false,
2207
+ },
2208
+ {
2209
+ permission: Permission.CreateProjectOnCallDutyPolicyExecutionLog,
2210
+ title: "Create On-Call Duty Policy Execution Log",
2211
+ description: "This permission can create on-call duty execution log.",
2205
2212
  isAssignableToTenant: true,
2206
2213
  isAccessControlPermission: false,
2207
2214
  },