@oneuptime/common 7.0.3457 → 7.0.3463

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 (28) hide show
  1. package/Models/DatabaseModels/AlertLog.ts +394 -0
  2. package/Models/DatabaseModels/IncidentLog.ts +394 -0
  3. package/Models/DatabaseModels/Index.ts +8 -0
  4. package/Models/DatabaseModels/ScheduledMaintenanceLog.ts +402 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/1736364478985-MigrationName.ts +51 -0
  6. package/Server/Infrastructure/Postgres/SchemaMigrations/1736364957990-MigrationName.ts +63 -0
  7. package/Server/Infrastructure/Postgres/SchemaMigrations/1736365532085-MigrationName.ts +26 -0
  8. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  9. package/Types/Permission.ts +115 -0
  10. package/build/dist/Models/DatabaseModels/AlertLog.js +415 -0
  11. package/build/dist/Models/DatabaseModels/AlertLog.js.map +1 -0
  12. package/build/dist/Models/DatabaseModels/IncidentLog.js +415 -0
  13. package/build/dist/Models/DatabaseModels/IncidentLog.js.map +1 -0
  14. package/build/dist/Models/DatabaseModels/Index.js +6 -0
  15. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  16. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceLog.js +415 -0
  17. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceLog.js.map +1 -0
  18. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736364478985-MigrationName.js +24 -0
  19. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736364478985-MigrationName.js.map +1 -0
  20. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736364957990-MigrationName.js +28 -0
  21. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736364957990-MigrationName.js.map +1 -0
  22. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736365532085-MigrationName.js +24 -0
  23. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1736365532085-MigrationName.js.map +1 -0
  24. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  25. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  26. package/build/dist/Types/Permission.js +96 -0
  27. package/build/dist/Types/Permission.js.map +1 -1
  28. package/package.json +2 -2
