@perses-dev/core 0.44.0 → 0.45.0-rc1

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.
@@ -14,3 +14,15 @@
14
14
  Object.defineProperty(exports, "__esModule", {
15
15
  value: true
16
16
  });
17
+ Object.defineProperty(exports, "isValidQueryPluginType", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return isValidQueryPluginType;
21
+ }
22
+ });
23
+ function isValidQueryPluginType(type) {
24
+ return [
25
+ 'TimeSeriesQuery',
26
+ 'TraceQuery'
27
+ ].includes(type);
28
+ }
@@ -21,57 +21,34 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
- getDashboardDisplayName: function() {
25
- return getDashboardDisplayName;
24
+ getResourceDisplayName: function() {
25
+ return getResourceDisplayName;
26
26
  },
27
- getDashboardExtendedDisplayName: function() {
28
- return getDashboardExtendedDisplayName;
29
- },
30
- getDatasourceDisplayName: function() {
31
- return getDatasourceDisplayName;
32
- },
33
- getDatasourceExtendedDisplayName: function() {
34
- return getDatasourceExtendedDisplayName;
35
- },
36
- getVariableDisplayName: function() {
37
- return getVariableDisplayName;
38
- },
39
- getVariableExtendedDisplayName: function() {
40
- return getVariableExtendedDisplayName;
27
+ getResourceExtendedDisplayName: function() {
28
+ return getResourceExtendedDisplayName;
41
29
  }
42
30
  });
