@oneuptime/common 8.0.5580 → 8.0.5581

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 (137) hide show
  1. package/Models/DatabaseModels/AlertInternalNote.ts +58 -1
  2. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.ts +1 -0
  3. package/Models/DatabaseModels/File.ts +1 -1
  4. package/Models/DatabaseModels/IncidentInternalNote.ts +58 -1
  5. package/Models/DatabaseModels/IncidentPublicNote.ts +58 -1
  6. package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.ts +58 -1
  7. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.ts +58 -1
  8. package/Models/DatabaseModels/StatusPageAnnouncement.ts +49 -0
  9. package/Server/API/AlertInternalNoteAPI.ts +96 -0
  10. package/Server/API/IncidentInternalNoteAPI.ts +96 -0
  11. package/Server/API/IncidentPublicNoteAPI.ts +96 -0
  12. package/Server/API/ScheduledMaintenanceInternalNoteAPI.ts +100 -0
  13. package/Server/API/ScheduledMaintenancePublicNoteAPI.ts +100 -0
  14. package/Server/API/StatusPageAPI.ts +585 -59
  15. package/Server/API/StatusPageAnnouncementAPI.ts +98 -0
  16. package/Server/API/UserAPI.ts +95 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.ts +79 -0
  18. package/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.ts +81 -0
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.ts +79 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  21. package/Server/Middleware/ProjectAuthorization.ts +3 -1
  22. package/Server/Services/AlertInternalNoteService.ts +75 -2
  23. package/Server/Services/IncidentInternalNoteService.ts +76 -2
  24. package/Server/Services/IncidentPublicNoteService.ts +76 -2
  25. package/Server/Services/ScheduledMaintenanceInternalNoteService.ts +76 -2
  26. package/Server/Services/ScheduledMaintenancePublicNoteService.ts +76 -2
  27. package/Server/Services/ScheduledMaintenanceService.ts +10 -7
  28. package/Server/Services/StatusPagePrivateUserService.ts +10 -7
  29. package/Server/Services/StatusPageService.ts +12 -7
  30. package/Server/Services/StatusPageSubscriberService.ts +19 -13
  31. package/Server/Utils/FileAttachmentMarkdownUtil.ts +98 -0
  32. package/Server/Utils/Response.ts +13 -0
  33. package/Types/File/MimeType.ts +18 -0
  34. package/UI/Components/AttachmentList/EventAttachmentList.tsx +121 -0
  35. package/UI/Components/EventItem/EventItem.tsx +22 -0
  36. package/UI/Components/Feed/FeedItem.tsx +9 -16
  37. package/UI/Components/FilePicker/FilePicker.tsx +441 -145
  38. package/UI/Components/Forms/Fields/FormField.tsx +32 -15
  39. package/UI/Components/Forms/FormSummary.tsx +168 -1
  40. package/UI/Components/Forms/ModelForm.tsx +46 -24
  41. package/UI/Components/Forms/Types/FormFieldSchemaType.ts +1 -0
  42. package/UI/Components/Icon/Icon.tsx +1 -1
  43. package/UI/Utils/API/RequestOptions.ts +2 -0
  44. package/UI/Utils/ModelAPI/ModelAPI.ts +18 -0
  45. package/UI/Utils/User.ts +8 -0
  46. package/Utils/API.ts +11 -1
  47. package/build/dist/Models/DatabaseModels/AlertInternalNote.js +49 -1
  48. package/build/dist/Models/DatabaseModels/AlertInternalNote.js.map +1 -1
  49. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +1 -0
  50. package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js.map +1 -1
  51. package/build/dist/Models/DatabaseModels/File.js +1 -1
  52. package/build/dist/Models/DatabaseModels/File.js.map +1 -1
  53. package/build/dist/Models/DatabaseModels/IncidentInternalNote.js +49 -1
  54. package/build/dist/Models/DatabaseModels/IncidentInternalNote.js.map +1 -1
  55. package/build/dist/Models/DatabaseModels/IncidentPublicNote.js +49 -1
  56. package/build/dist/Models/DatabaseModels/IncidentPublicNote.js.map +1 -1
  57. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +49 -1
  58. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js.map +1 -1
  59. package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +49 -1
  60. package/build/dist/Models/DatabaseModels/ScheduledMaintenancePublicNote.js.map +1 -1
  61. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js +48 -0
  62. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js.map +1 -1
  63. package/build/dist/Server/API/AlertInternalNoteAPI.js +68 -0
  64. package/build/dist/Server/API/AlertInternalNoteAPI.js.map +1 -0
  65. package/build/dist/Server/API/IncidentInternalNoteAPI.js +68 -0
  66. package/build/dist/Server/API/IncidentInternalNoteAPI.js.map +1 -0
  67. package/build/dist/Server/API/IncidentPublicNoteAPI.js +68 -0
  68. package/build/dist/Server/API/IncidentPublicNoteAPI.js.map +1 -0
  69. package/build/dist/Server/API/ScheduledMaintenanceInternalNoteAPI.js +68 -0
  70. package/build/dist/Server/API/ScheduledMaintenanceInternalNoteAPI.js.map +1 -0
  71. package/build/dist/Server/API/ScheduledMaintenancePublicNoteAPI.js +68 -0
  72. package/build/dist/Server/API/ScheduledMaintenancePublicNoteAPI.js.map +1 -0
  73. package/build/dist/Server/API/StatusPageAPI.js +488 -85
  74. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  75. package/build/dist/Server/API/StatusPageAnnouncementAPI.js +68 -0
  76. package/build/dist/Server/API/StatusPageAnnouncementAPI.js.map +1 -0
  77. package/build/dist/Server/API/UserAPI.js +66 -0
  78. package/build/dist/Server/API/UserAPI.js.map +1 -0
  79. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.js +34 -0
  80. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763471659817-MigrationName.js.map +1 -0
  81. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.js +34 -0
  82. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763477560906-MigrationName.js.map +1 -0
  83. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.js +34 -0
  84. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1763480947474-MigrationName.js.map +1 -0
  85. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  86. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  87. package/build/dist/Server/Middleware/ProjectAuthorization.js +4 -1
  88. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  89. package/build/dist/Server/Services/AlertInternalNoteService.js +54 -2
  90. package/build/dist/Server/Services/AlertInternalNoteService.js.map +1 -1
  91. package/build/dist/Server/Services/IncidentInternalNoteService.js +54 -2
  92. package/build/dist/Server/Services/IncidentInternalNoteService.js.map +1 -1
  93. package/build/dist/Server/Services/IncidentPublicNoteService.js +54 -2
  94. package/build/dist/Server/Services/IncidentPublicNoteService.js.map +1 -1
  95. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js +54 -2
  96. package/build/dist/Server/Services/ScheduledMaintenanceInternalNoteService.js.map +1 -1
  97. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js +54 -2
  98. package/build/dist/Server/Services/ScheduledMaintenancePublicNoteService.js.map +1 -1
  99. package/build/dist/Server/Services/ScheduledMaintenanceService.js +6 -5
  100. package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
  101. package/build/dist/Server/Services/StatusPagePrivateUserService.js +6 -4
  102. package/build/dist/Server/Services/StatusPagePrivateUserService.js.map +1 -1
  103. package/build/dist/Server/Services/StatusPageService.js +7 -4
  104. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  105. package/build/dist/Server/Services/StatusPageSubscriberService.js +11 -7
  106. package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
  107. package/build/dist/Server/Utils/FileAttachmentMarkdownUtil.js +67 -0
  108. package/build/dist/Server/Utils/FileAttachmentMarkdownUtil.js.map +1 -0
  109. package/build/dist/Server/Utils/Response.js +8 -0
  110. package/build/dist/Server/Utils/Response.js.map +1 -1
  111. package/build/dist/Types/File/MimeType.js +18 -0
  112. package/build/dist/Types/File/MimeType.js.map +1 -1
  113. package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js +42 -0
  114. package/build/dist/UI/Components/AttachmentList/EventAttachmentList.js.map +1 -0
  115. package/build/dist/UI/Components/EventItem/EventItem.js +5 -1
  116. package/build/dist/UI/Components/EventItem/EventItem.js.map +1 -1
  117. package/build/dist/UI/Components/Feed/FeedItem.js +6 -4
  118. package/build/dist/UI/Components/Feed/FeedItem.js.map +1 -1
  119. package/build/dist/UI/Components/FilePicker/FilePicker.js +262 -77
  120. package/build/dist/UI/Components/FilePicker/FilePicker.js.map +1 -1
  121. package/build/dist/UI/Components/Forms/Fields/FormField.js +24 -12
  122. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  123. package/build/dist/UI/Components/Forms/FormSummary.js +77 -1
  124. package/build/dist/UI/Components/Forms/FormSummary.js.map +1 -1
  125. package/build/dist/UI/Components/Forms/ModelForm.js +32 -18
  126. package/build/dist/UI/Components/Forms/ModelForm.js.map +1 -1
  127. package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js +1 -0
  128. package/build/dist/UI/Components/Forms/Types/FormFieldSchemaType.js.map +1 -1
  129. package/build/dist/UI/Components/Icon/Icon.js +1 -1
  130. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  131. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js +30 -45
  132. package/build/dist/UI/Utils/ModelAPI/ModelAPI.js.map +1 -1
  133. package/build/dist/UI/Utils/User.js +7 -0
  134. package/build/dist/UI/Utils/User.js.map +1 -1
  135. package/build/dist/Utils/API.js +3 -0
  136. package/build/dist/Utils/API.js.map +1 -1
  137. package/package.json +6 -6
