@perses-dev/core 0.53.0 → 0.54.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/cjs/constants/dashboard-defaults.js +3 -3
  2. package/dist/cjs/model/calculations.js +6 -6
  3. package/dist/cjs/model/definitions.js +1 -3
  4. package/dist/cjs/model/folder.js +16 -0
  5. package/dist/cjs/model/index.js +1 -0
  6. package/dist/cjs/model/legend.js +11 -11
  7. package/dist/cjs/model/otlp/index.js +4 -4
  8. package/dist/cjs/model/otlp/trace/v1/trace.js +4 -4
  9. package/dist/cjs/model/resource.js +3 -3
  10. package/dist/cjs/model/roles.js +4 -4
  11. package/dist/cjs/model/time.js +21 -309
  12. package/dist/cjs/model/units/bits.js +14 -6
  13. package/dist/cjs/model/units/bytes.js +16 -6
  14. package/dist/cjs/model/units/currency.js +14 -6
  15. package/dist/cjs/model/units/date.js +4 -4
  16. package/dist/cjs/model/units/decimal.js +13 -6
  17. package/dist/cjs/model/units/formatterCache.js +120 -0
  18. package/dist/cjs/model/units/percent.js +13 -6
  19. package/dist/cjs/model/units/temperature.js +13 -5
  20. package/dist/cjs/model/units/throughput.js +15 -6
  21. package/dist/cjs/model/units/time.js +15 -7
  22. package/dist/cjs/model/units/units.js +18 -18
  23. package/dist/cjs/model/units/utils.js +4 -4
  24. package/dist/cjs/model/variables.js +3 -3
  25. package/dist/cjs/schema/datasource.js +13 -29
  26. package/dist/cjs/schema/display.js +2 -6
  27. package/dist/cjs/schema/duration.js +2 -4
  28. package/dist/cjs/schema/metadata.js +4 -4
  29. package/dist/cjs/schema/panel.js +20 -72
  30. package/dist/cjs/schema/plugin.js +2 -6
  31. package/dist/cjs/schema/role.js +6 -6
  32. package/dist/cjs/schema/rolebinding.js +6 -6
  33. package/dist/cjs/schema/secret.js +5 -5
  34. package/dist/cjs/schema/user.js +5 -5
  35. package/dist/cjs/schema/variable.js +24 -137
  36. package/dist/cjs/utils/fetch.js +5 -5
  37. package/dist/cjs/utils/panel-refs.js +4 -4
  38. package/dist/cjs/utils/regexp.js +3 -3
  39. package/dist/cjs/utils/text.js +7 -7
  40. package/dist/cjs/utils/time-series-data.js +4 -4
  41. package/dist/cjs/utils/transform-data.js +6 -6
  42. package/dist/model/dashboard.d.ts +2 -21
  43. package/dist/model/dashboard.d.ts.map +1 -1
  44. package/dist/model/dashboard.js.map +1 -1
  45. package/dist/model/datasource.d.ts +3 -22
  46. package/dist/model/datasource.d.ts.map +1 -1
  47. package/dist/model/datasource.js +1 -3
  48. package/dist/model/datasource.js.map +1 -1
  49. package/dist/model/definitions.d.ts +1 -12
  50. package/dist/model/definitions.d.ts.map +1 -1
  51. package/dist/model/definitions.js +1 -6
  52. package/dist/model/definitions.js.map +1 -1
  53. package/dist/model/display.d.ts +1 -4
  54. package/dist/model/display.d.ts.map +1 -1
  55. package/dist/model/display.js.map +1 -1
  56. package/dist/model/folder.d.ts +19 -0
  57. package/dist/model/folder.d.ts.map +1 -0
  58. package/dist/model/folder.js +15 -0
  59. package/dist/model/folder.js.map +1 -0
  60. package/dist/model/index.d.ts +1 -0
  61. package/dist/model/index.d.ts.map +1 -1
  62. package/dist/model/index.js +1 -0
  63. package/dist/model/index.js.map +1 -1
  64. package/dist/model/project.d.ts +1 -1
  65. package/dist/model/project.d.ts.map +1 -1
  66. package/dist/model/project.js.map +1 -1
  67. package/dist/model/query.d.ts +1 -0
  68. package/dist/model/query.d.ts.map +1 -1
  69. package/dist/model/query.js.map +1 -1
  70. package/dist/model/resource.d.ts +1 -1
  71. package/dist/model/resource.d.ts.map +1 -1
  72. package/dist/model/resource.js.map +1 -1
  73. package/dist/model/time.d.ts +3 -54
  74. package/dist/model/time.d.ts.map +1 -1
  75. package/dist/model/time.js +2 -299
  76. package/dist/model/time.js.map +1 -1
  77. package/dist/model/units/bits.d.ts.map +1 -1
  78. package/dist/model/units/bits.js +10 -2
  79. package/dist/model/units/bits.js.map +1 -1
  80. package/dist/model/units/bytes.d.ts.map +1 -1
  81. package/dist/model/units/bytes.js +12 -2
  82. package/dist/model/units/bytes.js.map +1 -1
  83. package/dist/model/units/currency.d.ts.map +1 -1
  84. package/dist/model/units/currency.js +10 -2
  85. package/dist/model/units/currency.js.map +1 -1
  86. package/dist/model/units/decimal.d.ts.map +1 -1
  87. package/dist/model/units/decimal.js +9 -2
  88. package/dist/model/units/decimal.js.map +1 -1
  89. package/dist/model/units/formatterCache.d.ts +11 -0
  90. package/dist/model/units/formatterCache.d.ts.map +1 -0
  91. package/dist/model/units/formatterCache.js +104 -0
  92. package/dist/model/units/formatterCache.js.map +1 -0
  93. package/dist/model/units/percent.d.ts.map +1 -1
  94. package/dist/model/units/percent.js +9 -2
  95. package/dist/model/units/percent.js.map +1 -1
  96. package/dist/model/units/temperature.d.ts.map +1 -1
  97. package/dist/model/units/temperature.js +9 -1
  98. package/dist/model/units/temperature.js.map +1 -1
  99. package/dist/model/units/throughput.d.ts.map +1 -1
  100. package/dist/model/units/throughput.js +11 -2
  101. package/dist/model/units/throughput.js.map +1 -1
  102. package/dist/model/units/time.d.ts.map +1 -1
  103. package/dist/model/units/time.js +10 -2
  104. package/dist/model/units/time.js.map +1 -1
  105. package/dist/schema/datasource.d.ts +10 -9
  106. package/dist/schema/datasource.d.ts.map +1 -1
  107. package/dist/schema/datasource.js +2 -14
  108. package/dist/schema/datasource.js.map +1 -1
  109. package/dist/schema/display.d.ts +1 -11
  110. package/dist/schema/display.d.ts.map +1 -1
  111. package/dist/schema/display.js +1 -5
  112. package/dist/schema/display.js.map +1 -1
  113. package/dist/schema/duration.d.ts +1 -2
  114. package/dist/schema/duration.d.ts.map +1 -1
  115. package/dist/schema/duration.js +1 -3
  116. package/dist/schema/duration.js.map +1 -1
  117. package/dist/schema/panel.d.ts +1 -12
  118. package/dist/schema/panel.d.ts.map +1 -1
  119. package/dist/schema/panel.js +1 -53
  120. package/dist/schema/panel.js.map +1 -1
  121. package/dist/schema/plugin.d.ts +2 -13
  122. package/dist/schema/plugin.d.ts.map +1 -1
  123. package/dist/schema/plugin.js +1 -5
  124. package/dist/schema/plugin.js.map +1 -1
  125. package/dist/schema/role.d.ts +4 -4
  126. package/dist/schema/rolebinding.d.ts +4 -4
  127. package/dist/schema/secret.d.ts +70 -70
  128. package/dist/schema/variable.d.ts +1 -91
  129. package/dist/schema/variable.d.ts.map +1 -1
  130. package/dist/schema/variable.js +1 -105
  131. package/dist/schema/variable.js.map +1 -1
  132. package/dist/utils/fetch.js.map +1 -1
  133. package/dist/utils/text.js +4 -4
  134. package/dist/utils/text.js.map +1 -1
  135. package/package.json +3 -2
