@oneuptime/common 14.0.106 → 14.0.107
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/AuditLog.js +1 -1
- package/Models/AnalyticsModels/Index.js +3 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.mts +5 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.d.ts +5 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.js +300 -0
- package/Models/AnalyticsModels/RumProductAnalyticsEvent.mjs +3 -0
- package/Models/DatabaseModels/CallLog.d.mts +4 -0
- package/Models/DatabaseModels/CallLog.d.ts +4 -0
- package/Models/DatabaseModels/CallLog.js +85 -0
- package/Models/DatabaseModels/DataBiConnection.d.mts +3 -0
- package/Models/DatabaseModels/DataBiConnection.d.ts +3 -0
- package/Models/DatabaseModels/DataBiConnection.js +47 -1
- package/Models/DatabaseModels/DataDashboard.d.mts +10 -0
- package/Models/DatabaseModels/DataDashboard.d.ts +10 -0
- package/Models/DatabaseModels/DataDashboard.js +129 -2
- package/Models/DatabaseModels/Index.js +6 -0
- package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
- package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
- package/Models/DatabaseModels/NetworkDevice.js +55 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.d.mts +26 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.d.ts +26 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.js +536 -0
- package/Models/DatabaseModels/NetworkDeviceNamingRule.mjs +2 -0
- package/Models/DatabaseModels/NetworkSite.d.mts +1 -0
- package/Models/DatabaseModels/NetworkSite.d.ts +1 -0
- package/Models/DatabaseModels/NetworkSite.js +51 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.mts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.d.ts +2 -0
- package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +41 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.d.mts +2 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.d.ts +2 -0
- package/Models/DatabaseModels/ProjectCallSMSConfig.js +80 -1
- package/Models/DatabaseModels/RumApplication.d.mts +2 -0
- package/Models/DatabaseModels/RumApplication.d.ts +2 -0
- package/Models/DatabaseModels/RumApplication.js +108 -0
- package/Models/DatabaseModels/Team.js +10 -2
- package/Models/DatabaseModels/TeamComplianceSetting.js +8 -1
- package/Models/DatabaseModels/TeamCustomRole.js +9 -1
- package/Models/DatabaseModels/TeamMember.js +15 -1
- package/Models/DatabaseModels/TeamOwnerTeam.d.mts +17 -0
- package/Models/DatabaseModels/TeamOwnerTeam.d.ts +17 -0
- package/Models/DatabaseModels/TeamOwnerTeam.js +325 -0
- package/Models/DatabaseModels/TeamOwnerTeam.mjs +2 -0
- package/Models/DatabaseModels/TeamOwnerUser.d.mts +17 -0
- package/Models/DatabaseModels/TeamOwnerUser.d.ts +17 -0
- package/Models/DatabaseModels/TeamOwnerUser.js +331 -0
- package/Models/DatabaseModels/TeamOwnerUser.mjs +2 -0
- package/Models/DatabaseModels/TeamPermission.js +12 -1
- package/Models/DatabaseModels/TelemetryUsageBilling.d.mts +1 -0
- package/Models/DatabaseModels/TelemetryUsageBilling.d.ts +1 -0
- package/Models/DatabaseModels/TelemetryUsageBilling.js +34 -0
- package/Types/AI/AIActionWords.d.mts +1 -0
- package/Types/AI/AIActionWords.d.ts +1 -0
- package/Types/AI/AIActionWords.js +15 -4
- package/Types/AI/AIChatRecordSeen.d.mts +3 -0
- package/Types/AI/AIChatRecordSeen.d.ts +3 -0
- package/Types/AI/AIChatRecordSeen.js +28 -3
- package/Types/AI/AIChatRecordSeen.mjs +1 -0
- package/Types/AnalyticsDatabase/AnalyticsTableName.d.mts +2 -1
- package/Types/AnalyticsDatabase/AnalyticsTableName.d.ts +2 -1
- package/Types/AnalyticsDatabase/AnalyticsTableName.js +7 -0
- package/Types/AuditLog/AuditLogRetention.d.mts +10 -0
- package/Types/AuditLog/AuditLogRetention.d.ts +10 -0
- package/Types/AuditLog/AuditLogRetention.js +91 -0
- package/Types/AuditLog/AuditLogRetention.mjs +8 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.d.mts +37 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.d.ts +37 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.js +224 -0
- package/Types/CallAndSMS/TwilioConfigDefaults.mjs +3 -0
- package/Types/CodeRepository/CodeFileSeen.d.mts +3 -0
- package/Types/CodeRepository/CodeFileSeen.d.ts +3 -0
- package/Types/CodeRepository/CodeFileSeen.js +61 -3
- package/Types/DataObservability/DataDashboardActivity.d.mts +40 -0
- package/Types/DataObservability/DataDashboardActivity.d.ts +40 -0
- package/Types/DataObservability/DataDashboardActivity.js +119 -0
- package/Types/DataObservability/DataDashboardActivity.mjs +12 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.mts +7 -0
- package/Types/DataObservability/DataObservabilityApiTypes.d.ts +7 -0
- package/Types/DataObservability/DataObservabilityApiTypes.js +2 -0
- package/Types/DataObservability/DataTableLineage.d.mts +87 -0
- package/Types/DataObservability/DataTableLineage.d.ts +87 -0
- package/Types/DataObservability/DataTableLineage.js +111 -0
- package/Types/DataObservability/DataTableLineage.mjs +19 -0
- package/Types/DataSecurity/DataStoreKind.d.mts +1 -0
- package/Types/DataSecurity/DataStoreKind.d.ts +1 -0
- package/Types/DataSecurity/DataStoreKind.js +3 -0
- package/Types/Database/AccessControl/PermissionScopeNarrowing.js +6 -0
- package/Types/DatabaseServer/DatabaseServerMetricCatalog.js +71 -82
- package/Types/Date.d.mts +4 -0
- package/Types/Date.d.ts +4 -0
- package/Types/Date.js +47 -2
- package/Types/Date.mjs +2 -0
- package/Types/DateLanguage.d.mts +9 -0
- package/Types/DateLanguage.d.ts +9 -0
- package/Types/DateLanguage.js +79 -1
- package/Types/DateLanguage.mjs +4 -0
- package/Types/MessageQueue/MessageQueueMetricCatalog.js +61 -61
- package/Types/Monitor/CriteriaFilterTerms.d.mts +4 -0
- package/Types/Monitor/CriteriaFilterTerms.d.ts +4 -0
- package/Types/Monitor/CriteriaFilterTerms.js +166 -0
- package/Types/Monitor/CriteriaFilterTerms.mjs +4 -0
- package/Types/Monitor/EvaluationSentence.d.mts +37 -0
- package/Types/Monitor/EvaluationSentence.d.ts +37 -0
- package/Types/Monitor/EvaluationSentence.js +298 -0
- package/Types/Monitor/EvaluationSentence.mjs +12 -0
- package/Types/Monitor/MonitorCriteria.d.mts +2 -0
- package/Types/Monitor/MonitorCriteria.d.ts +2 -0
- package/Types/Monitor/MonitorCriteria.js +8 -0
- package/Types/Monitor/MonitorCriteriaInstance.d.mts +5 -0
- package/Types/Monitor/MonitorCriteriaInstance.d.ts +5 -0
- package/Types/Monitor/MonitorCriteriaInstance.js +243 -194
- package/Types/Monitor/MonitorEvaluationDetails.d.mts +2 -0
- package/Types/Monitor/MonitorEvaluationDetails.d.ts +2 -0
- package/Types/Monitor/MonitorEvaluationSummary.d.mts +4 -0
- package/Types/Monitor/MonitorEvaluationSummary.d.ts +4 -0
- package/Types/Monitor/MonitorStep.d.mts +2 -0
- package/Types/Monitor/MonitorStep.d.ts +2 -0
- package/Types/Monitor/MonitorSteps.d.mts +2 -0
- package/Types/Monitor/MonitorSteps.d.ts +2 -0
- package/Types/Monitor/MonitorType.d.mts +1 -0
- package/Types/Monitor/MonitorType.d.ts +1 -0
- package/Types/Monitor/MonitorType.js +12 -0
- package/Types/Monitor/TelemetryObservation.d.mts +15 -0
- package/Types/Monitor/TelemetryObservation.d.ts +15 -0
- package/Types/Monitor/TelemetryObservation.js +28 -0
- package/Types/Monitor/TelemetryObservation.mjs +2 -0
- package/Types/NetworkDevice/DeviceNaming.d.mts +87 -0
- package/Types/NetworkDevice/DeviceNaming.d.ts +87 -0
- package/Types/NetworkDevice/DeviceNaming.js +279 -0
- package/Types/NetworkDevice/DeviceNaming.mjs +24 -0
- package/Types/NetworkDevice/DiscoveredDevice.d.mts +1 -0
- package/Types/NetworkDevice/DiscoveredDevice.d.ts +1 -0
- package/Types/NetworkDevice/DiscoveredDevice.js +4 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.d.mts +68 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.d.ts +68 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.js +351 -0
- package/Types/OnCallDutyPolicy/OnCallPageChannel.mjs +15 -0
- package/Types/Permission.d.mts +5 -0
- package/Types/Permission.d.ts +5 -0
- package/Types/Permission.js +61 -5
- package/Types/Rules/RuleCriteriaFieldRegistry.js +12 -0
- package/Types/Rules/RuleCriteriaSubject.js +1 -0
- package/Types/Rum/ProductAnalyticsEventReads.d.mts +115 -0
- package/Types/Rum/ProductAnalyticsEventReads.d.ts +115 -0
- package/Types/Rum/ProductAnalyticsEventReads.js +166 -0
- package/Types/Rum/ProductAnalyticsEventReads.mjs +27 -0
- package/Types/Rum/ProductAnalyticsEvents.d.mts +121 -0
- package/Types/Rum/ProductAnalyticsEvents.d.ts +121 -0
- package/Types/Rum/ProductAnalyticsEvents.js +477 -0
- package/Types/Rum/ProductAnalyticsEvents.mjs +40 -0
- package/Types/Rum/SessionReplay.d.mts +4 -0
- package/Types/Rum/SessionReplay.d.ts +4 -0
- package/Types/Rum/SessionReplayHealth.js +1 -1
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.mts +10 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.d.ts +10 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.js +51 -0
- package/Types/ServiceLevelObjective/SloErrorBudgetPolicyChange.mjs +4 -0
- package/Types/Team/BuiltInTeam.d.mts +1 -0
- package/Types/Team/BuiltInTeam.d.ts +1 -0
- package/Types/Team/BuiltInTeam.js +14 -1
- package/Types/Team/BuiltInTeam.mjs +1 -0
- package/Types/Telemetry/TelemetryUsage.d.mts +7 -2
- package/Types/Telemetry/TelemetryUsage.d.ts +7 -2
- package/Types/Telemetry/TelemetryUsage.js +24 -5
- package/Types/Telemetry/TelemetryUsage.mjs +3 -0
- package/Types/UserNotification/UserNotificationStatus.d.mts +2 -1
- package/Types/UserNotification/UserNotificationStatus.d.ts +2 -1
- package/Types/UserNotification/UserNotificationStatus.js +8 -0
- package/Types/Workspace/NotificationRules/EventType.d.mts +2 -1
- package/Types/Workspace/NotificationRules/EventType.d.ts +2 -1
- package/Types/Workspace/NotificationRules/EventType.js +8 -0
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +7 -1
- package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +7 -1
- package/Types/Workspace/NotificationRules/NotificationRuleInvites.js +5 -1
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.mts +4 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.d.ts +4 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.js +2 -0
- package/Types/Workspace/NotificationRules/NotificationRuleTypes/ServiceLevelObjectiveNotificationRule.mjs +1 -0
- package/Utils/AI/InvestigationReport.js +93 -21
- package/Utils/AI/InvestigationReportLanguages.d.mts +25 -0
- package/Utils/AI/InvestigationReportLanguages.d.ts +25 -0
- package/Utils/AI/InvestigationReportLanguages.js +603 -0
- package/Utils/AI/InvestigationReportLanguages.mjs +11 -0
- package/Utils/Dashboard/TableThresholds.js +5 -2
- package/Utils/Monitor/MonitorLogSummaryUtil.d.mts +8 -0
- package/Utils/Monitor/MonitorLogSummaryUtil.d.ts +8 -0
- package/Utils/Monitor/MonitorLogSummaryUtil.js +170 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +17 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +17 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +242 -0
- package/Utils/Monitor/MonitorRootCauseWording.mjs +2 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.d.mts +3 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.d.ts +3 -0
- package/Utils/Monitor/MonitorSummarySnapshotUtil.js +5 -2
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.mts +75 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.d.ts +75 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.js +303 -0
- package/Utils/NetworkDevice/Naming/DeviceNamingPlanner.mjs +8 -0
- package/Utils/NetworkDevice/Naming/NamePattern.d.mts +122 -0
- package/Utils/NetworkDevice/Naming/NamePattern.d.ts +122 -0
- package/Utils/NetworkDevice/Naming/NamePattern.js +649 -0
- package/Utils/NetworkDevice/Naming/NamePattern.mjs +22 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.d.mts +77 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.d.ts +77 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.js +467 -0
- package/Utils/NetworkDevice/Naming/NamingLookup.mjs +14 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.mts +26 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.d.ts +26 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.js +327 -0
- package/Utils/NetworkDevice/Naming/NamingRuleMatcher.mjs +7 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.mts +1 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.d.ts +1 -0
- package/Utils/NetworkDiscovery/DiscoveredNameUpgrade.js +8 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.d.mts +2 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.d.ts +2 -0
- package/Utils/NetworkDiscovery/PingMonitorBuilder.js +1 -0
- package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.mts +7 -6
- package/Utils/{Rum → SessionReplay}/SessionReplayHealth.d.ts +7 -6
- package/Utils/SessionReplay/SessionReplayHealth.js +703 -0
- package/Utils/Slo/SloErrorBudgetPolicy.d.mts +7 -0
- package/Utils/Slo/SloErrorBudgetPolicy.d.ts +7 -0
- package/Utils/Slo/SloErrorBudgetPolicy.js +39 -0
- package/Utils/Slo/SloErrorBudgetPolicy.mjs +1 -0
- package/Utils/Slo/SloFeedMarkdown.d.mts +19 -4
- package/Utils/Slo/SloFeedMarkdown.d.ts +19 -4
- package/Utils/Slo/SloFeedMarkdown.js +64 -17
- package/Utils/Slo/SloFeedMarkdown.mjs +4 -0
- package/Utils/StatusPage/ResourceExplorer.js +9 -8
- package/Utils/TotpSetupKey.d.mts +3 -0
- package/Utils/TotpSetupKey.d.ts +3 -0
- package/Utils/TotpSetupKey.js +72 -0
- package/Utils/TotpSetupKey.mjs +4 -0
- package/Utils/Workspace/WorkspaceChannelName.js +5 -1
- package/package.json +1 -1
- package/Utils/Rum/SessionReplayHealth.js +0 -558
- /package/Utils/{Rum → SessionReplay}/SessionReplayHealth.mjs +0 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { DeviceNamingResult } from "../../../Types/NetworkDevice/DeviceNaming";
|
|
2
|
+
import { NamePatternValues, ParsedNamePattern } from "./NamePattern";
|
|
3
|
+
import { NamingLookupTable } from "./NamingLookup";
|
|
4
|
+
import { DeviceNamingFacts, NamingRuleConditionColumns } from "./NamingRuleMatcher";
|
|
5
|
+
export interface NamingRuleCandidate extends NamingRuleConditionColumns {
|
|
6
|
+
_id?: unknown;
|
|
7
|
+
id?: unknown;
|
|
8
|
+
name?: string | null | undefined;
|
|
9
|
+
priority?: number | null | undefined;
|
|
10
|
+
createdAt?: Date | string | null | undefined;
|
|
11
|
+
isEnabled?: boolean | null | undefined;
|
|
12
|
+
namePattern?: string | null | undefined;
|
|
13
|
+
lookupKey?: string | null | undefined;
|
|
14
|
+
lookupEntries?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface PreparedNamingRule {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
rule: NamingRuleCandidate;
|
|
20
|
+
pattern: ParsedNamePattern;
|
|
21
|
+
lookup: NamingLookupTable | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function compareNamingRules(left: NamingRuleCandidate, right: NamingRuleCandidate): number;
|
|
24
|
+
/**
|
|
25
|
+
* The rules a plan tries, in order: the enabled ones, each with a pattern
|
|
26
|
+
* that can be read. A rule whose stored pattern cannot be read names
|
|
27
|
+
* nothing - the service refuses such a pattern at save, so it is one
|
|
28
|
+
* written around it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function prepareNamingRules(rules: ReadonlyArray<NamingRuleCandidate>): Array<PreparedNamingRule>;
|
|
31
|
+
export declare class DeviceNameRegistry {
|
|
32
|
+
private readonly holders;
|
|
33
|
+
constructor(entries?: Iterable<{
|
|
34
|
+
name?: string | null | undefined;
|
|
35
|
+
deviceId?: string | null | undefined;
|
|
36
|
+
}>);
|
|
37
|
+
private static keyOf;
|
|
38
|
+
add(name: string, deviceId?: string | undefined): void;
|
|
39
|
+
isTaken(name: string, exceptDeviceId?: string | undefined): boolean;
|
|
40
|
+
getHeldName(name: string): string | undefined;
|
|
41
|
+
get size(): number;
|
|
42
|
+
}
|
|
43
|
+
export interface DeviceNamingSubject {
|
|
44
|
+
key: string;
|
|
45
|
+
facts: DeviceNamingFacts;
|
|
46
|
+
deviceId?: string | undefined;
|
|
47
|
+
currentName?: string | undefined;
|
|
48
|
+
}
|
|
49
|
+
export declare const MAX_NAME_COUNTER: number;
|
|
50
|
+
export declare function getNamePatternValues(facts: DeviceNamingFacts, lookup: NamingLookupTable | null): NamePatternValues;
|
|
51
|
+
/**
|
|
52
|
+
* What the rules call each device, by the subject's key. The registry holds
|
|
53
|
+
* the names the project's devices have, and is given every name the plan
|
|
54
|
+
* gives, so a caller that plans in several calls - an import's devices one
|
|
55
|
+
* at a time - hands the same registry to each.
|
|
56
|
+
*/
|
|
57
|
+
export declare function planDeviceNames(data: {
|
|
58
|
+
rules: ReadonlyArray<PreparedNamingRule>;
|
|
59
|
+
subjects: ReadonlyArray<DeviceNamingSubject>;
|
|
60
|
+
registry: DeviceNameRegistry;
|
|
61
|
+
nextCounters?: Map<string, number> | undefined;
|
|
62
|
+
}): Map<string, DeviceNamingResult>;
|
|
63
|
+
export declare class DeviceNamingSession {
|
|
64
|
+
private readonly rules;
|
|
65
|
+
private readonly registry;
|
|
66
|
+
private readonly nextCounters;
|
|
67
|
+
constructor(data: {
|
|
68
|
+
rules: ReadonlyArray<PreparedNamingRule>;
|
|
69
|
+
registry: DeviceNameRegistry;
|
|
70
|
+
});
|
|
71
|
+
get hasRules(): boolean;
|
|
72
|
+
name(subject: DeviceNamingSubject): DeviceNamingResult;
|
|
73
|
+
hold(name: string, deviceId?: string | undefined): void;
|
|
74
|
+
isTaken(name: string, exceptDeviceId?: string | undefined): boolean;
|
|
75
|
+
}
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DeviceNamingSession = exports.MAX_NAME_COUNTER = exports.DeviceNameRegistry = void 0;
|
|
7
|
+
exports.compareNamingRules = compareNamingRules;
|
|
8
|
+
exports.prepareNamingRules = prepareNamingRules;
|
|
9
|
+
exports.getNamePatternValues = getNamePatternValues;
|
|
10
|
+
exports.planDeviceNames = planDeviceNames;
|
|
11
|
+
const DeviceNaming_1 = require("../../../Types/NetworkDevice/DeviceNaming");
|
|
12
|
+
const DiscoveredDeviceBuilder_1 = require("../../NetworkDiscovery/DiscoveredDeviceBuilder");
|
|
13
|
+
const NamePattern_1 = require("./NamePattern");
|
|
14
|
+
const NamingLookup_1 = require("./NamingLookup");
|
|
15
|
+
const NamingRuleMatcher_1 = __importDefault(require("./NamingRuleMatcher"));
|
|
16
|
+
function readId(value) {
|
|
17
|
+
if (typeof value === "string") {
|
|
18
|
+
return value.trim();
|
|
19
|
+
}
|
|
20
|
+
if (value &&
|
|
21
|
+
typeof value.toString === "function") {
|
|
22
|
+
const text = String(value);
|
|
23
|
+
return text === "[object Object]" ? "" : text;
|
|
24
|
+
}
|
|
25
|
+
return "";
|
|
26
|
+
}
|
|
27
|
+
function toTime(value) {
|
|
28
|
+
if (value instanceof Date) {
|
|
29
|
+
const time = value.getTime();
|
|
30
|
+
return Number.isNaN(time) ? 0 : time;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value === "string" && value.trim()) {
|
|
33
|
+
const time = new Date(value).getTime();
|
|
34
|
+
return Number.isNaN(time) ? 0 : time;
|
|
35
|
+
}
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
/*
|
|
39
|
+
* The order rules are tried in, as the rules page lists them: the highest
|
|
40
|
+
* priority first, then the oldest, then by id - so two rules with the same
|
|
41
|
+
* place never swap between runs.
|
|
42
|
+
*/
|
|
43
|
+
function compareNamingRules(left, right) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
const leftPriority = typeof left.priority === "number" ? left.priority : 0;
|
|
46
|
+
const rightPriority = typeof right.priority === "number" ? right.priority : 0;
|
|
47
|
+
if (leftPriority !== rightPriority) {
|
|
48
|
+
return rightPriority - leftPriority;
|
|
49
|
+
}
|
|
50
|
+
const leftTime = toTime(left.createdAt);
|
|
51
|
+
const rightTime = toTime(right.createdAt);
|
|
52
|
+
if (leftTime !== rightTime) {
|
|
53
|
+
return leftTime - rightTime;
|
|
54
|
+
}
|
|
55
|
+
const leftId = readId((_a = left._id) !== null && _a !== void 0 ? _a : left.id);
|
|
56
|
+
const rightId = readId((_b = right._id) !== null && _b !== void 0 ? _b : right.id);
|
|
57
|
+
return leftId < rightId ? -1 : leftId > rightId ? 1 : 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The rules a plan tries, in order: the enabled ones, each with a pattern
|
|
61
|
+
* that can be read. A rule whose stored pattern cannot be read names
|
|
62
|
+
* nothing - the service refuses such a pattern at save, so it is one
|
|
63
|
+
* written around it.
|
|
64
|
+
*/
|
|
65
|
+
function prepareNamingRules(rules) {
|
|
66
|
+
var _a;
|
|
67
|
+
const prepared = [];
|
|
68
|
+
for (const rule of [...rules].sort(compareNamingRules)) {
|
|
69
|
+
if (!rule || rule.isEnabled === false) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
const read = (0, NamePattern_1.parseNamePattern)(rule.namePattern);
|
|
73
|
+
if ("problem" in read) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
prepared.push({
|
|
77
|
+
id: readId((_a = rule._id) !== null && _a !== void 0 ? _a : rule.id),
|
|
78
|
+
name: typeof rule.name === "string" ? rule.name : "",
|
|
79
|
+
rule: rule,
|
|
80
|
+
pattern: read.pattern,
|
|
81
|
+
lookup: read.pattern.placeholders.includes(NamePattern_1.NamePlaceholder.Lookup)
|
|
82
|
+
? (0, NamingLookup_1.readNamingLookupTable)({
|
|
83
|
+
kind: rule.lookupKey,
|
|
84
|
+
entries: rule.lookupEntries,
|
|
85
|
+
})
|
|
86
|
+
: null,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return prepared;
|
|
90
|
+
}
|
|
91
|
+
/*
|
|
92
|
+
* THE NAMES THE PROJECT'S DEVICES HAVE, compared without case, and the
|
|
93
|
+
* device holding each. Names given during a plan are added as it goes.
|
|
94
|
+
*/
|
|
95
|
+
class DeviceNameRegistry {
|
|
96
|
+
constructor(entries = []) {
|
|
97
|
+
this.holders = new Map();
|
|
98
|
+
for (const entry of entries) {
|
|
99
|
+
if (entry && typeof entry.name === "string") {
|
|
100
|
+
this.add(entry.name, entry.deviceId || undefined);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
static keyOf(name) {
|
|
105
|
+
return name.trim().toLowerCase();
|
|
106
|
+
}
|
|
107
|
+
add(name, deviceId) {
|
|
108
|
+
const key = DeviceNameRegistry.keyOf(name);
|
|
109
|
+
if (!key) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const holder = this.holders.get(key) || { name: name.trim(), deviceIds: new Set() };
|
|
113
|
+
// A name held without a device (one an import is about to create) holds it too.
|
|
114
|
+
holder.deviceIds.add(deviceId || "");
|
|
115
|
+
this.holders.set(key, holder);
|
|
116
|
+
}
|
|
117
|
+
/*
|
|
118
|
+
* True when a device other than `exceptDeviceId` has the name. A device's
|
|
119
|
+
* own name is never taken for itself.
|
|
120
|
+
*/
|
|
121
|
+
isTaken(name, exceptDeviceId) {
|
|
122
|
+
const holder = this.holders.get(DeviceNameRegistry.keyOf(name));
|
|
123
|
+
if (!holder) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
for (const deviceId of holder.deviceIds) {
|
|
127
|
+
if (!exceptDeviceId || deviceId !== exceptDeviceId) {
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
// The name as the device holding it spells it.
|
|
134
|
+
getHeldName(name) {
|
|
135
|
+
var _a;
|
|
136
|
+
return (_a = this.holders.get(DeviceNameRegistry.keyOf(name))) === null || _a === void 0 ? void 0 : _a.name;
|
|
137
|
+
}
|
|
138
|
+
get size() {
|
|
139
|
+
return this.holders.size;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.DeviceNameRegistry = DeviceNameRegistry;
|
|
143
|
+
/*
|
|
144
|
+
* The highest number a counter tries. A pattern with this many devices
|
|
145
|
+
* taking numbers already is not a pattern a person meant.
|
|
146
|
+
*/
|
|
147
|
+
exports.MAX_NAME_COUNTER = 99999;
|
|
148
|
+
function getNamePatternValues(facts, lookup) {
|
|
149
|
+
return {
|
|
150
|
+
discoveredName: facts.discoveredName,
|
|
151
|
+
ipAddress: facts.ipAddress,
|
|
152
|
+
macAddress: facts.macAddress,
|
|
153
|
+
vendor: facts.vendor,
|
|
154
|
+
siteName: facts.siteName,
|
|
155
|
+
siteCode: facts.siteCode,
|
|
156
|
+
lookupValue: lookup ? (0, NamingLookup_1.lookUpNamingValue)(lookup, facts) : undefined,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function counterKeyOf(rendering) {
|
|
160
|
+
return `${rendering.prefix.toLowerCase()}\u0000${rendering.counterWidth}\u0000${rendering.suffix.toLowerCase()}`;
|
|
161
|
+
}
|
|
162
|
+
function resolveName(data) {
|
|
163
|
+
const ruleFields = {
|
|
164
|
+
ruleId: data.rule.id,
|
|
165
|
+
ruleName: data.rule.name,
|
|
166
|
+
};
|
|
167
|
+
const currentName = (data.subject.currentName || "").trim();
|
|
168
|
+
const deviceId = data.subject.deviceId;
|
|
169
|
+
const registry = data.state.registry;
|
|
170
|
+
const give = (name) => {
|
|
171
|
+
registry.add(name, deviceId);
|
|
172
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.Named, name: name }, ruleFields);
|
|
173
|
+
};
|
|
174
|
+
if (data.rendering.counterWidth === null) {
|
|
175
|
+
const name = data.rendering.prefix;
|
|
176
|
+
if (name.length > DiscoveredDeviceBuilder_1.MAX_DEVICE_NAME_LENGTH) {
|
|
177
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.NameTooLong, name: name }, ruleFields);
|
|
178
|
+
}
|
|
179
|
+
if (currentName && currentName === name) {
|
|
180
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.FollowsRules, name: name }, ruleFields);
|
|
181
|
+
}
|
|
182
|
+
if (registry.isTaken(name, deviceId)) {
|
|
183
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.NameTaken, name: name, takenName: registry.getHeldName(name) || name }, ruleFields);
|
|
184
|
+
}
|
|
185
|
+
return give(name);
|
|
186
|
+
}
|
|
187
|
+
// A device that already carries a number of this pattern keeps it.
|
|
188
|
+
if (currentName) {
|
|
189
|
+
const carried = (0, NamePattern_1.readNameCounter)(currentName, data.rendering);
|
|
190
|
+
if (carried !== null) {
|
|
191
|
+
const name = (0, NamePattern_1.composeName)(data.rendering, carried);
|
|
192
|
+
if (name === currentName) {
|
|
193
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.FollowsRules, name: name }, ruleFields);
|
|
194
|
+
}
|
|
195
|
+
// The same number, in the pattern's own case.
|
|
196
|
+
if (name.length <= DiscoveredDeviceBuilder_1.MAX_DEVICE_NAME_LENGTH &&
|
|
197
|
+
!registry.isTaken(name, deviceId)) {
|
|
198
|
+
return give(name);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const counterKey = counterKeyOf(data.rendering);
|
|
203
|
+
let value = data.state.nextCounters.get(counterKey) || 1;
|
|
204
|
+
for (; value <= exports.MAX_NAME_COUNTER; value++) {
|
|
205
|
+
const name = (0, NamePattern_1.composeName)(data.rendering, value);
|
|
206
|
+
if (name.length > DiscoveredDeviceBuilder_1.MAX_DEVICE_NAME_LENGTH) {
|
|
207
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.NameTooLong, name: name }, ruleFields);
|
|
208
|
+
}
|
|
209
|
+
if (!registry.isTaken(name, deviceId)) {
|
|
210
|
+
/*
|
|
211
|
+
* The search for the next device starts here, not one past it: the
|
|
212
|
+
* number is free of every other device, but a device's own current
|
|
213
|
+
* name is free only to itself.
|
|
214
|
+
*/
|
|
215
|
+
data.state.nextCounters.set(counterKey, value);
|
|
216
|
+
return give(name);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
data.state.nextCounters.set(counterKey, value);
|
|
220
|
+
return Object.assign({ outcome: DeviceNaming_1.DeviceNamingOutcome.NameTaken, name: (0, NamePattern_1.composeName)(data.rendering, exports.MAX_NAME_COUNTER), takenName: (0, NamePattern_1.composeName)(data.rendering, exports.MAX_NAME_COUNTER) }, ruleFields);
|
|
221
|
+
}
|
|
222
|
+
function planOne(subject, rules, state) {
|
|
223
|
+
let firstMissing = null;
|
|
224
|
+
for (const rule of rules) {
|
|
225
|
+
if (!NamingRuleMatcher_1.default.ruleMatches(rule.rule, subject.facts)) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
const rendering = (0, NamePattern_1.renderNamePattern)(rule.pattern, getNamePatternValues(subject.facts, rule.lookup));
|
|
229
|
+
if (!rendering.isComplete) {
|
|
230
|
+
if (!firstMissing) {
|
|
231
|
+
firstMissing = {
|
|
232
|
+
outcome: DeviceNaming_1.DeviceNamingOutcome.MissingValue,
|
|
233
|
+
ruleId: rule.id,
|
|
234
|
+
ruleName: rule.name,
|
|
235
|
+
missing: rendering.missing,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
return resolveName({
|
|
241
|
+
rendering: rendering,
|
|
242
|
+
subject: subject,
|
|
243
|
+
rule: rule,
|
|
244
|
+
state: state,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return firstMissing || { outcome: DeviceNaming_1.DeviceNamingOutcome.NoMatchingRule };
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* What the rules call each device, by the subject's key. The registry holds
|
|
251
|
+
* the names the project's devices have, and is given every name the plan
|
|
252
|
+
* gives, so a caller that plans in several calls - an import's devices one
|
|
253
|
+
* at a time - hands the same registry to each.
|
|
254
|
+
*/
|
|
255
|
+
function planDeviceNames(data) {
|
|
256
|
+
const results = new Map();
|
|
257
|
+
const state = {
|
|
258
|
+
registry: data.registry,
|
|
259
|
+
nextCounters: data.nextCounters || new Map(),
|
|
260
|
+
};
|
|
261
|
+
for (const subject of data.subjects) {
|
|
262
|
+
if (!subject || results.has(subject.key)) {
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (data.rules.length === 0) {
|
|
266
|
+
results.set(subject.key, { outcome: DeviceNaming_1.DeviceNamingOutcome.NoMatchingRule });
|
|
267
|
+
continue;
|
|
268
|
+
}
|
|
269
|
+
results.set(subject.key, planOne(subject, data.rules, state));
|
|
270
|
+
}
|
|
271
|
+
return results;
|
|
272
|
+
}
|
|
273
|
+
/*
|
|
274
|
+
* A planner for one device at a time, holding its state between calls: the
|
|
275
|
+
* import names each host as it creates it, after reading what the earlier
|
|
276
|
+
* ones were created under.
|
|
277
|
+
*/
|
|
278
|
+
class DeviceNamingSession {
|
|
279
|
+
constructor(data) {
|
|
280
|
+
this.nextCounters = new Map();
|
|
281
|
+
this.rules = data.rules;
|
|
282
|
+
this.registry = data.registry;
|
|
283
|
+
}
|
|
284
|
+
get hasRules() {
|
|
285
|
+
return this.rules.length > 0;
|
|
286
|
+
}
|
|
287
|
+
name(subject) {
|
|
288
|
+
return (planDeviceNames({
|
|
289
|
+
rules: this.rules,
|
|
290
|
+
subjects: [subject],
|
|
291
|
+
registry: this.registry,
|
|
292
|
+
nextCounters: this.nextCounters,
|
|
293
|
+
}).get(subject.key) || { outcome: DeviceNaming_1.DeviceNamingOutcome.NoMatchingRule });
|
|
294
|
+
}
|
|
295
|
+
// A name a device was created or renamed under, outside the rules.
|
|
296
|
+
hold(name, deviceId) {
|
|
297
|
+
this.registry.add(name, deviceId);
|
|
298
|
+
}
|
|
299
|
+
isTaken(name, exceptDeviceId) {
|
|
300
|
+
return this.registry.isTaken(name, exceptDeviceId);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
exports.DeviceNamingSession = DeviceNamingSession;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import commonJsModule from "./DeviceNamingPlanner.js";
|
|
2
|
+
export const DeviceNameRegistry = commonJsModule.DeviceNameRegistry;
|
|
3
|
+
export const DeviceNamingSession = commonJsModule.DeviceNamingSession;
|
|
4
|
+
export const MAX_NAME_COUNTER = commonJsModule.MAX_NAME_COUNTER;
|
|
5
|
+
export const compareNamingRules = commonJsModule.compareNamingRules;
|
|
6
|
+
export const getNamePatternValues = commonJsModule.getNamePatternValues;
|
|
7
|
+
export const planDeviceNames = commonJsModule.planDeviceNames;
|
|
8
|
+
export const prepareNamingRules = commonJsModule.prepareNamingRules;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export declare enum NamePlaceholder {
|
|
2
|
+
DiscoveredName = "discoveredName",
|
|
3
|
+
IpAddress = "ip",
|
|
4
|
+
IpOctet1 = "ip.1",
|
|
5
|
+
IpOctet2 = "ip.2",
|
|
6
|
+
IpOctet3 = "ip.3",
|
|
7
|
+
IpOctet4 = "ip.4",
|
|
8
|
+
MacAddress = "mac",
|
|
9
|
+
Vendor = "vendor",
|
|
10
|
+
Site = "site",
|
|
11
|
+
SiteCode = "site.code",
|
|
12
|
+
Lookup = "lookup"
|
|
13
|
+
}
|
|
14
|
+
export declare enum NameFilter {
|
|
15
|
+
Upper = "upper",
|
|
16
|
+
Lower = "lower",
|
|
17
|
+
First = "first",
|
|
18
|
+
Last = "last",
|
|
19
|
+
Digits = "digits",
|
|
20
|
+
NoSpaces = "nospaces"
|
|
21
|
+
}
|
|
22
|
+
export interface NamePlaceholderInfo {
|
|
23
|
+
placeholder: NamePlaceholder;
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
example: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const NAME_PLACEHOLDERS: ReadonlyArray<NamePlaceholderInfo>;
|
|
29
|
+
export declare const NAME_COUNTERS: ReadonlyArray<{
|
|
30
|
+
token: string;
|
|
31
|
+
width: number;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const NAME_COUNTER_TITLE: string;
|
|
34
|
+
export declare const NAME_COUNTER_DESCRIPTION: string;
|
|
35
|
+
export declare const MAX_NAME_FILTER_COUNT: number;
|
|
36
|
+
export interface NamePatternFilterStep {
|
|
37
|
+
filter: NameFilter;
|
|
38
|
+
count?: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
export type NamePatternSegment = {
|
|
41
|
+
kind: "text";
|
|
42
|
+
text: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "value";
|
|
45
|
+
placeholder: NamePlaceholder;
|
|
46
|
+
filters: Array<NamePatternFilterStep>;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "counter";
|
|
49
|
+
width: number;
|
|
50
|
+
};
|
|
51
|
+
export interface ParsedNamePattern {
|
|
52
|
+
segments: Array<NamePatternSegment>;
|
|
53
|
+
placeholders: Array<NamePlaceholder>;
|
|
54
|
+
counterWidth: number | null;
|
|
55
|
+
}
|
|
56
|
+
export interface NamePatternProblem {
|
|
57
|
+
template: string;
|
|
58
|
+
values: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
export declare const NAME_PATTERN_PROBLEMS: {
|
|
61
|
+
readonly empty: string;
|
|
62
|
+
readonly tooLong: string;
|
|
63
|
+
readonly controlCharacter: string;
|
|
64
|
+
readonly unclosedBrace: string;
|
|
65
|
+
readonly strayClosingBrace: string;
|
|
66
|
+
readonly emptyPlaceholder: string;
|
|
67
|
+
readonly unknownPlaceholder: string;
|
|
68
|
+
readonly unknownFilter: string;
|
|
69
|
+
readonly filterNeedsCount: string;
|
|
70
|
+
readonly filterTakesNoCount: string;
|
|
71
|
+
readonly filterCountOutOfRange: string;
|
|
72
|
+
readonly twoCounters: string;
|
|
73
|
+
readonly counterTakesNoFilters: string;
|
|
74
|
+
};
|
|
75
|
+
export declare function formatNamePatternProblem(problem: NamePatternProblem): string;
|
|
76
|
+
/**
|
|
77
|
+
* The pattern read into its pieces, or what is wrong with it. Accepts
|
|
78
|
+
* `unknown`: the value comes out of a request body or a database row.
|
|
79
|
+
*/
|
|
80
|
+
export declare function parseNamePattern(pattern: unknown): {
|
|
81
|
+
pattern: ParsedNamePattern;
|
|
82
|
+
} | {
|
|
83
|
+
problem: NamePatternProblem;
|
|
84
|
+
};
|
|
85
|
+
export declare function getNamePatternProblem(pattern: unknown): NamePatternProblem | null;
|
|
86
|
+
export declare function getNamePatternError(pattern: unknown): string | null;
|
|
87
|
+
export interface NamePatternValues {
|
|
88
|
+
discoveredName?: string | undefined;
|
|
89
|
+
ipAddress?: string | undefined;
|
|
90
|
+
macAddress?: string | undefined;
|
|
91
|
+
vendor?: string | undefined;
|
|
92
|
+
siteName?: string | undefined;
|
|
93
|
+
siteCode?: string | undefined;
|
|
94
|
+
lookupValue?: string | undefined;
|
|
95
|
+
}
|
|
96
|
+
export type NamePatternRendering = {
|
|
97
|
+
isComplete: true;
|
|
98
|
+
prefix: string;
|
|
99
|
+
suffix: string;
|
|
100
|
+
counterWidth: number | null;
|
|
101
|
+
} | {
|
|
102
|
+
isComplete: false;
|
|
103
|
+
missing: NamePlaceholder;
|
|
104
|
+
};
|
|
105
|
+
export declare function readIpv4Octets(value: unknown): Array<string> | null;
|
|
106
|
+
export declare function readMacAddressDigits(value: unknown): string | null;
|
|
107
|
+
export declare function applyNameFilter(value: string, step: NamePatternFilterStep): string;
|
|
108
|
+
/**
|
|
109
|
+
* The name the pattern makes for a device with these values, or the first
|
|
110
|
+
* placeholder it has no value for. A placeholder whose value is empty -
|
|
111
|
+
* missing, or emptied by its filters - is a missing value.
|
|
112
|
+
*/
|
|
113
|
+
export declare function renderNamePattern(pattern: ParsedNamePattern, values: NamePatternValues): NamePatternRendering;
|
|
114
|
+
export declare function formatNameCounter(value: number, width: number): string;
|
|
115
|
+
export declare function composeName(rendering: Extract<NamePatternRendering, {
|
|
116
|
+
isComplete: true;
|
|
117
|
+
}>, value?: number): string;
|
|
118
|
+
export declare function readNameCounter(name: string, rendering: Extract<NamePatternRendering, {
|
|
119
|
+
isComplete: true;
|
|
120
|
+
}>): number | null;
|
|
121
|
+
export declare function getExampleNamePatternValues(lookupValue?: string | undefined): NamePatternValues;
|
|
122
|
+
export declare function getExampleName(pattern: unknown, lookupValue?: string | undefined): string | null;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export declare enum NamePlaceholder {
|
|
2
|
+
DiscoveredName = "discoveredName",
|
|
3
|
+
IpAddress = "ip",
|
|
4
|
+
IpOctet1 = "ip.1",
|
|
5
|
+
IpOctet2 = "ip.2",
|
|
6
|
+
IpOctet3 = "ip.3",
|
|
7
|
+
IpOctet4 = "ip.4",
|
|
8
|
+
MacAddress = "mac",
|
|
9
|
+
Vendor = "vendor",
|
|
10
|
+
Site = "site",
|
|
11
|
+
SiteCode = "site.code",
|
|
12
|
+
Lookup = "lookup"
|
|
13
|
+
}
|
|
14
|
+
export declare enum NameFilter {
|
|
15
|
+
Upper = "upper",
|
|
16
|
+
Lower = "lower",
|
|
17
|
+
First = "first",
|
|
18
|
+
Last = "last",
|
|
19
|
+
Digits = "digits",
|
|
20
|
+
NoSpaces = "nospaces"
|
|
21
|
+
}
|
|
22
|
+
export interface NamePlaceholderInfo {
|
|
23
|
+
placeholder: NamePlaceholder;
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
example: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const NAME_PLACEHOLDERS: ReadonlyArray<NamePlaceholderInfo>;
|
|
29
|
+
export declare const NAME_COUNTERS: ReadonlyArray<{
|
|
30
|
+
token: string;
|
|
31
|
+
width: number;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const NAME_COUNTER_TITLE: string;
|
|
34
|
+
export declare const NAME_COUNTER_DESCRIPTION: string;
|
|
35
|
+
export declare const MAX_NAME_FILTER_COUNT: number;
|
|
36
|
+
export interface NamePatternFilterStep {
|
|
37
|
+
filter: NameFilter;
|
|
38
|
+
count?: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
export type NamePatternSegment = {
|
|
41
|
+
kind: "text";
|
|
42
|
+
text: string;
|
|
43
|
+
} | {
|
|
44
|
+
kind: "value";
|
|
45
|
+
placeholder: NamePlaceholder;
|
|
46
|
+
filters: Array<NamePatternFilterStep>;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "counter";
|
|
49
|
+
width: number;
|
|
50
|
+
};
|
|
51
|
+
export interface ParsedNamePattern {
|
|
52
|
+
segments: Array<NamePatternSegment>;
|
|
53
|
+
placeholders: Array<NamePlaceholder>;
|
|
54
|
+
counterWidth: number | null;
|
|
55
|
+
}
|
|
56
|
+
export interface NamePatternProblem {
|
|
57
|
+
template: string;
|
|
58
|
+
values: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
export declare const NAME_PATTERN_PROBLEMS: {
|
|
61
|
+
readonly empty: string;
|
|
62
|
+
readonly tooLong: string;
|
|
63
|
+
readonly controlCharacter: string;
|
|
64
|
+
readonly unclosedBrace: string;
|
|
65
|
+
readonly strayClosingBrace: string;
|
|
66
|
+
readonly emptyPlaceholder: string;
|
|
67
|
+
readonly unknownPlaceholder: string;
|
|
68
|
+
readonly unknownFilter: string;
|
|
69
|
+
readonly filterNeedsCount: string;
|
|
70
|
+
readonly filterTakesNoCount: string;
|
|
71
|
+
readonly filterCountOutOfRange: string;
|
|
72
|
+
readonly twoCounters: string;
|
|
73
|
+
readonly counterTakesNoFilters: string;
|
|
74
|
+
};
|
|
75
|
+
export declare function formatNamePatternProblem(problem: NamePatternProblem): string;
|
|
76
|
+
/**
|
|
77
|
+
* The pattern read into its pieces, or what is wrong with it. Accepts
|
|
78
|
+
* `unknown`: the value comes out of a request body or a database row.
|
|
79
|
+
*/
|
|
80
|
+
export declare function parseNamePattern(pattern: unknown): {
|
|
81
|
+
pattern: ParsedNamePattern;
|
|
82
|
+
} | {
|
|
83
|
+
problem: NamePatternProblem;
|
|
84
|
+
};
|
|
85
|
+
export declare function getNamePatternProblem(pattern: unknown): NamePatternProblem | null;
|
|
86
|
+
export declare function getNamePatternError(pattern: unknown): string | null;
|
|
87
|
+
export interface NamePatternValues {
|
|
88
|
+
discoveredName?: string | undefined;
|
|
89
|
+
ipAddress?: string | undefined;
|
|
90
|
+
macAddress?: string | undefined;
|
|
91
|
+
vendor?: string | undefined;
|
|
92
|
+
siteName?: string | undefined;
|
|
93
|
+
siteCode?: string | undefined;
|
|
94
|
+
lookupValue?: string | undefined;
|
|
95
|
+
}
|
|
96
|
+
export type NamePatternRendering = {
|
|
97
|
+
isComplete: true;
|
|
98
|
+
prefix: string;
|
|
99
|
+
suffix: string;
|
|
100
|
+
counterWidth: number | null;
|
|
101
|
+
} | {
|
|
102
|
+
isComplete: false;
|
|
103
|
+
missing: NamePlaceholder;
|
|
104
|
+
};
|
|
105
|
+
export declare function readIpv4Octets(value: unknown): Array<string> | null;
|
|
106
|
+
export declare function readMacAddressDigits(value: unknown): string | null;
|
|
107
|
+
export declare function applyNameFilter(value: string, step: NamePatternFilterStep): string;
|
|
108
|
+
/**
|
|
109
|
+
* The name the pattern makes for a device with these values, or the first
|
|
110
|
+
* placeholder it has no value for. A placeholder whose value is empty -
|
|
111
|
+
* missing, or emptied by its filters - is a missing value.
|
|
112
|
+
*/
|
|
113
|
+
export declare function renderNamePattern(pattern: ParsedNamePattern, values: NamePatternValues): NamePatternRendering;
|
|
114
|
+
export declare function formatNameCounter(value: number, width: number): string;
|
|
115
|
+
export declare function composeName(rendering: Extract<NamePatternRendering, {
|
|
116
|
+
isComplete: true;
|
|
117
|
+
}>, value?: number): string;
|
|
118
|
+
export declare function readNameCounter(name: string, rendering: Extract<NamePatternRendering, {
|
|
119
|
+
isComplete: true;
|
|
120
|
+
}>): number | null;
|
|
121
|
+
export declare function getExampleNamePatternValues(lookupValue?: string | undefined): NamePatternValues;
|
|
122
|
+
export declare function getExampleName(pattern: unknown, lookupValue?: string | undefined): string | null;
|