@oneuptime/common 12.0.31 → 12.0.32

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 (188) hide show
  1. package/Models/DatabaseModels/AlertState.ts +0 -2
  2. package/Models/DatabaseModels/Domain.ts +1 -1
  3. package/Models/DatabaseModels/Incident.ts +1 -1
  4. package/Models/DatabaseModels/IncidentTemplate.ts +1 -1
  5. package/Models/DatabaseModels/Index.ts +2 -0
  6. package/Models/DatabaseModels/MetricType.ts +0 -2
  7. package/Models/DatabaseModels/MonitorStatusTimeline.ts +0 -2
  8. package/Models/DatabaseModels/MonitorTest.ts +0 -2
  9. package/Models/DatabaseModels/NetworkDevice.ts +121 -2
  10. package/Models/DatabaseModels/NetworkDeviceOidTemplate.ts +3 -1
  11. package/Models/DatabaseModels/NetworkDeviceRole.ts +648 -0
  12. package/Models/DatabaseModels/ScheduledMaintenance.ts +1 -1
  13. package/Models/DatabaseModels/ScheduledMaintenanceTemplate.ts +1 -1
  14. package/Models/DatabaseModels/StatusPageAnnouncement.ts +0 -2
  15. package/Models/DatabaseModels/StatusPageAnnouncementTemplate.ts +0 -2
  16. package/Models/DatabaseModels/StatusPagePrivateUser.ts +0 -2
  17. package/Models/DatabaseModels/StatusPageResource.ts +0 -2
  18. package/Models/DatabaseModels/StatusPageSubscriber.ts +0 -2
  19. package/Server/Infrastructure/Postgres/SchemaMigrations/1790800000000-AddNetworkDeviceRoleTable.ts +72 -0
  20. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  21. package/Server/Services/DatabaseService.ts +39 -9
  22. package/Server/Services/Index.ts +2 -0
  23. package/Server/Services/NetworkDeviceRoleService.ts +90 -0
  24. package/Server/Services/ProjectService.ts +85 -0
  25. package/Server/Services/UserNotificationSettingService.ts +0 -6
  26. package/Tests/App/Dashboard/AddNeighborToMonitoringModal.test.tsx +31 -1
  27. package/Tests/App/Dashboard/DashboardChartWidgetZoom.test.tsx +35 -8
  28. package/Tests/App/Dashboard/DashboardCommandPalette.test.tsx +107 -3
  29. package/Tests/App/Dashboard/DashboardWideChartZoom.test.tsx +401 -0
  30. package/Tests/App/Dashboard/MonitorTemplateColumnAndFacet.test.tsx +318 -0
  31. package/Tests/App/Dashboard/NetworkDeviceBulkDelete.test.tsx +357 -0
  32. package/Tests/App/Dashboard/NetworkSideMenu.test.tsx +590 -0
  33. package/Tests/App/Dashboard/SideMenuHarness.tsx +11 -3
  34. package/Tests/Models/DatabaseModels/ModelRegistryInvariants.test.ts +115 -41
  35. package/Tests/Server/Infrastructure/Postgres/NetworkDeviceRoleTableMigration.test.ts +476 -0
  36. package/Tests/Server/Services/DatabaseServiceGenerateSlug.test.ts +215 -0
  37. package/Tests/Server/Services/NetworkDeviceRoleModel.test.ts +672 -0
  38. package/Tests/Server/Services/NetworkDeviceRuleEngines.test.ts +1 -1
  39. package/Tests/Server/Services/ProjectServiceCreateSubscriptionStarted.test.ts +67 -4
  40. package/Tests/Server/Services/ScheduledMaintenanceSubscriberEndTime.test.ts +369 -0
  41. package/Tests/Server/Services/UserNotificationSettingMonitorDefaults.test.ts +248 -0
  42. package/Tests/Server/Services/UserNotificationSettingWorkspaceChannels.test.ts +43 -2
  43. package/Tests/Server/Utils/BasicCron.test.ts +283 -0
  44. package/Tests/Server/Utils/IncomingCallPhoneNumber.test.ts +174 -0
  45. package/Tests/Types/NetworkDevice/DefaultNetworkDeviceRole.test.ts +417 -0
  46. package/Tests/UI/Components/Charts/ChartClickDoubleClickDisambiguation.test.tsx +221 -0
  47. package/Tests/UI/Components/Charts/ChartDoubleClickReset.test.tsx +220 -0
  48. package/Tests/UI/Components/ModelTable/BaseModelTableBulkDelete.test.tsx +751 -0
  49. package/Tests/UI/Components/ModelTable/BaseModelTableColumnCustomization.test.tsx +475 -43
  50. package/Tests/UI/Components/ModelTable/ColumnPreference.test.ts +89 -0
  51. package/Tests/UI/Components/NavBarCommandKGating.test.tsx +103 -8
  52. package/Tests/UI/Components/SideMenuItem.test.tsx +30 -0
  53. package/Tests/UI/Utils/TableColumnsToCsv.test.ts +30 -0
  54. package/Tests/UI/Utils/UseDashboardTimeRangeZoom.test.tsx +187 -0
  55. package/Tests/Utils/Dashboard/DashboardResourceListSharedArgs.test.ts +302 -0
  56. package/Tests/Utils/Dashboard/DashboardTimeRangeZoom.test.ts +242 -0
  57. package/Tests/Utils/Monitor/NetworkDeviceRoleCatalog.test.ts +981 -0
  58. package/Tests/Utils/Monitor/NetworkTopologyRoleCatalog.test.ts +865 -0
  59. package/Tests/Utils/NetworkDevice/DeviceRoleKeyUtil.test.ts +538 -0
  60. package/Tests/Utils/Slo/SloEvaluation.test.ts +171 -0
  61. package/Tests/Utils/Slug.test.ts +61 -1
  62. package/Tests/jest.setup.ts +19 -0
  63. package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +61 -0
  64. package/Types/NetworkDevice/DefaultNetworkDeviceRole.ts +145 -0
  65. package/Types/Permission.ts +45 -0
  66. package/UI/Components/Charts/Area/AreaChart.tsx +7 -0
  67. package/UI/Components/Charts/Bar/BarChart.tsx +6 -0
  68. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +9 -1
  69. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +97 -35
  70. package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +14 -0
  71. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +97 -35
  72. package/UI/Components/Charts/ChartLibrary/Utils/DoubleClick.ts +13 -0
  73. package/UI/Components/Charts/Line/LineChart.tsx +7 -0
  74. package/UI/Components/ModelTable/BaseModelTable.tsx +50 -15
  75. package/UI/Components/Navbar/NavBar.tsx +62 -13
  76. package/UI/Components/Navbar/NavBarMenuModal.tsx +7 -2
  77. package/UI/Components/SideMenu/CountModelSideMenuItem.tsx +2 -0
  78. package/UI/Components/SideMenu/SideMenu.tsx +12 -2
  79. package/UI/Components/SideMenu/SideMenuItem.tsx +4 -1
  80. package/UI/Components/SideMenu/SideMenuSection.tsx +14 -2
  81. package/UI/Utils/UseDashboardTimeRangeZoom.ts +77 -0
  82. package/Utils/Dashboard/DashboardTimeRangeZoom.ts +118 -0
  83. package/Utils/Monitor/NetworkDeviceRoleCatalog.ts +232 -0
  84. package/Utils/Monitor/NetworkDeviceRoleUtil.ts +2 -1
  85. package/Utils/Monitor/NetworkTopologyUtil.ts +116 -33
  86. package/Utils/NetworkDevice/DeviceRoleKeyUtil.ts +137 -0
  87. package/Utils/Rules/RulePatternMatchUtil.ts +1 -1
  88. package/Utils/Slug.ts +34 -1
  89. package/build/dist/Models/DatabaseModels/AlertState.js +0 -2
  90. package/build/dist/Models/DatabaseModels/AlertState.js.map +1 -1
  91. package/build/dist/Models/DatabaseModels/Domain.js +1 -1
  92. package/build/dist/Models/DatabaseModels/Domain.js.map +1 -1
  93. package/build/dist/Models/DatabaseModels/Incident.js +1 -1
  94. package/build/dist/Models/DatabaseModels/Incident.js.map +1 -1
  95. package/build/dist/Models/DatabaseModels/IncidentTemplate.js +1 -1
  96. package/build/dist/Models/DatabaseModels/IncidentTemplate.js.map +1 -1
  97. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  98. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  99. package/build/dist/Models/DatabaseModels/MetricType.js +0 -2
  100. package/build/dist/Models/DatabaseModels/MetricType.js.map +1 -1
  101. package/build/dist/Models/DatabaseModels/MonitorStatusTimeline.js +0 -2
  102. package/build/dist/Models/DatabaseModels/MonitorStatusTimeline.js.map +1 -1
  103. package/build/dist/Models/DatabaseModels/MonitorTest.js +0 -2
  104. package/build/dist/Models/DatabaseModels/MonitorTest.js.map +1 -1
  105. package/build/dist/Models/DatabaseModels/NetworkDevice.js +124 -3
  106. package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
  107. package/build/dist/Models/DatabaseModels/NetworkDeviceOidTemplate.js +3 -1
  108. package/build/dist/Models/DatabaseModels/NetworkDeviceOidTemplate.js.map +1 -1
  109. package/build/dist/Models/DatabaseModels/NetworkDeviceRole.js +677 -0
  110. package/build/dist/Models/DatabaseModels/NetworkDeviceRole.js.map +1 -0
  111. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js +1 -1
  112. package/build/dist/Models/DatabaseModels/ScheduledMaintenance.js.map +1 -1
  113. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceTemplate.js +1 -1
  114. package/build/dist/Models/DatabaseModels/ScheduledMaintenanceTemplate.js.map +1 -1
  115. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js +0 -2
  116. package/build/dist/Models/DatabaseModels/StatusPageAnnouncement.js.map +1 -1
  117. package/build/dist/Models/DatabaseModels/StatusPageAnnouncementTemplate.js +0 -2
  118. package/build/dist/Models/DatabaseModels/StatusPageAnnouncementTemplate.js.map +1 -1
  119. package/build/dist/Models/DatabaseModels/StatusPagePrivateUser.js +0 -2
  120. package/build/dist/Models/DatabaseModels/StatusPagePrivateUser.js.map +1 -1
  121. package/build/dist/Models/DatabaseModels/StatusPageResource.js +0 -2
  122. package/build/dist/Models/DatabaseModels/StatusPageResource.js.map +1 -1
  123. package/build/dist/Models/DatabaseModels/StatusPageSubscriber.js +0 -2
  124. package/build/dist/Models/DatabaseModels/StatusPageSubscriber.js.map +1 -1
  125. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790800000000-AddNetworkDeviceRoleTable.js +39 -0
  126. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1790800000000-AddNetworkDeviceRoleTable.js.map +1 -0
  127. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  128. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  129. package/build/dist/Server/Services/DatabaseService.js +31 -5
  130. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  131. package/build/dist/Server/Services/Index.js +2 -0
  132. package/build/dist/Server/Services/Index.js.map +1 -1
  133. package/build/dist/Server/Services/NetworkDeviceRoleService.js +70 -0
  134. package/build/dist/Server/Services/NetworkDeviceRoleService.js.map +1 -0
  135. package/build/dist/Server/Services/ProjectService.js +65 -0
  136. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  137. package/build/dist/Server/Services/UserNotificationSettingService.js +0 -1
  138. package/build/dist/Server/Services/UserNotificationSettingService.js.map +1 -1
  139. package/build/dist/Types/NetworkDevice/DefaultNetworkDeviceRole.js +105 -0
  140. package/build/dist/Types/NetworkDevice/DefaultNetworkDeviceRole.js.map +1 -0
  141. package/build/dist/Types/Permission.js +40 -0
  142. package/build/dist/Types/Permission.js.map +1 -1
  143. package/build/dist/UI/Components/Charts/Area/AreaChart.js +1 -1
  144. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  145. package/build/dist/UI/Components/Charts/Bar/BarChart.js +1 -1
  146. package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
  147. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +6 -1
  148. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  149. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +79 -31
  150. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  151. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +7 -1
  152. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
  153. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +79 -31
  154. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  155. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/DoubleClick.js +14 -0
  156. package/build/dist/UI/Components/Charts/ChartLibrary/Utils/DoubleClick.js.map +1 -0
  157. package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
  158. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  159. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +39 -13
  160. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  161. package/build/dist/UI/Components/Navbar/NavBar.js +44 -9
  162. package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
  163. package/build/dist/UI/Components/Navbar/NavBarMenuModal.js +2 -2
  164. package/build/dist/UI/Components/Navbar/NavBarMenuModal.js.map +1 -1
  165. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js +1 -1
  166. package/build/dist/UI/Components/SideMenu/CountModelSideMenuItem.js.map +1 -1
  167. package/build/dist/UI/Components/SideMenu/SideMenu.js +9 -6
  168. package/build/dist/UI/Components/SideMenu/SideMenu.js.map +1 -1
  169. package/build/dist/UI/Components/SideMenu/SideMenuItem.js +1 -1
  170. package/build/dist/UI/Components/SideMenu/SideMenuItem.js.map +1 -1
  171. package/build/dist/UI/Components/SideMenu/SideMenuSection.js +7 -2
  172. package/build/dist/UI/Components/SideMenu/SideMenuSection.js.map +1 -1
  173. package/build/dist/UI/Utils/UseDashboardTimeRangeZoom.js +42 -0
  174. package/build/dist/UI/Utils/UseDashboardTimeRangeZoom.js.map +1 -0
  175. package/build/dist/Utils/Dashboard/DashboardTimeRangeZoom.js +74 -0
  176. package/build/dist/Utils/Dashboard/DashboardTimeRangeZoom.js.map +1 -0
  177. package/build/dist/Utils/Monitor/NetworkDeviceRoleCatalog.js +126 -0
  178. package/build/dist/Utils/Monitor/NetworkDeviceRoleCatalog.js.map +1 -0
  179. package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js +2 -1
  180. package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js.map +1 -1
  181. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +67 -32
  182. package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
  183. package/build/dist/Utils/NetworkDevice/DeviceRoleKeyUtil.js +114 -0
  184. package/build/dist/Utils/NetworkDevice/DeviceRoleKeyUtil.js.map +1 -0
  185. package/build/dist/Utils/Rules/RulePatternMatchUtil.js +1 -1
  186. package/build/dist/Utils/Slug.js +31 -1
  187. package/build/dist/Utils/Slug.js.map +1 -1
  188. package/package.json +1 -1
