@oneuptime/common 10.0.93 → 10.0.96
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.
- package/Models/DatabaseModels/DockerResource.ts +497 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Models/DatabaseModels/Monitor.ts +83 -0
- package/Server/API/MonitorTemplateAPI.ts +182 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1777933061000-MigrationName.ts +41 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1777972687018-MigrationName.ts +69 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/BillingInvoiceService.ts +18 -29
- package/Server/Services/DockerResourceService.ts +310 -0
- package/Server/Services/MonitorTemplateService.ts +367 -0
- package/Server/Utils/VM/VMRunner.ts +62 -0
- package/Types/Dashboard/DashboardComponentType.ts +13 -0
- package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +16 -0
- package/Types/Dashboard/DashboardComponents/DashboardAlertListComponent.ts +4 -0
- package/Types/Dashboard/DashboardComponents/DashboardDockerContainerListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardDockerHostListComponent.ts +14 -0
- package/Types/Dashboard/DashboardComponents/DashboardDockerImageListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardDockerNetworkListComponent.ts +14 -0
- package/Types/Dashboard/DashboardComponents/DashboardDockerVolumeListComponent.ts +14 -0
- package/Types/Dashboard/DashboardComponents/DashboardIncidentListComponent.ts +4 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesCronJobListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesDaemonSetListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesDeploymentListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesJobListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesNamespaceListComponent.ts +14 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesNodeListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesPodListComponent.ts +16 -0
- package/Types/Dashboard/DashboardComponents/DashboardKubernetesStatefulSetListComponent.ts +15 -0
- package/Types/Dashboard/DashboardComponents/DashboardMonitorListComponent.ts +3 -0
- package/Types/Docker/DockerInventoryExtractor.ts +343 -0
- package/Utils/Dashboard/Components/DashboardAlertListComponent.ts +47 -2
- package/Utils/Dashboard/Components/DashboardDockerContainerListComponent.ts +93 -0
- package/Utils/Dashboard/Components/DashboardDockerHostListComponent.ts +83 -0
- package/Utils/Dashboard/Components/DashboardDockerImageListComponent.ts +92 -0
- package/Utils/Dashboard/Components/DashboardDockerNetworkListComponent.ts +82 -0
- package/Utils/Dashboard/Components/DashboardDockerVolumeListComponent.ts +82 -0
- package/Utils/Dashboard/Components/DashboardIncidentListComponent.ts +47 -2
- package/Utils/Dashboard/Components/DashboardKubernetesCronJobListComponent.ts +36 -0
- package/Utils/Dashboard/Components/DashboardKubernetesDaemonSetListComponent.ts +36 -0
- package/Utils/Dashboard/Components/DashboardKubernetesDeploymentListComponent.ts +36 -0
- package/Utils/Dashboard/Components/DashboardKubernetesJobListComponent.ts +34 -0
- package/Utils/Dashboard/Components/DashboardKubernetesNamespaceListComponent.ts +36 -0
- package/Utils/Dashboard/Components/DashboardKubernetesNodeListComponent.ts +57 -0
- package/Utils/Dashboard/Components/DashboardKubernetesPodListComponent.ts +60 -0
- package/Utils/Dashboard/Components/DashboardKubernetesResourceListShared.ts +75 -0
- package/Utils/Dashboard/Components/DashboardKubernetesStatefulSetListComponent.ts +36 -0
- package/Utils/Dashboard/Components/DashboardMonitorListComponent.ts +59 -2
- package/Utils/Dashboard/Components/Index.ts +102 -0
- package/build/dist/Models/DatabaseModels/DockerResource.js +525 -0
- package/build/dist/Models/DatabaseModels/DockerResource.js.map +1 -0
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Monitor.js +82 -0
- package/build/dist/Models/DatabaseModels/Monitor.js.map +1 -1
- package/build/dist/Server/API/MonitorTemplateAPI.js +108 -0
- package/build/dist/Server/API/MonitorTemplateAPI.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1777933061000-MigrationName.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1777933061000-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1777972687018-MigrationName.js +30 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1777972687018-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/BillingInvoiceService.js +22 -25
- package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
- package/build/dist/Server/Services/DockerResourceService.js +196 -0
- package/build/dist/Server/Services/DockerResourceService.js.map +1 -0
- package/build/dist/Server/Services/MonitorTemplateService.js +297 -0
- package/build/dist/Server/Services/MonitorTemplateService.js.map +1 -1
- package/build/dist/Server/Utils/VM/VMRunner.js +61 -0
- package/build/dist/Server/Utils/VM/VMRunner.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponentType.js +13 -0
- package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +15 -0
- package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerContainerListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerContainerListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerHostListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerHostListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerImageListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerImageListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerNetworkListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerNetworkListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerVolumeListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardDockerVolumeListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesCronJobListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesCronJobListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesDaemonSetListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesDaemonSetListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesDeploymentListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesDeploymentListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesJobListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesJobListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesNamespaceListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesNamespaceListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesNodeListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesNodeListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesPodListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesPodListComponent.js.map +1 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesStatefulSetListComponent.js +2 -0
- package/build/dist/Types/Dashboard/DashboardComponents/DashboardKubernetesStatefulSetListComponent.js.map +1 -0
- package/build/dist/Types/Docker/DockerInventoryExtractor.js +293 -0
- package/build/dist/Types/Docker/DockerInventoryExtractor.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardAlertListComponent.js +43 -3
- package/build/dist/Utils/Dashboard/Components/DashboardAlertListComponent.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/DashboardDockerContainerListComponent.js +75 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerContainerListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerHostListComponent.js +69 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerHostListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerImageListComponent.js +75 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerImageListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerNetworkListComponent.js +66 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerNetworkListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerVolumeListComponent.js +66 -0
- package/build/dist/Utils/Dashboard/Components/DashboardDockerVolumeListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardIncidentListComponent.js +43 -3
- package/build/dist/Utils/Dashboard/Components/DashboardIncidentListComponent.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesCronJobListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesCronJobListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesDaemonSetListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesDaemonSetListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesDeploymentListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesDeploymentListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesJobListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesJobListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesNamespaceListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesNamespaceListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesNodeListComponent.js +44 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesNodeListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesPodListComponent.js +47 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesPodListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesResourceListShared.js +55 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesResourceListShared.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesStatefulSetListComponent.js +29 -0
- package/build/dist/Utils/Dashboard/Components/DashboardKubernetesStatefulSetListComponent.js.map +1 -0
- package/build/dist/Utils/Dashboard/Components/DashboardMonitorListComponent.js +46 -3
- package/build/dist/Utils/Dashboard/Components/DashboardMonitorListComponent.js.map +1 -1
- package/build/dist/Utils/Dashboard/Components/Index.js +53 -0
- package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import UserMiddleware from "../Middleware/UserAuthorization";
|
|
2
|
+
import MonitorTemplateService, {
|
|
3
|
+
Service as MonitorTemplateServiceType,
|
|
4
|
+
SyncLinkedMonitorsResult,
|
|
5
|
+
} from "../Services/MonitorTemplateService";
|
|
6
|
+
import {
|
|
7
|
+
ExpressRequest,
|
|
8
|
+
ExpressResponse,
|
|
9
|
+
NextFunction,
|
|
10
|
+
} from "../Utils/Express";
|
|
11
|
+
import Response from "../Utils/Response";
|
|
12
|
+
import BaseAPI from "./BaseAPI";
|
|
13
|
+
import CommonAPI from "./CommonAPI";
|
|
14
|
+
import MonitorTemplate from "../../Models/DatabaseModels/MonitorTemplate";
|
|
15
|
+
import DatabaseCommonInteractionProps from "../../Types/BaseDatabase/DatabaseCommonInteractionProps";
|
|
16
|
+
import BadDataException from "../../Types/Exception/BadDataException";
|
|
17
|
+
import ObjectID from "../../Types/ObjectID";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Pull a `fields` whitelist out of the request body for a sync endpoint.
|
|
21
|
+
* Returns undefined when the caller didn't ask to scope the sync — the
|
|
22
|
+
* service treats that as "sync everything syncable".
|
|
23
|
+
*/
|
|
24
|
+
function readSyncFields(req: ExpressRequest): Array<string> | undefined {
|
|
25
|
+
const raw: unknown = (req.body as Record<string, unknown> | undefined)?.[
|
|
26
|
+
"fields"
|
|
27
|
+
];
|
|
28
|
+
if (raw === undefined || raw === null) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (!Array.isArray(raw)) {
|
|
32
|
+
throw new BadDataException("`fields` must be an array of strings");
|
|
33
|
+
}
|
|
34
|
+
for (const entry of raw) {
|
|
35
|
+
if (typeof entry !== "string") {
|
|
36
|
+
throw new BadDataException("`fields` must be an array of strings");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return raw as Array<string>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export default class MonitorTemplateAPI extends BaseAPI<
|
|
43
|
+
MonitorTemplate,
|
|
44
|
+
MonitorTemplateServiceType
|
|
45
|
+
> {
|
|
46
|
+
public constructor() {
|
|
47
|
+
super(MonitorTemplate, MonitorTemplateService);
|
|
48
|
+
|
|
49
|
+
// Push the template's current configuration onto every linked monitor.
|
|
50
|
+
this.router.post(
|
|
51
|
+
`${new this.entityType()
|
|
52
|
+
.getCrudApiPath()
|
|
53
|
+
?.toString()}/:monitorTemplateId/sync-to-linked-monitors`,
|
|
54
|
+
UserMiddleware.getUserMiddleware,
|
|
55
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
56
|
+
try {
|
|
57
|
+
const monitorTemplateId: ObjectID = new ObjectID(
|
|
58
|
+
req.params["monitorTemplateId"] as string,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const props: DatabaseCommonInteractionProps =
|
|
62
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
63
|
+
|
|
64
|
+
const fields: Array<string> | undefined = readSyncFields(req);
|
|
65
|
+
|
|
66
|
+
const result: SyncLinkedMonitorsResult =
|
|
67
|
+
await MonitorTemplateService.syncLinkedMonitors({
|
|
68
|
+
monitorTemplateId,
|
|
69
|
+
props,
|
|
70
|
+
...(fields !== undefined ? { fields } : {}),
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return Response.sendJsonObjectResponse(req, res, {
|
|
74
|
+
...result,
|
|
75
|
+
});
|
|
76
|
+
} catch (e) {
|
|
77
|
+
next(e);
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
},
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Push the template's current configuration onto a single linked monitor.
|
|
84
|
+
this.router.post(
|
|
85
|
+
`${new this.entityType()
|
|
86
|
+
.getCrudApiPath()
|
|
87
|
+
?.toString()}/:monitorTemplateId/sync-to-monitor/:monitorId`,
|
|
88
|
+
UserMiddleware.getUserMiddleware,
|
|
89
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
90
|
+
try {
|
|
91
|
+
const monitorTemplateId: ObjectID = new ObjectID(
|
|
92
|
+
req.params["monitorTemplateId"] as string,
|
|
93
|
+
);
|
|
94
|
+
const monitorId: ObjectID = new ObjectID(
|
|
95
|
+
req.params["monitorId"] as string,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const props: DatabaseCommonInteractionProps =
|
|
99
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
100
|
+
|
|
101
|
+
const fields: Array<string> | undefined = readSyncFields(req);
|
|
102
|
+
|
|
103
|
+
await MonitorTemplateService.syncToMonitor({
|
|
104
|
+
monitorTemplateId,
|
|
105
|
+
monitorId,
|
|
106
|
+
props,
|
|
107
|
+
...(fields !== undefined ? { fields } : {}),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
return Response.sendEmptySuccessResponse(req, res);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
next(e);
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Link an existing monitor to this template.
|
|
119
|
+
this.router.post(
|
|
120
|
+
`${new this.entityType()
|
|
121
|
+
.getCrudApiPath()
|
|
122
|
+
?.toString()}/:monitorTemplateId/link-monitor/:monitorId`,
|
|
123
|
+
UserMiddleware.getUserMiddleware,
|
|
124
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
125
|
+
try {
|
|
126
|
+
const monitorTemplateId: ObjectID = new ObjectID(
|
|
127
|
+
req.params["monitorTemplateId"] as string,
|
|
128
|
+
);
|
|
129
|
+
const monitorId: ObjectID = new ObjectID(
|
|
130
|
+
req.params["monitorId"] as string,
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
const props: DatabaseCommonInteractionProps =
|
|
134
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
135
|
+
|
|
136
|
+
await MonitorTemplateService.linkMonitor({
|
|
137
|
+
monitorTemplateId,
|
|
138
|
+
monitorId,
|
|
139
|
+
props,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
return Response.sendEmptySuccessResponse(req, res);
|
|
143
|
+
} catch (e) {
|
|
144
|
+
next(e);
|
|
145
|
+
}
|
|
146
|
+
return;
|
|
147
|
+
},
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
// Detach a monitor from this template.
|
|
151
|
+
this.router.post(
|
|
152
|
+
`${new this.entityType()
|
|
153
|
+
.getCrudApiPath()
|
|
154
|
+
?.toString()}/:monitorTemplateId/unlink-monitor/:monitorId`,
|
|
155
|
+
UserMiddleware.getUserMiddleware,
|
|
156
|
+
async (req: ExpressRequest, res: ExpressResponse, next: NextFunction) => {
|
|
157
|
+
try {
|
|
158
|
+
const monitorTemplateId: ObjectID = new ObjectID(
|
|
159
|
+
req.params["monitorTemplateId"] as string,
|
|
160
|
+
);
|
|
161
|
+
const monitorId: ObjectID = new ObjectID(
|
|
162
|
+
req.params["monitorId"] as string,
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const props: DatabaseCommonInteractionProps =
|
|
166
|
+
await CommonAPI.getDatabaseCommonInteractionProps(req);
|
|
167
|
+
|
|
168
|
+
await MonitorTemplateService.unlinkMonitor({
|
|
169
|
+
monitorTemplateId,
|
|
170
|
+
monitorId,
|
|
171
|
+
props,
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return Response.sendEmptySuccessResponse(req, res);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
next(e);
|
|
177
|
+
}
|
|
178
|
+
return;
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1777933061000 implements MigrationInterface {
|
|
4
|
+
public name: string = "MigrationName1777933061000";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "Monitor" ADD "monitorTemplateId" uuid`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE INDEX "IDX_620a223938dfac49fed7ab46e9" ON "Monitor" ("monitorTemplateId") `,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "Monitor" ADD CONSTRAINT "FK_620a223938dfac49fed7ab46e9e" FOREIGN KEY ("monitorTemplateId") REFERENCES "MonitorTemplate"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "Monitor" DROP CONSTRAINT "FK_620a223938dfac49fed7ab46e9e"`,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`DROP INDEX "public"."IDX_620a223938dfac49fed7ab46e9"`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
36
|
+
);
|
|
37
|
+
await queryRunner.query(
|
|
38
|
+
`ALTER TABLE "Monitor" DROP COLUMN "monitorTemplateId"`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1777972687018 implements MigrationInterface {
|
|
4
|
+
public name: string = "MigrationName1777972687018";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`CREATE TABLE "DockerResource" ("_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, "dockerHostId" uuid NOT NULL, "kind" character varying(100) NOT NULL, "name" character varying(100) NOT NULL, "containerId" character varying(100), "imageName" character varying(100), "state" character varying(100), "labels" jsonb, "latestCpuPercent" numeric, "latestMemoryBytes" bigint, "metricsUpdatedAt" TIMESTAMP WITH TIME ZONE, "lastSeenAt" TIMESTAMP WITH TIME ZONE NOT NULL, "resourceCreationTimestamp" TIMESTAMP WITH TIME ZONE, "createdByUserId" uuid, "deletedByUserId" uuid, CONSTRAINT "PK_fe18834da4418412424e36df7ed" PRIMARY KEY ("_id"))`,
|
|
9
|
+
);
|
|
10
|
+
await queryRunner.query(
|
|
11
|
+
`CREATE INDEX "IDX_85a3903c05939d0e6faf7dc30e" ON "DockerResource" ("projectId") `,
|
|
12
|
+
);
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`CREATE INDEX "IDX_84fba362f2ac3a2550e08d16fb" ON "DockerResource" ("dockerHostId") `,
|
|
15
|
+
);
|
|
16
|
+
await queryRunner.query(
|
|
17
|
+
`CREATE UNIQUE INDEX "IDX_0355903ed10c35eed76eacefb4" ON "DockerResource" ("projectId", "dockerHostId", "kind", "name") `,
|
|
18
|
+
);
|
|
19
|
+
await queryRunner.query(
|
|
20
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type":"Recurring","value":{"intervalType":"Day","intervalCount":{"_type":"PositiveNumber","value":1}}}'`,
|
|
21
|
+
);
|
|
22
|
+
await queryRunner.query(
|
|
23
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type":"RestrictionTimes","value":{"restictionType":"None","dayRestrictionTimes":null,"weeklyRestrictionTimes":[]}}'`,
|
|
24
|
+
);
|
|
25
|
+
await queryRunner.query(
|
|
26
|
+
`ALTER TABLE "DockerResource" ADD CONSTRAINT "FK_85a3903c05939d0e6faf7dc30ed" FOREIGN KEY ("projectId") REFERENCES "Project"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
27
|
+
);
|
|
28
|
+
await queryRunner.query(
|
|
29
|
+
`ALTER TABLE "DockerResource" ADD CONSTRAINT "FK_84fba362f2ac3a2550e08d16fb2" FOREIGN KEY ("dockerHostId") REFERENCES "DockerHost"("_id") ON DELETE CASCADE ON UPDATE NO ACTION`,
|
|
30
|
+
);
|
|
31
|
+
await queryRunner.query(
|
|
32
|
+
`ALTER TABLE "DockerResource" ADD CONSTRAINT "FK_a9223bb731acb6a93f503978184" FOREIGN KEY ("createdByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
33
|
+
);
|
|
34
|
+
await queryRunner.query(
|
|
35
|
+
`ALTER TABLE "DockerResource" ADD CONSTRAINT "FK_2fda4244a259a6e28de2df1b479" FOREIGN KEY ("deletedByUserId") REFERENCES "User"("_id") ON DELETE SET NULL ON UPDATE NO ACTION`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
40
|
+
await queryRunner.query(
|
|
41
|
+
`ALTER TABLE "DockerResource" DROP CONSTRAINT "FK_2fda4244a259a6e28de2df1b479"`,
|
|
42
|
+
);
|
|
43
|
+
await queryRunner.query(
|
|
44
|
+
`ALTER TABLE "DockerResource" DROP CONSTRAINT "FK_a9223bb731acb6a93f503978184"`,
|
|
45
|
+
);
|
|
46
|
+
await queryRunner.query(
|
|
47
|
+
`ALTER TABLE "DockerResource" DROP CONSTRAINT "FK_84fba362f2ac3a2550e08d16fb2"`,
|
|
48
|
+
);
|
|
49
|
+
await queryRunner.query(
|
|
50
|
+
`ALTER TABLE "DockerResource" DROP CONSTRAINT "FK_85a3903c05939d0e6faf7dc30ed"`,
|
|
51
|
+
);
|
|
52
|
+
await queryRunner.query(
|
|
53
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "restrictionTimes" SET DEFAULT '{"_type": "RestrictionTimes", "value": {"restictionType": "None", "dayRestrictionTimes": null, "weeklyRestrictionTimes": []}}'`,
|
|
54
|
+
);
|
|
55
|
+
await queryRunner.query(
|
|
56
|
+
`ALTER TABLE "OnCallDutyPolicyScheduleLayer" ALTER COLUMN "rotation" SET DEFAULT '{"_type": "Recurring", "value": {"intervalType": "Day", "intervalCount": {"_type": "PositiveNumber", "value": 1}}}'`,
|
|
57
|
+
);
|
|
58
|
+
await queryRunner.query(
|
|
59
|
+
`DROP INDEX "public"."IDX_0355903ed10c35eed76eacefb4"`,
|
|
60
|
+
);
|
|
61
|
+
await queryRunner.query(
|
|
62
|
+
`DROP INDEX "public"."IDX_84fba362f2ac3a2550e08d16fb"`,
|
|
63
|
+
);
|
|
64
|
+
await queryRunner.query(
|
|
65
|
+
`DROP INDEX "public"."IDX_85a3903c05939d0e6faf7dc30e"`,
|
|
66
|
+
);
|
|
67
|
+
await queryRunner.query(`DROP TABLE "DockerResource"`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -296,6 +296,8 @@ import { AddMonitorTemplate1777201966799 } from "./1777201966799-AddMonitorTempl
|
|
|
296
296
|
import { MigrationName1777550162848 } from "./1777550162848-MigrationName";
|
|
297
297
|
import { MigrationName1777571961028 } from "./1777571961028-MigrationName";
|
|
298
298
|
import { MigrationName1777629313843 } from "./1777629313843-MigrationName";
|
|
299
|
+
import { MigrationName1777933061000 } from "./1777933061000-MigrationName";
|
|
300
|
+
import { MigrationName1777972687018 } from "./1777972687018-MigrationName";
|
|
299
301
|
export default [
|
|
300
302
|
InitialMigration,
|
|
301
303
|
MigrationName1717678334852,
|
|
@@ -595,4 +597,6 @@ export default [
|
|
|
595
597
|
MigrationName1777550162848,
|
|
596
598
|
MigrationName1777571961028,
|
|
597
599
|
MigrationName1777629313843,
|
|
600
|
+
MigrationName1777933061000,
|
|
601
|
+
MigrationName1777972687018,
|
|
598
602
|
];
|
|
@@ -56,7 +56,7 @@ export class Service extends DatabaseService<Model> {
|
|
|
56
56
|
} as LogAttributes);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
const project: Project | null = await ProjectService.findOneById({
|
|
60
60
|
id: data.projectId,
|
|
61
61
|
props: {
|
|
62
62
|
isRoot: true,
|
|
@@ -82,12 +82,12 @@ export class Service extends DatabaseService<Model> {
|
|
|
82
82
|
throw new BadDataException("Payment provider customer id not found.");
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
|
|
85
|
+
const subscriptionState: SubscriptionStatus =
|
|
86
86
|
await BillingService.getSubscriptionStatus(
|
|
87
87
|
project.paymentProviderSubscriptionId as string,
|
|
88
88
|
);
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
const meteredSubscriptionState: SubscriptionStatus =
|
|
91
91
|
await BillingService.getSubscriptionStatus(
|
|
92
92
|
project.paymentProviderMeteredSubscriptionId as string,
|
|
93
93
|
);
|
|
@@ -129,37 +129,26 @@ export class Service extends DatabaseService<Model> {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
if (allInvoicesPaid) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
select: {
|
|
139
|
-
_id: true,
|
|
140
|
-
paymentProviderCustomerId: true,
|
|
141
|
-
paymentProviderSubscriptionId: true,
|
|
142
|
-
paymentProviderMeteredSubscriptionId: true,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
if (!project) {
|
|
147
|
-
throw new BadDataException("Project not found");
|
|
132
|
+
try {
|
|
133
|
+
await ProjectService.reactiveSubscription(project.id!);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
logger.error(err, {
|
|
136
|
+
projectId: data.projectId?.toString(),
|
|
137
|
+
} as LogAttributes);
|
|
148
138
|
}
|
|
149
139
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
140
|
+
/*
|
|
141
|
+
* No Open/Uncollectible invoices means the project has no outstanding
|
|
142
|
+
* payment obligations, so we mark the subscription as Active. Stripe may
|
|
143
|
+
* still report the (re)created subscription as "incomplete" until the
|
|
144
|
+
* first payment confirms, which would otherwise surface a misleading
|
|
145
|
+
* "invoices are unpaid" banner.
|
|
146
|
+
*/
|
|
158
147
|
await ProjectService.updateOneById({
|
|
159
148
|
id: project.id!,
|
|
160
149
|
data: {
|
|
161
|
-
paymentProviderSubscriptionStatus:
|
|
162
|
-
paymentProviderMeteredSubscriptionStatus:
|
|
150
|
+
paymentProviderSubscriptionStatus: SubscriptionStatus.Active,
|
|
151
|
+
paymentProviderMeteredSubscriptionStatus: SubscriptionStatus.Active,
|
|
163
152
|
},
|
|
164
153
|
props: {
|
|
165
154
|
isRoot: true,
|