@perses-dev/core 0.0.0-snapshot-ts-panel-actions-90e9ef0 → 0.0.0-snapshot-reverse-proxy-75afbd7

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 (62) hide show
  1. package/dist/cjs/constants/index.js +0 -1
  2. package/dist/cjs/model/index.js +1 -0
  3. package/dist/cjs/{constants/dialog.js → model/log-data.js} +1 -8
  4. package/dist/cjs/model/units/bytes.js +19 -7
  5. package/dist/cjs/model/units/currency.js +118 -0
  6. package/dist/cjs/model/units/throughput.js +14 -2
  7. package/dist/cjs/model/units/units.js +14 -2
  8. package/dist/cjs/utils/fetch.js +2 -2
  9. package/dist/cjs/utils/transform-data.js +1 -1
  10. package/dist/constants/index.d.ts +0 -1
  11. package/dist/constants/index.d.ts.map +1 -1
  12. package/dist/constants/index.js +0 -1
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/model/index.d.ts +1 -0
  15. package/dist/model/index.d.ts.map +1 -1
  16. package/dist/model/index.js +1 -0
  17. package/dist/model/index.js.map +1 -1
  18. package/dist/model/layout.d.ts +1 -0
  19. package/dist/model/layout.d.ts.map +1 -1
  20. package/dist/model/layout.js.map +1 -1
  21. package/dist/model/log-data.d.ts +48 -0
  22. package/dist/model/log-data.d.ts.map +1 -0
  23. package/dist/{constants/dialog.js → model/log-data.js} +3 -3
  24. package/dist/model/log-data.js.map +1 -0
  25. package/dist/model/query.d.ts +2 -0
  26. package/dist/model/query.d.ts.map +1 -1
  27. package/dist/model/query.js.map +1 -1
  28. package/dist/model/units/bytes.d.ts +2 -2
  29. package/dist/model/units/bytes.d.ts.map +1 -1
  30. package/dist/model/units/bytes.js +19 -7
  31. package/dist/model/units/bytes.js.map +1 -1
  32. package/dist/model/units/currency.d.ts +11 -0
  33. package/dist/model/units/currency.d.ts.map +1 -0
  34. package/dist/model/units/currency.js +99 -0
  35. package/dist/model/units/currency.js.map +1 -0
  36. package/dist/model/units/throughput.d.ts +1 -1
  37. package/dist/model/units/throughput.d.ts.map +1 -1
  38. package/dist/model/units/throughput.js +14 -2
  39. package/dist/model/units/throughput.js.map +1 -1
  40. package/dist/model/units/types.d.ts +1 -1
  41. package/dist/model/units/types.d.ts.map +1 -1
  42. package/dist/model/units/types.js.map +1 -1
  43. package/dist/model/units/units.d.ts +20 -1
  44. package/dist/model/units/units.d.ts.map +1 -1
  45. package/dist/model/units/units.js +11 -2
  46. package/dist/model/units/units.js.map +1 -1
  47. package/dist/schema/datasource.d.ts +3 -3
  48. package/dist/schema/metadata.d.ts +3 -3
  49. package/dist/schema/role.d.ts +3 -3
  50. package/dist/schema/rolebinding.d.ts +3 -3
  51. package/dist/schema/secret.d.ts +6 -6
  52. package/dist/schema/variable.d.ts +6 -6
  53. package/dist/utils/fetch.d.ts +4 -4
  54. package/dist/utils/fetch.d.ts.map +1 -1
  55. package/dist/utils/fetch.js +3 -3
  56. package/dist/utils/fetch.js.map +1 -1
  57. package/dist/utils/transform-data.js +1 -1
  58. package/dist/utils/transform-data.js.map +1 -1
  59. package/package.json +3 -3
  60. package/dist/constants/dialog.d.ts +0 -2
  61. package/dist/constants/dialog.d.ts.map +0 -1
  62. package/dist/constants/dialog.js.map +0 -1
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
17
  _export_star(require("./dashboard-defaults"), exports);
