@oneuptime/common 14.0.91 → 14.0.93
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.js +8 -1
- package/Models/DatabaseModels/AlertEpisodeMember.d.mts +1 -0
- package/Models/DatabaseModels/AlertEpisodeMember.d.ts +1 -0
- package/Models/DatabaseModels/AlertEpisodeMember.js +50 -0
- package/Models/DatabaseModels/AutoRemediationRule.js +1 -1
- package/Models/DatabaseModels/CodeRepository.d.mts +1 -0
- package/Models/DatabaseModels/CodeRepository.d.ts +1 -0
- package/Models/DatabaseModels/CodeRepository.js +69 -6
- package/Models/DatabaseModels/IncidentEpisodeMember.d.mts +1 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.d.ts +1 -0
- package/Models/DatabaseModels/IncidentEpisodeMember.js +50 -0
- package/Models/DatabaseModels/IncomingCallPolicy.js +1 -1
- package/Models/DatabaseModels/LlmProvider.js +1 -1
- package/Models/DatabaseModels/MonitorTemplate.js +10 -4
- package/Models/DatabaseModels/NetworkDeviceDiscoveryScan.js +13 -13
- package/Models/DatabaseModels/OnCallDutyPolicy.js +1 -1
- package/Models/DatabaseModels/ScheduledMaintenanceReminderRule.js +1 -1
- package/Models/DatabaseModels/StatusPage.d.mts +2 -0
- package/Models/DatabaseModels/StatusPage.d.ts +2 -0
- package/Models/DatabaseModels/StatusPage.js +100 -0
- package/Types/AI/CodeTask.d.mts +1 -0
- package/Types/AI/CodeTask.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.d.mts +1 -0
- package/Types/AI/TelemetryAiActivity.d.ts +1 -0
- package/Types/AI/TelemetryAiActivity.js +4 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.mts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.d.ts +15 -0
- package/Types/CodeRepository/CodeRepositorySetting.js +49 -0
- package/Types/CodeRepository/CodeRepositorySetting.mjs +3 -0
- package/Types/Database/BlankColumnValue.d.mts +6 -0
- package/Types/Database/BlankColumnValue.d.ts +6 -0
- package/Types/Database/BlankColumnValue.js +77 -0
- package/Types/Database/BlankColumnValue.mjs +4 -0
- package/Types/Date.d.mts +10 -0
- package/Types/Date.d.ts +10 -0
- package/Types/Date.js +385 -98
- package/Types/DateLanguage.d.mts +67 -0
- package/Types/DateLanguage.d.ts +67 -0
- package/Types/DateLanguage.js +478 -0
- package/Types/DateLanguage.mjs +21 -0
- package/Types/Email/EmailTemplateType.d.mts +1 -0
- package/Types/Email/EmailTemplateType.d.ts +1 -0
- package/Types/Email/EmailTemplateType.js +1 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.d.mts +6 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.d.ts +6 -0
- package/Types/IncomingCall/IncomingCallPolicyRepeat.js +41 -14
- package/Types/IncomingCall/IncomingCallPolicyRepeat.mjs +3 -0
- package/Types/Monitor/CriteriaFilter.d.mts +1 -0
- package/Types/Monitor/CriteriaFilter.d.ts +1 -0
- package/Types/Monitor/CriteriaFilter.js +9 -0
- package/Types/Monitor/DatabaseMetricCatalog.js +2 -2
- package/Types/Monitor/KubernetesEventAlertTemplates.d.mts +20 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.d.ts +20 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.js +232 -0
- package/Types/Monitor/KubernetesEventAlertTemplates.mjs +8 -0
- package/Types/Monitor/MonitorType.js +12 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationCatalog.js +27 -2
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.mts +1 -0
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.d.ts +1 -0
- package/Types/Monitor/Recommendation/MonitorRecommendationUtil.js +31 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.mts +3 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.d.ts +3 -1
- package/Types/Monitor/SnmpMonitor/NetworkDeviceAlertPack.js +3 -2
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.mts +1 -0
- package/Types/Monitor/SnmpMonitor/SnmpMonitorResponse.d.ts +1 -0
- package/Types/NotificationSetting/NotificationEmailRollupCategory.js +2 -0
- package/Types/NotificationSetting/NotificationEmailRollupPolicy.js +10 -3
- package/Types/NotificationSetting/NotificationSettingEventType.d.mts +1 -0
- package/Types/NotificationSetting/NotificationSettingEventType.d.ts +1 -0
- package/Types/NotificationSetting/NotificationSettingEventType.js +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.mts +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.d.ts +7 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.js +51 -0
- package/Types/OnCallDutyPolicy/OnCallDutyPolicyRepeat.mjs +4 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.mts +8 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.d.ts +8 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.js +55 -0
- package/Types/Reminder/ScheduledMaintenanceReminderNeverReminds.mjs +5 -0
- package/Types/Runner/CodeRepositoryRunner.d.mts +7 -0
- package/Types/Runner/CodeRepositoryRunner.d.ts +7 -0
- package/Types/Runner/CodeRepositoryRunner.js +60 -14
- package/Types/Runner/CodeRepositoryRunner.mjs +1 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.mts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.d.ts +25 -0
- package/Types/SecurityEvent/OcsfProcessActivity.js +131 -0
- package/Types/SecurityEvent/OcsfProcessActivity.mjs +8 -0
- package/Types/Workflow/Templates.js +2 -5
- package/UI/Utils/TranslateTemplate.d.mts +73 -0
- package/UI/Utils/TranslateTemplate.d.ts +73 -0
- package/Utils/ColorContrast.d.mts +3 -0
- package/Utils/ColorContrast.d.ts +3 -0
- package/Utils/ColorContrast.js +41 -3
- package/Utils/ColorContrast.mjs +2 -0
- package/Utils/CronTab.d.mts +41 -3
- package/Utils/CronTab.d.ts +41 -3
- package/Utils/CronTab.js +112 -38
- package/Utils/Incident/WhoOpenedItRootCause.d.mts +2 -0
- package/Utils/Incident/WhoOpenedItRootCause.d.ts +2 -0
- package/Utils/Incident/WhoOpenedItRootCause.js +50 -0
- package/Utils/Incident/WhoOpenedItRootCause.mjs +3 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.mts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.d.ts +2 -0
- package/Utils/Monitor/MonitorOverviewTargetUtil.js +13 -2
- package/Utils/Monitor/SyntheticMonitorStepsUtil.d.mts +18 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.d.ts +18 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.js +129 -0
- package/Utils/Monitor/SyntheticMonitorStepsUtil.mjs +4 -0
- package/Utils/Rules/RuleRunSummary.d.mts +1 -0
- package/Utils/Rules/RuleRunSummary.d.ts +1 -0
- package/Utils/Rules/RuleRunSummary.js +19 -1
- package/Utils/Rules/RuleRunSummary.mjs +1 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.mts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.d.ts +5 -0
- package/Utils/SecurityEvent/Destinations/GoogleSecOpsUdmMapper.js +219 -58
- package/Utils/SecurityEvent/OcsfNormalizer.js +22 -13
- package/Utils/Slo/SloDuration.d.mts +1 -0
- package/Utils/Slo/SloDuration.d.ts +1 -0
- package/Utils/Slo/SloDuration.js +57 -8
- package/Utils/Slo/SloDuration.mjs +1 -0
- package/Utils/Sms/Gsm7Text.js +9 -1
- package/Utils/Sms/OnCallPageSms.d.mts +2 -0
- package/Utils/Sms/OnCallPageSms.d.ts +2 -0
- package/Utils/Sms/OnCallPageSms.js +19 -2
- package/Utils/Sms/OnCallPageSms.mjs +1 -0
- package/Utils/Sms/SubscriberSms.d.mts +2 -0
- package/Utils/Sms/SubscriberSms.d.ts +2 -0
- package/Utils/Sms/SubscriberSms.js +35 -0
- package/Utils/Sms/SubscriberSms.mjs +3 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.mts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.d.ts +15 -0
- package/Utils/Suggestions/CodeFixSuggestion.js +62 -1
- package/Utils/Suggestions/CodeFixSuggestion.mjs +4 -0
- package/Utils/Suggestions/ProfileFixSuggestion.js +4 -0
- package/Utils/Suggestions/SuggestionBlocker.d.mts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.d.ts +8 -0
- package/Utils/Suggestions/SuggestionBlocker.js +51 -0
- package/Utils/Suggestions/SuggestionBlocker.mjs +4 -0
- package/Utils/Suggestions/SuggestionOffer.d.mts +2 -1
- package/Utils/Suggestions/SuggestionOffer.d.ts +2 -1
- package/Utils/Suggestions/SuggestionOffer.js +5 -0
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.mts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.d.ts +2 -7
- package/Utils/Suggestions/TelemetryAiFixSuggestion.js +8 -36
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.mts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.d.ts +1 -0
- package/Utils/Suggestions/TelemetryImprovementSuggestion.js +1 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.mts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.d.ts +6 -0
- package/Utils/Suggestions/TracePerformanceFixSuggestion.js +46 -5
- package/package.json +8 -1
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.mts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.d.ts +0 -61
- package/Utils/Monitor/MonitorCheckScheduleUtil.js +0 -476
- package/Utils/Monitor/MonitorCheckScheduleUtil.mjs +0 -3
- package/Utils/Monitor/MonitorOverviewFamily.d.mts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.d.ts +0 -39
- package/Utils/Monitor/MonitorOverviewFamily.js +0 -206
- package/Utils/Monitor/MonitorOverviewFamily.mjs +0 -4
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.mts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.d.ts +0 -189
- package/Utils/Monitor/MonitorOverviewPresentationUtil.js +0 -1480
- package/Utils/Monitor/MonitorOverviewPresentationUtil.mjs +0 -5
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.mts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.d.ts +0 -112
- package/Utils/Monitor/MonitorOverviewProbeUtil.js +0 -640
- package/Utils/Monitor/MonitorOverviewProbeUtil.mjs +0 -3
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.mts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.d.ts +0 -27
- package/Utils/Monitor/MonitorStatusHistoryUtil.js +0 -132
- package/Utils/Monitor/MonitorStatusHistoryUtil.mjs +0 -2
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.mts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.d.ts +0 -42
- package/Utils/Monitor/MonitorUptimeSummaryUtil.js +0 -468
- package/Utils/Monitor/MonitorUptimeSummaryUtil.mjs +0 -2
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const ENGLISH_DATE_LANGUAGE: string;
|
|
2
|
+
export declare const isEnglishDateLanguage: (language: string | null | undefined) => boolean;
|
|
3
|
+
export declare const getDateDisplayLanguage: () => string;
|
|
4
|
+
export declare const setDateDisplayLanguage: (language: string | null | undefined) => void;
|
|
5
|
+
export declare function withDateDisplayLanguage<T>(language: string | null | undefined, work: () => T): T;
|
|
6
|
+
export declare function inEnglishDates<T>(work: () => T): T;
|
|
7
|
+
export declare const getDateLocale: (language: string | null | undefined) => string;
|
|
8
|
+
export declare const MAX_REMEMBERED_DATE_TEXTS: number;
|
|
9
|
+
export declare const rememberEnglishOf: (localized: string, english: () => string) => void;
|
|
10
|
+
export declare const getEnglishOf: (text: string) => string | undefined;
|
|
11
|
+
export declare const forgetRememberedDateTexts: () => void;
|
|
12
|
+
export declare const writeInDateDisplayLanguage: (english: () => string, localized: (language: string, locale: string) => string | null | undefined) => string;
|
|
13
|
+
export declare const getDateTimeFormat: (data: {
|
|
14
|
+
locale: string;
|
|
15
|
+
timezones: Array<string>;
|
|
16
|
+
options: Intl.DateTimeFormatOptions;
|
|
17
|
+
}) => Intl.DateTimeFormat | null;
|
|
18
|
+
export interface DateTextShape {
|
|
19
|
+
onlyShowDate?: boolean | undefined;
|
|
20
|
+
showSeconds?: boolean | undefined;
|
|
21
|
+
use12HourFormat?: boolean | undefined;
|
|
22
|
+
showWeekday?: boolean | undefined;
|
|
23
|
+
hideYear?: boolean | undefined;
|
|
24
|
+
twoDigitDay?: boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
export declare const getDateTimeOptions: (shape: DateTextShape) => Intl.DateTimeFormatOptions;
|
|
27
|
+
export declare const formatDateText: (data: {
|
|
28
|
+
date: Date;
|
|
29
|
+
locale: string;
|
|
30
|
+
timezones: Array<string>;
|
|
31
|
+
shape: DateTextShape;
|
|
32
|
+
}) => string | null;
|
|
33
|
+
export type RelativeDateUnit = "second" | "minute" | "hour" | "day" | "month" | "year";
|
|
34
|
+
export interface RelativeDistance {
|
|
35
|
+
isNow: boolean;
|
|
36
|
+
count: number;
|
|
37
|
+
unit: RelativeDateUnit;
|
|
38
|
+
isFuture: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare const getRelativeDistance: (date: Date, now: Date) => RelativeDistance;
|
|
41
|
+
export declare const formatRelativeDate: (data: {
|
|
42
|
+
date: Date;
|
|
43
|
+
now: Date;
|
|
44
|
+
locale: string;
|
|
45
|
+
}) => string | null;
|
|
46
|
+
export type DurationTextUnit = "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
|
|
47
|
+
export interface DurationTextPart {
|
|
48
|
+
count: number;
|
|
49
|
+
unit: DurationTextUnit;
|
|
50
|
+
}
|
|
51
|
+
export declare const formatDurationUnit: (data: {
|
|
52
|
+
part: DurationTextPart;
|
|
53
|
+
locale: string;
|
|
54
|
+
unitDisplay: "long" | "short" | "narrow";
|
|
55
|
+
maximumFractionDigits?: number | undefined;
|
|
56
|
+
}) => string | null;
|
|
57
|
+
export declare const formatDurationText: (data: {
|
|
58
|
+
parts: Array<DurationTextPart>;
|
|
59
|
+
locale: string;
|
|
60
|
+
unitDisplay: "long" | "short" | "narrow";
|
|
61
|
+
listStyle: "long" | "short" | "narrow";
|
|
62
|
+
}) => string | null;
|
|
63
|
+
export declare const formatDecimal: (data: {
|
|
64
|
+
value: number;
|
|
65
|
+
locale: string;
|
|
66
|
+
maximumFractionDigits: number;
|
|
67
|
+
}) => string | null;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const ENGLISH_DATE_LANGUAGE: string;
|
|
2
|
+
export declare const isEnglishDateLanguage: (language: string | null | undefined) => boolean;
|
|
3
|
+
export declare const getDateDisplayLanguage: () => string;
|
|
4
|
+
export declare const setDateDisplayLanguage: (language: string | null | undefined) => void;
|
|
5
|
+
export declare function withDateDisplayLanguage<T>(language: string | null | undefined, work: () => T): T;
|
|
6
|
+
export declare function inEnglishDates<T>(work: () => T): T;
|
|
7
|
+
export declare const getDateLocale: (language: string | null | undefined) => string;
|
|
8
|
+
export declare const MAX_REMEMBERED_DATE_TEXTS: number;
|
|
9
|
+
export declare const rememberEnglishOf: (localized: string, english: () => string) => void;
|
|
10
|
+
export declare const getEnglishOf: (text: string) => string | undefined;
|
|
11
|
+
export declare const forgetRememberedDateTexts: () => void;
|
|
12
|
+
export declare const writeInDateDisplayLanguage: (english: () => string, localized: (language: string, locale: string) => string | null | undefined) => string;
|
|
13
|
+
export declare const getDateTimeFormat: (data: {
|
|
14
|
+
locale: string;
|
|
15
|
+
timezones: Array<string>;
|
|
16
|
+
options: Intl.DateTimeFormatOptions;
|
|
17
|
+
}) => Intl.DateTimeFormat | null;
|
|
18
|
+
export interface DateTextShape {
|
|
19
|
+
onlyShowDate?: boolean | undefined;
|
|
20
|
+
showSeconds?: boolean | undefined;
|
|
21
|
+
use12HourFormat?: boolean | undefined;
|
|
22
|
+
showWeekday?: boolean | undefined;
|
|
23
|
+
hideYear?: boolean | undefined;
|
|
24
|
+
twoDigitDay?: boolean | undefined;
|
|
25
|
+
}
|
|
26
|
+
export declare const getDateTimeOptions: (shape: DateTextShape) => Intl.DateTimeFormatOptions;
|
|
27
|
+
export declare const formatDateText: (data: {
|
|
28
|
+
date: Date;
|
|
29
|
+
locale: string;
|
|
30
|
+
timezones: Array<string>;
|
|
31
|
+
shape: DateTextShape;
|
|
32
|
+
}) => string | null;
|
|
33
|
+
export type RelativeDateUnit = "second" | "minute" | "hour" | "day" | "month" | "year";
|
|
34
|
+
export interface RelativeDistance {
|
|
35
|
+
isNow: boolean;
|
|
36
|
+
count: number;
|
|
37
|
+
unit: RelativeDateUnit;
|
|
38
|
+
isFuture: boolean;
|
|
39
|
+
}
|
|
40
|
+
export declare const getRelativeDistance: (date: Date, now: Date) => RelativeDistance;
|
|
41
|
+
export declare const formatRelativeDate: (data: {
|
|
42
|
+
date: Date;
|
|
43
|
+
now: Date;
|
|
44
|
+
locale: string;
|
|
45
|
+
}) => string | null;
|
|
46
|
+
export type DurationTextUnit = "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
|
|
47
|
+
export interface DurationTextPart {
|
|
48
|
+
count: number;
|
|
49
|
+
unit: DurationTextUnit;
|
|
50
|
+
}
|
|
51
|
+
export declare const formatDurationUnit: (data: {
|
|
52
|
+
part: DurationTextPart;
|
|
53
|
+
locale: string;
|
|
54
|
+
unitDisplay: "long" | "short" | "narrow";
|
|
55
|
+
maximumFractionDigits?: number | undefined;
|
|
56
|
+
}) => string | null;
|
|
57
|
+
export declare const formatDurationText: (data: {
|
|
58
|
+
parts: Array<DurationTextPart>;
|
|
59
|
+
locale: string;
|
|
60
|
+
unitDisplay: "long" | "short" | "narrow";
|
|
61
|
+
listStyle: "long" | "short" | "narrow";
|
|
62
|
+
}) => string | null;
|
|
63
|
+
export declare const formatDecimal: (data: {
|
|
64
|
+
value: number;
|
|
65
|
+
locale: string;
|
|
66
|
+
maximumFractionDigits: number;
|
|
67
|
+
}) => string | null;
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* DATES, TIMES AND DURATIONS IN THE READER'S LANGUAGE.
|
|
4
|
+
*
|
|
5
|
+
* OneUptimeDate wrote every date with moment's English - "Oct 16 2026,
|
|
6
|
+
* 10:12 AM BST", "5 hours ago", "2 days, 3 hours" - under a German or a
|
|
7
|
+
* Japanese page. Each frontend now tells this module the language its reader
|
|
8
|
+
* reads (setDateDisplayLanguage, from its i18n set-up), and OneUptimeDate
|
|
9
|
+
* writes the words of a date in it: month and weekday names, "vor 5
|
|
10
|
+
* Stunden", "2 Tage, 3 Stunden", a decimal comma. The words come from the
|
|
11
|
+
* browser's Intl data, so no locale is shipped for them; the calendar is
|
|
12
|
+
* always the Gregorian one and the digits Latin, so a Persian reader's dates
|
|
13
|
+
* line up with every other number on the page.
|
|
14
|
+
*
|
|
15
|
+
* English is what nothing has set - the server, a worker, an email, a test -
|
|
16
|
+
* and every function writes it exactly as it always has.
|
|
17
|
+
*
|
|
18
|
+
* A date often goes into a sentence ("Checked {{time}}"). A sentence is
|
|
19
|
+
* wholly in the reader's language or wholly in English, never a German date
|
|
20
|
+
* inside an English sentence: a language that has not worded the sentence
|
|
21
|
+
* yet reads the English one. So every date written in another language is
|
|
22
|
+
* remembered with its English (rememberEnglishOf), and the translation layer
|
|
23
|
+
* puts the English back when it fills an English sentence (getEnglishOf), as
|
|
24
|
+
* a component inside a sentence draws its date in the sentence's language
|
|
25
|
+
* (withDateDisplayLanguage).
|
|
26
|
+
*
|
|
27
|
+
* React-free and free of the rest of OneUptime, so OneUptimeDate, the
|
|
28
|
+
* translation layer and any frontend can use it.
|
|
29
|
+
*/
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.formatDecimal = exports.formatDurationText = exports.formatDurationUnit = exports.formatRelativeDate = exports.getRelativeDistance = exports.formatDateText = exports.getDateTimeOptions = exports.getDateTimeFormat = exports.writeInDateDisplayLanguage = exports.forgetRememberedDateTexts = exports.getEnglishOf = exports.rememberEnglishOf = exports.MAX_REMEMBERED_DATE_TEXTS = exports.getDateLocale = exports.setDateDisplayLanguage = exports.getDateDisplayLanguage = exports.isEnglishDateLanguage = exports.ENGLISH_DATE_LANGUAGE = void 0;
|
|
35
|
+
exports.withDateDisplayLanguage = withDateDisplayLanguage;
|
|
36
|
+
exports.inEnglishDates = inEnglishDates;
|
|
37
|
+
const moment_timezone_1 = __importDefault(require("moment-timezone"));
|
|
38
|
+
exports.ENGLISH_DATE_LANGUAGE = "en";
|
|
39
|
+
let displayLanguage = exports.ENGLISH_DATE_LANGUAGE;
|
|
40
|
+
// "en", "en-GB", "EN": English, written the way OneUptimeDate always has.
|
|
41
|
+
const isEnglishDateLanguage = (language) => {
|
|
42
|
+
if (!language) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
const lower = language.trim().toLowerCase();
|
|
46
|
+
return lower === "" || lower === "en" || lower.startsWith("en-");
|
|
47
|
+
};
|
|
48
|
+
exports.isEnglishDateLanguage = isEnglishDateLanguage;
|
|
49
|
+
const normalizeLanguage = (language) => {
|
|
50
|
+
const trimmed = (language || "").trim();
|
|
51
|
+
return (0, exports.isEnglishDateLanguage)(trimmed) ? exports.ENGLISH_DATE_LANGUAGE : trimmed;
|
|
52
|
+
};
|
|
53
|
+
// The language dates are written in right now: "en" unless a frontend set one.
|
|
54
|
+
const getDateDisplayLanguage = () => {
|
|
55
|
+
return displayLanguage;
|
|
56
|
+
};
|
|
57
|
+
exports.getDateDisplayLanguage = getDateDisplayLanguage;
|
|
58
|
+
/*
|
|
59
|
+
* Set by each frontend from its i18n language, at start-up and on every
|
|
60
|
+
* switch. Anything that is not a language Intl knows is written in English.
|
|
61
|
+
*/
|
|
62
|
+
const setDateDisplayLanguage = (language) => {
|
|
63
|
+
displayLanguage = normalizeLanguage(language);
|
|
64
|
+
};
|
|
65
|
+
exports.setDateDisplayLanguage = setDateDisplayLanguage;
|
|
66
|
+
/*
|
|
67
|
+
* `work`'s dates written in `language`: a date drawn inside a sentence takes
|
|
68
|
+
* the sentence's language, which is English while the reader's language has
|
|
69
|
+
* not worded the sentence.
|
|
70
|
+
*/
|
|
71
|
+
function withDateDisplayLanguage(language, work) {
|
|
72
|
+
const previous = displayLanguage;
|
|
73
|
+
displayLanguage = normalizeLanguage(language);
|
|
74
|
+
try {
|
|
75
|
+
return work();
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
displayLanguage = previous;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/*
|
|
82
|
+
* `work`'s dates written in English: for text that stays English whatever
|
|
83
|
+
* the reader's language - an export, a prompt handed to OneUptime AI, a
|
|
84
|
+
* message not translated yet - so it never holds a German date.
|
|
85
|
+
*/
|
|
86
|
+
function inEnglishDates(work) {
|
|
87
|
+
return withDateDisplayLanguage(exports.ENGLISH_DATE_LANGUAGE, work);
|
|
88
|
+
}
|
|
89
|
+
const localeCache = new Map();
|
|
90
|
+
/*
|
|
91
|
+
* The Intl locale a language writes dates in: its own words and order, the
|
|
92
|
+
* Gregorian calendar and Latin digits ("fa" alone would give the Solar
|
|
93
|
+
* Hijri calendar in Persian digits). A language Intl does not know reads
|
|
94
|
+
* English, never the browser's own default, so a page never mixes two
|
|
95
|
+
* languages.
|
|
96
|
+
*/
|
|
97
|
+
const getDateLocale = (language) => {
|
|
98
|
+
const requested = normalizeLanguage(language);
|
|
99
|
+
const cached = localeCache.get(requested);
|
|
100
|
+
if (cached) {
|
|
101
|
+
return cached;
|
|
102
|
+
}
|
|
103
|
+
let locale = `${exports.ENGLISH_DATE_LANGUAGE}-u-ca-gregory-nu-latn`;
|
|
104
|
+
try {
|
|
105
|
+
const supported = Intl.DateTimeFormat.supportedLocalesOf([
|
|
106
|
+
requested,
|
|
107
|
+
]);
|
|
108
|
+
if (supported.length > 0 && supported[0]) {
|
|
109
|
+
locale = `${supported[0]}-u-ca-gregory-nu-latn`;
|
|
110
|
+
// Throws on a tag Intl cannot take an extension on.
|
|
111
|
+
new Intl.DateTimeFormat(locale);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (_a) {
|
|
115
|
+
locale = `${exports.ENGLISH_DATE_LANGUAGE}-u-ca-gregory-nu-latn`;
|
|
116
|
+
}
|
|
117
|
+
localeCache.set(requested, locale);
|
|
118
|
+
return locale;
|
|
119
|
+
};
|
|
120
|
+
exports.getDateLocale = getDateLocale;
|
|
121
|
+
/*
|
|
122
|
+
* THE ENGLISH OF A DATE WRITTEN IN ANOTHER LANGUAGE.
|
|
123
|
+
*
|
|
124
|
+
* Kept for the most recent texts only: a page writes its dates again on
|
|
125
|
+
* every render, so an old one that is no longer on screen is never asked
|
|
126
|
+
* for. The English is worked out only when a sentence asks for it.
|
|
127
|
+
*/
|
|
128
|
+
exports.MAX_REMEMBERED_DATE_TEXTS = 5000;
|
|
129
|
+
const englishOfText = new Map();
|
|
130
|
+
const rememberEnglishOf = (localized, english) => {
|
|
131
|
+
if (!localized) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
// The newest last, so the oldest is the first to go.
|
|
135
|
+
englishOfText.delete(localized);
|
|
136
|
+
englishOfText.set(localized, english);
|
|
137
|
+
if (englishOfText.size > exports.MAX_REMEMBERED_DATE_TEXTS) {
|
|
138
|
+
const oldest = englishOfText.keys().next().value;
|
|
139
|
+
if (oldest !== undefined) {
|
|
140
|
+
englishOfText.delete(oldest);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
exports.rememberEnglishOf = rememberEnglishOf;
|
|
145
|
+
/*
|
|
146
|
+
* The English of `text` when it is a date, a time or a duration this module
|
|
147
|
+
* wrote in another language; undefined for anything else.
|
|
148
|
+
*/
|
|
149
|
+
const getEnglishOf = (text) => {
|
|
150
|
+
const english = englishOfText.get(text);
|
|
151
|
+
if (!english) {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return english();
|
|
156
|
+
}
|
|
157
|
+
catch (_a) {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
exports.getEnglishOf = getEnglishOf;
|
|
162
|
+
// For tests: forget every remembered text.
|
|
163
|
+
const forgetRememberedDateTexts = () => {
|
|
164
|
+
englishOfText.clear();
|
|
165
|
+
};
|
|
166
|
+
exports.forgetRememberedDateTexts = forgetRememberedDateTexts;
|
|
167
|
+
/*
|
|
168
|
+
* A date's text in the display language: `english()` while that is English,
|
|
169
|
+
* `localized(language, locale)` otherwise - remembered with its English -
|
|
170
|
+
* and the English again when the language's text cannot be written.
|
|
171
|
+
*/
|
|
172
|
+
const writeInDateDisplayLanguage = (english, localized) => {
|
|
173
|
+
const language = (0, exports.getDateDisplayLanguage)();
|
|
174
|
+
const locale = (0, exports.getDateLocale)(language);
|
|
175
|
+
// English, or a language Intl does not know: moment's English, exactly.
|
|
176
|
+
if ((0, exports.isEnglishDateLanguage)(language) ||
|
|
177
|
+
locale.startsWith(`${exports.ENGLISH_DATE_LANGUAGE}-`)) {
|
|
178
|
+
return english();
|
|
179
|
+
}
|
|
180
|
+
let text = null;
|
|
181
|
+
try {
|
|
182
|
+
text = localized(language, locale);
|
|
183
|
+
}
|
|
184
|
+
catch (_a) {
|
|
185
|
+
text = null;
|
|
186
|
+
}
|
|
187
|
+
if (!text) {
|
|
188
|
+
return english();
|
|
189
|
+
}
|
|
190
|
+
/*
|
|
191
|
+
* Worked out in English when asked for, whatever the display language is
|
|
192
|
+
* then: the English of "06. Okt." names October as "Oct".
|
|
193
|
+
*/
|
|
194
|
+
(0, exports.rememberEnglishOf)(text, () => {
|
|
195
|
+
return withDateDisplayLanguage(exports.ENGLISH_DATE_LANGUAGE, english);
|
|
196
|
+
});
|
|
197
|
+
return text;
|
|
198
|
+
};
|
|
199
|
+
exports.writeInDateDisplayLanguage = writeInDateDisplayLanguage;
|
|
200
|
+
/*
|
|
201
|
+
* DATE AND TIME OF DAY.
|
|
202
|
+
*/
|
|
203
|
+
const dateTimeFormatCache = new Map();
|
|
204
|
+
/*
|
|
205
|
+
* A formatter for `options` in `locale`, read in the first of `timezones`
|
|
206
|
+
* this engine's Intl knows (an engine with older tzdata knows "Europe/Kiev"
|
|
207
|
+
* but not "Europe/Kyiv"); none means the runtime's own zone. Null when no
|
|
208
|
+
* zone works, so the caller writes the English moment knows how to write.
|
|
209
|
+
* Built once per locale, zone and shape: a table writes hundreds of dates.
|
|
210
|
+
*/
|
|
211
|
+
const getDateTimeFormat = (data) => {
|
|
212
|
+
const zones = data.timezones.length > 0 ? data.timezones : [undefined];
|
|
213
|
+
const shape = JSON.stringify(data.options);
|
|
214
|
+
for (const zone of zones) {
|
|
215
|
+
const key = `${data.locale}|${zone || ""}|${shape}`;
|
|
216
|
+
if (dateTimeFormatCache.has(key)) {
|
|
217
|
+
const cached = dateTimeFormatCache.get(key) || null;
|
|
218
|
+
if (cached) {
|
|
219
|
+
return cached;
|
|
220
|
+
}
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
try {
|
|
224
|
+
const format = new Intl.DateTimeFormat(data.locale, zone ? Object.assign(Object.assign({}, data.options), { timeZone: zone }) : data.options);
|
|
225
|
+
dateTimeFormatCache.set(key, format);
|
|
226
|
+
return format;
|
|
227
|
+
}
|
|
228
|
+
catch (_a) {
|
|
229
|
+
dateTimeFormatCache.set(key, null);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
};
|
|
234
|
+
exports.getDateTimeFormat = getDateTimeFormat;
|
|
235
|
+
// The Intl options a shape of OneUptimeDate's dates asks for.
|
|
236
|
+
const getDateTimeOptions = (shape) => {
|
|
237
|
+
const options = {
|
|
238
|
+
month: "short",
|
|
239
|
+
day: shape.twoDigitDay ? "2-digit" : "numeric",
|
|
240
|
+
};
|
|
241
|
+
if (!shape.hideYear) {
|
|
242
|
+
options.year = "numeric";
|
|
243
|
+
}
|
|
244
|
+
if (shape.showWeekday) {
|
|
245
|
+
options.weekday = "short";
|
|
246
|
+
}
|
|
247
|
+
if (!shape.onlyShowDate) {
|
|
248
|
+
options.hour = "2-digit";
|
|
249
|
+
options.minute = "2-digit";
|
|
250
|
+
options.hour12 = Boolean(shape.use12HourFormat);
|
|
251
|
+
if (shape.showSeconds) {
|
|
252
|
+
options.second = "2-digit";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
return options;
|
|
256
|
+
};
|
|
257
|
+
exports.getDateTimeOptions = getDateTimeOptions;
|
|
258
|
+
/*
|
|
259
|
+
* `date` in `locale`, read in the first zone of `timezones` Intl knows, in
|
|
260
|
+
* the shape asked for; null when Intl cannot write it.
|
|
261
|
+
*/
|
|
262
|
+
const formatDateText = (data) => {
|
|
263
|
+
if (Number.isNaN(data.date.getTime())) {
|
|
264
|
+
return null;
|
|
265
|
+
}
|
|
266
|
+
const format = (0, exports.getDateTimeFormat)({
|
|
267
|
+
locale: data.locale,
|
|
268
|
+
timezones: data.timezones,
|
|
269
|
+
options: (0, exports.getDateTimeOptions)(data.shape),
|
|
270
|
+
});
|
|
271
|
+
return format ? format.format(data.date) : null;
|
|
272
|
+
};
|
|
273
|
+
exports.formatDateText = formatDateText;
|
|
274
|
+
const relativeTimeFormatCache = new Map();
|
|
275
|
+
const getRelativeTimeFormatter = (locale, numeric) => {
|
|
276
|
+
const key = `${locale}|${numeric}`;
|
|
277
|
+
if (relativeTimeFormatCache.has(key)) {
|
|
278
|
+
return relativeTimeFormatCache.get(key) || null;
|
|
279
|
+
}
|
|
280
|
+
let formatter = null;
|
|
281
|
+
try {
|
|
282
|
+
const RelativeTimeFormat = Intl.RelativeTimeFormat;
|
|
283
|
+
if (RelativeTimeFormat) {
|
|
284
|
+
formatter = new RelativeTimeFormat(locale, {
|
|
285
|
+
numeric: numeric,
|
|
286
|
+
style: "long",
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
catch (_a) {
|
|
291
|
+
formatter = null;
|
|
292
|
+
}
|
|
293
|
+
relativeTimeFormatCache.set(key, formatter);
|
|
294
|
+
return formatter;
|
|
295
|
+
};
|
|
296
|
+
/*
|
|
297
|
+
* How far `date` is from `now`, counted and rounded the way moment's fromNow
|
|
298
|
+
* counts and rounds - the same calendar months and the same thresholds - so
|
|
299
|
+
* a status that read "a day ago" in English reads "vor 1 Tag" in German,
|
|
300
|
+
* never "vor 2 Tagen": up to 44 seconds is "a few seconds"; then minutes up
|
|
301
|
+
* to 44, hours up to 21, days up to 25, months up to 10, then years.
|
|
302
|
+
*/
|
|
303
|
+
const getRelativeDistance = (date, now) => {
|
|
304
|
+
const isFuture = date.getTime() - now.getTime() > 0;
|
|
305
|
+
// The calendar distance fromNow reads (whole months, then the rest).
|
|
306
|
+
const duration = moment_timezone_1.default
|
|
307
|
+
.duration({ from: now, to: date })
|
|
308
|
+
.abs();
|
|
309
|
+
const seconds = Math.round(duration.as("s"));
|
|
310
|
+
const minutes = Math.round(duration.as("m"));
|
|
311
|
+
const hours = Math.round(duration.as("h"));
|
|
312
|
+
const days = Math.round(duration.as("d"));
|
|
313
|
+
const months = Math.round(duration.as("M"));
|
|
314
|
+
const years = Math.round(duration.as("y"));
|
|
315
|
+
const distance = (count, unit) => {
|
|
316
|
+
return { isNow: false, count, unit, isFuture };
|
|
317
|
+
};
|
|
318
|
+
if (seconds <= 44) {
|
|
319
|
+
return { isNow: true, count: 0, unit: "second", isFuture };
|
|
320
|
+
}
|
|
321
|
+
if (minutes <= 1) {
|
|
322
|
+
return distance(1, "minute");
|
|
323
|
+
}
|
|
324
|
+
if (minutes < 45) {
|
|
325
|
+
return distance(minutes, "minute");
|
|
326
|
+
}
|
|
327
|
+
if (hours <= 1) {
|
|
328
|
+
return distance(1, "hour");
|
|
329
|
+
}
|
|
330
|
+
if (hours < 22) {
|
|
331
|
+
return distance(hours, "hour");
|
|
332
|
+
}
|
|
333
|
+
if (days <= 1) {
|
|
334
|
+
return distance(1, "day");
|
|
335
|
+
}
|
|
336
|
+
if (days < 26) {
|
|
337
|
+
return distance(days, "day");
|
|
338
|
+
}
|
|
339
|
+
if (months <= 1) {
|
|
340
|
+
return distance(1, "month");
|
|
341
|
+
}
|
|
342
|
+
if (months < 11) {
|
|
343
|
+
return distance(months, "month");
|
|
344
|
+
}
|
|
345
|
+
if (years <= 1) {
|
|
346
|
+
return distance(1, "year");
|
|
347
|
+
}
|
|
348
|
+
return distance(years, "year");
|
|
349
|
+
};
|
|
350
|
+
exports.getRelativeDistance = getRelativeDistance;
|
|
351
|
+
/*
|
|
352
|
+
* "vor 5 Stunden", "in 3 Tagen", "jetzt" - how far `date` is from `now`, in
|
|
353
|
+
* `locale`; null when this engine has no Intl.RelativeTimeFormat.
|
|
354
|
+
*/
|
|
355
|
+
const formatRelativeDate = (data) => {
|
|
356
|
+
if (Number.isNaN(data.date.getTime())) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
const distance = (0, exports.getRelativeDistance)(data.date, data.now);
|
|
360
|
+
if (distance.isNow) {
|
|
361
|
+
const auto = getRelativeTimeFormatter(data.locale, "auto");
|
|
362
|
+
return auto ? auto.format(0, "second") : null;
|
|
363
|
+
}
|
|
364
|
+
const always = getRelativeTimeFormatter(data.locale, "always");
|
|
365
|
+
if (!always) {
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
return always.format(distance.isFuture ? distance.count : -distance.count, distance.unit);
|
|
369
|
+
};
|
|
370
|
+
exports.formatRelativeDate = formatRelativeDate;
|
|
371
|
+
const unitFormatCache = new Map();
|
|
372
|
+
// The Intl.NumberFormat the cache was built with: another one starts afresh.
|
|
373
|
+
let unitFormatCacheOwner = null;
|
|
374
|
+
const getUnitFormatter = (data) => {
|
|
375
|
+
const key = `${data.locale}|${data.unit}|${data.unitDisplay}|${data.maximumFractionDigits}`;
|
|
376
|
+
if (unitFormatCacheOwner !== Intl.NumberFormat) {
|
|
377
|
+
unitFormatCache.clear();
|
|
378
|
+
unitFormatCacheOwner = Intl.NumberFormat;
|
|
379
|
+
}
|
|
380
|
+
if (unitFormatCache.has(key)) {
|
|
381
|
+
return unitFormatCache.get(key) || null;
|
|
382
|
+
}
|
|
383
|
+
let formatter = null;
|
|
384
|
+
try {
|
|
385
|
+
const candidate = new Intl.NumberFormat(data.locale, {
|
|
386
|
+
style: "unit",
|
|
387
|
+
unit: data.unit,
|
|
388
|
+
unitDisplay: data.unitDisplay,
|
|
389
|
+
maximumFractionDigits: data.maximumFractionDigits,
|
|
390
|
+
});
|
|
391
|
+
// An engine without the unit style writes the bare number.
|
|
392
|
+
const probe = candidate.format(2);
|
|
393
|
+
formatter =
|
|
394
|
+
probe === (2).toLocaleString(data.locale)
|
|
395
|
+
? null
|
|
396
|
+
: candidate;
|
|
397
|
+
}
|
|
398
|
+
catch (_a) {
|
|
399
|
+
formatter = null;
|
|
400
|
+
}
|
|
401
|
+
unitFormatCache.set(key, formatter);
|
|
402
|
+
return formatter;
|
|
403
|
+
};
|
|
404
|
+
// "2 Stunden", "2 Std.", "2h": one unit of a duration in `locale`.
|
|
405
|
+
const formatDurationUnit = (data) => {
|
|
406
|
+
var _a;
|
|
407
|
+
const formatter = getUnitFormatter({
|
|
408
|
+
locale: data.locale,
|
|
409
|
+
unit: data.part.unit,
|
|
410
|
+
unitDisplay: data.unitDisplay,
|
|
411
|
+
maximumFractionDigits: (_a = data.maximumFractionDigits) !== null && _a !== void 0 ? _a : 0,
|
|
412
|
+
});
|
|
413
|
+
return formatter ? formatter.format(data.part.count) : null;
|
|
414
|
+
};
|
|
415
|
+
exports.formatDurationUnit = formatDurationUnit;
|
|
416
|
+
/*
|
|
417
|
+
* A duration's units in `locale`, with the language's own unit names,
|
|
418
|
+
* plurals and list: "10 Tage, 23 Stunden", "10 jours et 23 heures", "10 日
|
|
419
|
+
* 23 時間". `listStyle` "narrow" joins them as a compact reading does ("2 J.
|
|
420
|
+
* 3 Mon."). Null when this engine cannot write one of the units.
|
|
421
|
+
*/
|
|
422
|
+
const formatDurationText = (data) => {
|
|
423
|
+
if (data.parts.length === 0) {
|
|
424
|
+
return null;
|
|
425
|
+
}
|
|
426
|
+
const words = [];
|
|
427
|
+
for (const part of data.parts) {
|
|
428
|
+
const word = (0, exports.formatDurationUnit)({
|
|
429
|
+
part,
|
|
430
|
+
locale: data.locale,
|
|
431
|
+
unitDisplay: data.unitDisplay,
|
|
432
|
+
});
|
|
433
|
+
if (!word) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
words.push(word);
|
|
437
|
+
}
|
|
438
|
+
if (words.length === 1) {
|
|
439
|
+
return words[0];
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
const ListFormat = Intl.ListFormat;
|
|
443
|
+
if (!ListFormat) {
|
|
444
|
+
return words.join(data.listStyle === "narrow" ? " " : ", ");
|
|
445
|
+
}
|
|
446
|
+
return new ListFormat(data.locale, {
|
|
447
|
+
type: "unit",
|
|
448
|
+
style: data.listStyle,
|
|
449
|
+
}).format(words);
|
|
450
|
+
}
|
|
451
|
+
catch (_a) {
|
|
452
|
+
return words.join(data.listStyle === "narrow" ? " " : ", ");
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
exports.formatDurationText = formatDurationText;
|
|
456
|
+
const numberFormatCache = new Map();
|
|
457
|
+
/*
|
|
458
|
+
* A number as `locale` writes it - "1,72" in German - with at most
|
|
459
|
+
* `maximumFractionDigits` decimals and no thousands separator, as a
|
|
460
|
+
* duration's figure is read. Null when Intl cannot.
|
|
461
|
+
*/
|
|
462
|
+
const formatDecimal = (data) => {
|
|
463
|
+
const key = `${data.locale}|${data.maximumFractionDigits}`;
|
|
464
|
+
if (!numberFormatCache.has(key)) {
|
|
465
|
+
try {
|
|
466
|
+
numberFormatCache.set(key, new Intl.NumberFormat(data.locale, {
|
|
467
|
+
maximumFractionDigits: data.maximumFractionDigits,
|
|
468
|
+
useGrouping: false,
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
catch (_a) {
|
|
472
|
+
numberFormatCache.set(key, null);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
const format = numberFormatCache.get(key) || null;
|
|
476
|
+
return format ? format.format(data.value) : null;
|
|
477
|
+
};
|
|
478
|
+
exports.formatDecimal = formatDecimal;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import commonJsModule from "./DateLanguage.js";
|
|
2
|
+
export const ENGLISH_DATE_LANGUAGE = commonJsModule.ENGLISH_DATE_LANGUAGE;
|
|
3
|
+
export const MAX_REMEMBERED_DATE_TEXTS = commonJsModule.MAX_REMEMBERED_DATE_TEXTS;
|
|
4
|
+
export const forgetRememberedDateTexts = commonJsModule.forgetRememberedDateTexts;
|
|
5
|
+
export const formatDateText = commonJsModule.formatDateText;
|
|
6
|
+
export const formatDecimal = commonJsModule.formatDecimal;
|
|
7
|
+
export const formatDurationText = commonJsModule.formatDurationText;
|
|
8
|
+
export const formatDurationUnit = commonJsModule.formatDurationUnit;
|
|
9
|
+
export const formatRelativeDate = commonJsModule.formatRelativeDate;
|
|
10
|
+
export const getDateDisplayLanguage = commonJsModule.getDateDisplayLanguage;
|
|
11
|
+
export const getDateLocale = commonJsModule.getDateLocale;
|
|
12
|
+
export const getDateTimeFormat = commonJsModule.getDateTimeFormat;
|
|
13
|
+
export const getDateTimeOptions = commonJsModule.getDateTimeOptions;
|
|
14
|
+
export const getEnglishOf = commonJsModule.getEnglishOf;
|
|
15
|
+
export const getRelativeDistance = commonJsModule.getRelativeDistance;
|
|
16
|
+
export const inEnglishDates = commonJsModule.inEnglishDates;
|
|
17
|
+
export const isEnglishDateLanguage = commonJsModule.isEnglishDateLanguage;
|
|
18
|
+
export const rememberEnglishOf = commonJsModule.rememberEnglishOf;
|
|
19
|
+
export const setDateDisplayLanguage = commonJsModule.setDateDisplayLanguage;
|
|
20
|
+
export const withDateDisplayLanguage = commonJsModule.withDateDisplayLanguage;
|
|
21
|
+
export const writeInDateDisplayLanguage = commonJsModule.writeInDateDisplayLanguage;
|
|
@@ -48,6 +48,7 @@ declare enum EmailTemplateType {
|
|
|
48
48
|
IncidentOwnerResourceCreated = "IncidentOwnerResourceCreated.hbs",
|
|
49
49
|
IncidentMemberAdded = "IncidentMemberAdded.hbs",
|
|
50
50
|
IncidentOwnerUnresolvedReminder = "IncidentOwnerUnresolvedReminder.hbs",
|
|
51
|
+
IncidentOwnerSlaBreached = "IncidentOwnerSlaBreached.hbs",
|
|
51
52
|
AlertOwnerAdded = "AlertOwnerAdded.hbs",
|
|
52
53
|
AlertOwnerStateChanged = "AlertOwnerStateChanged.hbs",
|
|
53
54
|
AlertOwnerNotePosted = "AlertOwnerNotePosted.hbs",
|
|
@@ -48,6 +48,7 @@ declare enum EmailTemplateType {
|
|
|
48
48
|
IncidentOwnerResourceCreated = "IncidentOwnerResourceCreated.hbs",
|
|
49
49
|
IncidentMemberAdded = "IncidentMemberAdded.hbs",
|
|
50
50
|
IncidentOwnerUnresolvedReminder = "IncidentOwnerUnresolvedReminder.hbs",
|
|
51
|
+
IncidentOwnerSlaBreached = "IncidentOwnerSlaBreached.hbs",
|
|
51
52
|
AlertOwnerAdded = "AlertOwnerAdded.hbs",
|
|
52
53
|
AlertOwnerStateChanged = "AlertOwnerStateChanged.hbs",
|
|
53
54
|
AlertOwnerNotePosted = "AlertOwnerNotePosted.hbs",
|
|
@@ -51,6 +51,7 @@ var EmailTemplateType;
|
|
|
51
51
|
EmailTemplateType["IncidentOwnerResourceCreated"] = "IncidentOwnerResourceCreated.hbs";
|
|
52
52
|
EmailTemplateType["IncidentMemberAdded"] = "IncidentMemberAdded.hbs";
|
|
53
53
|
EmailTemplateType["IncidentOwnerUnresolvedReminder"] = "IncidentOwnerUnresolvedReminder.hbs";
|
|
54
|
+
EmailTemplateType["IncidentOwnerSlaBreached"] = "IncidentOwnerSlaBreached.hbs";
|
|
54
55
|
EmailTemplateType["AlertOwnerAdded"] = "AlertOwnerAdded.hbs";
|
|
55
56
|
EmailTemplateType["AlertOwnerStateChanged"] = "AlertOwnerStateChanged.hbs";
|
|
56
57
|
EmailTemplateType["AlertOwnerNotePosted"] = "AlertOwnerNotePosted.hbs";
|
|
@@ -3,3 +3,9 @@ export interface IncomingCallPolicyRepeatSettings {
|
|
|
3
3
|
repeatPolicyIfNoOneAnswersTimes?: number | null | undefined;
|
|
4
4
|
}
|
|
5
5
|
export declare function getIncomingCallPolicyRepeatsAllowed(policy: IncomingCallPolicyRepeatSettings | null | undefined): number;
|
|
6
|
+
export declare const INCOMING_CALL_POLICY_REPEAT_COLUMNS: ReadonlyArray<string>;
|
|
7
|
+
export declare const INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL: string;
|
|
8
|
+
export declare function getIncomingCallPolicyRepeatRefusal(policy: {
|
|
9
|
+
repeatPolicyIfNoOneAnswers?: unknown;
|
|
10
|
+
repeatPolicyIfNoOneAnswersTimes?: unknown;
|
|
11
|
+
}): string | null;
|
|
@@ -3,3 +3,9 @@ export interface IncomingCallPolicyRepeatSettings {
|
|
|
3
3
|
repeatPolicyIfNoOneAnswersTimes?: number | null | undefined;
|
|
4
4
|
}
|
|
5
5
|
export declare function getIncomingCallPolicyRepeatsAllowed(policy: IncomingCallPolicyRepeatSettings | null | undefined): number;
|
|
6
|
+
export declare const INCOMING_CALL_POLICY_REPEAT_COLUMNS: ReadonlyArray<string>;
|
|
7
|
+
export declare const INCOMING_CALL_POLICY_REPEAT_TIMES_REFUSAL: string;
|
|
8
|
+
export declare function getIncomingCallPolicyRepeatRefusal(policy: {
|
|
9
|
+
repeatPolicyIfNoOneAnswers?: unknown;
|
|
10
|
+
repeatPolicyIfNoOneAnswersTimes?: unknown;
|
|
11
|
+
}): string | null;
|