@@ -0,0 +1,96 @@
1
+ import IncidentPublicNote from "../../Models/DatabaseModels/IncidentPublicNote";
2
+ import File from "../../Models/DatabaseModels/File";
3
+ import NotFoundException from "../../Types/Exception/NotFoundException";
4
+ import ObjectID from "../../Types/ObjectID";
5
+ import IncidentPublicNoteService, {
6
+ Service as IncidentPublicNoteServiceType,
7
+ } from "../Services/IncidentPublicNoteService";
8
+ import Response from "../Utils/Response";
9
+ import BaseAPI from "./BaseAPI";
10
+ import UserMiddleware from "../Middleware/UserAuthorization";
11
+ import {
12
+ ExpressRequest,
13
+ ExpressResponse,
14
+ NextFunction,
15
+ } from "../Utils/Express";
16
+ import CommonAPI from "./CommonAPI";
17
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
18
+
19
+ export default class IncidentPublicNoteAPI extends BaseAPI<
20
+ IncidentPublicNote,
21
+ IncidentPublicNoteServiceType
22
+ > {
23
+ public constructor() {
24
+ super(IncidentPublicNote, IncidentPublicNoteService);
25
+
26
+ this.router.get(
27
+ `${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
28
+ UserMiddleware.getUserMiddleware,
29
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
30
+ try {
31
+ await this.getAttachment(req, res);
32
+ } catch (err) {
33
+ next(err);
34
+ }
35
+ },
36
+ );
37
+ }
38
+
39
+ private async getAttachment(
40
+ req: ExpressRequest,
41
+ res: ExpressResponse,
42
+ ): Promise<void> {
43
+ const noteIdParam: string | undefined = req.params["noteId"];
44
+ const fileIdParam: string | undefined = req.params["fileId"];
45
+
46
+ if (!noteIdParam || !fileIdParam) {
47
+ throw new NotFoundException("Attachment not found");
48
+ }
49
+
50
+ let noteId: ObjectID;
51
+ let fileId: ObjectID;
52
+
53
+ try {
54
+ noteId = new ObjectID(noteIdParam);
55
+ fileId = new ObjectID(fileIdParam);
56
+ } catch {
57
+ throw new NotFoundException("Attachment not found");
58
+ }
59
+
60
+ const props: DatabaseCommonInteractionProps =
61
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
62
+
63
+ const note: IncidentPublicNote | null = await this.service.findOneBy({
64
+ query: {
65
+ _id: noteId,
66
+ },
67
+ select: {
68
+ attachments: {
69
+ _id: true,
70
+ file: true,
71
+ fileType: true,
72
+ name: true,
73
+ },
74
+ },
75
+ props,
76
+ });
77
+
78
+ const attachment: File | undefined = note?.attachments?.find(
79
+ (file: File) => {
80
+ const attachmentId: string | null = file._id
81
+ ? file._id.toString()
82
+ : file.id
83
+ ? file.id.toString()
84
+ : null;
85
+ return attachmentId === fileId.toString();
86
+ },
87
+ );
88
+
89
+ if (!attachment || !attachment.file) {
90
+ throw new NotFoundException("Attachment not found");
91
+ }
92
+
93
+ Response.setNoCacheHeaders(res);
94
+ return Response.sendFileResponse(req, res, attachment);
95
+ }
96
+ }
@@ -0,0 +1,100 @@
1
+ import ScheduledMaintenanceInternalNote from "../../Models/DatabaseModels/ScheduledMaintenanceInternalNote";
2
+ import File from "../../Models/DatabaseModels/File";
3
+ import NotFoundException from "../../Types/Exception/NotFoundException";
4
+ import ObjectID from "../../Types/ObjectID";
5
+ import ScheduledMaintenanceInternalNoteService, {
6
+ Service as ScheduledMaintenanceInternalNoteServiceType,
7
+ } from "../Services/ScheduledMaintenanceInternalNoteService";
8
+ import Response from "../Utils/Response";
9
+ import BaseAPI from "./BaseAPI";
10
+ import UserMiddleware from "../Middleware/UserAuthorization";
11
+ import CommonAPI from "./CommonAPI";
12
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
13
+ import {
14
+ ExpressRequest,
15
+ ExpressResponse,
16
+ NextFunction,
17
+ } from "../Utils/Express";
18
+
19
+ export default class ScheduledMaintenanceInternalNoteAPI extends BaseAPI<
20
+ ScheduledMaintenanceInternalNote,
21
+ ScheduledMaintenanceInternalNoteServiceType
22
+ > {
23
+ public constructor() {
24
+ super(
25
+ ScheduledMaintenanceInternalNote,
26
+ ScheduledMaintenanceInternalNoteService,
27
+ );
28
+
29
+ this.router.get(
30
+ `${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
31
+ UserMiddleware.getUserMiddleware,
32
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
33
+ try {
34
+ await this.getAttachment(req, res);
35
+ } catch (err) {
36
+ next(err);
37
+ }
38
+ },
39
+ );
40
+ }
41
+
42
+ private async getAttachment(
43
+ req: ExpressRequest,
44
+ res: ExpressResponse,
45
+ ): Promise<void> {
46
+ const noteIdParam: string | undefined = req.params["noteId"];
47
+ const fileIdParam: string | undefined = req.params["fileId"];
48
+
49
+ if (!noteIdParam || !fileIdParam) {
50
+ throw new NotFoundException("Attachment not found");
51
+ }
52
+
53
+ let noteId: ObjectID;
54
+ let fileId: ObjectID;
55
+
56
+ try {
57
+ noteId = new ObjectID(noteIdParam);
58
+ fileId = new ObjectID(fileIdParam);
59
+ } catch {
60
+ throw new NotFoundException("Attachment not found");
61
+ }
62
+
63
+ const props: DatabaseCommonInteractionProps =
64
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
65
+
66
+ const note: ScheduledMaintenanceInternalNote | null =
67
+ await this.service.findOneBy({
68
+ query: {
69
+ _id: noteId,
70
+ },
71
+ select: {
72
+ attachments: {
73
+ _id: true,
74
+ file: true,
75
+ fileType: true,
76
+ name: true,
77
+ },
78
+ },
79
+ props,
80
+ });
81
+
82
+ const attachment: File | undefined = note?.attachments?.find(
83
+ (file: File) => {
84
+ const attachmentId: string | null = file._id
85
+ ? file._id.toString()
86
+ : file.id
87
+ ? file.id.toString()
88
+ : null;
89
+ return attachmentId === fileId.toString();
90
+ },
91
+ );
92
+
93
+ if (!attachment || !attachment.file) {
94
+ throw new NotFoundException("Attachment not found");
95
+ }
96
+
97
+ Response.setNoCacheHeaders(res);
98
+ return Response.sendFileResponse(req, res, attachment);
99
+ }
100
+ }
@@ -0,0 +1,100 @@
1
+ import ScheduledMaintenancePublicNote from "../../Models/DatabaseModels/ScheduledMaintenancePublicNote";
2
+ import File from "../../Models/DatabaseModels/File";
3
+ import NotFoundException from "../../Types/Exception/NotFoundException";
4
+ import ObjectID from "../../Types/ObjectID";
5
+ import ScheduledMaintenancePublicNoteService, {
6
+ Service as ScheduledMaintenancePublicNoteServiceType,
7
+ } from "../Services/ScheduledMaintenancePublicNoteService";
8
+ import Response from "../Utils/Response";
9
+ import BaseAPI from "./BaseAPI";
10
+ import UserMiddleware from "../Middleware/UserAuthorization";
11
+ import {
12
+ ExpressRequest,
13
+ ExpressResponse,
14
+ NextFunction,
15
+ } from "../Utils/Express";
16
+ import CommonAPI from "./CommonAPI";
17
+ import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
18
+
19
+ export default class ScheduledMaintenancePublicNoteAPI extends BaseAPI<
20
+ ScheduledMaintenancePublicNote,
21
+ ScheduledMaintenancePublicNoteServiceType
22
+ > {
23
+ public constructor() {
24
+ super(
25
+ ScheduledMaintenancePublicNote,
26
+ ScheduledMaintenancePublicNoteService,
27
+ );
28
+
29
+ this.router.get(
30
+ `${new this.entityType().getCrudApiPath()?.toString()}/attachment/:projectId/:noteId/:fileId`,
31
+ UserMiddleware.getUserMiddleware,
32
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
33
+ try {
34
+ await this.getAttachment(req, res);
35
+ } catch (err) {
36
+ next(err);
37
+ }
38
+ },
39
+ );
40
+ }
41
+
42
+ private async getAttachment(
43
+ req: ExpressRequest,
44
+ res: ExpressResponse,
45
+ ): Promise<void> {
46
+ const noteIdParam: string | undefined = req.params["noteId"];
47
+ const fileIdParam: string | undefined = req.params["fileId"];
48
+
49
+ if (!noteIdParam || !fileIdParam) {
50
+ throw new NotFoundException("Attachment not found");
51
+ }
52
+
53
+ let noteId: ObjectID;
54
+ let fileId: ObjectID;
55
+
56
+ try {
57
+ noteId = new ObjectID(noteIdParam);
58
+ fileId = new ObjectID(fileIdParam);
59
+ } catch {
60
+ throw new NotFoundException("Attachment not found");
61
+ }
62
+
63
+ const props: DatabaseCommonInteractionProps =
64
+ await CommonAPI.getDatabaseCommonInteractionProps(req);
65
+
66
+ const note: ScheduledMaintenancePublicNote | null =
67
+ await this.service.findOneBy({
68
+ query: {
69
+ _id: noteId,
70
+ },
71
+ select: {
72
+ attachments: {
73
+ _id: true,
74
+ file: true,
75
+ fileType: true,
76
+ name: true,
77
+ },
78
+ },
79
+ props,
80
+ });
81
+
82
+ const attachment: File | undefined = note?.attachments?.find(
83
+ (file: File) => {
84
+ const attachmentId: string | null = file._id
85
+ ? file._id.toString()
86
+ : file.id
87
+ ? file.id.toString()
88
+ : null;
89
+ return attachmentId === fileId.toString();
90
+ },
91
+ );
92
+
93
+ if (!attachment || !attachment.file) {
94
+ throw new NotFoundException("Attachment not found");
95
+ }
96
+
97
+ Response.setNoCacheHeaders(res);
98
+ return Response.sendFileResponse(req, res, attachment);
99
+ }
100
+ }