@@ -14,7 +14,6 @@ import EnableDocumentation from "../../Types/Database/EnableDocumentation";
14
14
  import EnableMCP from "../../Types/Database/EnableMCP";
15
15
  import EnableWorkflow from "../../Types/Database/EnableWorkflow";
16
16
  import ColorField from "../../Types/Database/ColorField";
17
- import SlugifyColumn from "../../Types/Database/SlugifyColumn";
18
17
  import TableColumn from "../../Types/Database/TableColumn";
19
18
  import TableColumnType from "../../Types/Database/TableColumnType";
20
19
  import TableMetadata from "../../Types/Database/TableMetadata";
@@ -71,7 +70,6 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
71
70
  read: true,
72
71
  })
73
72
  @CrudApiEndpoint(new Route("/alert-state"))
74
- @SlugifyColumn("name", "slug")
75
73
  @TableMetadata({
76
74
  tableName: "AlertState",
77
75
  singularName: "Alert State",
@@ -50,7 +50,7 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
50
50
  ],
51
51
  })
52
52
  @CrudApiEndpoint(new Route("/domain"))
53
- @SlugifyColumn("name", "slug")
53
+ @SlugifyColumn("domain", "slug")
54
54
  @TableMetadata({
55
55
  tableName: "Domain",
56
56
  singularName: "Domain",
@@ -101,7 +101,7 @@ import NotificationRuleWorkspaceChannel from "../../Types/Workspace/Notification
101
101
  ],
102
102
  })
