@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
@@ -17,23 +17,24 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- CURRENCY_GROUP_CONFIG: function() {
24
+ get CURRENCY_GROUP_CONFIG () {
25
25
  return CURRENCY_GROUP_CONFIG;
26
26
  },
27
- CURRENCY_UNIT_CONFIG: function() {
27
+ get CURRENCY_UNIT_CONFIG () {
28
28
  return CURRENCY_UNIT_CONFIG;
29
29
  },
30
- formatCurrency: function() {
30
+ get formatCurrency () {
31
31
  return formatCurrency;
32
32
  }
33
33
  });
34
34
  const _lodash = require("lodash");
35
35
  const _constants = require("./constants");
36
36
  const _utils = require("./utils");
37
+ const _formatterCache = require("./formatterCache");
37
38
  const CURRENCY_GROUP = 'Currency';
38
39
  const CURRENCY_GROUP_CONFIG = {
39
40
  label: 'Currency',
@@ -113,6 +114,13 @@ function formatCurrency(value, { unit, decimalPlaces }) {
113
114
  } else {
114
115
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
115
116
  }
116
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
117
- return formatter.format(value);
117
+ const key = [
118
+ formatterOptions.style,
119
+ formatterOptions.currency,
120
+ formatterOptions.currencyDisplay,
121
+ formatterOptions.maximumSignificantDigits,
122
+ decimalPlaces,
123
+ unit
124
+ ];
125
+ return (0, _formatterCache.getFormatterFromCache)(key, 'currency', formatterOptions, 'en-US')(value);
118
126
  }
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DATE_GROUP_CONFIG: function() {
24
+ get DATE_GROUP_CONFIG () {
25
25
  return DATE_GROUP_CONFIG;
26
26
  },
27
- DATE_UNIT_CONFIG: function() {
27
+ get DATE_UNIT_CONFIG () {
28
28
  return DATE_UNIT_CONFIG;
29
29
  },
30
- formatDate: function() {
30
+ get formatDate () {
31
31
  return formatDate;
32
32
  }
33
33
  });
@@ -17,21 +17,22 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DECIMAL_GROUP_CONFIG: function() {
24
+ get DECIMAL_GROUP_CONFIG () {
25
25
  return DECIMAL_GROUP_CONFIG;
26
26
  },
27
- DECIMAL_UNIT_CONFIG: function() {
27
+ get DECIMAL_UNIT_CONFIG () {
28
28
  return DECIMAL_UNIT_CONFIG;
29
29
  },
30
- formatDecimal: function() {
30
+ get formatDecimal () {
31
31
  return formatDecimal;
32
32
  }
33
33
  });
34
34
  const _constants = require("./constants");
35
+ const _formatterCache = require("./formatterCache");
35
36
  const _utils = require("./utils");
36
37
  const DECIMAL_GROUP_CONFIG = {
37
38
  label: 'Decimal',
@@ -60,6 +61,12 @@ function formatDecimal(value, { shortValues, decimalPlaces }) {
60
61
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
61
62
  }
62
63
  }
63
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
64
- return formatter.format(value);
64
+ const key = [
65
+ formatterOptions.style,
66
+ formatterOptions.useGrouping,
67
+ formatterOptions.notation,
68
+ formatterOptions.maximumSignificantDigits,
69
+ decimalPlaces
70
+ ];
71
+ return (0, _formatterCache.getFormatterFromCache)(key, 'decimal', formatterOptions, 'en-US')(value);
65
72
  }
@@ -0,0 +1,120 @@
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
+ "use strict";
14
+ Object.defineProperty(exports, "__esModule", {
15
+ value: true
16
+ });
17
+ function _export(target, all) {
18
+ for(var name in all)Object.defineProperty(target, name, {
19
+ enumerable: true,
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
+ });
22
+ }
23
+ _export(exports, {
24
+ get getFormatterFromCache () {
25
+ return getFormatterFromCache;
26
+ },
27
+ get getFormatterStats () {
28
+ return getFormatterStats;
29
+ }
30
+ });
31
+ /**
32
+ * REASONING FOR CLUSTERING (Map-of-Maps):
33
+ *
34
+ * 1. PERSISTENCE & REUSE: Intl.NumberFormat instantiation is CPU-heavy due to
35
+ * locale/data lookups. Clustering allows 100x faster reuse via caching.
36
+ *
37
+ *
38
+ * 2. LOOKUP PERFORMANCE: Smaller, specialized Maps reduce the risk of hash
39
+ * collisions, ensuring O(1) retrieval time remains consistent even as
40
+ * the total number of formatters across the app grows.
41
+ *
42
+ * 3. GARBAGE COLLECTION & STATS: Categorization allows for targeted memory
43
+ * monitoring and easier debugging of which specific data types are
44
+ * consuming the most resources.
45
+ */ const TIME_FORMATTER_CACHE = new Map();
46
+ const DECIMAL_FORMATTER_CACHE = new Map();
47
+ const BITS_FORMATTER_CACHE = new Map();
48
+ const BYTES_FORMATTER_CACHE = new Map();
49
+ const CURRENCY_FORMATTER_CACHE = new Map();
50
+ const PERCENT_FORMATTER_CACHE = new Map();
51
+ const TEMPERATURE_FORMATTER_CACHE = new Map();
52
+ const THROUGHPUT_FORMATTER_CACHE = new Map();
53
+ const ALL_FORMATTERS = new Map([
54
+ [
55
+ 'time',
56
+ TIME_FORMATTER_CACHE
57
+ ],
58
+ [
59
+ 'decimal',
60
+ DECIMAL_FORMATTER_CACHE
61
+ ],
62
+ [
63
+ 'bits',
64
+ BITS_FORMATTER_CACHE
65
+ ],
66
+ [
67
+ 'bytes',
68
+ BYTES_FORMATTER_CACHE
69
+ ],
70
+ [
71
+ 'currency',
72
+ CURRENCY_FORMATTER_CACHE
73
+ ],
74
+ [
75
+ 'percent',
76
+ PERCENT_FORMATTER_CACHE
77
+ ],
78
+ [
79
+ 'temperature',
80
+ TEMPERATURE_FORMATTER_CACHE
81
+ ],
82
+ [
83
+ 'throughput',
84
+ THROUGHPUT_FORMATTER_CACHE
85
+ ]
86
+ ]);
87
+ function getFormatterFromCache(key, inputType, formatterOptions, locals = 'en-US') {
88
+ const compoundKey = `${key.filter((k)=>![
89
+ undefined,
90
+ null,
91
+ '',
92
+ NaN
93
+ ].includes(k)).join('|')}|${locals}`;
94
+ const inputTypeFormatters = ALL_FORMATTERS.get(inputType);
95
+ if (!inputTypeFormatters) throw new Error('No formatter found for the input type');
96
+ const formatter = inputTypeFormatters.get(compoundKey);
97
+ if (formatter) {
98
+ return formatter.format;
99
+ }
100
+ const newFormatter = Intl.NumberFormat(locals, formatterOptions);
101
+ inputTypeFormatters?.set(`${compoundKey}`, newFormatter);
102
+ return newFormatter.format;
103
+ }
104
+ const getFormatterStats = ()=>{
105
+ const countCacheItems = (inputType)=>{
106
+ if (inputType !== 'all') {
107
+ return ALL_FORMATTERS.get(inputType)?.size ?? 0;
108
+ }
109
+ return Array.from(ALL_FORMATTERS.values()).reduce((acc, map)=>acc + (map?.size ?? 0), 0);
110
+ };
111
+ const getKeys = (inputType)=>{
112
+ return [
113
+ ...ALL_FORMATTERS.get(inputType)?.keys() || []
114
+ ];
115
+ };
116
+ return {
117
+ countCacheItems,
118
+ getKeys
119
+ };
120
+ };
@@ -17,21 +17,22 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PERCENT_GROUP_CONFIG: function() {
24
+ get PERCENT_GROUP_CONFIG () {
25
25
  return PERCENT_GROUP_CONFIG;
26
26
  },
27
- PERCENT_UNIT_CONFIG: function() {
27
+ get PERCENT_UNIT_CONFIG () {
28
28
  return PERCENT_UNIT_CONFIG;
29
29
  },
30
- formatPercent: function() {
30
+ get formatPercent () {
31
31
  return formatPercent;
32
32
  }
33
33
  });
34
34
  const _constants = require("./constants");
35
+ const _formatterCache = require("./formatterCache");
35
36
  const _utils = require("./utils");
36
37
  const PERCENT_GROUP_CONFIG = {
37
38
  label: 'percent',
@@ -70,6 +71,12 @@ function formatPercent(value, { unit, decimalPlaces }) {
70
71
  if (unit === 'percent') {
71
72
  value = value / 100;
72
73
  }
73
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
74
- return formatter.format(value);
74
+ const key = [
75
+ formatterOptions.style,
76
+ formatterOptions.useGrouping,
77
+ formatterOptions.maximumSignificantDigits,
78
+ decimalPlaces,
79
+ unit
80
+ ];
81
+ return (0, _formatterCache.getFormatterFromCache)(key, 'percent', formatterOptions, 'en-US')(value);
75
82
  }
@@ -17,21 +17,22 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- TEMPERATURE_GROUP_CONFIG: function() {
24
+ get TEMPERATURE_GROUP_CONFIG () {
25
25
  return TEMPERATURE_GROUP_CONFIG;
26
26
  },
27
- TEMPERATURE_UNIT_CONFIG: function() {
27
+ get TEMPERATURE_UNIT_CONFIG () {
28
28
  return TEMPERATURE_UNIT_CONFIG;
29
29
  },
30
- formatTemperature: function() {
30
+ get formatTemperature () {
31
31
  return formatTemperature;
32
32
  }
33
33
  });
34
34
  const _constants = require("./constants");
35
+ const _formatterCache = require("./formatterCache");
35
36
  const _utils = require("./utils");
36
37
  const TEMPERATURE_GROUP = 'Temperature';
37
38
  const TEMPERATURE_GROUP_CONFIG = {
@@ -60,5 +61,12 @@ const formatTemperature = (value, { unit, decimalPlaces })=>{
60
61
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
61
62
  }
62
63
  const locals = unit === 'celsius' ? 'en-GB' : 'en-US';
63
- return Intl.NumberFormat(locals, formatterOptions).format(value);
64
+ const key = [
65
+ formatterOptions.style,
66
+ formatterOptions.unit,
67
+ formatterOptions.maximumSignificantDigits,
68
+ decimalPlaces,
69
+ locals
70
+ ];
71
+ return (0, _formatterCache.getFormatterFromCache)(key, 'temperature', formatterOptions, locals)(value);
64
72
  };
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- THROUGHPUT_GROUP_CONFIG: function() {
24
+ get THROUGHPUT_GROUP_CONFIG () {
25
25
  return THROUGHPUT_GROUP_CONFIG;
26
26
  },
27
- THROUGHPUT_UNIT_CONFIG: function() {
27
+ get THROUGHPUT_UNIT_CONFIG () {
28
28
  return THROUGHPUT_UNIT_CONFIG;
29
29
  },
30
- formatThroughput: function() {
30
+ get formatThroughput () {
31
31
  return formatThroughput;
32
32
  }
33
33
  });
@@ -35,6 +35,7 @@ const _bytes = require("./bytes");
35
35
  const _bits = require("./bits");
36
36
  const _constants = require("./constants");
37
37
  const _utils = require("./utils");
38
+ const _formatterCache = require("./formatterCache");
38
39
  const THROUGHPUT_GROUP_CONFIG = {
39
40
  label: 'Throughput',
40
41
  decimalPlaces: true
@@ -147,6 +148,14 @@ function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
147
148
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
148
149
  }
149
150
  }
150
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
151
- return formatter.format(value) + ' ' + unit;
151
+ const key = [
152
+ formatterOptions.style,
153
+ formatterOptions.useGrouping,
154
+ formatterOptions.notation,
155
+ formatterOptions.maximumSignificantDigits,
156
+ decimalPlaces,
157
+ shortValues,
158
+ unit
159
+ ];
160
+ return `${(0, _formatterCache.getFormatterFromCache)(key, 'throughput', formatterOptions, 'en-US')(value)} ${unit}`;
152
161
  }
@@ -17,24 +17,25 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- PersesTimeToIntlTime: function() {
24
+ get PersesTimeToIntlTime () {
25
25
  return PersesTimeToIntlTime;
26
26
  },
27
- TIME_GROUP_CONFIG: function() {
27
+ get TIME_GROUP_CONFIG () {
28
28
  return TIME_GROUP_CONFIG;
29
29
  },
30
- TIME_UNIT_CONFIG: function() {
30
+ get TIME_UNIT_CONFIG () {
31
31
  return TIME_UNIT_CONFIG;
32
32
  },
33
- formatTime: function() {
33
+ get formatTime () {
34
34
  return formatTime;
35
35
  }
36
36
  });
37
37
  const _constants = require("./constants");
38
+ const _formatterCache = require("./formatterCache");
38
39
  const _utils = require("./utils");
39
40
  const TIME_GROUP = 'Time';
40
41
  const TIME_GROUP_CONFIG = {
@@ -165,6 +166,13 @@ function formatTime(value, { unit, decimalPlaces }) {
165
166
  } else {
166
167
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
167
168
  }
168
- const formatter = Intl.NumberFormat('en-US', formatterOptions);
169
- return formatter.format(results.value);
169
+ const key = [
170
+ formatterOptions.style,
171
+ formatterOptions.unit,
172
+ formatterOptions.unitDisplay,
173
+ formatterOptions.maximumSignificantDigits,
174
+ decimalPlaces,
175
+ unit ?? 'seconds'
176
+ ];
177
+ return (0, _formatterCache.getFormatterFromCache)(key, 'time', formatterOptions, 'en-US')(results.value);
170
178
  }
@@ -17,59 +17,59 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- UNIT_CONFIG: function() {
24
+ get UNIT_CONFIG () {
25
25
  return UNIT_CONFIG;
26
26
  },
27
- UNIT_GROUP_CONFIG: function() {
27
+ get UNIT_GROUP_CONFIG () {
28
28
  return UNIT_GROUP_CONFIG;
29
29
  },
30
- formatValue: function() {
30
+ get formatValue () {
31
31
  return formatValue;
32
32
  },
33
- getUnitConfig: function() {
33
+ get getUnitConfig () {
34
34
  return getUnitConfig;
35
35
  },
36
- getUnitGroup: function() {
36
+ get getUnitGroup () {
37
37
  return getUnitGroup;
38
38
  },
39
- getUnitGroupConfig: function() {
39
+ get getUnitGroupConfig () {
40
40
  return getUnitGroupConfig;
41
41
  },
42
- isBitsUnit: function() {
42
+ get isBitsUnit () {
43
43
  return isBitsUnit;
44
44
  },
45
- isBytesUnit: function() {
45
+ get isBytesUnit () {
46
46
  return isBytesUnit;
47
47
  },
48
- isCurrencyUnit: function() {
48
+ get isCurrencyUnit () {
49
49
  return isCurrencyUnit;
50
50
  },
51
- isDateUnit: function() {
51
+ get isDateUnit () {
52
52
  return isDateUnit;
53
53
  },
54
- isDecimalUnit: function() {
54
+ get isDecimalUnit () {
55
55
  return isDecimalUnit;
56
56
  },
57
- isPercentUnit: function() {
57
+ get isPercentUnit () {
58
58
  return isPercentUnit;
59
59
  },
60
- isTemperatureUnit: function() {
60
+ get isTemperatureUnit () {
61
61
  return isTemperatureUnit;
62
62
  },
63
- isThroughputUnit: function() {
63
+ get isThroughputUnit () {
64
64
  return isThroughputUnit;
65
65
  },
66
- isTimeUnit: function() {
66
+ get isTimeUnit () {
67
67
  return isTimeUnit;
68
68
  },
69
- isUnitWithDecimalPlaces: function() {
69
+ get isUnitWithDecimalPlaces () {
70
70
  return isUnitWithDecimalPlaces;
71
71
  },
72
- isUnitWithShortValues: function() {
72
+ get isUnitWithShortValues () {
73
73
  return isUnitWithShortValues;
74
74
  }
75
75
  });
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- hasDecimalPlaces: function() {
24
+ get hasDecimalPlaces () {
25
25
  return hasDecimalPlaces;
26
26
  },
27
- limitDecimalPlaces: function() {
27
+ get limitDecimalPlaces () {
28
28
  return limitDecimalPlaces;
29
29
  },
30
- shouldShortenValues: function() {
30
+ get shouldShortenValues () {
31
31
  return shouldShortenValues;
32
32
  }
33
33
  });
@@ -17,14 +17,14 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- DEFAULT_ALL_VALUE: function() {
24
+ get DEFAULT_ALL_VALUE () {
25
25
  return DEFAULT_ALL_VALUE;
26
26
  },
27
- getVariableProject: function() {
27
+ get getVariableProject () {
28
28
  return getVariableProject;
29
29
  }
30
30
  });
@@ -17,57 +17,41 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- buildDatasourceDefinitionSchema: function() {
24
+ get buildDatasourceDefinitionSchema () {
25
25
  return buildDatasourceDefinitionSchema;
26
26
  },
27
- buildDatasourceSpecSchema: function() {
28
- return buildDatasourceSpecSchema;
27
+ get buildDatasourceSpecSchema () {
28
+ return _spec.buildDatasourceSpecSchema;
29
29
  },
30
- datasourceDefinitionSchema: function() {
30
+ get datasourceDefinitionSchema () {
31
31
  return datasourceDefinitionSchema;
32
32
  },
33
- datasourceSchema: function() {
33
+ get datasourceSchema () {
34
34
  return datasourceSchema;
35
35
  },
36
- datasourceSpecSchema: function() {
37
- return datasourceSpecSchema;
38
- },
39
- datasourcesSchema: function() {
36
+ get datasourcesSchema () {
40
37
  return datasourcesSchema;
41
38
  },
42
- globalDatasourceSchema: function() {
39
+ get globalDatasourceSchema () {
43
40
  return globalDatasourceSchema;
44
41
  }
45
42
  });
43
+ const _spec = require("@perses-dev/spec");
46
44
  const _zod = require("zod");
47
45
  const _metadata = require("./metadata");
48
- const _plugin = require("./plugin");
49
- const _display = require("./display");
50
- const datasourceSpecSchema = _zod.z.object({
51
- display: _display.displaySchema.optional(),
52
- default: _zod.z.boolean(),
53
- plugin: _plugin.pluginSchema
54
- });
55
- function buildDatasourceSpecSchema(pluginSchema) {
56
- return _zod.z.object({
57
- display: _display.displaySchema.optional(),
58
- default: _zod.z.boolean(),
59
- plugin: pluginSchema
60
- });
61
- }
62
46
  const datasourceSchema = _zod.z.object({
63
47
  kind: _zod.z.literal('Datasource'),
64
48
  metadata: _metadata.projectMetadataSchema,
65
- spec: datasourceSpecSchema
49
+ spec: _spec.datasourceSpecSchema
66
50
  });
67
51
  const globalDatasourceSchema = _zod.z.object({
68
52
  kind: _zod.z.literal('GlobalDatasource'),
69
53
  metadata: _metadata.metadataSchema,
70
- spec: datasourceSpecSchema
54
+ spec: _spec.datasourceSpecSchema
71
55
  });
72
56
  const datasourcesSchema = _zod.z.discriminatedUnion('kind', [
73
57
  datasourceSchema,
@@ -75,11 +59,11 @@ const datasourcesSchema = _zod.z.discriminatedUnion('kind', [
75
59
  ]);
76
60
  const datasourceDefinitionSchema = _zod.z.object({
77
61
  name: _zod.z.string().min(1),
78
- spec: datasourceSpecSchema
62
+ spec: _spec.datasourceSpecSchema
79
63
  });
80
64
  function buildDatasourceDefinitionSchema(pluginSchema) {
81
65
  return _zod.z.object({
82
66
  name: _zod.z.string().min(1),
83
- spec: buildDatasourceSpecSchema(pluginSchema)
67
+ spec: (0, _spec.buildDatasourceSpecSchema)(pluginSchema)
84
68
  });
85
69
  }
@@ -17,11 +17,7 @@ Object.defineProperty(exports, "__esModule", {
17
17
  Object.defineProperty(exports, "displaySchema", {
18
18
  enumerable: true,
19
19
  get: function() {
20
- return displaySchema;
20
+ return _spec.displaySchema;
21
21
  }
22
22
  });
23
- const _zod = require("zod");
24
- const displaySchema = _zod.z.object({
25
- name: _zod.z.string().optional(),
26
- description: _zod.z.string().optional()
27
- });
23
+ const _spec = require("@perses-dev/spec");
@@ -17,9 +17,7 @@ Object.defineProperty(exports, "__esModule", {
17
17
  Object.defineProperty(exports, "durationValidationSchema", {
18
18
  enumerable: true,
19
19
  get: function() {
20
- return durationValidationSchema;
20
+ return _spec.durationValidationSchema;
21
21
  }
22
22
  });
23
- const _zod = require("zod");
24
- const _model = require("../model");
25
- const durationValidationSchema = _zod.z.string().min(1, 'Required').regex(_model.DURATION_REGEX, 'Must be a valid duration string');
23
+ const _spec = require("@perses-dev/spec");
@@ -17,17 +17,17 @@ Object.defineProperty(exports, "__esModule", {
17
17
  function _export(target, all) {
18
18
  for(var name in all)Object.defineProperty(target, name, {
19
19
  enumerable: true,
20
- get: all[name]
20
+ get: Object.getOwnPropertyDescriptor(all, name).get
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- metadataSchema: function() {
24
+ get metadataSchema () {
25
25
  return metadataSchema;
26
26
  },
27
- nameSchema: function() {
27
+ get nameSchema () {
28
28
  return nameSchema;
29
29
  },
30
- projectMetadataSchema: function() {
30
+ get projectMetadataSchema () {
31
31
  return projectMetadataSchema;
32
32
  }
33
33
  });