@oneuptime/common 12.0.1 → 12.0.2
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/Host.ts +12 -4
- package/Models/DatabaseModels/KubernetesContainer.ts +5 -4
- package/Models/DatabaseModels/KubernetesResource.ts +8 -7
- package/Models/DatabaseModels/PodmanResource.ts +6 -6
- package/Models/DatabaseModels/ServiceLevelObjective.ts +91 -0
- package/Models/DatabaseModels/StatusPage.ts +95 -0
- package/Server/API/TeamMemberAPI.ts +85 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.ts +84 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.ts +40 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.ts +131 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.ts +25 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
- package/Server/Middleware/ProjectAuthorization.ts +66 -4
- package/Server/Services/BillingService.ts +600 -51
- package/Server/Services/CephClusterService.ts +47 -5
- package/Server/Services/CephResourceService.ts +43 -4
- package/Server/Services/CloudResourceService.ts +47 -5
- package/Server/Services/DatabaseService.ts +87 -6
- package/Server/Services/DockerHostService.ts +47 -5
- package/Server/Services/DockerResourceService.ts +62 -8
- package/Server/Services/DockerSwarmClusterService.ts +48 -5
- package/Server/Services/DockerSwarmResourceService.ts +53 -4
- package/Server/Services/HostService.ts +48 -5
- package/Server/Services/IoTDeviceService.ts +1 -17
- package/Server/Services/IoTFleetService.ts +47 -5
- package/Server/Services/KubernetesClusterService.ts +48 -5
- package/Server/Services/KubernetesContainerService.ts +50 -9
- package/Server/Services/KubernetesResourceService.ts +53 -7
- package/Server/Services/LabelService.ts +106 -1
- package/Server/Services/MonitorService.ts +57 -0
- package/Server/Services/PodmanHostService.ts +47 -5
- package/Server/Services/PodmanResourceService.ts +62 -8
- package/Server/Services/ProjectService.ts +165 -35
- package/Server/Services/ProxmoxClusterService.ts +47 -5
- package/Server/Services/ProxmoxResourceService.ts +43 -4
- package/Server/Services/RumApplicationService.ts +48 -5
- package/Server/Services/ServerlessFunctionService.ts +48 -5
- package/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.ts +426 -0
- package/Server/Services/ServiceLevelObjectiveService.ts +39 -0
- package/Server/Services/StatusPageService.ts +95 -36
- package/Server/Services/StatusPageSubscriberNotificationTemplateService.ts +18 -1
- package/Server/Services/StatusPageSubscriberService.ts +3 -0
- package/Server/Types/Database/JSONColumnQuery.ts +621 -0
- package/Server/Types/Database/Permissions/PublicPermission.ts +9 -2
- package/Server/Types/Database/QueryHelper.ts +17 -32
- package/Server/Utils/Database/TruncateColumnValue.ts +84 -0
- package/Tests/App/Dashboard/UsersTableGroupsByPerson.test.tsx +448 -0
- package/Tests/Server/API/BaseAPIApiKeyAuth.test.ts +704 -0
- package/Tests/Server/API/TeamMemberRemoveUserFromProjectAPI.test.ts +303 -0
- package/Tests/Server/Middleware/MasterAdminAuthorization.test.ts +350 -0
- package/Tests/Server/Middleware/ProjectAuthorizationApiKeyHeader.test.ts +362 -0
- package/Tests/Server/Middleware/ProjectAuthorizationApiKeyMiddleware.test.ts +687 -0
- package/Tests/Server/Services/BillingService.test.ts +78 -3
- package/Tests/Server/Services/BillingServiceChangePlanCancel.test.ts +645 -0
- package/Tests/Server/Services/BillingServiceTrialPlanChange.test.ts +1005 -0
- package/Tests/Server/Services/HookFreeWriteLengthClamp.test.ts +503 -0
- package/Tests/Server/Services/HostIpAddressesColumnWidth.test.ts +198 -0
- package/Tests/Server/Services/HostServiceUpdateLastSeen.test.ts +510 -0
- package/Tests/Server/Services/InventoryResourceNameColumnWidth.test.ts +500 -0
- package/Tests/Server/Services/InventoryUpsertSchemaParity.test.ts +586 -0
- package/Tests/Server/Services/InventoryUpsertTruncationGuard.test.ts +1242 -0
- package/Tests/Server/Services/ProjectServiceChangePlan.test.ts +650 -0
- package/Tests/Server/Services/ProjectServiceExtendTrial.test.ts +1 -0
- package/Tests/Server/Services/ResourceUpdateLastSeenLivenessFallback.test.ts +387 -0
- package/Tests/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.test.ts +770 -0
- package/Tests/Server/Services/ServiceLevelObjectiveService.test.ts +130 -0
- package/Tests/Server/Services/SloMonitorLabelRuleHooks.test.ts +352 -0
- package/Tests/Server/Services/StatusPageSubscriberReport.test.ts +29 -13
- package/Tests/Server/TestingUtils/Services/BillingServiceHelper.ts +69 -8
- package/Tests/Server/Types/Database/JSONColumnQuery.test.ts +593 -0
- package/Tests/Server/Types/Database/Permissions/PublicPermission.test.ts +495 -0
- package/Tests/Server/Types/Database/QueryUtil.test.ts +113 -0
- package/Tests/Server/Utils/Database/TruncateColumnValue.test.ts +179 -0
- package/Tests/Types/Events/Recurring.test.ts +157 -0
- package/Tests/UI/Components/ModelTable/ModelTableGroupsProjectUsers.test.tsx +375 -0
- package/Tests/UI/Components/ModelTable/useCustomFieldColumns.test.tsx +196 -0
- package/Tests/UI/Utils/ProjectUsersModelAPI.test.ts +739 -0
- package/Tests/UI/Utils/TeamMembersByUser.test.ts +633 -0
- package/Tests/Utils/StatusPage/ReportPeriod.test.ts +218 -0
- package/Tests/Utils/Telemetry/HostIpAddresses.test.ts +291 -0
- package/Types/CustomField/CustomFieldDefinition.ts +24 -0
- package/Types/Date.ts +112 -0
- package/Types/Events/Recurring.ts +99 -1
- package/Types/StatusPage/StatusPageReport.ts +11 -0
- package/Types/StatusPage/StatusPageReportPeriodType.ts +21 -0
- package/UI/Components/ModelTable/CustomFieldColumns.tsx +2 -6
- package/UI/Components/ModelTable/useCustomFieldColumns.ts +21 -2
- package/UI/Utils/ModelAPI/ProjectUsersModelAPI.ts +305 -0
- package/UI/Utils/TeamMembersByUser.ts +302 -0
- package/Utils/StatusPage/ReportPeriod.ts +236 -0
- package/Utils/Telemetry/HostIpAddresses.ts +98 -0
- package/build/dist/Models/DatabaseModels/Host.js +12 -4
- package/build/dist/Models/DatabaseModels/Host.js.map +1 -1
- package/build/dist/Models/DatabaseModels/KubernetesContainer.js +4 -4
- package/build/dist/Models/DatabaseModels/KubernetesContainer.js.map +1 -1
- package/build/dist/Models/DatabaseModels/KubernetesResource.js +7 -7
- package/build/dist/Models/DatabaseModels/KubernetesResource.js.map +1 -1
- package/build/dist/Models/DatabaseModels/PodmanResource.js +6 -6
- package/build/dist/Models/DatabaseModels/PodmanResource.js.map +1 -1
- package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js +87 -0
- package/build/dist/Models/DatabaseModels/ServiceLevelObjective.js.map +1 -1
- package/build/dist/Models/DatabaseModels/StatusPage.js +98 -0
- package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
- package/build/dist/Server/API/TeamMemberAPI.js +57 -2
- package/build/dist/Server/API/TeamMemberAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.js +45 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785900000000-AddSloMonitorLabelRule.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.js +31 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785915638551-IncreaseHostIpAddressesLength.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.js +90 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930000000-WidenInventoryResourceNameColumns.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.js +14 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1785930709405-AddStatusPageReportPeriod.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Middleware/ProjectAuthorization.js +59 -4
- package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
- package/build/dist/Server/Services/BillingService.js +466 -36
- package/build/dist/Server/Services/BillingService.js.map +1 -1
- package/build/dist/Server/Services/CephClusterService.js +42 -5
- package/build/dist/Server/Services/CephClusterService.js.map +1 -1
- package/build/dist/Server/Services/CephResourceService.js +28 -3
- package/build/dist/Server/Services/CephResourceService.js.map +1 -1
- package/build/dist/Server/Services/CloudResourceService.js +42 -5
- package/build/dist/Server/Services/CloudResourceService.js.map +1 -1
- package/build/dist/Server/Services/DatabaseService.js +69 -2
- package/build/dist/Server/Services/DatabaseService.js.map +1 -1
- package/build/dist/Server/Services/DockerHostService.js +42 -5
- package/build/dist/Server/Services/DockerHostService.js.map +1 -1
- package/build/dist/Server/Services/DockerResourceService.js +34 -4
- package/build/dist/Server/Services/DockerResourceService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmClusterService.js +43 -5
- package/build/dist/Server/Services/DockerSwarmClusterService.js.map +1 -1
- package/build/dist/Server/Services/DockerSwarmResourceService.js +28 -3
- package/build/dist/Server/Services/DockerSwarmResourceService.js.map +1 -1
- package/build/dist/Server/Services/HostService.js +43 -5
- package/build/dist/Server/Services/HostService.js.map +1 -1
- package/build/dist/Server/Services/IoTDeviceService.js +1 -8
- package/build/dist/Server/Services/IoTDeviceService.js.map +1 -1
- package/build/dist/Server/Services/IoTFleetService.js +42 -5
- package/build/dist/Server/Services/IoTFleetService.js.map +1 -1
- package/build/dist/Server/Services/KubernetesClusterService.js +43 -5
- package/build/dist/Server/Services/KubernetesClusterService.js.map +1 -1
- package/build/dist/Server/Services/KubernetesContainerService.js +29 -3
- package/build/dist/Server/Services/KubernetesContainerService.js.map +1 -1
- package/build/dist/Server/Services/KubernetesResourceService.js +32 -4
- package/build/dist/Server/Services/KubernetesResourceService.js.map +1 -1
- package/build/dist/Server/Services/LabelService.js +92 -0
- package/build/dist/Server/Services/LabelService.js.map +1 -1
- package/build/dist/Server/Services/MonitorService.js +47 -0
- package/build/dist/Server/Services/MonitorService.js.map +1 -1
- package/build/dist/Server/Services/PodmanHostService.js +42 -5
- package/build/dist/Server/Services/PodmanHostService.js.map +1 -1
- package/build/dist/Server/Services/PodmanResourceService.js +34 -4
- package/build/dist/Server/Services/PodmanResourceService.js.map +1 -1
- package/build/dist/Server/Services/ProjectService.js +135 -21
- package/build/dist/Server/Services/ProjectService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxClusterService.js +42 -5
- package/build/dist/Server/Services/ProxmoxClusterService.js.map +1 -1
- package/build/dist/Server/Services/ProxmoxResourceService.js +28 -3
- package/build/dist/Server/Services/ProxmoxResourceService.js.map +1 -1
- package/build/dist/Server/Services/RumApplicationService.js +43 -5
- package/build/dist/Server/Services/RumApplicationService.js.map +1 -1
- package/build/dist/Server/Services/ServerlessFunctionService.js +43 -5
- package/build/dist/Server/Services/ServerlessFunctionService.js.map +1 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js +347 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveMonitorRuleEngineService.js.map +1 -0
- package/build/dist/Server/Services/ServiceLevelObjectiveService.js +33 -1
- package/build/dist/Server/Services/ServiceLevelObjectiveService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageService.js +69 -46
- package/build/dist/Server/Services/StatusPageService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js +17 -1
- package/build/dist/Server/Services/StatusPageSubscriberNotificationTemplateService.js.map +1 -1
- package/build/dist/Server/Services/StatusPageSubscriberService.js +3 -0
- package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
- package/build/dist/Server/Types/Database/JSONColumnQuery.js +402 -0
- package/build/dist/Server/Types/Database/JSONColumnQuery.js.map +1 -0
- package/build/dist/Server/Types/Database/Permissions/PublicPermission.js +9 -2
- package/build/dist/Server/Types/Database/Permissions/PublicPermission.js.map +1 -1
- package/build/dist/Server/Types/Database/QueryHelper.js +17 -27
- package/build/dist/Server/Types/Database/QueryHelper.js.map +1 -1
- package/build/dist/Server/Utils/Database/TruncateColumnValue.js +32 -0
- package/build/dist/Server/Utils/Database/TruncateColumnValue.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldDefinition.js +2 -0
- package/build/dist/Types/CustomField/CustomFieldDefinition.js.map +1 -0
- package/build/dist/Types/Date.js +68 -0
- package/build/dist/Types/Date.js.map +1 -1
- package/build/dist/Types/Events/Recurring.js +63 -0
- package/build/dist/Types/Events/Recurring.js.map +1 -1
- package/build/dist/Types/StatusPage/StatusPageReportPeriodType.js +22 -0
- package/build/dist/Types/StatusPage/StatusPageReportPeriodType.js.map +1 -0
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js +18 -2
- package/build/dist/UI/Components/ModelTable/useCustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Utils/ModelAPI/ProjectUsersModelAPI.js +213 -0
- package/build/dist/UI/Utils/ModelAPI/ProjectUsersModelAPI.js.map +1 -0
- package/build/dist/UI/Utils/TeamMembersByUser.js +195 -0
- package/build/dist/UI/Utils/TeamMembersByUser.js.map +1 -0
- package/build/dist/Utils/StatusPage/ReportPeriod.js +131 -0
- package/build/dist/Utils/StatusPage/ReportPeriod.js.map +1 -0
- package/build/dist/Utils/Telemetry/HostIpAddresses.js +82 -0
- package/build/dist/Utils/Telemetry/HostIpAddresses.js.map +1 -0
- package/jest.config.json +2 -0
- package/package.json +1 -1
- package/tsconfig.json +12 -1
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import Team from "../../Models/DatabaseModels/Team";
|
|
2
|
+
import TeamMember from "../../Models/DatabaseModels/TeamMember";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* TeamMember is a (user, team) pair, so a list of team members is a list of
|
|
6
|
+
* memberships - not a list of people. Rendering it straight into a "Users"
|
|
7
|
+
* table gives one row per membership, and someone who belongs to three teams
|
|
8
|
+
* reads as three separate people with the same name and avatar.
|
|
9
|
+
*
|
|
10
|
+
* These helpers collapse memberships into one row per person, carrying every
|
|
11
|
+
* team that person belongs to on the row so the table can show them together.
|
|
12
|
+
* The row is still a TeamMember (the table, its columns and its delete action
|
|
13
|
+
* are all typed against the model) - it just stands for the user rather than
|
|
14
|
+
* for one of their memberships.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface ProjectUserExtras {
|
|
18
|
+
// Every team this user belongs to, sorted by name.
|
|
19
|
+
teamsForUser: Array<Team>;
|
|
20
|
+
teamCountForUser: number;
|
|
21
|
+
/*
|
|
22
|
+
* How many of those memberships are still unaccepted invitations. A user can
|
|
23
|
+
* be a fully accepted member of one team and a pending invite on another.
|
|
24
|
+
*/
|
|
25
|
+
pendingTeamCountForUser: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type ProjectUserRow = TeamMember & ProjectUserExtras;
|
|
29
|
+
|
|
30
|
+
export default class TeamMembersByUser {
|
|
31
|
+
/**
|
|
32
|
+
* The identity a membership is grouped under. Null when the row carries no
|
|
33
|
+
* user at all - those rows are never merged, because merging them would put
|
|
34
|
+
* unrelated memberships on one line.
|
|
35
|
+
*/
|
|
36
|
+
public static getGroupKey(teamMember: TeamMember): string | null {
|
|
37
|
+
const userId: string =
|
|
38
|
+
teamMember.userId?.toString() || teamMember.user?._id?.toString() || "";
|
|
39
|
+
|
|
40
|
+
return userId || null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The name this row sorts and reads under. Falls back to the email so a user
|
|
45
|
+
* who was invited but has not set a name yet still lands somewhere sensible.
|
|
46
|
+
*/
|
|
47
|
+
public static getDisplayName(teamMember: TeamMember): string {
|
|
48
|
+
return (
|
|
49
|
+
teamMember.user?.name?.toString() ||
|
|
50
|
+
teamMember.user?.email?.toString() ||
|
|
51
|
+
""
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* One row per user, in the order each user was first seen. The input order is
|
|
57
|
+
* whatever the server sorted by, so first-seen order keeps that sort intact.
|
|
58
|
+
*
|
|
59
|
+
* The returned rows are the same TeamMember instances that came in (the first
|
|
60
|
+
* membership seen for each user), mutated with the aggregate fields.
|
|
61
|
+
*/
|
|
62
|
+
public static groupByUser(
|
|
63
|
+
teamMembers: Array<TeamMember>,
|
|
64
|
+
): Array<ProjectUserRow> {
|
|
65
|
+
const rowsByGroupKey: Map<string, ProjectUserRow> = new Map<
|
|
66
|
+
string,
|
|
67
|
+
ProjectUserRow
|
|
68
|
+
>();
|
|
69
|
+
const rows: Array<ProjectUserRow> = [];
|
|
70
|
+
|
|
71
|
+
/*
|
|
72
|
+
* Which teams are already on a row, keyed the same way for every
|
|
73
|
+
* membership. Tracked here rather than re-derived from `teamsForUser`
|
|
74
|
+
* because a membership identifies its team by `teamId` while the team
|
|
75
|
+
* object it carries identifies itself by `_id`, and either one can be
|
|
76
|
+
* missing from a given select.
|
|
77
|
+
*/
|
|
78
|
+
const teamKeysByRow: Map<ProjectUserRow, Set<string>> = new Map<
|
|
79
|
+
ProjectUserRow,
|
|
80
|
+
Set<string>
|
|
81
|
+
>();
|
|
82
|
+
|
|
83
|
+
/*
|
|
84
|
+
* Every membership id folded into each row, so the row can be given a
|
|
85
|
+
* stable identity below.
|
|
86
|
+
*/
|
|
87
|
+
const membershipIdsByRow: Map<ProjectUserRow, Array<string>> = new Map<
|
|
88
|
+
ProjectUserRow,
|
|
89
|
+
Array<string>
|
|
90
|
+
>();
|
|
91
|
+
|
|
92
|
+
for (const teamMember of teamMembers) {
|
|
93
|
+
const groupKey: string | null = this.getGroupKey(teamMember);
|
|
94
|
+
|
|
95
|
+
const existingRow: ProjectUserRow | undefined = groupKey
|
|
96
|
+
? rowsByGroupKey.get(groupKey)
|
|
97
|
+
: undefined;
|
|
98
|
+
|
|
99
|
+
if (existingRow) {
|
|
100
|
+
this.addMembershipToRow(
|
|
101
|
+
existingRow,
|
|
102
|
+
teamMember,
|
|
103
|
+
teamKeysByRow.get(existingRow)!,
|
|
104
|
+
Boolean(teamMember.hasAcceptedInvitation),
|
|
105
|
+
);
|
|
106
|
+
this.rememberMembershipId(
|
|
107
|
+
membershipIdsByRow.get(existingRow)!,
|
|
108
|
+
teamMember,
|
|
109
|
+
);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const row: ProjectUserRow = teamMember as ProjectUserRow;
|
|
114
|
+
const teamKeys: Set<string> = new Set<string>();
|
|
115
|
+
const membershipIds: Array<string> = [];
|
|
116
|
+
|
|
117
|
+
/*
|
|
118
|
+
* The row *is* this membership, so read its acceptance before the reset
|
|
119
|
+
* below overwrites it.
|
|
120
|
+
*/
|
|
121
|
+
const hasAcceptedInvitation: boolean = Boolean(
|
|
122
|
+
teamMember.hasAcceptedInvitation,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
row.teamsForUser = [];
|
|
126
|
+
row.teamCountForUser = 0;
|
|
127
|
+
row.pendingTeamCountForUser = 0;
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* Reset before folding the row's own membership back in: on a grouped row
|
|
131
|
+
* this field means "is a member of this project", which is true as soon as
|
|
132
|
+
* any one of the memberships has been accepted.
|
|
133
|
+
*/
|
|
134
|
+
row.hasAcceptedInvitation = false;
|
|
135
|
+
|
|
136
|
+
teamKeysByRow.set(row, teamKeys);
|
|
137
|
+
membershipIdsByRow.set(row, membershipIds);
|
|
138
|
+
this.addMembershipToRow(row, teamMember, teamKeys, hasAcceptedInvitation);
|
|
139
|
+
this.rememberMembershipId(membershipIds, teamMember);
|
|
140
|
+
|
|
141
|
+
if (groupKey) {
|
|
142
|
+
rowsByGroupKey.set(groupKey, row);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
rows.push(row);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
for (const row of rows) {
|
|
149
|
+
this.finalizeRow(row, membershipIdsByRow.get(row) || []);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return rows;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Replaces the team aggregate on each row with the one derived from
|
|
157
|
+
* `allTeamMembers`.
|
|
158
|
+
*
|
|
159
|
+
* Needed because the rows on screen may have been built from a *filtered*
|
|
160
|
+
* membership list - filter the table by one team and grouping only ever sees
|
|
161
|
+
* that team, so the Teams column would claim each user belongs to exactly the
|
|
162
|
+
* team that was filtered for. The caller re-reads the unfiltered memberships
|
|
163
|
+
* for the users on the current page and merges them back in here.
|
|
164
|
+
*
|
|
165
|
+
* Rows with no matching membership in `allTeamMembers` are left untouched.
|
|
166
|
+
*/
|
|
167
|
+
public static mergeAllTeamsIntoRows(
|
|
168
|
+
rows: Array<ProjectUserRow>,
|
|
169
|
+
allTeamMembers: Array<TeamMember>,
|
|
170
|
+
): Array<ProjectUserRow> {
|
|
171
|
+
const groupedRows: Array<ProjectUserRow> = this.groupByUser(allTeamMembers);
|
|
172
|
+
|
|
173
|
+
const groupedRowsByKey: Map<string, ProjectUserRow> = new Map<
|
|
174
|
+
string,
|
|
175
|
+
ProjectUserRow
|
|
176
|
+
>();
|
|
177
|
+
|
|
178
|
+
for (const groupedRow of groupedRows) {
|
|
179
|
+
const groupKey: string | null = this.getGroupKey(groupedRow);
|
|
180
|
+
|
|
181
|
+
if (groupKey) {
|
|
182
|
+
groupedRowsByKey.set(groupKey, groupedRow);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
for (const row of rows) {
|
|
187
|
+
const groupKey: string | null = this.getGroupKey(row);
|
|
188
|
+
const groupedRow: ProjectUserRow | undefined = groupKey
|
|
189
|
+
? groupedRowsByKey.get(groupKey)
|
|
190
|
+
: undefined;
|
|
191
|
+
|
|
192
|
+
if (!groupedRow) {
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
row.teamsForUser = groupedRow.teamsForUser;
|
|
197
|
+
row.teamCountForUser = groupedRow.teamCountForUser;
|
|
198
|
+
row.pendingTeamCountForUser = groupedRow.pendingTeamCountForUser;
|
|
199
|
+
row.hasAcceptedInvitation = Boolean(groupedRow.hasAcceptedInvitation);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return rows;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Alphabetical by display name, case-insensitively. Rows with no name at all
|
|
207
|
+
* sort last so the list does not open on a run of blanks.
|
|
208
|
+
*
|
|
209
|
+
* Returns a new array; the input is left alone.
|
|
210
|
+
*/
|
|
211
|
+
public static sortRowsByUserName(
|
|
212
|
+
rows: Array<ProjectUserRow>,
|
|
213
|
+
): Array<ProjectUserRow> {
|
|
214
|
+
return [...rows].sort((a: ProjectUserRow, b: ProjectUserRow) => {
|
|
215
|
+
const nameA: string = this.getDisplayName(a).toLowerCase();
|
|
216
|
+
const nameB: string = this.getDisplayName(b).toLowerCase();
|
|
217
|
+
|
|
218
|
+
if (!nameA && !nameB) {
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (!nameA) {
|
|
223
|
+
return 1;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (!nameB) {
|
|
227
|
+
return -1;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return nameA.localeCompare(nameB);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private static addMembershipToRow(
|
|
235
|
+
row: ProjectUserRow,
|
|
236
|
+
teamMember: TeamMember,
|
|
237
|
+
teamKeys: Set<string>,
|
|
238
|
+
hasAcceptedInvitation: boolean,
|
|
239
|
+
): void {
|
|
240
|
+
if (hasAcceptedInvitation) {
|
|
241
|
+
row.hasAcceptedInvitation = true;
|
|
242
|
+
} else {
|
|
243
|
+
row.pendingTeamCountForUser = row.pendingTeamCountForUser + 1;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const team: Team | undefined = teamMember.team;
|
|
247
|
+
|
|
248
|
+
if (!team) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const teamKey: string =
|
|
253
|
+
teamMember.teamId?.toString() ||
|
|
254
|
+
team._id?.toString() ||
|
|
255
|
+
team.name?.toString() ||
|
|
256
|
+
"";
|
|
257
|
+
|
|
258
|
+
if (!teamKey || teamKeys.has(teamKey)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
teamKeys.add(teamKey);
|
|
263
|
+
row.teamsForUser.push(team);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private static rememberMembershipId(
|
|
267
|
+
membershipIds: Array<string>,
|
|
268
|
+
teamMember: TeamMember,
|
|
269
|
+
): void {
|
|
270
|
+
const membershipId: string = teamMember._id?.toString() || "";
|
|
271
|
+
|
|
272
|
+
if (membershipId) {
|
|
273
|
+
membershipIds.push(membershipId);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
private static finalizeRow(
|
|
278
|
+
row: ProjectUserRow,
|
|
279
|
+
membershipIds: Array<string>,
|
|
280
|
+
): void {
|
|
281
|
+
row.teamsForUser.sort((a: Team, b: Team) => {
|
|
282
|
+
return (a.name?.toString() || "")
|
|
283
|
+
.toLowerCase()
|
|
284
|
+
.localeCompare((b.name?.toString() || "").toLowerCase());
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
row.teamCountForUser = row.teamsForUser.length;
|
|
288
|
+
|
|
289
|
+
/*
|
|
290
|
+
* The row's id has to identify the *person*, not "whichever of their
|
|
291
|
+
* memberships was returned first". The table matches a selected row to an
|
|
292
|
+
* on-screen row by _id, and it fetches the on-screen page and the
|
|
293
|
+
* select-all set with two different sorts - so a first-seen id makes the
|
|
294
|
+
* same person carry different ids in the two results, and every
|
|
295
|
+
* multi-team user's checkbox silently fails to tick. The lowest membership
|
|
296
|
+
* id is stable under any ordering the server returns.
|
|
297
|
+
*/
|
|
298
|
+
if (membershipIds.length > 1) {
|
|
299
|
+
row._id = [...membershipIds].sort()[0]!;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import OneUptimeDate, { CalendarUnit } from "../../Types/Date";
|
|
2
|
+
import EventInterval from "../../Types/Events/EventInterval";
|
|
3
|
+
import Recurring from "../../Types/Events/Recurring";
|
|
4
|
+
import StatusPageReportPeriodType from "../../Types/StatusPage/StatusPageReportPeriodType";
|
|
5
|
+
import Timezone from "../../Types/Timezone";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* The exact stretch of time one scheduled status page report covers, plus the
|
|
9
|
+
* strings the email and the settings screen use to describe it.
|
|
10
|
+
*
|
|
11
|
+
* Deliberately pure and synchronous, and deliberately in Common/Utils rather
|
|
12
|
+
* than Common/Server: the settings screen renders the very same window the
|
|
13
|
+
* worker will use, so what the user is shown before saving is what actually
|
|
14
|
+
* gets emailed. That is the whole point of the calendar option - a report is no
|
|
15
|
+
* longer "whatever the last 30 days happened to be when the cron fired".
|
|
16
|
+
*/
|
|
17
|
+
export interface StatusPageReportPeriod {
|
|
18
|
+
// Inclusive. The first instant the report measures.
|
|
19
|
+
startDate: Date;
|
|
20
|
+
// Inclusive. The last instant the report measures.
|
|
21
|
+
endDate: Date;
|
|
22
|
+
// Whole days spanned, kept for display and for callers that think in days.
|
|
23
|
+
numberOfDays: number;
|
|
24
|
+
// The zone every boundary above was resolved in.
|
|
25
|
+
timezone: Timezone;
|
|
26
|
+
/*
|
|
27
|
+
* The `report.reportDates` template variable. Rolling windows keep the exact
|
|
28
|
+
* shape they have always had ("30 days (Jun 29, 2026 - Jul 29, 2026)") so
|
|
29
|
+
* customer-authored email templates written against it keep reading the same;
|
|
30
|
+
* calendar windows, which are new, are just the range.
|
|
31
|
+
*/
|
|
32
|
+
reportDates: string;
|
|
33
|
+
/*
|
|
34
|
+
* How a sentence refers to the period: "the last 30 days", "July 2026",
|
|
35
|
+
* "the week of Jul 27, 2026". Reads correctly after "your status summary
|
|
36
|
+
* for ...", which the old string did not once periods stopped being rolling.
|
|
37
|
+
*/
|
|
38
|
+
periodName: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default class StatusPageReportPeriodUtil {
|
|
42
|
+
public static readonly DEFAULT_REPORT_DATA_IN_DAYS: number = 30;
|
|
43
|
+
public static readonly DEFAULT_TIMEZONE: Timezone = Timezone.UTC;
|
|
44
|
+
|
|
45
|
+
public static getDefaultPeriodType(): StatusPageReportPeriodType {
|
|
46
|
+
return StatusPageReportPeriodType.Rolling;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Resolve the window a report sent at `sentAt` (default: now) covers.
|
|
51
|
+
*
|
|
52
|
+
* Everything is optional because this is called with a half-filled form as
|
|
53
|
+
* the user types, and with columns that are null on status pages created
|
|
54
|
+
* before reports were configurable. Missing values fall back to the same
|
|
55
|
+
* defaults the database columns carry.
|
|
56
|
+
*/
|
|
57
|
+
public static getReportPeriod(data: {
|
|
58
|
+
periodType?: StatusPageReportPeriodType | undefined;
|
|
59
|
+
reportRecurringInterval?: Recurring | undefined;
|
|
60
|
+
reportDataInDays?: number | undefined;
|
|
61
|
+
timezone?: Timezone | undefined;
|
|
62
|
+
sentAt?: Date | undefined;
|
|
63
|
+
}): StatusPageReportPeriod {
|
|
64
|
+
const timezone: Timezone = data.timezone || this.DEFAULT_TIMEZONE;
|
|
65
|
+
const sentAt: Date = data.sentAt || OneUptimeDate.getCurrentDate();
|
|
66
|
+
|
|
67
|
+
if (data.periodType === StatusPageReportPeriodType.PreviousCalendarPeriod) {
|
|
68
|
+
return this.getPreviousCalendarPeriod({
|
|
69
|
+
reportRecurringInterval: data.reportRecurringInterval,
|
|
70
|
+
timezone: timezone,
|
|
71
|
+
sentAt: sentAt,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return this.getRollingPeriod({
|
|
76
|
+
reportDataInDays: data.reportDataInDays,
|
|
77
|
+
timezone: timezone,
|
|
78
|
+
sentAt: sentAt,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private static getRollingPeriod(data: {
|
|
83
|
+
reportDataInDays?: number | undefined;
|
|
84
|
+
timezone: Timezone;
|
|
85
|
+
sentAt: Date;
|
|
86
|
+
}): StatusPageReportPeriod {
|
|
87
|
+
const numberOfDays: number = this.toWholeDays(
|
|
88
|
+
data.reportDataInDays,
|
|
89
|
+
this.DEFAULT_REPORT_DATA_IN_DAYS,
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const endDate: Date = data.sentAt;
|
|
93
|
+
const startDate: Date = OneUptimeDate.getSomeDaysAgoFromDate(
|
|
94
|
+
endDate,
|
|
95
|
+
numberOfDays,
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
startDate: startDate,
|
|
100
|
+
endDate: endDate,
|
|
101
|
+
numberOfDays: numberOfDays,
|
|
102
|
+
timezone: data.timezone,
|
|
103
|
+
reportDates: `${numberOfDays} days (${this.formatDay(startDate, data.timezone)} - ${this.formatDay(endDate, data.timezone)})`,
|
|
104
|
+
periodName:
|
|
105
|
+
numberOfDays === 1 ? "the last day" : `the last ${numberOfDays} days`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/*
|
|
110
|
+
* The last WHOLE calendar period before the report went out, sized by the
|
|
111
|
+
* send frequency. A monthly report sent at any point in August covers
|
|
112
|
+
* 1 Aug 00:00:00.000 minus one month through 31 Jul 23:59:59.999 - i.e. July,
|
|
113
|
+
* exactly as it reads on a calendar, in the status page's report timezone.
|
|
114
|
+
*/
|
|
115
|
+
private static getPreviousCalendarPeriod(data: {
|
|
116
|
+
reportRecurringInterval?: Recurring | undefined;
|
|
117
|
+
timezone: Timezone;
|
|
118
|
+
sentAt: Date;
|
|
119
|
+
}): StatusPageReportPeriod {
|
|
120
|
+
const recurring: Recurring = data.reportRecurringInterval
|
|
121
|
+
? Recurring.fromJSON(data.reportRecurringInterval)
|
|
122
|
+
: Recurring.getDefault();
|
|
123
|
+
|
|
124
|
+
const unit: CalendarUnit = Recurring.toCalendarUnit(recurring.intervalType);
|
|
125
|
+
const intervalCount: number = this.toWholeDays(
|
|
126
|
+
recurring.intervalCount?.toNumber(),
|
|
127
|
+
1,
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
/*
|
|
131
|
+
* Exclusive upper bound: the start of the period the report is being sent
|
|
132
|
+
* IN, which is the first instant not yet covered. The inclusive endDate
|
|
133
|
+
* below steps back a millisecond from it so the email reads "Jul 31" rather
|
|
134
|
+
* than "Aug 1".
|
|
135
|
+
*/
|
|
136
|
+
const endExclusive: Date = OneUptimeDate.getStartOfCalendarUnit(
|
|
137
|
+
data.sentAt,
|
|
138
|
+
unit,
|
|
139
|
+
data.timezone,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const startDate: Date = OneUptimeDate.addRemoveCalendarUnits(
|
|
143
|
+
endExclusive,
|
|
144
|
+
unit,
|
|
145
|
+
-intervalCount,
|
|
146
|
+
data.timezone,
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const endDate: Date = new Date(endExclusive.getTime() - 1);
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
startDate: startDate,
|
|
153
|
+
endDate: endDate,
|
|
154
|
+
numberOfDays: Math.max(
|
|
155
|
+
1,
|
|
156
|
+
Math.round(
|
|
157
|
+
(endExclusive.getTime() - startDate.getTime()) /
|
|
158
|
+
OneUptimeDate.getMillisecondsInDays(1),
|
|
159
|
+
),
|
|
160
|
+
),
|
|
161
|
+
timezone: data.timezone,
|
|
162
|
+
reportDates: `${this.formatDay(startDate, data.timezone)} - ${this.formatDay(endDate, data.timezone)}`,
|
|
163
|
+
periodName: this.getCalendarPeriodName({
|
|
164
|
+
intervalType: recurring.intervalType,
|
|
165
|
+
intervalCount: intervalCount,
|
|
166
|
+
startDate: startDate,
|
|
167
|
+
endDate: endDate,
|
|
168
|
+
timezone: data.timezone,
|
|
169
|
+
}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private static getCalendarPeriodName(data: {
|
|
174
|
+
intervalType: EventInterval;
|
|
175
|
+
intervalCount: number;
|
|
176
|
+
startDate: Date;
|
|
177
|
+
endDate: Date;
|
|
178
|
+
timezone: Timezone;
|
|
179
|
+
}): string {
|
|
180
|
+
/*
|
|
181
|
+
* Only a single-unit period has a name a reader already knows ("July 2026").
|
|
182
|
+
* Anything spanning several units, and hourly periods, are clearer as an
|
|
183
|
+
* explicit range.
|
|
184
|
+
*/
|
|
185
|
+
if (data.intervalCount === 1) {
|
|
186
|
+
if (data.intervalType === EventInterval.Month) {
|
|
187
|
+
return this.format(data.startDate, "MMMM YYYY", data.timezone);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (data.intervalType === EventInterval.Year) {
|
|
191
|
+
return this.format(data.startDate, "YYYY", data.timezone);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (data.intervalType === EventInterval.Week) {
|
|
195
|
+
return `the week of ${this.formatDay(data.startDate, data.timezone)}`;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (data.intervalType === EventInterval.Day) {
|
|
199
|
+
return this.formatDay(data.startDate, data.timezone);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return `${this.formatDay(data.startDate, data.timezone)} - ${this.formatDay(data.endDate, data.timezone)}`;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/*
|
|
207
|
+
* Guard against the nulls, decimals and zeroes a JSON column or a mid-edit
|
|
208
|
+
* form field can hold. A zero-length window would divide by zero downstream.
|
|
209
|
+
*/
|
|
210
|
+
private static toWholeDays(
|
|
211
|
+
value: number | undefined | null,
|
|
212
|
+
fallback: number,
|
|
213
|
+
): number {
|
|
214
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value < 1) {
|
|
215
|
+
return fallback;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return Math.floor(value);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
private static formatDay(date: Date, timezone: Timezone): string {
|
|
222
|
+
return this.format(date, "MMM D, YYYY", timezone);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private static format(
|
|
226
|
+
date: Date,
|
|
227
|
+
format: string,
|
|
228
|
+
timezone: Timezone,
|
|
229
|
+
): string {
|
|
230
|
+
return OneUptimeDate.getDateAsCustomFormattedStringInTimezone({
|
|
231
|
+
date: date,
|
|
232
|
+
format: format,
|
|
233
|
+
timezone: timezone,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Normalization for the OpenTelemetry `host.ip` resource attribute, which
|
|
3
|
+
* is an ARRAY of every address on every interface — not a single IP.
|
|
4
|
+
*
|
|
5
|
+
* On a Docker host with IPv6 enabled that array grows with the container
|
|
6
|
+
* count: the physical NIC, one address per docker bridge, one per veth,
|
|
7
|
+
* plus an IPv6 link-local per interface. 55 addresses / ~1450 characters
|
|
8
|
+
* has been observed in the wild (issue #3006), and there is no upper
|
|
9
|
+
* bound in the OTel spec.
|
|
10
|
+
*
|
|
11
|
+
* `Host.hostIpAddresses` is a `text` column so the realistic case is
|
|
12
|
+
* stored losslessly. These caps exist only so a pathological (or hostile)
|
|
13
|
+
* collector cannot push an unbounded blob into Postgres on every batch.
|
|
14
|
+
* They sit far above any plausible host, so in practice this function
|
|
15
|
+
* dedupes and joins and nothing else.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Maximum number of addresses retained. */
|
|
19
|
+
export const MAX_HOST_IP_ADDRESS_COUNT: number = 256;
|
|
20
|
+
|
|
21
|
+
/** Maximum length of the serialized, comma-separated list. */
|
|
22
|
+
export const MAX_HOST_IP_ADDRESSES_LENGTH: number = 10000;
|
|
23
|
+
|
|
24
|
+
const SEPARATOR: string = ", ";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Turn the raw `host.ip` values into the comma-separated string stored in
|
|
28
|
+
* `Host.hostIpAddresses`.
|
|
29
|
+
*
|
|
30
|
+
* - blank / whitespace-only entries are dropped,
|
|
31
|
+
* - each entry is trimmed,
|
|
32
|
+
* - duplicates are removed case-insensitively (IPv6 hex casing is not
|
|
33
|
+
* stable across resource detectors, so `FE80::1` and `fe80::1` are the
|
|
34
|
+
* same address),
|
|
35
|
+
* - source order is preserved — collectors report interfaces in a stable,
|
|
36
|
+
* meaningful order and reordering would churn the Hosts table column,
|
|
37
|
+
* - the result is capped by both address count and serialized length.
|
|
38
|
+
*
|
|
39
|
+
* Truncation always drops whole addresses from the tail. A half-written
|
|
40
|
+
* address would be worse than a missing one: it reads as a real address
|
|
41
|
+
* and there is no way for a consumer to tell it was cut.
|
|
42
|
+
*
|
|
43
|
+
* Returns `null` when nothing survives, so callers can leave the column
|
|
44
|
+
* untouched rather than writing an empty string.
|
|
45
|
+
*/
|
|
46
|
+
export function normalizeHostIpAddresses(
|
|
47
|
+
ipAddresses: Array<string> | null | undefined,
|
|
48
|
+
): string | null {
|
|
49
|
+
if (!ipAddresses || ipAddresses.length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const seen: Set<string> = new Set<string>();
|
|
54
|
+
const kept: Array<string> = [];
|
|
55
|
+
let serializedLength: number = 0;
|
|
56
|
+
|
|
57
|
+
for (const raw of ipAddresses) {
|
|
58
|
+
if (typeof raw !== "string") {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const trimmed: string = raw.trim();
|
|
63
|
+
if (!trimmed) {
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const dedupeKey: string = trimmed.toLowerCase();
|
|
68
|
+
if (seen.has(dedupeKey)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const lengthWithSeparator: number =
|
|
73
|
+
trimmed.length + (kept.length > 0 ? SEPARATOR.length : 0);
|
|
74
|
+
|
|
75
|
+
if (serializedLength + lengthWithSeparator > MAX_HOST_IP_ADDRESSES_LENGTH) {
|
|
76
|
+
/*
|
|
77
|
+
* Stop rather than continue: entries are already ordered by the
|
|
78
|
+
* collector, so skipping this one to squeeze in a shorter later one
|
|
79
|
+
* would make the stored list order-dependent on address width.
|
|
80
|
+
*/
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
seen.add(dedupeKey);
|
|
85
|
+
kept.push(trimmed);
|
|
86
|
+
serializedLength += lengthWithSeparator;
|
|
87
|
+
|
|
88
|
+
if (kept.length >= MAX_HOST_IP_ADDRESS_COUNT) {
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (kept.length === 0) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return kept.join(SEPARATOR);
|
|
98
|
+
}
|
|
@@ -49,6 +49,15 @@ let Host = class Host extends BaseModel {
|
|
|
49
49
|
this.hostId = undefined;
|
|
50
50
|
this.hostArch = undefined;
|
|
51
51
|
this.hostType = undefined;
|
|
52
|
+
/*
|
|
53
|
+
* `text`, not varchar(500). A Docker/Kubernetes host with IPv6 enabled
|
|
54
|
+
* reports one host.ip entry per interface — physical NICs, docker
|
|
55
|
+
* bridges, every veth, plus an IPv6 link-local per interface. Real
|
|
56
|
+
* reports of 55 addresses / ~1450 characters exist, and the count grows
|
|
57
|
+
* with the number of containers, so any fixed bound is the wrong shape
|
|
58
|
+
* here. Overflowing it used to abort the whole Host metadata write and
|
|
59
|
+
* strand the host as "disconnected" (issue #3006).
|
|
60
|
+
*/
|
|
52
61
|
this.hostIpAddresses = undefined;
|
|
53
62
|
this.cpuCores = undefined;
|
|
54
63
|
this.totalMemoryBytes = undefined;
|
|
@@ -619,16 +628,15 @@ __decorate([
|
|
|
619
628
|
}),
|
|
620
629
|
TableColumn({
|
|
621
630
|
required: false,
|
|
622
|
-
type: TableColumnType.
|
|
631
|
+
type: TableColumnType.VeryLongText,
|
|
623
632
|
canReadOnRelationQuery: true,
|
|
624
633
|
title: "Host IP Addresses",
|
|
625
|
-
description: "Comma-separated list of IP
|
|
634
|
+
description: "Comma-separated list of every IP address reported by the OTel host.ip resource attribute, in the order the collector reported them, deduplicated. The Hosts list shows the most routable one (IPv4, non-loopback, non-link-local) first; the host detail page groups them all by category.",
|
|
626
635
|
example: "192.168.1.42, 10.0.0.5",
|
|
627
636
|
}),
|
|
628
637
|
Column({
|
|
629
638
|
nullable: true,
|
|
630
|
-
type: ColumnType.
|
|
631
|
-
length: ColumnLength.LongText,
|
|
639
|
+
type: ColumnType.VeryLongText,
|
|
632
640
|
}),
|
|
633
641
|
__metadata("design:type", String)
|
|
634
642
|
], Host.prototype, "hostIpAddresses", void 0);
|