103
103
  @CrudApiEndpoint(new Route("/incident"))
104
- @SlugifyColumn("name", "slug")
104
+ @SlugifyColumn("title", "slug")
105
105
  @Entity({
106
106
  name: "Incident",
107
107
  })
@@ -88,7 +88,7 @@ import { PlanType } from "../../Types/Billing/SubscriptionPlan";
88
88
  ],
89
89
  })
90
90
  @CrudApiEndpoint(new Route("/incident-templates"))
91
- @SlugifyColumn("name", "slug")
91
+ @SlugifyColumn("templateName", "slug")
92
92
  @Entity({
93
93
  name: "IncidentTemplate",
94
94
  })
@@ -13,6 +13,7 @@ import NetworkDeviceOwnerRule from "./NetworkDeviceOwnerRule";
13
13
  import NetworkDeviceLabelRule from "./NetworkDeviceLabelRule";
14
14
  import NetworkDeviceAutoImportRule from "./NetworkDeviceAutoImportRule";
15
15
  import NetworkDeviceOidTemplate from "./NetworkDeviceOidTemplate";
16
+ import NetworkDeviceRole from "./NetworkDeviceRole";
16
17
  import NetworkDeviceDiscoveryScan from "./NetworkDeviceDiscoveryScan";
17
18
  import NetworkInterface from "./NetworkInterface";