18
- _export_star(require("./dialog"), exports);
19
18
  function _export_star(from, to) {
20
19
  Object.keys(from).forEach(function(k) {
21
20
  if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
@@ -40,6 +40,7 @@ _export_star(require("./time-series-data"), exports);
40
40
  _export_star(require("./time-series-queries"), exports);
41
41
  _export_star(require("./trace-data"), exports);
42
42
  _export_star(require("./profile-data"), exports);
43
+ _export_star(require("./log-data"), exports);
43
44
  _export_star(require("./transforms"), exports);
44
45
  _export_star(require("./units"), exports);
45
46
  _export_star(require("./user"), exports);
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -14,10 +14,3 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
- Object.defineProperty(exports, "SAVE_DEFAULTS_DIALOG_TEXT", {
18
- enumerable: true,
19
- get: function() {
20
- return SAVE_DEFAULTS_DIALOG_TEXT;
21
- }
22
- });
23
- const SAVE_DEFAULTS_DIALOG_TEXT = 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';
@@ -40,11 +40,17 @@ function _interop_require_default(obj) {
40
40
  };
41
41
  }
42
42
  /**
43
- * We consider the units for bytes to be powers of 1000.
44
- * In other words:
43
+ * We support both SI (decimal) and IEC (binary) units for bytes:
44
+ *
45
+ * SI/decimal (unit: 'decbytes'):
45
46
  * 1 KB = 1000 bytes (1000^1 bytes)
46
47
  * 1 MB = 1,000,000 bytes (1000^2 bytes)
47
48
  * etc.
49
+ *
50
+ * IEC/binary (unit: 'bytes'):
51
+ * 1 KiB = 1024 bytes (1024^1 bytes)
52
+ * 1 MiB = 1,048,576 bytes (1024^2 bytes)
53
+ * etc.
48
54
  */ const DEFAULT_NUMBRO_MANTISSA = 2;
49
55
  const BYTES_GROUP_CONFIG = {
50
56
  label: 'Bytes',
@@ -54,12 +60,18 @@ const BYTES_GROUP_CONFIG = {
54
60
  const BYTES_UNIT_CONFIG = {
55
61
  bytes: {
56
62
  group: 'Bytes',
57
- label: 'Bytes'
63
+ label: 'Bytes (IEC)'
64
+ },
65
+ decbytes: {
66
+ group: 'Bytes',
67
+ label: 'Bytes (SI)'
58
68
  }
59
69
  };
60
- function formatBytes(bytes, { shortValues, decimalPlaces }) {
70
+ function formatBytes(bytes, { unit = 'bytes', shortValues, decimalPlaces }) {
71
+ const isDecimal = unit === 'decbytes';
72
+ const threshold = isDecimal ? 1000 : 1024;
61
73
  // If we're showing the entire value, we can use Intl.NumberFormat.
62
- if (!(0, _utils.shouldShortenValues)(shortValues) || Math.abs(bytes) < 1000) {
74
+ if (!(0, _utils.shouldShortenValues)(shortValues) || Math.abs(bytes) < threshold) {
63
75
  const formatterOptions = {
64
76
  style: 'unit',
65
77
  unit: 'byte',
@@ -70,7 +82,7 @@ function formatBytes(bytes, { shortValues, decimalPlaces }) {
70
82
  formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
71
83
  formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
72
84
  } else {
73
- // This can happen if bytes is between -1000 and 1000
85
+ // This can happen if bytes is between -threshold and threshold (1000 for SI, 1024 for IEC)
74
86
  if ((0, _utils.shouldShortenValues)(shortValues)) {
75
87
  formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
76
88
  }
@@ -82,7 +94,7 @@ function formatBytes(bytes, { shortValues, decimalPlaces }) {
82
94
  // numbro is able to add units like KB, MB, GB, etc. correctly.
83
95
  return (0, _numbro.default)(bytes).format({
84
96
  output: 'byte',
85
- base: 'decimal',
97
+ base: isDecimal ? 'decimal' : 'binary',
86
98
  spaceSeparated: true,
87
99
  mantissa: (0, _utils.hasDecimalPlaces)(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,
88
100
  // trimMantissa trims trailing 0s
@@ -0,0 +1,118 @@
1
+ // Copyright 2025 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: all[name]
21
+ });
22
+ }
23
+ _export(exports, {
24
+ CURRENCY_GROUP_CONFIG: function() {
25
+ return CURRENCY_GROUP_CONFIG;
26
+ },
27
+ CURRENCY_UNIT_CONFIG: function() {
28
+ return CURRENCY_UNIT_CONFIG;
29
+ },
30
+ formatCurrency: function() {
31
+ return formatCurrency;
32
+ }
33
+ });
34
+ const _lodash = require("lodash");
35
+ const _constants = require("./constants");
36
+ const _utils = require("./utils");
37
+ const CURRENCY_GROUP = 'Currency';
38
+ const CURRENCY_GROUP_CONFIG = {
39
+ label: 'Currency',
40
+ decimalPlaces: true
41
+ };
42
+ const CURRENCY_UNIT_CONFIG = {
43
+ aud: {
44
+ group: CURRENCY_GROUP,
45
+ label: 'Australian Dollar (A$)'
46
+ },
47
+ cad: {
48
+ group: CURRENCY_GROUP,
49
+ label: 'Canadian Dollar (CA$)'
50
+ },
51
+ chf: {
52
+ group: CURRENCY_GROUP,
53
+ label: 'Swiss Franc (CHF)'
54
+ },
55
+ cny: {
56
+ group: CURRENCY_GROUP,
57
+ label: 'Renminbi (CN¥)'
58
+ },
59
+ eur: {
60
+ group: CURRENCY_GROUP,
61
+ label: 'Euro (€)'
62
+ },
63
+ gbp: {
64
+ group: CURRENCY_GROUP,
65
+ label: 'Pound (£)'
66
+ },
67
+ hkd: {
68
+ group: CURRENCY_GROUP,
69
+ label: 'Hong Kong Dollar (HK$)'
70
+ },
71
+ inr: {
72
+ group: CURRENCY_GROUP,
73
+ label: 'Indian Rupee (₹)'
74
+ },
75
+ jpy: {
76
+ group: CURRENCY_GROUP,
77
+ label: 'Yen (¥)'
78
+ },
79
+ krw: {
80
+ group: CURRENCY_GROUP,
81
+ label: 'South Korean Won (₩)'
82
+ },
83
+ nok: {
84
+ group: CURRENCY_GROUP,
85
+ label: 'Norwegian Krone (NOK)'
86
+ },
87
+ nzd: {
88
+ group: CURRENCY_GROUP,
89
+ label: 'New Zealand Dollar (NZ$)'
90
+ },
91
+ sek: {
92
+ group: CURRENCY_GROUP,
93
+ label: 'Swedish Krona (SEK)'
94
+ },
95
+ sgd: {
96
+ group: CURRENCY_GROUP,
97
+ label: 'Singapore Dollar (S$)'
98
+ },
99
+ usd: {
100
+ group: CURRENCY_GROUP,
101
+ label: 'US Dollar ($)'
102
+ }
103
+ };
104
+ function formatCurrency(value, { unit, decimalPlaces }) {
105
+ const formatterOptions = {
106
+ style: 'currency',
107
+ currency: (0, _lodash.toUpper)(unit),
108
+ currencyDisplay: 'symbol'
109
+ };
110
+ if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
111
+ formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
112
+ formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
113
+ } else {
114
+ formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
115
+ }
116
+ const formatter = Intl.NumberFormat('en-US', formatterOptions);
117
+ return formatter.format(value);
118
+ }
@@ -46,7 +46,11 @@ const THROUGHPUT_UNIT_CONFIG = {
46
46
  },
47
47
  'bytes/sec': {
48
48
  group: THROUGHPUT_GROUP,
49
- label: 'Bytes/sec'
49
+ label: 'Bytes/sec (IEC)'
50
+ },
51
+ 'decbytes/sec': {
52
+ group: THROUGHPUT_GROUP,
53
+ label: 'Bytes/sec (SI)'
50
54
  },
51
55
  'counts/sec': {
52
56
  group: THROUGHPUT_GROUP,
@@ -91,8 +95,16 @@ const THROUGHPUT_UNIT_CONFIG = {
91
95
  };
92
96
  function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
93
97
  // special case for data throughput
94
- if (unit === 'bytes/sec') {
98
+ if (unit === 'decbytes/sec') {
95
99
  const denominator = Math.abs(value) < 1000 ? 'sec' : 's';
100
+ return (0, _bytes.formatBytes)(value, {
101
+ unit: 'decbytes',
102
+ shortValues,
103
+ decimalPlaces
104
+ }) + '/' + denominator;
105
+ }
106
+ if (unit === 'bytes/sec') {
107
+ const denominator = Math.abs(value) < 1024 ? 'sec' : 's';
96
108
  return (0, _bytes.formatBytes)(value, {
97
109
  unit: 'bytes',
98
110
  shortValues,
@@ -42,6 +42,9 @@ _export(exports, {
42
42
  isBytesUnit: function() {
43
43
  return isBytesUnit;
44
44
  },
45
+ isCurrencyUnit: function() {
46
+ return isCurrencyUnit;
47
+ },
45
48
  isDecimalUnit: function() {
46
49
  return isDecimalUnit;
47
50
  },
@@ -66,19 +69,22 @@ const _decimal = require("./decimal");
66
69
  const _percent = require("./percent");
67
70
  const _time = require("./time");
68
71
  const _throughput = require("./throughput");
72
+ const _currency = require("./currency");
69
73
  const UNIT_GROUP_CONFIG = {
70
74
  Time: _time.TIME_GROUP_CONFIG,
71
75
  Percent: _percent.PERCENT_GROUP_CONFIG,
72
76
  Decimal: _decimal.DECIMAL_GROUP_CONFIG,
73
77
  Bytes: _bytes.BYTES_GROUP_CONFIG,
74
- Throughput: _throughput.THROUGHPUT_GROUP_CONFIG
78
+ Throughput: _throughput.THROUGHPUT_GROUP_CONFIG,
79
+ Currency: _currency.CURRENCY_GROUP_CONFIG
75
80
  };
76
81
  const UNIT_CONFIG = {
77
82
  ..._time.TIME_UNIT_CONFIG,
78
83
  ..._percent.PERCENT_UNIT_CONFIG,
79
84
  ..._decimal.DECIMAL_UNIT_CONFIG,
80
85
  ..._bytes.BYTES_UNIT_CONFIG,
81
- ..._throughput.THROUGHPUT_UNIT_CONFIG
86
+ ..._throughput.THROUGHPUT_UNIT_CONFIG,
87
+ ..._currency.CURRENCY_UNIT_CONFIG
82
88
  };
83
89
  function formatValue(value, formatOptions) {
84
90
  if (formatOptions === undefined) {
@@ -99,6 +105,9 @@ function formatValue(value, formatOptions) {
99
105
  if (isThroughputUnit(formatOptions)) {
100
106
  return (0, _throughput.formatThroughput)(value, formatOptions);
101
107
  }
108
+ if (isCurrencyUnit(formatOptions)) {
109
+ return (0, _currency.formatCurrency)(value, formatOptions);
110
+ }
102
111
  const exhaustive = formatOptions;
103
112
  throw new Error(`Unknown unit options ${exhaustive}`);
104
113
  }
@@ -136,3 +145,6 @@ function isUnitWithShortValues(formatOptions) {
136
145
  function isThroughputUnit(formatOptions) {
137
146
  return getUnitGroup(formatOptions) === 'Throughput';
138
147
  }
148
+ function isCurrencyUnit(formatOptions) {
149
+ return getUnitGroup(formatOptions) === 'Currency';
150
+ }
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  /**
14
- * Calls `global.fetch` and determines which type of error to show for non-200 responses.
14
+ * Calls `globalThis.fetch` and determines which type of error to show for non-200 responses.
15
15
  */ "use strict";
16
16
  Object.defineProperty(exports, "__esModule", {
17
17
  value: true
@@ -37,7 +37,7 @@ _export(exports, {
37
37
  }
38
38
  });
39
39
  async function fetch(...args) {
40
- const response = await global.fetch(...args);
40
+ const response = await globalThis.fetch(...args);
41
41
  if (response.ok === false) {
42
42
  const contentType = response.headers.get('content-type');
43
43
  if (contentType?.includes('application/json')) {
@@ -87,7 +87,7 @@ function applyMergeColumnsTransform(data, selectedColumns, outputName) {
87
87
  function applyMergeIndexedColumnsTransform(data, column) {
88
88
  const result = [];
89
89
  for (const entry of data){
90
- const indexedColumns = Object.keys(entry).filter((k)=>new RegExp('^(' + column + ' #\\d+)|(' + column + ')$').test(k));
90
+ const indexedColumns = Object.keys(entry).filter((k)=>new RegExp('^((' + column + ' #\\d+)|(' + column + '))$').test(k));
91
91
  const indexedColumnValues = {};
92
92
  for (const indexedColumn of indexedColumns){
93
93
  indexedColumnValues[indexedColumn] = entry[indexedColumn];
@@ -1,3 +1,2 @@
1
1
  export * from './dashboard-defaults';
2
- export * from './dialog';
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAaA,cAAc,sBAAsB,CAAC"}
@@ -11,6 +11,5 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  export * from './dashboard-defaults';
14
- export * from './dialog';
15
14
 
16
15
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-defaults';\nexport * from './dialog';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB;AACrC,cAAc,WAAW"}
1
+ {"version":3,"sources":["../../src/constants/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './dashboard-defaults';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,uBAAuB"}
@@ -24,6 +24,7 @@ export * from './time-series-data';
24
24
  export * from './time-series-queries';
25
25
  export * from './trace-data';
26
26
  export * from './profile-data';
27
+ export * from './log-data';
27
28
  export * from './transforms';
28
29
  export * from './units';
29
30
  export * from './user';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
@@ -36,6 +36,7 @@ export * from './time-series-data';
36
36
  export * from './time-series-queries';
37
37
  export * from './trace-data';
38
38
  export * from './profile-data';
39
+ export * from './log-data';
39
40
  export * from './transforms';
40
41
  export * from './units';
41
42
  export * from './user';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
1
+ {"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './log-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
@@ -10,6 +10,7 @@ export interface GridDefinition {
10
10
  };
11
11
  };
12
12
  items: GridItemDefinition[];
13
+ repeatVariable?: string;
13
14
  };
14
15
  }
15
16
  export interface GridItemDefinition {
@@ -1 +1 @@
1
- {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/model/layout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,OAAO,CAAC,EAAE;YACR,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,CAAC,EAAE;gBACT,IAAI,EAAE,OAAO,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE,kBAAkB,EAAE,CAAC;KAC7B,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC;CACnB"}
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/model/layout.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE9C,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,OAAO,CAAC,EAAE;YACR,KAAK,EAAE,MAAM,CAAC;YACd,QAAQ,CAAC,EAAE;gBACT,IAAI,EAAE,OAAO,CAAC;aACf,CAAC;SACH,CAAC;QACF,KAAK,EAAE,kBAAkB,EAAE,CAAC;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/layout.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelRef } from './panels';\n\nexport type LayoutDefinition = GridDefinition;\n\nexport interface GridDefinition {\n kind: 'Grid';\n spec: {\n display?: {\n title: string;\n collapse?: {\n open: boolean;\n };\n };\n items: GridItemDefinition[];\n };\n}\n\nexport interface GridItemDefinition {\n x: number;\n y: number;\n width: number;\n height: number;\n content: PanelRef;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAmBjC,WAMC"}
1
+ {"version":3,"sources":["../../src/model/layout.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { PanelRef } from './panels';\n\nexport type LayoutDefinition = GridDefinition;\n\nexport interface GridDefinition {\n kind: 'Grid';\n spec: {\n display?: {\n title: string;\n collapse?: {\n open: boolean;\n };\n };\n items: GridItemDefinition[];\n repeatVariable?: string;\n };\n}\n\nexport interface GridItemDefinition {\n x: number;\n y: number;\n width: number;\n height: number;\n content: PanelRef;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAoBjC,WAMC"}
@@ -0,0 +1,48 @@
1
+ import { Notice } from './notice';
2
+ import { AbsoluteTimeRange } from './time';
3
+ import { Labels } from './time-series-queries';
4
+ export interface LogEntry {
5
+ timestamp: number;
6
+ line: string;
7
+ labels: Labels;
8
+ }
9
+ export interface LogData {
10
+ timeRange?: AbsoluteTimeRange;
11
+ entries: LogEntry[];
12
+ metadata?: LogMetadata;
13
+ totalCount?: number;
14
+ hasMore?: boolean;
15
+ direction?: 'forward' | 'backward';
16
+ }
17
+ export interface LogMetadata {
18
+ notices?: Notice[];
19
+ /**
20
+ * The raw query that is executed to generate this data.
21
+ * Useful when needing to inspect the query that was executed
22
+ * after variables and other context modifications have been applied.
23
+ */
24
+ executedQueryString?: string;
25
+ /**
26
+ * Statistics about the log query execution
27
+ */
28
+ stats?: LogQueryStats;
29
+ }
30
+ export interface LogQueryStats {
31
+ /**
32
+ * Number of bytes examined during the query
33
+ */
34
+ bytesExamined?: number;
35
+ /**
36
+ * Number of lines examined during the query
37
+ */
38
+ linesExamined?: number;
39
+ /**
40
+ * Query execution time in milliseconds
41
+ */
42
+ executionTimeMs?: number;
43
+ /**
44
+ * Number of streams processed
45
+ */
46
+ streamsProcessed?: number;
47
+ }
48
+ //# sourceMappingURL=log-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log-data.d.ts","sourceRoot":"","sources":["../../src/model/log-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;CACpC;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -1,4 +1,4 @@
1
- // Copyright 2023 The Perses Authors
1
+ // Copyright 2025 The Perses Authors
2
2
  // Licensed under the Apache License, Version 2.0 (the "License");
3
3
  // you may not use this file except in compliance with the License.
4
4
  // You may obtain a copy of the License at
@@ -10,6 +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
- export const SAVE_DEFAULTS_DIALOG_TEXT = 'You have made changes to the time range or the variables values. Would you like to save these as defaults?';
13
+ export { };
14
14
 
15
- //# sourceMappingURL=dialog.js.map
15
+ //# sourceMappingURL=log-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/log-data.ts"],"sourcesContent":["// Copyright 2025 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Notice } from './notice';\nimport { AbsoluteTimeRange } from './time';\nimport { Labels } from './time-series-queries';\n\nexport interface LogEntry {\n timestamp: number;\n line: string;\n labels: Labels;\n}\n\nexport interface LogData {\n timeRange?: AbsoluteTimeRange;\n entries: LogEntry[];\n metadata?: LogMetadata;\n totalCount?: number;\n hasMore?: boolean;\n direction?: 'forward' | 'backward';\n}\n\nexport interface LogMetadata {\n notices?: Notice[];\n\n /**\n * The raw query that is executed to generate this data.\n * Useful when needing to inspect the query that was executed\n * after variables and other context modifications have been applied.\n */\n executedQueryString?: string;\n\n /**\n * Statistics about the log query execution\n */\n stats?: LogQueryStats;\n}\n\nexport interface LogQueryStats {\n /**\n * Number of bytes examined during the query\n */\n bytesExamined?: number;\n\n /**\n * Number of lines examined during the query\n */\n linesExamined?: number;\n\n /**\n * Query execution time in milliseconds\n */\n executionTimeMs?: number;\n\n /**\n * Number of streams processed\n */\n streamsProcessed?: number;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAqCjC,WAoBC"}
@@ -2,6 +2,7 @@ import { Definition, UnknownSpec } from './definitions';
2
2
  import { TimeSeriesData } from './time-series-data';
3
3
  import { TraceData } from './trace-data';
4
4
  import { ProfileData } from './profile-data';
5
+ import { LogData } from './log-data';
5
6
  interface QuerySpec<PluginSpec> {
6
7
  plugin: Definition<PluginSpec>;
7
8
  }
@@ -19,6 +20,7 @@ export interface QueryType {
19
20
  TimeSeriesQuery: TimeSeriesData;
20
21
  TraceQuery: TraceData;
21
22
  ProfileQuery: ProfileData;
23
+ LogQuery: LogData;
22
24
  }
23
25
  /**
24
26
  * Check if the given type is a valid {@link QueryPluginType} with compile time safety
@@ -1 +1 @@
1
- {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/model/query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,UAAU,SAAS,CAAC,UAAU;IAC5B,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AACD;;GAEG;AAGH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,GAAG,EAAE,UAAU,GAAG,WAAW;IACnE,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,WAAW,CAAC;CAG3B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/model/query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,UAAU,SAAS,CAAC,UAAU;IAC5B,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AACD;;GAEG;AAGH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,GAAG,EAAE,UAAU,GAAG,WAAW;IACnE,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,WAAW,CAAC;IAC1B,QAAQ,EAAE,OAAO,CAAC;CAGnB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/query.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { TimeSeriesData } from './time-series-data';\nimport { TraceData } from './trace-data';\nimport { ProfileData } from './profile-data';\n\ninterface QuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n/**\n * A generic query definition interface that can be extended to support more than just TimeSeriesQuery\n */\n// Kind needs to be `any` because otherwise typescript will complain 'unknown' is not assignable to type '\"TimeSeriesQuery\"' in a few places\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {\n kind: Kind;\n spec: QuerySpec<PluginSpec>;\n}\n\n/**\n * Mapping the query plugin to the data type it returns\n */\nexport interface QueryType {\n TimeSeriesQuery: TimeSeriesData;\n TraceQuery: TraceData;\n ProfileQuery: ProfileData;\n // in the future we can add other query plugin and data types\n // for example: we can add something like `LogsQuery: LogsData;`\n}\n\n/**\n * Check if the given type is a valid {@link QueryPluginType} with compile time safety\n * @param type\n */\nexport function isValidQueryPluginType(type: string): type is QueryPluginType {\n return ['TimeSeriesQuery', 'TraceQuery', 'ProfileQuery'].includes(type as QueryPluginType);\n}\n\n/**\n * Extract the keys of QueryType\n * ex: 'TimeSeriesQuery'\n */\nexport type QueryPluginType = keyof QueryType;\n\n/**\n * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\n"],"names":["isValidQueryPluginType","type","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA+BjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
1
+ {"version":3,"sources":["../../src/model/query.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { TimeSeriesData } from './time-series-data';\nimport { TraceData } from './trace-data';\nimport { ProfileData } from './profile-data';\nimport { LogData } from './log-data';\n\ninterface QuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n/**\n * A generic query definition interface that can be extended to support more than just TimeSeriesQuery\n */\n// Kind needs to be `any` because otherwise typescript will complain 'unknown' is not assignable to type '\"TimeSeriesQuery\"' in a few places\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {\n kind: Kind;\n spec: QuerySpec<PluginSpec>;\n}\n\n/**\n * Mapping the query plugin to the data type it returns\n */\nexport interface QueryType {\n TimeSeriesQuery: TimeSeriesData;\n TraceQuery: TraceData;\n ProfileQuery: ProfileData;\n LogQuery: LogData;\n // in the future we can add other query plugin and data types\n // for example: we can add something like `LogsQuery: LogsData;`\n}\n\n/**\n * Check if the given type is a valid {@link QueryPluginType} with compile time safety\n * @param type\n */\nexport function isValidQueryPluginType(type: string): type is QueryPluginType {\n return ['TimeSeriesQuery', 'TraceQuery', 'ProfileQuery'].includes(type as QueryPluginType);\n}\n\n/**\n * Extract the keys of QueryType\n * ex: 'TimeSeriesQuery'\n */\nexport type QueryPluginType = keyof QueryType;\n\n/**\n * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\n"],"names":["isValidQueryPluginType","type","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAiCjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
@@ -1,5 +1,5 @@
1
1
  import { UnitGroupConfig, UnitConfig } from './types';
2
- type BytesUnit = 'bytes';
2
+ type BytesUnit = 'bytes' | 'decbytes';
3
3
  export type BytesFormatOptions = {
4
4
  unit?: BytesUnit;
5
5
  decimalPlaces?: number;
@@ -7,6 +7,6 @@ export type BytesFormatOptions = {
7
7
  };
8
8
  export declare const BYTES_GROUP_CONFIG: UnitGroupConfig;
9
9
  export declare const BYTES_UNIT_CONFIG: Readonly<Record<BytesUnit, UnitConfig>>;
10
- export declare function formatBytes(bytes: number, { shortValues, decimalPlaces }: BytesFormatOptions): string;
10
+ export declare function formatBytes(bytes: number, { unit, shortValues, decimalPlaces }: BytesFormatOptions): string;
11
11
  export {};
12
12
  //# sourceMappingURL=bytes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/model/units/bytes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAatD,KAAK,SAAS,GAAG,OAAO,CAAC;AACzB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,eAIhC,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAKrE,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,kBAAkB,GAAG,MAAM,CAmCrG"}
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/model/units/bytes.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmBtD,KAAK,SAAS,GAAG,OAAO,GAAG,UAAU,CAAC;AAEtC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,eAIhC,CAAC;AACF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CASrE,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAc,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,kBAAkB,GAAG,MAAM,CAsCrH"}
@@ -14,11 +14,17 @@ import numbro from 'numbro';
14
14
  import { MAX_SIGNIFICANT_DIGITS } from './constants';
15
15
  import { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';
16
16
  /**
17
- * We consider the units for bytes to be powers of 1000.
18
- * In other words:
17
+ * We support both SI (decimal) and IEC (binary) units for bytes:
18
+ *
19
+ * SI/decimal (unit: 'decbytes'):
19
20
  * 1 KB = 1000 bytes (1000^1 bytes)
20
21
  * 1 MB = 1,000,000 bytes (1000^2 bytes)
21
22
  * etc.
23
+ *
24
+ * IEC/binary (unit: 'bytes'):
25
+ * 1 KiB = 1024 bytes (1024^1 bytes)
26
+ * 1 MiB = 1,048,576 bytes (1024^2 bytes)
27
+ * etc.
22
28
  */ const DEFAULT_NUMBRO_MANTISSA = 2;
23
29
  export const BYTES_GROUP_CONFIG = {
24
30
  label: 'Bytes',
@@ -28,12 +34,18 @@ export const BYTES_GROUP_CONFIG = {
28
34
  export const BYTES_UNIT_CONFIG = {
29
35
  bytes: {
30
36
  group: 'Bytes',
31
- label: 'Bytes'
37
+ label: 'Bytes (IEC)'
38
+ },
39
+ decbytes: {
40
+ group: 'Bytes',
41
+ label: 'Bytes (SI)'
32
42
  }
33
43
  };
34
- export function formatBytes(bytes, { shortValues, decimalPlaces }) {
44
+ export function formatBytes(bytes, { unit = 'bytes', shortValues, decimalPlaces }) {
45
+ const isDecimal = unit === 'decbytes';
46
+ const threshold = isDecimal ? 1000 : 1024;
35
47
  // If we're showing the entire value, we can use Intl.NumberFormat.
36
- if (!shouldShortenValues(shortValues) || Math.abs(bytes) < 1000) {
48
+ if (!shouldShortenValues(shortValues) || Math.abs(bytes) < threshold) {
37
49
  const formatterOptions = {
38
50
  style: 'unit',
39
51
  unit: 'byte',
@@ -44,7 +56,7 @@ export function formatBytes(bytes, { shortValues, decimalPlaces }) {
44
56
  formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);
45
57
  formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);
46
58
  } else {
47
- // This can happen if bytes is between -1000 and 1000
59
+ // This can happen if bytes is between -threshold and threshold (1000 for SI, 1024 for IEC)
48
60
  if (shouldShortenValues(shortValues)) {
49
61
  formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
50
62
  }
@@ -56,7 +68,7 @@ export function formatBytes(bytes, { shortValues, decimalPlaces }) {
56
68
  // numbro is able to add units like KB, MB, GB, etc. correctly.
57
69
  return numbro(bytes).format({
58
70
  output: 'byte',
59
- base: 'decimal',
71
+ base: isDecimal ? 'decimal' : 'binary',
60
72
  spaceSeparated: true,
61
73
  mantissa: hasDecimalPlaces(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,
62
74
  // trimMantissa trims trailing 0s