@oneuptime/common 7.0.3018 → 7.0.3026

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 (85) hide show
  1. package/Models/DatabaseModels/BillingInvoice.ts +33 -0
  2. package/Models/DatabaseModels/CopilotAction.ts +32 -0
  3. package/Models/DatabaseModels/CopilotActionTypePriority.ts +18 -3
  4. package/Models/DatabaseModels/CopilotPullRequest.ts +1 -0
  5. package/Models/DatabaseModels/StatusPageAnnouncement.ts +2 -2
  6. package/Server/API/CopilotActionAPI.ts +186 -1
  7. package/Server/API/StatusPageAPI.ts +2 -2
  8. package/Server/API/TelemetryAPI.ts +1 -1
  9. package/Server/Infrastructure/Postgres/SchemaMigrations/1725551629492-MigrationName.ts +17 -0
  10. package/Server/Infrastructure/Postgres/SchemaMigrations/1725556630384-MigrationName.ts +29 -0
  11. package/Server/Infrastructure/Postgres/SchemaMigrations/1725618842598-MigrationName.ts +17 -0
  12. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +6 -0
  13. package/Server/Services/BillingInvoiceService.ts +2 -0
  14. package/Server/Services/BillingService.ts +29 -10
  15. package/Server/Services/CopilotCodeRepositoryService.ts +36 -0
  16. package/Server/Services/ServiceCatalogService.ts +1 -1
  17. package/Server/Services/TelemetryServiceService.ts +1 -1
  18. package/Server/Types/Database/Permissions/AccessControlPermission.ts +1 -1
  19. package/Server/Utils/CodeRepository/CodeRepository.ts +1 -0
  20. package/Server/Utils/CodeRepository/CodeRepositoryFile.ts +1 -0
  21. package/Server/Utils/Telemetry.ts +4 -6
  22. package/Tests/Server/Services/BillingService.test.ts +5 -0
  23. package/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +2 -0
  24. package/Tests/Types/ArrayUtil.test.ts +1 -1
  25. package/Types/Copilot/CopilotActionProps/FileActionProp.ts +4 -2
  26. package/Types/File/MimeType.ts +1 -0
  27. package/UI/Components/Forms/Fields/FormField.tsx +1 -1
  28. package/{Types/ArrayUtil.ts → Utils/Array.ts} +1 -1
  29. package/Utils/CronTime.ts +1 -0
  30. package/build/dist/Models/DatabaseModels/BillingInvoice.js +37 -0
  31. package/build/dist/Models/DatabaseModels/BillingInvoice.js.map +1 -1
  32. package/build/dist/Models/DatabaseModels/CopilotAction.js +34 -0
  33. package/build/dist/Models/DatabaseModels/CopilotAction.js.map +1 -1
  34. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js +18 -3
  35. package/build/dist/Models/DatabaseModels/CopilotActionTypePriority.js.map +1 -1
  36. package/build/dist/Models/DatabaseModels/CopilotPullRequest.js +1 -0
  37. package/build/dist/Models/DatabaseModels/CopilotPullRequest.js.map +1 -1
  38. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js +2 -2
  39. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js.map +1 -1
  40. package/build/dist/Server/API/CopilotActionAPI.js +135 -3
  41. package/build/dist/Server/API/CopilotActionAPI.js.map +1 -1
  42. package/build/dist/Server/API/StatusPageAPI.js +2 -2
  43. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  44. package/build/dist/Server/API/TelemetryAPI.js +1 -1
  45. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  46. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725551629492-MigrationName.js +12 -0
  47. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725551629492-MigrationName.js.map +1 -0
  48. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725556630384-MigrationName.js +16 -0
  49. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725556630384-MigrationName.js.map +1 -0
  50. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725618842598-MigrationName.js +12 -0
  51. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1725618842598-MigrationName.js.map +1 -0
  52. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +6 -0
  53. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  54. package/build/dist/Server/Services/BillingInvoiceService.js +2 -0
  55. package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
  56. package/build/dist/Server/Services/BillingService.js +14 -1
  57. package/build/dist/Server/Services/BillingService.js.map +1 -1
  58. package/build/dist/Server/Services/CopilotCodeRepositoryService.js +22 -0
  59. package/build/dist/Server/Services/CopilotCodeRepositoryService.js.map +1 -1
  60. package/build/dist/Server/Services/ServiceCatalogService.js +1 -1
  61. package/build/dist/Server/Services/ServiceCatalogService.js.map +1 -1
  62. package/build/dist/Server/Services/TelemetryServiceService.js +1 -1
  63. package/build/dist/Server/Services/TelemetryServiceService.js.map +1 -1
  64. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js +1 -1
  65. package/build/dist/Server/Types/Database/Permissions/AccessControlPermission.js.map +1 -1
  66. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +1 -0
  67. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  68. package/build/dist/Server/Utils/Telemetry.js +5 -3
  69. package/build/dist/Server/Utils/Telemetry.js.map +1 -1
  70. package/build/dist/Tests/Server/Services/BillingService.test.js +4 -0
  71. package/build/dist/Tests/Server/Services/BillingService.test.js.map +1 -1
  72. package/build/dist/Tests/Server/TestingUtils/Services/BillingServiceHelper.js +2 -0
  73. package/build/dist/Tests/Server/TestingUtils/Services/BillingServiceHelper.js.map +1 -1
  74. package/build/dist/Tests/Types/ArrayUtil.test.js +1 -1
  75. package/build/dist/Tests/Types/ArrayUtil.test.js.map +1 -1
  76. package/build/dist/Types/File/MimeType.js +1 -0
  77. package/build/dist/Types/File/MimeType.js.map +1 -1
  78. package/build/dist/UI/Components/Forms/Fields/FormField.js +1 -1
  79. package/build/dist/UI/Components/Forms/Fields/FormField.js.map +1 -1
  80. package/build/dist/{Types/ArrayUtil.js → Utils/Array.js} +1 -1
  81. package/build/dist/Utils/Array.js.map +1 -0
  82. package/build/dist/Utils/CronTime.js +1 -0
  83. package/build/dist/Utils/CronTime.js.map +1 -1
  84. package/package.json +2 -2
  85. package/build/dist/Types/ArrayUtil.js.map +0 -1