18
19
  import NetworkSite from "./NetworkSite";
@@ -880,6 +881,7 @@ const AllModelTypes: Array<{
880
881
  NetworkDeviceLabelRule,
881
882
  NetworkDeviceAutoImportRule,
882
883
  NetworkDeviceOidTemplate,
884
+ NetworkDeviceRole,
883
885
  NetworkDeviceDiscoveryScan,
884
886
  NetworkInterface,
885
887
  NetworkSite,
@@ -8,7 +8,6 @@ import ColumnType from "../../Types/Database/ColumnType";
8
8
  import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
9
9
  import EnableDocumentation from "../../Types/Database/EnableDocumentation";
10
10
  import EnableWorkflow from "../../Types/Database/EnableWorkflow";
11
- import SlugifyColumn from "../../Types/Database/SlugifyColumn";
12
11
  import TableColumn from "../../Types/Database/TableColumn";
13
12
  import TableColumnType from "../../Types/Database/TableColumnType";
14
13
  import TableMetadata from "../../Types/Database/TableMetadata";
@@ -72,7 +71,6 @@ import { AggregationTemporality } from "../AnalyticsModels/Metric";
72
71
  read: false,
73
72
  })
74
73
  @CrudApiEndpoint(new Route("/metric-type"))
75
- @SlugifyColumn("name", "slug")
76
74
  @TableMetadata({
77
75
  tableName: "MetricType",
78
76
  singularName: "Metric Type",
@@ -13,7 +13,6 @@ import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
13
13
  import EnableDocumentation from "../../Types/Database/EnableDocumentation";
14
14
  import EnableMCP from "../../Types/Database/EnableMCP";
15
15
  import EnableWorkflow from "../../Types/Database/EnableWorkflow";
16
- import SlugifyColumn from "../../Types/Database/SlugifyColumn";
17
16
  import TableColumn from "../../Types/Database/TableColumn";
18
17
  import TableColumnType from "../../Types/Database/TableColumnType";
19
18
  import TableMetadata from "../../Types/Database/TableMetadata";
@@ -73,7 +72,6 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
73
72
  read: true,
74
73
  })
