@oneuptime/common 14.0.109 → 14.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/Models/AnalyticsModels/SecurityEvent.js +1 -1
  2. package/Models/DatabaseModels/AIInsight.js +2 -2
  3. package/Models/DatabaseModels/Alert.js +2 -2
  4. package/Models/DatabaseModels/AlertEpisode.js +2 -2
  5. package/Models/DatabaseModels/AlertEpisodeOnCallRule.js +3 -3
  6. package/Models/DatabaseModels/AlertGroupingRule.d.mts +1 -0
  7. package/Models/DatabaseModels/AlertGroupingRule.d.ts +1 -0
  8. package/Models/DatabaseModels/AlertGroupingRule.js +48 -2
  9. package/Models/DatabaseModels/AlertOnCallRule.js +3 -3
  10. package/Models/DatabaseModels/AlertSeverity.js +13 -4
  11. package/Models/DatabaseModels/AlertState.js +1 -1
  12. package/Models/DatabaseModels/CallLog.js +12 -12
  13. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.mts +2 -0
  14. package/Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel.d.ts +2 -0
  15. package/Models/DatabaseModels/EmailLog.js +12 -12
  16. package/Models/DatabaseModels/FormSubmission.js +2 -2
  17. package/Models/DatabaseModels/GlobalConfig.d.mts +1 -0
  18. package/Models/DatabaseModels/GlobalConfig.d.ts +1 -0
  19. package/Models/DatabaseModels/GlobalConfig.js +28 -0
  20. package/Models/DatabaseModels/Incident.js +2 -2
  21. package/Models/DatabaseModels/IncidentEpisode.js +2 -2
  22. package/Models/DatabaseModels/IncidentEpisodeOnCallRule.js +3 -3
  23. package/Models/DatabaseModels/IncidentGroupingRule.d.mts +1 -0
  24. package/Models/DatabaseModels/IncidentGroupingRule.d.ts +1 -0
  25. package/Models/DatabaseModels/IncidentGroupingRule.js +48 -2
  26. package/Models/DatabaseModels/IncidentOnCallRule.js +3 -3
  27. package/Models/DatabaseModels/IncidentSeverity.js +13 -4
  28. package/Models/DatabaseModels/IncidentState.js +1 -1
  29. package/Models/DatabaseModels/IncidentTemplate.js +2 -2
  30. package/Models/DatabaseModels/Monitor.js +3 -3
  31. package/Models/DatabaseModels/NetworkDevice.d.mts +1 -0
  32. package/Models/DatabaseModels/NetworkDevice.d.ts +1 -0
  33. package/Models/DatabaseModels/NetworkDevice.js +41 -0
  34. package/Models/DatabaseModels/OnCallDutyPolicy.js +4 -2
  35. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRule.js +1 -1
  36. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleSchedule.js +8 -5
  37. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleTeam.js +5 -2
  38. package/Models/DatabaseModels/OnCallDutyPolicyEscalationRuleUser.js +5 -2
  39. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLog.js +9 -6
  40. package/Models/DatabaseModels/OnCallDutyPolicyExecutionLogTimeline.js +10 -7
  41. package/Models/DatabaseModels/OnCallDutyPolicyFeed.js +14 -11
  42. package/Models/DatabaseModels/OnCallDutyPolicyOwnerTeam.js +7 -4
  43. package/Models/DatabaseModels/OnCallDutyPolicyOwnerUser.js +7 -4
  44. package/Models/DatabaseModels/OnCallDutyPolicySchedule.js +6 -3
  45. package/Models/DatabaseModels/OnCallDutyPolicyScheduleCalendarFeed.js +4 -4
  46. package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayer.js +3 -3
  47. package/Models/DatabaseModels/OnCallDutyPolicyScheduleLayerUser.js +6 -6
  48. package/Models/DatabaseModels/OnCallDutyPolicyTimeLog.js +9 -6
  49. package/Models/DatabaseModels/Project.d.mts +2 -0
  50. package/Models/DatabaseModels/Project.d.ts +2 -0
  51. package/Models/DatabaseModels/Project.js +96 -2
  52. package/Models/DatabaseModels/ProxmoxCluster.d.mts +1 -0
  53. package/Models/DatabaseModels/ProxmoxCluster.d.ts +1 -0
  54. package/Models/DatabaseModels/ProxmoxCluster.js +52 -3
  55. package/Models/DatabaseModels/PushNotificationLog.js +12 -12
  56. package/Models/DatabaseModels/Reseller.js +8 -2
  57. package/Models/DatabaseModels/ResellerPlan.js +8 -2
  58. package/Models/DatabaseModels/ScheduledMaintenance.js +6 -3
  59. package/Models/DatabaseModels/ScheduledMaintenanceInternalNote.js +7 -4
  60. package/Models/DatabaseModels/ScheduledMaintenanceMeasurementValue.js +2 -2
  61. package/Models/DatabaseModels/ScheduledMaintenancePublicNote.js +7 -4
  62. package/Models/DatabaseModels/ScheduledMaintenanceStateTimeline.js +1 -1
  63. package/Models/DatabaseModels/Service.js +1 -1
  64. package/Models/DatabaseModels/ServiceLevelObjectiveBurnRateRule.js +4 -4
  65. package/Models/DatabaseModels/ServiceLevelObjectiveErrorBudgetPolicyTier.js +4 -4
  66. package/Models/DatabaseModels/SmsLog.js +12 -12
  67. package/Models/DatabaseModels/StatusPage.js +5 -5
  68. package/Models/DatabaseModels/StatusPageSubscriber.js +2 -2
  69. package/Models/DatabaseModels/TelegramLog.js +12 -12
  70. package/Models/DatabaseModels/TelemetryIngestionKey.js +8 -5
  71. package/Models/DatabaseModels/TelemetryIngestionKeyRefusal.js +7 -4
  72. package/Models/DatabaseModels/User.d.mts +4 -0
  73. package/Models/DatabaseModels/User.d.ts +4 -0
  74. package/Models/DatabaseModels/User.js +100 -0
  75. package/Models/DatabaseModels/UserOnCallLog.js +6 -6
  76. package/Models/DatabaseModels/UserOnCallLogTimeline.js +3 -3
  77. package/Models/DatabaseModels/UserOnCallShiftReminderLog.js +2 -2
  78. package/Models/DatabaseModels/WebhookLog.js +12 -12
  79. package/Models/DatabaseModels/WhatsAppLog.js +12 -12
  80. package/Models/DatabaseModels/WorkspaceNotificationLog.js +12 -12
  81. package/Types/AI/AIChatTypes.d.mts +2 -1
  82. package/Types/AI/AIChatTypes.d.ts +2 -1
  83. package/Types/AI/AIChatTypes.js +5 -0
  84. package/Types/Analytics/ProductEvent.d.mts +6 -1
  85. package/Types/Analytics/ProductEvent.d.ts +6 -1
  86. package/Types/Analytics/ProductEvent.js +41 -0
  87. package/Types/AuditLog/AuditLogCoverage.d.mts +1 -0
  88. package/Types/AuditLog/AuditLogCoverage.d.ts +1 -0
  89. package/Types/AuditLog/AuditLogCoverage.js +4 -2
  90. package/Types/Cloud/CloudResourceCatalog.d.mts +2 -0
  91. package/Types/Cloud/CloudResourceCatalog.d.ts +2 -0
  92. package/Types/Cloud/CloudResourceCatalog.js +33 -3
  93. package/Types/Cloud/CloudResourceCatalog.mjs +1 -0
  94. package/Types/DataObservability/DataCheckSuggestions.d.mts +25 -0
  95. package/Types/DataObservability/DataCheckSuggestions.d.ts +25 -0
  96. package/Types/DataObservability/DataCheckSuggestions.js +102 -65
  97. package/Types/DataObservability/DataCheckSuggestions.mjs +1 -0
  98. package/Types/Database/TableMetadata.d.mts +2 -0
  99. package/Types/Database/TableMetadata.d.ts +2 -0
  100. package/Types/Database/TableMetadata.js +6 -0
  101. package/Types/Date.d.mts +20 -1
  102. package/Types/Date.d.ts +20 -1
  103. package/Types/Date.js +42 -2
  104. package/Types/DateLanguage.d.mts +2 -0
  105. package/Types/DateLanguage.d.ts +2 -0
  106. package/Types/DateLanguage.js +44 -2
  107. package/Types/DateLanguage.mjs +2 -0
  108. package/Types/DirectionArrow.d.mts +7 -0
  109. package/Types/DirectionArrow.d.ts +7 -0
  110. package/Types/DirectionArrow.js +88 -0
  111. package/Types/DirectionArrow.mjs +7 -0
  112. package/Types/Docs/GlossaryTerm.d.mts +1 -0
  113. package/Types/Docs/GlossaryTerm.d.ts +1 -0
  114. package/Types/Docs/GlossaryTerm.js +2 -0
  115. package/Types/Docs/RetiredNames.d.mts +11 -0
  116. package/Types/Docs/RetiredNames.d.ts +11 -0
  117. package/Types/Docs/RetiredNames.js +139 -0
  118. package/Types/Docs/RetiredNames.mjs +3 -0
  119. package/Types/Exception/RefusalWithValues.d.mts +7 -0
  120. package/Types/Exception/RefusalWithValues.d.ts +7 -0
  121. package/Types/Exception/RefusalWithValues.js +76 -0
  122. package/Types/Exception/RefusalWithValues.mjs +3 -0
  123. package/Types/Exception/UnexplainedError.d.mts +13 -0
  124. package/Types/Exception/UnexplainedError.d.ts +13 -0
  125. package/Types/Exception/UnexplainedError.js +53 -1
  126. package/Types/Exception/UnexplainedError.mjs +1 -0
  127. package/Types/File/FileSize.d.mts +4 -1
  128. package/Types/File/FileSize.d.ts +4 -1
  129. package/Types/File/FileSize.js +18 -17
  130. package/Types/HostCollector/HostCollector.d.mts +1 -0
  131. package/Types/HostCollector/HostCollector.d.ts +1 -0
  132. package/Types/HostCollector/HostCollector.js +26 -10
  133. package/Types/HostCollector/HostCollector.mjs +1 -0
  134. package/Types/Monitor/MonitorCriteria.js +2 -2
  135. package/Types/Monitor/MonitorStep.js +1 -1
  136. package/Types/Monitor/MonitorTemplateSyncField.d.mts +6 -0
  137. package/Types/Monitor/MonitorTemplateSyncField.d.ts +6 -0
  138. package/Types/Monitor/MonitorTemplateSyncField.js +106 -64
  139. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.mts +1 -0
  140. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.d.ts +1 -0
  141. package/Types/Monitor/NtpMonitor/NtpMonitorUtil.js +11 -3
  142. package/Types/Monitor/WhoIsTold.d.mts +3 -1
  143. package/Types/Monitor/WhoIsTold.d.ts +3 -1
  144. package/Types/Monitor/WhoIsTold.js +2 -1
  145. package/Types/NotificationRule/PagingLadder.d.mts +137 -0
  146. package/Types/NotificationRule/PagingLadder.d.ts +137 -0
  147. package/Types/NotificationRule/PagingLadder.js +682 -0
  148. package/Types/NotificationRule/PagingLadder.mjs +28 -0
  149. package/Types/NotificationSetting/NotificationEmailRollupCategory.js +1 -1
  150. package/Types/OnCallDutyPolicy/OnCallPageLine.d.mts +26 -0
  151. package/Types/OnCallDutyPolicy/OnCallPageLine.d.ts +26 -0
  152. package/Types/OnCallDutyPolicy/OnCallPageLine.js +136 -0
  153. package/Types/OnCallDutyPolicy/OnCallPageLine.mjs +18 -0
  154. package/Types/OnCallDutyPolicy/OnCallTestPage.d.mts +44 -0
  155. package/Types/OnCallDutyPolicy/OnCallTestPage.d.ts +44 -0
  156. package/Types/OnCallDutyPolicy/OnCallTestPage.js +96 -5
  157. package/Types/OnCallDutyPolicy/OnCallTestPage.mjs +1 -0
  158. package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.mts +19 -0
  159. package/Types/OnCallDutyPolicy/OnCallTestPageLine.d.ts +19 -0
  160. package/Types/OnCallDutyPolicy/OnCallTestPageLine.js +222 -0
  161. package/Types/OnCallDutyPolicy/OnCallTestPageLine.mjs +6 -0
  162. package/Types/OnCallDutyPolicy/ScheduleLayerDefaults.js +5 -2
  163. package/Types/OnCallDutyPolicy/UserOverrideCoverRequest.js +9 -1
  164. package/Types/Permission.d.mts +2 -2
  165. package/Types/Permission.d.ts +2 -2
  166. package/Types/Permission.js +194 -193
  167. package/Types/Product/ProductCatalog.d.mts +10 -0
  168. package/Types/Product/ProductCatalog.d.ts +10 -0
  169. package/Types/Product/ProductCatalog.js +208 -0
  170. package/Types/Product/ProductCatalog.mjs +6 -0
  171. package/Types/Product/ProductOfTable.d.mts +3 -0
  172. package/Types/Product/ProductOfTable.d.ts +3 -0
  173. package/Types/Product/ProductOfTable.js +68 -0
  174. package/Types/Product/ProductOfTable.mjs +3 -0
  175. package/Types/Product/ProjectProductsAnswer.d.mts +3 -0
  176. package/Types/Product/ProjectProductsAnswer.d.ts +3 -0
  177. package/Types/Product/ProjectProductsAnswer.js +35 -2
  178. package/Types/Product/ProjectProductsAnswer.mjs +1 -0
  179. package/Types/Product/ServerProducts.d.mts +65 -0
  180. package/Types/Product/ServerProducts.d.ts +65 -0
  181. package/Types/Product/ServerProducts.js +383 -0
  182. package/Types/Product/ServerProducts.mjs +26 -0
  183. package/Types/Product/ServerProductsAnswer.d.mts +21 -0
  184. package/Types/Product/ServerProductsAnswer.d.ts +21 -0
  185. package/Types/Product/ServerProductsAnswer.js +78 -0
  186. package/Types/Product/ServerProductsAnswer.mjs +5 -0
  187. package/Types/ProductFeedback/ProductFeedback.d.mts +3 -1
  188. package/Types/ProductFeedback/ProductFeedback.d.ts +3 -1
  189. package/Types/ProductFeedback/ProductFeedback.js +8 -0
  190. package/Types/Rum/SessionReplayCustomEvents.d.mts +1 -0
  191. package/Types/Rum/SessionReplayCustomEvents.d.ts +1 -0
  192. package/Types/SampleProject/SampleProject.d.mts +54 -0
  193. package/Types/SampleProject/SampleProject.d.ts +54 -0
  194. package/Types/SampleProject/SampleProject.js +177 -0
  195. package/Types/SampleProject/SampleProject.mjs +22 -0
  196. package/Types/SampleProject/SampleProjectContent.d.mts +127 -0
  197. package/Types/SampleProject/SampleProjectContent.d.ts +127 -0
  198. package/Types/SampleProject/SampleProjectContent.js +397 -0
  199. package/Types/SampleProject/SampleProjectContent.mjs +18 -0
  200. package/Types/Telemetry/TelemetryIngestSurface.js +6 -5
  201. package/Types/Translator.d.mts +1 -0
  202. package/Types/Translator.d.ts +1 -0
  203. package/Types/Translator.js +40 -2
  204. package/Types/Translator.mjs +1 -0
  205. package/Types/UsedBy/UsedBy.d.mts +103 -0
  206. package/Types/UsedBy/UsedBy.d.ts +103 -0
  207. package/Types/UsedBy/UsedBy.js +389 -0
  208. package/Types/UsedBy/UsedBy.mjs +20 -0
  209. package/Types/UsedBy/UsedByServerProducts.d.mts +4 -0
  210. package/Types/UsedBy/UsedByServerProducts.d.ts +4 -0
  211. package/Types/UsedBy/UsedByServerProducts.js +48 -0
  212. package/Types/UsedBy/UsedByServerProducts.mjs +3 -0
  213. package/Types/WelcomeChecklist/WelcomeChecklist.d.mts +6 -0
  214. package/Types/WelcomeChecklist/WelcomeChecklist.d.ts +6 -0
  215. package/Types/WelcomeChecklist/WelcomeChecklist.js +54 -2
  216. package/Types/WelcomeChecklist/WelcomeChecklist.mjs +4 -0
  217. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.mts +1 -0
  218. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.d.ts +1 -0
  219. package/Types/WelcomeChecklist/WelcomeChecklistAnswer.js +3 -0
  220. package/Types/Workflow/PassedOnFields.js +2 -1
  221. package/Types/Workflow/Templates.js +1 -1
  222. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.mts +2 -0
  223. package/Types/Workspace/NotificationRules/NotificationRuleCondition.d.ts +2 -0
  224. package/Utils/AI/MeaningMatch.d.mts +36 -0
  225. package/Utils/AI/MeaningMatch.d.ts +36 -0
  226. package/Utils/AI/MeaningMatch.js +535 -0
  227. package/Utils/AI/MeaningMatch.mjs +7 -0
  228. package/Utils/ArchivableValues.js +1 -1
  229. package/Utils/AuditLog/AuditLogValues.js +2 -2
  230. package/Utils/Dashboard/ClockWidgetFormat.d.mts +14 -2
  231. package/Utils/Dashboard/ClockWidgetFormat.d.ts +14 -2
  232. package/Utils/Dashboard/ClockWidgetFormat.js +105 -2
  233. package/Utils/Dashboard/DashboardViewConfigSignature.d.mts +3 -0
  234. package/Utils/Dashboard/DashboardViewConfigSignature.d.ts +3 -0
  235. package/Utils/Dashboard/DashboardViewConfigSignature.js +45 -0
  236. package/Utils/Dashboard/DashboardViewConfigSignature.mjs +3 -0
  237. package/Utils/DataSecurity/TextScanner.js +2 -2
  238. package/Utils/DeveloperDocs/AiAssistantExamples.js +4 -4
  239. package/Utils/DeveloperDocs/CliCommands.d.mts +1 -0
  240. package/Utils/DeveloperDocs/CliCommands.d.ts +1 -0
  241. package/Utils/DeveloperDocs/CliCommands.js +2 -1
  242. package/Utils/DeveloperDocs/CliResources.js +2 -1
  243. package/Utils/DeveloperDocs/TerraformSchema.js +3 -1
  244. package/Utils/Markdown/LinkReferenceDefinitions.d.mts +8 -0
  245. package/Utils/Markdown/LinkReferenceDefinitions.d.ts +8 -0
  246. package/Utils/Markdown/LinkReferenceDefinitions.js +1493 -131
  247. package/Utils/Markdown/LinkReferenceDefinitions.mjs +1 -0
  248. package/Utils/Markdown/MarkdownTableCell.js +2 -1
  249. package/Utils/Markdown/OverLongText.js +523 -5
  250. package/Utils/Markdown/SlowMarkdown.d.mts +14 -0
  251. package/Utils/Markdown/SlowMarkdown.d.ts +14 -0
  252. package/Utils/Markdown/SlowMarkdown.js +595 -11
  253. package/Utils/Markdown/SlowMarkdown.mjs +6 -0
  254. package/Utils/ModelApiName.d.mts +11 -0
  255. package/Utils/ModelApiName.d.ts +11 -0
  256. package/Utils/ModelApiName.js +72 -0
  257. package/Utils/ModelApiName.mjs +5 -0
  258. package/Utils/Monitor/DeviceMacLearningUtil.d.mts +2 -1
  259. package/Utils/Monitor/DeviceMacLearningUtil.d.ts +2 -1
  260. package/Utils/Monitor/DeviceMacLearningUtil.js +26 -0
  261. package/Utils/Monitor/EndpointAttachmentUtil.js +8 -3
  262. package/Utils/Monitor/ExternalStatusPageReading.d.mts +3 -0
  263. package/Utils/Monitor/ExternalStatusPageReading.d.ts +3 -0
  264. package/Utils/Monitor/ExternalStatusPageReading.js +35 -1
  265. package/Utils/Monitor/ExternalStatusPageReading.mjs +2 -0
  266. package/Utils/Monitor/MonitorTemplateLinkRefusal.d.mts +9 -0
  267. package/Utils/Monitor/MonitorTemplateLinkRefusal.d.ts +9 -0
  268. package/Utils/Monitor/MonitorTemplateLinkRefusal.js +45 -0
  269. package/Utils/Monitor/MonitorTemplateLinkRefusal.mjs +6 -0
  270. package/Utils/OpenStack/OpenStackCheckName.js +2 -1
  271. package/Utils/OpenStack/OpenStackLogScrub.js +1 -1
  272. package/Utils/OpenStack/OpenStackLogs.js +3 -2
  273. package/Utils/OpenStack/OpenStackTraces.js +2 -1
  274. package/Utils/Project/NotificationChannels.js +5 -5
  275. package/Utils/Project/ProjectBalance.js +2 -2
  276. package/Utils/Project/TwilioAccount.js +2 -2
  277. package/Utils/ScheduledMaintenanceStart.d.mts +3 -0
  278. package/Utils/ScheduledMaintenanceStart.d.ts +3 -0
  279. package/Utils/ScheduledMaintenanceStart.js +9 -0
  280. package/Utils/Schema/ModelSchema.js +10 -1
  281. package/Utils/Uptime/UptimeMaintenanceUtil.js +2 -1
  282. package/Utils/ValueFormatter.d.mts +8 -6
  283. package/Utils/ValueFormatter.d.ts +8 -6
  284. package/Utils/ValueFormatter.js +145 -0
  285. package/package.json +1 -1
