@oneuptime/common 7.0.3126 → 7.0.3139
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/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel.ts +1 -1
- package/Models/AnalyticsModels/Index.ts +28 -1
- package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.ts +14 -3
- package/Models/DatabaseModels/Incident.ts +5 -0
- package/Models/DatabaseModels/Index.ts +35 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727192530019-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727193130193-MigrationName.ts +17 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727193702212-MigrationName.ts +726 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727194211048-MigrationName.ts +732 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1727194579925-MigrationName.ts +493 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +10 -0
- package/Server/Middleware/ProjectAuthorization.ts +5 -3
- package/Server/Middleware/UserAuthorization.ts +32 -5
- package/Server/Services/AccessTokenService.ts +10 -154
- package/Server/Services/AnalyticsDatabaseService.ts +2 -2
- package/Server/Services/DatabaseService.ts +77 -4
- package/Server/Services/StatusPageService.ts +1 -1
- package/Server/Types/Permission/PermissionNamespace.ts +6 -0
- package/Server/Utils/APIKey/AccessPermission.ts +111 -0
- package/Server/Utils/Cookie.ts +15 -1
- package/Server/Utils/Monitor/MonitorResource.ts +57 -23
- package/Server/Utils/Realtime.ts +288 -79
- package/Server/Utils/UserPermission/UserPermission.ts +81 -0
- package/Tests/Server/Middleware/ProjectAuthorization.test.ts +3 -3
- package/Tests/Server/Middleware/UserAuthorization.test.ts +14 -10
- package/Tests/Server/Services/ScheduledMaintenanceService.test.ts +4 -2
- package/Tests/Server/Utils/Cookie.test.ts +1 -1
- package/Types/Database/TableMetadata.ts +5 -0
- package/Types/Realtime/EnableRealtimeEventsOn.ts +5 -0
- package/Types/Realtime/EventName.ts +5 -0
- package/Types/Realtime/ListenToModelEventJSON.ts +10 -0
- package/Types/Realtime/ModelEventType.ts +7 -0
- package/UI/Components/HeaderAlert/HeaderModelAlert.tsx +1 -1
- package/UI/Components/ModelList/ModelList.tsx +1 -1
- package/UI/Components/ModelTable/BaseModelTable.tsx +1 -1
- package/UI/Utils/Realtime.ts +29 -19
- package/Utils/Realtime.ts +10 -29
- package/build/dist/Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel.js.map +1 -1
- package/build/dist/Models/AnalyticsModels/Index.js +14 -0
- package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js +10 -3
- package/build/dist/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Incident.js +5 -0
- package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +16 -1
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727192530019-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727192530019-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727193130193-MigrationName.js +12 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727193130193-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727193702212-MigrationName.js +247 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727193702212-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727194211048-MigrationName.js +249 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727194211048-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727194579925-MigrationName.js +131 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1727194579925-MigrationName.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +10 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +3 -3
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Middleware/UserAuthorization.js +13 -5
- package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
- package/build/dist/Server/Services/AccessTokenService.js +6 -108
- package/build/dist/Server/Services/AccessTokenService.js.map +1 -1
- package/build/dist/Server/Services/AnalyticsDatabaseService.js +2 -2
- package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +43 -4
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +1 -1
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Types/Permission/PermissionNamespace.js +7 -0
- package/build/dist/Server/Types/Permission/PermissionNamespace.js.map +1 -0
- package/build/dist/Server/Utils/APIKey/AccessPermission.js +78 -0
- package/build/dist/Server/Utils/APIKey/AccessPermission.js.map +1 -0
- package/build/dist/Server/Utils/Cookie.js +11 -1
- package/build/dist/Server/Utils/Cookie.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorResource.js +58 -32
- package/build/dist/Server/Utils/Monitor/MonitorResource.js.map +1 -1
- package/build/dist/Server/Utils/Realtime.js +181 -51
- package/build/dist/Server/Utils/Realtime.js.map +1 -1
- package/build/dist/Server/Utils/UserPermission/UserPermission.js +47 -0
- package/build/dist/Server/Utils/UserPermission/UserPermission.js.map +1 -0
- package/build/dist/Tests/Server/Middleware/ProjectAuthorization.test.js +3 -3
- package/build/dist/Tests/Server/Middleware/ProjectAuthorization.test.js.map +1 -1
- package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js +9 -8
- package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js.map +1 -1
- package/build/dist/Tests/Server/Services/ScheduledMaintenanceService.test.js +2 -2
- package/build/dist/Tests/Server/Services/ScheduledMaintenanceService.test.js.map +1 -1
- package/build/dist/Tests/Server/Utils/Cookie.test.js +1 -1
- package/build/dist/Tests/Server/Utils/Cookie.test.js.map +1 -1
- package/build/dist/Types/Database/TableMetadata.js +3 -0
- package/build/dist/Types/Database/TableMetadata.js.map +1 -1
- package/build/dist/Types/Realtime/EnableRealtimeEventsOn.js +2 -0
- package/build/dist/Types/Realtime/EnableRealtimeEventsOn.js.map +1 -0
- package/build/dist/Types/Realtime/EventName.js +6 -0
- package/build/dist/Types/Realtime/EventName.js.map +1 -0
- package/build/dist/Types/Realtime/ListenToModelEventJSON.js +2 -0
- package/build/dist/Types/Realtime/ListenToModelEventJSON.js.map +1 -0
- package/build/dist/Types/Realtime/ModelEventType.js +8 -0
- package/build/dist/Types/Realtime/ModelEventType.js.map +1 -0
- package/build/dist/UI/Utils/Realtime.js +16 -11
- package/build/dist/UI/Utils/Realtime.js.map +1 -1
- package/build/dist/Utils/Realtime.js +6 -12
- package/build/dist/Utils/Realtime.js.map +1 -1
- package/package.json +2 -2
- package/Models/Permissions/Permission.ts +0 -0
- package/build/dist/Models/Permissions/Permission.js +0 -2
- package/build/dist/Models/Permissions/Permission.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import EnableRealtimeEventsOn from "../../../Types/Realtime/EnableRealtimeEventsOn";
|
|
1
2
|
import Route from "../../../Types/API/Route";
|
|
2
3
|
import AnalyticsTableEngine from "../../../Types/AnalyticsDatabase/AnalyticsTableEngine";
|
|
3
4
|
import AnalyticsTableColumn from "../../../Types/AnalyticsDatabase/TableColumn";
|
|
@@ -19,7 +20,6 @@ import Permission, {
|
|
|
19
20
|
UserTenantAccessPermission,
|
|
20
21
|
} from "../../../Types/Permission";
|
|
21
22
|
import Text from "../../../Types/Text";
|
|
22
|
-
import { EnableRealtimeEventsOn } from "../../../Utils/Realtime";
|
|
23
23
|
import CommonModel from "./CommonModel";
|
|
24
24
|
|
|
25
25
|
export type AnalyticsBaseModelType = { new (): AnalyticsBaseModel };
|
|
@@ -6,7 +6,7 @@ import Span from "./Span";
|
|
|
6
6
|
import TelemetryAttribute from "./TelemetryAttribute";
|
|
7
7
|
import ExceptionInstance from "./ExceptionInstance";
|
|
8
8
|
|
|
9
|
-
const AnalyticsModels: Array<
|
|
9
|
+
const AnalyticsModels: Array<{ new (): AnalyticsBaseModel }> = [
|
|
10
10
|
Log,
|
|
11
11
|
Span,
|
|
12
12
|
Metric,
|
|
@@ -15,4 +15,31 @@ const AnalyticsModels: Array<typeof AnalyticsBaseModel> = [
|
|
|
15
15
|
ExceptionInstance,
|
|
16
16
|
];
|
|
17
17
|
|
|
18
|
+
const modelTypeMap: { [key: string]: { new (): AnalyticsBaseModel } } = {};
|
|
19
|
+
|
|
20
|
+
type GetModelTypeByName = (
|
|
21
|
+
tableName: string,
|
|
22
|
+
) => (new () => AnalyticsBaseModel) | null;
|
|
23
|
+
|
|
24
|
+
export const getModelTypeByName: GetModelTypeByName = (
|
|
25
|
+
tableName: string,
|
|
26
|
+
): (new () => AnalyticsBaseModel) | null => {
|
|
27
|
+
if (modelTypeMap[tableName]) {
|
|
28
|
+
return modelTypeMap[tableName] || null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const modelType: { new (): AnalyticsBaseModel } | undefined =
|
|
32
|
+
AnalyticsModels.find((modelType: { new (): AnalyticsBaseModel }) => {
|
|
33
|
+
return new modelType().tableName === tableName;
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
if (!modelType) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
modelTypeMap[tableName] = modelType;
|
|
41
|
+
|
|
42
|
+
return modelType;
|
|
43
|
+
};
|
|
44
|
+
|
|
18
45
|
export default AnalyticsModels;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import EnableRealtimeEventsOn from "../../../Types/Realtime/EnableRealtimeEventsOn";
|
|
1
2
|
import Route from "../../../Types/API/Route";
|
|
2
3
|
import { ColumnAccessControl } from "../../../Types/BaseDatabase/AccessControl";
|
|
3
4
|
import ColumnBillingAccessControl from "../../../Types/BaseDatabase/ColumnBillingAccessControl";
|
|
@@ -7,6 +8,7 @@ import { PlanType } from "../../../Types/Billing/SubscriptionPlan";
|
|
|
7
8
|
import { getColumnAccessControlForAllColumns } from "../../../Types/Database/AccessControl/ColumnAccessControl";
|
|
8
9
|
import { getColumnBillingAccessControlForAllColumns } from "../../../Types/Database/AccessControl/ColumnBillingAccessControl";
|
|
9
10
|
import Columns from "../../../Types/Database/Columns";
|
|
11
|
+
import ColumnType from "../../../Types/Database/ColumnType";
|
|
10
12
|
import TableColumn, {
|
|
11
13
|
TableColumnMetadata,
|
|
12
14
|
getTableColumn,
|
|
@@ -63,7 +65,9 @@ export default class DatabaseBaseModel extends BaseEntity {
|
|
|
63
65
|
type: TableColumnType.Date,
|
|
64
66
|
description: "Date and Time when the object was created.",
|
|
65
67
|
})
|
|
66
|
-
@CreateDateColumn(
|
|
68
|
+
@CreateDateColumn({
|
|
69
|
+
type: ColumnType.Date,
|
|
70
|
+
})
|
|
67
71
|
public createdAt?: Date = undefined;
|
|
68
72
|
|
|
69
73
|
@TableColumn({
|
|
@@ -71,7 +75,9 @@ export default class DatabaseBaseModel extends BaseEntity {
|
|
|
71
75
|
type: TableColumnType.Date,
|
|
72
76
|
description: "Date and Time when the object was updated.",
|
|
73
77
|
})
|
|
74
|
-
@UpdateDateColumn(
|
|
78
|
+
@UpdateDateColumn({
|
|
79
|
+
type: ColumnType.Date,
|
|
80
|
+
})
|
|
75
81
|
public updatedAt?: Date = undefined;
|
|
76
82
|
|
|
77
83
|
@TableColumn({
|
|
@@ -79,7 +85,9 @@ export default class DatabaseBaseModel extends BaseEntity {
|
|
|
79
85
|
type: TableColumnType.Date,
|
|
80
86
|
description: "Date and Time when the object was deleted.",
|
|
81
87
|
})
|
|
82
|
-
@DeleteDateColumn(
|
|
88
|
+
@DeleteDateColumn({
|
|
89
|
+
type: ColumnType.Date,
|
|
90
|
+
})
|
|
83
91
|
public deletedAt?: Date = undefined;
|
|
84
92
|
|
|
85
93
|
@TableColumn({
|
|
@@ -115,6 +123,9 @@ export default class DatabaseBaseModel extends BaseEntity {
|
|
|
115
123
|
public singularName!: string | null;
|
|
116
124
|
public pluralName!: string | null;
|
|
117
125
|
|
|
126
|
+
// realtime events.
|
|
127
|
+
public enableRealtimeEventsOn!: EnableRealtimeEventsOn | null;
|
|
128
|
+
|
|
118
129
|
// total items by
|
|
119
130
|
public totalItemsByColumnName!: string | null;
|
|
120
131
|
public totalItemsNumber!: number | null;
|
|
@@ -94,6 +94,11 @@ export interface TelemetryIncidentQuery {
|
|
|
94
94
|
pluralName: "Incidents",
|
|
95
95
|
icon: IconProp.Alert,
|
|
96
96
|
tableDescription: "Manage incidents for your project",
|
|
97
|
+
enableRealtimeEventsOn: {
|
|
98
|
+
create: true,
|
|
99
|
+
update: true,
|
|
100
|
+
delete: true,
|
|
101
|
+
},
|
|
97
102
|
})
|
|
98
103
|
export default class Incident extends BaseModel {
|
|
99
104
|
@ColumnAccessControl({
|
|
@@ -141,7 +141,11 @@ import ScheduledMaintenanceTemplate from "./ScheduledMaintenanceTemplate";
|
|
|
141
141
|
import ScheduledMaintenanceTemplateOwnerTeam from "./ScheduledMaintenanceTemplateOwnerTeam";
|
|
142
142
|
import ScheduledMaintenanceTemplateOwnerUser from "./ScheduledMaintenanceTemplateOwnerUser";
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
import BaseModel from "./DatabaseBaseModel/DatabaseBaseModel";
|
|
145
|
+
|
|
146
|
+
const AllModelTypes: Array<{
|
|
147
|
+
new (): BaseModel;
|
|
148
|
+
}> = [
|
|
145
149
|
User,
|
|
146
150
|
Probe,
|
|
147
151
|
Project,
|
|
@@ -302,3 +306,33 @@ export default [
|
|
|
302
306
|
|
|
303
307
|
TelemetryException,
|
|
304
308
|
];
|
|
309
|
+
|
|
310
|
+
const modelTypeMap: { [key: string]: { new (): BaseModel } } = {};
|
|
311
|
+
|
|
312
|
+
type GetModelTypeByNameFunction = (
|
|
313
|
+
tableName: string,
|
|
314
|
+
) => { new (): BaseModel } | null;
|
|
315
|
+
|
|
316
|
+
export const getModelTypeByName: GetModelTypeByNameFunction = (
|
|
317
|
+
tableName: string,
|
|
318
|
+
): { new (): BaseModel } | null => {
|
|
319
|
+
if (modelTypeMap[tableName]) {
|
|
320
|
+
return modelTypeMap[tableName] || null;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const modelType: { new (): BaseModel } | undefined = AllModelTypes.find(
|
|
324
|
+
(modelType: { new (): BaseModel }) => {
|
|
325
|
+
return new modelType().tableName === tableName;
|
|
326
|
+
},
|
|
327
|
+
);
|
|
328
|
+
|
|
329
|
+
if (!modelType) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
modelTypeMap[tableName] = modelType;
|
|
334
|
+
|
|
335
|
+
return modelType;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
export default AllModelTypes;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1727192530019 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1727192530019";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "File" ALTER COLUMN "createdAt" TYPE TIMESTAMP WITH TIME ZONE`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "File" ALTER COLUMN "createdAt" TYPE TIMESTAMP`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MigrationInterface, QueryRunner } from "typeorm";
|
|
2
|
+
|
|
3
|
+
export class MigrationName1727193130193 implements MigrationInterface {
|
|
4
|
+
public name = "MigrationName1727193130193";
|
|
5
|
+
|
|
6
|
+
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
7
|
+
await queryRunner.query(
|
|
8
|
+
`ALTER TABLE "User" ALTER COLUMN "createdAt" TYPE TIMESTAMP WITH TIME ZONE`,
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
13
|
+
await queryRunner.query(
|
|
14
|
+
`ALTER TABLE "User" ALTER COLUMN "createdAt" TYPE TIMESTAMP`,
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|