@perses-dev/core 0.52.0-rc.1 → 0.53.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.
@@ -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
@@ -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,
@@ -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,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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/bytes.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 numbro from 'numbro';\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\n/**\n * We consider the units for bytes to be powers of 1000.\n * In other words:\n * 1 KB = 1000 bytes (1000^1 bytes)\n * 1 MB = 1,000,000 bytes (1000^2 bytes)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BytesUnit = 'bytes';\nexport type BytesFormatOptions = {\n unit?: BytesUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const BYTES_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bytes',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const BYTES_UNIT_CONFIG: Readonly<Record<BytesUnit, UnitConfig>> = {\n bytes: {\n group: 'Bytes',\n label: 'Bytes',\n },\n};\n\nexport function formatBytes(bytes: number, { shortValues, decimalPlaces }: BytesFormatOptions): string {\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bytes) < 1000) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: 'byte',\n unitDisplay: 'long',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n // This can happen if bytes is between -1000 and 1000\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(bytes);\n }\n\n // If we're showing the shorten value, we use numbro.\n // numbro is able to add units like KB, MB, GB, etc. correctly.\n return numbro(bytes).format({\n output: 'byte',\n base: 'decimal',\n spaceSeparated: true,\n mantissa: hasDecimalPlaces(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,\n // trimMantissa trims trailing 0s\n trimMantissa: !hasDecimalPlaces(decimalPlaces),\n // optionalMantissa excludes all the decimal places if they're all zeros\n optionalMantissa: !hasDecimalPlaces(decimalPlaces),\n });\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BYTES_GROUP_CONFIG","label","decimalPlaces","shortValues","BYTES_UNIT_CONFIG","bytes","group","formatBytes","Math","abs","formatterOptions","style","unit","unitDisplay","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa"],"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,OAAOA,YAAY,SAAS;AAE5B,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAEpF;;;;;;CAMC,GAED,MAAMC,0BAA0B;AAQhC,OAAO,MAAMC,qBAAsC;IACjDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AACF,OAAO,MAAMC,oBAA6D;IACxEC,OAAO;QACLC,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASM,YAAYF,KAAa,EAAE,EAAEF,WAAW,EAAED,aAAa,EAAsB;IAC3F,mEAAmE;IACnE,IAAI,CAACJ,oBAAoBK,gBAAgBK,KAAKC,GAAG,CAACJ,SAAS,MAAM;QAC/D,MAAMK,mBAA6C;YACjDC,OAAO;YACPC,MAAM;YACNC,aAAa;YACbC,aAAa;QACf;QAEA,IAAIlB,iBAAiBM,gBAAgB;YACnCQ,iBAAiBK,qBAAqB,GAAGlB,mBAAmBK;YAC5DQ,iBAAiBM,qBAAqB,GAAGnB,mBAAmBK;QAC9D,OAAO;YACL,qDAAqD;YACrD,IAAIJ,oBAAoBK,cAAc;gBACpCO,iBAAiBO,wBAAwB,GAAGtB;YAC9C;QACF;QACA,MAAMuB,YAAYC,KAAKC,YAAY,CAAC,SAASV;QAC7C,OAAOQ,UAAUG,MAAM,CAAChB;IAC1B;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,OAAOX,OAAOW,OAAOgB,MAAM,CAAC;QAC1BC,QAAQ;QACRC,MAAM;QACNC,gBAAgB;QAChBC,UAAU7B,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC2B,cAAc,CAAC9B,iBAAiBM;QAChC,wEAAwE;QACxEyB,kBAAkB,CAAC/B,iBAAiBM;IACtC;AACF"}
1
+ {"version":3,"sources":["../../../src/model/units/bytes.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 numbro from 'numbro';\n\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\n/**\n * We support both SI (decimal) and IEC (binary) units for bytes:\n *\n * SI/decimal (unit: 'decbytes'):\n * 1 KB = 1000 bytes (1000^1 bytes)\n * 1 MB = 1,000,000 bytes (1000^2 bytes)\n * etc.\n *\n * IEC/binary (unit: 'bytes'):\n * 1 KiB = 1024 bytes (1024^1 bytes)\n * 1 MiB = 1,048,576 bytes (1024^2 bytes)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BytesUnit = 'bytes' | 'decbytes';\n\nexport type BytesFormatOptions = {\n unit?: BytesUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\nexport const BYTES_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bytes',\n decimalPlaces: true,\n shortValues: true,\n};\nexport const BYTES_UNIT_CONFIG: Readonly<Record<BytesUnit, UnitConfig>> = {\n bytes: {\n group: 'Bytes',\n label: 'Bytes (IEC)',\n },\n decbytes: {\n group: 'Bytes',\n label: 'Bytes (SI)',\n },\n};\n\nexport function formatBytes(bytes: number, { unit = 'bytes', shortValues, decimalPlaces }: BytesFormatOptions): string {\n const isDecimal = unit === 'decbytes';\n const threshold = isDecimal ? 1000 : 1024;\n\n // If we're showing the entire value, we can use Intl.NumberFormat.\n if (!shouldShortenValues(shortValues) || Math.abs(bytes) < threshold) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'unit',\n unit: 'byte',\n unitDisplay: 'long',\n useGrouping: true,\n };\n\n if (hasDecimalPlaces(decimalPlaces)) {\n formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);\n formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);\n } else {\n // This can happen if bytes is between -threshold and threshold (1000 for SI, 1024 for IEC)\n if (shouldShortenValues(shortValues)) {\n formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;\n }\n }\n const formatter = Intl.NumberFormat('en-US', formatterOptions);\n return formatter.format(bytes);\n }\n\n // If we're showing the shorten value, we use numbro.\n // numbro is able to add units like KB, MB, GB, etc. correctly.\n return numbro(bytes).format({\n output: 'byte',\n base: isDecimal ? 'decimal' : 'binary',\n spaceSeparated: true,\n mantissa: hasDecimalPlaces(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,\n // trimMantissa trims trailing 0s\n trimMantissa: !hasDecimalPlaces(decimalPlaces),\n // optionalMantissa excludes all the decimal places if they're all zeros\n optionalMantissa: !hasDecimalPlaces(decimalPlaces),\n });\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BYTES_GROUP_CONFIG","label","decimalPlaces","shortValues","BYTES_UNIT_CONFIG","bytes","group","decbytes","formatBytes","unit","isDecimal","threshold","Math","abs","formatterOptions","style","unitDisplay","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","output","base","spaceSeparated","mantissa","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OAAOW,OAAOmB,MAAM,CAAC;QAC1BC,QAAQ;QACRC,MAAMhB,YAAY,YAAY;QAC9BiB,gBAAgB;QAChBC,UAAUhC,iBAAiBM,iBAAiBA,gBAAgBH;QAC5D,iCAAiC;QACjC8B,cAAc,CAACjC,iBAAiBM;QAChC,wEAAwE;QACxE4B,kBAAkB,CAAClC,iBAAiBM;IACtC;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { UnitGroupConfig, UnitConfig } from './types';
2
- type ThroughputUnit = 'bits/sec' | 'bytes/sec' | 'counts/sec' | 'events/sec' | 'messages/sec' | 'ops/sec' | 'packets/sec' | 'reads/sec' | 'records/sec' | 'requests/sec' | 'rows/sec' | 'writes/sec';
2
+ type ThroughputUnit = 'bits/sec' | 'bytes/sec' | 'decbytes/sec' | 'counts/sec' | 'events/sec' | 'messages/sec' | 'ops/sec' | 'packets/sec' | 'reads/sec' | 'records/sec' | 'requests/sec' | 'rows/sec' | 'writes/sec';
3
3
  export type ThroughputFormatOptions = {
4
4
  unit?: ThroughputUnit;
5
5
  decimalPlaces?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"throughput.d.ts","sourceRoot":"","sources":["../../../src/model/units/throughput.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,cAAc,GACf,UAAU,GACV,WAAW,GACX,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,CAiD/E,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,GAAG,MAAM,CA2BrH"}
1
+ {"version":3,"file":"throughput.d.ts","sourceRoot":"","sources":["../../../src/model/units/throughput.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGtD,KAAK,cAAc,GACf,UAAU,GACV,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,CAsD/E,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,uBAAuB,GAAG,MAAM,CAgCrH"}
@@ -25,7 +25,11 @@ export const THROUGHPUT_UNIT_CONFIG = {
25
25
  },
26
26
  'bytes/sec': {
27
27
  group: THROUGHPUT_GROUP,
28
- label: 'Bytes/sec'
28
+ label: 'Bytes/sec (IEC)'
29
+ },
30
+ 'decbytes/sec': {
31
+ group: THROUGHPUT_GROUP,
32
+ label: 'Bytes/sec (SI)'
29
33
  },
30
34
  'counts/sec': {
31
35
  group: THROUGHPUT_GROUP,
@@ -70,8 +74,16 @@ export const THROUGHPUT_UNIT_CONFIG = {
70
74
  };
71
75
  export function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
72
76
  // special case for data throughput
73
- if (unit === 'bytes/sec') {
77
+ if (unit === 'decbytes/sec') {
74
78
  const denominator = Math.abs(value) < 1000 ? 'sec' : 's';
79
+ return formatBytes(value, {
80
+ unit: 'decbytes',
81
+ shortValues,
82
+ decimalPlaces
83
+ }) + '/' + denominator;
84
+ }
85
+ if (unit === 'bytes/sec') {
86
+ const denominator = Math.abs(value) < 1024 ? 'sec' : 's';
75
87
  return formatBytes(value, {
76
88
  unit: 'bytes',
77
89
  shortValues,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/model/units/throughput.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes } from './bytes';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype ThroughputUnit =\n | 'bits/sec'\n | 'bytes/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',\n },\n 'bytes/sec': {\n group: THROUGHPUT_GROUP,\n label: 'Bytes/sec',\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 === 'bytes/sec') {\n const denominator = Math.abs(value) < 1000 ? '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","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","THROUGHPUT_GROUP_CONFIG","label","decimalPlaces","THROUGHPUT_GROUP","THROUGHPUT_UNIT_CONFIG","group","formatThroughput","value","unit","shortValues","denominator","Math","abs","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAoBpF,OAAO,MAAMC,0BAA2C;IACtDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,mBAAmB;AACzB,OAAO,MAAMC,yBAAuE;IAClF,YAAY;QACVC,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,WAAW;QACTI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,aAAa;QACXI,OAAOF;QACPF,OAAO;IACT;IACA,gBAAgB;QACdI,OAAOF;QACPF,OAAO;IACT;IACA,eAAe;QACbI,OAAOF;QACPF,OAAO;IACT;IACA,YAAY;QACVI,OAAOF;QACPF,OAAO;IACT;IACA,cAAc;QACZI,OAAOF;QACPF,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASK,iBAAiBC,KAAa,EAAE,EAAEC,IAAI,EAAEC,WAAW,EAAEP,aAAa,EAA2B;IAC3G,mCAAmC;IACnC,IAAIM,SAAS,aAAa;QACxB,MAAME,cAAcC,KAAKC,GAAG,CAACL,SAAS,OAAO,QAAQ;QACrD,OAAOZ,YAAYY,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 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { formatBytes } from './bytes';\nimport { MAX_SIGNIFICANT_DIGITS } from './constants';\nimport { UnitGroupConfig, UnitConfig } from './types';\nimport { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';\n\ntype ThroughputUnit =\n | 'bits/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',\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 === '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","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","THROUGHPUT_GROUP_CONFIG","label","decimalPlaces","THROUGHPUT_GROUP","THROUGHPUT_UNIT_CONFIG","group","formatThroughput","value","unit","shortValues","denominator","Math","abs","formatterOptions","style","useGrouping","notation","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,SAASA,WAAW,QAAQ,UAAU;AACtC,SAASC,sBAAsB,QAAQ,cAAc;AAErD,SAASC,gBAAgB,EAAEC,kBAAkB,EAAEC,mBAAmB,QAAQ,UAAU;AAqBpF,OAAO,MAAMC,0BAA2C;IACtDC,OAAO;IACPC,eAAe;AACjB,EAAE;AACF,MAAMC,mBAAmB;AACzB,OAAO,MAAMC,yBAAuE;IAClF,YAAY;QACVC,OAAOF;QACPF,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c;YACpCI,iBAAiBM,wBAAwB,GAAGvB;QAC9C;IACF;IAEA,MAAMwB,YAAYC,KAAKC,YAAY,CAAC,SAAST;IAC7C,OAAOO,UAAUG,MAAM,CAAChB,SAAS,MAAMC;AACzC"}
@@ -31,6 +31,7 @@ export declare const UNIT_CONFIG: {
31
31
  readonly usd: UnitConfig;
32
32
  readonly "bits/sec": UnitConfig;
33
33
  readonly "bytes/sec": UnitConfig;
34
+ readonly "decbytes/sec": UnitConfig;
34
35
  readonly "counts/sec": UnitConfig;
35
36
  readonly "events/sec": UnitConfig;
36
37
  readonly "messages/sec": UnitConfig;
@@ -42,6 +43,7 @@ export declare const UNIT_CONFIG: {
42
43
  readonly "rows/sec": UnitConfig;
43
44
  readonly "writes/sec": UnitConfig;
44
45
  readonly bytes: UnitConfig;
46
+ readonly decbytes: UnitConfig;
45
47
  readonly decimal: UnitConfig;
46
48
  readonly percent: UnitConfig;
47
49
  readonly "percent-decimal": UnitConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"units.d.ts","sourceRoot":"","sources":["../../../src/model/units/units.ts"],"names":[],"mappings":"AAaA,OAAO,EAAe,kBAAkB,IAAI,kBAAkB,EAAyC,MAAM,SAAS,CAAC;AACvH,OAAO,EAEL,oBAAoB,IAAI,oBAAoB,EAG7C,MAAM,WAAW,CAAC;AACnB,OAAO,EAEL,oBAAoB,IAAI,oBAAoB,EAG7C,MAAM,WAAW,CAAC;AACnB,OAAO,EAAc,iBAAiB,IAAI,iBAAiB,EAAuC,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAIL,uBAAuB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAA+D,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEhH;;;;;;GAMG;AAEH,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,eAAe,CAAC,CAO1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KAAK,CAAC;AAE3F,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,aAAa,GAAG,MAAM,CA+BhF;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,UAAU,CAGtE;AAED,wBAAgB,YAAY,CAAC,aAAa,EAAE,aAAa,GAAG,SAAS,CAEpE;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe,CAGhF;AAGD,wBAAgB,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,iBAAiB,CAE3F;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,oBAAoB,CAEjG;AAED,wBAAgB,aAAa,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,oBAAoB,CAEjG;AAED,wBAAgB,WAAW,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,kBAAkB,CAE7F;AAED,wBAAgB,uBAAuB,CACrC,aAAa,EAAE,aAAa,GAC3B,aAAa,IAAI,gBAAgB,CAAC,aAAa,CAAC,CAIlD;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,cAAc,CAAC,aAAa,CAAC,CAIlH;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,uBAAuB,CAEvG;AAED,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,aAAa,IAAI,qBAAqB,CAEnG"}
@@ -1,13 +1,13 @@
1
1
  /**
2
- * Calls `global.fetch` and determines which type of error to show for non-200 responses.
2
+ * Calls `globalThis.fetch` and determines which type of error to show for non-200 responses.
3
3
  */
