@oneuptime/common 14.1.0 → 14.2.0
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/Alert.d.mts +1 -0
- package/Models/DatabaseModels/Alert.d.ts +1 -0
- package/Models/DatabaseModels/Alert.js +34 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.mts +2 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.d.ts +2 -0
- package/Models/DatabaseModels/AutoRemediationSuggestion.js +62 -0
- package/Models/DatabaseModels/Incident.d.mts +1 -0
- package/Models/DatabaseModels/Incident.d.ts +1 -0
- package/Models/DatabaseModels/Incident.js +35 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.d.mts +31 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.d.ts +31 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.js +591 -0
- package/Models/DatabaseModels/IncidentPostmortemActionItem.mjs +3 -0
- package/Models/DatabaseModels/Index.js +2 -0
- package/Models/DatabaseModels/TelemetryIngestionKey.js +1 -1
- package/Types/AI/AIActionWords.d.mts +3 -1
- package/Types/AI/AIActionWords.d.ts +3 -1
- package/Types/AI/AIActionWords.js +70 -1
- package/Types/AI/AIActionWords.mjs +2 -0
- package/Types/AI/AIChatTypes.d.mts +2 -1
- package/Types/AI/AIChatTypes.d.ts +2 -1
- package/Types/AI/AIReadTableWords.d.mts +192 -0
- package/Types/AI/AIReadTableWords.d.ts +192 -0
- package/Types/AI/AIReadTableWords.js +368 -0
- package/Types/AI/AIReadTableWords.mjs +18 -0
- package/Types/AI/AiRunRefusal.d.mts +3 -0
- package/Types/AI/AiRunRefusal.d.ts +3 -0
- package/Types/AI/AiRunRefusal.js +22 -1
- package/Types/AI/ResourceAiAccessPermissions.js +7 -18
- package/Types/AuditLog/AuditLogActionLabel.js +19 -9
- package/Types/BaseDatabase/AggregationIntervalUtil.d.mts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.d.ts +16 -0
- package/Types/BaseDatabase/AggregationIntervalUtil.js +123 -16
- package/Types/Cloud/CloudResourceHealth.d.mts +30 -1
- package/Types/Cloud/CloudResourceHealth.d.ts +30 -1
- package/Types/Cloud/CloudResourceHealth.js +405 -13
- package/Types/Cloud/CloudResourceHealth.mjs +28 -0
- package/Types/DataObservability/DataCheckRefusals.d.mts +32 -0
- package/Types/DataObservability/DataCheckRefusals.d.ts +32 -0
- package/Types/DataObservability/DataCheckRefusals.js +77 -0
- package/Types/DataObservability/DataCheckRefusals.mjs +8 -0
- package/Types/Database/AccessControl/PermissionScopeNarrowing.js +4 -0
- package/Types/Date.d.mts +2 -0
- package/Types/Date.d.ts +2 -0
- package/Types/Date.js +22 -0
- package/Types/DateLanguage.d.mts +2 -0
- package/Types/DateLanguage.d.ts +2 -0
- package/Types/DateLanguage.js +8 -5
- package/Types/Email/EmailTemplateType.d.mts +1 -0
- package/Types/Email/EmailTemplateType.d.ts +1 -0
- package/Types/Email/EmailTemplateType.js +2 -0
- package/Types/Exception/EgressGuardException.js +1 -1
- package/Types/Exception/ErrorMessageRule.d.mts +1 -0
- package/Types/Exception/ErrorMessageRule.d.ts +1 -0
- package/Types/Exception/ErrorMessageRule.js +67 -13
- package/Types/Exception/ErrorMessageRule.mjs +1 -0
- package/Types/Exception/ExceptionMessages.d.mts +2 -0
- package/Types/Exception/ExceptionMessages.d.ts +2 -0
- package/Types/Exception/ExceptionMessages.js +2 -0
- package/Types/Incident/PostmortemActionItemStatus.d.mts +17 -0
- package/Types/Incident/PostmortemActionItemStatus.d.ts +17 -0
- package/Types/Incident/PostmortemActionItemStatus.js +74 -0
- package/Types/Incident/PostmortemActionItemStatus.mjs +5 -0
- package/Types/JSONFunctions.js +10 -3
- package/Types/Link.d.mts +1 -0
- package/Types/Link.d.ts +1 -0
- package/Types/MeaningKeys.d.mts +4 -0
- package/Types/MeaningKeys.d.ts +4 -0
- package/Types/MeaningKeys.js +74 -0
- package/Types/MeaningKeys.mjs +5 -0
- package/Types/Monitor/WhoIsTold.d.mts +3 -0
- package/Types/Monitor/WhoIsTold.d.ts +3 -0
- package/Types/Monitor/WhoIsTold.js +63 -13
- package/Types/NoBreakSpaces.d.mts +16 -0
- package/Types/NoBreakSpaces.d.ts +16 -0
- package/Types/NoBreakSpaces.js +419 -0
- package/Types/NoBreakSpaces.mjs +9 -0
- package/Types/NotificationRule/PagingLadder.d.mts +12 -0
- package/Types/NotificationRule/PagingLadder.d.ts +12 -0
- package/Types/NotificationRule/PagingLadder.js +159 -11
- package/Types/NotificationRule/PagingLadder.mjs +3 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.mts +3 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.d.ts +3 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.js +42 -0
- package/Types/OnCallDutyPolicy/OnCallPageRecordGone.mjs +4 -0
- package/Types/OnCallDutyPolicy/OnCallPageWords.d.mts +6 -2
- package/Types/OnCallDutyPolicy/OnCallPageWords.d.ts +6 -2
- package/Types/OnCallDutyPolicy/OnCallPageWords.js +21 -20
- package/Types/OnCallDutyPolicy/OnCallPersonPage.d.mts +4 -0
- package/Types/OnCallDutyPolicy/OnCallPersonPage.d.ts +4 -0
- package/Types/OnCallDutyPolicy/OnCallPersonPage.js +125 -1
- package/Types/OnCallDutyPolicy/OnCallPersonPage.mjs +1 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +2 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +2 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.js +12 -0
- package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
- package/Types/OpenStack/OpenStackCapacity.js +12 -5
- package/Types/Permission.d.mts +4 -0
- package/Types/Permission.d.ts +4 -0
- package/Types/Permission.js +64 -8
- package/Types/Product/ProductUsage.js +2 -1
- package/Types/Product/ProjectProductsAnswer.js +2 -1
- package/Types/ResourceAiAgent/AiResourceType.d.mts +1 -0
- package/Types/ResourceAiAgent/AiResourceType.d.ts +1 -0
- package/Types/ResourceAiAgent/AiResourceType.js +12 -0
- package/Types/Rum/ProductAnalyticsEventReads.js +10 -1
- package/Types/Rum/ProductAnalyticsEvents.js +13 -1
- package/Types/Rum/SessionReplayCustomEvents.d.mts +4 -1
- package/Types/Rum/SessionReplayCustomEvents.d.ts +4 -1
- package/Types/Rum/SessionReplayCustomEvents.js +12 -0
- package/Types/Rum/SessionReplayCustomEvents.mjs +1 -0
- package/Types/SetupHealth/SetupHealth.d.mts +1 -0
- package/Types/SetupHealth/SetupHealth.d.ts +1 -0
- package/Types/SetupHealth/SetupHealth.js +13 -5
- package/Types/StatusPage/DefaultStatusNames.d.mts +11 -3
- package/Types/StatusPage/DefaultStatusNames.d.ts +11 -3
- package/Types/StatusPage/DefaultStatusNames.js +74 -28
- package/Types/StatusPage/DefaultStatusNames.mjs +9 -2
- package/Types/StatusPage/StateChangeNoteMessage.d.mts +3 -2
- package/Types/StatusPage/StateChangeNoteMessage.d.ts +3 -2
- package/Types/StatusPage/StateChangeNoteMessage.js +16 -13
- package/Types/Telemetry/TelemetryIngestionKeyType.js +7 -6
- package/Types/Translator.d.mts +1 -0
- package/Types/Translator.d.ts +1 -0
- package/Types/Translator.js +100 -19
- package/Types/Translator.mjs +1 -0
- package/Types/UserSession/SessionLength.d.mts +33 -0
- package/Types/UserSession/SessionLength.d.ts +33 -0
- package/Types/UserSession/SessionLength.js +134 -5
- package/Types/UserSession/SessionLength.mjs +5 -0
- package/Types/Workflow/WorkflowStatus.js +21 -10
- package/Utils/AI/InvestigationReport.js +2 -2
- package/Utils/API.d.mts +0 -11
- package/Utils/API.d.ts +0 -11
- package/Utils/API.js +0 -432
- package/Utils/AiRemediation/Resource/ResourceCommandPolicy.js +2 -2
- package/Utils/AiRemediation/VerifiedFixRunbook.d.mts +39 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.d.ts +39 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.js +231 -0
- package/Utils/AiRemediation/VerifiedFixRunbook.mjs +10 -0
- package/Utils/Dashboard/DashboardWidgetSorts.js +11 -2
- package/Utils/Dashboard/MonitorListWidgetFormat.d.mts +2 -1
- package/Utils/Dashboard/MonitorListWidgetFormat.d.ts +2 -1
- package/Utils/Dashboard/MonitorListWidgetFormat.js +5 -3
- package/Utils/DefaultRecordNames.d.mts +6 -0
- package/Utils/DefaultRecordNames.d.ts +6 -0
- package/Utils/DefaultRecordNames.js +122 -0
- package/Utils/DefaultRecordNames.mjs +6 -0
- package/Utils/Grok/Grok.js +7 -4
- package/Utils/Incident/PostmortemActionItemCodeTask.d.mts +20 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.d.ts +20 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.js +107 -0
- package/Utils/Incident/PostmortemActionItemCodeTask.mjs +10 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.d.mts +39 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.d.ts +39 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.js +118 -0
- package/Utils/Incident/PostmortemActionItemMarkdown.mjs +12 -0
- package/Utils/Incident/PostmortemNoteActionItems.d.mts +29 -0
- package/Utils/Incident/PostmortemNoteActionItems.d.ts +29 -0
- package/Utils/Incident/PostmortemNoteActionItems.js +544 -0
- package/Utils/Incident/PostmortemNoteActionItems.mjs +7 -0
- package/Utils/LookupTable.d.mts +3 -0
- package/Utils/LookupTable.d.ts +3 -0
- package/Utils/LookupTable.js +61 -0
- package/Utils/LookupTable.mjs +3 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.mts +2 -0
- package/Utils/Markdown/LinkReferenceDefinitions.d.ts +2 -0
- package/Utils/Markdown/LinkReferenceDefinitions.js +101 -1
- package/Utils/Markdown/LinkReferenceDefinitions.mjs +2 -0
- package/Utils/Markdown/OverLongText.js +296 -2
- package/Utils/Markdown/SlowMarkdown.d.mts +1 -0
- package/Utils/Markdown/SlowMarkdown.d.ts +1 -0
- package/Utils/Markdown/SlowMarkdown.js +354 -4
- package/Utils/Markdown/SlowMarkdown.mjs +1 -0
- package/Utils/Metrics/MetricFormulaEvaluator.js +10 -4
- package/Utils/Metrics/MetricSeriesFingerprint.js +13 -4
- package/Utils/Metrics/MetricSeriesScope.d.mts +5 -0
- package/Utils/Metrics/MetricSeriesScope.d.ts +5 -0
- package/Utils/Metrics/MetricSeriesScope.js +5 -1
- package/Utils/Monitor/MonitorRootCauseWording.d.mts +3 -0
- package/Utils/Monitor/MonitorRootCauseWording.d.ts +3 -0
- package/Utils/Monitor/MonitorRootCauseWording.js +100 -11
- package/Utils/Monitor/ProbeAgreementRule.d.mts +10 -0
- package/Utils/Monitor/ProbeAgreementRule.d.ts +10 -0
- package/Utils/Monitor/ProbeAgreementRule.js +58 -0
- package/Utils/Monitor/ProbeAgreementRule.mjs +3 -0
- package/Utils/Monitor/ProbeFailureReading.d.mts +4 -0
- package/Utils/Monitor/ProbeFailureReading.d.ts +4 -0
- package/Utils/Monitor/ProbeFailureReading.js +30 -1
- package/Utils/Monitor/ProbeFailureReading.mjs +1 -0
- package/Utils/Monitor/RequestFailureDescriptions.d.mts +61 -0
- package/Utils/Monitor/RequestFailureDescriptions.d.ts +61 -0
- package/Utils/Monitor/RequestFailureDescriptions.js +252 -0
- package/Utils/Monitor/RequestFailureDescriptions.mjs +6 -0
- package/Utils/PromQL/PromQLEngine.js +18 -9
- package/Utils/PromQL/PromQLFunctionEvaluators.js +114 -58
- package/Utils/PromQL/PromQLLabelOrder.d.mts +8 -0
- package/Utils/PromQL/PromQLLabelOrder.d.ts +8 -0
- package/Utils/PromQL/PromQLLabelOrder.js +212 -0
- package/Utils/PromQL/PromQLLabelOrder.mjs +6 -0
- package/Utils/PromQL/PromQLLabels.js +4 -3
- package/Utils/PromQL/PromQLMetricNames.js +8 -2
- package/Utils/PromQL/PromQLParser.js +11 -6
- package/Utils/PromQL/PromQLRegex.d.mts +11 -0
- package/Utils/PromQL/PromQLRegex.d.ts +11 -0
- package/Utils/PromQL/PromQLRegex.js +990 -50
- package/Utils/PromQL/PromQLRegex.mjs +3 -0
- package/Utils/PromQL/PrometheusResponse.js +3 -1
- package/Utils/PromQL/RE2CharacterClass.d.mts +24 -0
- package/Utils/PromQL/RE2CharacterClass.d.ts +24 -0
- package/Utils/PromQL/RE2CharacterClass.js +532 -0
- package/Utils/PromQL/RE2CharacterClass.mjs +16 -0
- package/Utils/RequestFailedDetailsUtil.d.mts +15 -0
- package/Utils/RequestFailedDetailsUtil.d.ts +15 -0
- package/Utils/RequestFailedDetailsUtil.js +452 -0
- package/Utils/RequestFailedDetailsUtil.mjs +2 -0
- package/Utils/Rum/UrlScrubber.d.mts +1 -1
- package/Utils/Rum/UrlScrubber.d.ts +1 -1
- package/Utils/Rum/UrlScrubber.js +10 -4
- package/Utils/Rum/UserFlow.js +22 -4
- package/Utils/SecurityCase/SecurityOverviewMetrics.d.mts +11 -1
- package/Utils/SecurityCase/SecurityOverviewMetrics.d.ts +11 -1
- package/Utils/SecurityCase/SecurityOverviewMetrics.js +99 -17
- package/Utils/SecurityCase/SecurityOverviewMetrics.mjs +3 -0
- package/Utils/Sms/OnCallPageSms.d.mts +2 -0
- package/Utils/Sms/OnCallPageSms.d.ts +2 -0
- package/Utils/Sms/OnCallPageSms.js +3 -1
- package/Utils/StateListType.d.mts +11 -0
- package/Utils/StateListType.d.ts +11 -0
- package/Utils/StateListType.js +21 -0
- package/Utils/StateListType.mjs +2 -0
- package/Utils/StateOrder.d.mts +8 -11
- package/Utils/StateOrder.d.ts +8 -11
- package/Utils/StateOrder.js +49 -84
- package/Utils/StateOrder.mjs +2 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.mts +9 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.d.ts +9 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.js +25 -0
- package/Utils/Suggestions/ActionItemCodeTaskSuggestion.mjs +2 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.mts +5 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.d.ts +5 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.js +39 -0
- package/Utils/Suggestions/VerifiedFixRunbookSuggestion.mjs +2 -0
- package/Utils/Syslog/SyslogMessageParser.js +16 -6
- package/Utils/Telemetry/HeartbeatAvailability.js +16 -21
- package/Utils/ValueFormatter.d.mts +1 -0
- package/Utils/ValueFormatter.d.ts +1 -0
- package/Utils/ValueFormatter.js +258 -18
- package/package.json +1 -1
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import commonJsModule from "./PromQLRegex.js";
|
|
2
|
+
export const PromQLPatternError = commonJsModule.PromQLPatternError;
|
|
2
3
|
export const compilePromQLRegex = commonJsModule.compilePromQLRegex;
|
|
4
|
+
export const describePromQLPatternProblem = commonJsModule.describePromQLPatternProblem;
|
|
5
|
+
export const readNamedCapture = commonJsModule.readNamedCapture;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parsePrometheusResult = exports.parsePrometheusValue = void 0;
|
|
4
|
+
const LookupTable_1 = require("../LookupTable");
|
|
4
5
|
const parsePrometheusValue = (value) => {
|
|
5
6
|
if (typeof value === "number") {
|
|
6
7
|
return value;
|
|
@@ -34,7 +35,8 @@ const toLabels = (metric) => {
|
|
|
34
35
|
}
|
|
35
36
|
const labels = {};
|
|
36
37
|
for (const [name, value] of Object.entries(metric)) {
|
|
37
|
-
|
|
38
|
+
// As an own key: a series may carry a label named __proto__.
|
|
39
|
+
(0, LookupTable_1.writeOwnValue)(labels, name, String(value));
|
|
38
40
|
}
|
|
39
41
|
return labels;
|
|
40
42
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const MAX_CODE_POINT: number;
|
|
2
|
+
export type CodePointRanges = ReadonlyArray<number>;
|
|
3
|
+
export declare const toCodePointRanges: (pairs: ReadonlyArray<number>) => Array<number>;
|
|
4
|
+
export declare const complementOf: (set: CodePointRanges) => Array<number>;
|
|
5
|
+
export declare const POSIX_CLASS_NAMES: ReadonlyArray<string>;
|
|
6
|
+
export declare const WIDER_CASE_FOLDS: ReadonlyArray<ReadonlyArray<number>>;
|
|
7
|
+
export declare const foldCase: (set: CodePointRanges) => Array<number>;
|
|
8
|
+
export declare const caseFoldedLetter: (codePoint: number) => Array<number>;
|
|
9
|
+
export declare const needsWrittenCaseFold: (codePoint: number) => boolean;
|
|
10
|
+
export declare const holdsCodePoint: (set: CodePointRanges, codePoint: number) => boolean;
|
|
11
|
+
export declare const posixClass: (name: string) => CodePointRanges | undefined;
|
|
12
|
+
export declare const perlClass: (letter: string) => CodePointRanges | undefined;
|
|
13
|
+
export declare const namedSet: (data: {
|
|
14
|
+
set: CodePointRanges;
|
|
15
|
+
negated: boolean;
|
|
16
|
+
ignoreCase: boolean;
|
|
17
|
+
}) => Array<number>;
|
|
18
|
+
export declare const literalCodeUnit: (codeUnit: number) => string;
|
|
19
|
+
export interface WrittenSet {
|
|
20
|
+
source: string;
|
|
21
|
+
needsGroup: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const writeSet: (set: CodePointRanges) => WrittenSet;
|
|
24
|
+
export declare const writeCodePoint: (codePoint: number) => WrittenSet;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const MAX_CODE_POINT: number;
|
|
2
|
+
export type CodePointRanges = ReadonlyArray<number>;
|
|
3
|
+
export declare const toCodePointRanges: (pairs: ReadonlyArray<number>) => Array<number>;
|
|
4
|
+
export declare const complementOf: (set: CodePointRanges) => Array<number>;
|
|
5
|
+
export declare const POSIX_CLASS_NAMES: ReadonlyArray<string>;
|
|
6
|
+
export declare const WIDER_CASE_FOLDS: ReadonlyArray<ReadonlyArray<number>>;
|
|
7
|
+
export declare const foldCase: (set: CodePointRanges) => Array<number>;
|
|
8
|
+
export declare const caseFoldedLetter: (codePoint: number) => Array<number>;
|
|
9
|
+
export declare const needsWrittenCaseFold: (codePoint: number) => boolean;
|
|
10
|
+
export declare const holdsCodePoint: (set: CodePointRanges, codePoint: number) => boolean;
|
|
11
|
+
export declare const posixClass: (name: string) => CodePointRanges | undefined;
|
|
12
|
+
export declare const perlClass: (letter: string) => CodePointRanges | undefined;
|
|
13
|
+
export declare const namedSet: (data: {
|
|
14
|
+
set: CodePointRanges;
|
|
15
|
+
negated: boolean;
|
|
16
|
+
ignoreCase: boolean;
|
|
17
|
+
}) => Array<number>;
|
|
18
|
+
export declare const literalCodeUnit: (codeUnit: number) => string;
|
|
19
|
+
export interface WrittenSet {
|
|
20
|
+
source: string;
|
|
21
|
+
needsGroup: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare const writeSet: (set: CodePointRanges) => WrittenSet;
|
|
24
|
+
export declare const writeCodePoint: (codePoint: number) => WrittenSet;
|
|
@@ -0,0 +1,532 @@
|
|
|
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.writeCodePoint = exports.writeSet = exports.literalCodeUnit = exports.namedSet = exports.perlClass = exports.posixClass = exports.holdsCodePoint = exports.needsWrittenCaseFold = exports.caseFoldedLetter = exports.foldCase = exports.WIDER_CASE_FOLDS = exports.POSIX_CLASS_NAMES = exports.complementOf = exports.toCodePointRanges = exports.MAX_CODE_POINT = void 0;
|
|
7
|
+
const CharacterSet_1 = __importDefault(require("../LinearRegExp/CharacterSet"));
|
|
8
|
+
const CaseCanonicalization_1 = require("../LinearRegExp/CaseCanonicalization");
|
|
9
|
+
const LookupTable_1 = __importDefault(require("../LookupTable"));
|
|
10
|
+
/*
|
|
11
|
+
* RE2'S CHARACTER CLASSES, WRITTEN FOR JAVASCRIPT'S RegExp.
|
|
12
|
+
*
|
|
13
|
+
* A bracket such as [a-z[:digit:]], an escape such as \s or \W, and a
|
|
14
|
+
* letter matched under (?i) each stand for a set of code points in RE2
|
|
15
|
+
* (Go's regexp/syntax, which Prometheus matches with). This file holds RE2's
|
|
16
|
+
* named sets, computes a class's set as RE2 does (parseClass, parse.go), and
|
|
17
|
+
* writes a set as JavaScript's RegExp without the u flag reads one: a
|
|
18
|
+
* character class of UTF-16 code units, and each code point beyond U+FFFF
|
|
19
|
+
* as its two code units.
|
|
20
|
+
*
|
|
21
|
+
* A set that holds every code point beyond U+FFFF - [^a], \S, \W - is
|
|
22
|
+
* written as a class of single code units, surrogates included, as "."
|
|
23
|
+
* reads text here: a character beyond U+FFFF, such as an emoji, is two
|
|
24
|
+
* characters to it, where RE2 reads one. A set that holds some of them -
|
|
25
|
+
* [\x{1F600}-\x{1F64F}] - matches each as one character, as RE2 does.
|
|
26
|
+
*/
|
|
27
|
+
exports.MAX_CODE_POINT = 0x10ffff;
|
|
28
|
+
const BMP_LAST = 0xffff;
|
|
29
|
+
const ASTRAL_FIRST = 0x10000;
|
|
30
|
+
const SURROGATE_FIRST = 0xd800;
|
|
31
|
+
const SURROGATE_LAST = 0xdfff;
|
|
32
|
+
const HIGH_SURROGATE_FIRST = 0xd800;
|
|
33
|
+
const LOW_SURROGATE_FIRST = 0xdc00;
|
|
34
|
+
const LOW_SURROGATE_LAST = 0xdfff;
|
|
35
|
+
/*
|
|
36
|
+
* The highest code point Go's case folding reaches (maxFold, parse.go):
|
|
37
|
+
* above it, no code point has another case.
|
|
38
|
+
*/
|
|
39
|
+
const LAST_FOLDING_CODE_POINT = 0x1e943;
|
|
40
|
+
// The ranges of any [first, last] pairs, in the form CodePointRanges keeps.
|
|
41
|
+
const toCodePointRanges = (pairs) => {
|
|
42
|
+
const ranges = [];
|
|
43
|
+
for (let index = 0; index + 1 < pairs.length; index += 2) {
|
|
44
|
+
ranges.push([pairs[index], pairs[index + 1]]);
|
|
45
|
+
}
|
|
46
|
+
ranges.sort((one, other) => {
|
|
47
|
+
return one[0] - other[0];
|
|
48
|
+
});
|
|
49
|
+
const merged = [];
|
|
50
|
+
for (const [first, last] of ranges) {
|
|
51
|
+
const end = merged.length;
|
|
52
|
+
if (end > 0 && first <= merged[end - 1] + 1) {
|
|
53
|
+
merged[end - 1] = Math.max(merged[end - 1], last);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
merged.push(first, last);
|
|
57
|
+
}
|
|
58
|
+
return merged;
|
|
59
|
+
};
|
|
60
|
+
exports.toCodePointRanges = toCodePointRanges;
|
|
61
|
+
// Every code point the set does not hold.
|
|
62
|
+
const complementOf = (set) => {
|
|
63
|
+
const complement = [];
|
|
64
|
+
let next = 0;
|
|
65
|
+
for (let index = 0; index < set.length; index += 2) {
|
|
66
|
+
if (set[index] > next) {
|
|
67
|
+
complement.push(next, set[index] - 1);
|
|
68
|
+
}
|
|
69
|
+
next = set[index + 1] + 1;
|
|
70
|
+
}
|
|
71
|
+
if (next <= exports.MAX_CODE_POINT) {
|
|
72
|
+
complement.push(next, exports.MAX_CODE_POINT);
|
|
73
|
+
}
|
|
74
|
+
return complement;
|
|
75
|
+
};
|
|
76
|
+
exports.complementOf = complementOf;
|
|
77
|
+
// The part of the set from `first` to `last`.
|
|
78
|
+
const partOf = (set, first, last) => {
|
|
79
|
+
const part = [];
|
|
80
|
+
for (let index = 0; index < set.length; index += 2) {
|
|
81
|
+
const from = Math.max(set[index], first);
|
|
82
|
+
const to = Math.min(set[index + 1], last);
|
|
83
|
+
if (from <= to) {
|
|
84
|
+
part.push(from, to);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return part;
|
|
88
|
+
};
|
|
89
|
+
const holdsAll = (set, first, last) => {
|
|
90
|
+
const part = partOf(set, first, last);
|
|
91
|
+
return part.length === 2 && part[0] === first && part[1] === last;
|
|
92
|
+
};
|
|
93
|
+
/*
|
|
94
|
+
* RE2's POSIX classes, [[:name:]] in a bracket, by name (posixGroup,
|
|
95
|
+
* perl_groups.go). A lookup table, so a name such as constructor, which
|
|
96
|
+
* every object inherits, names no class.
|
|
97
|
+
*/
|
|
98
|
+
const POSIX_CLASSES = (0, LookupTable_1.default)({
|
|
99
|
+
alnum: [0x30, 0x39, 0x41, 0x5a, 0x61, 0x7a],
|
|
100
|
+
alpha: [0x41, 0x5a, 0x61, 0x7a],
|
|
101
|
+
ascii: [0x00, 0x7f],
|
|
102
|
+
blank: [0x09, 0x09, 0x20, 0x20],
|
|
103
|
+
cntrl: [0x00, 0x1f, 0x7f, 0x7f],
|
|
104
|
+
digit: [0x30, 0x39],
|
|
105
|
+
graph: [0x21, 0x7e],
|
|
106
|
+
lower: [0x61, 0x7a],
|
|
107
|
+
print: [0x20, 0x7e],
|
|
108
|
+
punct: [0x21, 0x2f, 0x3a, 0x40, 0x5b, 0x60, 0x7b, 0x7e],
|
|
109
|
+
space: [0x09, 0x0d, 0x20, 0x20],
|
|
110
|
+
upper: [0x41, 0x5a],
|
|
111
|
+
word: [0x30, 0x39, 0x41, 0x5a, 0x5f, 0x5f, 0x61, 0x7a],
|
|
112
|
+
xdigit: [0x30, 0x39, 0x41, 0x46, 0x61, 0x66],
|
|
113
|
+
});
|
|
114
|
+
// The POSIX class names, for the sentence that refuses one RE2 does not have.
|
|
115
|
+
exports.POSIX_CLASS_NAMES = Array.from(POSIX_CLASSES.keys());
|
|
116
|
+
/*
|
|
117
|
+
* RE2's Perl classes, \d \s \w, by their letter (perlGroup,
|
|
118
|
+
* perl_groups.go); \D \S \W are their complements. RE2's \s is
|
|
119
|
+
* [\t\n\f\r ]: no \v, U+00A0 or other spaces, which JavaScript's \s holds.
|
|
120
|
+
*/
|
|
121
|
+
const PERL_CLASSES = (0, LookupTable_1.default)({
|
|
122
|
+
d: [0x30, 0x39],
|
|
123
|
+
s: [0x09, 0x0a, 0x0c, 0x0d, 0x20, 0x20],
|
|
124
|
+
w: [0x30, 0x39, 0x41, 0x5a, 0x5f, 0x5f, 0x61, 0x7a],
|
|
125
|
+
});
|
|
126
|
+
/*
|
|
127
|
+
* The case-folding orbits of Go's unicode.SimpleFold that JavaScript's
|
|
128
|
+
* RegExp with the i flag, and without u, does not join whole: the Kelvin
|
|
129
|
+
* sign with k, the long s with s, the Angstrom sign with å, the Ohm sign
|
|
130
|
+
* with ω, ẞ with ß, ϴ with θ and ϑ, and Greek letters with ypogegrammeni
|
|
131
|
+
* with their capitals. JavaScript compares two code units by their upper
|
|
132
|
+
* case (Canonicalize), never one at or above 128 with one below it, and
|
|
133
|
+
* not a letter whose upper case is two characters.
|
|
134
|
+
*
|
|
135
|
+
* Found by comparing, for every code point up to U+FFFF, Go 1.27's orbits
|
|
136
|
+
* (Unicode 17.0) with what Node 26's RegExp takes for one another (Unicode
|
|
137
|
+
* 17.0): these 36 differ, Go's orbit holding all of JavaScript's and more,
|
|
138
|
+
* and JavaScript never joins two code points Go keeps apart. A test holds
|
|
139
|
+
* the running engine to that (PromQLParser.test.ts).
|
|
140
|
+
*/
|
|
141
|
+
exports.WIDER_CASE_FOLDS = [
|
|
142
|
+
[0x004b, 0x006b, 0x212a],
|
|
143
|
+
[0x0053, 0x0073, 0x017f],
|
|
144
|
+
[0x00c5, 0x00e5, 0x212b],
|
|
145
|
+
[0x00df, 0x1e9e],
|
|
146
|
+
[0x0390, 0x1fd3],
|
|
147
|
+
[0x0398, 0x03b8, 0x03d1, 0x03f4],
|
|
148
|
+
[0x03a9, 0x03c9, 0x2126],
|
|
149
|
+
[0x03b0, 0x1fe3],
|
|
150
|
+
[0x1f80, 0x1f88],
|
|
151
|
+
[0x1f81, 0x1f89],
|
|
152
|
+
[0x1f82, 0x1f8a],
|
|
153
|
+
[0x1f83, 0x1f8b],
|
|
154
|
+
[0x1f84, 0x1f8c],
|
|
155
|
+
[0x1f85, 0x1f8d],
|
|
156
|
+
[0x1f86, 0x1f8e],
|
|
157
|
+
[0x1f87, 0x1f8f],
|
|
158
|
+
[0x1f90, 0x1f98],
|
|
159
|
+
[0x1f91, 0x1f99],
|
|
160
|
+
[0x1f92, 0x1f9a],
|
|
161
|
+
[0x1f93, 0x1f9b],
|
|
162
|
+
[0x1f94, 0x1f9c],
|
|
163
|
+
[0x1f95, 0x1f9d],
|
|
164
|
+
[0x1f96, 0x1f9e],
|
|
165
|
+
[0x1f97, 0x1f9f],
|
|
166
|
+
[0x1fa0, 0x1fa8],
|
|
167
|
+
[0x1fa1, 0x1fa9],
|
|
168
|
+
[0x1fa2, 0x1faa],
|
|
169
|
+
[0x1fa3, 0x1fab],
|
|
170
|
+
[0x1fa4, 0x1fac],
|
|
171
|
+
[0x1fa5, 0x1fad],
|
|
172
|
+
[0x1fa6, 0x1fae],
|
|
173
|
+
[0x1fa7, 0x1faf],
|
|
174
|
+
[0x1fb3, 0x1fbc],
|
|
175
|
+
[0x1fc3, 0x1fcc],
|
|
176
|
+
[0x1ff3, 0x1ffc],
|
|
177
|
+
[0xfb05, 0xfb06],
|
|
178
|
+
];
|
|
179
|
+
// Each code point of WIDER_CASE_FOLDS, by its orbit.
|
|
180
|
+
const WIDER_CASE_FOLD_OF = new Map(exports.WIDER_CASE_FOLDS.flatMap((orbit) => {
|
|
181
|
+
return orbit.map((codePoint) => {
|
|
182
|
+
return [codePoint, orbit];
|
|
183
|
+
});
|
|
184
|
+
}));
|
|
185
|
+
/*
|
|
186
|
+
* The other cases of a code point beyond U+FFFF, by its lower and upper
|
|
187
|
+
* case: Deseret, Osage, Adlam and the other scripts with case up there.
|
|
188
|
+
* JavaScript's case mappings join the same pairs Go's SimpleFold joins
|
|
189
|
+
* (each a pair, Unicode 17.0 in both), but its RegExp without u reads each
|
|
190
|
+
* such letter as two code units that have no case.
|
|
191
|
+
*/
|
|
192
|
+
const astralCaseVariants = (codePoint) => {
|
|
193
|
+
const variants = [];
|
|
194
|
+
const character = String.fromCodePoint(codePoint);
|
|
195
|
+
for (const other of [character.toLowerCase(), character.toUpperCase()]) {
|
|
196
|
+
const otherCodePoint = other.codePointAt(0);
|
|
197
|
+
if (otherCodePoint !== undefined &&
|
|
198
|
+
other.length === String.fromCodePoint(otherCodePoint).length &&
|
|
199
|
+
otherCodePoint !== codePoint &&
|
|
200
|
+
!variants.includes(otherCodePoint)) {
|
|
201
|
+
variants.push(otherCodePoint);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return variants;
|
|
205
|
+
};
|
|
206
|
+
/*
|
|
207
|
+
* The code points beyond U+FFFF that have another case, ascending, each
|
|
208
|
+
* with its other cases: read once, when a pattern first asks.
|
|
209
|
+
*/
|
|
210
|
+
let astralCasePairs = null;
|
|
211
|
+
const getAstralCasePairs = () => {
|
|
212
|
+
if (astralCasePairs === null) {
|
|
213
|
+
const found = [];
|
|
214
|
+
for (let codePoint = ASTRAL_FIRST; codePoint <= LAST_FOLDING_CODE_POINT; codePoint++) {
|
|
215
|
+
const variants = astralCaseVariants(codePoint);
|
|
216
|
+
if (variants.length > 0) {
|
|
217
|
+
found.push([codePoint, variants]);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
astralCasePairs = found;
|
|
221
|
+
}
|
|
222
|
+
return astralCasePairs;
|
|
223
|
+
};
|
|
224
|
+
/*
|
|
225
|
+
* The set and every code point Go's case folding joins to one of its code
|
|
226
|
+
* points (appendFoldedRange, parse.go): what (?i) makes of a class.
|
|
227
|
+
*/
|
|
228
|
+
const foldCase = (set) => {
|
|
229
|
+
const pairs = [...set];
|
|
230
|
+
const bmp = partOf(set, 0, BMP_LAST);
|
|
231
|
+
if (bmp.length > 0) {
|
|
232
|
+
// JavaScript's own case pairs, as the linear-time matcher reads them.
|
|
233
|
+
pairs.push(...(0, CaseCanonicalization_1.closeOverCase)(CharacterSet_1.default.fromPairs(bmp)).ranges);
|
|
234
|
+
for (const orbit of exports.WIDER_CASE_FOLDS) {
|
|
235
|
+
if (orbit.some((codePoint) => {
|
|
236
|
+
return (0, exports.holdsCodePoint)(bmp, codePoint);
|
|
237
|
+
})) {
|
|
238
|
+
for (const codePoint of orbit) {
|
|
239
|
+
pairs.push(codePoint, codePoint);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (partOf(set, ASTRAL_FIRST, LAST_FOLDING_CODE_POINT).length > 0) {
|
|
245
|
+
for (const [codePoint, variants] of getAstralCasePairs()) {
|
|
246
|
+
if ((0, exports.holdsCodePoint)(set, codePoint)) {
|
|
247
|
+
for (const variant of variants) {
|
|
248
|
+
pairs.push(variant, variant);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return (0, exports.toCodePointRanges)(pairs);
|
|
254
|
+
};
|
|
255
|
+
exports.foldCase = foldCase;
|
|
256
|
+
/*
|
|
257
|
+
* A letter under (?i), as the fewest of its cases that JavaScript's i flag
|
|
258
|
+
* joins into all of Go's: [sſ] for s, the flag adding S. Kept short, since
|
|
259
|
+
* a pattern runs only up to MAX_PATTERN_LENGTH once written out.
|
|
260
|
+
*/
|
|
261
|
+
const caseFoldedLetter = (codePoint) => {
|
|
262
|
+
const orbit = WIDER_CASE_FOLD_OF.get(codePoint);
|
|
263
|
+
if (orbit === undefined) {
|
|
264
|
+
// Beyond U+FFFF, where the i flag joins nothing: every case.
|
|
265
|
+
return (0, exports.foldCase)([codePoint, codePoint]);
|
|
266
|
+
}
|
|
267
|
+
const written = [codePoint, codePoint];
|
|
268
|
+
const joined = new Set((0, CaseCanonicalization_1.getCaseVariants)(codePoint));
|
|
269
|
+
for (const member of orbit) {
|
|
270
|
+
if (!joined.has(member)) {
|
|
271
|
+
written.push(member, member);
|
|
272
|
+
for (const variant of (0, CaseCanonicalization_1.getCaseVariants)(member)) {
|
|
273
|
+
joined.add(variant);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return (0, exports.toCodePointRanges)(written);
|
|
278
|
+
};
|
|
279
|
+
exports.caseFoldedLetter = caseFoldedLetter;
|
|
280
|
+
/*
|
|
281
|
+
* Whether a letter matched under (?i) needs its orbit written out: JavaScript's
|
|
282
|
+
* i flag joins every other letter's cases itself.
|
|
283
|
+
*/
|
|
284
|
+
const needsWrittenCaseFold = (codePoint) => {
|
|
285
|
+
if (codePoint > BMP_LAST) {
|
|
286
|
+
return (codePoint <= LAST_FOLDING_CODE_POINT &&
|
|
287
|
+
astralCaseVariants(codePoint).length > 0);
|
|
288
|
+
}
|
|
289
|
+
return WIDER_CASE_FOLD_OF.has(codePoint);
|
|
290
|
+
};
|
|
291
|
+
exports.needsWrittenCaseFold = needsWrittenCaseFold;
|
|
292
|
+
const holdsCodePoint = (set, codePoint) => {
|
|
293
|
+
let low = 0;
|
|
294
|
+
let high = set.length / 2 - 1;
|
|
295
|
+
while (low <= high) {
|
|
296
|
+
const middle = (low + high) >>> 1;
|
|
297
|
+
if (codePoint < set[middle * 2]) {
|
|
298
|
+
high = middle - 1;
|
|
299
|
+
}
|
|
300
|
+
else if (codePoint > set[middle * 2 + 1]) {
|
|
301
|
+
low = middle + 1;
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
};
|
|
309
|
+
exports.holdsCodePoint = holdsCodePoint;
|
|
310
|
+
/*
|
|
311
|
+
* One of RE2's named sets in a class: a POSIX class by its name, or a Perl
|
|
312
|
+
* class by its letter; undefined for a name RE2 does not have.
|
|
313
|
+
*/
|
|
314
|
+
const posixClass = (name) => {
|
|
315
|
+
return POSIX_CLASSES.get(name);
|
|
316
|
+
};
|
|
317
|
+
exports.posixClass = posixClass;
|
|
318
|
+
const perlClass = (letter) => {
|
|
319
|
+
return PERL_CLASSES.get(letter);
|
|
320
|
+
};
|
|
321
|
+
exports.perlClass = perlClass;
|
|
322
|
+
/*
|
|
323
|
+
* A named set as RE2 adds it to a class (appendGroup, parse.go): folded
|
|
324
|
+
* under (?i), then turned inside out when negated, so (?i)[[:^upper:]]
|
|
325
|
+
* holds no letter at all.
|
|
326
|
+
*/
|
|
327
|
+
const namedSet = (data) => {
|
|
328
|
+
const set = data.ignoreCase
|
|
329
|
+
? (0, exports.foldCase)(data.set)
|
|
330
|
+
: [...data.set];
|
|
331
|
+
return data.negated ? (0, exports.complementOf)(set) : set;
|
|
332
|
+
};
|
|
333
|
+
exports.namedSet = namedSet;
|
|
334
|
+
// A code unit as it is written inside a JavaScript class: [...].
|
|
335
|
+
const classCodeUnit = (codeUnit) => {
|
|
336
|
+
switch (codeUnit) {
|
|
337
|
+
case 0x5c: // \
|
|
338
|
+
case 0x5d: // ]
|
|
339
|
+
case 0x5b: // [
|
|
340
|
+
case 0x5e: // ^
|
|
341
|
+
case 0x2d: // -
|
|
342
|
+
return `\\${String.fromCharCode(codeUnit)}`;
|
|
343
|
+
default:
|
|
344
|
+
return plainCodeUnit(codeUnit);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
/*
|
|
348
|
+
* A code unit that needs no escape for what it means, written so it can be
|
|
349
|
+
* read: control characters, line separators and surrogates by their code.
|
|
350
|
+
*/
|
|
351
|
+
const plainCodeUnit = (codeUnit) => {
|
|
352
|
+
switch (codeUnit) {
|
|
353
|
+
case 0x09:
|
|
354
|
+
return "\\t";
|
|
355
|
+
case 0x0a:
|
|
356
|
+
return "\\n";
|
|
357
|
+
case 0x0b:
|
|
358
|
+
return "\\v";
|
|
359
|
+
case 0x0c:
|
|
360
|
+
return "\\f";
|
|
361
|
+
case 0x0d:
|
|
362
|
+
return "\\r";
|
|
363
|
+
default:
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
if (codeUnit < 0x20 || (codeUnit >= 0x7f && codeUnit <= 0x9f)) {
|
|
367
|
+
return `\\x${codeUnit.toString(16).padStart(2, "0")}`;
|
|
368
|
+
}
|
|
369
|
+
const character = String.fromCharCode(codeUnit);
|
|
370
|
+
if (codeUnit === 0x20 || PRINTABLE.test(character)) {
|
|
371
|
+
return character;
|
|
372
|
+
}
|
|
373
|
+
// A surrogate, a separator, a mark, a private or unassigned code point.
|
|
374
|
+
return `\\u${codeUnit.toString(16).padStart(4, "0")}`;
|
|
375
|
+
};
|
|
376
|
+
// A character that can be read as itself: a letter, digit, punctuation, symbol.
|
|
377
|
+
const PRINTABLE = /^[\p{L}\p{N}\p{P}\p{S}]$/u;
|
|
378
|
+
// The characters JavaScript reads as syntax outside a class.
|
|
379
|
+
const SYNTAX_CODE_UNITS = new Set(Array.from("^$\\.*+?()[]{}|/").map((character) => {
|
|
380
|
+
return character.charCodeAt(0);
|
|
381
|
+
}));
|
|
382
|
+
// A code unit as a literal outside a class.
|
|
383
|
+
const literalCodeUnit = (codeUnit) => {
|
|
384
|
+
if (SYNTAX_CODE_UNITS.has(codeUnit)) {
|
|
385
|
+
return `\\${String.fromCharCode(codeUnit)}`;
|
|
386
|
+
}
|
|
387
|
+
return plainCodeUnit(codeUnit);
|
|
388
|
+
};
|
|
389
|
+
exports.literalCodeUnit = literalCodeUnit;
|
|
390
|
+
// The body of a class of these code units, without its brackets.
|
|
391
|
+
const classBody = (units) => {
|
|
392
|
+
let body = "";
|
|
393
|
+
for (let index = 0; index < units.length; index += 2) {
|
|
394
|
+
const first = units[index];
|
|
395
|
+
const last = units[index + 1];
|
|
396
|
+
body += classCodeUnit(first);
|
|
397
|
+
if (last === first + 1) {
|
|
398
|
+
body += classCodeUnit(last);
|
|
399
|
+
}
|
|
400
|
+
else if (last > first) {
|
|
401
|
+
body += `-${classCodeUnit(last)}`;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return body;
|
|
405
|
+
};
|
|
406
|
+
/*
|
|
407
|
+
* A class of code units, the shorter way round: [abc] or [^abc]. Either
|
|
408
|
+
* reads the same under the i flag, for a set closed over case.
|
|
409
|
+
*/
|
|
410
|
+
const unitClass = (units) => {
|
|
411
|
+
if (units.length === 2 && units[0] === units[1]) {
|
|
412
|
+
return (0, exports.literalCodeUnit)(units[0]);
|
|
413
|
+
}
|
|
414
|
+
const positive = `[${classBody(units)}]`;
|
|
415
|
+
const negative = `[^${classBody(partOf((0, exports.complementOf)(units), 0, BMP_LAST))}]`;
|
|
416
|
+
return negative.length < positive.length ? negative : positive;
|
|
417
|
+
};
|
|
418
|
+
// A code point beyond U+FFFF as its two code units.
|
|
419
|
+
const surrogatePairOf = (codePoint) => {
|
|
420
|
+
const offset = codePoint - ASTRAL_FIRST;
|
|
421
|
+
return [
|
|
422
|
+
HIGH_SURROGATE_FIRST + (offset >> 10),
|
|
423
|
+
LOW_SURROGATE_FIRST + (offset & 0x3ff),
|
|
424
|
+
];
|
|
425
|
+
};
|
|
426
|
+
/*
|
|
427
|
+
* Code points beyond U+FFFF as alternatives of two code units each, the
|
|
428
|
+
* code points that share a high surrogate together:
|
|
429
|
+
* \ud83d[\ude00-\ude4f], [\ud800-\udbff][\udc00-\udfff]. Read range by
|
|
430
|
+
* range, so a set's alternatives cost in line with its ranges.
|
|
431
|
+
*/
|
|
432
|
+
const astralAlternatives = (set) => {
|
|
433
|
+
const blocks = [];
|
|
434
|
+
const add = (first, last, lows) => {
|
|
435
|
+
const previous = blocks[blocks.length - 1];
|
|
436
|
+
if (previous !== undefined &&
|
|
437
|
+
previous.first === previous.last &&
|
|
438
|
+
first === last &&
|
|
439
|
+
previous.last === first) {
|
|
440
|
+
// Another range under the same high surrogate.
|
|
441
|
+
previous.lows.push(...lows);
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
blocks.push({ first, last, lows });
|
|
445
|
+
};
|
|
446
|
+
for (let index = 0; index < set.length; index += 2) {
|
|
447
|
+
const [firstHigh, firstLow] = surrogatePairOf(set[index]);
|
|
448
|
+
const [lastHigh, lastLow] = surrogatePairOf(set[index + 1]);
|
|
449
|
+
if (firstHigh === lastHigh) {
|
|
450
|
+
add(firstHigh, firstHigh, [firstLow, lastLow]);
|
|
451
|
+
continue;
|
|
452
|
+
}
|
|
453
|
+
add(firstHigh, firstHigh, [firstLow, LOW_SURROGATE_LAST]);
|
|
454
|
+
if (lastHigh - firstHigh > 1) {
|
|
455
|
+
add(firstHigh + 1, lastHigh - 1, [
|
|
456
|
+
LOW_SURROGATE_FIRST,
|
|
457
|
+
LOW_SURROGATE_LAST,
|
|
458
|
+
]);
|
|
459
|
+
}
|
|
460
|
+
add(lastHigh, lastHigh, [LOW_SURROGATE_FIRST, lastLow]);
|
|
461
|
+
}
|
|
462
|
+
// Neighbouring high surrogates with the same low surrogates go together.
|
|
463
|
+
const merged = [];
|
|
464
|
+
for (const block of blocks) {
|
|
465
|
+
const lows = unitClass((0, exports.toCodePointRanges)(block.lows));
|
|
466
|
+
const previous = merged[merged.length - 1];
|
|
467
|
+
if (previous !== undefined &&
|
|
468
|
+
previous.lows === lows &&
|
|
469
|
+
previous.last + 1 === block.first) {
|
|
470
|
+
previous.last = block.last;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
merged.push({ first: block.first, last: block.last, lows });
|
|
474
|
+
}
|
|
475
|
+
return merged.map((block) => {
|
|
476
|
+
return `${unitClass([block.first, block.last])}${block.lows}`;
|
|
477
|
+
});
|
|
478
|
+
};
|
|
479
|
+
/*
|
|
480
|
+
* A set of code points, written for JavaScript's RegExp without u: as one
|
|
481
|
+
* class of code units when it holds every code point beyond U+FFFF or none
|
|
482
|
+
* of them, and otherwise as alternatives that match each code point beyond
|
|
483
|
+
* U+FFFF whole, as its two code units, beside a class of the rest.
|
|
484
|
+
*/
|
|
485
|
+
const writeSet = (set) => {
|
|
486
|
+
if (holdsAll(set, ASTRAL_FIRST, exports.MAX_CODE_POINT) &&
|
|
487
|
+
holdsAll(set, SURROGATE_FIRST, SURROGATE_LAST)) {
|
|
488
|
+
/*
|
|
489
|
+
* A set that leaves out only some of U+0000 to U+FFFF, [^a] or \S:
|
|
490
|
+
* each code unit of a character beyond U+FFFF, as "." reads it.
|
|
491
|
+
*/
|
|
492
|
+
return { source: unitClass(partOf(set, 0, BMP_LAST)), needsGroup: false };
|
|
493
|
+
}
|
|
494
|
+
/*
|
|
495
|
+
* Any other set's surrogates go: as code points, RE2 matches them in no
|
|
496
|
+
* text, and as code units they are halves of a character beyond U+FFFF.
|
|
497
|
+
*/
|
|
498
|
+
const units = (0, exports.toCodePointRanges)([
|
|
499
|
+
...partOf(set, 0, SURROGATE_FIRST - 1),
|
|
500
|
+
...partOf(set, SURROGATE_LAST + 1, BMP_LAST),
|
|
501
|
+
]);
|
|
502
|
+
const astral = partOf(set, ASTRAL_FIRST, exports.MAX_CODE_POINT);
|
|
503
|
+
if (astral.length === 0) {
|
|
504
|
+
return {
|
|
505
|
+
source: units.length === 0 ? "[]" : unitClass(units),
|
|
506
|
+
needsGroup: false,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
const alternatives = [];
|
|
510
|
+
if (units.length > 0) {
|
|
511
|
+
alternatives.push(unitClass(units));
|
|
512
|
+
}
|
|
513
|
+
alternatives.push(...astralAlternatives(astral));
|
|
514
|
+
if (alternatives.length === 1) {
|
|
515
|
+
// One code point beyond U+FFFF, or one high surrogate's: two code units.
|
|
516
|
+
return { source: alternatives[0], needsGroup: true };
|
|
517
|
+
}
|
|
518
|
+
return { source: `(?:${alternatives.join("|")})`, needsGroup: false };
|
|
519
|
+
};
|
|
520
|
+
exports.writeSet = writeSet;
|
|
521
|
+
// A code point as a literal: one code unit, or two beyond U+FFFF.
|
|
522
|
+
const writeCodePoint = (codePoint) => {
|
|
523
|
+
if (codePoint <= BMP_LAST) {
|
|
524
|
+
return { source: (0, exports.literalCodeUnit)(codePoint), needsGroup: false };
|
|
525
|
+
}
|
|
526
|
+
const [high, low] = surrogatePairOf(codePoint);
|
|
527
|
+
return {
|
|
528
|
+
source: `${plainCodeUnit(high)}${plainCodeUnit(low)}`,
|
|
529
|
+
needsGroup: true,
|
|
530
|
+
};
|
|
531
|
+
};
|
|
532
|
+
exports.writeCodePoint = writeCodePoint;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import commonJsModule from "./RE2CharacterClass.js";
|
|
2
|
+
export const MAX_CODE_POINT = commonJsModule.MAX_CODE_POINT;
|
|
3
|
+
export const POSIX_CLASS_NAMES = commonJsModule.POSIX_CLASS_NAMES;
|
|
4
|
+
export const WIDER_CASE_FOLDS = commonJsModule.WIDER_CASE_FOLDS;
|
|
5
|
+
export const caseFoldedLetter = commonJsModule.caseFoldedLetter;
|
|
6
|
+
export const complementOf = commonJsModule.complementOf;
|
|
7
|
+
export const foldCase = commonJsModule.foldCase;
|
|
8
|
+
export const holdsCodePoint = commonJsModule.holdsCodePoint;
|
|
9
|
+
export const literalCodeUnit = commonJsModule.literalCodeUnit;
|
|
10
|
+
export const namedSet = commonJsModule.namedSet;
|
|
11
|
+
export const needsWrittenCaseFold = commonJsModule.needsWrittenCaseFold;
|
|
12
|
+
export const perlClass = commonJsModule.perlClass;
|
|
13
|
+
export const posixClass = commonJsModule.posixClass;
|
|
14
|
+
export const toCodePointRanges = commonJsModule.toCodePointRanges;
|
|
15
|
+
export const writeCodePoint = commonJsModule.writeCodePoint;
|
|
16
|
+
export const writeSet = commonJsModule.writeSet;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosError } from "axios";
|
|
2
|
+
import RequestFailedDetails from "../Types/Probe/RequestFailedDetails.mjs";
|
|
3
|
+
export default class RequestFailedDetailsUtil {
|
|
4
|
+
/**
|
|
5
|
+
* Extracts detailed error information from an axios error or generic error.
|
|
6
|
+
* This provides more context about where and why a request failed.
|
|
7
|
+
*/
|
|
8
|
+
static getRequestFailedDetails(error: AxiosError | Error | unknown): RequestFailedDetails;
|
|
9
|
+
static getProbeNetworkFailureDescription(error: unknown): string | null;
|
|
10
|
+
private static getProbeSideRequestFailure;
|
|
11
|
+
private static getProbeSideFailureDescription;
|
|
12
|
+
private static getHttpStatusDescription;
|
|
13
|
+
private static getRequestHost;
|
|
14
|
+
private static collectConnectAddresses;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AxiosError } from "axios";
|
|
2
|
+
import RequestFailedDetails from "../Types/Probe/RequestFailedDetails";
|
|
3
|
+
export default class RequestFailedDetailsUtil {
|
|
4
|
+
/**
|
|
5
|
+
* Extracts detailed error information from an axios error or generic error.
|
|
6
|
+
* This provides more context about where and why a request failed.
|
|
7
|
+
*/
|
|
8
|
+
static getRequestFailedDetails(error: AxiosError | Error | unknown): RequestFailedDetails;
|
|
9
|
+
static getProbeNetworkFailureDescription(error: unknown): string | null;
|
|
10
|
+
private static getProbeSideRequestFailure;
|
|
11
|
+
private static getProbeSideFailureDescription;
|
|
12
|
+
private static getHttpStatusDescription;
|
|
13
|
+
private static getRequestHost;
|
|
14
|
+
private static collectConnectAddresses;
|
|
15
|
+
}
|