@@ -336,4 +336,37 @@ export default class BillingInvoice extends BaseModel {
336
336
  unique: false,
337
337
  })
338
338
  public paymentProviderInvoiceId?: string = undefined;
339
+
340
+ @ColumnAccessControl({
341
+ create: [],
342
+ read: [
343
+ Permission.ProjectOwner,
344
+ Permission.ProjectAdmin,
345
+ Permission.ReadInvoices,
346
+ ],
347
+ update: [],
348
+ })
349
+ @TableColumn({ type: TableColumnType.Date })
350
+ @Column({
351
+ type: ColumnType.Date,
352
+ nullable: true,
353
+ })
354
+ public invoiceDate?: Date = undefined;
355
+
356
+ @ColumnAccessControl({
357
+ create: [],
358
+ read: [
359
+ Permission.ProjectOwner,
360
+ Permission.ProjectAdmin,
361
+ Permission.ReadInvoices,
362
+ ],
363
+ update: [],
364
+ })
365
+ @TableColumn({ type: TableColumnType.LongText })
366
+ @Column({
367
+ type: ColumnType.LongText,
368
+ length: ColumnLength.LongText,
369
+ nullable: true,
370
+ })
371
+ public invoiceNumber?: string = undefined;
339
372
  }
@@ -736,4 +736,36 @@ export default class CopilotAction extends BaseModel {
736
736
  default: false,
737
737
  })
738
738
  public isPriority?: string = undefined;