@@ -0,0 +1,104 @@
1
+ // Copyright The Perses Authors
2
+ // Licensed under the Apache License, Version 2.0 (the "License");
3
+ // you may not use this file except in compliance with the License.
4
+ // You may obtain a copy of the License at
5
+ //
6
+ // http://www.apache.org/licenses/LICENSE-2.0
7
+ //
8
+ // Unless required by applicable law or agreed to in writing, software
9
+ // distributed under the License is distributed on an "AS IS" BASIS,
10
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ // See the License for the specific language governing permissions and
12
+ // limitations under the License.
13
+ /**
14
+ * REASONING FOR CLUSTERING (Map-of-Maps):
15
+ *
16
+ * 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to
17
+ * locale/data lookups. Clustering allows 100x faster reuse via caching.
18
+ *
19
+ *
20
+ * 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash
21
+ * collisions, ensuring O(1) retrieval time remains consistent even as
22
+ * the total number of formatters across the app grows.
23
+ *
24
+ * 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory
25
+ * monitoring and easier debugging of which specific data types are
26
+ * consuming the most resources.
27
+ */ const TIME_FORMATTER_CACHE = new Map();
28
+ const DECIMAL_FORMATTER_CACHE = new Map();
29
+ const BITS_FORMATTER_CACHE = new Map();
30
+ const BYTES_FORMATTER_CACHE = new Map();
31
+ const CURRENCY_FORMATTER_CACHE = new Map();
32
+ const PERCENT_FORMATTER_CACHE = new Map();
33
+ const TEMPERATURE_FORMATTER_CACHE = new Map();
34
+ const THROUGHPUT_FORMATTER_CACHE = new Map();
35
+ const ALL_FORMATTERS = new Map([
36
+ [
37
+ 'time',
38
+ TIME_FORMATTER_CACHE
39
+ ],
40
+ [
41
+ 'decimal',
42
+ DECIMAL_FORMATTER_CACHE
43
+ ],
44
+ [
45
+ 'bits',
46
+ BITS_FORMATTER_CACHE
47
+ ],
48
+ [
49
+ 'bytes',
50
+ BYTES_FORMATTER_CACHE
51
+ ],
52
+ [
53
+ 'currency',
54
+ CURRENCY_FORMATTER_CACHE
55
+ ],
56
+ [
57
+ 'percent',
58
+ PERCENT_FORMATTER_CACHE
59
+ ],
60
+ [
61
+ 'temperature',
62
+ TEMPERATURE_FORMATTER_CACHE
63
+ ],
64
+ [
65
+ 'throughput',
66
+ THROUGHPUT_FORMATTER_CACHE
67
+ ]
68
+ ]);
69
+ export function getFormatterFromCache(key, inputType, formatterOptions, locals = 'en-US') {
70
+ const compoundKey = `${key.filter((k)=>![
71
+ undefined,
72
+ null,
73
+ '',
74
+ NaN
75
+ ].includes(k)).join('|')}|${locals}`;
76
+ const inputTypeFormatters = ALL_FORMATTERS.get(inputType);
77
+ if (!inputTypeFormatters) throw new Error('No formatter found for the input type');
78
+ const formatter = inputTypeFormatters.get(compoundKey);
79
+ if (formatter) {
80
+ return formatter.format;
81
+ }
82
+ const newFormatter = Intl.NumberFormat(locals, formatterOptions);
83
+ inputTypeFormatters?.set(`${compoundKey}`, newFormatter);
84
+ return newFormatter.format;
85
+ }
86
+ export const getFormatterStats = ()=>{
87
+ const countCacheItems = (inputType)=>{
88
+ if (inputType !== 'all') {
89
+ return ALL_FORMATTERS.get(inputType)?.size ?? 0;
90
+ }
91
+ return Array.from(ALL_FORMATTERS.values()).reduce((acc, map)=>acc + (map?.size ?? 0), 0);
92
+ };
93
+ const getKeys = (inputType)=>{
94
+ return [
95
+ ...ALL_FORMATTERS.get(inputType)?.keys() || []
96
+ ];
97
+ };
98
+ return {
99
+ countCacheItems,
100
+ getKeys
101
+ };
102
+ };
103
+
104
+ //# sourceMappingURL=formatterCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/model/units/formatterCache.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\ntype FormatFn = (value: number | bigint) => string;\ntype InputType = 'time' | 'temperature' | 'bytes' | 'bits' | 'decimal' | 'currency' | 'percent' | 'throughput';\ntype Locals = 'en-US' | 'en-GB';\n\n/**\n * REASONING FOR CLUSTERING (Map-of-Maps):\n *\n * 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to\n * locale/data lookups. Clustering allows 100x faster reuse via caching.\n *\n *\n * 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash\n * collisions, ensuring O(1) retrieval time remains consistent even as\n * the total number of formatters across the app grows.\n *\n * 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory\n * monitoring and easier debugging of which specific data types are\n * consuming the most resources.\n */\nconst TIME_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst DECIMAL_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst BITS_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst BYTES_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst CURRENCY_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst PERCENT_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst TEMPERATURE_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\nconst THROUGHPUT_FORMATTER_CACHE = new Map<string, Intl.NumberFormat>();\n\nconst ALL_FORMATTERS: Map<InputType, Map<string, Intl.NumberFormat>> = new Map([\n ['time', TIME_FORMATTER_CACHE],\n ['decimal', DECIMAL_FORMATTER_CACHE],\n ['bits', BITS_FORMATTER_CACHE],\n ['bytes', BYTES_FORMATTER_CACHE],\n ['currency', CURRENCY_FORMATTER_CACHE],\n ['percent', PERCENT_FORMATTER_CACHE],\n ['temperature', TEMPERATURE_FORMATTER_CACHE],\n ['throughput', THROUGHPUT_FORMATTER_CACHE],\n]);\n\nexport function getFormatterFromCache(\n key: Array<string | number | boolean | undefined>,\n inputType: InputType,\n formatterOptions: Intl.NumberFormatOptions,\n locals: Locals = 'en-US'\n): FormatFn {\n const compoundKey = `${key.filter((k) => !([undefined, null, '', NaN] as unknown[]).includes(k)).join('|')}|${locals}`;\n const inputTypeFormatters = ALL_FORMATTERS.get(inputType);\n if (!inputTypeFormatters) throw new Error('No formatter found for the input type');\n\n const formatter = inputTypeFormatters.get(compoundKey);\n if (formatter) {\n return formatter.format;\n }\n\n const newFormatter = Intl.NumberFormat(locals, formatterOptions);\n inputTypeFormatters?.set(`${compoundKey}`, newFormatter);\n\n return newFormatter.format;\n}\n\n/* This is a small utility for unit tests */\nexport interface IFormatterStats {\n countCacheItems: (inputType: InputType | 'all') => number;\n getKeys: (inputType: InputType) => string[];\n}\n\nexport const getFormatterStats = (): IFormatterStats => {\n const countCacheItems = (inputType: InputType | 'all'): number => {\n if (inputType !== 'all') {\n return ALL_FORMATTERS.get(inputType)?.size ?? 0;\n }\n\n return Array.from(ALL_FORMATTERS.values()).reduce((acc, map) => acc + (map?.size ?? 0), 0);\n };\n\n const getKeys = (inputType: InputType): string[] => {\n return [...(ALL_FORMATTERS.get(inputType)?.keys() || [])];\n };\n\n return { countCacheItems, getKeys };\n};\n"],"names":["TIME_FORMATTER_CACHE","Map","DECIMAL_FORMATTER_CACHE","BITS_FORMATTER_CACHE","BYTES_FORMATTER_CACHE","CURRENCY_FORMATTER_CACHE","PERCENT_FORMATTER_CACHE","TEMPERATURE_FORMATTER_CACHE","THROUGHPUT_FORMATTER_CACHE","ALL_FORMATTERS","getFormatterFromCache","key","inputType","formatterOptions","locals","compoundKey","filter","k","undefined","NaN","includes","join","inputTypeFormatters","get","Error","formatter","format","newFormatter","Intl","NumberFormat","set","getFormatterStats","countCacheItems","size","Array","from","values","reduce","acc","map","getKeys","keys"],"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;AAMjC;;;;;;;;;;;;;;CAcC,GACD,MAAMA,uBAAuB,IAAIC;AACjC,MAAMC,0BAA0B,IAAID;AACpC,MAAME,uBAAuB,IAAIF;AACjC,MAAMG,wBAAwB,IAAIH;AAClC,MAAMI,2BAA2B,IAAIJ;AACrC,MAAMK,0BAA0B,IAAIL;AACpC,MAAMM,8BAA8B,IAAIN;AACxC,MAAMO,6BAA6B,IAAIP;AAEvC,MAAMQ,iBAAiE,IAAIR,IAAI;IAC7E;QAAC;QAAQD;KAAqB;IAC9B;QAAC;QAAWE;KAAwB;IACpC;QAAC;QAAQC;KAAqB;IAC9B;QAAC;QAASC;KAAsB;IAChC;QAAC;QAAYC;KAAyB;IACtC;QAAC;QAAWC;KAAwB;IACpC;QAAC;QAAeC;KAA4B;IAC5C;QAAC;QAAcC;KAA2B;CAC3C;AAED,OAAO,SAASE,sBACdC,GAAiD,EACjDC,SAAoB,EACpBC,gBAA0C,EAC1CC,SAAiB,OAAO;IAExB,MAAMC,cAAc,GAAGJ,IAAIK,MAAM,CAAC,CAACC,IAAM,CAAC,AAAC;YAACC;YAAW;YAAM;YAAIC;SAAI,CAAeC,QAAQ,CAACH,IAAII,IAAI,CAAC,KAAK,CAAC,E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a,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,MAAM,CAoBlG"}
1
+ {"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../../src/model/units/percent.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,WAAW,GAAG,SAAS,GAAG,iBAAiB,GAAG,GAAG,CAAC;AACvD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,eAGlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,CAgBzE,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,oBAAoB,GAAG,MAAM,CA2BlG"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { MAX_SIGNIFICANT_DIGITS } from './constants';
14
+ import { getFormatterFromCache } from './formatterCache';
14
15
  import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
15
16
  export const PERCENT_GROUP_CONFIG = {
16
17
  label: 'percent',
@@ -49,8 +50,14 @@ export function formatPercent(value, { unit, decimalPlaces }) {
49
50
  if (unit === 'percent') {
50
51
  value = value / 100;
51
52
  }
52
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
53
- return formatter.format(value);
53
+ const key = [
54
+ formatterOptions.style,
55
+ formatterOptions.useGrouping,
56
+ formatterOptions.maximumSignificantDigits,
57
+ decimalPlaces,
58
+ unit
59
+ ];
60
+ return getFormatterFromCache(key, 'percent', formatterOptions, 'en-US')(value);
54
61
  }
55
62
 
56
63
  //# sourceMappingURL=percent.js.map
@@ -1 +1 @@
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
+ {"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 { getFormatterFromCache } from './formatterCache';\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 key = [\n formatterOptions.style,\n formatterOptions.useGrouping,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n unit,\n ];\n\n return getFormatterFromCache(key, 'percent', formatterOptions, 'en-US')(value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","getFormatterFromCache","hasDecimalPlaces","limitDecimalPlaces","PERCENT_GROUP_CONFIG","label","decimalPlaces","PERCENT_GROUP","PERCENT_UNIT_CONFIG","percent","group","disableSelectorOption","formatPercent","value","unit","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","key"],"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;AACrD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,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,GAAGpB;IAC9C;IAEA,oEAAoE;IACpE,IAAIc,SAAS,WAAW;QACtBD,QAAQA,QAAQ;IAClB;IAEA,MAAMQ,MAAM;QACVN,iBAAiBC,KAAK;QACtBD,iBAAiBE,WAAW;QAC5BF,iBAAiBK,wBAAwB;QACzCd;QACAQ;KACD;IAED,OAAOb,sBAAsBoB,KAAK,WAAWN,kBAAkB,SAASF;AAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../../src/model/units/temperature.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKtD,KAAK,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CASlF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,2BAA2B,wBAAwB,KAAG,MAepG,CAAC"}
1
+ {"version":3,"file":"temperature.d.ts","sourceRoot":"","sources":["../../../src/model/units/temperature.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKtD,KAAK,gBAAgB,GAAG,SAAS,GAAG,YAAY,CAAC;AAEjD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,gBAAgB,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,UAAU,CAAC,CASlF,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,MAAM,2BAA2B,wBAAwB,KAAG,MAwBpG,CAAC"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { MAX_SIGNIFICANT_DIGITS } from './constants';
14
+ import { getFormatterFromCache } from './formatterCache';
14
15
  import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
15
16
  const TEMPERATURE_GROUP = 'Temperature';
16
17
  export const TEMPERATURE_GROUP_CONFIG = {
@@ -39,7 +40,14 @@ export const formatTemperature = (value, { unit, decimalPlaces })=>{
39
40
  formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
40
41
  }
41
42
  const locals = unit === 'celsius' ? 'en-GB' : 'en-US';
42
- return Intl.NumberFormat(locals, formatterOptions).format(value);
43
+ const key = [
44
+ formatterOptions.style,
45
+ formatterOptions.unit,
46
+ formatterOptions.maximumSignificantDigits,
47
+ decimalPlaces,
48
+ locals
49
+ ];
50
+ return getFormatterFromCache(key, 'temperature', formatterOptions, locals)(value);
43
51
  };
44
52
 
45
53
  //# sourceMappingURL=temperature.js.map
@@ -1 +1 @@
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
+ {"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 { getFormatterFromCache } from './formatterCache';\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\n const key = [\n formatterOptions.style,\n formatterOptions.unit,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n locals,\n ];\n\n return getFormatterFromCache(key, 'temperature', formatterOptions, locals)(value);\n};\n"],"names":["MAX_SIGNIFICANT_DIGITS","getFormatterFromCache","hasDecimalPlaces","limitDecimalPlaces","TEMPERATURE_GROUP","TEMPERATURE_GROUP_CONFIG","label","decimalPlaces","TEMPERATURE_UNIT_CONFIG","celsius","group","fahrenheit","formatTemperature","value","unit","formatterOptions","style","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","locals","key"],"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;AACrD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,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,GAAGnB;IAC9C;IAEA,MAAMoB,SAASN,SAAS,YAAY,UAAU;IAE9C,MAAMO,MAAM;QACVN,iBAAiBC,KAAK;QACtBD,iBAAiBD,IAAI;QACrBC,iBAAiBI,wBAAwB;QACzCZ;QACAa;KACD;IAED,OAAOnB,sBAAsBoB,KAAK,eAAeN,kBAAkBK,QAAQP;AAC7E,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"throughput.d.ts","sourceRoot":"","sources":["../../../src/model/units/throughput.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,cAAc,GACf,UAAU,GACV,aAAa,GACb,WAAW,GACX,cAAc,GACd,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,SAAS,GACT,aAAa,GACb,WAAW,GACX,aAAa,GACb,cAAc,GACd,UAAU,GACV,YAAY,CAAC;AACjB,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,uBAAuB,EAAE,eAGrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CA0D/E,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,GAAG,MAAM,CA0CrH"}
1
+ {"version":3,"file":"throughput.d.ts","sourceRoot":"","sources":["../../../src/model/units/throughput.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAItD,KAAK,cAAc,GACf,UAAU,GACV,aAAa,GACb,WAAW,GACX,cAAc,GACd,YAAY,GACZ,YAAY,GACZ,cAAc,GACd,SAAS,GACT,aAAa,GACb,WAAW,GACX,aAAa,GACb,cAAc,GACd,UAAU,GACV,YAAY,CAAC;AACjB,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,uBAAuB,EAAE,eAGrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,MAAM,CAAC,cAAc,EAAE,UAAU,CAAC,CA0D/E,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAmDrH"}
@@ -14,6 +14,7 @@ import { formatBytes } from './bytes';
14
14
  import { formatBits } from './bits';
15
15
  import { MAX_SIGNIFICANT_DIGITS } from './constants';
16
16
  import { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';
17
+ import { getFormatterFromCache } from './formatterCache';
17
18
  export const THROUGHPUT_GROUP_CONFIG = {
18
19
  label: 'Throughput',
19
20
  decimalPlaces: true
@@ -126,8 +127,16 @@ export function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
126
127
  formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
127
128
  }
128
129
  }
129
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
130
- return formatter.format(value) + ' ' + unit;
130
+ const key = [
131
+ formatterOptions.style,
132
+ formatterOptions.useGrouping,
133
+ formatterOptions.notation,
134
+ formatterOptions.maximumSignificantDigits,
135
+ decimalPlaces,
136
+ shortValues,
137
+ unit
138
+ ];
139
+ return `${getFormatterFromCache(key, 'throughput', formatterOptions, 'en-US')(value)} ${unit}`;
131
140
  }
132
141
 
133
142
  //# sourceMappingURL=throughput.js.map
@@ -1 +1 @@
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,SAA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MQ;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';\nimport { getFormatterFromCache } from './formatterCache';\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 key = [\n formatterOptions.style,\n formatterOptions.useGrouping,\n formatterOptions.notation,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n shortValues,\n unit,\n ];\n\n return `${getFormatterFromCache(key, 'throughput', formatterOptions, 'en-US')(value)} ${unit}`;\n}\n"],"names":["formatBytes","formatBits","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","getFormatterFromCache","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","key"],"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;AACpF,SAASC,qBAAqB,QAAQ,mBAAmB;AAsBzD,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,E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AAkB,SAASN,OAAO,CAAC,EAAEC,MAAM;AAChG"}
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/units/time.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,SAAS,GACV,aAAa,GACb,cAAc,GACd,cAAc,GACd,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAG/B,CAAC;AACF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAyCpE,CAAC;AAIF,oBAAY,oBAAoB;IAC9B,WAAW,eAAe;IAC1B,YAAY,gBAAgB;IAC5B,YAAY,gBAAgB;IAC5B,OAAO,WAAW;IAClB,OAAO,WAAW;IAClB,KAAK,SAAS;IACd,IAAI,QAAQ;IACZ,KAAK,SAAS;IACd,MAAM,UAAU;IAChB,KAAK,SAAS;CACf;AA4DD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAoB5F"}
1
+ {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../../src/model/units/time.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,SAAS,GACV,aAAa,GACb,cAAc,GACd,cAAc,GACd,SAAS,GACT,SAAS,GACT,OAAO,GACP,MAAM,GACN,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AACZ,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAG/B,CAAC;AACF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAyCpE,CAAC;AAIF,oBAAY,oBAAoB;IAC9B,WAAW,eAAe;IAC1B,YAAY,gBAAgB;IAC5B,YAAY,gBAAgB;IAC5B,OAAO,WAAW;IAClB,OAAO,WAAW;IAClB,KAAK,SAAS;IACd,IAAI,QAAQ;IACZ,KAAK,SAAS;IACd,MAAM,UAAU;IAChB,KAAK,SAAS;CACf;AA4DD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,iBAAiB,GAAG,MAAM,CA4B5F"}
@@ -11,6 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { MAX_SIGNIFICANT_DIGITS } from './constants';
14
+ import { getFormatterFromCache } from './formatterCache';
14
15
  import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
15
16
  const TIME_GROUP = 'Time';
16
17
  export const TIME_GROUP_CONFIG = {
@@ -143,8 +144,15 @@ export function formatTime(value, { unit, decimalPlaces }) {
143
144
  } else {
144
145
  formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
145
146
  }
146
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
147
- return formatter.format(results.value);
147
+ const key = [
148
+ formatterOptions.style,
149
+ formatterOptions.unit,
150
+ formatterOptions.unitDisplay,
151
+ formatterOptions.maximumSignificantDigits,
152
+ decimalPlaces,
153
+ unit ?? 'seconds'
154
+ ];
155
+ return getFormatterFromCache(key, 'time', formatterOptions, 'en-US')(results.value);
148
156
  }
149
157
 
150
158
  //# sourceMappingURL=time.js.map
@@ -1 +1 @@
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;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Ae;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 { getFormatterFromCache } from './formatterCache';\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 key = [\n formatterOptions.style,\n formatterOptions.unit,\n formatterOptions.unitDisplay,\n formatterOptions.maximumSignificantDigits,\n decimalPlaces,\n unit ?? 'seconds',\n ];\n\n return getFormatterFromCache(key, 'time', formatterOptions, 'en-US')(results.value);\n}\n"],"names":["MAX_SIGNIFICANT_DIGITS","getFormatterFromCache","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","key"],"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;AACrD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,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;IACAY,QAAQ;QACNR,OAAON;QACPE,OAAO;IACT;IACAa,OAAO;QACLT,OAAON;QACPE,OAAO;IACT;AACF,EAAE;AAEF,oEAAoE;AACpE,k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I,qBAAqB,GAAGlC,mBAAmBI;IAC9D,OAAO;QACL0B,iBAAiBK,wBAAwB,GAAGtC;IAC9C;IAEA,MAAMuC,MAAM;QACVN,iBAAiBC,KAAK;QACtBD,iBAAiBR,IAAI;QACrBQ,iBAAiBE,WAAW;QAC5BF,iBAAiBK,wBAAwB;QACzC/B;QACAkB,QAAQ;KACT;IAED,OAAOxB,sBAAsBsC,KAAK,QAAQN,kBAAkB,SAASD,QAAQR,KAAK;AACpF"}
@@ -1,8 +1,9 @@
1
+ import { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';
1
2
  import { z } from 'zod';
2
- import { Datasource, DatasourceDefinition, DatasourceSpec } from '../model';
3
+ import { Datasource, DatasourceDefinition } from '../model';
3
4
  import { PluginSchema } from './plugin';
4
- export declare const datasourceSpecSchema: z.ZodSchema<DatasourceSpec>;
5
- export declare function buildDatasourceSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<DatasourceSpec>;
5
+ export type { datasourceSpecSchema };
6
+ export { buildDatasourceSpecSchema };
6
7
  export declare const datasourceSchema: z.ZodObject<{
7
8
  kind: z.ZodLiteral<"Datasource">;
8
9
  metadata: z.ZodObject<{
@@ -16,21 +17,21 @@ export declare const datasourceSchema: z.ZodObject<{
16
17
  name: string;
17
18
  project: string;
18
19
  }>;
19
- spec: z.ZodType<DatasourceSpec<import("../model").UnknownSpec>, z.ZodTypeDef, DatasourceSpec<import("../model").UnknownSpec>>;
20
+ spec: z.ZodType<import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>, z.ZodTypeDef, import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>>;
20
21
  }, "strip", z.ZodTypeAny, {
21
22
  kind: "Datasource";
22
- spec: DatasourceSpec<import("../model").UnknownSpec>;
23
23
  metadata: {
24
24
  name: string;
25
25
  project: string;
26
26
  };
27
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
27
28
  }, {
28
29
  kind: "Datasource";
29
- spec: DatasourceSpec<import("../model").UnknownSpec>;
30
30
  metadata: {
31
31
  name: string;
32
32
  project: string;
33
33
  };
34
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
34
35
  }>;
35
36
  export declare const globalDatasourceSchema: z.ZodObject<{
36
37
  kind: z.ZodLiteral<"GlobalDatasource">;
@@ -41,19 +42,19 @@ export declare const globalDatasourceSchema: z.ZodObject<{
41
42
  }, {
42
43
  name: string;
43
44
  }>;
44
- spec: z.ZodType<DatasourceSpec<import("../model").UnknownSpec>, z.ZodTypeDef, DatasourceSpec<import("../model").UnknownSpec>>;
45
+ spec: z.ZodType<import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>, z.ZodTypeDef, import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>>;
45
46
  }, "strip", z.ZodTypeAny, {
46
47
  kind: "GlobalDatasource";
47
- spec: DatasourceSpec<import("../model").UnknownSpec>;
48
48
  metadata: {
49
49
  name: string;
50
50
  };
51
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
51
52
  }, {
52
53
  kind: "GlobalDatasource";
53
- spec: DatasourceSpec<import("../model").UnknownSpec>;
54
54
  metadata: {
55
55
  name: string;
56
56
  };
57
+ spec: import("@perses-dev/spec").DatasourceSpec<import("@perses-dev/spec").UnknownSpec>;
57
58
  }>;
58
59
  export declare const datasourcesSchema: z.Schema<Datasource>;
59
60
  export declare const datasourceDefinitionSchema: z.Schema<DatasourceDefinition>;
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/schema/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAE,YAAY,EA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AC,oBAAoB,CAGpE,CAAC;AAEH,wBAAgB,+BAA+B,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAK1G"}
@@ -10,22 +10,10 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ import { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';
13
14
  import { z } from 'zod';
14
15
  import { metadataSchema, projectMetadataSchema } from './metadata';
15
- import { pluginSchema } from './plugin';
16
- import { displaySchema } from './display';
17
- export const datasourceSpecSchema = z.object({
18
- display: displaySchema.optional(),
19
- default: z.boolean(),
20
- plugin: pluginSchema
21
- });
22
- export function buildDatasourceSpecSchema(pluginSchema) {
23
- return z.object({
24
- display: displaySchema.optional(),
25
- default: z.boolean(),
26
- plugin: pluginSchema
27
- });
28
- }
16
+ export { buildDatasourceSpecSchema };
29
17
  export const datasourceSchema = z.object({
30
18
  kind: z.literal('Datasource'),
31
19
  metadata: projectMetadataSchema,
@@ -1 +1 @@
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
+ {"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 { datasourceSpecSchema, buildDatasourceSpecSchema } from '@perses-dev/spec';\nimport { z } from 'zod';\nimport { Datasource, DatasourceDefinition } from '../model';\nimport { metadataSchema, projectMetadataSchema } from './metadata';\nimport { PluginSchema } from './plugin';\nexport type { datasourceSpecSchema };\nexport { buildDatasourceSpecSchema };\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":["datasourceSpecSchema","buildDatasourceSpecSchema","z","metadataSchema","projectMetadataSchema","datasourceSchema","object","kind","literal","metadata","spec","globalDatasourceSchema","datasourcesSchema","discriminatedUnion","datasourceDefinitionSchema","name","string","min","buildDatasourceDefinitionSchema","pluginSchema"],"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,oBAAoB,EAAEC,yBAAyB,QAAQ,mBAAmB;AACnF,SAASC,CAAC,QAAQ,MAAM;AAExB,SAASC,cAAc,EAAEC,qBAAqB,QAAQ,aAAa;AAGnE,SAASH,yBAAyB,GAAG;AAErC,OAAO,MAAMI,mBAAmBH,EAAEI,MAAM,CAAC;IACvCC,MAAML,EAAEM,OAAO,CAAC;IAChBC,UAAUL;IACVM,MAAMV;AACR,GAAG;AAEH,OAAO,MAAMW,yBAAyBT,EAAEI,MAAM,CAAC;IAC7CC,MAAML,EAAEM,OAAO,CAAC;IAChBC,UAAUN;IACVO,MAAMV;AACR,GAAG;AAEH,OAAO,MAAMY,oBAA0CV,EAAEW,kBAAkB,CAAC,QAAQ;IAClFR;IACAM;CACD,EAAE;AAEH,OAAO,MAAMG,6BAA6DZ,EAAEI,MAAM,CAAC;IACjFS,MAAMb,EAAEc,MAAM,GAAGC,GAAG,CAAC;IACrBP,MAAMV;AACR,GAAG;AAEH,OAAO,SAASkB,gCAAgCC,YAA0B;IACxE,OAAOjB,EAAEI,MAAM,CAAC;QACdS,MAAMb,EAAEc,MAAM,GAAGC,GAAG,CAAC;QACrBP,MAAMT,0BAA0BkB;IAClC;AACF"}
@@ -1,12 +1,2 @@
1
- import { z } from 'zod';
2
- export declare const displaySchema: z.ZodObject<{
3
- name: z.ZodOptional<z.ZodString>;
4
- description: z.ZodOptional<z.ZodString>;
5
- }, "strip", z.ZodTypeAny, {
6
- name?: string | undefined;
7
- description?: string | undefined;
8
- }, {
9
- name?: string | undefined;
10
- description?: string | undefined;
11
- }>;
1
+ export { displaySchema } from '@perses-dev/spec';
12
2
  //# sourceMappingURL=display.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/schema/display.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,aAAa;;;;;;;;;EAGxB,CAAC"}
1
+ {"version":3,"file":"display.d.ts","sourceRoot":"","sources":["../../src/schema/display.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -10,10 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { z } from 'zod';
14
- export const displaySchema = z.object({
15
- name: z.string().optional(),
16
- description: z.string().optional()
17
- });
13
+ export { displaySchema } from '@perses-dev/spec';
18
14
 
19
15
  //# sourceMappingURL=display.js.map
@@ -1 +1 @@
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
+ {"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\nexport { displaySchema } from '@perses-dev/spec';\n"],"names":["displaySchema"],"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,aAAa,QAAQ,mBAAmB"}
@@ -1,3 +1,2 @@
1
- import { z } from 'zod';
2
- export declare const durationValidationSchema: z.ZodString;
1
+ export { durationValidationSchema } from '@perses-dev/spec';
3
2
  //# sourceMappingURL=duration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/schema/duration.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,wBAAwB,aAGsB,CAAC"}
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/schema/duration.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC"}
@@ -10,8 +10,6 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
- import { z } from 'zod';
14
- import { DURATION_REGEX } from '../model';
15
- export const durationValidationSchema = z.string().min(1, 'Required').regex(DURATION_REGEX, 'Must be a valid duration string');
13
+ export { durationValidationSchema } from '@perses-dev/spec';
16
14
 
17
15
  //# sourceMappingURL=duration.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/schema/duration.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 { DURATION_REGEX } from '../model';\n\nexport const durationValidationSchema = z\n .string()\n .min(1, 'Required')\n .regex(DURATION_REGEX, 'Must be a valid duration string');\n"],"names":["z","DURATION_REGEX","durationValidationSchema","string","min","regex"],"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;AACxB,SAASC,cAAc,QAAQ,WAAW;AAE1C,OAAO,MAAMC,2BAA2BF,EACrCG,MAAM,GACNC,GAAG,CAAC,GAAG,YACPC,KAAK,CAACJ,gBAAgB,mCAAmC"}
1
+ {"version":3,"sources":["../../src/schema/duration.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 { durationValidationSchema } from '@perses-dev/spec';\n"],"names":["durationValidationSchema"],"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,wBAAwB,QAAQ,mBAAmB"}
@@ -1,13 +1,2 @@
1
- import { z } from 'zod';
2
- import { Link, PanelDefinition, PanelDisplay, PanelEditorValues, PanelSpec, QueryDefinition } from '../model';
3
- import { PluginSchema } from './plugin';
4
- export declare const panelDisplaySpec: z.ZodSchema<PanelDisplay>;
5
- export declare const querySpecSchema: z.ZodSchema<QueryDefinition>;
6
- export declare const linkSchema: z.ZodSchema<Link>;
7
- export declare const panelSpecSchema: z.ZodSchema<PanelSpec>;
8
- export declare function buildPanelSpecSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelSpec>;
9
- export declare const panelDefinitionSchema: z.ZodSchema<PanelDefinition>;
10
- export declare function buildPanelDefinitionSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelDefinition>;
11
- export declare const panelEditorSchema: z.ZodSchema<PanelEditorValues>;
12
- export declare function buildPanelEditorSchema(pluginSchema: PluginSchema): z.ZodSchema<PanelEditorValues>;
1
+ export { panelDisplaySpec, querySpecSchema, linkSchema, panelSpecSchema, buildPanelSpecSchema, panelDefinitionSchema, buildPanelDefinitionSchema, panelEditorSchema, buildPanelEditorSchema, } from '@perses-dev/spec';
13
2
  //# sourceMappingURL=panel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/schema/panel.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC9G,OAAO,EAAE,YAAY,EAAgB,MAAM,UAAU,CAAC;AAEtD,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,SAAS,CAAC,YAAY,CAGrD,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,CAKvD,CAAC;AAEH,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,SAAS,CAAC,IAAI,CAMvC,CAAC;AAEH,eAAO,MAAM,eAAe,EAAE,CAAC,CAAC,SAAS,CAAC,SAAS,CAKjD,CAAC;AAEH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAOvF;AAED,eAAO,MAAM,qBAAqB,EAAE,CAAC,CAAC,SAAS,CAAC,eAAe,CAG7D,CAAC;AAEH,wBAAgB,0BAA0B,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAKnG;AAED,eAAO,MAAM,iBAAiB,EAAE,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAG3D,CAAC;AAEH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAKjG"}
1
+ {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/schema/panel.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,0BAA0B,EAC1B,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,kBAAkB,CAAC"}