75
74
  @CrudApiEndpoint(new Route("/monitor-status-timeline"))
76
- @SlugifyColumn("name", "slug")
77
75
  @OwnedThrough("monitorId", Monitor)
78
76
  @Entity({
79
77
  name: "MonitorStatusTimeline",
@@ -10,7 +10,6 @@ import ColumnLength from "../../Types/Database/ColumnLength";
10
10
  import ColumnType from "../../Types/Database/ColumnType";
11
11
  import CrudApiEndpoint from "../../Types/Database/CrudApiEndpoint";
12
12
  import EnableWorkflow from "../../Types/Database/EnableWorkflow";
13
- import SlugifyColumn from "../../Types/Database/SlugifyColumn";
14
13
  import TableColumn from "../../Types/Database/TableColumn";
15
14
  import TableColumnType from "../../Types/Database/TableColumnType";
16
15
  import TableMetadata from "../../Types/Database/TableMetadata";
@@ -70,7 +69,6 @@ import Monitor from "./Monitor";
70
69
  read: true,
71
70
  })
72
71
  @CrudApiEndpoint(new Route("/monitor-test"))
73
- @SlugifyColumn("name", "slug")
74
72
  @OwnedThrough("monitorId", Monitor)
75
73
  @Entity({
76
74
  name: "MonitorTest",
@@ -2,6 +2,7 @@ import Label from "./Label";
2
2
  import Monitor from "./Monitor";
3
3
  import MonitorStatus from "./MonitorStatus";
4
4
  import NetworkDeviceOidTemplate from "./NetworkDeviceOidTemplate";
5
+ import NetworkDeviceRole from "./NetworkDeviceRole";
5
6
  import NetworkSite from "./NetworkSite";
6
7
  import Probe from "./Probe";
7
8
  import Project from "./Project";
@@ -845,13 +846,22 @@ export default class NetworkDevice extends BaseModel {
845
846
  Permission.EditNetworkDevice,
846
847
  ],
847
848
  })