43
- function getDashboardDisplayName(dashboard) {
44
- var _dashboard_spec_display;
45
- var _dashboard_spec_display_name;
46
- return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
47
- }
48
- function getVariableDisplayName(variable) {
49
- var _variable_spec_spec_display;
50
- var _variable_spec_spec_display_name;
51
- return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
52
- }
53
- function getDatasourceDisplayName(datasource) {
54
- var _datasource_spec_display;
55
- return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
56
- }
57
- function getDashboardExtendedDisplayName(dashboard) {
58
- var _dashboard_spec_display;
59
- if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
60
- return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
31
+ function getResourceDisplayName(resource) {
32
+ var _resource_spec_spec_display, _resource_spec_spec, _resource_spec_display;
33
+ // Variables
34
+ if ((_resource_spec_spec = resource.spec.spec) === null || _resource_spec_spec === void 0 ? void 0 : (_resource_spec_spec_display = _resource_spec_spec.display) === null || _resource_spec_spec_display === void 0 ? void 0 : _resource_spec_spec_display.name) {
35
+ return resource.spec.spec.display.name;
61
36
  }
62
- return dashboard.metadata.name;
63
- }
64
- function getVariableExtendedDisplayName(variable) {
65
- var _variable_spec_spec_display;
66
- if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
67
- return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
37
+ // Other resources with display
38
+ if ((_resource_spec_display = resource.spec.display) === null || _resource_spec_display === void 0 ? void 0 : _resource_spec_display.name) {
39
+ return resource.spec.display.name;
68
40
  }
69
- return variable.metadata.name;
41
+ return resource.metadata.name;
70
42
  }
71
- function getDatasourceExtendedDisplayName(datasource) {
72
- var _datasource_spec_display;
73
- if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
74
- return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
43
+ function getResourceExtendedDisplayName(resource) {
44
+ var _resource_spec_spec_display, _resource_spec_spec, _resource_spec_display;
45
+ // Variables
46
+ if ((_resource_spec_spec = resource.spec.spec) === null || _resource_spec_spec === void 0 ? void 0 : (_resource_spec_spec_display = _resource_spec_spec.display) === null || _resource_spec_spec_display === void 0 ? void 0 : _resource_spec_spec_display.name) {
47
+ return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
48
+ }
49
+ // Other resources with display
50
+ if ((_resource_spec_display = resource.spec.display) === null || _resource_spec_display === void 0 ? void 0 : _resource_spec_display.name) {
51
+ return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
75
52
  }
76
- return datasource.metadata.name;
53
+ return resource.metadata.name;
77
54
  }
@@ -1,5 +1,12 @@
1
1
  import { Definition, UnknownSpec } from './definitions';
2
2
  import { QueryDefinition } from './query';
3
+ export interface Link {
4
+ name?: string;
5
+ url: string;
6
+ tooltip?: string;
7
+ renderVariables?: boolean;
8
+ targetBlank?: boolean;
9
+ }
3
10
  export interface PanelDisplay {
4
11
  name: string;
5
12
  description?: string;
@@ -11,6 +18,7 @@ export interface PanelSpec<PluginSpec> {
11
18
  display: PanelDisplay;
12
19
  plugin: Definition<PluginSpec>;
13
20
  queries?: QueryDefinition[];
21
+ links?: Link[];
14
22
  }
15
23
  /**
16
24
  * A reference to a panel defined in the DashboardSpec.
@@ -1 +1 @@
1
- {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe,CAAC,UAAU,GAAG,WAAW,CAAE,SAAQ,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClG,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,SAAS,CAAC,UAAU;IACnC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,iBAAiB,MAAM,EAAE,CAAC;CACjC"}
1
+ {"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,WAAW,IAAI;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe,CAAC,UAAU,GAAG,WAAW,CAAE,SAAQ,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAClG,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,SAAS,CAAC,UAAU;IACnC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAC5B,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,iBAAiB,MAAM,EAAE,CAAC;CACjC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/panels.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 { QueryDefinition } from './query';\n\nexport interface PanelDisplay {\n name: string;\n description?: string;\n}\n\nexport interface PanelDefinition<PluginSpec = UnknownSpec> extends Definition<PanelSpec<PluginSpec>> {\n kind: 'Panel';\n}\n\nexport interface PanelSpec<PluginSpec> {\n display: PanelDisplay;\n plugin: Definition<PluginSpec>;\n queries?: QueryDefinition[];\n}\n\n/**\n * A reference to a panel defined in the DashboardSpec.\n */\nexport interface PanelRef {\n $ref: `#/spec/panels/${string}`;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAoBjC;;CAEC,GACD,WAEC"}
1
+ {"version":3,"sources":["../../src/model/panels.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 { QueryDefinition } from './query';\n\nexport interface Link {\n name?: string;\n url: string;\n tooltip?: string;\n renderVariables?: boolean;\n targetBlank?: boolean;\n}\n\nexport interface PanelDisplay {\n name: string;\n description?: string;\n}\n\nexport interface PanelDefinition<PluginSpec = UnknownSpec> extends Definition<PanelSpec<PluginSpec>> {\n kind: 'Panel';\n}\n\nexport interface PanelSpec<PluginSpec> {\n display: PanelDisplay;\n plugin: Definition<PluginSpec>;\n queries?: QueryDefinition[];\n links?: Link[];\n}\n\n/**\n * A reference to a panel defined in the DashboardSpec.\n */\nexport interface PanelRef {\n $ref: `#/spec/panels/${string}`;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AA6BjC;;CAEC,GACD,WAEC"}
@@ -1,6 +1,11 @@
1
1
  import { Metadata } from './resource';
2
+ import { Display } from './display';
2
3
  export interface ProjectResource {
3
4
  kind: 'Project';
4
5
  metadata: Metadata;
6
+ spec: ProjectSpec;
7
+ }
8
+ export interface ProjectSpec {
9
+ display?: Display;
5
10
  }
6
11
  //# sourceMappingURL=project.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/model/project.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1 +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;AAIjC,WAGC"}
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';\nimport { Display } from './display';\n\nexport interface ProjectResource {\n kind: 'Project';\n metadata: Metadata;\n spec: ProjectSpec;\n}\n\nexport interface ProjectSpec {\n display?: Display;\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;AAWjC,WAEC"}
@@ -18,6 +18,16 @@ export interface QueryType {
18
18
  TimeSeriesQuery: TimeSeriesData;
19
19
  TraceQuery: TraceData;
20
20
  }
21
+ /**
22
+ * Check if the given type is a valid {@link QueryPluginType} with compile time safety
23
+ * @param type
24
+ */
25
+ export declare function isValidQueryPluginType(type: string): type is QueryPluginType;
26
+ /**
27
+ * Extract the keys of QueryType
28
+ * ex: 'TimeSeriesQuery'
29
+ */
30
+ export type QueryPluginType = keyof QueryType;
21
31
  /**
22
32
  * Values of QueryType
23
33
  * ex: 'TimeSeriesData'
@@ -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;AAEzC,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;CAGvB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC"}
1
+ {"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/model/query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,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;CAGvB;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"}
@@ -11,8 +11,13 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  /**
14
- * Values of QueryType
15
- * ex: 'TimeSeriesData'
16
- */ export { };
14
+ * Check if the given type is a valid {@link QueryPluginType} with compile time safety
15
+ * @param type
16
+ */ export function isValidQueryPluginType(type) {
17
+ return [
18
+ 'TimeSeriesQuery',
19
+ 'TraceQuery'
20
+ ].includes(type);
21
+ }
17
22
 
18
23
  //# sourceMappingURL=query.js.map
@@ -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 * Values of QueryType\n * ex: 'TimeSeriesData'\n */\nexport type QueryDataType = QueryType[keyof QueryType];\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;AA6BjC;;;CAGC,GACD,WAAuD"}
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;AA6BjC;;;CAGC,GACD,OAAO,SAASA,uBAAuBC,IAAY;IACjD,OAAO;QAAC;QAAmB;KAAa,CAACC,QAAQ,CAACD;AACpD"}
@@ -1,3 +1,4 @@
1
+ import { Kind } from './kind';
1
2
  export interface Metadata {
2
3
  name: string;
3
4
  createdAt?: string;
@@ -7,5 +8,10 @@ export interface Metadata {
7
8
  export interface ProjectMetadata extends Metadata {
8
9
  project: string;
9
10
  }
11
+ export interface Resource {
12
+ kind: Kind;
13
+ metadata: Metadata | ProjectMetadata;
14
+ spec: any;
15
+ }
10
16
  export declare function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined;
11
17
  //# sourceMappingURL=resource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,QAAQ,GAAG,eAAe,CAAC;IAErC,IAAI,EAAE,GAAG,CAAC;CACX;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,CAE3F"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/resource.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 interface Metadata {\n name: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: string;\n}\n\nexport function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined {\n return 'project' in metadata ? metadata.project : undefined;\n}\n"],"names":["getMetadataProject","metadata","project","undefined"],"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;AAajC,OAAO,SAASA,mBAAmBC,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASC,OAAO,GAAGC;AACpD"}
1
+ {"version":3,"sources":["../../src/model/resource.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 { Kind } from './kind';\n\nexport interface Metadata {\n name: string;\n createdAt?: string;\n updatedAt?: string;\n version?: number;\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: string;\n}\n\nexport interface Resource {\n kind: Kind;\n metadata: Metadata | ProjectMetadata;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n spec: any;\n}\n\nexport function getMetadataProject(metadata: ProjectMetadata | Metadata): string | undefined {\n return 'project' in metadata ? metadata.project : undefined;\n}\n"],"names":["getMetadataProject","metadata","project","undefined"],"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;AAsBjC,OAAO,SAASA,mBAAmBC,QAAoC;IACrE,OAAO,aAAaA,WAAWA,SAASC,OAAO,GAAGC;AACpD"}
@@ -1,38 +1,12 @@
1
- import { DashboardResource, Variable, Datasource, EphemeralDashboardResource } from '../model';
1
+ import { Resource } from '../model';
2
2
  /**
3
- * If the dashboard has a display name, return the dashboard display name
4
- * Else, only return the dashboard name
5
- * @param dashboard
3
+ * If the resource has a display name, return the variable display name
4
+ * Else, only return the resource metdata name
6
5
  */
7
- export declare function getDashboardDisplayName(dashboard: DashboardResource | EphemeralDashboardResource): string;
6
+ export declare function getResourceDisplayName<T extends Resource>(resource: T): string;
8
7
  /**
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
8
+ * If the resource has a display name, return the resource display name with the resource name too
9
+ * Else, only return the resource name
12
10
  */
13
- export declare function getVariableDisplayName(variable: Variable): string;
14
- /**
15
- * If the variable has a display name, return the datasource display name
16
- * Else, only return the datasource name
17
- * @param datasource Project or Global datasource
18
- */
19
- export declare function getDatasourceDisplayName(datasource: Datasource): string;
20
- /**
21
- * If the dashboard has a display name, return the dashboard display name and the dashboard name
22
- * Else, only return the dashboard name
23
- * @param dashboard
24
- */
25
- export declare function getDashboardExtendedDisplayName(dashboard: DashboardResource | EphemeralDashboardResource): string;
26
- /**
27
- * If the variable has a display name, return the variable display name and the variable name
28
- * Else, only return the variable name
29
- * @param variable Project or Global variable
30
- */
31
- export declare function getVariableExtendedDisplayName(variable: Variable): string;
32
- /**
33
- * If the datasource has a display name, return the datasource display name and the datasource name
34
- * Else, only return the datasource name
35
- * @param datasource Project or Global datasource
36
- */
37
- export declare function getDatasourceExtendedDisplayName(datasource: Datasource): string;
11
+ export declare function getResourceExtendedDisplayName<T extends Resource>(resource: T): string;
38
12
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAE/F;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,GAAG,0BAA0B,UAEhG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,UAExD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,UAAU,UAE9D;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,SAAS,EAAE,iBAAiB,GAAG,0BAA0B,UAKxG;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,QAAQ,EAAE,QAAQ,UAKhE;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,UAAU,UAKtE"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAY9E;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,CAAC,SAAS,QAAQ,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAYtF"}
@@ -11,63 +11,34 @@
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) {
18
- var _dashboard_spec_display;
19
- var _dashboard_spec_display_name;
20
- return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
21
- }
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 _variable_spec_spec_display;
28
- var _variable_spec_spec_display_name;
29
- return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
30
- }
31
- /**
32
- * If the variable has a display name, return the datasource display name
33
- * Else, only return the datasource name
34
- * @param datasource Project or Global datasource
35
- */ export function getDatasourceDisplayName(datasource) {
36
- var _datasource_spec_display;
37
- return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
38
- }
39
- /**
40
- * If the dashboard has a display name, return the dashboard display name and the dashboard name
41
- * Else, only return the dashboard name
42
- * @param dashboard
43
- */ export function getDashboardExtendedDisplayName(dashboard) {
44
- var _dashboard_spec_display;
45
- if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
46
- return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
14
+ * If the resource has a display name, return the variable display name
15
+ * Else, only return the resource metdata name
16
+ */ export function getResourceDisplayName(resource) {
17
+ var _resource_spec_spec_display, _resource_spec_spec, _resource_spec_display;
18
+ // Variables
19
+ if ((_resource_spec_spec = resource.spec.spec) === null || _resource_spec_spec === void 0 ? void 0 : (_resource_spec_spec_display = _resource_spec_spec.display) === null || _resource_spec_spec_display === void 0 ? void 0 : _resource_spec_spec_display.name) {
20
+ return resource.spec.spec.display.name;
47
21
  }
48
- return dashboard.metadata.name;
49
- }
50
- /**
51
- * If the variable has a display name, return the variable display name and the variable name
52
- * Else, only return the variable name
53
- * @param variable Project or Global variable
54
- */ export function getVariableExtendedDisplayName(variable) {
55
- var _variable_spec_spec_display;
56
- if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
57
- return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
22
+ // Other resources with display
23
+ if ((_resource_spec_display = resource.spec.display) === null || _resource_spec_display === void 0 ? void 0 : _resource_spec_display.name) {
24
+ return resource.spec.display.name;
58
25
  }
59
- return variable.metadata.name;
26
+ return resource.metadata.name;
60
27
  }
61
28
  /**
62
- * If the datasource has a display name, return the datasource display name and the datasource name
63
- * Else, only return the datasource name
64
- * @param datasource Project or Global datasource
65
- */ export function getDatasourceExtendedDisplayName(datasource) {
66
- var _datasource_spec_display;
67
- if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
68
- return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
29
+ * If the resource has a display name, return the resource display name with the resource name too
30
+ * Else, only return the resource name
31
+ */ export function getResourceExtendedDisplayName(resource) {
32
+ var _resource_spec_spec_display, _resource_spec_spec, _resource_spec_display;
33
+ // Variables
34
+ if ((_resource_spec_spec = resource.spec.spec) === null || _resource_spec_spec === void 0 ? void 0 : (_resource_spec_spec_display = _resource_spec_spec.display) === null || _resource_spec_spec_display === void 0 ? void 0 : _resource_spec_spec_display.name) {
35
+ return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;
36
+ }
37
+ // Other resources with display
38
+ if ((_resource_spec_display = resource.spec.display) === null || _resource_spec_display === void 0 ? void 0 : _resource_spec_display.name) {
39
+ return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;
69
40
  }
70
- return datasource.metadata.name;
41
+ return resource.metadata.name;
71
42
  }
72
43
 
73
44
  //# sourceMappingURL=text.js.map
@@ -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, Variable, Datasource, EphemeralDashboardResource } 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 | EphemeralDashboardResource) {\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: Variable) {\n return variable.spec.spec.display?.name ?? variable.metadata.name;\n}\n\n/**\n * If the variable has a display name, return the datasource display name\n * Else, only return the datasource name\n * @param datasource Project or Global datasource\n */\nexport function getDatasourceDisplayName(datasource: Datasource) {\n return datasource.spec.display?.name || datasource.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 | EphemeralDashboardResource) {\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: Variable) {\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\n/**\n * If the datasource has a display name, return the datasource display name and the datasource name\n * Else, only return the datasource name\n * @param datasource Project or Global datasource\n */\nexport function getDatasourceExtendedDisplayName(datasource: Datasource) {\n if (datasource.spec.display?.name) {\n return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;\n }\n return datasource.metadata.name;\n}\n"],"names":["getDashboardDisplayName","dashboard","spec","display","name","metadata","getVariableDisplayName","variable","getDatasourceDisplayName","datasource","getDashboardExtendedDisplayName","getVariableExtendedDisplayName","getDatasourceExtendedDisplayName"],"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,wBAAwBC,SAAyD;QACxFA;QAAAA;IAAP,OAAOA,CAAAA,gCAAAA,0BAAAA,UAAUC,IAAI,CAACC,OAAO,cAAtBF,8CAAAA,wBAAwBG,IAAI,cAA5BH,0CAAAA,+BAAgCA,UAAUI,QAAQ,CAACD,IAAI;AAChE;AAEA;;;;CAIC,GACD,OAAO,SAASE,uBAAuBC,QAAkB;QAChDA;QAAAA;IAAP,OAAOA,CAAAA,oCAAAA,8BAAAA,SAASL,IAAI,CAACA,IAAI,CAACC,OAAO,cAA1BI,kDAAAA,4BAA4BH,IAAI,cAAhCG,8CAAAA,mCAAoCA,SAASF,QAAQ,CAACD,IAAI;AACnE;AAEA;;;;CAIC,GACD,OAAO,SAASI,yBAAyBC,UAAsB;QACtDA;IAAP,OAAOA,EAAAA,2BAAAA,WAAWP,IAAI,CAACC,OAAO,cAAvBM,+CAAAA,yBAAyBL,IAAI,KAAIK,WAAWJ,QAAQ,CAACD,IAAI;AAClE;AAEA;;;;CAIC,GACD,OAAO,SAASM,gCAAgCT,SAAyD;QACnGA;IAAJ,KAAIA,0BAAAA,UAAUC,IAAI,CAACC,OAAO,cAAtBF,8CAAAA,wBAAwBG,IAAI,EAAE;QAChC,OAAO,CAAC,EAAEH,UAAUC,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,QAAQ,EAAEH,UAAUI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC5E;IACA,OAAOH,UAAUI,QAAQ,CAACD,IAAI;AAChC;AAEA;;;;CAIC,GACD,OAAO,SAASO,+BAA+BJ,QAAkB;QAC3DA;IAAJ,KAAIA,8BAAAA,SAASL,IAAI,CAACA,IAAI,CAACC,OAAO,cAA1BI,kDAAAA,4BAA4BH,IAAI,EAAE;QACpC,OAAO,CAAC,EAAEG,SAASL,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,QAAQ,EAAEG,SAASF,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC/E;IACA,OAAOG,SAASF,QAAQ,CAACD,IAAI;AAC/B;AAEA;;;;CAIC,GACD,OAAO,SAASQ,iCAAiCH,UAAsB;QACjEA;IAAJ,KAAIA,2BAAAA,WAAWP,IAAI,CAACC,OAAO,cAAvBM,+CAAAA,yBAAyBL,IAAI,EAAE;QACjC,OAAO,CAAC,EAAEK,WAAWP,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,QAAQ,EAAEK,WAAWJ,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC9E;IACA,OAAOK,WAAWJ,QAAQ,CAACD,IAAI;AACjC"}
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 { Resource } from '../model';\n\n/**\n * If the resource has a display name, return the variable display name\n * Else, only return the resource metdata name\n */\nexport function getResourceDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec.spec?.display?.name) {\n return resource.spec.spec.display.name;\n }\n\n // Other resources with display\n if (resource.spec.display?.name) {\n return resource.spec.display.name;\n }\n\n return resource.metadata.name;\n}\n\n/**\n * If the resource has a display name, return the resource display name with the resource name too\n * Else, only return the resource name\n */\nexport function getResourceExtendedDisplayName<T extends Resource>(resource: T): string {\n // Variables\n if (resource.spec.spec?.display?.name) {\n return `${resource.spec.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n // Other resources with display\n if (resource.spec.display?.name) {\n return `${resource.spec.display.name} (ID: ${resource.metadata.name})`;\n }\n\n return resource.metadata.name;\n}\n"],"names":["getResourceDisplayName","resource","spec","display","name","metadata","getResourceExtendedDisplayName"],"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;;;CAGC,GACD,OAAO,SAASA,uBAA2CC,QAAW;QAEhEA,6BAAAA,qBAKAA;IANJ,YAAY;IACZ,KAAIA,sBAAAA,SAASC,IAAI,CAACA,IAAI,cAAlBD,2CAAAA,8BAAAA,oBAAoBE,OAAO,cAA3BF,kDAAAA,4BAA6BG,IAAI,EAAE;QACrC,OAAOH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI;IACxC;IAEA,+BAA+B;IAC/B,KAAIH,yBAAAA,SAASC,IAAI,CAACC,OAAO,cAArBF,6CAAAA,uBAAuBG,IAAI,EAAE;QAC/B,OAAOH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI;IACnC;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B;AAEA;;;CAGC,GACD,OAAO,SAASE,+BAAmDL,QAAW;QAExEA,6BAAAA,qBAKAA;IANJ,YAAY;IACZ,KAAIA,sBAAAA,SAASC,IAAI,CAACA,IAAI,cAAlBD,2CAAAA,8BAAAA,oBAAoBE,OAAO,cAA3BF,kDAAAA,4BAA6BG,IAAI,EAAE;QACrC,OAAO,CAAC,EAAEH,SAASC,IAAI,CAACA,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IAC7E;IAEA,+BAA+B;IAC/B,KAAIH,yBAAAA,SAASC,IAAI,CAACC,OAAO,cAArBF,6CAAAA,uBAAuBG,IAAI,EAAE;QAC/B,OAAO,CAAC,EAAEH,SAASC,IAAI,CAACC,OAAO,CAACC,IAAI,CAAC,MAAM,EAAEH,SAASI,QAAQ,CAACD,IAAI,CAAC,CAAC,CAAC;IACxE;IAEA,OAAOH,SAASI,QAAQ,CAACD,IAAI;AAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.44.0",
3
+ "version": "0.45.0-rc1",
4
4
  "description": "Core functionality consumed by both the Perses UI and plugins",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",