@perses-dev/core 0.53.0-beta.4 → 0.53.0-rc.1

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 (249) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +1 -1
  2. package/dist/cjs/constants/index.js +1 -1
  3. package/dist/cjs/index.js +1 -1
  4. package/dist/cjs/model/base-metadata.js +1 -1
  5. package/dist/cjs/model/calculations.js +1 -1
  6. package/dist/cjs/model/dashboard.js +1 -1
  7. package/dist/cjs/model/datasource-api.js +1 -1
  8. package/dist/cjs/model/datasource.js +1 -1
  9. package/dist/cjs/model/definitions.js +1 -1
  10. package/dist/cjs/model/display.js +1 -1
  11. package/dist/cjs/model/ephemeraldashboard.js +1 -1
  12. package/dist/cjs/model/external-variable.js +1 -1
  13. package/dist/cjs/model/http-proxy.js +1 -1
  14. package/dist/cjs/model/http.js +1 -1
  15. package/dist/cjs/model/index.js +1 -1
  16. package/dist/cjs/model/kind.js +1 -1
  17. package/dist/cjs/model/layout.js +1 -1
  18. package/dist/cjs/model/legend.js +1 -1
  19. package/dist/cjs/model/log-data.js +1 -1
  20. package/dist/cjs/model/notice.js +1 -1
  21. package/dist/cjs/model/otlp/common/v1/common.js +1 -1
  22. package/dist/cjs/model/otlp/index.js +1 -1
  23. package/dist/cjs/model/otlp/resource/v1/resource.js +1 -1
  24. package/dist/cjs/model/otlp/trace/v1/trace.js +1 -1
  25. package/dist/cjs/model/panel-group.js +1 -1
  26. package/dist/cjs/model/panels.js +1 -1
  27. package/dist/cjs/model/profile-data.js +1 -1
  28. package/dist/cjs/model/project.js +1 -1
  29. package/dist/cjs/model/query.js +1 -1
  30. package/dist/cjs/model/resource.js +1 -1
  31. package/dist/cjs/model/rolebindings.js +1 -1
  32. package/dist/cjs/model/roles.js +1 -1
  33. package/dist/cjs/model/secrets.js +1 -1
  34. package/dist/cjs/model/thresholds.js +1 -1
  35. package/dist/cjs/model/time-series-data.js +1 -1
  36. package/dist/cjs/model/time-series-queries.js +1 -1
  37. package/dist/cjs/model/time.js +1 -1
  38. package/dist/cjs/model/trace-data.js +1 -1
  39. package/dist/cjs/model/transforms.js +3 -2
  40. package/dist/cjs/model/units/bits.js +1 -1
  41. package/dist/cjs/model/units/bytes.js +1 -1
  42. package/dist/cjs/model/units/constants.js +1 -1
  43. package/dist/cjs/model/units/currency.js +1 -1
  44. package/dist/cjs/model/units/date.js +1 -1
  45. package/dist/cjs/model/units/decimal.js +1 -1
  46. package/dist/cjs/model/units/index.js +1 -1
  47. package/dist/cjs/model/units/percent.js +1 -1
  48. package/dist/cjs/model/units/temperature.js +1 -1
  49. package/dist/cjs/model/units/throughput.js +1 -1
  50. package/dist/cjs/model/units/time.js +1 -1
  51. package/dist/cjs/model/units/types.js +1 -1
  52. package/dist/cjs/model/units/units.js +1 -1
  53. package/dist/cjs/model/units/utils.js +1 -1
  54. package/dist/cjs/model/user.js +1 -1
  55. package/dist/cjs/model/value-mapping.js +1 -1
  56. package/dist/cjs/model/variables.js +1 -1
  57. package/dist/cjs/schema/datasource.js +1 -1
  58. package/dist/cjs/schema/display.js +1 -1
  59. package/dist/cjs/schema/duration.js +1 -1
  60. package/dist/cjs/schema/index.js +1 -1
  61. package/dist/cjs/schema/metadata.js +1 -1
  62. package/dist/cjs/schema/panel.js +4 -6
  63. package/dist/cjs/schema/plugin.js +1 -1
  64. package/dist/cjs/schema/role.js +1 -1
  65. package/dist/cjs/schema/rolebinding.js +1 -1
  66. package/dist/cjs/schema/secret.js +1 -1
  67. package/dist/cjs/schema/user.js +1 -1
  68. package/dist/cjs/schema/variable.js +1 -1
  69. package/dist/cjs/test/setup-tests.js +1 -1
  70. package/dist/cjs/utils/fetch.js +1 -1
  71. package/dist/cjs/utils/index.js +1 -1
  72. package/dist/cjs/utils/is-empty-object.js +1 -1
  73. package/dist/cjs/utils/mathjs.js +1 -1
  74. package/dist/cjs/utils/panel-refs.js +1 -1
  75. package/dist/cjs/utils/regexp.js +1 -1
  76. package/dist/cjs/utils/text.js +1 -1
  77. package/dist/cjs/utils/time-series-data.js +1 -1
  78. package/dist/cjs/utils/transform-data.js +1 -1
  79. package/dist/cjs/utils/types.js +1 -1
  80. package/dist/cjs/utils/value-mapping.js +1 -1
  81. package/dist/constants/dashboard-defaults.js +1 -1
  82. package/dist/constants/dashboard-defaults.js.map +1 -1
  83. package/dist/constants/index.js +1 -1
  84. package/dist/constants/index.js.map +1 -1
  85. package/dist/index.js +1 -1
  86. package/dist/index.js.map +1 -1
  87. package/dist/model/base-metadata.js +1 -1
  88. package/dist/model/base-metadata.js.map +1 -1
  89. package/dist/model/calculations.js +1 -1
  90. package/dist/model/calculations.js.map +1 -1
  91. package/dist/model/dashboard.js +1 -1
  92. package/dist/model/dashboard.js.map +1 -1
  93. package/dist/model/datasource-api.js +1 -1
  94. package/dist/model/datasource-api.js.map +1 -1
  95. package/dist/model/datasource.js +1 -1
  96. package/dist/model/datasource.js.map +1 -1
  97. package/dist/model/definitions.js +1 -1
  98. package/dist/model/definitions.js.map +1 -1
  99. package/dist/model/display.js +1 -1
  100. package/dist/model/display.js.map +1 -1
  101. package/dist/model/ephemeraldashboard.js +1 -1
  102. package/dist/model/ephemeraldashboard.js.map +1 -1
  103. package/dist/model/external-variable.js +1 -1
  104. package/dist/model/external-variable.js.map +1 -1
  105. package/dist/model/http-proxy.js +1 -1
  106. package/dist/model/http-proxy.js.map +1 -1
  107. package/dist/model/http.js +1 -1
  108. package/dist/model/http.js.map +1 -1
  109. package/dist/model/index.js +1 -1
  110. package/dist/model/index.js.map +1 -1
  111. package/dist/model/kind.js +1 -1
  112. package/dist/model/kind.js.map +1 -1
  113. package/dist/model/layout.js +1 -1
  114. package/dist/model/layout.js.map +1 -1
  115. package/dist/model/legend.js +1 -1
  116. package/dist/model/legend.js.map +1 -1
  117. package/dist/model/log-data.js +1 -1
  118. package/dist/model/log-data.js.map +1 -1
  119. package/dist/model/notice.js +1 -1
  120. package/dist/model/notice.js.map +1 -1
  121. package/dist/model/otlp/common/v1/common.d.ts +13 -3
  122. package/dist/model/otlp/common/v1/common.d.ts.map +1 -1
  123. package/dist/model/otlp/common/v1/common.js +1 -1
  124. package/dist/model/otlp/common/v1/common.js.map +1 -1
  125. package/dist/model/otlp/index.js +1 -1
  126. package/dist/model/otlp/index.js.map +1 -1
  127. package/dist/model/otlp/resource/v1/resource.js +1 -1
  128. package/dist/model/otlp/resource/v1/resource.js.map +1 -1
  129. package/dist/model/otlp/trace/v1/trace.d.ts +4 -2
  130. package/dist/model/otlp/trace/v1/trace.d.ts.map +1 -1
  131. package/dist/model/otlp/trace/v1/trace.js +1 -1
  132. package/dist/model/otlp/trace/v1/trace.js.map +1 -1
  133. package/dist/model/panel-group.js +1 -1
  134. package/dist/model/panel-group.js.map +1 -1
  135. package/dist/model/panels.d.ts +2 -2
  136. package/dist/model/panels.d.ts.map +1 -1
  137. package/dist/model/panels.js +1 -1
  138. package/dist/model/panels.js.map +1 -1
  139. package/dist/model/profile-data.js +1 -1
  140. package/dist/model/profile-data.js.map +1 -1
  141. package/dist/model/project.js +1 -1
  142. package/dist/model/project.js.map +1 -1
  143. package/dist/model/query.js +1 -1
  144. package/dist/model/query.js.map +1 -1
  145. package/dist/model/resource.js +1 -1
  146. package/dist/model/resource.js.map +1 -1
  147. package/dist/model/rolebindings.js +1 -1
  148. package/dist/model/rolebindings.js.map +1 -1
  149. package/dist/model/roles.js +1 -1
  150. package/dist/model/roles.js.map +1 -1
  151. package/dist/model/secrets.js +1 -1
  152. package/dist/model/secrets.js.map +1 -1
  153. package/dist/model/thresholds.js +1 -1
  154. package/dist/model/thresholds.js.map +1 -1
  155. package/dist/model/time-series-data.js +1 -1
  156. package/dist/model/time-series-data.js.map +1 -1
  157. package/dist/model/time-series-queries.js +1 -1
  158. package/dist/model/time-series-queries.js.map +1 -1
  159. package/dist/model/time.js +1 -1
  160. package/dist/model/time.js.map +1 -1
  161. package/dist/model/trace-data.js +1 -1
  162. package/dist/model/trace-data.js.map +1 -1
  163. package/dist/model/transforms.d.ts +10 -1
  164. package/dist/model/transforms.d.ts.map +1 -1
  165. package/dist/model/transforms.js +3 -2
  166. package/dist/model/transforms.js.map +1 -1
  167. package/dist/model/units/bits.js +1 -1
  168. package/dist/model/units/bits.js.map +1 -1
  169. package/dist/model/units/bytes.js +1 -1
  170. package/dist/model/units/bytes.js.map +1 -1
  171. package/dist/model/units/constants.js +1 -1
  172. package/dist/model/units/constants.js.map +1 -1
  173. package/dist/model/units/currency.js +1 -1
  174. package/dist/model/units/currency.js.map +1 -1
  175. package/dist/model/units/date.js +1 -1
  176. package/dist/model/units/date.js.map +1 -1
  177. package/dist/model/units/decimal.js +1 -1
  178. package/dist/model/units/decimal.js.map +1 -1
  179. package/dist/model/units/index.js +1 -1
  180. package/dist/model/units/index.js.map +1 -1
  181. package/dist/model/units/percent.js +1 -1
  182. package/dist/model/units/percent.js.map +1 -1
  183. package/dist/model/units/temperature.js +1 -1
  184. package/dist/model/units/temperature.js.map +1 -1
  185. package/dist/model/units/throughput.js +1 -1
  186. package/dist/model/units/throughput.js.map +1 -1
  187. package/dist/model/units/time.js +1 -1
  188. package/dist/model/units/time.js.map +1 -1
  189. package/dist/model/units/types.js +1 -1
  190. package/dist/model/units/types.js.map +1 -1
  191. package/dist/model/units/units.js +1 -1
  192. package/dist/model/units/units.js.map +1 -1
  193. package/dist/model/units/utils.js +1 -1
  194. package/dist/model/units/utils.js.map +1 -1
  195. package/dist/model/user.js +1 -1
  196. package/dist/model/user.js.map +1 -1
  197. package/dist/model/value-mapping.js +1 -1
  198. package/dist/model/value-mapping.js.map +1 -1
  199. package/dist/model/variables.js +1 -1
  200. package/dist/model/variables.js.map +1 -1
  201. package/dist/schema/datasource.js +1 -1
  202. package/dist/schema/datasource.js.map +1 -1
  203. package/dist/schema/display.js +1 -1
  204. package/dist/schema/display.js.map +1 -1
  205. package/dist/schema/duration.js +1 -1
  206. package/dist/schema/duration.js.map +1 -1
  207. package/dist/schema/index.js +1 -1
  208. package/dist/schema/index.js.map +1 -1
  209. package/dist/schema/metadata.js +1 -1
  210. package/dist/schema/metadata.js.map +1 -1
  211. package/dist/schema/panel.js +4 -6
  212. package/dist/schema/panel.js.map +1 -1
  213. package/dist/schema/plugin.js +1 -1
  214. package/dist/schema/plugin.js.map +1 -1
  215. package/dist/schema/role.js +1 -1
  216. package/dist/schema/role.js.map +1 -1
  217. package/dist/schema/rolebinding.js +1 -1
  218. package/dist/schema/rolebinding.js.map +1 -1
  219. package/dist/schema/secret.js +1 -1
  220. package/dist/schema/secret.js.map +1 -1
  221. package/dist/schema/user.js +1 -1
  222. package/dist/schema/user.js.map +1 -1
  223. package/dist/schema/variable.js +1 -1
  224. package/dist/schema/variable.js.map +1 -1
  225. package/dist/test/setup-tests.js +1 -1
  226. package/dist/test/setup-tests.js.map +1 -1
  227. package/dist/utils/fetch.js +1 -1
  228. package/dist/utils/fetch.js.map +1 -1
  229. package/dist/utils/index.js +1 -1
  230. package/dist/utils/index.js.map +1 -1
  231. package/dist/utils/is-empty-object.js +1 -1
  232. package/dist/utils/is-empty-object.js.map +1 -1
  233. package/dist/utils/mathjs.js +1 -1
  234. package/dist/utils/mathjs.js.map +1 -1
  235. package/dist/utils/panel-refs.js +1 -1
  236. package/dist/utils/panel-refs.js.map +1 -1
  237. package/dist/utils/regexp.js +1 -1
  238. package/dist/utils/regexp.js.map +1 -1
  239. package/dist/utils/text.js +1 -1
  240. package/dist/utils/text.js.map +1 -1
  241. package/dist/utils/time-series-data.js +1 -1
  242. package/dist/utils/time-series-data.js.map +1 -1
  243. package/dist/utils/transform-data.js +1 -1
  244. package/dist/utils/transform-data.js.map +1 -1
  245. package/dist/utils/types.js +1 -1
  246. package/dist/utils/types.js.map +1 -1
  247. package/dist/utils/value-mapping.js +1 -1
  248. package/dist/utils/value-mapping.js.map +1 -1
  249. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/currency.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { toUpper } from 'lodash';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\n// See Intl.supportedValuesOf(\"currency\") for valid options, key names will\n// be converted to uppercase to match the expectation of Intl.NumberFormat\ntype CurrencyUnits =\n | 'aud'\n | 'cad'\n | 'chf'\n | 'cny'\n | 'eur'\n | 'gbp'\n | 'hkd'\n | 'inr'\n | 'jpy'\n | 'krw'\n | 'nok'\n | 'nzd'\n | 'sek'\n | 'sgd'\n | 'usd';\nexport type CurrencyFormatOptions = {\n unit: CurrencyUnits;\n decimalPlaces?: number;\n};\n\nconst CURRENCY_GROUP = 'Currency';\nexport const CURRENCY_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Currency',\n decimalPlaces: true,\n};\nexport const CURRENCY_UNIT_CONFIG: Readonly<Record<CurrencyUnits, UnitConfig>> = {\n aud: {\n group: CURRENCY_GROUP,\n label: 'Australian Dollar (A$)',\n },\n cad: {\n group: CURRENCY_GROUP,\n label: 'Canadian Dollar (CA$)',\n },\n chf: {\n group: CURRENCY_GROUP,\n label: 'Swiss Franc (CHF)',\n },\n cny: {\n group: CURRENCY_GROUP,\n label: 'Renminbi (CN¥)',\n },\n eur: {\n group: CURRENCY_GROUP,\n label: 'Euro (€)',\n },\n gbp: {\n group: CURRENCY_GROUP,\n label: 'Pound (£)',\n },\n hkd: {\n group: CURRENCY_GROUP,\n label: 'Hong Kong Dollar (HK$)',\n },\n inr: {\n group: CURRENCY_GROUP,\n label: 'Indian Rupee (₹)',\n },\n jpy: {\n group: CURRENCY_GROUP,\n label: 'Yen (¥)',\n },\n krw: {\n group: CURRENCY_GROUP,\n label: 'South Korean Won (₩)',\n },\n nok: {\n group: CURRENCY_GROUP,\n label: 'Norwegian Krone (NOK)',\n },\n nzd: {\n group: CURRENCY_GROUP,\n label: 'New Zealand Dollar (NZ$)',\n },\n sek: {\n group: CURRENCY_GROUP,\n label: 'Swedish Krona (SEK)',\n },\n sgd: {\n group: CURRENCY_GROUP,\n label: 'Singapore Dollar (S$)',\n },\n usd: {\n group: CURRENCY_GROUP,\n label: 'US Dollar ($)',\n },\n};\n\nexport function formatCurrency(value: number, { unit, decimalPlaces }: CurrencyFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'currency',\n currency: toUpper(unit),\n currencyDisplay: 'symbol',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["toUpper","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","CURRENCY_GROUP","CURRENCY_GROUP_CONFIG","label","decimalPlaces","CURRENCY_UNIT_CONFIG","aud","group","cad","chf","cny","eur","gbp","hkd","inr","jpy","krw","nok","nzd","sek","sgd","usd","formatCurrency","value","unit","formatterOptions","style","currency","currencyDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAA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,mBAAmBI;QAC5DqB,iBAAiBK,qBAAqB,GAAG9B,mBAAmBI;IAC9D,OAAO;QACLqB,iBAAiBM,wBAAwB,GAAGjC;IAC9C;IAEA,MAAMkC,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACZ;AAC1B"}