849
+ /*
850
+ * DEPRECATED. Device roles used to be a fixed union stored inline as a
851
+ * string; they are now the per-project NetworkDeviceRole lookup table
852
+ * below, so a project can rename them, change what each is drawn as, or add
853
+ * roles of its own. This column is retained ONLY so the
854
+ * BackfillNetworkDeviceRoles data migration can read the old value and
855
+ * point networkDeviceRoleId at the matching role row. It is dropped in a
856
+ * follow-up PR - do not read or write it from new code.
857
+ */
848
858
  @TableColumn({
849
859
  required: false,
850
860
  type: TableColumnType.ShortText,
851
861
  canReadOnRelationQuery: true,
852
- title: "Device Role",
862
+ title: "Device Role (Deprecated)",
853
863
  description:
854
- "What this device does on the network — router, switch, access point and so on. Left empty, the role is worked out from the device's own SNMP identity. Set it when there is no SNMP to read: a ping-only device has no identity to classify, and the role decides both the shape it is drawn with and where it sits in the topology hierarchy.",
864
+ "Deprecated legacy device role key. Use the Network Device Role relation instead; this column exists only for the backfill migration and will be removed.",
855
865
  example: "switch",
856
866
  })
857
867
  @Column({
@@ -861,6 +871,115 @@ export default class NetworkDevice extends BaseModel {
861
871
  })
862
872
  public deviceRole?: string = undefined;
863
873
 
874
+ @ColumnAccessControl({
875
+ create: [
876
+ Permission.ProjectOwner,
877
+ Permission.ProjectAdmin,
878
+ Permission.ProjectMember,
879
+ Permission.SettingsAdmin,
880
+ Permission.SettingsMember,
881
+ Permission.CreateNetworkDevice,
882
+ ],
883
+ read: [
884
+ Permission.ProjectOwner,
885
+ Permission.ProjectAdmin,
886
+ Permission.ProjectMember,
887
+ Permission.Viewer,
888
+ Permission.SettingsAdmin,
889
+ Permission.SettingsMember,
890
+ Permission.SettingsViewer,
891
+ Permission.ReadNetworkDevice,
892
+ ],
893
+ update: [
894
+ Permission.ProjectOwner,
895
+ Permission.ProjectAdmin,
896
+ Permission.ProjectMember,
897
+ Permission.SettingsAdmin,
898
+ Permission.SettingsMember,
899
+ Permission.EditNetworkDevice,
900
+ ],
901
+ })
902
+ /*
903
+ * The operator's own answer to what this device is, when they gave one.
904
+ *
905
+ * Empty is not "unknown": it means "no answer given", and the SNMP
906
+ * classifier is left to work the role out from the device's own identity.
907
+ * That is the better source when there IS an identity to read, which is
908
+ * why this is left empty on SNMP devices by default. On a device nothing
909
+ * walks - a ping-only device, a monitor-backed one - the classifier has
910
+ * only a hostname to go on, so this is the only statement about the role
911
+ * available at all, and it decides both the shape the device is drawn with
912
+ * and where it sits in the topology hierarchy.
913
+ *
914
+ * SET NULL on delete, deliberately: removing a role from the project's
915
+ * settings must not remove the devices that were using it. They simply go
916
+ * back to being classified from their SNMP identity.
917
+ */
918
+ @TableColumn({
919
+ manyToOneRelationColumn: "networkDeviceRoleId",
920
+ type: TableColumnType.Entity,
921
+ modelType: NetworkDeviceRole,
922
+ title: "Device Role",
923
+ description:
924
+ "What this device does on the network - Router, Switch, Wireless AP and so on. Configured per project in Network > Settings > Device Roles.",
925
+ })
926
+ @ManyToOne(
927
+ () => {
928
+ return NetworkDeviceRole;
929
+ },
930
+ {
931
+ eager: false,
932
+ nullable: true,
933
+ onDelete: "SET NULL",
934
+ orphanedRowAction: "nullify",
935
+ },
936
+ )
937
+ @JoinColumn({ name: "networkDeviceRoleId" })
938
+ public networkDeviceRole?: NetworkDeviceRole = undefined;
939
+
940
+ @ColumnAccessControl({
941
+ create: [
942
+ Permission.ProjectOwner,
943
+ Permission.ProjectAdmin,
944
+ Permission.ProjectMember,
945
+ Permission.SettingsAdmin,
946
+ Permission.SettingsMember,
947
+ Permission.CreateNetworkDevice,
948
+ ],
949
+ read: [
950
+ Permission.ProjectOwner,
951
+ Permission.ProjectAdmin,
952
+ Permission.ProjectMember,
953
+ Permission.Viewer,
954
+ Permission.SettingsAdmin,
955
+ Permission.SettingsMember,
956
+ Permission.SettingsViewer,
957
+ Permission.ReadNetworkDevice,
958
+ ],
959
+ update: [
960
+ Permission.ProjectOwner,
961
+ Permission.ProjectAdmin,
962
+ Permission.ProjectMember,
963
+ Permission.SettingsAdmin,
964
+ Permission.SettingsMember,
965
+ Permission.EditNetworkDevice,
966
+ ],
967
+ })
968
+ @Index()
969
+ @TableColumn({
970
+ required: false,
971
+ type: TableColumnType.ObjectID,
972
+ canReadOnRelationQuery: true,
973
+ title: "Device Role ID",
974
+ description: "ID of the Network Device Role this device is assigned.",
975
+ })
976
+ @Column({
977
+ type: ColumnType.ObjectID,
978
+ nullable: true,
979
+ transformer: ObjectID.getDatabaseTransformer(),
980
+ })
981
+ public networkDeviceRoleId?: ObjectID = undefined;
982
+
864
983
  @ColumnAccessControl({
865
984
  create: [
866
985
  Permission.ProjectOwner,
@@ -37,7 +37,9 @@ import { Column, Entity, Index, JoinColumn, ManyToOne } from "typeorm";
37
37
  *
38
38
  * The template's NAME is the device type. There is no NetworkDeviceType
39
39
  * model and every candidate matching key was defective: labels double as the
40
- * row-level ACL column, deviceRole is unconstrained free text, and
40
+ * row-level ACL column, deviceRole was unconstrained free text (it is
41
+ * the NetworkDeviceRole lookup now, but a role says what a device DOES, not
42
+ * which OIDs it answers), and
41
43
  * vendor/sysObjectId are probe-managed and NULL until the first successful
42
44
  * walk. Devices link by an explicit FK the operator sets, in bulk from the
43
45
  * device list.