@@ -0,0 +1,402 @@
1
+ import ScheduledMaintenance from "./ScheduledMaintenance";
2
+ import Project from "./Project";
3
+ import User from "./User";
4
+ import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
5
+ import Route from "../../Types/API/Route";
6
+ import ColumnAccessControl from "../../Types/Database/AccessControl/ColumnAccessControl";
7
+ import TableAccessControl from "../../Types/Database/AccessControl/TableAccessControl";
8
+ import CanAccessIfCanReadOn from "../../Types/Database/CanAccessIfCanReadOn";
9
+ import ColumnType from "../../Types/Database/ColumnType";
10
+ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
11
+ import EnableDocumentation from "../../Types/Database/EnableDocumentation";
12
+ import EnableWorkflow from "../../Types/Database/EnableWorkflow";
13
+ import TableColumn from "../../Types/Database/TableColumn";
14
+ import TableColumnType from "../../Types/Database/TableColumnType";
15
+ import TableMetadata from "../../Types/Database/TableMetadata";
16
+ import TenantColumn from "../../Types/Database/TenantColumn";
17
+ import IconProp from "../../Types/Icon/IconProp";
18
+ import ObjectID from "../../Types/ObjectID";
19
+ import Permission from "../../Types/Permission";
20
+ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
21
+
22
+
23
+ export enum ScheduledMaintenanceLogEvent {
24
+ PublicNote = "PublicNote",
25
+ SubscriberEmailSent = "SubscriberEmailSent",
26
+ OwnerEmailSent = "OwnerEmailSent",
27
+ ScheduledMaintenanceCreated = "ScheduledMaintenanceCreated",
28
+ ScheduledMaintenanceAcknowledged = "ScheduledMaintenanceAcknowledged",
29
+ ScheduledMaintenanceResolved = "ScheduledMaintenanceResolved",
30
+ PrivateNote = "PrivateNote",
31
+ }
32
+
33
+ @EnableDocumentation()
34
+ @CanAccessIfCanReadOn("scheduledMaintenance")
35
+ @TenantColumn("projectId")
36
+ @TableAccessControl({
37
+ create: [
38
+ Permission.ProjectOwner,
39
+ Permission.ProjectAdmin,
40
+ Permission.ProjectMember,
41
+ Permission.CreateScheduledMaintenanceLog,
42
+ ],
43
+ read: [
44
+ Permission.ProjectOwner,
45
+ Permission.ProjectAdmin,
46
+ Permission.ProjectMember,
47
+ Permission.ReadScheduledMaintenanceLog,
48
+ ],
49
+ delete: [
50
+
51
+ ],
52
+ update: [
53
+
54
+ ],
55
+ })
56
+ @EnableWorkflow({
57
+ create: true,
58
+ delete: true,
59
+ update: true,
60
+ read: true,
61
+ })
62
+ @CrudApiEndpoint(new Route("/scheduled-maintenance-log"))
63
+ @Entity({
64
+ name: "ScheduledMaintenanceLog",
65
+ })
66
+ @TableMetadata({
67
+ tableName: "ScheduledMaintenanceLog",
68
+ singularName: "ScheduledMaintenance Log",
69
+ pluralName: "ScheduledMaintenance Logs",
70
+ icon: IconProp.List,
71
+ tableDescription:
72
+ "Log of the entire scheduled maintenance state change. This is a log of all the scheduled maintenance state changes, public notes, more etc.",
73
+ })
74
+ export default class ScheduledMaintenanceLog extends BaseModel {
75
+ @ColumnAccessControl({
76
+ create: [
77
+ Permission.ProjectOwner,
78
+ Permission.ProjectAdmin,
79
+ Permission.ProjectMember,
80
+ Permission.CreateScheduledMaintenanceLog,
81
+ ],
82
+ read: [
83
+ Permission.ProjectOwner,
84
+ Permission.ProjectAdmin,
85
+ Permission.ProjectMember,
86
+ Permission.ReadScheduledMaintenanceLog,
87
+ ],
88
+ update: [],
89
+ })
90
+ @TableColumn({
91
+ manyToOneRelationColumn: "projectId",
92
+ type: TableColumnType.Entity,
93
+ modelType: Project,
94
+ title: "Project",
95
+ description: "Relation to Project Resource in which this object belongs",
96
+ })
97
+ @ManyToOne(
98
+ () => {
99
+ return Project;
100
+ },
101
+ {
102
+ eager: false,
103
+ nullable: true,
104
+ onDelete: "CASCADE",
105
+ orphanedRowAction: "nullify",
106
+ },
107
+ )
108
+ @JoinColumn({ name: "projectId" })
109
+ public project?: Project = undefined;
110
+
111
+ @ColumnAccessControl({
112
+ create: [
113
+ Permission.ProjectOwner,
114
+ Permission.ProjectAdmin,
115
+ Permission.ProjectMember,
116
+ Permission.CreateScheduledMaintenanceLog,
117
+ ],
118
+ read: [
119
+ Permission.ProjectOwner,
120
+ Permission.ProjectAdmin,
121
+ Permission.ProjectMember,
122
+ Permission.ReadScheduledMaintenanceLog,
123
+ ],
124
+ update: [],
125
+ })
126
+ @Index()
127
+ @TableColumn({
128
+ type: TableColumnType.ObjectID,
129
+ required: true,
130
+ canReadOnRelationQuery: true,
131
+ title: "Project ID",
132
+ description: "ID of your OneUptime Project in which this object belongs",
133
+ })
134
+ @Column({
135
+ type: ColumnType.ObjectID,
136
+ nullable: false,
137
+ transformer: ObjectID.getDatabaseTransformer(),
138
+ })
139
+ public projectId?: ObjectID = undefined;
140
+
141
+ @ColumnAccessControl({
142
+ create: [
143
+ Permission.ProjectOwner,
144
+ Permission.ProjectAdmin,
145
+ Permission.ProjectMember,
146
+ Permission.CreateScheduledMaintenanceLog,
147
+ ],
148
+ read: [
149
+ Permission.ProjectOwner,
150
+ Permission.ProjectAdmin,
151
+ Permission.ProjectMember,
152
+ Permission.ReadScheduledMaintenanceLog,
153
+ ],
154
+ update: [],
155
+ })
156
+ @TableColumn({
157
+ manyToOneRelationColumn: "scheduledMaintenanceId",
158
+ type: TableColumnType.Entity,
159
+ modelType: ScheduledMaintenance,
160
+ title: "ScheduledMaintenance",
161
+ description: "Relation to ScheduledMaintenance in which this resource belongs",
162
+ })
163
+ @ManyToOne(
164
+ () => {
165
+ return ScheduledMaintenance;
166
+ },
167
+ {
168
+ eager: false,
169
+ nullable: true,
170
+ onDelete: "CASCADE",
171
+ orphanedRowAction: "nullify",
172
+ },
173
+ )
174
+ @JoinColumn({ name: "scheduledMaintenanceId" })
175
+ public scheduledMaintenance?: ScheduledMaintenance = undefined;
176
+
177
+ @ColumnAccessControl({
178
+ create: [
179
+ Permission.ProjectOwner,
180
+ Permission.ProjectAdmin,
181
+ Permission.ProjectMember,
182
+ Permission.CreateScheduledMaintenanceLog,
183
+ ],
184
+ read: [
185
+ Permission.ProjectOwner,
186
+ Permission.ProjectAdmin,
187
+ Permission.ProjectMember,
188
+ Permission.ReadScheduledMaintenanceLog,
189
+ ],
190
+ update: [],
191
+ })
192
+ @Index()
193
+ @TableColumn({
194
+ type: TableColumnType.ObjectID,
195
+ required: true,
196
+ title: "ScheduledMaintenance ID",
197
+ description: "Relation to ScheduledMaintenance ID in which this resource belongs",
198
+ })
199
+ @Column({
200
+ type: ColumnType.ObjectID,
201
+ nullable: false,
202
+ transformer: ObjectID.getDatabaseTransformer(),
203
+ })
204
+ public scheduledMaintenanceId?: ObjectID = undefined;
205
+
206
+ @ColumnAccessControl({
207
+ create: [
208
+ Permission.ProjectOwner,
209
+ Permission.ProjectAdmin,
210
+ Permission.ProjectMember,
211
+ Permission.CreateScheduledMaintenanceLog,
212
+ ],
213
+ read: [
214
+ Permission.ProjectOwner,
215
+ Permission.ProjectAdmin,
216
+ Permission.ProjectMember,
217
+ Permission.ReadScheduledMaintenanceLog,
218
+ ],
219
+ update: [],
220
+ })
221
+ @TableColumn({
222
+ manyToOneRelationColumn: "createdByUserId",
223
+ type: TableColumnType.Entity,
224
+ modelType: User,
225
+ title: "Created by User",
226
+ description:
227
+ "Relation to User who created this object (if this object was created by a User)",
228
+ })
229
+ @ManyToOne(
230
+ () => {
231
+ return User;
232
+ },
233
+ {
234
+ eager: false,
235
+ nullable: true,
236
+ onDelete: "SET NULL",
237
+ orphanedRowAction: "nullify",
238
+ },
239
+ )
240
+ @JoinColumn({ name: "createdByUserId" })
241
+ public createdByUser?: User = undefined;
242
+
243
+ @ColumnAccessControl({
244
+ create: [
245
+ Permission.ProjectOwner,
246
+ Permission.ProjectAdmin,
247
+ Permission.ProjectMember,
248
+ Permission.CreateScheduledMaintenanceLog,
249
+ ],
250
+ read: [
251
+ Permission.ProjectOwner,
252
+ Permission.ProjectAdmin,
253
+ Permission.ProjectMember,
254
+ Permission.ReadScheduledMaintenanceLog,
255
+ ],
256
+ update: [],
257
+ })
258
+ @TableColumn({
259
+ type: TableColumnType.ObjectID,
260
+ title: "Created by User ID",
261
+ description:
262
+ "User ID who created this object (if this object was created by a User)",
263
+ })
264
+ @Column({
265
+ type: ColumnType.ObjectID,
266
+ nullable: true,
267
+ transformer: ObjectID.getDatabaseTransformer(),
268
+ })
269
+ public createdByUserId?: ObjectID = undefined;
270
+
271
+ @ColumnAccessControl({
272
+ create: [],
273
+ read: [],
274
+ update: [],
275
+ })
276
+ @TableColumn({
277
+ manyToOneRelationColumn: "deletedByUserId",
278
+ type: TableColumnType.Entity,
279
+ title: "Deleted by User",
280
+ description:
281
+ "Relation to User who deleted this object (if this object was deleted by a User)",
282
+ })
283
+ @ManyToOne(
284
+ () => {
285
+ return User;
286
+ },
287
+ {
288
+ cascade: false,
289
+ eager: false,
290
+ nullable: true,
291
+ onDelete: "SET NULL",
292
+ orphanedRowAction: "nullify",
293
+ },
294
+ )
295
+ @JoinColumn({ name: "deletedByUserId" })
296
+ public deletedByUser?: User = undefined;
297
+
298
+ @ColumnAccessControl({
299
+ create: [],
300
+ read: [],
301
+ update: [],
302
+ })
303
+ @TableColumn({
304
+ type: TableColumnType.ObjectID,
305
+ title: "Deleted by User ID",
306
+ description:
307
+ "User ID who deleted this object (if this object was deleted by a User)",
308
+ })
309
+ @Column({
310
+ type: ColumnType.ObjectID,
311
+ nullable: true,
312
+ transformer: ObjectID.getDatabaseTransformer(),
313
+ })
314
+ public deletedByUserId?: ObjectID = undefined;
315
+
316
+
317
+ @ColumnAccessControl({
318
+ create: [
319
+ Permission.ProjectOwner,
320
+ Permission.ProjectAdmin,
321
+ Permission.ProjectMember,
322
+ Permission.CreateScheduledMaintenanceLog,
323
+ ],
324
+ read: [
325
+ Permission.ProjectOwner,
326
+ Permission.ProjectAdmin,
327
+ Permission.ProjectMember,
328
+ Permission.ReadScheduledMaintenanceLog,
329
+ ],
330
+ update: [],
331
+ })
332
+ @TableColumn({
333
+ type: TableColumnType.Markdown,
334
+ required: true,
335
+ title: "Log (in Markdown)",
336
+ description: "Log of the entire scheduledMaintenance state change in Markdown",
337
+ })
338
+ @Column({
339
+ type: ColumnType.Markdown,
340
+ nullable: false,
341
+ unique: false,
342
+ })
343
+ public logInMarkdown?: string = undefined;
344
+
345
+
346
+ @ColumnAccessControl({
347
+ create: [
348
+ Permission.ProjectOwner,
349
+ Permission.ProjectAdmin,
350
+ Permission.ProjectMember,
351
+ Permission.CreateScheduledMaintenanceLog,
352
+ ],
353
+ read: [
354
+ Permission.ProjectOwner,
355
+ Permission.ProjectAdmin,
356
+ Permission.ProjectMember,
357
+ Permission.ReadScheduledMaintenanceLog,
358
+ ],
359
+ update: [],
360
+ })
361
+ @TableColumn({
362
+ type: TableColumnType.Markdown,
363
+ required: true,
364
+ title: "More Information (in Markdown)",
365
+ description: "More information in Markdown",
366
+ })
367
+ @Column({
368
+ type: ColumnType.Markdown,
369
+ nullable: false,
370
+ unique: false,
371
+ })
372
+ public moreInformationInMarkdown?: string = undefined;
373
+
374
+
375
+ @ColumnAccessControl({
376
+ create: [
377
+ Permission.ProjectOwner,
378
+ Permission.ProjectAdmin,
379
+ Permission.ProjectMember,
380
+ Permission.CreateScheduledMaintenanceLog,
381
+ ],
382
+ read: [
383
+ Permission.ProjectOwner,
384
+ Permission.ProjectAdmin,
385
+ Permission.ProjectMember,
386
+ Permission.ReadScheduledMaintenanceLog,
387
+ ],
388
+ update: [],
389
+ })
390
+ @TableColumn({
391
+ type: TableColumnType.ShortText,
392
+ required: true,
393
+ title: "ScheduledMaintenance Log Event",
394
+ description: "ScheduledMaintenance Log Event",
395
+ })
396
+ @Column({
397
+ type: ColumnType.ShortText,
398
+ nullable: false,
399
+ unique: false,
400
+ })
401
+ public scheduledMaintenanceLogEvent?: ScheduledMaintenanceLogEvent = undefined;
402
+ }
@@ -0,0 +1,51 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1736364478985 implements MigrationInterface {
4
+ public name = "MigrationName1736364478985";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE "IncidentLog" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "incidentId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "logInMarkdown" text NOT NULL, "moreInformationInMarkdown" text NOT NULL, "incidentLogEvent" character varying NOT NULL, CONSTRAINT "PK_947cb9f32cf204561d10d64adeb" PRIMARY KEY ("_id"))`,
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE INDEX "IDX_855797e41af7d35b18a7f3f97b" ON "IncidentLog" ("projectId") `,
12
+ );
13
+ await queryRunner.query(
14
+ `CREATE INDEX "IDX_1eff2f3d075754ef9c16e8b962" ON "IncidentLog" ("incidentId") `,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "IncidentLog" ADD CONSTRAINT "FK_855797e41af7d35b18a7f3f97bd" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "IncidentLog" ADD CONSTRAINT "FK_1eff2f3d075754ef9c16e8b962c" FOREIGN KEY ("incidentId") REFERENCES "Incident"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "IncidentLog" ADD CONSTRAINT "FK_da6bb8bf63b18a7ddc35cc2901a" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "IncidentLog" ADD CONSTRAINT "FK_bb1b8b83ffdfc702088b74f2e16" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
27
+ );
28
+ }
29
+
30
+ public async down(queryRunner: QueryRunner): Promise<void> {
31
+ await queryRunner.query(
32
+ `ALTER TABLE "IncidentLog" DROP CONSTRAINT "FK_bb1b8b83ffdfc702088b74f2e16"`,
33
+ );
34
+ await queryRunner.query(
35
+ `ALTER TABLE "IncidentLog" DROP CONSTRAINT "FK_da6bb8bf63b18a7ddc35cc2901a"`,
36
+ );
37
+ await queryRunner.query(
38
+ `ALTER TABLE "IncidentLog" DROP CONSTRAINT "FK_1eff2f3d075754ef9c16e8b962c"`,
39
+ );
40
+ await queryRunner.query(
41
+ `ALTER TABLE "IncidentLog" DROP CONSTRAINT "FK_855797e41af7d35b18a7f3f97bd"`,
42
+ );
43
+ await queryRunner.query(
44
+ `DROP INDEX "public"."IDX_1eff2f3d075754ef9c16e8b962"`,
45
+ );
46
+ await queryRunner.query(
47
+ `DROP INDEX "public"."IDX_855797e41af7d35b18a7f3f97b"`,
48
+ );
49
+ await queryRunner.query(`DROP TABLE "IncidentLog"`);
50
+ }
51
+ }
@@ -0,0 +1,63 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1736364957990 implements MigrationInterface {
4
+ public name = "MigrationName1736364957990";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `CREATE TABLE "AlertLog" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "alertId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "logInMarkdown" text NOT NULL, "moreInformationInMarkdown" text NOT NULL, "alertLogEvent" character varying NOT NULL, CONSTRAINT "PK_500826238fa54528b0026f55d47" PRIMARY KEY ("_id"))`,
9
+ );
10
+ await queryRunner.query(
11
+ `CREATE INDEX "IDX_d5d56f9ed2c4c72745372a1ac6" ON "AlertLog" ("projectId") `,
12
+ );
13
+ await queryRunner.query(
14
+ `CREATE INDEX "IDX_52bbabed66e4e728441d49478f" ON "AlertLog" ("alertId") `,
15
+ );
16
+ await queryRunner.query(
17
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
18
+ );
19
+ await queryRunner.query(
20
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "AlertLog" ADD CONSTRAINT "FK_d5d56f9ed2c4c72745372a1ac6f" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "AlertLog" ADD CONSTRAINT "FK_52bbabed66e4e728441d49478f8" FOREIGN KEY ("alertId") REFERENCES "Alert"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
27
+ );
28
+ await queryRunner.query(
29
+ `ALTER TABLE "AlertLog" ADD CONSTRAINT "FK_f5f832aad105579e95a09e1ddd0" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
30
+ );
31
+ await queryRunner.query(
32
+ `ALTER TABLE "AlertLog" ADD CONSTRAINT "FK_7ca9046915f6de6e7a199588d26" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
33
+ );
34
+ }
35
+
36
+ public async down(queryRunner: QueryRunner): Promise<void> {
37
+ await queryRunner.query(
38
+ `ALTER TABLE "AlertLog" DROP CONSTRAINT "FK_7ca9046915f6de6e7a199588d26"`,
39
+ );
40
+ await queryRunner.query(
41
+ `ALTER TABLE "AlertLog" DROP CONSTRAINT "FK_f5f832aad105579e95a09e1ddd0"`,
42
+ );
43
+ await queryRunner.query(
44
+ `ALTER TABLE "AlertLog" DROP CONSTRAINT "FK_52bbabed66e4e728441d49478f8"`,
45
+ );
46
+ await queryRunner.query(
47
+ `ALTER TABLE "AlertLog" DROP CONSTRAINT "FK_d5d56f9ed2c4c72745372a1ac6f"`,
48
+ );
49
+ await queryRunner.query(
50
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
51
+ );
52
+ await queryRunner.query(
53
+ `ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
54
+ );
55
+ await queryRunner.query(
56
+ `DROP INDEX "public"."IDX_52bbabed66e4e728441d49478f"`,
57
+ );
58
+ await queryRunner.query(
59
+ `DROP INDEX "public"."IDX_d5d56f9ed2c4c72745372a1ac6"`,
60
+ );
61
+ await queryRunner.query(`DROP TABLE "AlertLog"`);
62
+ }
63
+ }
@@ -0,0 +1,26 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1736365532085 implements MigrationInterface {
4
+ public name = 'MigrationName1736365532085'
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(`CREATE TABLE "ScheduledMaintenanceLog" ("_id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "deletedAt" TIMESTAMP WITH TIME ZONE, "version" integer NOT NULL, "projectId" uuid NOT NULL, "scheduledMaintenanceId" uuid NOT NULL, "createdByUserId" uuid, "deletedByUserId" uuid, "logInMarkdown" text NOT NULL, "moreInformationInMarkdown" text NOT NULL, "scheduledMaintenanceLogEvent" character varying NOT NULL, CONSTRAINT "PK_27b89f28bf48418fabba9a1ea14" PRIMARY KEY ("_id"))`);
8
+ await queryRunner.query(`CREATE INDEX "IDX_9239de1ee33f9505c30f255a99" ON "ScheduledMaintenanceLog" ("projectId") `);
9
+ await queryRunner.query(`CREATE INDEX "IDX_58e403ba261dfa94addb5f04d3" ON "ScheduledMaintenanceLog" ("scheduledMaintenanceId") `);
10
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" ADD CONSTRAINT "FK_9239de1ee33f9505c30f255a994" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
11
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" ADD CONSTRAINT "FK_58e403ba261dfa94addb5f04d36" FOREIGN KEY ("scheduledMaintenanceId") REFERENCES "ScheduledMaintenance"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`);
12
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" ADD CONSTRAINT "FK_9152528e4f7f59adaba3e9bc41f" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`);
13
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" ADD CONSTRAINT "FK_a957f435d1504f41808f20a2c45" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`);
14
+ }
15
+
16
+ public async down(queryRunner: QueryRunner): Promise<void> {
17
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" DROP CONSTRAINT "FK_a957f435d1504f41808f20a2c45"`);
18
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" DROP CONSTRAINT "FK_9152528e4f7f59adaba3e9bc41f"`);
19
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" DROP CONSTRAINT "FK_58e403ba261dfa94addb5f04d36"`);
20
+ await queryRunner.query(`ALTER TABLE "ScheduledMaintenanceLog" DROP CONSTRAINT "FK_9239de1ee33f9505c30f255a994"`);
21
+ await queryRunner.query(`DROP INDEX "public"."IDX_58e403ba261dfa94addb5f04d3"`);
22
+ await queryRunner.query(`DROP INDEX "public"."IDX_9239de1ee33f9505c30f255a99"`);
23
+ await queryRunner.query(`DROP TABLE "ScheduledMaintenanceLog"`);
24
+ }
25
+
26
+ }
@@ -84,6 +84,9 @@ import { MigrationName1731435267537 } from "./1731435267537-MigrationName";
84
84
  import { MigrationName1731435514287 } from "./1731435514287-MigrationName";
85
85
  import { MigrationName1732553444010 } from "./1732553444010-MigrationName";
86
86
  import { MigrationName1734435866602 } from "./1734435866602-MigrationName";
87
+ import { MigrationName1736364478985 } from "./1736364478985-MigrationName";
88
+ import { MigrationName1736364957990 } from "./1736364957990-MigrationName";
89
+ import { MigrationName1736365532085 } from "./1736365532085-MigrationName";
87
90
 
88
91
  export default [
89
92
  InitialMigration,
@@ -172,4 +175,7 @@ export default [
172
175
  MigrationName1731435514287,
173
176
  MigrationName1732553444010,
174
177
  MigrationName1734435866602,
178
+ MigrationName1736364478985,
179
+ MigrationName1736364957990,
180
+ MigrationName1736365532085
175
181
  ];
@@ -420,6 +420,22 @@ enum Permission {
420
420
  ReadIncidentStateTimeline = "ReadIncidentStateTimeline",
421
421
  DeleteIncidentStateTimeline = "DeleteIncidentStateTimeline",
422
422
 
423
+ CreateIncidentLog = "CreateIncidentLog",
424
+ EditIncidentLog = "EditIncidentLog",
425
+ ReadIncidentLog = "ReadIncidentLog",
426
+ DeleteIncidentLog = "DeleteIncidentLog",
427
+
428
+
429
+ CreateScheduledMaintenanceLog = "CreateScheduledMaintenanceLog",
430
+ EditScheduledMaintenanceLog = "EditScheduledMaintenanceLog",
431
+ ReadScheduledMaintenanceLog = "ReadScheduledMaintenanceLog",
432
+ DeleteScheduledMaintenanceLog = "DeleteScheduledMaintenanceLog",
433
+
434
+ CreateAlertLog = "CreateAlertLog",
435
+ EditAlertLog = "EditAlertLog",
436
+ ReadAlertLog = "ReadAlertLog",
437
+ DeleteAlertLog = "DeleteAlertLog",
438
+
423
439
  // Incident Status Permissions (Owner + Admin Permission by default)
424
440
  CreateMonitorStatusTimeline = "CreateMonitorStatusTimeline",
425
441
  EditMonitorStatusTimeline = "EditMonitorStatusTimeline",
@@ -1057,6 +1073,105 @@ export class PermissionHelper {
1057
1073
  isAccessControlPermission: false,
1058
1074
  },
1059
1075
 
1076
+ {
1077
+ permission: Permission.CreateIncidentLog,
1078
+ title: "Create Incident Log",
1079
+ description:
1080
+ "This permission can create log of an incident in this project.",
1081
+ isAssignableToTenant: true,
1082
+ isAccessControlPermission: false,
1083
+ },
1084
+ {
1085
+ permission: Permission.DeleteIncidentLog,
1086
+ title: "Delete Incident Log",
1087
+ description:
1088
+ "This permission can delete log of an incident in this project.",
1089
+ isAssignableToTenant: true,
1090
+ isAccessControlPermission: false,
1091
+ },
1092
+ {
1093
+ permission: Permission.EditIncidentLog,
1094
+ title: "Edit Incident Log",
1095
+ description:
1096
+ "This permission can edit log of an incident in this project.",
1097
+ isAssignableToTenant: true,
1098
+ isAccessControlPermission: false,
1099
+ },
1100
+ {
1101
+ permission: Permission.ReadIncidentLog,
1102
+ title: "Read Incident Log",
1103
+ description:
1104
+ "This permission can read log of an incident in this project.",
1105
+ isAssignableToTenant: true,
1106
+ isAccessControlPermission: false,
1107
+ },
1108
+
1109
+ {
1110
+ permission: Permission.CreateAlertLog,
1111
+ title: "Create Alert Log",
1112
+ description:
1113
+ "This permission can create log of an incident in this project.",
1114
+ isAssignableToTenant: true,
1115
+ isAccessControlPermission: false,
1116
+ },
1117
+ {
1118
+ permission: Permission.DeleteAlertLog,
1119
+ title: "Delete Alert Log",
1120
+ description:
1121
+ "This permission can delete log of an incident in this project.",
1122
+ isAssignableToTenant: true,
1123
+ isAccessControlPermission: false,
1124
+ },
1125
+ {
1126
+ permission: Permission.EditAlertLog,
1127
+ title: "Edit Alert Log",
1128
+ description:
1129
+ "This permission can edit log of an incident in this project.",
1130
+ isAssignableToTenant: true,
1131
+ isAccessControlPermission: false,
1132
+ },
1133
+ {
1134
+ permission: Permission.ReadAlertLog,
1135
+ title: "Read Alert Log",
1136
+ description:
1137
+ "This permission can read log of an incident in this project.",
1138
+ isAssignableToTenant: true,
1139
+ isAccessControlPermission: false,
1140
+ },
1141
+
1142
+ {
1143
+ permission: Permission.CreateScheduledMaintenanceLog,
1144
+ title: "Create Scheduled Maintenance Log",
1145
+ description:
1146
+ "This permission can create log of a scheduled maintenance in this project.",
1147
+ isAssignableToTenant: true,
1148
+ isAccessControlPermission: false,
1149
+ },
1150
+ {
1151
+ permission: Permission.DeleteScheduledMaintenanceLog,
1152
+ title: "Delete Scheduled Maintenance Log",
1153
+ description:
1154
+ "This permission can delete log of an scheduled maintenance in this project.",
1155
+ isAssignableToTenant: true,
1156
+ isAccessControlPermission: false,
1157
+ },
1158
+ {
1159
+ permission: Permission.EditScheduledMaintenanceLog,
1160
+ title: "Edit Scheduled Maintenance Log",
1161
+ description:
1162
+ "This permission can edit log of an scheduled maintenance in this project.",
1163
+ isAssignableToTenant: true,
1164
+ isAccessControlPermission: false,
1165
+ },
1166
+ {
1167
+ permission: Permission.ReadScheduledMaintenanceLog,
1168
+ title: "Read Scheduled Maintenance Log",
1169
+ description:
1170
+ "This permission can read log of an incident in this project.",
1171
+ isAssignableToTenant: true,
1172
+ isAccessControlPermission: false,
1173
+ },
1174
+
1060
1175
  {
1061
1176
  permission: Permission.CreateAlertStateTimeline,
1062
1177
  title: "Create Alert State Timeline",