739
+
740
+ @ColumnAccessControl({
741
+ create: [
742
+ Permission.ProjectOwner,
743
+ Permission.ProjectAdmin,
744
+ Permission.ProjectMember,
745
+ Permission.CreateCopilotAction,
746
+ ],
747
+ read: [
748
+ Permission.ProjectOwner,
749
+ Permission.ProjectAdmin,
750
+ Permission.ProjectMember,
751
+ Permission.ReadCopilotAction,
752
+ ],
753
+ update: [
754
+ Permission.ProjectOwner,
755
+ Permission.ProjectAdmin,
756
+ Permission.ProjectMember,
757
+ Permission.EditCopilotAction,
758
+ ],
759
+ })
760
+ @TableColumn({
761
+ required: false,
762
+ type: TableColumnType.Date,
763
+ title: "Status Changed at",
764
+ description: "When the status of this action was changed",
765
+ })
766
+ @Column({
767
+ nullable: true,
768
+ type: ColumnType.Date,
769
+ })
770
+ public statusChangedAt?: Date = undefined;
739
771
  }
@@ -25,15 +25,30 @@ import ColumnLength from "../../Types/Database/ColumnLength";
25
25
  @EnableDocumentation()
26
26
  @TenantColumn("projectId")
27
27
  @TableAccessControl({
28
- create: [],
28
+ create: [
29
+ Permission.ProjectOwner,
30
+ Permission.ProjectAdmin,
31
+ Permission.ProjectMember,
32
+ Permission.CreateCopilotAction,
33
+ ],
29
34
  read: [
30
35
  Permission.ProjectOwner,
31
36
  Permission.ProjectAdmin,
32
37
  Permission.ProjectMember,
33
38
  Permission.ReadCopilotAction,
34
39
  ],
35
- delete: [],
36
- update: [],
40
+ delete: [
41
+ Permission.ProjectOwner,
42
+ Permission.ProjectAdmin,
43
+ Permission.ProjectMember,
44
+ Permission.DeleteCopilotAction,
45
+ ],
46
+ update: [
47
+ Permission.ProjectOwner,
48
+ Permission.ProjectAdmin,
49
+ Permission.ProjectMember,
50
+ Permission.EditCopilotAction,
51
+ ],
37
52
  })