1
+ {"version":3,"sources":["../../../src/model/units/currency.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { toUpper } from 'lodash';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\n// See Intl.supportedValuesOf(\"currency\") for valid options, key names will\n// be converted to uppercase to match the expectation of Intl.NumberFormat\ntype CurrencyUnits =\n | 'aud'\n | 'cad'\n | 'chf'\n | 'cny'\n | 'eur'\n | 'gbp'\n | 'hkd'\n | 'inr'\n | 'jpy'\n | 'krw'\n | 'nok'\n | 'nzd'\n | 'sek'\n | 'sgd'\n | 'usd';\nexport type CurrencyFormatOptions = {\n unit: CurrencyUnits;\n decimalPlaces?: number;\n};\n\nconst CURRENCY_GROUP = 'Currency';\nexport const CURRENCY_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Currency',\n decimalPlaces: true,\n};\nexport const CURRENCY_UNIT_CONFIG: Readonly<Record<CurrencyUnits, UnitConfig>> = {\n aud: {\n group: CURRENCY_GROUP,\n label: 'Australian Dollar (A$)',\n },\n cad: {\n group: CURRENCY_GROUP,\n label: 'Canadian Dollar (CA$)',\n },\n chf: {\n group: CURRENCY_GROUP,\n label: 'Swiss Franc (CHF)',\n },\n cny: {\n group: CURRENCY_GROUP,\n label: 'Renminbi (CN¥)',\n },\n eur: {\n group: CURRENCY_GROUP,\n label: 'Euro (€)',\n },\n gbp: {\n group: CURRENCY_GROUP,\n label: 'Pound (£)',\n },\n hkd: {\n group: CURRENCY_GROUP,\n label: 'Hong Kong Dollar (HK$)',\n },\n inr: {\n group: CURRENCY_GROUP,\n label: 'Indian Rupee (₹)',\n },\n jpy: {\n group: CURRENCY_GROUP,\n label: 'Yen (¥)',\n },\n krw: {\n group: CURRENCY_GROUP,\n label: 'South Korean Won (₩)',\n },\n nok: {\n group: CURRENCY_GROUP,\n label: 'Norwegian Krone (NOK)',\n },\n nzd: {\n group: CURRENCY_GROUP,\n label: 'New Zealand Dollar (NZ$)',\n },\n sek: {\n group: CURRENCY_GROUP,\n label: 'Swedish Krona (SEK)',\n },\n sgd: {\n group: CURRENCY_GROUP,\n label: 'Singapore Dollar (S$)',\n },\n usd: {\n group: CURRENCY_GROUP,\n label: 'US Dollar ($)',\n },\n};\n\nexport function formatCurrency(value: number, { unit, decimalPlaces }: CurrencyFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'currency',\n currency: toUpper(unit),\n currencyDisplay: 'symbol',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["toUpper","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","CURRENCY_GROUP","CURRENCY_GROUP_CONFIG","label","decimalPlaces","CURRENCY_UNIT_CONFIG","aud","group","cad","chf","cny","eur","gbp","hkd","inr","jpy","krw","nok","nzd","sek","sgd","usd","formatCurrency","value","unit","formatterOptions","style","currency","currencyDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,OAAO,QAAQ,SAAS;AACjC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAyB/D,MAAMC,iBAAiB;AACvB,OAAO,MAAMC,wBAAyC;IACpDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,OAAO,MAAMC,uBAAoE;IAC/EC,KAAK;QACHC,OAAON;QACPE,OAAO;IACT;IACAK,KAAK;QACHD,OAAON;QACPE,OAAO;IACT;IACAM,KAAK;QACHF,OAAON;QACPE,OAAO;IACT;IACAO,KAAK;QACHH,OAAON;QACPE,OAAO;IACT;IACAQ,KAAK;QACHJ,OAAON;QACPE,OAAO;IACT;IACAS,KAAK;QACHL,OAAON;QACPE,OAAO;IACT;IACAU,KAAK;QACHN,OAAON;QACPE,OAAO;IACT;IACAW,KAAK;QACHP,OAAON;QACPE,OAAO;IACT;IACAY,KAAK;QACHR,OAAON;QACPE,OAAO;IACT;IACAa,KAAK;QACHT,OAAON;QACPE,OAAO;IACT;IACAc,KAAK;QACHV,OAAON;QACPE,OAAO;IACT;IACAe,KAAK;QACHX,OAAON;QACPE,OAAO;IACT;IACAgB,KAAK;QACHZ,OAAON;QACPE,OAAO;IACT;IACAiB,KAAK;QACHb,OAAON;QACPE,OAAO;IACT;IACAkB,KAAK;QACHd,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASmB,eAAeC,KAAa,EAAE,EAAEC,IAAI,EAAEpB,aAAa,EAAyB;IAC1F,MAAMqB,mBAA6C;QACjDC,OAAO;QACPC,UAAU9B,QAAQ2B;QAClBI,iBAAiB;IACnB;IAEA,IAAI7B,iBAAiBK,gBAAgB;QACnCqB,iBAAiBI,qBAAqB,GAAG7B,mBAAmBI;QAC5DqB,iBAAiBK,qBAAqB,GAAG9B,mBAAmBI;IAC9D,OAAO;QACLqB,iBAAiBM,wBAAwB,GAAGjC;IAC9C;IAEA,MAAMkC,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACZ;AAC1B"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/date.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnitGroupConfig, UnitConfig } from './types';\n\ntype DateUnits =\n | 'datetime-iso'\n | 'datetime-us'\n | 'datetime-local'\n | 'date-iso'\n | 'date-us'\n | 'date-local'\n | 'time-local'\n | 'time-iso'\n | 'time-us'\n | 'relative-time'\n | 'unix-timestamp'\n | 'unix-timestamp-ms';\n\nexport type DateFormatOptions = {\n unit?: DateUnits;\n /**\n * The locale to use for formatting. Defaults to the system's locale.\n */\n locale?: string;\n /**\n * The timezone to use for formatting. Defaults to the user's local timezone.\n */\n timeZone?: string;\n /**\n * For relative time formatting, the reference time to compare against.\n * Defaults to current time.\n */\n referenceTime?: number;\n /**\n * This property is not used for date formatting, but is included for\n * compatibility with the FormatControls UI component.\n */\n decimalPlaces?: number;\n};\n\nconst DATE_GROUP = 'Date';\n\nexport const DATE_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Date & Time',\n};\n\nexport const DATE_UNIT_CONFIG: Readonly<Record<DateUnits, UnitConfig>> = {\n 'datetime-iso': {\n group: DATE_GROUP,\n label: 'DateTime (GMT)',\n },\n 'datetime-us': {\n group: DATE_GROUP,\n label: 'DateTime (US-East)',\n },\n 'datetime-local': {\n group: DATE_GROUP,\n label: 'DateTime (Browser Local)',\n },\n 'date-iso': {\n group: DATE_GROUP,\n label: 'Date (GMT)',\n },\n 'date-us': {\n group: DATE_GROUP,\n label: 'Date (US-East)',\n },\n 'date-local': {\n group: DATE_GROUP,\n label: 'Date (Browser Local)',\n },\n 'time-local': {\n group: DATE_GROUP,\n label: 'Time (Browser Local)',\n },\n 'time-iso': {\n group: DATE_GROUP,\n label: 'Time (GMT)',\n },\n 'time-us': {\n group: DATE_GROUP,\n label: 'Time (US-East)',\n },\n 'relative-time': {\n group: DATE_GROUP,\n label: 'Relative Time',\n },\n 'unix-timestamp': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (s)',\n },\n 'unix-timestamp-ms': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (ms)',\n },\n};\n\n/**\n * Converts a numeric value to a Date object.\n * Handles both Unix timestamps (seconds) and millisecond timestamps.\n */\nfunction valueToDate(value: number): Date {\n // Timestamp detection logic with special case handling\n // Main threshold stays at 10 billion to maintain existing behavior\n // Handle special edge cases explicitly\n\n // Special case: negative timestamps\n if (value < 0) {\n // For negative values, check magnitude to distinguish seconds vs milliseconds\n // Large negative values (> 1 billion in magnitude) are likely milliseconds\n // Small negative values are likely seconds (rare edge case)\n if (Math.abs(value) > 10000000000) {\n return new Date(value); // milliseconds\n } else {\n return new Date(value * 1000); // seconds\n }\n }\n\n // Special case: year 9999 in seconds (~253402300799)\n // This is a very specific edge case for far-future timestamps\n if (value >= 250000000000 && value <= 260000000000) {\n // Check if this looks like year 9999 in seconds\n const asSeconds = new Date(value * 1000);\n const year = asSeconds.getUTCFullYear();\n if (year >= 9999) {\n return asSeconds; // seconds\n }\n }\n\n const SECONDS_THRESHOLD = 10000000000; // ~year 2286 - original threshold\n\n if (value < SECONDS_THRESHOLD) {\n // Assume it's in seconds\n return new Date(value * 1000);\n } else {\n // Assume it's in milliseconds\n return new Date(value);\n }\n}\n\n/**\n * Formats a relative time string using the Intl.RelativeTimeFormat API.\n */\nfunction formatRelativeTime(date: Date, referenceTime: number, locale: string): string {\n const referenceDate = new Date(referenceTime);\n const diffMs = date.getTime() - referenceDate.getTime();\n\n const units = [\n { unit: 'year', ms: 1000 * 60 * 60 * 24 * 365 },\n { unit: 'month', ms: 1000 * 60 * 60 * 24 * 30 },\n { unit: 'week', ms: 1000 * 60 * 60 * 24 * 7 },\n { unit: 'day', ms: 1000 * 60 * 60 * 24 },\n { unit: 'hour', ms: 1000 * 60 * 60 },\n { unit: 'minute', ms: 1000 * 60 },\n { unit: 'second', ms: 1000 },\n ] as const;\n\n for (const { unit, ms } of units) {\n // Determine the value for the current unit, ensuring it's an integer for Intl.RelativeTimeFormat\n const value = Math.round(diffMs / ms);\n // If the absolute value is 1 or more, use this unit\n if (Math.abs(value) >= 1) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(value, unit);\n }\n }\n\n // If less than a second, show \"now\" or \"0 seconds\"\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(0, 'second');\n}\n\n/**\n * Gets the browser's preferred locale with comprehensive fallbacks.\n */\nconst getBrowserLocale = (): string => {\n if (typeof navigator !== 'undefined') {\n if (navigator.language) return navigator.language;\n if (navigator.languages && navigator.languages.length > 0) {\n const firstLanguage = navigator.languages[0];\n if (firstLanguage) return firstLanguage;\n }\n // Legacy fallbacks for older browsers\n const nav = navigator as Navigator & {\n userLanguage?: string;\n browserLanguage?: string;\n systemLanguage?: string;\n };\n if (nav.userLanguage) return nav.userLanguage;\n if (nav.browserLanguage) return nav.browserLanguage;\n if (nav.systemLanguage) return nav.systemLanguage;\n }\n // Node.js or server-side fallback, or if navigator is not available/empty\n return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US';\n};\n\nexport function formatDate(value: number, options: DateFormatOptions = {}): string {\n const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n const {\n unit = 'datetime-local',\n locale = getBrowserLocale(),\n timeZone = systemTimeZone,\n referenceTime = Date.now(),\n } = options;\n\n // Handle raw timestamp display\n if (unit === 'unix-timestamp') {\n // Ensure it's in seconds. If it looks like milliseconds, convert.\n const timestamp = value > 1000000000000 ? Math.floor(value / 1000) : value;\n return timestamp.toString();\n }\n\n if (unit === 'unix-timestamp-ms') {\n // Ensure it's in milliseconds. If it looks like seconds, convert.\n // Use 100 billion as threshold - values < 100B are likely seconds, >= 100B are likely milliseconds\n // This distinguishes between 999999999 (seconds) and 999999999000 (milliseconds)\n const MILLISECONDS_THRESHOLD = 100000000000; // 100 billion\n const timestamp = value < MILLISECONDS_THRESHOLD ? value * 1000 : value;\n return Math.floor(timestamp).toString();\n }\n\n const date = valueToDate(value);\n\n // Handle relative time\n if (unit === 'relative-time') {\n return formatRelativeTime(date, referenceTime, locale);\n }\n\n // Configure Intl.DateTimeFormat options based on unit\n const formatOptions: Intl.DateTimeFormatOptions = {\n timeZone, // This will be overridden for specific units that need different timezones\n };\n\n switch (unit) {\n case 'datetime-iso':\n // datetime-iso should ALWAYS show GMT/UTC time\n return date.toISOString();\n\n case 'datetime-us': {\n // datetime-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true; // 12-hour format with AM/PM\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'datetime-local':\n // datetime-local should use the browser's local timezone (detected automatically)\n // Don't override timeZone - let it use the detected system timezone\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'date-iso':\n // date-iso should ALWAYS show GMT/UTC date\n return date.toISOString().split('T')[0]!;\n\n case 'date-us': {\n // date-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'date-local':\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n break;\n\n case 'time-local':\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'time-iso':\n // time-iso should ALWAYS show GMT/UTC time\n return date.toISOString().split('T')[1]!.replace('Z', '');\n\n case 'time-us': {\n // time-us should show time in US-East timezone (Eastern Time)\n formatOptions.timeZone = 'America/New_York';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true;\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n }\n\n default: {\n // This ensures that all DateUnits are handled at compile time.\n const exhaustive: never = unit;\n throw new Error(`Unknown date unit: ${exhaustive}`);\n }\n }\n\n // For all other units, use Intl.DateTimeFormat with the specified locale and options\n const formatter = new Intl.DateTimeFormat(locale, formatOptions);\n return formatter.format(date);\n}\n"],"names":["DATE_GROUP","DATE_GROUP_CONFIG","label","DATE_UNIT_CONFIG","group","valueToDate","value","Math","abs","Date","asSeconds","year","getUTCFullYear","SECONDS_THRESHOLD","formatRelativeTime","date","referenceTime","locale","referenceDate","diffMs","getTime","units","unit","ms","round","rtf","Intl","RelativeTimeFormat","numeric","format","getBrowserLocale","navigator","language","languages","length","firstLanguage","nav","userLanguage","browserLanguage","systemLanguage","DateTimeFormat","resolvedOptions","formatDate","options","systemTimeZone","timeZone","now","timestamp","floor","toString","MILLISECONDS_THRESHOLD","formatOptions","toISOString","month","day","hour","minute","second","hour12","formatter","split","replace","exhaustive","Error"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAwCjC,MAAMA,aAAa;AAEnB,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;AACT,EAAE;AAEF,OAAO,MAAMC,mBAA4D;IACvE,gBAAgB;QACdC,OAAOJ;QACPE,OAAO;IACT;IACA,eAAe;QACbE,OAAOJ;QACPE,OAAO;IACT;IACA,kBAAkB;QAChBE,OAAOJ;QACPE,OAAO;IACT;IACA,YAAY;QACVE,OAAOJ;QACPE,OAAO;IACT;IACA,WAAW;QACTE,OAAOJ;QACPE,OAAO;IACT;IACA,cAAc;QACZE,OAAOJ;QACPE,OAAO;IACT;IACA,cAAc;QACZE,OAAOJ;QACPE,OAAO;IACT;IACA,YAAY;QACVE,OAAOJ;QACPE,OAAO;IACT;IACA,WAAW;QACTE,OAAOJ;QACPE,OAAO;IACT;IACA,iBAAiB;QACfE,OAAOJ;QACPE,OAAO;IACT;IACA,kBAAkB;QAChBE,OAAOJ;QACPE,OAAO;IACT;IACA,qBAAqB;QACnBE,OAAOJ;QACPE,OAAO;IACT;AACF,EAAE;AAEF;;;CAGC,GACD,SAASG,YAAYC,KAAa;IAChC,uDAAuD;IACvD,mEAAmE;IACnE,uCAAuC;IAEvC,oCAAoC;IACpC,IAAIA,QAAQ,GAAG;QACb,8EAA8E;QAC9E,2EAA2E;QAC3E,4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GQ,KAAK,CAAC,IAAI,CAAC,EAAE;QAEzC,KAAK;YAAW;gBACd,yDAAyD;gBACzDT,cAAcN,QAAQ,GAAG;gBACzBM,cAAcxC,IAAI,GAAG;gBACrBwC,cAAcE,KAAK,GAAG;gBACtBF,cAAcG,GAAG,GAAG;gBACpB,MAAMK,YAAY,IAAIjC,KAAKc,cAAc,CAAC,SAASW;gBACnD,OAAOQ,UAAU9B,MAAM,CAACd;YAC1B;QAEA,KAAK;YACHoC,cAAcxC,IAAI,GAAG;YACrBwC,cAAcE,KAAK,GAAG;YACtBF,cAAcG,GAAG,GAAG;YACpB;QAEF,KAAK;YACHH,cAAcI,IAAI,GAAG;YACrBJ,cAAcK,MAAM,GAAG;YACvBL,cAAcM,MAAM,GAAG;YACvBN,cAAcO,MAAM,GAAG,OAAO,iBAAiB;YAC/C;QAEF,KAAK;YACH,2CAA2C;YAC3C,OAAO3C,KAAKqC,WAAW,GAAGQ,KAAK,CAAC,IAAI,CAAC,EAAE,CAAEC,OAAO,CAAC,KAAK;QAExD,KAAK;YAAW;gBACd,8DAA8D;gBAC9DV,cAAcN,QAAQ,GAAG;gBACzBM,cAAcI,IAAI,GAAG;gBACrBJ,cAAcK,MAAM,GAAG;gBACvBL,cAAcM,MAAM,GAAG;gBACvBN,cAAcO,MAAM,GAAG;gBACvB,OAAO,IAAIhC,KAAKc,cAAc,CAAC,SAASW,eAAetB,MAAM,CAACd;YAChE;QAEA;YAAS;gBACP,+DAA+D;gBAC/D,MAAM+C,aAAoBxC;gBAC1B,MAAM,IAAIyC,MAAM,CAAC,mBAAmB,EAAED,YAAY;YACpD;IACF;IAEA,qFAAqF;IACrF,MAAMH,YAAY,IAAIjC,KAAKc,cAAc,CAACvB,QAAQkC;IAClD,OAAOQ,UAAU9B,MAAM,CAACd;AAC1B"}
1
+ {"version":3,"sources":["../../../src/model/units/date.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { UnitGroupConfig, UnitConfig } from './types';\n\ntype DateUnits =\n | 'datetime-iso'\n | 'datetime-us'\n | 'datetime-local'\n | 'date-iso'\n | 'date-us'\n | 'date-local'\n | 'time-local'\n | 'time-iso'\n | 'time-us'\n | 'relative-time'\n | 'unix-timestamp'\n | 'unix-timestamp-ms';\n\nexport type DateFormatOptions = {\n unit?: DateUnits;\n /**\n * The locale to use for formatting. Defaults to the system's locale.\n */\n locale?: string;\n /**\n * The timezone to use for formatting. Defaults to the user's local timezone.\n */\n timeZone?: string;\n /**\n * For relative time formatting, the reference time to compare against.\n * Defaults to current time.\n */\n referenceTime?: number;\n /**\n * This property is not used for date formatting, but is included for\n * compatibility with the FormatControls UI component.\n */\n decimalPlaces?: number;\n};\n\nconst DATE_GROUP = 'Date';\n\nexport const DATE_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Date & Time',\n};\n\nexport const DATE_UNIT_CONFIG: Readonly<Record<DateUnits, UnitConfig>> = {\n 'datetime-iso': {\n group: DATE_GROUP,\n label: 'DateTime (GMT)',\n },\n 'datetime-us': {\n group: DATE_GROUP,\n label: 'DateTime (US-East)',\n },\n 'datetime-local': {\n group: DATE_GROUP,\n label: 'DateTime (Browser Local)',\n },\n 'date-iso': {\n group: DATE_GROUP,\n label: 'Date (GMT)',\n },\n 'date-us': {\n group: DATE_GROUP,\n label: 'Date (US-East)',\n },\n 'date-local': {\n group: DATE_GROUP,\n label: 'Date (Browser Local)',\n },\n 'time-local': {\n group: DATE_GROUP,\n label: 'Time (Browser Local)',\n },\n 'time-iso': {\n group: DATE_GROUP,\n label: 'Time (GMT)',\n },\n 'time-us': {\n group: DATE_GROUP,\n label: 'Time (US-East)',\n },\n 'relative-time': {\n group: DATE_GROUP,\n label: 'Relative Time',\n },\n 'unix-timestamp': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (s)',\n },\n 'unix-timestamp-ms': {\n group: DATE_GROUP,\n label: 'Unix Timestamp (ms)',\n },\n};\n\n/**\n * Converts a numeric value to a Date object.\n * Handles both Unix timestamps (seconds) and millisecond timestamps.\n */\nfunction valueToDate(value: number): Date {\n // Timestamp detection logic with special case handling\n // Main threshold stays at 10 billion to maintain existing behavior\n // Handle special edge cases explicitly\n\n // Special case: negative timestamps\n if (value < 0) {\n // For negative values, check magnitude to distinguish seconds vs milliseconds\n // Large negative values (> 1 billion in magnitude) are likely milliseconds\n // Small negative values are likely seconds (rare edge case)\n if (Math.abs(value) > 10000000000) {\n return new Date(value); // milliseconds\n } else {\n return new Date(value * 1000); // seconds\n }\n }\n\n // Special case: year 9999 in seconds (~253402300799)\n // This is a very specific edge case for far-future timestamps\n if (value >= 250000000000 && value <= 260000000000) {\n // Check if this looks like year 9999 in seconds\n const asSeconds = new Date(value * 1000);\n const year = asSeconds.getUTCFullYear();\n if (year >= 9999) {\n return asSeconds; // seconds\n }\n }\n\n const SECONDS_THRESHOLD = 10000000000; // ~year 2286 - original threshold\n\n if (value < SECONDS_THRESHOLD) {\n // Assume it's in seconds\n return new Date(value * 1000);\n } else {\n // Assume it's in milliseconds\n return new Date(value);\n }\n}\n\n/**\n * Formats a relative time string using the Intl.RelativeTimeFormat API.\n */\nfunction formatRelativeTime(date: Date, referenceTime: number, locale: string): string {\n const referenceDate = new Date(referenceTime);\n const diffMs = date.getTime() - referenceDate.getTime();\n\n const units = [\n { unit: 'year', ms: 1000 * 60 * 60 * 24 * 365 },\n { unit: 'month', ms: 1000 * 60 * 60 * 24 * 30 },\n { unit: 'week', ms: 1000 * 60 * 60 * 24 * 7 },\n { unit: 'day', ms: 1000 * 60 * 60 * 24 },\n { unit: 'hour', ms: 1000 * 60 * 60 },\n { unit: 'minute', ms: 1000 * 60 },\n { unit: 'second', ms: 1000 },\n ] as const;\n\n for (const { unit, ms } of units) {\n // Determine the value for the current unit, ensuring it's an integer for Intl.RelativeTimeFormat\n const value = Math.round(diffMs / ms);\n // If the absolute value is 1 or more, use this unit\n if (Math.abs(value) >= 1) {\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(value, unit);\n }\n }\n\n // If less than a second, show \"now\" or \"0 seconds\"\n const rtf = new Intl.RelativeTimeFormat(locale, { numeric: 'auto' });\n return rtf.format(0, 'second');\n}\n\n/**\n * Gets the browser's preferred locale with comprehensive fallbacks.\n */\nconst getBrowserLocale = (): string => {\n if (typeof navigator !== 'undefined') {\n if (navigator.language) return navigator.language;\n if (navigator.languages && navigator.languages.length > 0) {\n const firstLanguage = navigator.languages[0];\n if (firstLanguage) return firstLanguage;\n }\n // Legacy fallbacks for older browsers\n const nav = navigator as Navigator & {\n userLanguage?: string;\n browserLanguage?: string;\n systemLanguage?: string;\n };\n if (nav.userLanguage) return nav.userLanguage;\n if (nav.browserLanguage) return nav.browserLanguage;\n if (nav.systemLanguage) return nav.systemLanguage;\n }\n // Node.js or server-side fallback, or if navigator is not available/empty\n return Intl.DateTimeFormat().resolvedOptions().locale || 'en-US';\n};\n\nexport function formatDate(value: number, options: DateFormatOptions = {}): string {\n const systemTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;\n\n const {\n unit = 'datetime-local',\n locale = getBrowserLocale(),\n timeZone = systemTimeZone,\n referenceTime = Date.now(),\n } = options;\n\n // Handle raw timestamp display\n if (unit === 'unix-timestamp') {\n // Ensure it's in seconds. If it looks like milliseconds, convert.\n const timestamp = value > 1000000000000 ? Math.floor(value / 1000) : value;\n return timestamp.toString();\n }\n\n if (unit === 'unix-timestamp-ms') {\n // Ensure it's in milliseconds. If it looks like seconds, convert.\n // Use 100 billion as threshold - values < 100B are likely seconds, >= 100B are likely milliseconds\n // This distinguishes between 999999999 (seconds) and 999999999000 (milliseconds)\n const MILLISECONDS_THRESHOLD = 100000000000; // 100 billion\n const timestamp = value < MILLISECONDS_THRESHOLD ? value * 1000 : value;\n return Math.floor(timestamp).toString();\n }\n\n const date = valueToDate(value);\n\n // Handle relative time\n if (unit === 'relative-time') {\n return formatRelativeTime(date, referenceTime, locale);\n }\n\n // Configure Intl.DateTimeFormat options based on unit\n const formatOptions: Intl.DateTimeFormatOptions = {\n timeZone, // This will be overridden for specific units that need different timezones\n };\n\n switch (unit) {\n case 'datetime-iso':\n // datetime-iso should ALWAYS show GMT/UTC time\n return date.toISOString();\n\n case 'datetime-us': {\n // datetime-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true; // 12-hour format with AM/PM\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'datetime-local':\n // datetime-local should use the browser's local timezone (detected automatically)\n // Don't override timeZone - let it use the detected system timezone\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'date-iso':\n // date-iso should ALWAYS show GMT/UTC date\n return date.toISOString().split('T')[0]!;\n\n case 'date-us': {\n // date-us should ALWAYS show date in US Eastern timezone\n formatOptions.timeZone = 'America/New_York';\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n const formatter = new Intl.DateTimeFormat('en-US', formatOptions);\n return formatter.format(date);\n }\n\n case 'date-local':\n formatOptions.year = 'numeric';\n formatOptions.month = '2-digit';\n formatOptions.day = '2-digit';\n break;\n\n case 'time-local':\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = false; // 24-hour format\n break;\n\n case 'time-iso':\n // time-iso should ALWAYS show GMT/UTC time\n return date.toISOString().split('T')[1]!.replace('Z', '');\n\n case 'time-us': {\n // time-us should show time in US-East timezone (Eastern Time)\n formatOptions.timeZone = 'America/New_York';\n formatOptions.hour = '2-digit';\n formatOptions.minute = '2-digit';\n formatOptions.second = '2-digit';\n formatOptions.hour12 = true;\n return new Intl.DateTimeFormat('en-US', formatOptions).format(date);\n }\n\n default: {\n // This ensures that all DateUnits are handled at compile time.\n const exhaustive: never = unit;\n throw new Error(`Unknown date unit: ${exhaustive}`);\n }\n }\n\n // For all other units, use Intl.DateTimeFormat with the specified locale and options\n const formatter = new Intl.DateTimeFormat(locale, formatOptions);\n return formatter.format(date);\n}\n"],"names":["DATE_GROUP","DATE_GROUP_CONFIG","label","DATE_UNIT_CONFIG","group","valueToDate","value","Math","abs","Date","asSeconds","year","getUTCFullYear","SECONDS_THRESHOLD","formatRelativeTime","date","referenceTime","locale","referenceDate","diffMs","getTime","units","unit","ms","round","rtf","Intl","RelativeTimeFormat","numeric","format","getBrowserLocale","navigator","language","languages","length","firstLanguage","nav","userLanguage","browserLanguage","systemLanguage","DateTimeFormat","resolvedOptions","formatDate","options","systemTimeZone","timeZone","now","timestamp","floor","toString","MILLISECONDS_THRESHOLD","formatOptions","toISOString","month","day","hour","minute","second","hour12","formatter","split","replace","exhaustive","Error"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAwCjC,MAAMA,aAAa;AAEnB,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;AACT,EAAE;AAEF,OAAO,MAAMC,mBAA4D;IACvE,gBAAgB;QACdC,OAAOJ;QACPE,OAAO;IACT;IACA,eAAe;QACbE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I,CAAC,EAAE,CAAEC,OAAO,CAAC,KAAK;QAExD,KAAK;YAAW;gBACd,8DAA8D;gBAC9DV,cAAcN,QAAQ,GAAG;gBACzBM,cAAcI,IAAI,GAAG;gBACrBJ,cAAcK,MAAM,GAAG;gBACvBL,cAAcM,MAAM,GAAG;gBACvBN,cAAcO,MAAM,GAAG;gBACvB,OAAO,IAAIhC,KAAKc,cAAc,CAAC,SAASW,eAAetB,MAAM,CAACd;YAChE;QAEA;YAAS;gBACP,+DAA+D;gBAC/D,MAAM+C,aAAoBxC;gBAC1B,MAAM,IAAIyC,MAAM,CAAC,mBAAmB,EAAED,YAAY;YACpD;IACF;IAEA,qFAAqF;IACrF,MAAMH,YAAY,IAAIjC,KAAKc,cAAc,CAACvB,QAAQkC;IAClD,OAAOQ,UAAU9B,MAAM,CAACd;AAC1B"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/decimal.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype DecimalUnit = 'decimal';\nexport type DecimalFormatOptions = {\n unit?: DecimalUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const DECIMAL_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Decimal',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const DECIMAL_UNIT_CONFIG: Readonly<Record<DecimalUnit, UnitConfig>> = {\n decimal: {\n group: 'Decimal',\n label: 'Decimal',\n },\n};\n\nexport function formatDecimal(value: number, { shortValues, decimalPlaces }: DecimalFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DECIMAL_GROUP_CONFIG","label","decimalPlaces","shortValues","DECIMAL_UNIT_CONFIG","decimal","group","formatDecimal","value","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAQpF,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASM,cAAcC,KAAa,EAAE,EAAEL,WAAW,EAAED,aAAa,EAAwB;IAC/F,MAAMO,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIZ,oBAAoBI,cAAc;QACpCM,iBAAiBG,QAAQ,GAAG;IAC9B;IAEA,IAAIf,iBAAiBK,gBAAgB;QACnCO,iBAAiBI,qBAAqB,GAAGf,mBAAmBI;QAC5DO,iBAAiBK,qBAAqB,GAAGhB,mBAAmBI;IAC9D,OAAO;QACL,IAAIH,oBAAoBI,cAAc;YACpCM,iBAAiBM,wBAAwB,GAAGnB;QAC9C;IACF;IAEA,MAAMoB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACX;AAC1B"}
1
+ {"version":3,"sources":["../../../src/model/units/decimal.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype DecimalUnit = 'decimal';\nexport type DecimalFormatOptions = {\n unit?: DecimalUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const DECIMAL_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Decimal',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const DECIMAL_UNIT_CONFIG: Readonly<Record<DecimalUnit, UnitConfig>> = {\n decimal: {\n group: 'Decimal',\n label: 'Decimal',\n },\n};\n\nexport function formatDecimal(value: number, { shortValues, decimalPlaces }: DecimalFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DECIMAL_GROUP_CONFIG","label","decimalPlaces","shortValues","DECIMAL_UNIT_CONFIG","decimal","group","formatDecimal","value","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAQpF,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASM,cAAcC,KAAa,EAAE,EAAEL,WAAW,EAAED,aAAa,EAAwB;IAC/F,MAAMO,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIZ,oBAAoBI,cAAc;QACpCM,iBAAiBG,QAAQ,GAAG;IAC9B;IAEA,IAAIf,iBAAiBK,gBAAgB;QACnCO,iBAAiBI,qBAAqB,GAAGf,mBAAmBI;QAC5DO,iBAAiBK,qBAAqB,GAAGhB,mBAAmBI;IAC9D,OAAO;QACL,IAAIH,oBAAoBI,cAAc;YACpCM,iBAAiBM,wBAAwB,GAAGnB;QAC9C;IACF;IAEA,MAAMoB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAACX;AAC1B"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './utils';\nexport * from './units';\nexport * from './constants';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,cAAc;AAC5B,cAAc,UAAU"}
1
+ {"version":3,"sources":["../../../src/model/units/index.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './utils';\nexport * from './units';\nexport * from './constants';\nexport * from './types';\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,cAAc;AAC5B,cAAc,UAAU"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/percent.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype PercentUnit = 'percent' | 'percent-decimal' | '%';\nexport type PercentFormatOptions = {\n unit?: PercentUnit;\n decimalPlaces?: number;\n};\nexport const PERCENT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'percent',\n decimalPlaces: true,\n};\nconst PERCENT_GROUP = 'Percent';\nexport const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnit, UnitConfig>> = {\n percent: {\n group: PERCENT_GROUP,\n label: 'Percent (0-100)',\n },\n 'percent-decimal': {\n group: PERCENT_GROUP,\n label: 'Percent (0.0-1.0)',\n },\n '%': {\n // This option is not shown in the selector because it is a shorthand\n // duplicate of `Percent`.\n disableSelectorOption: true,\n group: PERCENT_GROUP,\n label: '%',\n },\n};\n\nexport function formatPercent(value: number, { unit, decimalPlaces }: PercentFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'percent',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.\n if (unit === 'percent') {\n value = value / 100;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","PERCENT_GROUP_CONFIG","label","decimalPlaces","PERCENT_GROUP","PERCENT_UNIT_CONFIG","percent","group","disableSelectorOption","formatPercent","value","unit","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAO/D,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,gBAAgB;AACtB,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAOH;QACPF,OAAO;IACT;IACA,mBAAmB;QACjBK,OAAOH;QACPF,OAAO;IACT;IACA,KAAK;QACH,qEAAqE;QACrE,0BAA0B;QAC1BM,uBAAuB;QACvBD,OAAOH;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,cAAcC,KAAa,EAAE,EAAEC,IAAI,EAAER,aAAa,EAAwB;IACxF,MAAMS,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIf,iBAAiBI,gBAAgB;QACnCS,iBAAiBG,qBAAqB,GAAGf,mBAAmBG;QAC5DS,iBAAiBI,qBAAqB,GAAGhB,mBAAmBG;IAC9D,OAAO;QACLS,iBAAiBK,wBAAwB,GAAGnB;IAC9C;IAEA,oEAAoE;IACpE,IAAIa,SAAS,WAAW;QACtBD,QAAQA,QAAQ;IAClB;IAEA,MAAMQ,YAAYC,KAAKC,YAAY,CAAC,SAASR;IAC7C,OAAOM,UAAUG,MAAM,CAACX;AAC1B"}
1
+ {"version":3,"sources":["../../../src/model/units/percent.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype PercentUnit = 'percent' | 'percent-decimal' | '%';\nexport type PercentFormatOptions = {\n unit?: PercentUnit;\n decimalPlaces?: number;\n};\nexport const PERCENT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'percent',\n decimalPlaces: true,\n};\nconst PERCENT_GROUP = 'Percent';\nexport const PERCENT_UNIT_CONFIG: Readonly<Record<PercentUnit, UnitConfig>> = {\n percent: {\n group: PERCENT_GROUP,\n label: 'Percent (0-100)',\n },\n 'percent-decimal': {\n group: PERCENT_GROUP,\n label: 'Percent (0.0-1.0)',\n },\n '%': {\n // This option is not shown in the selector because it is a shorthand\n // duplicate of `Percent`.\n disableSelectorOption: true,\n group: PERCENT_GROUP,\n label: '%',\n },\n};\n\nexport function formatPercent(value: number, { unit, decimalPlaces }: PercentFormatOptions): string {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'percent',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n // Intl.NumberFormat translates 0 -> 0%, 0.5 -> 50%, 1 -> 100%, etc.\n if (unit === 'percent') {\n value = value / 100;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","PERCENT_GROUP_CONFIG","label","decimalPlaces","PERCENT_GROUP","PERCENT_UNIT_CONFIG","percent","group","disableSelectorOption","formatPercent","value","unit","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAO/D,OAAO,MAAMC,uBAAwC;IACnDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,gBAAgB;AACtB,OAAO,MAAMC,sBAAiE;IAC5EC,SAAS;QACPC,OAAOH;QACPF,OAAO;IACT;IACA,mBAAmB;QACjBK,OAAOH;QACPF,OAAO;IACT;IACA,KAAK;QACH,qEAAqE;QACrE,0BAA0B;QAC1BM,uBAAuB;QACvBD,OAAOH;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,cAAcC,KAAa,EAAE,EAAEC,IAAI,EAAER,aAAa,EAAwB;IACxF,MAAMS,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIf,iBAAiBI,gBAAgB;QACnCS,iBAAiBG,qBAAqB,GAAGf,mBAAmBG;QAC5DS,iBAAiBI,qBAAqB,GAAGhB,mBAAmBG;IAC9D,OAAO;QACLS,iBAAiBK,wBAAwB,GAAGnB;IAC9C;IAEA,oEAAoE;IACpE,IAAIa,SAAS,WAAW;QACtBD,QAAQA,QAAQ;IAClB;IAEA,MAAMQ,YAAYC,KAAKC,YAAY,CAAC,SAASR;IAC7C,OAAOM,UAAUG,MAAM,CAACX;AAC1B"}
@@ -1,4 +1,4 @@
1
- // Copyright 2025 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/temperature.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\nconst TEMPERATURE_GROUP = 'Temperature';\n\ntype TemperatureUnits = 'celsius' | 'fahrenheit';\n\nexport type TemperatureFormatOptions = {\n unit: TemperatureUnits;\n decimalPlaces?: number;\n};\n\nexport const TEMPERATURE_GROUP_CONFIG: UnitGroupConfig = {\n label: TEMPERATURE_GROUP,\n decimalPlaces: true,\n};\n\nexport const TEMPERATURE_UNIT_CONFIG: Readonly<Record<TemperatureUnits, UnitConfig>> = {\n celsius: {\n group: TEMPERATURE_GROUP,\n label: 'Celsius (°C)',\n },\n fahrenheit: {\n group: TEMPERATURE_GROUP,\n label: 'Fahrenheit (°F)',\n },\n};\n\nexport const formatTemperature = (value: number, { unit, decimalPlaces }: TemperatureFormatOptions): string => {\n const formatterOptions: Intl.NumberFormatOptions = {\n unit,\n style: 'unit',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const locals = unit === 'celsius' ? 'en-GB' : 'en-US';\n return Intl.NumberFormat(locals, formatterOptions).format(value);\n};\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","TEMPERATURE_GROUP","TEMPERATURE_GROUP_CONFIG","label","decimalPlaces","TEMPERATURE_UNIT_CONFIG","celsius","group","fahrenheit","formatTemperature","value","unit","formatterOptions","style","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","locals","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAE/D,MAAMC,oBAAoB;AAS1B,OAAO,MAAMC,2BAA4C;IACvDC,OAAOF;IACPG,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,0BAA0E;IACrFC,SAAS;QACPC,OAAON;QACPE,OAAO;IACT;IACAK,YAAY;QACVD,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,OAAO,MAAMM,oBAAoB,CAACC,OAAe,EAAEC,IAAI,EAAEP,aAAa,EAA4B;IAChG,MAAMQ,mBAA6C;QACjDD;QACAE,OAAO;IACT;IAEA,IAAId,iBAAiBK,gBAAgB;QACnCQ,iBAAiBE,qBAAqB,GAAGd,mBAAmBI;QAC5DQ,iBAAiBG,qBAAqB,GAAGf,mBAAmBI;IAC9D,OAAO;QACLQ,iBAAiBI,wBAAwB,GAAGlB;IAC9C;IAEA,MAAMmB,SAASN,SAAS,YAAY,UAAU;IAC9C,OAAOO,KAAKC,YAAY,CAACF,QAAQL,kBAAkBQ,MAAM,CAACV;AAC5D,EAAE"}
1
+ {"version":3,"sources":["../../../src/model/units/temperature.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitConfig, UnitGroupConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\nconst TEMPERATURE_GROUP = 'Temperature';\n\ntype TemperatureUnits = 'celsius' | 'fahrenheit';\n\nexport type TemperatureFormatOptions = {\n unit: TemperatureUnits;\n decimalPlaces?: number;\n};\n\nexport const TEMPERATURE_GROUP_CONFIG: UnitGroupConfig = {\n label: TEMPERATURE_GROUP,\n decimalPlaces: true,\n};\n\nexport const TEMPERATURE_UNIT_CONFIG: Readonly<Record<TemperatureUnits, UnitConfig>> = {\n celsius: {\n group: TEMPERATURE_GROUP,\n label: 'Celsius (°C)',\n },\n fahrenheit: {\n group: TEMPERATURE_GROUP,\n label: 'Fahrenheit (°F)',\n },\n};\n\nexport const formatTemperature = (value: number, { unit, decimalPlaces }: TemperatureFormatOptions): string => {\n const formatterOptions: Intl.NumberFormatOptions = {\n unit,\n style: 'unit',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const locals = unit === 'celsius' ? 'en-GB' : 'en-US';\n return Intl.NumberFormat(locals, formatterOptions).format(value);\n};\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","TEMPERATURE_GROUP","TEMPERATURE_GROUP_CONFIG","label","decimalPlaces","TEMPERATURE_UNIT_CONFIG","celsius","group","fahrenheit","formatTemperature","value","unit","formatterOptions","style","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","locals","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAE/D,MAAMC,oBAAoB;AAS1B,OAAO,MAAMC,2BAA4C;IACvDC,OAAOF;IACPG,eAAe;AACjB,EAAE;AAEF,OAAO,MAAMC,0BAA0E;IACrFC,SAAS;QACPC,OAAON;QACPE,OAAO;IACT;IACAK,YAAY;QACVD,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,OAAO,MAAMM,oBAAoB,CAACC,OAAe,EAAEC,IAAI,EAAEP,aAAa,EAA4B;IAChG,MAAMQ,mBAA6C;QACjDD;QACAE,OAAO;IACT;IAEA,IAAId,iBAAiBK,gBAAgB;QACnCQ,iBAAiBE,qBAAqB,GAAGd,mBAAmBI;QAC5DQ,iBAAiBG,qBAAqB,GAAGf,mBAAmBI;IAC9D,OAAO;QACLQ,iBAAiBI,wBAAwB,GAAGlB;IAC9C;IAEA,MAAMmB,SAASN,SAAS,YAAY,UAAU;IAC9C,OAAOO,KAAKC,YAAY,CAACF,QAAQL,kBAAkBQ,MAAM,CAACV;AAC5D,EAAE"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/throughput.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes } from './bytes';\nimport { formatBits } from './bits';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype ThroughputUnit =\n | 'bits/sec'\n | 'decbits/sec'\n | 'bytes/sec'\n | 'decbytes/sec'\n | 'counts/sec'\n | 'events/sec'\n | 'messages/sec'\n | 'ops/sec'\n | 'packets/sec'\n | 'reads/sec'\n | 'records/sec'\n | 'requests/sec'\n | 'rows/sec'\n | 'writes/sec';\nexport type ThroughputFormatOptions = {\n unit?: ThroughputUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const THROUGHPUT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Throughput',\n decimalPlaces: true,\n};\nconst THROUGHPUT_GROUP = 'Throughput';\nexport const THROUGHPUT_UNIT_CONFIG: Readonly<Record<ThroughputUnit, UnitConfig>> = {\n 'bits/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bits/sec (IEC)',\n },\n 'decbits/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bits/sec (SI)',\n },\n 'bytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec (IEC)',\n },\n 'decbytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec (SI)',\n },\n\n 'counts/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Counts/sec',\n },\n 'events/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Events/sec',\n },\n 'messages/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Messages/sec',\n },\n 'ops/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Ops/sec',\n },\n 'packets/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Packets/sec',\n },\n 'reads/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Reads/sec',\n },\n 'requests/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Requests/sec',\n },\n 'records/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Records/sec',\n },\n 'rows/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Rows/sec',\n },\n 'writes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Writes/sec',\n },\n};\n\nexport function formatThroughput(value: number, { unit, shortValues, decimalPlaces }: ThroughputFormatOptions): string {\n // special case for data throughput\n if (unit === 'bits/sec') {\n const denominator = Math.abs(value) < 1024 ? 'sec' : 's';\n return formatBits(value, { unit: 'bits', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'decbits/sec') {\n const denominator = Math.abs(value) < 1000 ? 'sec' : 's';\n return formatBits(value, { unit: 'decbits', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'decbytes/sec') {\n const denominator = Math.abs(value) < 1000 ? 'sec' : 's';\n return formatBytes(value, { unit: 'decbytes', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'bytes/sec') {\n const denominator = Math.abs(value) < 1024 ? 'sec' : 's';\n return formatBytes(value, { unit: 'bytes', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value) + ' ' + unit;\n}\n"],"names":["formatBytes","formatBits","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","THROUGHPUT_GROUP_CONFIG","label","decimalPlaces","THROUGHPUT_GROUP","THROUGHPUT_UNIT_CONFIG","group","formatThroughput","value","unit","shortValues","denominator","Math","abs","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAsBpF,OAAO,MAAMC,0BAA2C;IACtDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,mBAAmB;AACzB,OAAO,MAAMC,yBAAuE;IAClF,YAAY;QACVC,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IAEA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,WAAW;QACTI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,YAAY;QACVI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASK,iBAAiBC,KAAa,EAAE,EAAEC,IAAI,EAAEC,WAAW,EAAEP,aAAa,EAA2B;IAC3G,mCAAmC;IACnC,IAAIM,SAAS,YAAY;QACvB,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOZ,WAAWY,OAAO;YAAEC,MAAM;YAAQC;YAAaP;QAAc,KAAK,MAAMQ;IACjF;IAEA,IAAIF,SAAS,eAAe;QAC1B,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOZ,WAAWY,OAAO;YAAEC,MAAM;YAAWC;YAAaP;QAAc,KAAK,MAAMQ;IACpF;IAEA,IAAIF,SAAS,gBAAgB;QAC3B,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOb,YAAYa,OAAO;YAAEC,MAAM;YAAYC;YAAaP;QAAc,KAAK,MAAMQ;IACtF;IAEA,IAAIF,SAAS,aAAa;QACxB,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOb,YAAYa,OAAO;YAAEC,MAAM;YAASC;YAAaP;QAAc,KAAK,MAAMQ;IACnF;IAEA,MAAMG,mBAA6C;QACjDC,OAAO;QACPC,aAAa;IACf;IAEA,IAAIhB,oBAAoBU,cAAc;QACpCI,iBAAiBG,QAAQ,GAAG;IAC9B;IAEA,IAAInB,iBAAiBK,gBAAgB;QACnCW,iBAAiBI,qBAAqB,GAAGnB,mBAAmBI;QAC5DW,iBAAiBK,qBAAqB,GAAGpB,mBAAmBI;IAC9D,OAAO;QACL,IAAIH,oBAAoBU,cAAc;YACpCI,iBAAiBM,wBAAwB,GAAGvB;QAC9C;IACF;IAEA,MAAMwB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAAChB,SAAS,MAAMC;AACzC"}
1
+ {"version":3,"sources":["../../../src/model/units/throughput.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes } from './bytes';\nimport { formatBits } from './bits';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype ThroughputUnit =\n | 'bits/sec'\n | 'decbits/sec'\n | 'bytes/sec'\n | 'decbytes/sec'\n | 'counts/sec'\n | 'events/sec'\n | 'messages/sec'\n | 'ops/sec'\n | 'packets/sec'\n | 'reads/sec'\n | 'records/sec'\n | 'requests/sec'\n | 'rows/sec'\n | 'writes/sec';\nexport type ThroughputFormatOptions = {\n unit?: ThroughputUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const THROUGHPUT_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Throughput',\n decimalPlaces: true,\n};\nconst THROUGHPUT_GROUP = 'Throughput';\nexport const THROUGHPUT_UNIT_CONFIG: Readonly<Record<ThroughputUnit, UnitConfig>> = {\n 'bits/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bits/sec (IEC)',\n },\n 'decbits/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bits/sec (SI)',\n },\n 'bytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec (IEC)',\n },\n 'decbytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec (SI)',\n },\n\n 'counts/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Counts/sec',\n },\n 'events/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Events/sec',\n },\n 'messages/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Messages/sec',\n },\n 'ops/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Ops/sec',\n },\n 'packets/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Packets/sec',\n },\n 'reads/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Reads/sec',\n },\n 'requests/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Requests/sec',\n },\n 'records/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Records/sec',\n },\n 'rows/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Rows/sec',\n },\n 'writes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Writes/sec',\n },\n};\n\nexport function formatThroughput(value: number, { unit, shortValues, decimalPlaces }: ThroughputFormatOptions): string {\n // special case for data throughput\n if (unit === 'bits/sec') {\n const denominator = Math.abs(value) < 1024 ? 'sec' : 's';\n return formatBits(value, { unit: 'bits', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'decbits/sec') {\n const denominator = Math.abs(value) < 1000 ? 'sec' : 's';\n return formatBits(value, { unit: 'decbits', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'decbytes/sec') {\n const denominator = Math.abs(value) < 1000 ? 'sec' : 's';\n return formatBytes(value, { unit: 'decbytes', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n if (unit === 'bytes/sec') {\n const denominator = Math.abs(value) < 1024 ? 'sec' : 's';\n return formatBytes(value, { unit: 'bytes', shortValues, decimalPlaces }) + '/' + denominator;\n }\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\n useGrouping: true,\n };\n\n if (shouldShortenValues(shortValues)) {\n formatterOptions.notation = 'compact';\n }\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(value) + ' ' + unit;\n}\n"],"names":["formatBytes","formatBits","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","THROUGHPUT_GROUP_CONFIG","label","decimalPlaces","THROUGHPUT_GROUP","THROUGHPUT_UNIT_CONFIG","group","formatThroughput","value","unit","shortValues","denominator","Math","abs","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,UAAU,QAAQ,SAAS;AACpC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAsBpF,OAAO,MAAMC,0BAA2C;IACtDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,mBAAmB;AACzB,OAAO,MAAMC,yBAAuE;IAClF,YAAY;QACVC,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IAEA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,WAAW;QACTI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,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,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAAChB,SAAS,MAAMC;AACzC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/time.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype TimeUnits =\n | 'nanoseconds'\n | 'microseconds'\n | 'milliseconds'\n | 'seconds'\n | 'minutes'\n | 'hours'\n | 'days'\n | 'weeks'\n | 'months'\n | 'years';\nexport type TimeFormatOptions = {\n unit?: TimeUnits;\n decimalPlaces?: number;\n};\nconst TIME_GROUP = 'Time';\nexport const TIME_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Time',\n decimalPlaces: true,\n};\nexport const TIME_UNIT_CONFIG: Readonly<Record<TimeUnits, UnitConfig>> = {\n nanoseconds: {\n group: TIME_GROUP,\n label: 'Nanoseconds',\n },\n microseconds: {\n group: TIME_GROUP,\n label: 'Microseconds',\n },\n milliseconds: {\n group: TIME_GROUP,\n label: 'Milliseconds',\n },\n seconds: {\n group: TIME_GROUP,\n label: 'Seconds',\n },\n minutes: {\n group: TIME_GROUP,\n label: 'Minutes',\n },\n hours: {\n group: TIME_GROUP,\n label: 'Hours',\n },\n days: {\n group: TIME_GROUP,\n label: 'Days',\n },\n weeks: {\n group: TIME_GROUP,\n label: 'Weeks',\n },\n months: {\n group: TIME_GROUP,\n label: 'Months',\n },\n years: {\n group: TIME_GROUP,\n label: 'Years',\n },\n};\n\n// Mapping of time units to what Intl.NumberFormat formatter expects\n// https://v8.dev/features/intl-numberformat#units\nexport enum PersesTimeToIntlTime {\n nanoseconds = 'nanosecond',\n microseconds = 'microsecond',\n milliseconds = 'millisecond',\n seconds = 'second',\n minutes = 'minute',\n hours = 'hour',\n days = 'day',\n weeks = 'week',\n months = 'month',\n years = 'year',\n}\n\n/**\n * Note: This conversion will not be exactly accurate for months and years,\n * due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).\n * For precision with months and years, we would need more complex algorithms and/or external libraries.\n * However, we expect that measurements in months and years will be rare.\n */\nconst TIME_UNITS_IN_SECONDS: Record<TimeUnits, number> = {\n years: 31536000, // 365 days\n months: 2592000, // 30 days\n weeks: 604800, // 7 days\n days: 86400,\n hours: 3600,\n minutes: 60,\n seconds: 1,\n milliseconds: 0.001,\n microseconds: 0.000001,\n nanoseconds: 0.000000001,\n};\n\nconst LARGEST_TO_SMALLEST_TIME_UNITS: TimeUnits[] = [\n 'years',\n 'months',\n 'weeks',\n 'days',\n 'hours',\n 'minutes',\n 'seconds',\n 'milliseconds',\n 'microseconds',\n 'nanoseconds',\n];\n\n/**\n * Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.\n */\nfunction getValueAndKindForNaturalNumbers(value: number, unit: TimeUnits): { value: number; unit: TimeUnits } {\n const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];\n\n // Initialize for TS\n const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';\n let timeUnit: TimeUnits = largestTimeUnit;\n let valueInTimeUnit: number = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];\n\n for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS) {\n valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];\n if (valueInTimeUnit >= 1) {\n return { value: valueInTimeUnit, unit: timeUnit };\n }\n }\n\n // If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).\n return { value: valueInTimeUnit, unit: timeUnit };\n}\n\nfunction isMonthOrYear(unit: TimeUnits): boolean {\n return unit === 'months' || unit === 'years';\n}\n\nexport function formatTime(value: number, { unit, decimalPlaces }: TimeFormatOptions): string {\n if (value === 0) return '0s';\n\n const results = getValueAndKindForNaturalNumbers(value, unit ?? 'seconds');\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: PersesTimeToIntlTime[results.unit],\n unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(results.value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","TIME_GROUP","TIME_GROUP_CONFIG","label","decimalPlaces","TIME_UNIT_CONFIG","nanoseconds","group","microseconds","milliseconds","seconds","minutes","hours","days","weeks","months","years","PersesTimeToIntlTime","TIME_UNITS_IN_SECONDS","LARGEST_TO_SMALLEST_TIME_UNITS","getValueAndKindForNaturalNumbers","value","unit","valueInSeconds","largestTimeUnit","timeUnit","valueInTimeUnit","isMonthOrYear","formatTime","results","formatterOptions","style","unitDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;A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AqB,CAACM,gBAAgB;IAErF,KAAKC,YAAYN,+BAAgC;QAC/CO,kBAAkBH,iBAAiBL,qBAAqB,CAACO,SAAS;QAClE,IAAIC,mBAAmB,GAAG;YACxB,OAAO;gBAAEL,OAAOK;gBAAiBJ,MAAMG;YAAS;QAClD;IACF;IAEA,6GAA6G;IAC7G,OAAO;QAAEJ,OAAOK;QAAiBJ,MAAMG;IAAS;AAClD;AAEA,SAASE,cAAcL,IAAe;IACpC,OAAOA,SAAS,YAAYA,SAAS;AACvC;AAEA,OAAO,SAASM,WAAWP,KAAa,EAAE,EAAEC,IAAI,EAAElB,aAAa,EAAqB;IAClF,IAAIiB,UAAU,GAAG,OAAO;IAExB,MAAMQ,UAAUT,iCAAiCC,OAAOC,QAAQ;IAEhE,MAAMQ,mBAA6C;QACjDC,OAAO;QACPT,MAAML,oBAAoB,CAACY,QAAQP,IAAI,CAAC;QACxCU,aAAaL,cAAcE,QAAQP,IAAI,IAAI,SAAS;IACtD;IAEA,IAAIvB,iBAAiBK,gBAAgB;QACnC0B,iBAAiBG,qBAAqB,GAAGjC,mBAAmBI;QAC5D0B,iBAAiBI,qBAAqB,GAAGlC,mBAAmBI;IAC9D,OAAO;QACL0B,iBAAiBK,wBAAwB,GAAGrC;IAC9C;IAEA,MAAMsC,YAAYC,KAAKC,YAAY,CAAC,SAASR;IAC7C,OAAOM,UAAUG,MAAM,CAACV,QAAQR,KAAK;AACvC"}
1
+ {"version":3,"sources":["../../../src/model/units/time.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces } from './utils';\n\ntype TimeUnits =\n | 'nanoseconds'\n | 'microseconds'\n | 'milliseconds'\n | 'seconds'\n | 'minutes'\n | 'hours'\n | 'days'\n | 'weeks'\n | 'months'\n | 'years';\nexport type TimeFormatOptions = {\n unit?: TimeUnits;\n decimalPlaces?: number;\n};\nconst TIME_GROUP = 'Time';\nexport const TIME_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Time',\n decimalPlaces: true,\n};\nexport const TIME_UNIT_CONFIG: Readonly<Record<TimeUnits, UnitConfig>> = {\n nanoseconds: {\n group: TIME_GROUP,\n label: 'Nanoseconds',\n },\n microseconds: {\n group: TIME_GROUP,\n label: 'Microseconds',\n },\n milliseconds: {\n group: TIME_GROUP,\n label: 'Milliseconds',\n },\n seconds: {\n group: TIME_GROUP,\n label: 'Seconds',\n },\n minutes: {\n group: TIME_GROUP,\n label: 'Minutes',\n },\n hours: {\n group: TIME_GROUP,\n label: 'Hours',\n },\n days: {\n group: TIME_GROUP,\n label: 'Days',\n },\n weeks: {\n group: TIME_GROUP,\n label: 'Weeks',\n },\n months: {\n group: TIME_GROUP,\n label: 'Months',\n },\n years: {\n group: TIME_GROUP,\n label: 'Years',\n },\n};\n\n// Mapping of time units to what Intl.NumberFormat formatter expects\n// https://v8.dev/features/intl-numberformat#units\nexport enum PersesTimeToIntlTime {\n nanoseconds = 'nanosecond',\n microseconds = 'microsecond',\n milliseconds = 'millisecond',\n seconds = 'second',\n minutes = 'minute',\n hours = 'hour',\n days = 'day',\n weeks = 'week',\n months = 'month',\n years = 'year',\n}\n\n/**\n * Note: This conversion will not be exactly accurate for months and years,\n * due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).\n * For precision with months and years, we would need more complex algorithms and/or external libraries.\n * However, we expect that measurements in months and years will be rare.\n */\nconst TIME_UNITS_IN_SECONDS: Record<TimeUnits, number> = {\n years: 31536000, // 365 days\n months: 2592000, // 30 days\n weeks: 604800, // 7 days\n days: 86400,\n hours: 3600,\n minutes: 60,\n seconds: 1,\n milliseconds: 0.001,\n microseconds: 0.000001,\n nanoseconds: 0.000000001,\n};\n\nconst LARGEST_TO_SMALLEST_TIME_UNITS: TimeUnits[] = [\n 'years',\n 'months',\n 'weeks',\n 'days',\n 'hours',\n 'minutes',\n 'seconds',\n 'milliseconds',\n 'microseconds',\n 'nanoseconds',\n];\n\n/**\n * Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.\n */\nfunction getValueAndKindForNaturalNumbers(value: number, unit: TimeUnits): { value: number; unit: TimeUnits } {\n const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];\n\n // Initialize for TS\n const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';\n let timeUnit: TimeUnits = largestTimeUnit;\n let valueInTimeUnit: number = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];\n\n for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS) {\n valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];\n if (valueInTimeUnit >= 1) {\n return { value: valueInTimeUnit, unit: timeUnit };\n }\n }\n\n // If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).\n return { value: valueInTimeUnit, unit: timeUnit };\n}\n\nfunction isMonthOrYear(unit: TimeUnits): boolean {\n return unit === 'months' || unit === 'years';\n}\n\nexport function formatTime(value: number, { unit, decimalPlaces }: TimeFormatOptions): string {\n if (value === 0) return '0s';\n\n const results = getValueAndKindForNaturalNumbers(value, unit ?? 'seconds');\n\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: PersesTimeToIntlTime[results.unit],\n unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow',\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(results.value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","TIME_GROUP","TIME_GROUP_CONFIG","label","decimalPlaces","TIME_UNIT_CONFIG","nanoseconds","group","microseconds","milliseconds","seconds","minutes","hours","days","weeks","months","years","PersesTimeToIntlTime","TIME_UNITS_IN_SECONDS","LARGEST_TO_SMALLEST_TIME_UNITS","getValueAndKindForNaturalNumbers","value","unit","valueInSeconds","largestTimeUnit","timeUnit","valueInTimeUnit","isMonthOrYear","formatTime","results","formatterOptions","style","unitDisplay","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ,UAAU;AAiB/D,MAAMC,aAAa;AACnB,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,OAAO,MAAMC,mBAA4D;IACvEC,aAAa;QACXC,OAAON;QACPE,OAAO;IACT;IACAK,cAAc;QACZD,OAAON;QACPE,OAAO;IACT;IACAM,cAAc;QACZF,OAAON;QACPE,OAAO;IACT;IACAO,SAAS;QACPH,OAAON;QACPE,OAAO;IACT;IACAQ,SAAS;QACPJ,OAAON;QACPE,OAAO;IACT;IACAS,OAAO;QACLL,OAAON;QACPE,OAAO;IACT;IACAU,MAAM;QACJN,OAAON;QACPE,OAAO;IACT;IACAW,OAAO;QACLP,OAAON;QACPE,OAAO;IACT;I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I,IAAI,SAAS;IACtD;IAEA,IAAIvB,iBAAiBK,gBAAgB;QACnC0B,iBAAiBG,qBAAqB,GAAGjC,mBAAmBI;QAC5D0B,iBAAiBI,qBAAqB,GAAGlC,mBAAmBI;IAC9D,OAAO;QACL0B,iBAAiBK,wBAAwB,GAAGrC;IAC9C;IAEA,MAAMsC,YAAYC,KAAKC,YAAY,CAAC,SAASR;IAC7C,OAAOM,UAAUG,MAAM,CAACV,QAAQR,KAAK;AACvC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/types.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Common types needed across individual unit groups and the overall combined\n// units.\n\nimport { Duration } from 'date-fns';\nimport { AbsoluteTimeRange, DurationString } from '../time';\nimport { FormatOptions } from './units';\n\nexport type UnitGroup =\n | 'Time'\n | 'Percent'\n | 'Decimal'\n | 'Bytes'\n | 'Bits'\n | 'Throughput'\n | 'Currency'\n | 'Temperature'\n | 'Date';\n\n/**\n * Configuration for rendering units that are part of a group.\n */\nexport type UnitGroupConfig = {\n /**\n * The label that is shown in the UI.\n */\n label: string;\n /**\n * When true, the unit group supports setting decimal places.\n */\n decimalPlaces?: boolean;\n /**\n * When true, the unit group supports enabling shortValues.\n */\n shortValues?: boolean;\n};\n\n/**\n * Configuration for rendering a specific unit.\n */\nexport type UnitConfig = {\n /**\n * The group the unit is part of. This will inform common rendering behavior.\n */\n group?: UnitGroup;\n\n /**\n * When true, this unit will not be displayed in the unit selector. This is\n * useful for units that are shorthand variants of other units.\n */\n disableSelectorOption?: boolean;\n\n /**\n * The label that is shown in the UI.\n */\n label: string;\n};\n\n/**\n * Used in the tests for each type of unit.\n */\nexport interface UnitTestCase {\n value: number;\n format: FormatOptions;\n expected: string;\n}\n\nexport interface IntervalTestCase {\n timeRange: AbsoluteTimeRange;\n expected: Duration;\n}\n\nexport interface FormatTestCase {\n duration: Duration;\n expected: DurationString;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6EAA6E;AAC7E,SAAS;AAsET,WAGC"}
1
+ {"version":3,"sources":["../../../src/model/units/types.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// Common types needed across individual unit groups and the overall combined\n// units.\n\nimport { Duration } from 'date-fns';\nimport { AbsoluteTimeRange, DurationString } from '../time';\nimport { FormatOptions } from './units';\n\nexport type UnitGroup =\n | 'Time'\n | 'Percent'\n | 'Decimal'\n | 'Bytes'\n | 'Bits'\n | 'Throughput'\n | 'Currency'\n | 'Temperature'\n | 'Date';\n\n/**\n * Configuration for rendering units that are part of a group.\n */\nexport type UnitGroupConfig = {\n /**\n * The label that is shown in the UI.\n */\n label: string;\n /**\n * When true, the unit group supports setting decimal places.\n */\n decimalPlaces?: boolean;\n /**\n * When true, the unit group supports enabling shortValues.\n */\n shortValues?: boolean;\n};\n\n/**\n * Configuration for rendering a specific unit.\n */\nexport type UnitConfig = {\n /**\n * The group the unit is part of. This will inform common rendering behavior.\n */\n group?: UnitGroup;\n\n /**\n * When true, this unit will not be displayed in the unit selector. This is\n * useful for units that are shorthand variants of other units.\n */\n disableSelectorOption?: boolean;\n\n /**\n * The label that is shown in the UI.\n */\n label: string;\n};\n\n/**\n * Used in the tests for each type of unit.\n */\nexport interface UnitTestCase {\n value: number;\n format: FormatOptions;\n expected: string;\n}\n\nexport interface IntervalTestCase {\n timeRange: AbsoluteTimeRange;\n expected: Duration;\n}\n\nexport interface FormatTestCase {\n duration: Duration;\n expected: DurationString;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6EAA6E;AAC7E,SAAS;AAsET,WAGC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/units.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes, BytesFormatOptions as BytesFormatOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';\nimport { formatBits, BitsFormatOptions as BitsFormatOptions, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';\nimport {\n formatDecimal,\n DecimalFormatOptions as DecimalFormatOptions,\n DECIMAL_GROUP_CONFIG,\n DECIMAL_UNIT_CONFIG,\n} from './decimal';\nimport {\n formatPercent,\n PercentFormatOptions as PercentFormatOptions,\n PERCENT_GROUP_CONFIG,\n PERCENT_UNIT_CONFIG,\n} from './percent';\nimport {\n TEMPERATURE_GROUP_CONFIG,\n formatTemperature,\n TEMPERATURE_UNIT_CONFIG,\n TemperatureFormatOptions,\n} from './temperature';\nimport { formatTime, TimeFormatOptions as TimeFormatOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\nimport {\n formatThroughput,\n THROUGHPUT_GROUP_CONFIG,\n THROUGHPUT_UNIT_CONFIG,\n ThroughputFormatOptions,\n} from './throughput';\nimport { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG, CurrencyFormatOptions } from './currency';\nimport { formatDate, DateFormatOptions, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';\n\n/**\n * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.\n * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.\n *\n * To format bytes, we also make use of the `numbro` package,\n * because it can handle adding units like KB, MB, GB, etc. correctly.\n */\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n Bits: BITS_GROUP_CONFIG,\n Throughput: THROUGHPUT_GROUP_CONFIG,\n Currency: CURRENCY_GROUP_CONFIG,\n Temperature: TEMPERATURE_GROUP_CONFIG,\n Date: DATE_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n ...BITS_UNIT_CONFIG,\n ...THROUGHPUT_UNIT_CONFIG,\n ...CURRENCY_UNIT_CONFIG,\n ...TEMPERATURE_UNIT_CONFIG,\n ...DATE_UNIT_CONFIG,\n} as const;\n\nexport type FormatOptions =\n | TimeFormatOptions\n | PercentFormatOptions\n | DecimalFormatOptions\n | BytesFormatOptions\n | BitsFormatOptions\n | ThroughputFormatOptions\n | CurrencyFormatOptions\n | TemperatureFormatOptions\n | DateFormatOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimalPlaces?: number } ? UnitOpt : never;\ntype HasShortValues<UnitOpt> = UnitOpt extends { shortValues?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, formatOptions?: FormatOptions): string {\n if (!formatOptions) {\n return value.toString();\n }\n\n if (isBytesUnit(formatOptions)) {\n return formatBytes(value, formatOptions);\n }\n\n if (isBitsUnit(formatOptions)) {\n return formatBits(value, formatOptions);\n }\n\n if (isDecimalUnit(formatOptions)) {\n return formatDecimal(value, formatOptions);\n }\n\n if (isPercentUnit(formatOptions)) {\n return formatPercent(value, formatOptions);\n }\n\n if (isTimeUnit(formatOptions)) {\n return formatTime(value, formatOptions);\n }\n\n if (isThroughputUnit(formatOptions)) {\n return formatThroughput(value, formatOptions);\n }\n\n if (isCurrencyUnit(formatOptions)) {\n return formatCurrency(value, formatOptions);\n }\n\n if (isDateUnit(formatOptions)) {\n return formatDate(value, formatOptions);\n }\n\n if (isTemperatureUnit(formatOptions)) {\n return formatTemperature(value, formatOptions);\n }\n\n const exhaustive: never = formatOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitConfig(formatOptions: FormatOptions): UnitConfig {\n const unit = formatOptions.unit ?? 'decimal';\n return UNIT_CONFIG[unit];\n}\n\nexport function getUnitGroup(formatOptions: FormatOptions): UnitGroup {\n return getUnitConfig(formatOptions).group ?? 'Decimal';\n}\n\nexport function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig {\n const unitConfig = getUnitConfig(formatOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];\n}\n\n// Type guards\nexport function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions {\n return getUnitGroup(formatOptions) === 'Time';\n}\n\nexport function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions {\n return getUnitGroup(formatOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions {\n return getUnitGroup(formatOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions {\n return getUnitGroup(formatOptions) === 'Bytes';\n}\n\nexport function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions {\n return getUnitGroup(formatOptions) === 'Bits';\n}\n\nexport function isUnitWithDecimalPlaces(\n formatOptions: FormatOptions\n): formatOptions is HasDecimalPlaces<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.decimalPlaces;\n}\n\nexport function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.shortValues;\n}\n\nexport function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions {\n return getUnitGroup(formatOptions) === 'Throughput';\n}\n\nexport function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions {\n return getUnitGroup(formatOptions) === 'Currency';\n}\n\nexport function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions {\n return getUnitGroup(formatOptions) === 'Date';\n}\n\nexport function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions {\n return getUnitGroup(formatOptions) === 'Temperature';\n}\n"],"names":["formatBytes","BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatBits","BITS_GROUP_CONFIG","BITS_UNIT_CONFIG","formatDecimal","DECIMAL_GROUP_CONFIG","DECIMAL_UNIT_CONFIG","formatPercent","PERCENT_GROUP_CONFIG","PERCENT_UNIT_CONFIG","TEMPERATURE_GROUP_CONFIG","formatTemperature","TEMPERATURE_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","formatThroughput","THROUGHPUT_GROUP_CONFIG","THROUGHPUT_UNIT_CONFIG","formatCurrency","CURRENCY_GROUP_CONFIG","CURRENCY_UNIT_CONFIG","formatDate","DATE_GROUP_CONFIG","DATE_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","Bits","Throughput","Currency","Temperature","Date","UNIT_CONFIG","formatValue","value","formatOptions","toString","isBytesUnit","isBitsUnit","isDecimalUnit","isPercentUnit","isTimeUnit","isThroughputUnit","isCurrencyUnit","isDateUnit","isTemperatureUnit","exhaustive","Error","getUnitConfig","unit","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","decimalPlaces","isUnitWithShortValues","shortValues"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAA4CC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AACvH,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AACjH,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,wBAAwB,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af,mBAAmB;AACzC;AAEA,OAAO,SAASQ,eAAeR,aAA4B;IACzD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASS,WAAWT,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASU,kBAAkBV,aAA4B;IAC5D,OAAOe,aAAaf,mBAAmB;AACzC"}
1
+ {"version":3,"sources":["../../../src/model/units/units.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes, BytesFormatOptions as BytesFormatOptions, BYTES_GROUP_CONFIG, BYTES_UNIT_CONFIG } from './bytes';\nimport { formatBits, BitsFormatOptions as BitsFormatOptions, BITS_GROUP_CONFIG, BITS_UNIT_CONFIG } from './bits';\nimport {\n formatDecimal,\n DecimalFormatOptions as DecimalFormatOptions,\n DECIMAL_GROUP_CONFIG,\n DECIMAL_UNIT_CONFIG,\n} from './decimal';\nimport {\n formatPercent,\n PercentFormatOptions as PercentFormatOptions,\n PERCENT_GROUP_CONFIG,\n PERCENT_UNIT_CONFIG,\n} from './percent';\nimport {\n TEMPERATURE_GROUP_CONFIG,\n formatTemperature,\n TEMPERATURE_UNIT_CONFIG,\n TemperatureFormatOptions,\n} from './temperature';\nimport { formatTime, TimeFormatOptions as TimeFormatOptions, TIME_GROUP_CONFIG, TIME_UNIT_CONFIG } from './time';\nimport { UnitGroup, UnitGroupConfig, UnitConfig } from './types';\nimport {\n formatThroughput,\n THROUGHPUT_GROUP_CONFIG,\n THROUGHPUT_UNIT_CONFIG,\n ThroughputFormatOptions,\n} from './throughput';\nimport { formatCurrency, CURRENCY_GROUP_CONFIG, CURRENCY_UNIT_CONFIG, CurrencyFormatOptions } from './currency';\nimport { formatDate, DateFormatOptions, DATE_GROUP_CONFIG, DATE_UNIT_CONFIG } from './date';\n\n/**\n * Most of the number formatting is based on Intl.NumberFormat, which is built into JavaScript.\n * Prefer Intl.NumbeFormat because it covers most use cases and will continue to be supported with time.\n *\n * To format bytes, we also make use of the `numbro` package,\n * because it can handle adding units like KB, MB, GB, etc. correctly.\n */\n\nexport const UNIT_GROUP_CONFIG: Readonly<Record<UnitGroup, UnitGroupConfig>> = {\n Time: TIME_GROUP_CONFIG,\n Percent: PERCENT_GROUP_CONFIG,\n Decimal: DECIMAL_GROUP_CONFIG,\n Bytes: BYTES_GROUP_CONFIG,\n Bits: BITS_GROUP_CONFIG,\n Throughput: THROUGHPUT_GROUP_CONFIG,\n Currency: CURRENCY_GROUP_CONFIG,\n Temperature: TEMPERATURE_GROUP_CONFIG,\n Date: DATE_GROUP_CONFIG,\n};\nexport const UNIT_CONFIG = {\n ...TIME_UNIT_CONFIG,\n ...PERCENT_UNIT_CONFIG,\n ...DECIMAL_UNIT_CONFIG,\n ...BYTES_UNIT_CONFIG,\n ...BITS_UNIT_CONFIG,\n ...THROUGHPUT_UNIT_CONFIG,\n ...CURRENCY_UNIT_CONFIG,\n ...TEMPERATURE_UNIT_CONFIG,\n ...DATE_UNIT_CONFIG,\n} as const;\n\nexport type FormatOptions =\n | TimeFormatOptions\n | PercentFormatOptions\n | DecimalFormatOptions\n | BytesFormatOptions\n | BitsFormatOptions\n | ThroughputFormatOptions\n | CurrencyFormatOptions\n | TemperatureFormatOptions\n | DateFormatOptions;\n\ntype HasDecimalPlaces<UnitOpt> = UnitOpt extends { decimalPlaces?: number } ? UnitOpt : never;\ntype HasShortValues<UnitOpt> = UnitOpt extends { shortValues?: boolean } ? UnitOpt : never;\n\nexport function formatValue(value: number, formatOptions?: FormatOptions): string {\n if (!formatOptions) {\n return value.toString();\n }\n\n if (isBytesUnit(formatOptions)) {\n return formatBytes(value, formatOptions);\n }\n\n if (isBitsUnit(formatOptions)) {\n return formatBits(value, formatOptions);\n }\n\n if (isDecimalUnit(formatOptions)) {\n return formatDecimal(value, formatOptions);\n }\n\n if (isPercentUnit(formatOptions)) {\n return formatPercent(value, formatOptions);\n }\n\n if (isTimeUnit(formatOptions)) {\n return formatTime(value, formatOptions);\n }\n\n if (isThroughputUnit(formatOptions)) {\n return formatThroughput(value, formatOptions);\n }\n\n if (isCurrencyUnit(formatOptions)) {\n return formatCurrency(value, formatOptions);\n }\n\n if (isDateUnit(formatOptions)) {\n return formatDate(value, formatOptions);\n }\n\n if (isTemperatureUnit(formatOptions)) {\n return formatTemperature(value, formatOptions);\n }\n\n const exhaustive: never = formatOptions;\n throw new Error(`Unknown unit options ${exhaustive}`);\n}\n\nexport function getUnitConfig(formatOptions: FormatOptions): UnitConfig {\n const unit = formatOptions.unit ?? 'decimal';\n return UNIT_CONFIG[unit];\n}\n\nexport function getUnitGroup(formatOptions: FormatOptions): UnitGroup {\n return getUnitConfig(formatOptions).group ?? 'Decimal';\n}\n\nexport function getUnitGroupConfig(formatOptions: FormatOptions): UnitGroupConfig {\n const unitConfig = getUnitConfig(formatOptions);\n return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];\n}\n\n// Type guards\nexport function isTimeUnit(formatOptions: FormatOptions): formatOptions is TimeFormatOptions {\n return getUnitGroup(formatOptions) === 'Time';\n}\n\nexport function isPercentUnit(formatOptions: FormatOptions): formatOptions is PercentFormatOptions {\n return getUnitGroup(formatOptions) === 'Percent';\n}\n\nexport function isDecimalUnit(formatOptions: FormatOptions): formatOptions is DecimalFormatOptions {\n return getUnitGroup(formatOptions) === 'Decimal';\n}\n\nexport function isBytesUnit(formatOptions: FormatOptions): formatOptions is BytesFormatOptions {\n return getUnitGroup(formatOptions) === 'Bytes';\n}\n\nexport function isBitsUnit(formatOptions: FormatOptions): formatOptions is BitsFormatOptions {\n return getUnitGroup(formatOptions) === 'Bits';\n}\n\nexport function isUnitWithDecimalPlaces(\n formatOptions: FormatOptions\n): formatOptions is HasDecimalPlaces<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.decimalPlaces;\n}\n\nexport function isUnitWithShortValues(formatOptions: FormatOptions): formatOptions is HasShortValues<FormatOptions> {\n const groupConfig = getUnitGroupConfig(formatOptions);\n\n return !!groupConfig.shortValues;\n}\n\nexport function isThroughputUnit(formatOptions: FormatOptions): formatOptions is ThroughputFormatOptions {\n return getUnitGroup(formatOptions) === 'Throughput';\n}\n\nexport function isCurrencyUnit(formatOptions: FormatOptions): formatOptions is CurrencyFormatOptions {\n return getUnitGroup(formatOptions) === 'Currency';\n}\n\nexport function isDateUnit(formatOptions: FormatOptions): formatOptions is DateFormatOptions {\n return getUnitGroup(formatOptions) === 'Date';\n}\n\nexport function isTemperatureUnit(formatOptions: FormatOptions): formatOptions is TemperatureFormatOptions {\n return getUnitGroup(formatOptions) === 'Temperature';\n}\n"],"names":["formatBytes","BYTES_GROUP_CONFIG","BYTES_UNIT_CONFIG","formatBits","BITS_GROUP_CONFIG","BITS_UNIT_CONFIG","formatDecimal","DECIMAL_GROUP_CONFIG","DECIMAL_UNIT_CONFIG","formatPercent","PERCENT_GROUP_CONFIG","PERCENT_UNIT_CONFIG","TEMPERATURE_GROUP_CONFIG","formatTemperature","TEMPERATURE_UNIT_CONFIG","formatTime","TIME_GROUP_CONFIG","TIME_UNIT_CONFIG","formatThroughput","THROUGHPUT_GROUP_CONFIG","THROUGHPUT_UNIT_CONFIG","formatCurrency","CURRENCY_GROUP_CONFIG","CURRENCY_UNIT_CONFIG","formatDate","DATE_GROUP_CONFIG","DATE_UNIT_CONFIG","UNIT_GROUP_CONFIG","Time","Percent","Decimal","Bytes","Bits","Throughput","Currency","Temperature","Date","UNIT_CONFIG","formatValue","value","formatOptions","toString","isBytesUnit","isBitsUnit","isDecimalUnit","isPercentUnit","isTimeUnit","isThroughputUnit","isCurrencyUnit","isDateUnit","isTemperatureUnit","exhaustive","Error","getUnitConfig","unit","getUnitGroup","group","getUnitGroupConfig","unitConfig","isUnitWithDecimalPlaces","groupConfig","decimalPlaces","isUnitWithShortValues","shortValues"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,EAA4CC,kBAAkB,EAAEC,iBAAiB,QAAQ,UAAU;AACvH,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AACjH,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,aAAa,EAEbC,oBAAoB,EACpBC,mBAAmB,QACd,YAAY;AACnB,SACEC,wBAAwB,EACxBC,iBAAiB,EACjBC,uBAAuB,QAElB,gBAAgB;AACvB,SAASC,UAAU,EAA0CC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AAEjH,SACEC,gBAAgB,EAChBC,uBAAuB,EACvBC,sBAAsB,QAEjB,eAAe;AACtB,SAASC,cAAc,EAAEC,qBAAqB,EAAEC,oBAAoB,QAA+B,aAAa;AAChH,SAASC,UAAU,EAAqBC,iBAAiB,EAAEC,gBAAgB,QAAQ,SAAS;AAE5F;;;;;;CAMC,GAED,OAAO,MAAMC,oBAAkE;IAC7EC,MAAMZ;IACNa,SAASnB;IACToB,SAASvB;IACTwB,OAAO9B;IACP+B,MAAM5B;IACN6B,YAAYd;IACZe,UAAUZ;IACVa,aAAavB;IACbwB,MAAMX;AACR,EAAE;AACF,OAAO,MAAMY,cAAc;IACzB,GAAGpB,gBAAgB;IACnB,GAAGN,mBAAmB;IACtB,GAAGH,mBAAmB;IACtB,GAAGN,iBAAiB;IACpB,GAAGG,gBAAgB;IACnB,GAAGe,sBAAsB;IACzB,GAA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e,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASK,cAAcL,aAA4B;IACxD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASI,cAAcJ,aAA4B;IACxD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASE,YAAYF,aAA4B;IACtD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASG,WAAWH,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASmB,wBACdnB,aAA4B;IAE5B,MAAMoB,cAAcH,mBAAmBjB;IAEvC,OAAO,CAAC,CAACoB,YAAYC,aAAa;AACpC;AAEA,OAAO,SAASC,sBAAsBtB,aAA4B;IAChE,MAAMoB,cAAcH,mBAAmBjB;IAEvC,OAAO,CAAC,CAACoB,YAAYG,WAAW;AAClC;AAEA,OAAO,SAAShB,iBAAiBP,aAA4B;IAC3D,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASQ,eAAeR,aAA4B;IACzD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASS,WAAWT,aAA4B;IACrD,OAAOe,aAAaf,mBAAmB;AACzC;AAEA,OAAO,SAASU,kBAAkBV,aAA4B;IAC5D,OAAOe,aAAaf,mBAAmB;AACzC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/utils.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport function shouldShortenValues(shortValues?: boolean): boolean {\n return shortValues !== false;\n}\n\nexport function hasDecimalPlaces(decimalPlaces?: number): boolean {\n return typeof decimalPlaces === 'number';\n}\n\n// Avoids maximumFractionDigits out-of-range error.\n// Allowed values are 0 to 20.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits\nexport function limitDecimalPlaces(num?: number): number | undefined {\n if (!num) return num;\n\n if (num < 0) {\n num = 0;\n } else if (num > 20) {\n num = 20;\n }\n\n return num;\n}\n"],"names":["shouldShortenValues","shortValues","hasDecimalPlaces","decimalPlaces","limitDecimalPlaces","num"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,SAASA,oBAAoBC,WAAqB;IACvD,OAAOA,gBAAgB;AACzB;AAEA,OAAO,SAASC,iBAAiBC,aAAsB;IACrD,OAAO,OAAOA,kBAAkB;AAClC;AAEA,mDAAmD;AACnD,8BAA8B;AAC9B,wIAAwI;AACxI,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,IAAI,CAACA,KAAK,OAAOA;IAEjB,IAAIA,MAAM,GAAG;QACXA,MAAM;IACR,OAAO,IAAIA,MAAM,IAAI;QACnBA,MAAM;IACR;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../../src/model/units/utils.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport function shouldShortenValues(shortValues?: boolean): boolean {\n return shortValues !== false;\n}\n\nexport function hasDecimalPlaces(decimalPlaces?: number): boolean {\n return typeof decimalPlaces === 'number';\n}\n\n// Avoids maximumFractionDigits out-of-range error.\n// Allowed values are 0 to 20.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#maximumfractiondigits\nexport function limitDecimalPlaces(num?: number): number | undefined {\n if (!num) return num;\n\n if (num < 0) {\n num = 0;\n } else if (num > 20) {\n num = 20;\n }\n\n return num;\n}\n"],"names":["shouldShortenValues","shortValues","hasDecimalPlaces","decimalPlaces","limitDecimalPlaces","num"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,OAAO,SAASA,oBAAoBC,WAAqB;IACvD,OAAOA,gBAAgB;AACzB;AAEA,OAAO,SAASC,iBAAiBC,aAAsB;IACrD,OAAO,OAAOA,kBAAkB;AAClC;AAEA,mDAAmD;AACnD,8BAA8B;AAC9B,wIAAwI;AACxI,OAAO,SAASC,mBAAmBC,GAAY;IAC7C,IAAI,CAACA,KAAK,OAAOA;IAEjB,IAAIA,MAAM,GAAG;QACXA,MAAM;IACR,OAAO,IAAIA,MAAM,IAAI;QACnBA,MAAM;IACR;IAEA,OAAOA;AACT"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/user.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata } from './resource';\n\nexport interface NativeProvider {\n password?: string;\n}\n\nexport interface OAuthProvider {\n issuer?: string;\n email?: string;\n subject?: string;\n}\n\nexport interface UserSpec {\n firstName?: string;\n lastName?: string;\n nativeProvider?: NativeProvider;\n oauthProviders?: OAuthProvider[];\n}\n\nexport interface UserResource {\n kind: 'User';\n metadata: Metadata;\n spec: UserSpec;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqBjC,WAIC"}
1
+ {"version":3,"sources":["../../src/model/user.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Metadata } from './resource';\n\nexport interface NativeProvider {\n password?: string;\n}\n\nexport interface OAuthProvider {\n issuer?: string;\n email?: string;\n subject?: string;\n}\n\nexport interface UserSpec {\n firstName?: string;\n lastName?: string;\n nativeProvider?: NativeProvider;\n oauthProviders?: OAuthProvider[];\n}\n\nexport interface UserResource {\n kind: 'User';\n metadata: Metadata;\n spec: UserSpec;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqBjC,WAIC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/value-mapping.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type ValueMapping =\n | ValueMappingOptions\n | ValueMappingOptionsRange\n | ValueMappingOptionsRegex\n | ValueMappingOptionsMisc;\n\nexport interface ValueMappingOptions {\n kind: 'Value';\n spec: {\n value: string | number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRange {\n kind: 'Range';\n spec: {\n from?: number;\n to?: number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRegex {\n kind: 'Regex';\n spec: {\n pattern: string;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsMisc {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n result: MappedValue;\n };\n}\n\nexport interface MappedValue {\n value: number | string;\n color?: string;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyCjC,WAGC"}
1
+ {"version":3,"sources":["../../src/model/value-mapping.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport type ValueMapping =\n | ValueMappingOptions\n | ValueMappingOptionsRange\n | ValueMappingOptionsRegex\n | ValueMappingOptionsMisc;\n\nexport interface ValueMappingOptions {\n kind: 'Value';\n spec: {\n value: string | number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRange {\n kind: 'Range';\n spec: {\n from?: number;\n to?: number;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsRegex {\n kind: 'Regex';\n spec: {\n pattern: string;\n result: MappedValue;\n };\n}\n\nexport interface ValueMappingOptionsMisc {\n kind: 'Misc';\n spec: {\n value: 'empty' | 'null' | 'NaN' | 'true' | 'false';\n result: MappedValue;\n };\n}\n\nexport interface MappedValue {\n value: number | string;\n color?: string;\n}\n"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyCjC,WAGC"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/variables.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { Display } from './display';\nimport { Metadata, ProjectMetadata } from './resource';\n\nexport type VariableName = string;\n\nexport type VariableValue = string | string[] | null;\n\nexport interface VariableDisplay extends Display {\n hidden?: boolean;\n}\n\nexport interface VariableSpec {\n name: VariableName;\n display?: VariableDisplay;\n}\n\nexport interface TextVariableDefinition extends Definition<TextVariableSpec> {\n kind: 'TextVariable';\n}\n\nexport interface TextVariableSpec extends VariableSpec {\n value: string;\n constant?: boolean;\n}\n\nexport interface ListVariableDefinition extends Definition<ListVariableSpec> {\n kind: 'ListVariable';\n}\n\nexport interface ListVariableSpec<PluginSpec = UnknownSpec> extends VariableSpec {\n defaultValue?: VariableValue;\n allowMultiple: boolean;\n allowAllValue: boolean;\n customAllValue?: string;\n capturingRegexp?: string;\n sort?: string;\n plugin: Definition<PluginSpec>;\n}\n\nexport interface BuiltinVariableDefinition extends Definition<BuiltinVariableSpec> {\n kind: 'BuiltinVariable';\n}\n\nexport interface BuiltinVariableSpec extends VariableSpec {\n value: () => string;\n source: string;\n}\n\nexport type VariableDefinition = TextVariableDefinition | ListVariableDefinition;\n\n/**\n * A variable that belongs to a project.\n */\nexport interface VariableResource {\n kind: 'Variable';\n metadata: ProjectMetadata;\n spec: VariableDefinition;\n}\n\n/**\n * A global variable that doesn´t belong to a project.\n */\nexport interface GlobalVariableResource {\n kind: 'GlobalVariable';\n metadata: Metadata;\n spec: VariableDefinition;\n}\n\nexport type Variable = VariableResource | GlobalVariableResource;\n\nexport function getVariableProject(variable: Variable): string | undefined {\n return 'project' in variable.metadata ? variable.metadata.project : undefined;\n}\n\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n"],"names":["getVariableProject","variable","metadata","project","undefined","DEFAULT_ALL_VALUE"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyEjC,OAAO,SAASA,mBAAmBC,QAAkB;IACnD,OAAO,aAAaA,SAASC,QAAQ,GAAGD,SAASC,QAAQ,CAACC,OAAO,GAAGC;AACtE;AAEA,OAAO,MAAMC,oBAAoB,SAAkB"}
1
+ {"version":3,"sources":["../../src/model/variables.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { Display } from './display';\nimport { Metadata, ProjectMetadata } from './resource';\n\nexport type VariableName = string;\n\nexport type VariableValue = string | string[] | null;\n\nexport interface VariableDisplay extends Display {\n hidden?: boolean;\n}\n\nexport interface VariableSpec {\n name: VariableName;\n display?: VariableDisplay;\n}\n\nexport interface TextVariableDefinition extends Definition<TextVariableSpec> {\n kind: 'TextVariable';\n}\n\nexport interface TextVariableSpec extends VariableSpec {\n value: string;\n constant?: boolean;\n}\n\nexport interface ListVariableDefinition extends Definition<ListVariableSpec> {\n kind: 'ListVariable';\n}\n\nexport interface ListVariableSpec<PluginSpec = UnknownSpec> extends VariableSpec {\n defaultValue?: VariableValue;\n allowMultiple: boolean;\n allowAllValue: boolean;\n customAllValue?: string;\n capturingRegexp?: string;\n sort?: string;\n plugin: Definition<PluginSpec>;\n}\n\nexport interface BuiltinVariableDefinition extends Definition<BuiltinVariableSpec> {\n kind: 'BuiltinVariable';\n}\n\nexport interface BuiltinVariableSpec extends VariableSpec {\n value: () => string;\n source: string;\n}\n\nexport type VariableDefinition = TextVariableDefinition | ListVariableDefinition;\n\n/**\n * A variable that belongs to a project.\n */\nexport interface VariableResource {\n kind: 'Variable';\n metadata: ProjectMetadata;\n spec: VariableDefinition;\n}\n\n/**\n * A global variable that doesn´t belong to a project.\n */\nexport interface GlobalVariableResource {\n kind: 'GlobalVariable';\n metadata: Metadata;\n spec: VariableDefinition;\n}\n\nexport type Variable = VariableResource | GlobalVariableResource;\n\nexport function getVariableProject(variable: Variable): string | undefined {\n return 'project' in variable.metadata ? variable.metadata.project : undefined;\n}\n\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n"],"names":["getVariableProject","variable","metadata","project","undefined","DEFAULT_ALL_VALUE"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAyEjC,OAAO,SAASA,mBAAmBC,QAAkB;IACnD,OAAO,aAAaA,SAASC,QAAQ,GAAGD,SAASC,QAAQ,CAACC,OAAO,GAAGC;AACtE;AAEA,OAAO,MAAMC,oBAAoB,SAAkB"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/datasource.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema, pluginSchema } from './plugin';\nimport { displaySchema } from './display';\n\nexport const datasourceSpecSchema: z.ZodSchema<DatasourceSpec> = z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n});\n\nexport function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec> {\n return z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n });\n}\n\nexport const datasourceSchema = z.object({\n kind: z.literal('Datasource'),\n metadata: projectMetadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const globalDatasourceSchema = z.object({\n kind: z.literal('GlobalDatasource'),\n metadata: metadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const datasourcesSchema: z.Schema<Datasource> = z.discriminatedUnion('kind', [\n datasourceSchema,\n globalDatasourceSchema,\n]);\n\nexport const datasourceDefinitionSchema: z.Schema<DatasourceDefinition> = z.object({\n name: z.string().min(1),\n spec: datasourceSpecSchema,\n});\n\nexport function buildDatasourceDefinitionSchema(pluginSchema: PluginSchema): z.Schema<DatasourceDefinition> {\n return z.object({\n name: z.string().min(1),\n spec: buildDatasourceSpecSchema(pluginSchema),\n });\n}\n"],"names":["z","metadataSchema","projectMetadataSchema","pluginSchema","displaySchema","datasourceSpecSchema","object","display","optional","default","boolean","plugin","buildDatasourceSpecSchema","datasourceSchema","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AACnE,SAAuBC,YAAY,QAAQ,WAAW;AACtD,SAASC,aAAa,QAAQ,YAAY;AAE1C,OAAO,MAAMC,uBAAoDL,EAAEM,MAAM,CAAC;IACxEC,SAASH,cAAcI,QAAQ;IAC/BC,SAAST,EAAEU,OAAO;IAClBC,QAAQR;AACV,GAAG;AAEH,OAAO,SAASS,0BAA0BT,YAA0B;IAClE,OAAOH,EAAEM,MAAM,CAAC;QACdC,SAASH,cAAcI,QAAQ;QAC/BC,SAAST,EAAEU,OAAO;QAClBC,QAAQR;IACV;AACF;AAEA,OAAO,MAAMU,mBAAmBb,EAAEM,MAAM,CAAC;IACvCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUd;IACVe,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMa,yBAAyBlB,EAAEM,MAAM,CAAC;IAC7CQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUf;IACVgB,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMc,oBAA0CnB,EAAEoB,kBAAkB,CAAC,QAAQ;IAClFP;IACAK;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DrB,EAAEM,MAAM,CAAC;IACjFgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMZ;AACR,GAAG;AAEH,OAAO,SAASoB,gCAAgCtB,YAA0B;IACxE,OAAOH,EAAEM,MAAM,CAAC;QACdgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAML,0BAA0BT;IAClC;AACF"}
1
+ {"version":3,"sources":["../../src/schema/datasource.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\nimport { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema, pluginSchema } from './plugin';\nimport { displaySchema } from './display';\n\nexport const datasourceSpecSchema: z.ZodSchema<DatasourceSpec> = z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n});\n\nexport function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec> {\n return z.object({\n display: displaySchema.optional(),\n default: z.boolean(),\n plugin: pluginSchema,\n });\n}\n\nexport const datasourceSchema = z.object({\n kind: z.literal('Datasource'),\n metadata: projectMetadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const globalDatasourceSchema = z.object({\n kind: z.literal('GlobalDatasource'),\n metadata: metadataSchema,\n spec: datasourceSpecSchema,\n});\n\nexport const datasourcesSchema: z.Schema<Datasource> = z.discriminatedUnion('kind', [\n datasourceSchema,\n globalDatasourceSchema,\n]);\n\nexport const datasourceDefinitionSchema: z.Schema<DatasourceDefinition> = z.object({\n name: z.string().min(1),\n spec: datasourceSpecSchema,\n});\n\nexport function buildDatasourceDefinitionSchema(pluginSchema: PluginSchema): z.Schema<DatasourceDefinition> {\n return z.object({\n name: z.string().min(1),\n spec: buildDatasourceSpecSchema(pluginSchema),\n });\n}\n"],"names":["z","metadataSchema","projectMetadataSchema","pluginSchema","displaySchema","datasourceSpecSchema","object","display","optional","default","boolean","plugin","buildDatasourceSpecSchema","datasourceSchema","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AACnE,SAAuBC,YAAY,QAAQ,WAAW;AACtD,SAASC,aAAa,QAAQ,YAAY;AAE1C,OAAO,MAAMC,uBAAoDL,EAAEM,MAAM,CAAC;IACxEC,SAASH,cAAcI,QAAQ;IAC/BC,SAAST,EAAEU,OAAO;IAClBC,QAAQR;AACV,GAAG;AAEH,OAAO,SAASS,0BAA0BT,YAA0B;IAClE,OAAOH,EAAEM,MAAM,CAAC;QACdC,SAASH,cAAcI,QAAQ;QAC/BC,SAAST,EAAEU,OAAO;QAClBC,QAAQR;IACV;AACF;AAEA,OAAO,MAAMU,mBAAmBb,EAAEM,MAAM,CAAC;IACvCQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUd;IACVe,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMa,yBAAyBlB,EAAEM,MAAM,CAAC;IAC7CQ,MAAMd,EAAEe,OAAO,CAAC;IAChBC,UAAUf;IACVgB,MAAMZ;AACR,GAAG;AAEH,OAAO,MAAMc,oBAA0CnB,EAAEoB,kBAAkB,CAAC,QAAQ;IAClFP;IACAK;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DrB,EAAEM,MAAM,CAAC;IACjFgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMZ;AACR,GAAG;AAEH,OAAO,SAASoB,gCAAgCtB,YAA0B;IACxE,OAAOH,EAAEM,MAAM,CAAC;QACdgB,MAAMtB,EAAEuB,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAML,0BAA0BT;IAClC;AACF"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/display.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\n\nexport const displaySchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n});\n"],"names":["z","displaySchema","object","name","string","optional","description"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,gBAAgBD,EAAEE,MAAM,CAAC;IACpCC,MAAMH,EAAEI,MAAM,GAAGC,QAAQ;IACzBC,aAAaN,EAAEI,MAAM,GAAGC,QAAQ;AAClC,GAAG"}
1
+ {"version":3,"sources":["../../src/schema/display.ts"],"sourcesContent":["// Copyright The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\n\nexport const displaySchema = z.object({\n name: z.string().optional(),\n description: z.string().optional(),\n});\n"],"names":["z","displaySchema","object","name","string","optional","description"],"mappings":"AAAA,+BAA+B;AAC/B,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,gBAAgBD,EAAEE,MAAM,CAAC;IACpCC,MAAMH,EAAEI,MAAM,GAAGC,QAAQ;IACzBC,aAAaN,EAAEI,MAAM,GAAGC,QAAQ;AAClC,GAAG"}
@@ -1,4 +1,4 @@
1
- // Copyright 2024 The Perses Authors
1
+ // Copyright The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at