@perses-dev/core 0.37.2 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/index.js +1 -0
- package/dist/cjs/model/project.js +16 -0
- package/dist/cjs/utils/text.js +21 -6
- 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/project.d.ts +6 -0
- package/dist/model/project.d.ts.map +1 -0
- package/dist/model/project.js +15 -0
- package/dist/model/project.js.map +1 -0
- package/dist/model/variables.d.ts +10 -2
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js.map +1 -1
- package/dist/utils/text.d.ts +25 -3
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +33 -4
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time-series-data.d.ts +1 -0
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +1 -0
- package/dist/utils/time-series-data.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/model/index.js
CHANGED
|
@@ -24,6 +24,7 @@ _exportStar(require("./layout"), exports);
|
|
|
24
24
|
_exportStar(require("./legend"), exports);
|
|
25
25
|
_exportStar(require("./notice"), exports);
|
|
26
26
|
_exportStar(require("./panels"), exports);
|
|
27
|
+
_exportStar(require("./project"), exports);
|
|
27
28
|
_exportStar(require("./query"), exports);
|
|
28
29
|
_exportStar(require("./resource"), exports);
|
|
29
30
|
_exportStar(require("./thresholds"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
package/dist/cjs/utils/text.js
CHANGED
|
@@ -21,17 +21,32 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
getDashboardDisplayName: ()=>getDashboardDisplayName,
|
|
25
|
+
getVariableDisplayName: ()=>getVariableDisplayName,
|
|
26
|
+
getDashboardExtendedDisplayName: ()=>getDashboardExtendedDisplayName,
|
|
27
|
+
getVariableExtendedDisplayName: ()=>getVariableExtendedDisplayName
|
|
26
28
|
});
|
|
27
|
-
function
|
|
29
|
+
function getDashboardDisplayName(dashboard) {
|
|
28
30
|
var ref;
|
|
29
|
-
|
|
31
|
+
var ref1;
|
|
32
|
+
return (ref1 = (ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : dashboard.metadata.name;
|
|
30
33
|
}
|
|
31
|
-
function
|
|
34
|
+
function getVariableDisplayName(variable) {
|
|
35
|
+
var ref;
|
|
36
|
+
var ref1;
|
|
37
|
+
return (ref1 = (ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : variable.metadata.name;
|
|
38
|
+
}
|
|
39
|
+
function getDashboardExtendedDisplayName(dashboard) {
|
|
32
40
|
var ref;
|
|
33
41
|
if ((ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
|
|
34
|
-
return `${dashboard.spec.display.name} (
|
|
42
|
+
return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
|
|
35
43
|
}
|
|
36
44
|
return dashboard.metadata.name;
|
|
37
45
|
}
|
|
46
|
+
function getVariableExtendedDisplayName(variable) {
|
|
47
|
+
var ref;
|
|
48
|
+
if ((ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
|
|
49
|
+
return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
|
|
50
|
+
}
|
|
51
|
+
return variable.metadata.name;
|
|
52
|
+
}
|
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,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,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,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,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 './http';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './panels';\nexport * from './query';\nexport * from './resource';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './units';\nexport * from './variables';\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,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
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 './http';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\nexport * from './panels';\nexport * from './project';\nexport * from './query';\nexport * from './resource';\nexport * from './thresholds';\nexport * from './time';\nexport * from './time-series-data';\nexport * from './time-series-queries';\nexport * from './units';\nexport * from './variables';\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,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/model/project.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;CACpB"}
|
|
@@ -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=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/project.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 { Metadata } from './resource';\n\nexport interface ProjectResource {\n kind: 'Project';\n metadata: Metadata;\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,WAKC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Definition, UnknownSpec } from './definitions';
|
|
2
2
|
import { Display } from './display';
|
|
3
|
+
import { ProjectMetadata } from './resource';
|
|
3
4
|
export declare type VariableName = string;
|
|
4
5
|
export declare type VariableValue = string | string[] | null;
|
|
5
|
-
interface VariableSpec {
|
|
6
|
+
export interface VariableSpec {
|
|
6
7
|
name: VariableName;
|
|
7
8
|
display?: Display & {
|
|
8
9
|
hidden?: boolean;
|
|
@@ -26,6 +27,13 @@ export interface ListVariableSpec<PluginSpec> extends VariableSpec {
|
|
|
26
27
|
plugin: Definition<PluginSpec>;
|
|
27
28
|
}
|
|
28
29
|
export declare type VariableDefinition = TextVariableDefinition | ListVariableDefinition;
|
|
30
|
+
/**
|
|
31
|
+
* A variable that belongs to a project.
|
|
32
|
+
*/
|
|
33
|
+
export interface VariableResource {
|
|
34
|
+
kind: 'Variable';
|
|
35
|
+
metadata: ProjectMetadata;
|
|
36
|
+
spec: VariableDefinition;
|
|
37
|
+
}
|
|
29
38
|
export declare const DEFAULT_ALL_VALUE: "$__all";
|
|
30
|
-
export {};
|
|
31
39
|
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,OAAO,EAA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E,UAAU,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED,eAAO,MAAM,iBAAiB,UAAoB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/variables.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 { Display } from './display';\n\nexport type VariableName = string;\n\nexport type VariableValue = string | string[] | null;\n\
|
|
1
|
+
{"version":3,"sources":["../../src/model/variables.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 { Display } from './display';\nimport { ProjectMetadata } from './resource';\n\nexport type VariableName = string;\n\nexport type VariableValue = string | string[] | null;\n\nexport interface VariableSpec {\n name: VariableName;\n display?: Display & {\n hidden?: boolean;\n };\n}\n\nexport interface TextVariableDefinition extends Definition<TextVariableSpec> {\n kind: 'TextVariable';\n}\n\nexport interface TextVariableSpec extends VariableSpec {\n value: string;\n}\n\nexport interface ListVariableDefinition<PluginSpec = UnknownSpec> extends Definition<ListVariableSpec<PluginSpec>> {\n kind: 'ListVariable';\n}\n\nexport interface ListVariableSpec<PluginSpec> extends VariableSpec {\n default_value?: VariableValue;\n allow_multiple?: boolean;\n allow_all_value?: boolean;\n custom_all_value?: string;\n capturing_regexp?: string;\n plugin: Definition<PluginSpec>;\n}\n\nexport type VariableDefinition = TextVariableDefinition | ListVariableDefinition;\n\n/**\n * A variable that belongs to a project.\n */\nexport interface VariableResource {\n kind: 'Variable';\n metadata: ProjectMetadata;\n spec: VariableDefinition;\n}\n\nexport const DEFAULT_ALL_VALUE = '$__all' as const;\n"],"names":["DEFAULT_ALL_VALUE"],"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;AAiDjC,OAAO,MAAMA,iBAAiB,GAAG,QAAQ,AAAS,CAAC"}
|
package/dist/utils/text.d.ts
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
import { DashboardResource } from '../model';
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { DashboardResource, VariableResource } from '../model';
|
|
2
|
+
/**
|
|
3
|
+
* If the dashboard has a display name, return the dashboard display name
|
|
4
|
+
* Else, only return the dashboard name
|
|
5
|
+
* @param dashboard
|
|
6
|
+
*/
|
|
7
|
+
export declare function getDashboardDisplayName(dashboard: DashboardResource): string;
|
|
8
|
+
/**
|
|
9
|
+
* If the variable has a display name, return the variable display name
|
|
10
|
+
* Else, only return the variable name
|
|
11
|
+
* @param variable Project or Global variable
|
|
12
|
+
*/
|
|
13
|
+
export declare function getVariableDisplayName(variable: VariableResource): string;
|
|
14
|
+
/**
|
|
15
|
+
* If the dashboard has a display name, return the dashboard display name and the dashboard name
|
|
16
|
+
* Else, only return the dashboard name
|
|
17
|
+
* @param dashboard
|
|
18
|
+
*/
|
|
19
|
+
export declare function getDashboardExtendedDisplayName(dashboard: DashboardResource): string;
|
|
20
|
+
/**
|
|
21
|
+
* If the variable has a display name, return the variable display name and the variable name
|
|
22
|
+
* Else, only return the variable name
|
|
23
|
+
* @param variable Project or Global variable
|
|
24
|
+
*/
|
|
25
|
+
export declare function getVariableExtendedDisplayName(variable: VariableResource): string;
|
|
4
26
|
//# sourceMappingURL=text.d.ts.map
|
package/dist/utils/text.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,UAEnE;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,gBAAgB,UAEhE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,iBAAiB,UAK3E;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,gBAAgB,UAKxE"}
|
package/dist/utils/text.js
CHANGED
|
@@ -10,16 +10,45 @@
|
|
|
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
|
-
|
|
13
|
+
/**
|
|
14
|
+
* If the dashboard has a display name, return the dashboard display name
|
|
15
|
+
* Else, only return the dashboard name
|
|
16
|
+
* @param dashboard
|
|
17
|
+
*/ export function getDashboardDisplayName(dashboard) {
|
|
14
18
|
var ref;
|
|
15
|
-
|
|
19
|
+
var ref1;
|
|
20
|
+
return (ref1 = (ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : dashboard.metadata.name;
|
|
16
21
|
}
|
|
17
|
-
|
|
22
|
+
/**
|
|
23
|
+
* If the variable has a display name, return the variable display name
|
|
24
|
+
* Else, only return the variable name
|
|
25
|
+
* @param variable Project or Global variable
|
|
26
|
+
*/ export function getVariableDisplayName(variable) {
|
|
27
|
+
var ref;
|
|
28
|
+
var ref1;
|
|
29
|
+
return (ref1 = (ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) !== null && ref1 !== void 0 ? ref1 : variable.metadata.name;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* If the dashboard has a display name, return the dashboard display name and the dashboard name
|
|
33
|
+
* Else, only return the dashboard name
|
|
34
|
+
* @param dashboard
|
|
35
|
+
*/ export function getDashboardExtendedDisplayName(dashboard) {
|
|
18
36
|
var ref;
|
|
19
37
|
if ((ref = dashboard.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
|
|
20
|
-
return `${dashboard.spec.display.name} (
|
|
38
|
+
return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
|
|
21
39
|
}
|
|
22
40
|
return dashboard.metadata.name;
|
|
23
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* If the variable has a display name, return the variable display name and the variable name
|
|
44
|
+
* Else, only return the variable name
|
|
45
|
+
* @param variable Project or Global variable
|
|
46
|
+
*/ export function getVariableExtendedDisplayName(variable) {
|
|
47
|
+
var ref;
|
|
48
|
+
if ((ref = variable.spec.spec.display) === null || ref === void 0 ? void 0 : ref.name) {
|
|
49
|
+
return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
|
|
50
|
+
}
|
|
51
|
+
return variable.metadata.name;
|
|
52
|
+
}
|
|
24
53
|
|
|
25
54
|
//# sourceMappingURL=text.js.map
|
package/dist/utils/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/text.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 { DashboardResource } from '../model';\n\nexport function
|
|
1
|
+
{"version":3,"sources":["../../src/utils/text.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 { DashboardResource, VariableResource } from '../model';\n\n/**\n * If the dashboard has a display name, return the dashboard display name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardDisplayName(dashboard: DashboardResource) {\n return dashboard.spec.display?.name ?? dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableDisplayName(variable: VariableResource) {\n return variable.spec.spec.display?.name ?? variable.metadata.name;\n}\n\n/**\n * If the dashboard has a display name, return the dashboard display name and the dashboard name\n * Else, only return the dashboard name\n * @param dashboard\n */\nexport function getDashboardExtendedDisplayName(dashboard: DashboardResource) {\n if (dashboard.spec.display?.name) {\n return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;\n }\n return dashboard.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the variable display name and the variable name\n * Else, only return the variable name\n * @param variable Project or Global variable\n */\nexport function getVariableExtendedDisplayName(variable: VariableResource) {\n if (variable.spec.spec.display?.name) {\n return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;\n }\n return variable.metadata.name;\n}\n"],"names":["getDashboardDisplayName","dashboard","spec","display","name","metadata","getVariableDisplayName","variable","getDashboardExtendedDisplayName","getVariableExtendedDisplayName"],"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;;;;CAIC,GACD,OAAO,SAASA,uBAAuB,CAACC,SAA4B,EAAE;QAC7DA,GAAsB;QAAtBA,IAA4B;IAAnC,OAAOA,CAAAA,IAA4B,GAA5BA,CAAAA,GAAsB,GAAtBA,SAAS,CAACC,IAAI,CAACC,OAAO,cAAtBF,GAAsB,WAAM,GAA5BA,KAAAA,CAA4B,GAA5BA,GAAsB,CAAEG,IAAI,cAA5BH,IAA4B,cAA5BA,IAA4B,GAAIA,SAAS,CAACI,QAAQ,CAACD,IAAI,CAAC;AACjE,CAAC;AAED;;;;CAIC,GACD,OAAO,SAASE,sBAAsB,CAACC,QAA0B,EAAE;QAC1DA,GAA0B;QAA1BA,IAAgC;IAAvC,OAAOA,CAAAA,IAAgC,GAAhCA,CAAAA,GAA0B,GAA1BA,QAAQ,CAACL,IAAI,CAACA,IAAI,CAACC,OAAO,cAA1BI,GAA0B,WAAM,GAAhCA,KAAAA,CAAgC,GAAhCA,GAA0B,CAAEH,IAAI,cAAhCG,IAAgC,cAAhCA,IAAgC,GAAIA,QAAQ,CAACF,QAAQ,CAACD,IAAI,CAAC;AACpE,CAAC;AAED;;;;CAIC,GACD,OAAO,SAASI,+BAA+B,CAACP,SAA4B,EAAE;QACxEA,GAAsB;IAA1B,IAAIA,CAAAA,GAAsB,GAAtBA,SAAS,CAACC,IAAI,CAACC,OAAO,cAAtBF,GAAsB,WAAM,GAA5BA,KAAAA,CAA4B,GAA5BA,GAAsB,CAAEG,IAAI,EAAE;QAChC,OAAO,CAAC,EAAEH,SAAS,CAACC,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,QAAQ,EAAEH,SAAS,CAACI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC;IAC7E,CAAC;IACD,OAAOH,SAAS,CAACI,QAAQ,CAACD,IAAI,CAAC;AACjC,CAAC;AAED;;;;CAIC,GACD,OAAO,SAASK,8BAA8B,CAACF,QAA0B,EAAE;QACrEA,GAA0B;IAA9B,IAAIA,CAAAA,GAA0B,GAA1BA,QAAQ,CAACL,IAAI,CAACA,IAAI,CAACC,OAAO,cAA1BI,GAA0B,WAAM,GAAhCA,KAAAA,CAAgC,GAAhCA,GAA0B,CAAEH,IAAI,EAAE;QACpC,OAAO,CAAC,EAAEG,QAAQ,CAACL,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,QAAQ,EAAEG,QAAQ,CAACF,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC,CAAC;IAChF,CAAC;IACD,OAAOG,QAAQ,CAACF,QAAQ,CAACD,IAAI,CAAC;AAChC,CAAC"}
|
|
@@ -6,6 +6,7 @@ export declare const MIN_STEP_INTERVAL_MS = 10;
|
|
|
6
6
|
*/
|
|
7
7
|
export declare function getXValues(timeScale: TimeScale): number[];
|
|
8
8
|
/**
|
|
9
|
+
* [DEPRECATED] Used for legacy LineChart 'category' axis approach.
|
|
9
10
|
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
10
11
|
* processes the time series values, filling in any timestamps that are missing
|
|
11
12
|
* from the time series data with `null` values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG1G,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAQzD;AAED
|
|
1
|
+
{"version":3,"file":"time-series-data.d.ts","sourceRoot":"","sources":["../../src/utils/time-series-data.ts"],"names":[],"mappings":"AAaA,OAAO,EAAqB,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAG1G,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,EAAE,CAQzD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,0BAyB3E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBzF;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,GACzE,SAAS,GAAG,SAAS,CAgFvB"}
|
|
@@ -25,6 +25,7 @@ export const MIN_STEP_INTERVAL_MS = 10;
|
|
|
25
25
|
return xValues;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
+
* [DEPRECATED] Used for legacy LineChart 'category' axis approach.
|
|
28
29
|
* Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),
|
|
29
30
|
* processes the time series values, filling in any timestamps that are missing
|
|
30
31
|
* from the time series data with `null` values.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/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 { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a common time scale (see `getCommonTimeScale`), generates an array of\n * timestamp values in ms for the x axis of a graph.\n */\nexport function getXValues(timeScale: TimeScale): number[] {\n const xValues: number[] = [];\n let timestamp = timeScale.startMs;\n while (timestamp <= timeScale.endMs) {\n xValues.push(timestamp);\n timestamp += timeScale.stepMs;\n }\n return xValues;\n}\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * processes the time series values, filling in any timestamps that are missing\n * from the time series data with `null` values.\n */\nexport function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale) {\n let timestamp = timeScale.startMs;\n\n const values = series.values;\n const processedValues: TimeSeriesValueTuple[] = [];\n\n for (const valueTuple of values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n processedValues.push([timestamp, valueTuple[1]]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n return processedValues;\n}\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * gets the values for the y axis of a graph, filling in any timestamps that are\n * missing from the time series data with `null` values.\n */\nexport function getYValues(series: TimeSeries, timeScale: TimeScale): Array<number | null> {\n let timestamp = timeScale.startMs;\n\n const yValues: Array<number | null> = [];\n for (const valueTuple of series.values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n yValues.push(valueTuple[1]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n return yValues;\n}\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScale(\n seriesData: Array<TimeSeriesData | Pick<TimeSeries, 'values'> | undefined>\n): TimeScale | undefined {\n let timeRange: AbsoluteTimeRange | undefined = undefined;\n const steps: number[] = [];\n\n for (const data of seriesData) {\n if (data && 'timeRange' in data) {\n if (data === undefined || data.timeRange === undefined || data.stepMs === undefined) continue;\n\n // Keep track of query steps so we can calculate a common one for the graph\n steps.push(data.stepMs);\n\n // If we don't have an overall time range yet, just start with this one\n if (timeRange === undefined) {\n timeRange = data.timeRange;\n continue;\n }\n\n // Otherwise, see if this query has a start or end outside of the current\n // time range\n if (data.timeRange.start < timeRange.start) {\n timeRange.start = data.timeRange.start;\n }\n if (data.timeRange.end > timeRange.end) {\n timeRange.end = data.timeRange.end;\n }\n } else if (data && 'values' in data) {\n for (let i = 0; i < data.values.length; i++) {\n const values = data.values[i];\n if (values === undefined) {\n continue;\n }\n\n const [timestamp] = values;\n const start = new Date(timestamp);\n const end = new Date(timestamp);\n\n if (timeRange === undefined) {\n timeRange = {\n start,\n end,\n };\n continue;\n }\n\n if (start < timeRange.start) {\n timeRange.start = start;\n }\n\n if (end > timeRange.end) {\n timeRange.end = end;\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, rangeMs, stepMs: MIN_STEP_INTERVAL_MS };\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n // Use the greatest common divisor of all step values as the overall step\n // for the x axis (or if only one query, just use that query's step value)\n let stepMs: number;\n if (steps.length === 1) {\n stepMs = steps[0] as number;\n } else {\n const calculatedStepMs = gcd(...steps);\n stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;\n }\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, stepMs, rangeMs };\n}\n"],"names":["gcd","MIN_STEP_INTERVAL_MS","getXValues","timeScale","xValues","timestamp","startMs","endMs","push","stepMs","getTimeSeriesValues","series","values","processedValues","valueTuple","getYValues","yValues","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,GAAG,QAAQ,UAAU,CAAC;AAE/B,OAAO,MAAMC,oBAAoB,GAAG,EAAE,CAAC;AAEvC;;;CAGC,GACD,OAAO,SAASC,UAAU,CAACC,SAAoB,EAAY;IACzD,MAAMC,OAAO,GAAa,EAAE,AAAC;IAC7B,IAAIC,SAAS,GAAGF,SAAS,CAACG,OAAO,AAAC;IAClC,MAAOD,SAAS,IAAIF,SAAS,CAACI,KAAK,CAAE;QACnCH,OAAO,CAACI,IAAI,CAACH,SAAS,CAAC,CAAC;QACxBA,SAAS,IAAIF,SAAS,CAACM,MAAM,CAAC;IAChC,CAAC;IACD,OAAOL,OAAO,CAAC;AACjB,CAAC;AAED;;;;CAIC,GACD,OAAO,SAASM,mBAAmB,CAACC,MAAkB,EAAER,SAAoB,EAAE;IAC5E,IAAIE,SAAS,GAAGF,SAAS,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;IAC1E,IAAIX,MAAM,AAAQ,AAAC;IACnB,IAAIY,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;QACtBjB,MAAM,GAAGY,KAAK,CAAC,CAAC,CAAC,AAAU,CAAC;IAC9B,OAAO;QACL,MAAMS,gBAAgB,GAAG9B,GAAG,IAAIqB,KAAK,CAAC,AAAC;QACvCZ,MAAM,GAAGqB,gBAAgB,GAAG7B,oBAAoB,GAAGA,oBAAoB,GAAG6B,gBAAgB,CAAC;IAC7F,CAAC;IAED,MAAMxB,QAAO,GAAGa,SAAS,CAACI,KAAK,CAACK,OAAO,EAAE,AAAC;IAC1C,MAAMrB,MAAK,GAAGY,SAAS,CAACK,GAAG,CAACI,OAAO,EAAE,AAAC;IACtC,MAAMC,QAAO,GAAGtB,MAAK,GAAGD,QAAO,AAAC;IAEhC,OAAO;QAAEA,OAAO,EAAPA,QAAO;QAAEC,KAAK,EAALA,MAAK;QAAEE,MAAM;QAAEoB,OAAO,EAAPA,QAAO;KAAE,CAAC;AAC7C,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/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 { AbsoluteTimeRange, TimeScale, TimeSeries, TimeSeriesData, TimeSeriesValueTuple } from '../model';\nimport { gcd } from './mathjs';\n\nexport const MIN_STEP_INTERVAL_MS = 10;\n\n/**\n * Given a common time scale (see `getCommonTimeScale`), generates an array of\n * timestamp values in ms for the x axis of a graph.\n */\nexport function getXValues(timeScale: TimeScale): number[] {\n const xValues: number[] = [];\n let timestamp = timeScale.startMs;\n while (timestamp <= timeScale.endMs) {\n xValues.push(timestamp);\n timestamp += timeScale.stepMs;\n }\n return xValues;\n}\n\n/**\n * [DEPRECATED] Used for legacy LineChart 'category' axis approach.\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * processes the time series values, filling in any timestamps that are missing\n * from the time series data with `null` values.\n */\nexport function getTimeSeriesValues(series: TimeSeries, timeScale: TimeScale) {\n let timestamp = timeScale.startMs;\n\n const values = series.values;\n const processedValues: TimeSeriesValueTuple[] = [];\n\n for (const valueTuple of values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n processedValues.push([timestamp, valueTuple[1]]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n processedValues.push([timestamp, null]);\n timestamp += timeScale.stepMs;\n }\n\n return processedValues;\n}\n\n/**\n * Given a TimeSeries from a query and a common time scale (see `getCommonTimeScale`),\n * gets the values for the y axis of a graph, filling in any timestamps that are\n * missing from the time series data with `null` values.\n */\nexport function getYValues(series: TimeSeries, timeScale: TimeScale): Array<number | null> {\n let timestamp = timeScale.startMs;\n\n const yValues: Array<number | null> = [];\n for (const valueTuple of series.values) {\n // Fill in values up to the current series value timestamp with nulls\n while (timestamp < valueTuple[0]) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n // Now add the current value since timestamp should match\n yValues.push(valueTuple[1]);\n timestamp += timeScale.stepMs;\n }\n\n // Add null values at the end of the series if necessary\n while (timestamp <= timeScale.endMs) {\n yValues.push(null);\n timestamp += timeScale.stepMs;\n }\n\n return yValues;\n}\n\n/**\n * Given a list of running queries, calculates a common time scale for use on\n * the x axis (i.e. start/end dates and a step that is divisible into all of\n * the queries' steps).\n */\nexport function getCommonTimeScale(\n seriesData: Array<TimeSeriesData | Pick<TimeSeries, 'values'> | undefined>\n): TimeScale | undefined {\n let timeRange: AbsoluteTimeRange | undefined = undefined;\n const steps: number[] = [];\n\n for (const data of seriesData) {\n if (data && 'timeRange' in data) {\n if (data === undefined || data.timeRange === undefined || data.stepMs === undefined) continue;\n\n // Keep track of query steps so we can calculate a common one for the graph\n steps.push(data.stepMs);\n\n // If we don't have an overall time range yet, just start with this one\n if (timeRange === undefined) {\n timeRange = data.timeRange;\n continue;\n }\n\n // Otherwise, see if this query has a start or end outside of the current\n // time range\n if (data.timeRange.start < timeRange.start) {\n timeRange.start = data.timeRange.start;\n }\n if (data.timeRange.end > timeRange.end) {\n timeRange.end = data.timeRange.end;\n }\n } else if (data && 'values' in data) {\n for (let i = 0; i < data.values.length; i++) {\n const values = data.values[i];\n if (values === undefined) {\n continue;\n }\n\n const [timestamp] = values;\n const start = new Date(timestamp);\n const end = new Date(timestamp);\n\n if (timeRange === undefined) {\n timeRange = {\n start,\n end,\n };\n continue;\n }\n\n if (start < timeRange.start) {\n timeRange.start = start;\n }\n\n if (end > timeRange.end) {\n timeRange.end = end;\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, rangeMs, stepMs: MIN_STEP_INTERVAL_MS };\n }\n }\n\n if (timeRange === undefined) return undefined;\n\n // Use the greatest common divisor of all step values as the overall step\n // for the x axis (or if only one query, just use that query's step value)\n let stepMs: number;\n if (steps.length === 1) {\n stepMs = steps[0] as number;\n } else {\n const calculatedStepMs = gcd(...steps);\n stepMs = calculatedStepMs < MIN_STEP_INTERVAL_MS ? MIN_STEP_INTERVAL_MS : calculatedStepMs;\n }\n\n const startMs = timeRange.start.valueOf();\n const endMs = timeRange.end.valueOf();\n const rangeMs = endMs - startMs;\n\n return { startMs, endMs, stepMs, rangeMs };\n}\n"],"names":["gcd","MIN_STEP_INTERVAL_MS","getXValues","timeScale","xValues","timestamp","startMs","endMs","push","stepMs","getTimeSeriesValues","series","values","processedValues","valueTuple","getYValues","yValues","getCommonTimeScale","seriesData","timeRange","undefined","steps","data","start","end","i","length","Date","valueOf","rangeMs","calculatedStepMs"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAGjC,SAASA,GAAG,QAAQ,UAAU,CAAC;AAE/B,OAAO,MAAMC,oBAAoB,GAAG,EAAE,CAAC;AAEvC;;;CAGC,GACD,OAAO,SAASC,UAAU,CAACC,SAAoB,EAAY;IACzD,MAAMC,OAAO,GAAa,EAAE,AAAC;IAC7B,IAAIC,SAAS,GAAGF,SAAS,CAACG,OAAO,AAAC;IAClC,MAAOD,SAAS,IAAIF,SAAS,CAACI,KAAK,CAAE;QACnCH,OAAO,CAACI,IAAI,CAACH,SAAS,CAAC,CAAC;QACxBA,SAAS,IAAIF,SAAS,CAACM,MAAM,CAAC;IAChC,CAAC;IACD,OAAOL,OAAO,CAAC;AACjB,CAAC;AAED;;;;;CAKC,GACD,OAAO,SAASM,mBAAmB,CAACC,MAAkB,EAAER,SAAoB,EAAE;IAC5E,IAAIE,SAAS,GAAGF,SAAS,CAACG,OAAO,AAAC;IAElC,MAAMM,MAAM,GAAGD,MAAM,CAACC,MAAM,AAAC;IAC7B,MAAMC,eAAe,GAA2B,EAAE,AAAC;IAEnD,KAAK,MAAMC,UAAU,IAAIF,MAAM,CAAE;QAC/B,qEAAqE;QACrE,MAAOP,SAAS,GAAGS,UAAU,CAAC,CAAC,CAAC,CAAE;YAChCD,eAAe,CAACL,IAAI,CAAC;gBAACH,SAAS;gBAAE,IAAI;aAAC,CAAC,CAAC;YACxCA,SAAS,IAAIF,SAAS,CAACM,MAAM,CAAC;QAChC,CAAC;QAED,yDAAyD;QACzDI,eAAe,CAACL,IAAI,CAAC;YAACH,SAAS;YAAES,U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