@@ -3,16 +3,18 @@ export interface FormattedValue {
3
3
  unit: string;
4
4
  formatted: string;
5
5
  }
6
+ export interface ValueFormatterOptions {
7
+ metricName?: string;
8
+ language?: string | undefined;
9
+ }
6
10
  export default class ValueFormatter {
7
- static formatValue(value: number, unit: string, options?: {
8
- metricName?: string;
9
- }): string;
11
+ static formatValue(value: number, unit: string, options?: ValueFormatterOptions): string;
12
+ static formatValueInParts(value: number, unit: string, options?: ValueFormatterOptions): FormattedValue;
13
+ static isUnitSetApart(parts: FormattedValue): boolean;
10
14
  static getCompactUnit(unit: string, options?: {
11
15
  metricName?: string;
12
16
  }): string;
13
- static formatValueCompact(value: number, unit: string, options?: {
14
- metricName?: string;
15
- }): FormattedValue;
17
+ static formatValueCompact(value: number, unit: string, options?: ValueFormatterOptions): FormattedValue;
16
18
  static isPercentUnit(unit: string | undefined): boolean;
17
19
  static isFractionMetric(metricName: string | undefined): boolean;
18
20
  static isHigherWorseMetric(metricName: string | undefined): boolean;
@@ -4,6 +4,7 @@
4
4
  * Converts raw values like 1048576 bytes → "1 MB", 3661 seconds → "1.02 hr", etc.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
+ const DateLanguage_1 = require("../Types/DateLanguage");
7
8
  const byteUnits = [
8
9
  { threshold: 1e15, unit: "PB", divisor: 1e15 },
9
10
  { threshold: 1e12, unit: "TB", divisor: 1e12 },
@@ -363,6 +364,107 @@ function formatPercent(value) {
363
364
  }
364
365
  return value.toFixed(2);
365
366
  }
367
+ /*
368
+ * THE NUMBER IN THE READER'S LANGUAGE (#7094).
369
+ *
370
+ * The formatter writes its numbers the way English does - "73.40", "1.5K" -
371
+ * and a Gauge or a Value widget drew them so on every board: Latin digits
372
+ * and a point on a Persian one, beside an SLO tile that wrote "۹۹٫۹٪", and
373
+ * "73.4" where German writes "73,4". Given the reader's language, a number
374
+ * keeps exactly the decimals and the scale letter (K, M, B, T, P) it was
375
+ * written with, in that language's digits, decimal sign and minus: "73,40"
376
+ * in German, "۷۳٫۴۰" in Persian, Latin digits in Arabic (getNumberLocale).
377
+ * A percentage takes the language's own percent sign and spacing, as the
378
+ * SLO tiles write theirs: "73,40 %", "۷۳٫۴۰٪". No language, or English,
379
+ * writes every number exactly as before.
380
+ */
381
+ // A number as formatNumber and formatPercent write it: "73.40", "-1.5", "119.25B".
382
+ const WRITTEN_NUMBER = /^(-?\d+)(?:\.(\d+))?([KMBTP]?)$/;
383
+ // What follows a number that sets its unit apart: a space, or a no-break one.
384
+ const STARTS_WITH_SPACE = /^\s/;
385
+ // One Intl format per language, decimals and style: a board writes many numbers.
386
+ const languageNumberFormats = new Map();
387
+ function getLanguageNumberFormat(language, decimals, isPercent) {
388
+ const key = [
389
+ language,
390
+ decimals,
391
+ isPercent ? "percent" : "decimal",
392
+ ].join("|");
393
+ if (!languageNumberFormats.has(key)) {
394
+ let format = null;
395
+ try {
396
+ format = new Intl.NumberFormat((0, DateLanguage_1.getNumberLocale)(language), {
397
+ style: isPercent ? "percent" : "decimal",
398
+ minimumFractionDigits: decimals,
399
+ maximumFractionDigits: decimals,
400
+ });
401
+ }
402
+ catch (_a) {
403
+ format = null;
404
+ }
405
+ languageNumberFormats.set(key, format);
406
+ }
407
+ return languageNumberFormats.get(key) || null;
408
+ }
409
+ /*
410
+ * `text`, a number this formatter wrote in English, written in `language`:
411
+ * the number (with its scale letter), the percent sign when it is a
412
+ * percentage ("" otherwise), and the two as the language joins them. Null
413
+ * where there is nothing to rewrite - English, or a text that is not a
414
+ * number - and the English stands.
415
+ */
416
+ function writeNumberInLanguage(text, isPercent, language) {
417
+ var _a;
418
+ if ((0, DateLanguage_1.isEnglishDateLanguage)(language)) {
419
+ return null;
420
+ }
421
+ const match = WRITTEN_NUMBER.exec(text);
422
+ if (!match) {
423
+ return null;
424
+ }
425
+ const fraction = match[2] || "";
426
+ const scaleLetter = match[3] || "";
427
+ const format = getLanguageNumberFormat((language || "").trim(), fraction.length, isPercent);
428
+ if (!format) {
429
+ return null;
430
+ }
431
+ const number = Number(fraction ? `${match[1]}.${fraction}` : match[1]);
432
+ const parts = format.formatToParts(isPercent ? number / 100 : number);
433
+ /*
434
+ * Everything but the percent sign is the number - a negative's minus and
435
+ * the mark that keeps it before its digits on a page read from the right
436
+ * too - except the space or the marks set beside the sign (German's
437
+ * space, Arabic's marks), which go with the sign.
438
+ */
439
+ const value = parts
440
+ .filter((part, index) => {
441
+ var _a, _b;
442
+ if (part.type === "percentSign") {
443
+ return false;
444
+ }
445
+ return (part.type !== "literal" ||
446
+ (((_a = parts[index - 1]) === null || _a === void 0 ? void 0 : _a.type) !== "percentSign" &&
447
+ ((_b = parts[index + 1]) === null || _b === void 0 ? void 0 : _b.type) !== "percentSign"));
448
+ })
449
+ .map((part) => {
450
+ return part.value;
451
+ })
452
+ .join("");
453
+ const percentSign = ((_a = parts.find((part) => {
454
+ return part.type === "percentSign";
455
+ })) === null || _a === void 0 ? void 0 : _a.value) || "";
456
+ return {
457
+ value: `${value}${scaleLetter}`,
458
+ percentSign: percentSign,
459
+ formatted: isPercent
460
+ ? parts
461
+ .map((part) => {
462
+ return part.value;
463
+ })
464
+ .join("")
465
+ : `${value}${scaleLetter}`,
466
+ };
467
+ }
366
468
  /*
367
469
  * The separator rules formatValue has always used: percent joins with no
368
470
  * space, an empty unit contributes nothing, everything else gets one space.
@@ -400,6 +502,21 @@ function compactThresholdUnit(unit) {
400
502
  function formatValueParts(value, unit, options, unitStyle) {
401
503
  const trimmedUnit = (unit || "").trim();
402
504
  const build = (partValue, partUnit) => {
505
+ // In the reader's language, when one is given (#7094).
506
+ const inLanguage = writeNumberInLanguage(partValue, partUnit === "%", options === null || options === void 0 ? void 0 : options.language);
507
+ if (inLanguage) {
508
+ return partUnit === "%"
509
+ ? {
510
+ value: inLanguage.value,
511
+ unit: inLanguage.percentSign || partUnit,
512
+ formatted: inLanguage.formatted,
513
+ }
514
+ : {
515
+ value: inLanguage.value,
516
+ unit: partUnit,
517
+ formatted: joinValueAndUnit(inLanguage.value, partUnit),
518
+ };
519
+ }
403
520
  return {
404
521
  value: partValue,
405
522
  unit: partUnit,
@@ -477,10 +594,38 @@ class ValueFormatter {
477
594
  * e.g. formatValue(3661, "seconds") → "1.02 hr"
478
595
  * e.g. formatValue(42, "%") → "42%"
479
596
  * e.g. formatValue(0.25, "1", { metricName: "system.cpu.utilization" }) → "25%"
597
+ * e.g. formatValue(73.4, "%", { language: "de" }) → "73,40 %"
480
598
  */
481
599
  static formatValue(value, unit, options) {
482
600
  return formatValueParts(value, unit, options, "readable").formatted;
483
601
  }
602
+ /*
603
+ * formatValue, but returning the number and the unit separately, the unit
604
+ * named as formatValue names it ("hours", "Bytes per Second"). For a
605
+ * widget that draws the two at different sizes, as formatValueCompact is
606
+ * for one that draws the unit's symbol: the Gauge split the joined string
607
+ * at its last space, which put "requests per" in the big-number span and
608
+ * cannot find the number in "73,40 %" or "۷۳٫۴۰٪".
609
+ */
610
+ static formatValueInParts(value, unit, options) {
611
+ return formatValueParts(value, unit, options, "readable");
612
+ }
613
+ /*
614
+ * Whether `parts` set their unit apart from the number - "1.5 MB", and
615
+ * "73,40 %" in German - or write it right after it: "73.40%", "۷۳٫۴۰٪".
616
+ * What a widget that draws the number and the unit in spans of their own
617
+ * leaves between them.
618
+ */
619
+ static isUnitSetApart(parts) {
620
+ if (!parts.unit) {
621
+ return false;
622
+ }
623
+ const valueStart = parts.formatted.indexOf(parts.value);
624
+ if (valueStart < 0) {
625
+ return parts.unit !== "%";
626
+ }
627
+ return STARTS_WITH_SPACE.test(parts.formatted.slice(valueStart + parts.value.length));
628
+ }
484
629
  /*
485
630
  * Compact sibling of getReadableUnit: the unit SYMBOL, for surfaces where
486
631
  * the spelled-out name competes with the value for horizontal space.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oneuptime/common",
3
- "version": "14.0.109",
3
+ "version": "14.0.110",
4
4
  "description": "OneUptime's shared types, utilities and data models, for Node.js and TypeScript.",
5
5
  "homepage": "https://oneuptime.com",
6
6
  "repository": {