38
53
  @EnableWorkflow({
39
54
  create: true,
@@ -411,6 +411,7 @@ export default class CopilotPullRequest extends BaseModel {
411
411
  type: TableColumnType.ShortText,
412
412
  required: false,
413
413
  isDefaultValueColumn: false,
414
+ canReadOnRelationQuery: true,
414
415
  title: "Pull Request ID",
415
416
  description:
416
417
  "ID of Pull Request in the repository where this event was executed and then PR was created.",
@@ -260,7 +260,7 @@ export default class StatusPageAnnouncement extends BaseModel {
260
260
  @TableColumn({
261
261
  title: "End At",
262
262
  type: TableColumnType.Date,
263
- required: true,
263
+ required: false,
264
264
  description: "When should this announcement hidden?",
265
265
  })
266
266
  @ColumnAccessControl({
@@ -284,7 +284,7 @@ export default class StatusPageAnnouncement extends BaseModel {
284
284
  ],
285
285
  })
286
286
  @Column({
287
- nullable: false,
287
+ nullable: true,
288
288
  type: ColumnType.Date,
289
289
  })
290
290
  public endAnnouncementAt?: Date = undefined;
@@ -19,6 +19,10 @@ import CopilotActionStatus from "../../Types/Copilot/CopilotActionStatus";
19
19
  import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
20
20
  import CopilotActionTypePriorityService from "../Services/CopilotActionTypePriorityService";
21
21
  import SortOrder from "../../Types/BaseDatabase/SortOrder";
22
+ import JSONFunctions from "../../Types/JSONFunctions";
23
+ import CopilotActionType from "../../Types/Copilot/CopilotActionType";
24
+ import { JSONObject } from "../../Types/JSON";
25
+ import OneUptimeDate from "../../Types/Date";
22
26
 
23
27
  export default class CopilotActionAPI extends BaseAPI<
24
28
  CopilotAction,
@@ -142,6 +146,7 @@ export default class CopilotActionAPI extends BaseAPI<
142
146
  serviceCatalogId: true,
143
147
  copilotActionStatus: true,
144
148
  copilotActionType: true,
149
+ copilotActionProp: true,
145
150
  createdAt: true,
146
151
  copilotPullRequest: {
147
152
  _id: true,
@@ -168,10 +173,96 @@ export default class CopilotActionAPI extends BaseAPI<
168
173
  },
169
174
  );
170
175
 
176
+ this.router.get(
177
+ `${new this.entityType()
178
+ .getCrudApiPath()
179
+ ?.toString()}/get-copilot-action/:secretkey`,
180
+ CodeRepositoryAuthorization.isAuthorizedRepository,
181
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
182
+ try {
183
+ const secretkey: string = req.params["secretkey"]!;
184
+
185
+ if (!secretkey) {
186
+ throw new BadDataException("Secret key is required");
187
+ }
188
+
189
+ const serviceCatalogId: string = req.body["serviceCatalogId"]!;
190
+
191
+ if (!serviceCatalogId) {
192
+ throw new BadDataException("Service catalog id is required");
193
+ }
194
+
195
+ const codeRepository: CopilotCodeRepository | null =
196
+ await CopilotCodeRepositoryService.findOneBy({
197
+ query: {
198
+ secretToken: new ObjectID(secretkey),
199
+ },
200
+ select: {
201
+ _id: true,
202
+ },
203
+ props: {
204
+ isRoot: true,
205
+ },
206
+ });
207
+
208
+ if (!codeRepository) {
209
+ throw new BadDataException(
210
+ "Code repository not found. Secret key is invalid.",
211
+ );
212
+ }
213
+
214
+ const actionType: CopilotActionType = req.body["actionType"]!;
215
+
216
+ if (!actionType) {
217
+ throw new BadDataException("Action type is required");
218
+ }
219
+
220
+ const actionProps: JSONObject = req.body["actionProps"]!;
221
+
222
+ const copilotAction: CopilotAction | null =
223
+ await CopilotActionService.findOneBy({
224
+ query: {
225
+ codeRepositoryId: codeRepository.id!,
226
+ serviceCatalogId: new ObjectID(serviceCatalogId),
227
+ copilotActionType: actionType,
228
+ copilotActionProp: actionProps as any,
229
+ },
230
+ select: {
231
+ _id: true,
232
+ codeRepositoryId: true,
233
+ serviceCatalogId: true,
234
+ copilotActionStatus: true,
235
+ copilotActionType: true,
236
+ createdAt: true,
237
+ copilotPullRequest: {
238
+ _id: true,
239
+ pullRequestId: true,
240
+ copilotPullRequestStatus: true,
241
+ },
242
+ },
243
+ sort: {
244
+ createdAt: SortOrder.Descending,
245
+ },
246
+ props: {
247
+ isRoot: true,
248
+ },
249
+ });
250
+
251
+ return Response.sendJsonObjectResponse(req, res, {
252
+ copilotAction: copilotAction
253
+ ? CopilotAction.toJSONObject(copilotAction, CopilotAction)
254
+ : null,
255
+ });
256
+ } catch (err) {
257
+ next(err);
258
+ }
259
+ },
260
+ );
261
+
171
262
  this.router.post(
172
263
  `${new this.entityType()
173
264
  .getCrudApiPath()
174
- ?.toString()}/queue-copilot-action/:secretkey`,
265
+ ?.toString()}/create-copilot-action/:secretkey`,
175
266
  CodeRepositoryAuthorization.isAuthorizedRepository,
176
267
  async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
177
268
  try {
@@ -229,5 +320,99 @@ export default class CopilotActionAPI extends BaseAPI<
229
320
  }
230
321
  },
231
322
  );
323
+
324
+ this.router.post(
325
+ `${new this.entityType()
326
+ .getCrudApiPath()
327
+ ?.toString()}/update-copilot-action/:secretkey`,
328
+ CodeRepositoryAuthorization.isAuthorizedRepository,
329
+ async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
330
+ try {
331
+ const secretkey: string = req.params["secretkey"]!;
332
+
333
+ if (!secretkey) {
334
+ throw new BadDataException("Secret key is required");
335
+ }
336
+
337
+ const codeRepository: CopilotCodeRepository | null =
338
+ await CopilotCodeRepositoryService.findOneBy({
339
+ query: {
340
+ secretToken: new ObjectID(secretkey),
341
+ },
342
+ select: {
343
+ _id: true,
344
+ projectId: true,
345
+ },
346
+ props: {
347
+ isRoot: true,
348
+ },
349
+ });
350
+
351
+ if (!codeRepository) {
352
+ throw new BadDataException(
353
+ "Code repository not found. Secret key is invalid.",
354
+ );
355
+ }
356
+
357
+ req.body = JSONFunctions.deserialize(req.body);
358
+
359
+ const {
360
+ actionStatus,
361
+ pullRequestId,
362
+ commitHash,
363
+ statusMessage,
364
+ logs,
365
+ actionId,
366
+ }: {
367
+ actionStatus: CopilotActionStatus;
368
+ pullRequestId?: ObjectID | undefined;
369
+ commitHash?: string | undefined;
370
+ statusMessage?: string | undefined;
371
+ logs?: Array<string> | undefined;
372
+ actionId: ObjectID;
373
+ } = req.body;
374
+
375
+ const exisingAction: CopilotAction | null =
376
+ await CopilotActionService.findOneBy({
377
+ query: {
378
+ _id: actionId,
379
+ codeRepositoryId: codeRepository.id!,
380
+ },
381
+ select: {
382
+ _id: true,
383
+ },
384
+ props: {
385
+ isRoot: true,
386
+ },
387
+ });
388
+
389
+ if (!exisingAction) {
390
+ throw new BadDataException("Action not found");
391
+ }
392
+
393
+ await CopilotActionService.updateOneBy({
394
+ query: {
395
+ _id: actionId,
396
+ codeRepositoryId: codeRepository.id!,
397
+ },
398
+ data: {
399
+ copilotActionStatus: actionStatus!,
400
+ copilotPullRequestId: pullRequestId!,
401
+ commitHash: commitHash!,
402
+ statusMessage: statusMessage!,
403
+ statusChangedAt: OneUptimeDate.getCurrentDate(),
404
+ logs: logs?.join("\n") || "",
405
+ },
406
+ props: {
407
+ isRoot: true,
408
+ },
409
+ });
410
+
411
+ return Response.sendEmptySuccessResponse(req, res);
412
+ } catch (err) {
413
+ next(err);
414
+ }
415
+ },
416
+ );
232
417
  }
233
418
  }
@@ -36,7 +36,7 @@ import Response from "../Utils/Response";
36
36
  import BaseAPI from "./BaseAPI";
37
37
  import CommonAPI from "./CommonAPI";
38
38
  import BaseModel from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
39
- import ArrayUtil from "Common/Types/ArrayUtil";
39
+ import ArrayUtil from "Common/Utils/Array";
40
40
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
41
41
  import SortOrder from "Common/Types/BaseDatabase/SortOrder";
42
42
  import { LIMIT_PER_PROJECT } from "Common/Types/Database/LimitMax";
@@ -840,7 +840,7 @@ export default class StatusPageAPI extends BaseAPI<
840
840
  query: {
841
841
  statusPages: objectId as any,
842
842
  showAnnouncementAt: QueryHelper.lessThan(today),
843
- endAnnouncementAt: QueryHelper.greaterThan(today),
843
+ endAnnouncementAt: QueryHelper.greaterThanOrNull(today),
844
844
  projectId: statusPage.projectId!,
845
845
  },
846
846
  select: {
@@ -11,7 +11,7 @@ import CommonAPI from "./CommonAPI";
11
11
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
12
12
  import TelemetryType from "Common/Types/Telemetry/TelemetryType";
13
13
  import TelemetryAttributeService from "../Services/TelemetryAttributeService";
14
- import ArrayUtil from "Common/Types/ArrayUtil";
14
+ import ArrayUtil from "Common/Utils/Array";
15
15
 
16
16
  const router: ExpressRouter = Express.getRouter();
17
17
 
@@ -0,0 +1,17 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725551629492 implements MigrationInterface {
4
+ public name = "MigrationName1725551629492";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "CopilotAction" DROP COLUMN "filePath"`,
9
+ );
10
+ }
11
+
12
+ public async down(queryRunner: QueryRunner): Promise<void> {
13
+ await queryRunner.query(
14
+ `ALTER TABLE "CopilotAction" ADD "filePath" character varying NOT NULL`,
15
+ );
16
+ }
17
+ }
@@ -0,0 +1,29 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725556630384 implements MigrationInterface {
4
+ public name = "MigrationName1725556630384";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "BillingInvoice" ADD "invoiceDate" TIMESTAMP WITH TIME ZONE`,
9
+ );
10
+ await queryRunner.query(
11
+ `ALTER TABLE "BillingInvoice" ADD "invoiceNumber" character varying(500)`,
12
+ );
13
+ await queryRunner.query(
14
+ `ALTER TABLE "CopilotAction" ADD "statusChangedAt" TIMESTAMP WITH TIME ZONE`,
15
+ );
16
+ }
17
+
18
+ public async down(queryRunner: QueryRunner): Promise<void> {
19
+ await queryRunner.query(
20
+ `ALTER TABLE "CopilotAction" DROP COLUMN "statusChangedAt"`,
21
+ );
22
+ await queryRunner.query(
23
+ `ALTER TABLE "BillingInvoice" DROP COLUMN "invoiceNumber"`,
24
+ );
25
+ await queryRunner.query(
26
+ `ALTER TABLE "BillingInvoice" DROP COLUMN "invoiceDate"`,
27
+ );
28
+ }
29
+ }
@@ -0,0 +1,17 @@
1
+ import { MigrationInterface, QueryRunner } from "typeorm";
2
+
3
+ export class MigrationName1725618842598 implements MigrationInterface {
4
+ public name = "MigrationName1725618842598";
5
+
6
+ public async up(queryRunner: QueryRunner): Promise<void> {
7
+ await queryRunner.query(
8
+ `ALTER TABLE "StatusPageAnnouncement" ALTER COLUMN "endAnnouncementAt" DROP NOT NULL`,
9
+ );
10
+ }
11
+
12
+ public async down(queryRunner: QueryRunner): Promise<void> {
13
+ await queryRunner.query(
14
+ `ALTER TABLE "StatusPageAnnouncement" ALTER COLUMN "endAnnouncementAt" SET NOT NULL`,
15
+ );
16
+ }
17
+ }
@@ -48,6 +48,9 @@ import { MigrationName1725291476867 } from "./1725291476867-MigrationName";
48
48
  import { MigrationName1725357719072 } from "./1725357719072-MigrationName";
49
49
  import { MigrationName1725360199561 } from "./1725360199561-MigrationName";
50
50
  import { MigrationName1725379949648 } from "./1725379949648-MigrationName";
51
+ import { MigrationName1725551629492 } from "./1725551629492-MigrationName";
52
+ import { MigrationName1725556630384 } from "./1725556630384-MigrationName";
53
+ import { MigrationName1725618842598 } from "./1725618842598-MigrationName";
51
54
 
52
55
  export default [
53
56
  InitialMigration,
@@ -100,4 +103,7 @@ export default [
100
103
  MigrationName1725357719072,
101
104
  MigrationName1725360199561,
102
105
  MigrationName1725379949648,
106
+ MigrationName1725551629492,
107
+ MigrationName1725556630384,
108
+ MigrationName1725618842598,
103
109
  ];
@@ -77,6 +77,8 @@ export class Service extends DatabaseService<Model> {
77
77
  billingInvoice.status =
78
78
  (invoice.status as InvoiceStatus) || InvoiceStatus.Undefined;
79
79
  billingInvoice.paymentProviderInvoiceId = invoice.id;
80
+ billingInvoice.invoiceDate = invoice.invoiceDate;
81
+ billingInvoice.invoiceNumber = invoice.invoiceNumber || "Unknown";
80
82
 
81
83
  await this.create({
82
84
  data: billingInvoice,
@@ -35,6 +35,8 @@ export interface Invoice {
35
35
  status: string;
36
36
  downloadableLink: string;
37
37
  customerId: string | undefined;
38
+ invoiceDate: Date;
39
+ invoiceNumber: string | undefined;
38
40
  }
39
41
 
40
42
  export class BillingService extends BaseService {
@@ -693,17 +695,30 @@ export class BillingService extends BaseService {
693
695
  limit: 100,
694
696
  });
695
697
 
696
- return invoices.data.map((invoice: Stripe.Invoice) => {
697
- return {
698
- id: invoice.id!,
699
- amount: invoice.amount_due,
700
- currencyCode: invoice.currency,
701
- subscriptionId: invoice.subscription?.toString() || undefined,
702
- status: invoice.status?.toString() || "Unknown",
703
- downloadableLink: invoice.invoice_pdf?.toString() || "",
704
- customerId: invoice.customer?.toString() || "",
705
- };
698
+ let billingInvoices: Array<Invoice> = invoices.data.map(
699
+ (invoice: Stripe.Invoice) => {
700
+ return {
701
+ id: invoice.id!,
702
+ amount: invoice.amount_due,
703
+ currencyCode: invoice.currency,
704
+ subscriptionId: invoice.subscription?.toString() || undefined,
705
+ status: invoice.status?.toString() || "Unknown",
706
+ downloadableLink: invoice.invoice_pdf?.toString() || "",
707
+ customerId: invoice.customer?.toString() || "",
708
+ invoiceDate: invoice.created
709
+ ? new Date(invoice.created * 1000)
710
+ : OneUptimeDate.getCurrentDate(),
711
+ invoiceNumber: invoice.number || undefined,
712
+ };
713
+ },
714
+ );
715
+
716
+ // sort by date in descending order.
717
+ billingInvoices = billingInvoices.sort((a: Invoice, b: Invoice) => {
718
+ return a.invoiceDate.getTime() - b.invoiceDate.getTime();
706
719
  });
720
+
721
+ return billingInvoices;
707
722
  }
708
723
 
709
724
  public async generateInvoiceAndChargeCustomer(
@@ -770,6 +785,10 @@ export class BillingService extends BaseService {
770
785
  status: invoice.status?.toString() || "Unknown",
771
786
  downloadableLink: invoice.invoice_pdf?.toString() || "",
772
787
  customerId: invoice.customer?.toString() || "",
788
+ invoiceDate: invoice.created
789
+ ? new Date(invoice.created * 1000)
790
+ : OneUptimeDate.getCurrentDate(),
791
+ invoiceNumber: invoice.number || undefined,
773
792
  };
774
793
  }
775
794
 
@@ -3,6 +3,12 @@ import { OnCreate } from "../Types/Database/Hooks";
3
3
  import DatabaseService from "./DatabaseService";
4
4
  import ObjectID from "../../Types/ObjectID";
5
5
  import Model from "Common/Models/DatabaseModels/CopilotCodeRepository";
6
+ import {
7
+ CopilotActionTypeData,
8
+ CopilotActionTypeUtil,
9
+ } from "../../Types/Copilot/CopilotActionType";
10
+ import CopilotActionTypePriority from "../../Models/DatabaseModels/CopilotActionTypePriority";
11
+ import CopilotActionTypePriorityService from "./CopilotActionTypePriorityService";
6
12
 
7
13
  export class Service extends DatabaseService<Model> {
8
14
  public constructor() {
@@ -19,6 +25,36 @@ export class Service extends DatabaseService<Model> {
19
25
  createBy: createBy,
20
26
  };
21
27
  }
28
+
29
+ protected override async onCreateSuccess(
30
+ _onCreate: OnCreate<Model>,
31
+ createdItem: Model,
32
+ ): Promise<Model> {
33
+ // add all the actions.
34
+
35
+ const repo: Model = createdItem;
36
+
37
+ const defaultCopilotActionTypes: Array<CopilotActionTypeData> =
38
+ CopilotActionTypeUtil.getAllCopilotActionTypes();
39
+
40
+ for (const defaultAction of defaultCopilotActionTypes) {
41
+ const copilotActionTypePriority: CopilotActionTypePriority =
42
+ new CopilotActionTypePriority();
43
+ copilotActionTypePriority.projectId = repo.projectId!;
44
+ copilotActionTypePriority.actionType = defaultAction.type;
45
+ copilotActionTypePriority.priority = defaultAction.defaultPriority;
46
+ copilotActionTypePriority.codeRepositoryId = repo.id!;
47
+
48
+ await CopilotActionTypePriorityService.create({
49
+ data: copilotActionTypePriority,
50
+ props: {
51
+ isRoot: true,
52
+ },
53
+ });
54
+ }
55
+
56
+ return createdItem;
57
+ }
22
58
  }
23
59
 
24
60
  export default new Service();
@@ -1,7 +1,7 @@
1
1
  import CreateBy from "../Types/Database/CreateBy";
2
2
  import { OnCreate } from "../Types/Database/Hooks";
3
3
  import DatabaseService from "./DatabaseService";
4
- import ArrayUtil from "../../Types/ArrayUtil";
4
+ import ArrayUtil from "../../Utils/Array";
5
5
  import { BrightColors } from "../../Types/BrandColors";
6
6
  import Model from "Common/Models/DatabaseModels/ServiceCatalog";
7
7
 
@@ -1,7 +1,7 @@
1
1
  import CreateBy from "../Types/Database/CreateBy";
2
2
  import { OnCreate } from "../Types/Database/Hooks";
3
3
  import DatabaseService from "./DatabaseService";
4
- import ArrayUtil from "../../Types/ArrayUtil";
4
+ import ArrayUtil from "../../Utils/Array";
5
5
  import { BrightColors } from "../../Types/BrandColors";
6
6
  import BadDataException from "../../Types/Exception/BadDataException";
7
7
  import ObjectID from "../../Types/ObjectID";
@@ -6,7 +6,7 @@ import AccessControlModel from "Common/Models/DatabaseModels/DatabaseBaseModel/A
6
6
  import BaseModel, {
7
7
  DatabaseBaseModelType,
8
8
  } from "Common/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
9
- import ArrayUtil from "Common/Types/ArrayUtil";
9
+ import ArrayUtil from "Common/Utils/Array";
10
10
  import { ColumnAccessControl } from "Common/Types/BaseDatabase/AccessControl";
11
11
  import DatabaseCommonInteractionProps from "Common/Types/BaseDatabase/DatabaseCommonInteractionProps";
12
12
  import DatabaseCommonInteractionPropsUtil, {
@@ -381,6 +381,7 @@ export default class CodeRepositoryUtil {
381
381
  filePath: LocalFile.sanitizeFilePath(`${directoryPath}/${fileName}`),
382
382
  repoPath,
383
383
  }),
384
+ filePath: filePath,
384
385
  };
385
386
  }
386
387
 
@@ -1,3 +1,4 @@
1
1
  export default interface CodeRepositoryFile {
2
2
  fileContent: string;
3
+ filePath: string;
3
4
  }
@@ -18,10 +18,8 @@ import { CompressionAlgorithm } from "@opentelemetry/otlp-exporter-base";
18
18
  import { Resource } from "@opentelemetry/resources";
19
19
  import {
20
20
  BatchLogRecordProcessor,
21
- ConsoleLogRecordExporter,
22
21
  LoggerProvider,
23
22
  LogRecordProcessor,
24
- SimpleLogRecordProcessor,
25
23
  } from "@opentelemetry/sdk-logs";
26
24
  import {
27
25
  MeterProvider,
@@ -167,9 +165,7 @@ export default class Telemetry {
167
165
  }),
168
166
  });
169
167
 
170
- let logRecordProcessor: LogRecordProcessor = new SimpleLogRecordProcessor(
171
- new ConsoleLogRecordExporter(),
172
- );
168
+ let logRecordProcessor: LogRecordProcessor | null = null;
173
169
 
174
170
  if (this.getOltpLogsEndpoint() && hasHeaders) {
175
171
  const logExporter: OTLPLogExporter = new OTLPLogExporter({
@@ -181,7 +177,9 @@ export default class Telemetry {
181
177
  logRecordProcessor = new BatchLogRecordProcessor(logExporter);
182
178
  }
183
179
 
184
- this.loggerProvider.addLogRecordProcessor(logRecordProcessor);
180
+ if (logRecordProcessor) {
181
+ this.loggerProvider.addLogRecordProcessor(logRecordProcessor);
182
+ }
185
183
 
186
184
  logs.setGlobalLoggerProvider(this.loggerProvider);
187
185