4
- export declare function fetch(...args: Parameters<typeof global.fetch>): Promise<Response>;
4
+ export declare function fetch(...args: Parameters<typeof globalThis.fetch>): Promise<Response>;
5
5
  /**
6
- * Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also
6
+ * Calls `globalThis.fetch` and throws a `FetchError` on non-200 responses, but also
7
7
  * decodes the response body as JSON, casting it to type `T`. Returns the
8
8
  * decoded body.
9
9
  */
10
- export declare function fetchJson<T>(...args: Parameters<typeof global.fetch>): Promise<T>;
10
+ export declare function fetchJson<T>(...args: Parameters<typeof globalThis.fetch>): Promise<T>;
11
11
  export interface StatusError extends Error {
12
12
  status: number;
13
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqBvF;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAMvF;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAM,YAAW,WAAW;IAC1D,MAAM,EAAE,MAAM,CAAC;gBACH,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAKzC;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAM,YAAW,WAAW;IACjE,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C"}
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/utils/fetch.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,wBAAsB,KAAK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAqB3F;AAED;;;;GAIG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAM3F;AAED,MAAM,WAAW,WAAY,SAAQ,KAAK;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,qBAAa,UAAW,SAAQ,KAAM,YAAW,WAAW;IAC1D,MAAM,EAAE,MAAM,CAAC;gBACH,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC;CAKzC;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,KAAM,YAAW,WAAW;IACjE,MAAM,EAAE,MAAM,CAAC;gBACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAK5C"}
@@ -11,9 +11,9 @@
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
  */ export async function fetch(...args) {
16
- const response = await global.fetch(...args);
16
+ const response = await globalThis.fetch(...args);
17
17
  if (response.ok === false) {
18
18
  const contentType = response.headers.get('content-type');
19
19
  if (contentType?.includes('application/json')) {
@@ -34,7 +34,7 @@
34
34
  return response;
35
35
  }
36
36
  /**
37
- * Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also
37
+ * Calls `globalThis.fetch` and throws a `FetchError` on non-200 responses, but also
38
38
  * decodes the response body as JSON, casting it to type `T`. Returns the
39
39
  * decoded body.
40
40
  */ export async function fetchJson(...args) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/fetch.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Calls `global.fetch` and determines which type of error to show for non-200 responses.\n */\nexport async function fetch(...args: Parameters<typeof global.fetch>): Promise<Response> {\n const response = await global.fetch(...args);\n if (response.ok === false) {\n const contentType = response.headers.get('content-type');\n if (contentType?.includes('application/json')) {\n const json = await response.clone().json();\n if (json.error) {\n throw new UserFriendlyError(json.error, response.status);\n }\n if (json.message) {\n throw new UserFriendlyError(json.message, response.status);\n }\n }\n\n const text = await response.clone().text();\n if (text) {\n throw new UserFriendlyError(text, response.status);\n }\n throw new FetchError(response);\n }\n return response;\n}\n\n/**\n * Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also\n * decodes the response body as JSON, casting it to type `T`. Returns the\n * decoded body.\n */\nexport async function fetchJson<T>(...args: Parameters<typeof global.fetch>): Promise<T> {\n const response = await fetch(...args);\n if (!response.ok) {\n throw new FetchError(response);\n }\n return await response.json();\n}\n\nexport interface StatusError extends Error {\n status: number;\n}\n\n/**\n * Error thrown when fetch returns a non-200 response.\n */\nexport class FetchError extends Error implements StatusError {\n status: number;\n constructor(response: Readonly<Response>) {\n super(`${response.status} ${response.statusText}`);\n this.status = response.status;\n Object.setPrototypeOf(this, FetchError.prototype);\n }\n}\n\n/**\n * General error type for an error that has a message that is OK to show to the end user.\n */\nexport class UserFriendlyError extends Error implements StatusError {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n Object.setPrototypeOf(this, UserFriendlyError.prototype);\n }\n}\n"],"names":["fetch","args","response","global","ok","contentType","headers","get","includes","json","clone","error","UserFriendlyError","status","message","text","FetchError","fetchJson","Error","constructor","statusText","Object","setPrototypeOf","prototype"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E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,CAAE;QAC3C,KAAK,CAACC;QACN,IAAI,CAACD,MAAM,GAAGA;QACdQ,OAAOC,cAAc,CAAC,IAAI,EAAEV,kBAAkBW,SAAS;IACzD;AACF"}
1
+ {"version":3,"sources":["../../src/utils/fetch.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Calls `globalThis.fetch` and determines which type of error to show for non-200 responses.\n */\nexport async function fetch(...args: Parameters<typeof globalThis.fetch>): Promise<Response> {\n const response = await globalThis.fetch(...args);\n if (response.ok === false) {\n const contentType = response.headers.get('content-type');\n if (contentType?.includes('application/json')) {\n const json = await response.clone().json();\n if (json.error) {\n throw new UserFriendlyError(json.error, response.status);\n }\n if (json.message) {\n throw new UserFriendlyError(json.message, response.status);\n }\n }\n\n const text = await response.clone().text();\n if (text) {\n throw new UserFriendlyError(text, response.status);\n }\n throw new FetchError(response);\n }\n return response;\n}\n\n/**\n * Calls `globalThis.fetch` and throws a `FetchError` on non-200 responses, but also\n * decodes the response body as JSON, casting it to type `T`. Returns the\n * decoded body.\n */\nexport async function fetchJson<T>(...args: Parameters<typeof globalThis.fetch>): Promise<T> {\n const response = await fetch(...args);\n if (!response.ok) {\n throw new FetchError(response);\n }\n return await response.json();\n}\n\nexport interface StatusError extends Error {\n status: number;\n}\n\n/**\n * Error thrown when fetch returns a non-200 response.\n */\nexport class FetchError extends Error implements StatusError {\n status: number;\n constructor(response: Readonly<Response>) {\n super(`${response.status} ${response.statusText}`);\n this.status = response.status;\n Object.setPrototypeOf(this, FetchError.prototype);\n }\n}\n\n/**\n * General error type for an error that has a message that is OK to show to the end user.\n */\nexport class UserFriendlyError extends Error implements StatusError {\n status: number;\n constructor(message: string, status: number) {\n super(message);\n this.status = status;\n Object.setPrototypeOf(this, UserFriendlyError.prototype);\n }\n}\n"],"names":["fetch","args","response","globalThis","ok","contentType","headers","get","includes","json","clone","error","UserFriendlyError","status","message","text","FetchError","fetchJson","Error","constructor","statusText","Object","setPrototypeOf","prototype"],"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;;CAEC,GACD,OAAO,eAAeA,MAAM,GAAGC,IAAyC;IACtE,MAAMC,WAAW,MAAMC,WAAWH,KAAK,IAAIC;IAC3C,IAAIC,SAASE,EAAE,KAAK,OAAO;QACzB,MAAMC,cAAcH,SAASI,OAAO,CAACC,GAAG,CAAC;QACzC,IAAIF,aAAaG,SAAS,qBAAqB;YAC7C,MAAMC,OAAO,MAAMP,SAASQ,KAAK,GAAGD,IAAI;YACxC,IAAIA,KAAKE,KAAK,EAAE;gBACd,MAAM,IAAIC,kBAAkBH,KAAKE,KAAK,EAAET,SAASW,MAAM;YACzD;YACA,IAAIJ,KAAKK,OAAO,EAAE;gBAChB,MAAM,IAAIF,kBAAkBH,KAAKK,OAAO,EAAEZ,SAASW,MAAM;YAC3D;QACF;QAEA,MAAME,OAAO,MAAMb,SAASQ,KAAK,GAAGK,IAAI;QACxC,IAAIA,MAAM;YACR,MAAM,IAAIH,kBAAkBG,MAAMb,SAASW,MAAM;QACnD;QACA,MAAM,IAAIG,WAAWd;IACvB;IACA,OAAOA;AACT;AAEA;;;;CAIC,GACD,OAAO,eAAee,UAAa,GAAGhB,IAAyC;IAC7E,MAAMC,WAAW,MAAMF,SAASC;IAChC,IAAI,CAACC,SAASE,EAAE,EAAE;QAChB,MAAM,IAAIY,WAAWd;IACvB;IACA,OAAO,MAAMA,SAASO,IAAI;AAC5B;AAMA;;CAEC,GACD,OAAO,MAAMO,mBAAmBE;IAC9BL,OAAe;IACfM,YAAYjB,QAA4B,CAAE;QACxC,KAAK,CAAC,GAAGA,SAASW,MAAM,CAAC,CAAC,EAAEX,SAASkB,UAAU,EAAE;QACjD,IAAI,CAACP,MAAM,GAAGX,SAASW,MAAM;QAC7BQ,OAAOC,cAAc,CAAC,IAAI,EAAEN,WAAWO,SAAS;IAClD;AACF;AAEA;;CAEC,GACD,OAAO,MAAMX,0BAA0BM;IACrCL,OAAe;IACfM,YAAYL,OAAe,EAAED,MAAc,CAAE;QAC3C,KAAK,CAACC;QACN,IAAI,CAACD,MAAM,GAAGA;QACdQ,OAAOC,cAAc,CAAC,IAAI,EAAEV,kBAAkBW,SAAS;IACzD;AACF"}
@@ -121,7 +121,7 @@ import { useMemo } from 'react';
121
121
  */ export function applyMergeIndexedColumnsTransform(data, column) {
122
122
  const result = [];
123
123
  for (const entry of data){
124
- const indexedColumns = Object.keys(entry).filter((k)=>new RegExp('^(' + column + ' #\\d+)|(' + column + ')$').test(k));
124
+ const indexedColumns = Object.keys(entry).filter((k)=>new RegExp('^((' + column + ' #\\d+)|(' + column + '))$').test(k));
125
125
  const indexedColumnValues = {};
126
126
  for (const indexedColumn of indexedColumns){
127
127
  indexedColumnValues[indexedColumn] = entry[indexedColumn];
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/transform-data.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Transform } from '@perses-dev/core';\nimport { useMemo } from 'react';\n\n/*\n * Join: Regroup rows with equal cell value in a column.\n * If there are multiple line with same value, next row values override the current one\n *\n * Example: Join on 'mount' column\n * INPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | | / |\n * | 1630000000 | 2 | | /boot/efi |\n * | 1630000000 | | 3 | / |\n * | 1630000000 | | 4 | /boot/efi |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | 3 | / |\n * | 1630000000 | 2 | 4 | /boot/efi |\n */\nexport function applyJoinTransform(\n data: Array<Record<string, unknown>>,\n columns: string[]\n): Array<Record<string, unknown>> {\n // If column is undefined or empty, return data as is\n if (columns.length === 0) {\n return data;\n }\n\n const rowHashed: { [key: string]: Record<string, unknown> } = {};\n\n for (const row of data) {\n const rowHash = Object.keys(row)\n .filter((k) => columns.includes(k))\n .map((k) => row[k])\n .join('|');\n\n const rowHashedValue = rowHashed[rowHash];\n if (rowHashedValue) {\n rowHashed[rowHash] = { ...rowHashedValue, ...row };\n } else {\n rowHashed[rowHash] = { ...row };\n }\n }\n return Object.values(rowHashed);\n}\n\n/*\n * Merges selected columns into a single column.\n *\n * Example: Merge columns 'value #1' and 'value #2' into a single column 'MERGED'\n * INPUT:\n * +------------+----------+----------+-----------+-----------+\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 |\n * +------------+----------+----------+-----------+-----------+\n * | 1630000000 | 1 | | / | |\n * | 1630000000 | 2 | | /boot/efi | |\n * | 1630000000 | | 3 | | / |\n * | 1630000000 | | 4 | | /boot/efi |\n * +------------+----------+----------+-----------+-----------+\n *\n * OUTPUT:\n * +------------+--------+-----------+-----------+\n * | timestamp | MERGED | mount #1 | mount #2 |\n * +------------+--------+-----------+-----------+\n * | 1630000000 | 1 | / | |\n * | 1630000000 | 2 | /boot/efi | |\n * | 1630000000 | 2 | | / |\n * | 1630000000 | 3 | | /boot/efi |\n * +------------+--------+-----------+-----------+\n */\nexport function applyMergeColumnsTransform(\n data: Array<Record<string, unknown>>,\n selectedColumns: string[],\n outputName: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const row of data) {\n const columns = Object.keys(row).filter((k) => selectedColumns.includes(k));\n\n const selectedColumnValues: Record<string, unknown> = {};\n\n for (const column of columns) {\n selectedColumnValues[column] = row[column];\n delete row[column];\n }\n\n for (const column of columns) {\n result.push({ ...row, [outputName]: selectedColumnValues[column] });\n }\n\n if (columns.length === 0) {\n result.push(row);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * Example: Join on 'value' column\n * INPUT:\n * | timestamp #1 | timestamp #2 | value #1 | value #2 | instance #1 | instance #2 |\n * |--------------|--------------|----------|----------|-------------|-------------|\n * | 1630000000 | | 55 | | toto | |\n * | 1630000000 | | 33 | | toto | |\n * | 1630000000 | | 45 | | toto | |\n * | | 1630000000 | | 112 | | titi |\n * | | 1630000000 | | 20 | | titi |\n * | | 1630000000 | | 10 | | titi |\n *\n * OUTPUT:\n * | timestamp #1 | timestamp #2 | value | instance #1 | instance #2 |\n * |--------------|--------------|-------|-------------|-------------|\n * | 1630000000 | | 55 | toto | |\n * | 1630000000 | | 33 | toto | |\n * | 1630000000 | | 45 | toto | |\n * | | 1630000000 | 112 | | titi |\n * | | 1630000000 | 20 | | titi |\n * | | 1630000000 | 10 | | titi |\n */\nexport function applyMergeIndexedColumnsTransform(\n data: Array<Record<string, unknown>>,\n column: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const entry of data) {\n const indexedColumns = Object.keys(entry).filter((k) =>\n new RegExp('^(' + column + ' #\\\\d+)|(' + column + ')$').test(k)\n );\n const indexedColumnValues: Record<string, unknown> = {};\n\n for (const indexedColumn of indexedColumns) {\n indexedColumnValues[indexedColumn] = entry[indexedColumn];\n delete entry[indexedColumn];\n }\n\n for (const indexedColumn of indexedColumns) {\n result.push({ ...entry, [column]: indexedColumnValues[indexedColumn] });\n }\n\n if (indexedColumns.length === 0) {\n result.push(entry);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * INPUT:\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 | instance #1 | instance #2 | env #1 | env #2 |\n * |------------|----------|----------|-----------|-----------|-------------|-------------|--------|--------|\n * | 1630000000 | 1 | | / | | test:44 | | prd | |\n * | 1630000000 | 2 | | /boot/efi | | test:44 | | prd | |\n * | 1630000000 | | 5 | | / | | test:44 | | prd |\n * | 1630000000 | | 6 | | /boot/efi | | test:44 | | prd |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #2 | mount | instance | env |\n * |------------|----------|----------|-----------|----------|-----|\n * | 1630000000 | 1 | 5 | / | test:44 | prd |\n * | 1630000000 | 2 | 6 | /boot/efi | test:44 | prd |\n */\nexport function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = [...data];\n\n const labelColumns = Array.from(\n new Set(\n data\n .flatMap(Object.keys)\n .map((label) => label.replace(/ #\\d+/, ''))\n .filter((label) => label !== 'value')\n )\n );\n\n for (const label of labelColumns) {\n result = applyMergeIndexedColumnsTransform(result, label);\n }\n\n result = applyJoinTransform(result, labelColumns);\n\n return result;\n}\n\n/*\n * Transforms query data with the given transforms\n */\nexport function transformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = data;\n\n // Apply transforms by their orders\n for (const transform of transforms ?? []) {\n if (transform.spec.disabled) continue;\n\n switch (transform.kind) {\n case 'JoinByColumnValue': {\n if (transform.spec.columns && transform.spec.columns.length > 0) {\n result = applyJoinTransform(result, transform.spec.columns);\n }\n break;\n }\n case 'MergeIndexedColumns': {\n if (transform.spec.column) {\n result = applyMergeIndexedColumnsTransform(result, transform.spec.column);\n }\n break;\n }\n case 'MergeColumns': {\n if (transform.spec.columns && transform.spec.columns.length > 0 && transform.spec.name) {\n result = applyMergeColumnsTransform(result, transform.spec.columns, transform.spec.name);\n }\n break;\n }\n case 'MergeSeries': {\n result = applyMergeSeriesTransform(result);\n break;\n }\n }\n }\n\n // Ordering data column alphabetically\n result = result.map((row) => {\n return Object.keys(row)\n .sort()\n .reduce((obj: Record<string, unknown>, key: string) => {\n obj[key] = row[key];\n return obj;\n }, {});\n });\n return result;\n}\n\nexport function useTransformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n return useMemo(() => transformData(data, transforms), [data, transforms]);\n}\n"],"names":["useMemo","applyJoinTransform","data","columns","length","rowHashed","row","rowHash","Object","keys","filter","k","includes","map","join","rowHashedValue","values","applyMergeColumnsTransform","selectedColumns","outputName","result","selectedColumnValues","column","push","applyMergeIndexedColumnsTransform","entry","indexedColumns","RegExp","test","indexedColumnValues","indexedColumn","applyMergeSeriesTransform","labelColumns","Array","from","Set","flatMap","label","replace","transformData","transforms","transform","spec","disabled","kind","name","sort","reduce","obj","key","useTransformData"],"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;AAGjC,SAASA,OAAO,QAAQ,QAAQ;AAEhC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,mBACdC,IAAoC,EACpCC,OAAiB;IAEjB,qDAAqD;IACrD,IAAIA,QAAQC,MAAM,KAAK,GAAG;QACxB,OAAOF;IACT;IAEA,MAAMG,YAAwD,CAAC;IAE/D,KAAK,MAAMC,OAAOJ,KAAM;QACtB,MAAMK,UAAUC,OAAOC,IAAI,CAACH,KACzBI,MAAM,CAAC,CAACC,IAAMR,QAAQS,QAAQ,CAACD,IAC/BE,GAAG,CAAC,CAACF,IAAML,GAAG,CAACK,EAAE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BACA;gBACF;YACA,KAAK;gBAAuB;oBAC1B,IAAIsC,UAAUC,IAAI,CAACpB,MAAM,EAAE;wBACzBF,SAASI,kCAAkCJ,QAAQqB,UAAUC,IAAI,CAACpB,MAAM;oBAC1E;oBACA;gBACF;YACA,KAAK;gBAAgB;oBACnB,IAAImB,UAAUC,IAAI,CAACvC,OAAO,IAAIsC,UAAUC,IAAI,CAACvC,OAAO,CAACC,MAAM,GAAG,KAAKqC,UAAUC,IAAI,CAACG,IAAI,EAAE;wBACtFzB,SAASH,2BAA2BG,QAAQqB,UAAUC,IAAI,CAACvC,OAAO,EAAEsC,UAAUC,IAAI,CAACG,IAAI;oBACzF;oBACA;gBACF;YACA,KAAK;gBAAe;oBAClBzB,SAASW,0BAA0BX;oBACnC;gBACF;QACF;IACF;IAEA,sCAAsC;IACtCA,SAASA,OAAOP,GAAG,CAAC,CAACP;QACnB,OAAOE,OAAOC,IAAI,CAACH,KAChBwC,IAAI,GACJC,MAAM,CAAC,CAACC,KAA8BC;YACrCD,GAAG,CAACC,IAAI,GAAG3C,GAAG,CAAC2C,IAAI;YACnB,OAAOD;QACT,GAAG,CAAC;IACR;IACA,OAAO5B;AACT;AAEA,OAAO,SAAS8B,iBACdhD,IAAoC,EACpCsC,UAAuB;IAEvB,OAAOxC,QAAQ,IAAMuC,cAAcrC,MAAMsC,aAAa;QAACtC;QAAMsC;KAAW;AAC1E"}
1
+ {"version":3,"sources":["../../src/utils/transform-data.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Transform } from '@perses-dev/core';\nimport { useMemo } from 'react';\n\n/*\n * Join: Regroup rows with equal cell value in a column.\n * If there are multiple line with same value, next row values override the current one\n *\n * Example: Join on 'mount' column\n * INPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | | / |\n * | 1630000000 | 2 | | /boot/efi |\n * | 1630000000 | | 3 | / |\n * | 1630000000 | | 4 | /boot/efi |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #3 | mount |\n * |------------|----------|----------|-----------|\n * | 1630000000 | 1 | 3 | / |\n * | 1630000000 | 2 | 4 | /boot/efi |\n */\nexport function applyJoinTransform(\n data: Array<Record<string, unknown>>,\n columns: string[]\n): Array<Record<string, unknown>> {\n // If column is undefined or empty, return data as is\n if (columns.length === 0) {\n return data;\n }\n\n const rowHashed: { [key: string]: Record<string, unknown> } = {};\n\n for (const row of data) {\n const rowHash = Object.keys(row)\n .filter((k) => columns.includes(k))\n .map((k) => row[k])\n .join('|');\n\n const rowHashedValue = rowHashed[rowHash];\n if (rowHashedValue) {\n rowHashed[rowHash] = { ...rowHashedValue, ...row };\n } else {\n rowHashed[rowHash] = { ...row };\n }\n }\n return Object.values(rowHashed);\n}\n\n/*\n * Merges selected columns into a single column.\n *\n * Example: Merge columns 'value #1' and 'value #2' into a single column 'MERGED'\n * INPUT:\n * +------------+----------+----------+-----------+-----------+\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 |\n * +------------+----------+----------+-----------+-----------+\n * | 1630000000 | 1 | | / | |\n * | 1630000000 | 2 | | /boot/efi | |\n * | 1630000000 | | 3 | | / |\n * | 1630000000 | | 4 | | /boot/efi |\n * +------------+----------+----------+-----------+-----------+\n *\n * OUTPUT:\n * +------------+--------+-----------+-----------+\n * | timestamp | MERGED | mount #1 | mount #2 |\n * +------------+--------+-----------+-----------+\n * | 1630000000 | 1 | / | |\n * | 1630000000 | 2 | /boot/efi | |\n * | 1630000000 | 2 | | / |\n * | 1630000000 | 3 | | /boot/efi |\n * +------------+--------+-----------+-----------+\n */\nexport function applyMergeColumnsTransform(\n data: Array<Record<string, unknown>>,\n selectedColumns: string[],\n outputName: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const row of data) {\n const columns = Object.keys(row).filter((k) => selectedColumns.includes(k));\n\n const selectedColumnValues: Record<string, unknown> = {};\n\n for (const column of columns) {\n selectedColumnValues[column] = row[column];\n delete row[column];\n }\n\n for (const column of columns) {\n result.push({ ...row, [outputName]: selectedColumnValues[column] });\n }\n\n if (columns.length === 0) {\n result.push(row);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * Example: Join on 'value' column\n * INPUT:\n * | timestamp #1 | timestamp #2 | value #1 | value #2 | instance #1 | instance #2 |\n * |--------------|--------------|----------|----------|-------------|-------------|\n * | 1630000000 | | 55 | | toto | |\n * | 1630000000 | | 33 | | toto | |\n * | 1630000000 | | 45 | | toto | |\n * | | 1630000000 | | 112 | | titi |\n * | | 1630000000 | | 20 | | titi |\n * | | 1630000000 | | 10 | | titi |\n *\n * OUTPUT:\n * | timestamp #1 | timestamp #2 | value | instance #1 | instance #2 |\n * |--------------|--------------|-------|-------------|-------------|\n * | 1630000000 | | 55 | toto | |\n * | 1630000000 | | 33 | toto | |\n * | 1630000000 | | 45 | toto | |\n * | | 1630000000 | 112 | | titi |\n * | | 1630000000 | 20 | | titi |\n * | | 1630000000 | 10 | | titi |\n */\nexport function applyMergeIndexedColumnsTransform(\n data: Array<Record<string, unknown>>,\n column: string\n): Array<Record<string, unknown>> {\n const result: Array<Record<string, unknown>> = [];\n\n for (const entry of data) {\n const indexedColumns = Object.keys(entry).filter((k) =>\n new RegExp('^((' + column + ' #\\\\d+)|(' + column + '))$').test(k)\n );\n const indexedColumnValues: Record<string, unknown> = {};\n\n for (const indexedColumn of indexedColumns) {\n indexedColumnValues[indexedColumn] = entry[indexedColumn];\n delete entry[indexedColumn];\n }\n\n for (const indexedColumn of indexedColumns) {\n result.push({ ...entry, [column]: indexedColumnValues[indexedColumn] });\n }\n\n if (indexedColumns.length === 0) {\n result.push(entry);\n }\n }\n\n return result;\n}\n\n/*\n * Merge Indexed Columns: All indexed columns are merged to one column\n *\n * INPUT:\n * | timestamp | value #1 | value #2 | mount #1 | mount #2 | instance #1 | instance #2 | env #1 | env #2 |\n * |------------|----------|----------|-----------|-----------|-------------|-------------|--------|--------|\n * | 1630000000 | 1 | | / | | test:44 | | prd | |\n * | 1630000000 | 2 | | /boot/efi | | test:44 | | prd | |\n * | 1630000000 | | 5 | | / | | test:44 | | prd |\n * | 1630000000 | | 6 | | /boot/efi | | test:44 | | prd |\n *\n * OUTPUT:\n * | timestamp | value #1 | value #2 | mount | instance | env |\n * |------------|----------|----------|-----------|----------|-----|\n * | 1630000000 | 1 | 5 | / | test:44 | prd |\n * | 1630000000 | 2 | 6 | /boot/efi | test:44 | prd |\n */\nexport function applyMergeSeriesTransform(data: Array<Record<string, unknown>>): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = [...data];\n\n const labelColumns = Array.from(\n new Set(\n data\n .flatMap(Object.keys)\n .map((label) => label.replace(/ #\\d+/, ''))\n .filter((label) => label !== 'value')\n )\n );\n\n for (const label of labelColumns) {\n result = applyMergeIndexedColumnsTransform(result, label);\n }\n\n result = applyJoinTransform(result, labelColumns);\n\n return result;\n}\n\n/*\n * Transforms query data with the given transforms\n */\nexport function transformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n let result: Array<Record<string, unknown>> = data;\n\n // Apply transforms by their orders\n for (const transform of transforms ?? []) {\n if (transform.spec.disabled) continue;\n\n switch (transform.kind) {\n case 'JoinByColumnValue': {\n if (transform.spec.columns && transform.spec.columns.length > 0) {\n result = applyJoinTransform(result, transform.spec.columns);\n }\n break;\n }\n case 'MergeIndexedColumns': {\n if (transform.spec.column) {\n result = applyMergeIndexedColumnsTransform(result, transform.spec.column);\n }\n break;\n }\n case 'MergeColumns': {\n if (transform.spec.columns && transform.spec.columns.length > 0 && transform.spec.name) {\n result = applyMergeColumnsTransform(result, transform.spec.columns, transform.spec.name);\n }\n break;\n }\n case 'MergeSeries': {\n result = applyMergeSeriesTransform(result);\n break;\n }\n }\n }\n\n // Ordering data column alphabetically\n result = result.map((row) => {\n return Object.keys(row)\n .sort()\n .reduce((obj: Record<string, unknown>, key: string) => {\n obj[key] = row[key];\n return obj;\n }, {});\n });\n return result;\n}\n\nexport function useTransformData(\n data: Array<Record<string, unknown>>,\n transforms: Transform[]\n): Array<Record<string, unknown>> {\n return useMemo(() => transformData(data, transforms), [data, transforms]);\n}\n"],"names":["useMemo","applyJoinTransform","data","columns","length","rowHashed","row","rowHash","Object","keys","filter","k","includes","map","join","rowHashedValue","values","applyMergeColumnsTransform","selectedColumns","outputName","result","selectedColumnValues","column","push","applyMergeIndexedColumnsTransform","entry","indexedColumns","RegExp","test","indexedColumnValues","indexedColumn","applyMergeSeriesTransform","labelColumns","Array","from","Set","flatMap","label","replace","transformData","transforms","transform","spec","disabled","kind","name","sort","reduce","obj","key","useTransformData"],"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;AAGjC,SAASA,OAAO,QAAQ,QAAQ;AAEhC;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,SAASC,mBACdC,IAAoC,EACpCC,OAAiB;IAEjB,qDAAqD;IACrD,IAAIA,QAAQC,MAAM,KAAK,GAAG;QACxB,OAAOF;IACT;IAEA,MAAMG,YAAwD,CAAC;IAE/D,KAAK,MAAMC,OAAOJ,KAAM;QACtB,MAAMK,UAAUC,OAAOC,IAAI,CAACH,KACzBI,MAAM,CAAC,CAACC,IAAMR,QAAQS,QAAQ,CAACD,IAC/BE,GAAG,CAAC,CAACF,IAAML,GAAG,CAACK,EAAE,E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A;gBACF;YACA,KAAK;gBAAuB;oBAC1B,IAAIsC,UAAUC,IAAI,CAACpB,MAAM,EAAE;wBACzBF,SAASI,kCAAkCJ,QAAQqB,UAAUC,IAAI,CAACpB,MAAM;oBAC1E;oBACA;gBACF;YACA,KAAK;gBAAgB;oBACnB,IAAImB,UAAUC,IAAI,CAACvC,OAAO,IAAIsC,UAAUC,IAAI,CAACvC,OAAO,CAACC,MAAM,GAAG,KAAKqC,UAAUC,IAAI,CAACG,IAAI,EAAE;wBACtFzB,SAASH,2BAA2BG,QAAQqB,UAAUC,IAAI,CAACvC,OAAO,EAAEsC,UAAUC,IAAI,CAACG,IAAI;oBACzF;oBACA;gBACF;YACA,KAAK;gBAAe;oBAClBzB,SAASW,0BAA0BX;oBACnC;gBACF;QACF;IACF;IAEA,sCAAsC;IACtCA,SAASA,OAAOP,GAAG,CAAC,CAACP;QACnB,OAAOE,OAAOC,IAAI,CAACH,KAChBwC,IAAI,GACJC,MAAM,CAAC,CAACC,KAA8BC;YACrCD,GAAG,CAACC,IAAI,GAAG3C,GAAG,CAAC2C,IAAI;YACnB,OAAOD;QACT,GAAG,CAAC;IACR;IACA,OAAO5B;AACT;AAEA,OAAO,SAAS8B,iBACdhD,IAAoC,EACpCsC,UAAuB;IAEvB,OAAOxC,QAAQ,IAAMuC,cAAcrC,MAAMsC,aAAa;QAACtC;QAAMsC;KAAW;AAC1E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.52.0-rc.1",
3
+ "version": "0.53.0-beta.0",
4
4
  "description": "Core functionality consumed by both the Perses UI and plugins",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",