@perses-dev/core 0.51.1 → 0.52.0-beta.1
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/index.js +1 -0
- package/dist/cjs/model/profile-data.js +20 -0
- package/dist/cjs/model/query.js +2 -1
- package/dist/cjs/model/units/currency.js +118 -0
- package/dist/cjs/model/units/time.js +1 -1
- package/dist/cjs/model/units/units.js +18 -5
- package/dist/cjs/schema/secret.js +1 -1
- package/dist/model/index.d.ts +1 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +1 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/otlp/trace/v1/trace.d.ts +6 -0
- package/dist/model/otlp/trace/v1/trace.d.ts.map +1 -1
- package/dist/model/otlp/trace/v1/trace.js.map +1 -1
- package/dist/model/profile-data.d.ts +49 -0
- package/dist/model/profile-data.d.ts.map +1 -0
- package/dist/model/profile-data.js +19 -0
- package/dist/model/profile-data.js.map +1 -0
- package/dist/model/query.d.ts +2 -0
- package/dist/model/query.d.ts.map +1 -1
- package/dist/model/query.js +2 -1
- package/dist/model/query.js.map +1 -1
- package/dist/model/units/bytes.d.ts +1 -1
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/currency.d.ts +11 -0
- package/dist/model/units/currency.d.ts.map +1 -0
- package/dist/model/units/currency.js +99 -0
- package/dist/model/units/currency.js.map +1 -0
- package/dist/model/units/decimal.d.ts +1 -1
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/percent.d.ts +1 -1
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js.map +1 -1
- 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.map +1 -1
- package/dist/model/units/time.d.ts +1 -1
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +1 -1
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +2 -2
- 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 +18 -1
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +15 -5
- package/dist/model/units/units.js.map +1 -1
- package/dist/schema/secret.d.ts +53 -53
- package/dist/schema/secret.js +1 -1
- package/dist/schema/secret.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/model/index.js
CHANGED
|
@@ -39,6 +39,7 @@ _export_star(require("./time"), exports);
|
|
|
39
39
|
_export_star(require("./time-series-data"), exports);
|
|
40
40
|
_export_star(require("./time-series-queries"), exports);
|
|
41
41
|
_export_star(require("./trace-data"), exports);
|
|
42
|
+
_export_star(require("./profile-data"), exports);
|
|
42
43
|
_export_star(require("./transforms"), exports);
|
|
43
44
|
_export_star(require("./units"), exports);
|
|
44
45
|
_export_star(require("./user"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
/**
|
|
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
|
+
*/ "use strict";
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: true
|
|
20
|
+
});
|
package/dist/cjs/model/query.js
CHANGED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Copyright 2025 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
CURRENCY_GROUP_CONFIG: function() {
|
|
25
|
+
return CURRENCY_GROUP_CONFIG;
|
|
26
|
+
},
|
|
27
|
+
CURRENCY_UNIT_CONFIG: function() {
|
|
28
|
+
return CURRENCY_UNIT_CONFIG;
|
|
29
|
+
},
|
|
30
|
+
formatCurrency: function() {
|
|
31
|
+
return formatCurrency;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _lodash = require("lodash");
|
|
35
|
+
const _constants = require("./constants");
|
|
36
|
+
const _utils = require("./utils");
|
|
37
|
+
const CURRENCY_GROUP = 'Currency';
|
|
38
|
+
const CURRENCY_GROUP_CONFIG = {
|
|
39
|
+
label: 'Currency',
|
|
40
|
+
decimalPlaces: true
|
|
41
|
+
};
|
|
42
|
+
const CURRENCY_UNIT_CONFIG = {
|
|
43
|
+
aud: {
|
|
44
|
+
group: CURRENCY_GROUP,
|
|
45
|
+
label: 'Australian Dollar (A$)'
|
|
46
|
+
},
|
|
47
|
+
cad: {
|
|
48
|
+
group: CURRENCY_GROUP,
|
|
49
|
+
label: 'Canadian Dollar (CA$)'
|
|
50
|
+
},
|
|
51
|
+
chf: {
|
|
52
|
+
group: CURRENCY_GROUP,
|
|
53
|
+
label: 'Swiss Franc (CHF)'
|
|
54
|
+
},
|
|
55
|
+
cny: {
|
|
56
|
+
group: CURRENCY_GROUP,
|
|
57
|
+
label: 'Renminbi (CN¥)'
|
|
58
|
+
},
|
|
59
|
+
eur: {
|
|
60
|
+
group: CURRENCY_GROUP,
|
|
61
|
+
label: 'Euro (€)'
|
|
62
|
+
},
|
|
63
|
+
gbp: {
|
|
64
|
+
group: CURRENCY_GROUP,
|
|
65
|
+
label: 'Pound (£)'
|
|
66
|
+
},
|
|
67
|
+
hkd: {
|
|
68
|
+
group: CURRENCY_GROUP,
|
|
69
|
+
label: 'Hong Kong Dollar (HK$)'
|
|
70
|
+
},
|
|
71
|
+
inr: {
|
|
72
|
+
group: CURRENCY_GROUP,
|
|
73
|
+
label: 'Indian Rupee (₹)'
|
|
74
|
+
},
|
|
75
|
+
jpy: {
|
|
76
|
+
group: CURRENCY_GROUP,
|
|
77
|
+
label: 'Yen (¥)'
|
|
78
|
+
},
|
|
79
|
+
krw: {
|
|
80
|
+
group: CURRENCY_GROUP,
|
|
81
|
+
label: 'South Korean Won (₩)'
|
|
82
|
+
},
|
|
83
|
+
nok: {
|
|
84
|
+
group: CURRENCY_GROUP,
|
|
85
|
+
label: 'Norwegian Krone (NOK)'
|
|
86
|
+
},
|
|
87
|
+
nzd: {
|
|
88
|
+
group: CURRENCY_GROUP,
|
|
89
|
+
label: 'New Zealand Dollar (NZ$)'
|
|
90
|
+
},
|
|
91
|
+
sek: {
|
|
92
|
+
group: CURRENCY_GROUP,
|
|
93
|
+
label: 'Swedish Krona (SEK)'
|
|
94
|
+
},
|
|
95
|
+
sgd: {
|
|
96
|
+
group: CURRENCY_GROUP,
|
|
97
|
+
label: 'Singapore Dollar (S$)'
|
|
98
|
+
},
|
|
99
|
+
usd: {
|
|
100
|
+
group: CURRENCY_GROUP,
|
|
101
|
+
label: 'US Dollar ($)'
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
function formatCurrency(value, { unit, decimalPlaces }) {
|
|
105
|
+
const formatterOptions = {
|
|
106
|
+
style: 'currency',
|
|
107
|
+
currency: (0, _lodash.toUpper)(unit),
|
|
108
|
+
currencyDisplay: 'symbol'
|
|
109
|
+
};
|
|
110
|
+
if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
|
|
111
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
112
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
113
|
+
} else {
|
|
114
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
115
|
+
}
|
|
116
|
+
const formatter = Intl.NumberFormat('en-US', formatterOptions);
|
|
117
|
+
return formatter.format(value);
|
|
118
|
+
}
|
|
@@ -139,7 +139,7 @@ function isMonthOrYear(unit) {
|
|
|
139
139
|
}
|
|
140
140
|
function formatTime(value, { unit, decimalPlaces }) {
|
|
141
141
|
if (value === 0) return '0s';
|
|
142
|
-
const results = getValueAndKindForNaturalNumbers(value, unit);
|
|
142
|
+
const results = getValueAndKindForNaturalNumbers(value, unit ?? 'seconds');
|
|
143
143
|
const formatterOptions = {
|
|
144
144
|
style: 'unit',
|
|
145
145
|
unit: PersesTimeToIntlTime[results.unit],
|
|
@@ -42,6 +42,9 @@ _export(exports, {
|
|
|
42
42
|
isBytesUnit: function() {
|
|
43
43
|
return isBytesUnit;
|
|
44
44
|
},
|
|
45
|
+
isCurrencyUnit: function() {
|
|
46
|
+
return isCurrencyUnit;
|
|
47
|
+
},
|
|
45
48
|
isDecimalUnit: function() {
|
|
46
49
|
return isDecimalUnit;
|
|
47
50
|
},
|
|
@@ -66,19 +69,22 @@ const _decimal = require("./decimal");
|
|
|
66
69
|
const _percent = require("./percent");
|
|
67
70
|
const _time = require("./time");
|
|
68
71
|
const _throughput = require("./throughput");
|
|
72
|
+
const _currency = require("./currency");
|
|
69
73
|
const UNIT_GROUP_CONFIG = {
|
|
70
74
|
Time: _time.TIME_GROUP_CONFIG,
|
|
71
75
|
Percent: _percent.PERCENT_GROUP_CONFIG,
|
|
72
76
|
Decimal: _decimal.DECIMAL_GROUP_CONFIG,
|
|
73
77
|
Bytes: _bytes.BYTES_GROUP_CONFIG,
|
|
74
|
-
Throughput: _throughput.THROUGHPUT_GROUP_CONFIG
|
|
78
|
+
Throughput: _throughput.THROUGHPUT_GROUP_CONFIG,
|
|
79
|
+
Currency: _currency.CURRENCY_GROUP_CONFIG
|
|
75
80
|
};
|
|
76
81
|
const UNIT_CONFIG = {
|
|
77
82
|
..._time.TIME_UNIT_CONFIG,
|
|
78
83
|
..._percent.PERCENT_UNIT_CONFIG,
|
|
79
84
|
..._decimal.DECIMAL_UNIT_CONFIG,
|
|
80
85
|
..._bytes.BYTES_UNIT_CONFIG,
|
|
81
|
-
..._throughput.THROUGHPUT_UNIT_CONFIG
|
|
86
|
+
..._throughput.THROUGHPUT_UNIT_CONFIG,
|
|
87
|
+
..._currency.CURRENCY_UNIT_CONFIG
|
|
82
88
|
};
|
|
83
89
|
function formatValue(value, formatOptions) {
|
|
84
90
|
if (formatOptions === undefined) {
|
|
@@ -99,18 +105,22 @@ function formatValue(value, formatOptions) {
|
|
|
99
105
|
if (isThroughputUnit(formatOptions)) {
|
|
100
106
|
return (0, _throughput.formatThroughput)(value, formatOptions);
|
|
101
107
|
}
|
|
108
|
+
if (isCurrencyUnit(formatOptions)) {
|
|
109
|
+
return (0, _currency.formatCurrency)(value, formatOptions);
|
|
110
|
+
}
|
|
102
111
|
const exhaustive = formatOptions;
|
|
103
112
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
104
113
|
}
|
|
105
114
|
function getUnitConfig(formatOptions) {
|
|
106
|
-
|
|
115
|
+
const unit = formatOptions.unit ?? 'decimal';
|
|
116
|
+
return UNIT_CONFIG[unit];
|
|
107
117
|
}
|
|
108
118
|
function getUnitGroup(formatOptions) {
|
|
109
|
-
return getUnitConfig(formatOptions).group;
|
|
119
|
+
return getUnitConfig(formatOptions).group ?? 'Decimal';
|
|
110
120
|
}
|
|
111
121
|
function getUnitGroupConfig(formatOptions) {
|
|
112
122
|
const unitConfig = getUnitConfig(formatOptions);
|
|
113
|
-
return UNIT_GROUP_CONFIG[unitConfig.group];
|
|
123
|
+
return UNIT_GROUP_CONFIG[unitConfig.group ?? 'Decimal'];
|
|
114
124
|
}
|
|
115
125
|
function isTimeUnit(formatOptions) {
|
|
116
126
|
return getUnitGroup(formatOptions) === 'Time';
|
|
@@ -135,3 +145,6 @@ function isUnitWithShortValues(formatOptions) {
|
|
|
135
145
|
function isThroughputUnit(formatOptions) {
|
|
136
146
|
return getUnitGroup(formatOptions) === 'Throughput';
|
|
137
147
|
}
|
|
148
|
+
function isCurrencyUnit(formatOptions) {
|
|
149
|
+
return getUnitGroup(formatOptions) === 'Currency';
|
|
150
|
+
}
|
|
@@ -119,7 +119,7 @@ const secretSpecSchema = _zod.z.object({
|
|
|
119
119
|
certFile: _zod.z.string().optional(),
|
|
120
120
|
keyFile: _zod.z.string().optional(),
|
|
121
121
|
serverName: _zod.z.string().optional(),
|
|
122
|
-
insecureSkipVerify: _zod.z.boolean()
|
|
122
|
+
insecureSkipVerify: _zod.z.boolean().optional()
|
|
123
123
|
}).superRefine((val, ctx)=>{
|
|
124
124
|
if (val.ca && val.ca.length > 0 && val.caFile && val.caFile.length > 0) {
|
|
125
125
|
ctx.addIssue({
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC"}
|
package/dist/model/index.js
CHANGED
package/dist/model/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './calculations';\nexport * from './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './display';\nexport * from './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './otlp';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './roles';\nexport * from './rolebindings';\nexport * from './secrets';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './trace-data';\nexport * from './profile-data';\nexport * from './transforms';\nexport * from './units';\nexport * from './user';\nexport * from './variables';\nexport * from './value-mapping';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,YAAY;AAC1B,cAAc,UAAU;AACxB,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,iBAAiB;AAC/B,cAAc,YAAY;AAC1B,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,wBAAwB;AACtC,cAAc,eAAe;AAC7B,cAAc,iBAAiB;AAC/B,cAAc,eAAe;AAC7B,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,cAAc;AAC5B,cAAc,kBAAkB"}
|
|
@@ -21,6 +21,7 @@ export interface Span {
|
|
|
21
21
|
endTimeUnixNano: string;
|
|
22
22
|
attributes?: KeyValue[];
|
|
23
23
|
events?: Event[];
|
|
24
|
+
links?: Link[];
|
|
24
25
|
status?: Status;
|
|
25
26
|
}
|
|
26
27
|
export interface Event {
|
|
@@ -28,6 +29,11 @@ export interface Event {
|
|
|
28
29
|
name: string;
|
|
29
30
|
attributes?: KeyValue[];
|
|
30
31
|
}
|
|
32
|
+
export interface Link {
|
|
33
|
+
traceId: string;
|
|
34
|
+
spanId: string;
|
|
35
|
+
attributes?: KeyValue[];
|
|
36
|
+
}
|
|
31
37
|
export interface Status {
|
|
32
38
|
code?: typeof StatusCodeUnset | typeof StatusCodeOk | typeof StatusCodeError;
|
|
33
39
|
message?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../../../src/model/otlp/trace/v1/trace.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAKtD,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE,OAAO,eAAe,GAAG,OAAO,YAAY,GAAG,OAAO,eAAe,CAAC;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAC7C,eAAO,MAAM,eAAe,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../../../../../src/model/otlp/trace/v1/trace.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAKtD,MAAM,WAAW,UAAU;IACzB,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,UAAU,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,oBAAoB,CAAC;IAC7B,KAAK,EAAE,IAAI,EAAE,CAAC;CACf;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;IACxB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,KAAK;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,IAAI;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,MAAM;IACrB,IAAI,CAAC,EAAE,OAAO,eAAe,GAAG,OAAO,YAAY,GAAG,OAAO,eAAe,CAAC;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,eAAe,sBAAsB,CAAC;AACnD,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAC7C,eAAO,MAAM,eAAe,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/model/otlp/trace/v1/trace.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 { InstrumentationScope, KeyValue } from '../../common/v1/common';\nimport { Resource } from '../../resource/v1/resource';\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/examples/trace.json\n\nexport interface TracesData {\n resourceSpans: ResourceSpan[];\n}\n\nexport interface ResourceSpan {\n resource?: Resource;\n scopeSpans: ScopeSpans[];\n}\n\nexport interface ScopeSpans {\n scope?: InstrumentationScope;\n spans: Span[];\n}\n\nexport interface Span {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n kind?: string;\n startTimeUnixNano: string;\n endTimeUnixNano: string;\n attributes?: KeyValue[];\n events?: Event[];\n status?: Status;\n}\n\nexport interface Event {\n timeUnixNano: string;\n name: string;\n attributes?: KeyValue[];\n}\n\nexport interface Status {\n code?: typeof StatusCodeUnset | typeof StatusCodeOk | typeof StatusCodeError;\n message?: string;\n}\n\nexport const StatusCodeUnset = 'STATUS_CODE_UNSET';\nexport const StatusCodeOk = 'STATUS_CODE_OK';\nexport const StatusCodeError = 'STATUS_CODE_ERROR';\n"],"names":["StatusCodeUnset","StatusCodeOk","StatusCodeError"],"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/otlp/trace/v1/trace.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 { InstrumentationScope, KeyValue } from '../../common/v1/common';\nimport { Resource } from '../../resource/v1/resource';\n\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/opentelemetry/proto/trace/v1/trace.proto\n// https://github.com/open-telemetry/opentelemetry-proto/blob/v1.5.0/examples/trace.json\n\nexport interface TracesData {\n resourceSpans: ResourceSpan[];\n}\n\nexport interface ResourceSpan {\n resource?: Resource;\n scopeSpans: ScopeSpans[];\n}\n\nexport interface ScopeSpans {\n scope?: InstrumentationScope;\n spans: Span[];\n}\n\nexport interface Span {\n traceId: string;\n spanId: string;\n parentSpanId?: string;\n name: string;\n kind?: string;\n startTimeUnixNano: string;\n endTimeUnixNano: string;\n attributes?: KeyValue[];\n events?: Event[];\n links?: Link[];\n status?: Status;\n}\n\nexport interface Event {\n timeUnixNano: string;\n name: string;\n attributes?: KeyValue[];\n}\n\nexport interface Link {\n traceId: string;\n spanId: string;\n attributes?: KeyValue[];\n}\n\nexport interface Status {\n code?: typeof StatusCodeUnset | typeof StatusCodeOk | typeof StatusCodeError;\n message?: string;\n}\n\nexport const StatusCodeUnset = 'STATUS_CODE_UNSET';\nexport const StatusCodeOk = 'STATUS_CODE_OK';\nexport const StatusCodeError = 'STATUS_CODE_ERROR';\n"],"names":["StatusCodeUnset","StatusCodeOk","StatusCodeError"],"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;AAqDjC,OAAO,MAAMA,kBAAkB,oBAAoB;AACnD,OAAO,MAAMC,eAAe,iBAAiB;AAC7C,OAAO,MAAMC,kBAAkB,oBAAoB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A stackTrace
|
|
3
|
+
* It corresponds to a function called during a program execution.
|
|
4
|
+
* Children of a function are functions called by the parent function during its execution.
|
|
5
|
+
*/
|
|
6
|
+
export interface StackTrace {
|
|
7
|
+
id: number;
|
|
8
|
+
name: string;
|
|
9
|
+
level: number;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
total: number;
|
|
13
|
+
self: number;
|
|
14
|
+
children: StackTrace[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Timeline attribute contains data to draw the chart showing the evolution of the profiled resource over time (CPU, memory, etc.).
|
|
18
|
+
* It is like a metric and it helps to identify bottlenecks.
|
|
19
|
+
*/
|
|
20
|
+
export interface Timeline {
|
|
21
|
+
startTime: number;
|
|
22
|
+
samples: number[];
|
|
23
|
+
durationDelta: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* An entire profile
|
|
27
|
+
* It is the stacktrace of the root function.
|
|
28
|
+
*/
|
|
29
|
+
export interface Profile {
|
|
30
|
+
stackTrace: StackTrace;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A generalized data-model that will be used by Panel components
|
|
34
|
+
* to display profiles.
|
|
35
|
+
*/
|
|
36
|
+
export interface ProfileData {
|
|
37
|
+
profile: Profile;
|
|
38
|
+
timeline?: Timeline;
|
|
39
|
+
numTicks?: number;
|
|
40
|
+
maxSelf?: number;
|
|
41
|
+
metadata?: ProfileMetaData;
|
|
42
|
+
}
|
|
43
|
+
export interface ProfileMetaData {
|
|
44
|
+
spyName: string;
|
|
45
|
+
sampleRate: number;
|
|
46
|
+
units: string;
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=profile-data.d.ts.map
|
|
@@ -0,0 +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,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
/**
|
|
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 { };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=profile-data.js.map
|
|
@@ -0,0 +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;AAEjC;;;;CAIC,GA4CD,WAKC"}
|
package/dist/model/query.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Definition, UnknownSpec } from './definitions';
|
|
2
2
|
import { TimeSeriesData } from './time-series-data';
|
|
3
3
|
import { TraceData } from './trace-data';
|
|
4
|
+
import { ProfileData } from './profile-data';
|
|
4
5
|
interface QuerySpec<PluginSpec> {
|
|
5
6
|
plugin: Definition<PluginSpec>;
|
|
6
7
|
}
|
|
@@ -17,6 +18,7 @@ export interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {
|
|
|
17
18
|
export interface QueryType {
|
|
18
19
|
TimeSeriesQuery: TimeSeriesData;
|
|
19
20
|
TraceQuery: TraceData;
|
|
21
|
+
ProfileQuery: ProfileData;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Check if the given type is a valid {@link QueryPluginType} with compile time safety
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/model/query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/model/query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,UAAU,SAAS,CAAC,UAAU;IAC5B,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AACD;;GAEG;AAGH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,GAAG,EAAE,UAAU,GAAG,WAAW;IACnE,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,SAAS,CAAC,UAAU,CAAC,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,eAAe,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,WAAW,CAAC;CAG3B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,SAAS,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC"}
|
package/dist/model/query.js
CHANGED
package/dist/model/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/query.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { TimeSeriesData } from './time-series-data';\nimport { TraceData } from './trace-data';\n\ninterface QuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n/**\n * A generic query definition interface that can be extended to support more than just TimeSeriesQuery\n */\n// Kind needs to be `any` because otherwise typescript will complain 'unknown' is not assignable to type '\"TimeSeriesQuery\"' in a few places\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {\n kind: Kind;\n spec: QuerySpec<PluginSpec>;\n}\n\n/**\n * Mapping the query plugin to the data type it returns\n */\nexport interface QueryType {\n TimeSeriesQuery: TimeSeriesData;\n TraceQuery: TraceData;\n // in the future we can add other query plugin and data types\n // for example: we can add something like `LogsQuery: LogsData;`\n}\n\n/**\n * Check if the given type is a valid {@link QueryPluginType} with compile time safety\n * @param type\n */\nexport function isValidQueryPluginType(type: string): type is QueryPluginType {\n return ['TimeSeriesQuery', 'TraceQuery'].includes(type as QueryPluginType);\n}\n\n/**\n * Extract the keys of QueryType\n * ex: 'TimeSeriesQuery'\n */\nexport type QueryPluginType = keyof QueryType;\n\n/**\n * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\n"],"names":["isValidQueryPluginType","type","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;
|
|
1
|
+
{"version":3,"sources":["../../src/model/query.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, UnknownSpec } from './definitions';\nimport { TimeSeriesData } from './time-series-data';\nimport { TraceData } from './trace-data';\nimport { ProfileData } from './profile-data';\n\ninterface QuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n/**\n * A generic query definition interface that can be extended to support more than just TimeSeriesQuery\n */\n// Kind needs to be `any` because otherwise typescript will complain 'unknown' is not assignable to type '\"TimeSeriesQuery\"' in a few places\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface QueryDefinition<Kind = any, PluginSpec = UnknownSpec> {\n kind: Kind;\n spec: QuerySpec<PluginSpec>;\n}\n\n/**\n * Mapping the query plugin to the data type it returns\n */\nexport interface QueryType {\n TimeSeriesQuery: TimeSeriesData;\n TraceQuery: TraceData;\n ProfileQuery: ProfileData;\n // in the future we can add other query plugin and data types\n // for example: we can add something like `LogsQuery: LogsData;`\n}\n\n/**\n * Check if the given type is a valid {@link QueryPluginType} with compile time safety\n * @param type\n */\nexport function isValidQueryPluginType(type: string): type is QueryPluginType {\n return ['TimeSeriesQuery', 'TraceQuery', 'ProfileQuery'].includes(type as QueryPluginType);\n}\n\n/**\n * Extract the keys of QueryType\n * ex: 'TimeSeriesQuery'\n */\nexport type QueryPluginType = keyof QueryType;\n\n/**\n * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\n"],"names":["isValidQueryPluginType","type","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA+BjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;QAAc;KAAe,CAACC,QAAQ,CAACD;AACpE"}
|
|
@@ -1 +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,EAAE,SAAS,CAAC;
|
|
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 +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
|
|
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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { UnitConfig, UnitGroupConfig } from './types';
|
|
2
|
+
type CurrencyUnits = 'aud' | 'cad' | 'chf' | 'cny' | 'eur' | 'gbp' | 'hkd' | 'inr' | 'jpy' | 'krw' | 'nok' | 'nzd' | 'sek' | 'sgd' | 'usd';
|
|
3
|
+
export type CurrencyFormatOptions = {
|
|
4
|
+
unit: CurrencyUnits;
|
|
5
|
+
decimalPlaces?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const CURRENCY_GROUP_CONFIG: UnitGroupConfig;
|
|
8
|
+
export declare const CURRENCY_UNIT_CONFIG: Readonly<Record<CurrencyUnits, UnitConfig>>;
|
|
9
|
+
export declare function formatCurrency(value: number, { unit, decimalPlaces }: CurrencyFormatOptions): string;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=currency.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/model/units/currency.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAKtD,KAAK,aAAa,GACd,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,CAAC;AACV,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAGF,eAAO,MAAM,qBAAqB,EAAE,eAGnC,CAAC;AACF,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,aAAa,EAAE,UAAU,CAAC,CA6D5E,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,qBAAqB,GAAG,MAAM,CAgBpG"}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { toUpper } from 'lodash';
|
|
14
|
+
import { MAX_SIGNIFICANT_DIGITS } from './constants';
|
|
15
|
+
import { hasDecimalPlaces, limitDecimalPlaces } from './utils';
|
|
16
|
+
const CURRENCY_GROUP = 'Currency';
|
|
17
|
+
export const CURRENCY_GROUP_CONFIG = {
|
|
18
|
+
label: 'Currency',
|
|
19
|
+
decimalPlaces: true
|
|
20
|
+
};
|
|
21
|
+
export const CURRENCY_UNIT_CONFIG = {
|
|
22
|
+
aud: {
|
|
23
|
+
group: CURRENCY_GROUP,
|
|
24
|
+
label: 'Australian Dollar (A$)'
|
|
25
|
+
},
|
|
26
|
+
cad: {
|
|
27
|
+
group: CURRENCY_GROUP,
|
|
28
|
+
label: 'Canadian Dollar (CA$)'
|
|
29
|
+
},
|
|
30
|
+
chf: {
|
|
31
|
+
group: CURRENCY_GROUP,
|
|
32
|
+
label: 'Swiss Franc (CHF)'
|
|
33
|
+
},
|
|
34
|
+
cny: {
|
|
35
|
+
group: CURRENCY_GROUP,
|
|
36
|
+
label: 'Renminbi (CN¥)'
|
|
37
|
+
},
|
|
38
|
+
eur: {
|
|
39
|
+
group: CURRENCY_GROUP,
|
|
40
|
+
label: 'Euro (€)'
|
|
41
|
+
},
|
|
42
|
+
gbp: {
|
|
43
|
+
group: CURRENCY_GROUP,
|
|
44
|
+
label: 'Pound (£)'
|
|
45
|
+
},
|
|
46
|
+
hkd: {
|
|
47
|
+
group: CURRENCY_GROUP,
|
|
48
|
+
label: 'Hong Kong Dollar (HK$)'
|
|
49
|
+
},
|
|
50
|
+
inr: {
|
|
51
|
+
group: CURRENCY_GROUP,
|
|
52
|
+
label: 'Indian Rupee (₹)'
|
|
53
|
+
},
|
|
54
|
+
jpy: {
|
|
55
|
+
group: CURRENCY_GROUP,
|
|
56
|
+
label: 'Yen (¥)'
|
|
57
|
+
},
|
|
58
|
+
krw: {
|
|
59
|
+
group: CURRENCY_GROUP,
|
|
60
|
+
label: 'South Korean Won (₩)'
|
|
61
|
+
},
|
|
62
|
+
nok: {
|
|
63
|
+
group: CURRENCY_GROUP,
|
|
64
|
+
label: 'Norwegian Krone (NOK)'
|
|
65
|
+
},
|
|
66
|
+
nzd: {
|
|
67
|
+
group: CURRENCY_GROUP,
|
|
68
|
+
label: 'New Zealand Dollar (NZ$)'
|
|
69
|
+
},
|
|
70
|
+
sek: {
|
|
71
|
+
group: CURRENCY_GROUP,
|
|
72
|
+
label: 'Swedish Krona (SEK)'
|
|
73
|
+
},
|
|
74
|
+
sgd: {
|
|
75
|
+
group: CURRENCY_GROUP,
|
|
76
|
+
label: 'Singapore Dollar (S$)'
|
|
77
|
+
},
|
|
78
|
+
usd: {
|
|
79
|
+
group: CURRENCY_GROUP,
|
|
80
|
+
label: 'US Dollar ($)'
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export function formatCurrency(value, { unit, decimalPlaces }) {
|
|
84
|
+
const formatterOptions = {
|
|
85
|
+
style: 'currency',
|
|
86
|
+
currency: toUpper(unit),
|
|
87
|
+
currencyDisplay: 'symbol'
|
|
88
|
+
};
|
|
89
|
+
if (hasDecimalPlaces(decimalPlaces)) {
|
|
90
|
+
formatterOptions.minimumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
91
|
+
formatterOptions.maximumFractionDigits = limitDecimalPlaces(decimalPlaces);
|
|
92
|
+
} else {
|
|
93
|
+
formatterOptions.maximumSignificantDigits = MAX_SIGNIFICANT_DIGITS;
|
|
94
|
+
}
|
|
95
|
+
const formatter = Intl.NumberFormat('en-US', formatterOptions);
|
|
96
|
+
return formatter.format(value);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=currency.js.map
|