@perses-dev/core 0.53.0-beta.1 → 0.53.0-beta.3
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.
- package/dist/cjs/model/base-metadata.js +16 -0
- package/dist/cjs/model/profile-data.js +1 -5
- package/dist/cjs/model/units/bits.js +105 -0
- package/dist/cjs/model/units/date.js +297 -0
- package/dist/cjs/model/units/temperature.js +64 -0
- package/dist/cjs/model/units/throughput.js +22 -1
- package/dist/cjs/model/units/time.js +16 -2
- package/dist/cjs/model/units/units.js +39 -3
- package/dist/model/base-metadata.d.ts +17 -0
- package/dist/model/base-metadata.d.ts.map +1 -0
- package/dist/model/base-metadata.js +15 -0
- package/dist/model/base-metadata.js.map +1 -0
- package/dist/model/log-data.d.ts +2 -9
- package/dist/model/log-data.d.ts.map +1 -1
- package/dist/model/log-data.js.map +1 -1
- package/dist/model/profile-data.d.ts +2 -1
- package/dist/model/profile-data.d.ts.map +1 -1
- package/dist/model/profile-data.js +1 -5
- package/dist/model/profile-data.js.map +1 -1
- package/dist/model/time-series-data.d.ts +3 -9
- package/dist/model/time-series-data.d.ts.map +1 -1
- package/dist/model/time-series-data.js.map +1 -1
- package/dist/model/trace-data.d.ts +5 -2
- package/dist/model/trace-data.d.ts.map +1 -1
- package/dist/model/trace-data.js.map +1 -1
- package/dist/model/units/bits.d.ts +12 -0
- package/dist/model/units/bits.d.ts.map +1 -0
- package/dist/model/units/bits.js +81 -0
- package/dist/model/units/bits.js.map +1 -0
- package/dist/model/units/date.d.ts +28 -0
- package/dist/model/units/date.d.ts.map +1 -0
- package/dist/model/units/date.js +278 -0
- package/dist/model/units/date.js.map +1 -0
- package/dist/model/units/temperature.d.ts +11 -0
- package/dist/model/units/temperature.d.ts.map +1 -0
- package/dist/model/units/temperature.js +45 -0
- package/dist/model/units/temperature.js.map +1 -0
- package/dist/model/units/throughput.d.ts +1 -1
- package/dist/model/units/throughput.d.ts.map +1 -1
- package/dist/model/units/throughput.js +22 -1
- package/dist/model/units/throughput.js.map +1 -1
- package/dist/model/units/time.d.ts +3 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +16 -2
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +1 -1
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +26 -1
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +30 -3
- package/dist/model/units/units.js.map +1 -1
- package/dist/schema/datasource.d.ts +4 -4
- package/dist/schema/metadata.d.ts +2 -2
- package/dist/schema/role.d.ts +4 -4
- package/dist/schema/rolebinding.d.ts +4 -4
- package/dist/schema/secret.d.ts +8 -8
- package/dist/schema/variable.d.ts +8 -8
- package/package.json +1 -1
|
@@ -39,18 +39,27 @@ _export(exports, {
|
|
|
39
39
|
getUnitGroupConfig: function() {
|
|
40
40
|
return getUnitGroupConfig;
|
|
41
41
|
},
|
|
42
|
+
isBitsUnit: function() {
|
|
43
|
+
return isBitsUnit;
|
|
44
|
+
},
|
|
42
45
|
isBytesUnit: function() {
|
|
43
46
|
return isBytesUnit;
|
|
44
47
|
},
|
|
45
48
|
isCurrencyUnit: function() {
|
|
46
49
|
return isCurrencyUnit;
|
|
47
50
|
},
|
|
51
|
+
isDateUnit: function() {
|
|
52
|
+
return isDateUnit;
|
|
53
|
+
},
|
|
48
54
|
isDecimalUnit: function() {
|
|
49
55
|
return isDecimalUnit;
|
|
50
56
|
},
|
|
51
57
|
isPercentUnit: function() {
|
|
52
58
|
return isPercentUnit;
|
|
53
59
|
},
|
|
60
|
+
isTemperatureUnit: function() {
|
|
61
|
+
return isTemperatureUnit;
|
|
62
|
+
},
|
|
54
63
|
isThroughputUnit: function() {
|
|
55
64
|
return isThroughputUnit;
|
|
56
65
|
},
|
|
@@ -65,34 +74,46 @@ _export(exports, {
|
|
|
65
74
|
}
|
|
66
75
|
});
|
|
67
76
|
const _bytes = require("./bytes");
|
|
77
|
+
const _bits = require("./bits");
|
|
68
78
|
const _decimal = require("./decimal");
|
|
69
79
|
const _percent = require("./percent");
|
|
80
|
+
const _temperature = require("./temperature");
|
|
70
81
|
const _time = require("./time");
|
|
71
82
|
const _throughput = require("./throughput");
|
|
72
83
|
const _currency = require("./currency");
|
|
84
|
+
const _date = require("./date");
|
|
73
85
|
const UNIT_GROUP_CONFIG = {
|
|
74
86
|
Time: _time.TIME_GROUP_CONFIG,
|
|
75
87
|
Percent: _percent.PERCENT_GROUP_CONFIG,
|
|
76
88
|
Decimal: _decimal.DECIMAL_GROUP_CONFIG,
|
|
77
89
|
Bytes: _bytes.BYTES_GROUP_CONFIG,
|
|
90
|
+
Bits: _bits.BITS_GROUP_CONFIG,
|
|
78
91
|
Throughput: _throughput.THROUGHPUT_GROUP_CONFIG,
|
|
79
|
-
Currency: _currency.CURRENCY_GROUP_CONFIG
|
|
92
|
+
Currency: _currency.CURRENCY_GROUP_CONFIG,
|
|
93
|
+
Temperature: _temperature.TEMPERATURE_GROUP_CONFIG,
|
|
94
|
+
Date: _date.DATE_GROUP_CONFIG
|
|
80
95
|
};
|
|
81
96
|
const UNIT_CONFIG = {
|
|
82
97
|
..._time.TIME_UNIT_CONFIG,
|
|
83
98
|
..._percent.PERCENT_UNIT_CONFIG,
|
|
84
99
|
..._decimal.DECIMAL_UNIT_CONFIG,
|
|
85
100
|
..._bytes.BYTES_UNIT_CONFIG,
|
|
101
|
+
..._bits.BITS_UNIT_CONFIG,
|
|
86
102
|
..._throughput.THROUGHPUT_UNIT_CONFIG,
|
|
87
|
-
..._currency.CURRENCY_UNIT_CONFIG
|
|
103
|
+
..._currency.CURRENCY_UNIT_CONFIG,
|
|
104
|
+
..._temperature.TEMPERATURE_UNIT_CONFIG,
|
|
105
|
+
..._date.DATE_UNIT_CONFIG
|
|
88
106
|
};
|
|
89
107
|
function formatValue(value, formatOptions) {
|
|
90
|
-
if (formatOptions
|
|
108
|
+
if (!formatOptions) {
|
|
91
109
|
return value.toString();
|
|
92
110
|
}
|
|
93
111
|
if (isBytesUnit(formatOptions)) {
|
|
94
112
|
return (0, _bytes.formatBytes)(value, formatOptions);
|
|
95
113
|
}
|
|
114
|
+
if (isBitsUnit(formatOptions)) {
|
|
115
|
+
return (0, _bits.formatBits)(value, formatOptions);
|
|
116
|
+
}
|
|
96
117
|
if (isDecimalUnit(formatOptions)) {
|
|
97
118
|
return (0, _decimal.formatDecimal)(value, formatOptions);
|
|
98
119
|
}
|
|
@@ -108,6 +129,12 @@ function formatValue(value, formatOptions) {
|
|
|
108
129
|
if (isCurrencyUnit(formatOptions)) {
|
|
109
130
|
return (0, _currency.formatCurrency)(value, formatOptions);
|
|
110
131
|
}
|
|
132
|
+
if (isDateUnit(formatOptions)) {
|
|
133
|
+
return (0, _date.formatDate)(value, formatOptions);
|
|
134
|
+
}
|
|
135
|
+
if (isTemperatureUnit(formatOptions)) {
|
|
136
|
+
return (0, _temperature.formatTemperature)(value, formatOptions);
|
|
137
|
+
}
|
|
111
138
|
const exhaustive = formatOptions;
|
|
112
139
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
113
140
|
}
|
|
@@ -134,6 +161,9 @@ function isDecimalUnit(formatOptions) {
|
|
|
134
161
|
function isBytesUnit(formatOptions) {
|
|
135
162
|
return getUnitGroup(formatOptions) === 'Bytes';
|
|
136
163
|
}
|
|
164
|
+
function isBitsUnit(formatOptions) {
|
|
165
|
+
return getUnitGroup(formatOptions) === 'Bits';
|
|
166
|
+
}
|
|
137
167
|
function isUnitWithDecimalPlaces(formatOptions) {
|
|
138
168
|
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
139
169
|
return !!groupConfig.decimalPlaces;
|
|
@@ -148,3 +178,9 @@ function isThroughputUnit(formatOptions) {
|
|
|
148
178
|
function isCurrencyUnit(formatOptions) {
|
|
149
179
|
return getUnitGroup(formatOptions) === 'Currency';
|
|
150
180
|
}
|
|
181
|
+
function isDateUnit(formatOptions) {
|
|
182
|
+
return getUnitGroup(formatOptions) === 'Date';
|
|
183
|
+
}
|
|
184
|
+
function isTemperatureUnit(formatOptions) {
|
|
185
|
+
return getUnitGroup(formatOptions) === 'Temperature';
|
|
186
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Notice } from './notice';
|
|
2
|
+
export interface BaseMetadata {
|
|
3
|
+
/**
|
|
4
|
+
* A list of notices to display in the panel.
|
|
5
|
+
* These notices are passed down to the panel header
|
|
6
|
+
* and can be used to inform the user about important
|
|
7
|
+
* states, warnings, or messages related to the panel’s data or configuration.
|
|
8
|
+
*/
|
|
9
|
+
notices?: Notice[];
|
|
10
|
+
/**
|
|
11
|
+
* The raw query that is executed to generate this data.
|
|
12
|
+
* Useful when needing to inspect the query that was executed
|
|
13
|
+
* after variables and other context modifications have been applied.
|
|
14
|
+
*/
|
|
15
|
+
executedQueryString?: string;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=base-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-metadata.d.ts","sourceRoot":"","sources":["../../src/model/base-metadata.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAEnB;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=base-metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/base-metadata.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 { Notice } from './notice';\n\nexport interface BaseMetadata {\n /**\n * A list of notices to display in the panel.\n * These notices are passed down to the panel header\n * and can be used to inform the user about important\n * states, warnings, or messages related to the panel’s data or configuration.\n */\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"],"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;AAIjC,WAeC"}
|
package/dist/model/log-data.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseMetadata } from './base-metadata';
|
|
2
2
|
import { AbsoluteTimeRange } from './time';
|
|
3
3
|
import { Labels } from './time-series-queries';
|
|
4
4
|
export interface LogEntry {
|
|
@@ -14,14 +14,7 @@ export interface LogData {
|
|
|
14
14
|
hasMore?: boolean;
|
|
15
15
|
direction?: 'forward' | 'backward';
|
|
16
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;
|
|
17
|
+
export interface LogMetadata extends BaseMetadata {
|
|
25
18
|
/**
|
|
26
19
|
* Statistics about the log query execution
|
|
27
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"log-data.d.ts","sourceRoot":"","sources":["../../src/model/log-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"log-data.d.ts","sourceRoot":"","sources":["../../src/model/log-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,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,WAAY,SAAQ,YAAY;IAC/C;;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 +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 {
|
|
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 { BaseMetadata } from './base-metadata';\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 extends BaseMetadata {\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;AA4BjC,WAoBC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseMetadata } from './base-metadata';
|
|
1
2
|
/**
|
|
2
3
|
* A stackTrace
|
|
3
4
|
* It corresponds to a function called during a program execution.
|
|
@@ -40,7 +41,7 @@ export interface ProfileData {
|
|
|
40
41
|
maxSelf?: number;
|
|
41
42
|
metadata?: ProfileMetaData;
|
|
42
43
|
}
|
|
43
|
-
export interface ProfileMetaData {
|
|
44
|
+
export interface ProfileMetaData extends BaseMetadata {
|
|
44
45
|
spyName: string;
|
|
45
46
|
sampleRate: number;
|
|
46
47
|
units: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile-data.d.ts","sourceRoot":"","sources":["../../src/model/profile-data.ts"],"names":[],"mappings":"AAaA;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"profile-data.d.ts","sourceRoot":"","sources":["../../src/model/profile-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,OAAO;IACtB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC5B;AAED,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
|
-
|
|
14
|
-
* A stackTrace
|
|
15
|
-
* It corresponds to a function called during a program execution.
|
|
16
|
-
* Children of a function are functions called by the parent function during its execution.
|
|
17
|
-
*/ export { };
|
|
13
|
+
export { };
|
|
18
14
|
|
|
19
15
|
//# sourceMappingURL=profile-data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/profile-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\n/**\n * A stackTrace\n * It corresponds to a function called during a program execution.\n * Children of a function are functions called by the parent function during its execution.\n */\nexport interface StackTrace {\n id: number; // index of function's name in names array\n name: string; // function's name\n level: number; // level of the function in the flame graph\n start: number; // time at which the function starts\n end: number; // time at which the function ends\n total: number; // total samples (including the samples in its children nodes)\n self: number; // self samples (excluding the samples in its children nodes)\n children: StackTrace[];\n}\n\n/**\n * Timeline attribute contains data to draw the chart showing the evolution of the profiled resource over time (CPU, memory, etc.).\n * It is like a metric and it helps to identify bottlenecks.\n */\nexport interface Timeline {\n startTime: number; // Time at which the timeline starts, as a Unix timestamp\n samples: number[]; // A sequence of samples starting at startTime, spaced by durationDelta seconds\n durationDelta: number; // Time delta between samples, in seconds\n}\n\n/**\n * An entire profile\n * It is the stacktrace of the root function.\n */\nexport interface Profile {\n stackTrace: StackTrace;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display profiles.\n */\nexport interface ProfileData {\n profile: Profile;\n timeline?: Timeline;\n\n numTicks?: number; // Total number of samples\n maxSelf?: number; // Maximum self value in any node\n\n metadata?: ProfileMetaData;\n}\n\nexport interface ProfileMetaData {\n spyName: string; // Name of the spy / profiler used to generate the profile, if any\n sampleRate: number; // Sample rate at which the profiler was operating\n units: string; // The unit of measurement for the profiled data\n name: string; // A name that identifies the profile. [Is this really necessary?]\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;
|
|
1
|
+
{"version":3,"sources":["../../src/model/profile-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 { BaseMetadata } from './base-metadata';\n\n/**\n * A stackTrace\n * It corresponds to a function called during a program execution.\n * Children of a function are functions called by the parent function during its execution.\n */\nexport interface StackTrace {\n id: number; // index of function's name in names array\n name: string; // function's name\n level: number; // level of the function in the flame graph\n start: number; // time at which the function starts\n end: number; // time at which the function ends\n total: number; // total samples (including the samples in its children nodes)\n self: number; // self samples (excluding the samples in its children nodes)\n children: StackTrace[];\n}\n\n/**\n * Timeline attribute contains data to draw the chart showing the evolution of the profiled resource over time (CPU, memory, etc.).\n * It is like a metric and it helps to identify bottlenecks.\n */\nexport interface Timeline {\n startTime: number; // Time at which the timeline starts, as a Unix timestamp\n samples: number[]; // A sequence of samples starting at startTime, spaced by durationDelta seconds\n durationDelta: number; // Time delta between samples, in seconds\n}\n\n/**\n * An entire profile\n * It is the stacktrace of the root function.\n */\nexport interface Profile {\n stackTrace: StackTrace;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display profiles.\n */\nexport interface ProfileData {\n profile: Profile;\n timeline?: Timeline;\n\n numTicks?: number; // Total number of samples\n maxSelf?: number; // Maximum self value in any node\n\n metadata?: ProfileMetaData;\n}\n\nexport interface ProfileMetaData extends BaseMetadata {\n spyName: string; // Name of the spy / profiler used to generate the profile, if any\n sampleRate: number; // Sample rate at which the profiler was operating\n units: string; // The unit of measurement for the profiled data\n name: string; // A name that identifies the profile. [Is this really necessary?]\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;AAoDjC,WAKC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseMetadata } from './base-metadata';
|
|
2
2
|
import { AbsoluteTimeRange } from './time';
|
|
3
3
|
import { Labels, TimeSeriesValueTuple, TimeSeriesHistogramTuple } from './time-series-queries';
|
|
4
4
|
export interface TimeScale {
|
|
@@ -20,13 +20,7 @@ export interface TimeSeries {
|
|
|
20
20
|
formattedName?: string;
|
|
21
21
|
labels?: Labels;
|
|
22
22
|
}
|
|
23
|
-
export interface TimeSeriesMetadata {
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* The raw query that is executed to generate this data.
|
|
27
|
-
* Useful when needing to inspect the query that was executed
|
|
28
|
-
* after variables and other context modifications have been applied.
|
|
29
|
-
*/
|
|
30
|
-
executedQueryString?: string;
|
|
23
|
+
export interface TimeSeriesMetadata extends BaseMetadata {
|
|
24
|
+
[key: string]: unknown;
|
|
31
25
|
}
|
|
32
26
|
//# sourceMappingURL=time-series-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/model/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/model/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAE/F,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,oBAAoB,EAAE,CAAC;IAC/B,UAAU,CAAC,EAAE,wBAAwB,EAAE,CAAC;IACxC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/time-series-data.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 {
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-data.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 { BaseMetadata } from './base-metadata';\nimport { AbsoluteTimeRange } from './time';\nimport { Labels, TimeSeriesValueTuple, TimeSeriesHistogramTuple } from './time-series-queries';\n\nexport interface TimeScale {\n startMs: number;\n endMs: number;\n stepMs: number;\n rangeMs: number;\n}\n\nexport interface TimeSeriesData {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n metadata?: TimeSeriesMetadata;\n}\n\nexport interface TimeSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n histograms?: TimeSeriesHistogramTuple[];\n formattedName?: string;\n labels?: Labels;\n}\n\nexport interface TimeSeriesMetadata extends BaseMetadata {\n [key: string]: unknown;\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;AA4BjC,WAEC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseMetadata } from './base-metadata';
|
|
1
2
|
import { TracesData } from './otlp/trace/v1/trace';
|
|
2
3
|
/**
|
|
3
4
|
* Partial trace information returned by search endpoint
|
|
@@ -27,8 +28,10 @@ export interface TraceData {
|
|
|
27
28
|
searchResult?: TraceSearchResult[];
|
|
28
29
|
metadata?: TraceMetaData;
|
|
29
30
|
}
|
|
30
|
-
export interface TraceMetaData {
|
|
31
|
-
|
|
31
|
+
export interface TraceMetaData extends BaseMetadata {
|
|
32
|
+
/** this field indicates if there are more traces matching the search query, however not all traces were returned */
|
|
33
|
+
hasMoreResults?: boolean;
|
|
34
|
+
[key: string]: unknown;
|
|
32
35
|
}
|
|
33
36
|
export declare function isValidTraceId(traceId: string): boolean;
|
|
34
37
|
//# sourceMappingURL=trace-data.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace-data.d.ts","sourceRoot":"","sources":["../../src/model/trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEnC,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"trace-data.d.ts","sourceRoot":"","sources":["../../src/model/trace-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,SAAS;IACxB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEnC,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,aAAc,SAAQ,YAAY;IACjD,oHAAoH;IACpH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/trace-data.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 { TracesData } from './otlp/trace/v1/trace';\n\n/**\n * Partial trace information returned by search endpoint\n */\nexport interface TraceSearchResult {\n traceId: string;\n rootServiceName: string;\n rootTraceName: string;\n startTimeUnixMs: number;\n durationMs: number;\n serviceStats: Record<string, ServiceStats>;\n}\n\nexport interface ServiceStats {\n spanCount: number;\n /** number of spans with errors, unset if zero */\n errorCount?: number;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display traces.\n *\n * If the query contains a valid trace ID, the 'trace' attribute will contain the entire trace.\n * If the query contains a TraceQL query, the 'searchResult' attribute will contain the search results.\n */\nexport interface TraceData {\n trace?: TracesData;\n searchResult?: TraceSearchResult[];\n\n metadata?: TraceMetaData;\n}\n\nexport interface TraceMetaData {\n
|
|
1
|
+
{"version":3,"sources":["../../src/model/trace-data.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 { BaseMetadata } from './base-metadata';\nimport { TracesData } from './otlp/trace/v1/trace';\n\n/**\n * Partial trace information returned by search endpoint\n */\nexport interface TraceSearchResult {\n traceId: string;\n rootServiceName: string;\n rootTraceName: string;\n startTimeUnixMs: number;\n durationMs: number;\n serviceStats: Record<string, ServiceStats>;\n}\n\nexport interface ServiceStats {\n spanCount: number;\n /** number of spans with errors, unset if zero */\n errorCount?: number;\n}\n\n/**\n * A generalized data-model that will be used by Panel components\n * to display traces.\n *\n * If the query contains a valid trace ID, the 'trace' attribute will contain the entire trace.\n * If the query contains a TraceQL query, the 'searchResult' attribute will contain the search results.\n */\nexport interface TraceData {\n trace?: TracesData;\n searchResult?: TraceSearchResult[];\n\n metadata?: TraceMetaData;\n}\n\nexport interface TraceMetaData extends BaseMetadata {\n /** this field indicates if there are more traces matching the search query, however not all traces were returned */\n hasMoreResults?: boolean;\n [key: string]: unknown;\n}\n\nexport function isValidTraceId(traceId: string): boolean {\n return /^[0-9a-fA-F]+$/.test(traceId);\n}\n"],"names":["isValidTraceId","traceId","test"],"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;AA2CjC,OAAO,SAASA,eAAeC,OAAe;IAC5C,OAAO,iBAAiBC,IAAI,CAACD;AAC/B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UnitGroupConfig, UnitConfig } from './types';
|
|
2
|
+
type BitsUnit = 'bits' | 'decbits';
|
|
3
|
+
export type BitsFormatOptions = {
|
|
4
|
+
unit?: BitsUnit;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
shortValues?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const BITS_GROUP_CONFIG: UnitGroupConfig;
|
|
9
|
+
export declare const BITS_UNIT_CONFIG: Readonly<Record<BitsUnit, UnitConfig>>;
|
|
10
|
+
export declare function formatBits(bits: number, { unit, shortValues, decimalPlaces }: BitsFormatOptions): string;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=bits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bits.d.ts","sourceRoot":"","sources":["../../../src/model/units/bits.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAmBtD,KAAK,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,eAI/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,CASnE,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,IAAa,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE,iBAAiB,GAAG,MAAM,CAmDjH"}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
import numbro from 'numbro';
|
|
14
|
+
import { MAX_SIGNIFICANT_DIGITS } from './constants';
|
|
15
|
+
import { hasDecimalPlaces, limitDecimalPlaces, shouldShortenValues } from './utils';
|
|
16
|
+
/**
|
|
17
|
+
* We support both SI (decimal) and IEC (binary) units for bits:
|
|
18
|
+
*
|
|
19
|
+
* SI/decimal (unit: 'decbits'):
|
|
20
|
+
* 1 Kb = 1000 bits (1000^1 bits)
|
|
21
|
+
* 1 Mb = 1,000,000 bits (1000^2 bits)
|
|
22
|
+
* etc.
|
|
23
|
+
*
|
|
24
|
+
* IEC/binary (unit: 'bits'):
|
|
25
|
+
* 1 Kib = 1024 bits (1024^1 bits)
|
|
26
|
+
* 1 Mib = 1,048,576 bits (1024^2 bits)
|
|
27
|
+
* etc.
|
|
28
|
+
*/ const DEFAULT_NUMBRO_MANTISSA = 2;
|
|
29
|
+
export const BITS_GROUP_CONFIG = {
|
|
30
|
+
label: 'Bits',
|
|
31
|
+
decimalPlaces: true,
|
|
32
|
+
shortValues: true
|
|
33
|
+
};
|
|
34
|
+
export const BITS_UNIT_CONFIG = {
|
|
35
|
+
bits: {
|
|
36
|
+
group: 'Bits',
|
|
37
|
+
label: 'Bits (IEC)'
|
|
38
|
+
},
|
|
39
|
+
decbits: {
|
|
40
|
+
group: 'Bits',
|
|
41
|
+
label: 'Bits (SI)'
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
export function formatBits(bits, { unit = 'bits', shortValues, decimalPlaces }) {
|
|
45
|
+
const isDecimal = unit === 'decbits';
|
|
46
|
+
const threshold = isDecimal ? 1000 : 1024;
|
|
47
|
+
// If we're showing the entire value, we can use Intl.NumberFormat.
|
|
48
|
+
if (!shouldShortenValues(shortValues) || Math.abs(bits) < threshold) {
|
|
49
|
+
const formatterOptions = {
|
|
50
|
+
style: 'decimal',
|
|
51
|
+
useGrouping: true
|
|
52
|
+
};
|
|
53
|
+
if (hasDecimalPlaces(decimalPlaces)) {
|
|
54
|
+
formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
55
|
+
formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
56
|
+
} else {
|
|
57
|
+
// This can happen if bits is between -threshold and threshold (1000 for SI, 1024 for IEC)
|
|
58
|
+
if (shouldShortenValues(shortValues)) {
|
|
59
|
+
formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const formatter = Intl.NumberFormat('en-US', formatterOptions);
|
|
63
|
+
return formatter.format(bits) + ' bits';
|
|
64
|
+
}
|
|
65
|
+
// If we're showing the shorten value, we use numbro.
|
|
66
|
+
// numbro is able to add units like Kb, Mb, Gb, etc. correctly.
|
|
67
|
+
const formatted = numbro(bits).format({
|
|
68
|
+
output: 'byte',
|
|
69
|
+
base: isDecimal ? 'decimal' : 'binary',
|
|
70
|
+
spaceSeparated: true,
|
|
71
|
+
mantissa: hasDecimalPlaces(decimalPlaces) ? decimalPlaces : DEFAULT_NUMBRO_MANTISSA,
|
|
72
|
+
// trimMantissa trims trailing 0s
|
|
73
|
+
trimMantissa: !hasDecimalPlaces(decimalPlaces),
|
|
74
|
+
// optionalMantissa excludes all the decimal places if they're all zeros
|
|
75
|
+
optionalMantissa: !hasDecimalPlaces(decimalPlaces)
|
|
76
|
+
});
|
|
77
|
+
// Replace byte units with bit units
|
|
78
|
+
return formatted.replace(/KB/g, 'Kb').replace(/MB/g, 'Mb').replace(/GB/g, 'Gb').replace(/TB/g, 'Tb').replace(/PB/g, 'Pb').replace(/EB/g, 'Eb').replace(/KiB/g, 'Kib').replace(/MiB/g, 'Mib').replace(/GiB/g, 'Gib').replace(/TiB/g, 'Tib').replace(/PiB/g, 'Pib').replace(/EiB/g, 'Eib');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
//# sourceMappingURL=bits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/model/units/bits.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 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 bits:\n *\n * SI/decimal (unit: 'decbits'):\n * 1 Kb = 1000 bits (1000^1 bits)\n * 1 Mb = 1,000,000 bits (1000^2 bits)\n * etc.\n *\n * IEC/binary (unit: 'bits'):\n * 1 Kib = 1024 bits (1024^1 bits)\n * 1 Mib = 1,048,576 bits (1024^2 bits)\n * etc.\n */\n\nconst DEFAULT_NUMBRO_MANTISSA = 2;\n\ntype BitsUnit = 'bits' | 'decbits';\n\nexport type BitsFormatOptions = {\n unit?: BitsUnit;\n decimalPlaces?: number;\n shortValues?: boolean;\n};\n\nexport const BITS_GROUP_CONFIG: UnitGroupConfig = {\n label: 'Bits',\n decimalPlaces: true,\n shortValues: true,\n};\n\nexport const BITS_UNIT_CONFIG: Readonly<Record<BitsUnit, UnitConfig>> = {\n bits: {\n group: 'Bits',\n label: 'Bits (IEC)',\n },\n decbits: {\n group: 'Bits',\n label: 'Bits (SI)',\n },\n};\n\nexport function formatBits(bits: number, { unit = 'bits', shortValues, decimalPlaces }: BitsFormatOptions): string {\n const isDecimal = unit === 'decbits';\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(bits) < threshold) {\n const formatterOptions: Intl.NumberFormatOptions = {\n style: 'decimal',\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 bits 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(bits) + ' bits';\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 const formatted = numbro(bits).format({\n output: 'byte', // numbro uses 'byte' output for bit formatting\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 // Replace byte units with bit units\n return formatted\n .replace(/KB/g, 'Kb')\n .replace(/MB/g, 'Mb')\n .replace(/GB/g, 'Gb')\n .replace(/TB/g, 'Tb')\n .replace(/PB/g, 'Pb')\n .replace(/EB/g, 'Eb')\n .replace(/KiB/g, 'Kib')\n .replace(/MiB/g, 'Mib')\n .replace(/GiB/g, 'Gib')\n .replace(/TiB/g, 'Tib')\n .replace(/PiB/g, 'Pib')\n .replace(/EiB/g, 'Eib');\n}\n"],"names":["numbro","MAX_SIGNIFICANT_DIGITS","hasDecimalPlaces","limitDecimalPlaces","shouldShortenValues","DEFAULT_NUMBRO_MANTISSA","BITS_GROUP_CONFIG","label","decimalPlaces","shortValues","BITS_UNIT_CONFIG","bits","group","decbits","formatBits","unit","isDecimal","threshold","Math","abs","formatterOptions","style","useGrouping","minimumFractionDigits","maximumFractionDigits","maximumSignificantDigits","formatter","Intl","NumberFormat","format","formatted","output","base","spaceSeparated","mantissa","trimMantissa","optionalMantissa","replace"],"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;;;;;;;;;;;;CAYC,GAED,MAAMC,0BAA0B;AAUhC,OAAO,MAAMC,oBAAqC;IAChDC,OAAO;IACPC,eAAe;IACfC,aAAa;AACf,EAAE;AAEF,OAAO,MAAMC,mBAA2D;IACtEC,MAAM;QACJC,OAAO;QACPL,OAAO;IACT;IACAM,SAAS;QACPD,OAAO;QACPL,OAAO;IACT;AACF,EAAE;AAEF,OAAO,SAASO,WAAWH,IAAY,EAAE,EAAEI,OAAO,MAAM,EAAEN,WAAW,EAAED,aAAa,EAAqB;IACvG,MAAMQ,YAAYD,SAAS;IAC3B,MAAME,YAAYD,YAAY,OAAO;IAErC,mEAAmE;IACnE,IAAI,CAACZ,oBAAoBK,gBAAgBS,KAAKC,GAAG,CAACR,QAAQM,WAAW;QACnE,MAAMG,mBAA6C;YACjDC,OAAO;YACPC,aAAa;QACf;QAEA,IAAIpB,iBAAiBM,gBAAgB;YACnCY,iBAAiBG,qBAAqB,GAAGpB,mBAAmBK;YAC5DY,iBAAiBI,qBAAqB,GAAGrB,mBAAmBK;QAC9D,OAAO;YACL,0FAA0F;YAC1F,IAAIJ,oBAAoBK,cAAc;gBACpCW,iBAAiBK,wBAAwB,GAAGxB;YAC9C;QACF;QACA,MAAMyB,YAAYC,KAAKC,YAAY,CAAC,SAASR;QAC7C,OAAOM,UAAUG,MAAM,CAAClB,QAAQ;IAClC;IAEA,qDAAqD;IACrD,+DAA+D;IAC/D,MAAMmB,YAAY9B,OAAOW,MAAMkB,MAAM,CAAC;QACpCE,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;IAEA,oCAAoC;IACpC,OAAOsB,UACJO,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,OAAO,MACfA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ,OAChBA,OAAO,CAAC,QAAQ;AACrB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { UnitGroupConfig, UnitConfig } from './types';
|
|
2
|
+
type DateUnits = 'datetime-iso' | 'datetime-us' | 'datetime-local' | 'date-iso' | 'date-us' | 'date-local' | 'time-local' | 'time-iso' | 'time-us' | 'relative-time' | 'unix-timestamp' | 'unix-timestamp-ms';
|
|
3
|
+
export type DateFormatOptions = {
|
|
4
|
+
unit?: DateUnits;
|
|
5
|
+
/**
|
|
6
|
+
* The locale to use for formatting. Defaults to the system's locale.
|
|
7
|
+
*/
|
|
8
|
+
locale?: string;
|
|
9
|
+
/**
|
|
10
|
+
* The timezone to use for formatting. Defaults to the user's local timezone.
|
|
11
|
+
*/
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
/**
|
|
14
|
+
* For relative time formatting, the reference time to compare against.
|
|
15
|
+
* Defaults to current time.
|
|
16
|
+
*/
|
|
17
|
+
referenceTime?: number;
|
|
18
|
+
/**
|
|
19
|
+
* This property is not used for date formatting, but is included for
|
|
20
|
+
* compatibility with the FormatControls UI component.
|
|
21
|
+
*/
|
|
22
|
+
decimalPlaces?: number;
|
|
23
|
+
};
|
|
24
|
+
export declare const DATE_GROUP_CONFIG: UnitGroupConfig;
|
|
25
|
+
export declare const DATE_UNIT_CONFIG: Readonly<Record<DateUnits, UnitConfig>>;
|
|
26
|
+
export declare function formatDate(value: number, options?: DateFormatOptions): string;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../../src/model/units/date.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,KAAK,SAAS,GACV,cAAc,GACd,aAAa,GACb,gBAAgB,GAChB,UAAU,GACV,SAAS,GACT,YAAY,GACZ,YAAY,GACZ,UAAU,GACV,SAAS,GACT,eAAe,GACf,gBAAgB,GAChB,mBAAmB,CAAC;AAExB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAIF,eAAO,MAAM,iBAAiB,EAAE,eAE/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAiDpE,CAAC;AAqGF,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,MAAM,CAwHjF"}
|