@perses-dev/core 0.44.0-rc1 → 0.44.0-rc2

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.
@@ -0,0 +1,16 @@
1
+ // Copyright 2024 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
+ });
@@ -19,6 +19,7 @@ _export_star(require("./dashboard"), exports);
19
19
  _export_star(require("./datasource"), exports);
20
20
  _export_star(require("./definitions"), exports);
21
21
  _export_star(require("./display"), exports);
22
+ _export_star(require("./ephemeraldashboard"), exports);
22
23
  _export_star(require("./http"), exports);
23
24
  _export_star(require("./http-proxy"), exports);
24
25
  _export_star(require("./kind"), exports);
@@ -23,6 +23,7 @@ Object.defineProperty(exports, "KINDS", {
23
23
  const KINDS = [
24
24
  'Dashboard',
25
25
  'Datasource',
26
+ 'EphemeralDashboard',
26
27
  'Folder',
27
28
  'GlobalDatasource',
28
29
  'GlobalRole',
@@ -42,6 +42,7 @@ const PROJECT_SCOPES = [
42
42
  '*',
43
43
  'Dashboard',
44
44
  'Datasource',
45
+ 'EphemeralDashboard',
45
46
  'Folder',
46
47
  'Project',
47
48
  'Role',
@@ -21,6 +21,9 @@ function _export(target, all) {
21
21
  });
22
22
  }
23
23
  _export(exports, {
24
+ DURATION_REGEX: function() {
25
+ return DURATION_REGEX;
26
+ },
24
27
  formatDuration: function() {
25
28
  return formatDuration;
26
29
  },
@@ -37,4 +37,11 @@ export interface DatasourceSelector {
37
37
  */
38
38
  name?: string;
39
39
  }
40
+ /**
41
+ * An intermediary type to regroup the name and the spec of a datasource.
42
+ */
43
+ export interface DatasourceDefinition {
44
+ name: string;
45
+ spec: DatasourceSpec;
46
+ }
40
47
  //# sourceMappingURL=datasource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/model/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE9D,MAAM,WAAW,cAAc,CAAC,UAAU,GAAG,WAAW;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
1
+ {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/model/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,kBAAkB,CAAC;IACzB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,cAAc,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,MAAM,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAE9D,MAAM,WAAW,cAAc,CAAC,UAAU,GAAG,WAAW;IACtD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;CACtB"}
@@ -11,7 +11,7 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  /**
14
- * A selector for pointing at a specific Datasource.
14
+ * An intermediary type to regroup the name and the spec of a datasource.
15
15
  */ export { };
16
16
 
17
17
  //# sourceMappingURL=datasource.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/datasource.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 { Metadata, ProjectMetadata } from './resource';\nimport { Display } from './display';\n\n/**\n * A Datasource that's available across all projects.\n */\nexport interface GlobalDatasource {\n kind: 'GlobalDatasource';\n metadata: Metadata;\n spec: DatasourceSpec;\n}\n\n/**\n * A Datasource resource, that belongs to a project.\n */\nexport interface ProjectDatasource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport type Datasource = ProjectDatasource | GlobalDatasource;\n\nexport interface DatasourceSpec<PluginSpec = UnknownSpec> {\n display?: Display;\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A selector for pointing at a specific Datasource.\n */\nexport interface DatasourceSelector {\n /**\n * Kind of the datasource.\n */\n kind: string;\n\n /**\n * Name of the datasource.\n * If omitted, it's assumed that you target the default datasource for the specified kind (and group, if set)\n */\n name?: 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;AAgCjC;;CAEC,GACD,WAWC"}
1
+ {"version":3,"sources":["../../src/model/datasource.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 { Metadata, ProjectMetadata } from './resource';\nimport { Display } from './display';\n\n/**\n * A Datasource that's available across all projects.\n */\nexport interface GlobalDatasource {\n kind: 'GlobalDatasource';\n metadata: Metadata;\n spec: DatasourceSpec;\n}\n\n/**\n * A Datasource resource, that belongs to a project.\n */\nexport interface ProjectDatasource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport type Datasource = ProjectDatasource | GlobalDatasource;\n\nexport interface DatasourceSpec<PluginSpec = UnknownSpec> {\n display?: Display;\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A selector for pointing at a specific Datasource.\n */\nexport interface DatasourceSelector {\n /**\n * Kind of the datasource.\n */\n kind: string;\n\n /**\n * Name of the datasource.\n * If omitted, it's assumed that you target the default datasource for the specified kind (and group, if set)\n */\n name?: string;\n}\n\n/**\n * An intermediary type to regroup the name and the spec of a datasource.\n */\nexport interface DatasourceDefinition {\n name: string;\n spec: DatasourceSpec;\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;AAgDjC;;CAEC,GACD,WAGC"}
@@ -0,0 +1,15 @@
1
+ import { ProjectMetadata } from './resource';
2
+ import { DurationString } from './time';
3
+ import { DashboardSelector, DashboardSpec } from './dashboard';
4
+ export interface EphemeralDashboardResource {
5
+ kind: 'EphemeralDashboard';
6
+ metadata: ProjectMetadata;
7
+ spec: EphemeralDashboardSpec;
8
+ }
9
+ export interface EphemeralDashboardSpec extends DashboardSpec {
10
+ ttl: DurationString;
11
+ }
12
+ export interface EphemeralDashboardInfo extends DashboardSelector {
13
+ ttl: DurationString;
14
+ }
15
+ //# sourceMappingURL=ephemeraldashboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ephemeraldashboard.d.ts","sourceRoot":"","sources":["../../src/model/ephemeraldashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,sBAAsB,CAAC;CAC9B;AAED,MAAM,WAAW,sBAAuB,SAAQ,aAAa;IAC3D,GAAG,EAAE,cAAc,CAAC;CACrB;AAED,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,GAAG,EAAE,cAAc,CAAC;CACrB"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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=ephemeraldashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/model/ephemeraldashboard.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { DashboardSelector, DashboardSpec } from './dashboard';\n\nexport interface EphemeralDashboardResource {\n kind: 'EphemeralDashboard';\n metadata: ProjectMetadata;\n spec: EphemeralDashboardSpec;\n}\n\nexport interface EphemeralDashboardSpec extends DashboardSpec {\n ttl: DurationString;\n}\n\nexport interface EphemeralDashboardInfo extends DashboardSelector {\n ttl: DurationString;\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;AAgBjC,WAEC"}
@@ -3,6 +3,7 @@ export * from './dashboard';
3
3
  export * from './datasource';
4
4
  export * from './definitions';
5
5
  export * from './display';
6
+ export * from './ephemeraldashboard';
6
7
  export * from './http';
7
8
  export * from './http-proxy';
8
9
  export * from './kind';
@@ -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,cAAc,CAAC;AAC7B,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,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,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,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,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,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -15,6 +15,7 @@ export * from './dashboard';
15
15
  export * from './datasource';
16
16
  export * from './definitions';
17
17
  export * from './display';
18
+ export * from './ephemeraldashboard';
18
19
  export * from './http';
19
20
  export * from './http-proxy';
20
21
  export * from './kind';
@@ -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 './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\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 './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,iBAAiB;AAC/B,cAAc,cAAc;AAC5B,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,cAAc,YAAY;AAC1B,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,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,UAAU;AACxB,cAAc,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 './ephemeraldashboard';\nexport * from './http';\nexport * from './http-proxy';\nexport * from './kind';\nexport * from './layout';\nexport * from './legend';\nexport * from './notice';\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 './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,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,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,UAAU;AACxB,cAAc,cAAc"}
@@ -1,3 +1,3 @@
1
- export type Kind = 'Dashboard' | 'Datasource' | 'Folder' | 'GlobalDatasource' | 'GlobalRole' | 'GlobalRoleBinding' | 'GlobalSecret' | 'GlobalVariable' | 'Project' | 'Role' | 'RoleBinding' | 'Secret' | 'User' | 'Variable';
1
+ export type Kind = 'Dashboard' | 'Datasource' | 'EphemeralDashboard' | 'Folder' | 'GlobalDatasource' | 'GlobalRole' | 'GlobalRoleBinding' | 'GlobalSecret' | 'GlobalVariable' | 'Project' | 'Role' | 'RoleBinding' | 'Secret' | 'User' | 'Variable';
2
2
  export declare const KINDS: Kind[];
3
3
  //# sourceMappingURL=kind.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/model/kind.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,IAAI,GACZ,WAAW,GACX,YAAY,GACZ,QAAQ,GACR,kBAAkB,GAClB,YAAY,GACZ,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,SAAS,GACT,MAAM,GACN,aAAa,GACb,QAAQ,GACR,MAAM,GACN,UAAU,CAAC;AAEf,eAAO,MAAM,KAAK,EAAE,IAAI,EAevB,CAAC"}
1
+ {"version":3,"file":"kind.d.ts","sourceRoot":"","sources":["../../src/model/kind.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,IAAI,GACZ,WAAW,GACX,YAAY,GACZ,oBAAoB,GACpB,QAAQ,GACR,kBAAkB,GAClB,YAAY,GACZ,mBAAmB,GACnB,cAAc,GACd,gBAAgB,GAChB,SAAS,GACT,MAAM,GACN,aAAa,GACb,QAAQ,GACR,MAAM,GACN,UAAU,CAAC;AAEf,eAAO,MAAM,KAAK,EAAE,IAAI,EAgBvB,CAAC"}
@@ -13,6 +13,7 @@
13
13
  export const KINDS = [
14
14
  'Dashboard',
15
15
  'Datasource',
16
+ 'EphemeralDashboard',
16
17
  'Folder',
17
18
  'GlobalDatasource',
18
19
  'GlobalRole',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/kind.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 type Kind =\n | 'Dashboard'\n | 'Datasource'\n | 'Folder'\n | 'GlobalDatasource'\n | 'GlobalRole'\n | 'GlobalRoleBinding'\n | 'GlobalSecret'\n | 'GlobalVariable'\n | 'Project'\n | 'Role'\n | 'RoleBinding'\n | 'Secret'\n | 'User'\n | 'Variable';\n\nexport const KINDS: Kind[] = [\n 'Dashboard',\n 'Datasource',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n];\n"],"names":["KINDS"],"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;AAkBjC,OAAO,MAAMA,QAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
1
+ {"version":3,"sources":["../../src/model/kind.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 type Kind =\n | 'Dashboard'\n | 'Datasource'\n | 'EphemeralDashboard'\n | 'Folder'\n | 'GlobalDatasource'\n | 'GlobalRole'\n | 'GlobalRoleBinding'\n | 'GlobalSecret'\n | 'GlobalVariable'\n | 'Project'\n | 'Role'\n | 'RoleBinding'\n | 'Secret'\n | 'User'\n | 'Variable';\n\nexport const KINDS: Kind[] = [\n 'Dashboard',\n 'Datasource',\n 'EphemeralDashboard',\n 'Folder',\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'User',\n 'Variable',\n];\n"],"names":["KINDS"],"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;AAmBjC,OAAO,MAAMA,QAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../../src/model/roles.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,MAAM,MAAM,MAAM,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,GAAG,CAAC;AACnE,eAAO,MAAM,OAAO,UAA8C,CAAC;AACnE,MAAM,MAAM,KAAK,GAAG,IAAI,GAAG,GAAG,CAAC;AAC/B,eAAO,MAAM,cAAc,UAU1B,CAAC;AAEF,eAAO,MAAM,aAAa,UAOzB,CAAC;AAEF,MAAM,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ChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,MAAM,MAAM,IAAI,GAAG,YAAY,GAAG,kBAAkB,CAAC"}
@@ -21,6 +21,7 @@ export const PROJECT_SCOPES = [
21
21
  '*',
22
22
  'Dashboard',
23
23
  'Datasource',
24
+ 'EphemeralDashboard',
24
25
  'Folder',
25
26
  'Project',
26
27
  'Role',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/roles.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, ProjectMetadata } from './resource';\nimport { Kind } from './kind';\n\nexport type Action = 'create' | 'read' | 'update' | 'delete' | '*';\nexport const ACTIONS = ['*', 'create', 'read', 'update', 'delete'];\nexport type Scope = Kind | '*';\nexport const PROJECT_SCOPES = [\n '*',\n 'Dashboard',\n 'Datasource',\n 'Folder',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'Variable',\n];\n\nexport const GLOBAL_SCOPES = [\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'User',\n];\n\nexport interface Permission {\n actions: Action[];\n scopes: Scope[];\n}\n\nexport interface RoleSpec {\n permissions: Permission[];\n}\n\n/**\n * A role that belongs to a project.\n */\nexport interface RoleResource {\n kind: 'Role';\n metadata: ProjectMetadata;\n spec: RoleSpec;\n}\n\n/**\n * A global role that doesn´t belong to a project.\n */\nexport interface GlobalRoleResource {\n kind: 'GlobalRole';\n metadata: Metadata;\n spec: RoleSpec;\n}\n\nexport type Role = RoleResource | GlobalRoleResource;\n"],"names":["ACTIONS","PROJECT_SCOPES","GLOBAL_SCOPES"],"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;AAMjC,OAAO,MAAMA,UAAU;IAAC;IAAK;IAAU;IAAQ;IAAU;CAAS,CAAC;AAEnE,OAAO,MAAMC,iBAAiB;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,OAAO,MAAMC,gBAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
1
+ {"version":3,"sources":["../../src/model/roles.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, ProjectMetadata } from './resource';\nimport { Kind } from './kind';\n\nexport type Action = 'create' | 'read' | 'update' | 'delete' | '*';\nexport const ACTIONS = ['*', 'create', 'read', 'update', 'delete'];\nexport type Scope = Kind | '*';\nexport const PROJECT_SCOPES = [\n '*',\n 'Dashboard',\n 'Datasource',\n 'EphemeralDashboard',\n 'Folder',\n 'Project',\n 'Role',\n 'RoleBinding',\n 'Secret',\n 'Variable',\n];\n\nexport const GLOBAL_SCOPES = [\n 'GlobalDatasource',\n 'GlobalRole',\n 'GlobalRoleBinding',\n 'GlobalSecret',\n 'GlobalVariable',\n 'User',\n];\n\nexport interface Permission {\n actions: Action[];\n scopes: Scope[];\n}\n\nexport interface RoleSpec {\n permissions: Permission[];\n}\n\n/**\n * A role that belongs to a project.\n */\nexport interface RoleResource {\n kind: 'Role';\n metadata: ProjectMetadata;\n spec: RoleSpec;\n}\n\n/**\n * A global role that doesn´t belong to a project.\n */\nexport interface GlobalRoleResource {\n kind: 'GlobalRole';\n metadata: Metadata;\n spec: RoleSpec;\n}\n\nexport type Role = RoleResource | GlobalRoleResource;\n"],"names":["ACTIONS","PROJECT_SCOPES","GLOBAL_SCOPES"],"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;AAMjC,OAAO,MAAMA,UAAU;IAAC;IAAK;IAAU;IAAQ;IAAU;CAAS,CAAC;AAEnE,OAAO,MAAMC,iBAAiB;IAC5B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAC;AAEF,OAAO,MAAMC,gBAAgB;IAC3B;IACA;IACA;IACA;IACA;IACA;CACD,CAAC"}
@@ -30,6 +30,7 @@ type DaysDurationString = `${number}d`;
30
30
  type WeeksDurationString = `${number}w`;
31
31
  type YearsDurationString = `${number}y`;
32
32
  export type DurationString = Exclude<`${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${MinutesDurationString | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`, ''>;
33
+ export declare const DURATION_REGEX: RegExp;
33
34
  /**
34
35
  * Parses a DurationString into a Duration object with numeric values that can
35
36
  * be used to do Date math. Throws if not a valid duration string.
@@ -1 +1 @@
1
- {"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,E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,7 +37,7 @@ const ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d
37
37
  end
38
38
  };
39
39
  }
40
- const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
40
+ export const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
41
41
  /**
42
42
  * Parses a DurationString into a Duration object with numeric values that can
43
43
  * be used to do Date math. Throws if not a valid duration string.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/model/time.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 { Duration, sub } from 'date-fns';\n\nconst ONE_SECOND_IN_MS = 1000;\nconst ONE_MINUTE_IN_MS = 60000;\nconst ONE_HOUR_IN_MS = 3600000;\nconst ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h\nconst ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d\nconst ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d\n\nexport type UnixTimeMs = number;\n\nexport type DateTimeFormat = number | string;\n\nexport interface AbsoluteTimeRange {\n start: Date;\n end: Date;\n}\n\nexport interface RelativeTimeRange {\n // End date or undefined if relative to the current Date\n end?: Date;\n pastDuration: DurationString;\n}\n\nexport type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;\n\n/**\n * Determine whether a given time range is relative\n */\nexport function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange {\n return (timeRange as RelativeTimeRange).pastDuration !== undefined;\n}\n\n/**\n * Determine whether a given time range is absolute\n */\nexport function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange {\n return (timeRange as AbsoluteTimeRange).start !== undefined && (timeRange as AbsoluteTimeRange).end !== undefined;\n}\n\n/**\n * Returns an absolute time range from a RelativeTimeRange.\n */\nexport function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange {\n const end = timeRange.end ?? new Date();\n\n return {\n start: sub(end, parseDurationString(timeRange.pastDuration)),\n end,\n };\n}\n\ntype MillisecondsDurationString = `${number}ms`;\ntype SecondsDurationString = `${number}s`;\ntype MinutesDurationString = `${number}m`;\ntype HoursDurationString = `${number}h`;\ntype DaysDurationString = `${number}d`;\ntype WeeksDurationString = `${number}w`;\ntype YearsDurationString = `${number}y`;\n\nexport type DurationString = Exclude<\n `${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${\n | MinutesDurationString\n | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`,\n ''\n>;\n\nconst DURATION_REGEX = /^(?:(\\d+)y)?(?:(\\d+)w)?(?:(\\d+)d)?(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?(?:(\\d+)ms)?$/;\n\n/**\n * Parses a DurationString into a Duration object with numeric values that can\n * be used to do Date math. Throws if not a valid duration string.\n */\nexport function parseDurationString(durationString: string): Duration {\n const matches = DURATION_REGEX.exec(durationString);\n if (matches === null) {\n throw new Error(`Invalid duration string '${durationString}'`);\n }\n\n return {\n years: parseInt(matches[1] ?? '0'),\n months: 0,\n weeks: parseInt(matches[2] ?? '0'),\n days: parseInt(matches[3] ?? '0'),\n hours: parseInt(matches[4] ?? '0'),\n minutes: parseInt(matches[5] ?? '0'),\n seconds: parseInt(matches[6] ?? '0') + parseInt(matches[7] ?? '0') / 1000,\n };\n}\n\n/**\n * Returns true if the given string is a valid DurationString.\n */\nexport function isDurationString(maybeDuration: string): maybeDuration is DurationString {\n if (maybeDuration === '') return false;\n return DURATION_REGEX.test(maybeDuration);\n}\n\nexport function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration {\n const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n return msToPrometheusDuration(durationInMs);\n}\n\nexport function msToPrometheusDuration(durationInMs: number): Duration {\n const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);\n if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;\n const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);\n if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;\n const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);\n if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;\n const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);\n if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;\n const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);\n if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;\n\n return {\n years: years,\n months: 0,\n weeks: weeks,\n days: days,\n hours: hours,\n minutes: minutes,\n seconds: durationInMs / 1000,\n };\n}\n\nexport function formatDuration(duration: Duration): DurationString {\n const result: string[] = [];\n if (duration.years) {\n result.push(`${duration.years}y`);\n }\n if (duration.weeks) {\n result.push(`${duration.weeks}w`);\n }\n if (duration.days) {\n result.push(`${duration.days}d`);\n }\n if (duration.hours) {\n result.push(`${duration.hours}h`);\n }\n if (duration.minutes) {\n result.push(`${duration.minutes}m`);\n }\n if (duration.seconds) {\n const seconds = Math.trunc(duration.seconds);\n if (seconds) {\n result.push(`${seconds}s`);\n }\n const ms = (duration.seconds - seconds) * 1000;\n if (ms) {\n result.push(`${ms}ms`);\n }\n }\n return result.join('') as DurationString;\n}\n\nconst DEFAULT_STEP_MS = 15000;\n\nconst ROUNDED_STEP_INTERVALS = [\n // max: 0.015s\n { maxMs: 15, roundedStepMs: 10, display: '0.01s' },\n // max: 0.035s\n { maxMs: 35, roundedStepMs: 20, display: '0.02s' },\n // max: 0.075s\n { maxMs: 75, roundedStepMs: 50, display: '0.05s' },\n // max: 0.15s\n { maxMs: 150, roundedStepMs: 100, display: '0.1s' },\n // max: 0.35s\n { maxMs: 350, roundedStepMs: 200, display: '0.2s' },\n // max: 0.75s\n { maxMs: 750, roundedStepMs: 500, display: '0.5s' },\n // max: 1.5s\n { maxMs: ONE_SECOND_IN_MS * 1.5, roundedStepMs: ONE_SECOND_IN_MS, display: '1s' },\n // max: 3.5s\n { maxMs: ONE_SECOND_IN_MS * 3.5, roundedStepMs: ONE_SECOND_IN_MS * 2, display: '2s' },\n // max: 7.5s\n { maxMs: ONE_SECOND_IN_MS * 7.5, roundedStepMs: ONE_SECOND_IN_MS * 5, display: '5s' },\n // max: 12.5s\n { maxMs: ONE_SECOND_IN_MS * 12.5, roundedStepMs: ONE_SECOND_IN_MS * 10, display: '10s' },\n // max: 17.5s\n { maxMs: ONE_SECOND_IN_MS * 17.5, roundedStepMs: ONE_SECOND_IN_MS * 15, display: '15s' },\n // max: 25s\n { maxMs: ONE_SECOND_IN_MS * 25, roundedStepMs: ONE_SECOND_IN_MS * 20, display: '20s' },\n // max: 45s\n { maxMs: ONE_SECOND_IN_MS * 45, roundedStepMs: ONE_SECOND_IN_MS * 30, display: '30s' },\n // max: 1.5m\n { maxMs: ONE_MINUTE_IN_MS * 1.5, roundedStepMs: ONE_MINUTE_IN_MS, display: '1m' },\n // max: 3.5m\n { maxMs: ONE_MINUTE_IN_MS * 3.5, roundedStepMs: ONE_MINUTE_IN_MS * 2, display: '2m' },\n // max: 7.5m\n { maxMs: ONE_MINUTE_IN_MS * 7.5, roundedStepMs: ONE_MINUTE_IN_MS * 5, display: '5m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 10, display: '10m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 15, display: '15m' },\n // max: 25m\n { maxMs: ONE_MINUTE_IN_MS * 25, roundedStepMs: ONE_MINUTE_IN_MS * 20, display: '20m' },\n // max: 45m\n { maxMs: ONE_MINUTE_IN_MS * 45, roundedStepMs: ONE_MINUTE_IN_MS * 30, display: '30m' },\n // max: 1.5h\n { maxMs: ONE_HOUR_IN_MS * 1.5, roundedStepMs: ONE_HOUR_IN_MS, display: '1h' },\n // max: 2.5h\n { maxMs: ONE_HOUR_IN_MS * 2.5, roundedStepMs: ONE_HOUR_IN_MS * 2, display: '2h' },\n // max: 4.5h\n { maxMs: ONE_HOUR_IN_MS * 4.5, roundedStepMs: ONE_HOUR_IN_MS * 3, display: '3h' },\n // max: 9h\n { maxMs: ONE_HOUR_IN_MS * 9, roundedStepMs: ONE_HOUR_IN_MS * 6, display: '6h' },\n // max: 1d\n { maxMs: ONE_DAY_IN_MS, roundedStepMs: ONE_HOUR_IN_MS * 12, display: '12h' },\n // max: 1w\n { maxMs: ONE_WEEK_IN_MS, roundedStepMs: ONE_DAY_IN_MS, display: '1d' },\n // max: 3w\n { maxMs: ONE_WEEK_IN_MS * 3, roundedStepMs: ONE_WEEK_IN_MS, display: '1w' },\n // max: 6w\n { maxMs: ONE_WEEK_IN_MS * 6, roundedStepMs: ONE_DAY_IN_MS * 30, display: '30d' },\n // max: 2y\n { maxMs: ONE_YEAR_IN_MS * 2, roundedStepMs: ONE_YEAR_IN_MS, display: '1y' },\n];\n\n/**\n * Round interval to clearer increments\n */\nexport function roundStepInterval(stepMs: number) {\n for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS) {\n if (stepMs < maxMs) {\n return roundedStepMs;\n }\n }\n return DEFAULT_STEP_MS;\n}\n\n/**\n * Gets a suggested step/interval size for a time range based on the width of a visual component.\n */\nexport function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number) {\n const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n const stepMs = Math.floor(queryRangeMs / width);\n return roundStepInterval(stepMs);\n}\n"],"names":["sub","ONE_SECOND_IN_MS","ONE_MINUTE_IN_MS","ONE_HOUR_IN_MS","ONE_DAY_IN_MS","ONE_WEEK_IN_MS","ONE_YEAR_IN_MS","isRelativeTimeRange","timeRange","pastDuration","undefined","isAbsoluteTimeRange","start","end","toAbsoluteTimeRange","Date","parseDurationString","DURATION_REGEX","durationString","matches","exec","Error","years","parseInt","months","weeks","days","hours","minutes","seconds","isDurationString","maybeDuration","test","intervalToPrometheusDuration","durationInMs","valueOf","msToPrometheusDuration","Math","trunc","formatDuration","duration","result","push","ms","join","DEFAULT_STEP_MS","ROUNDED_STEP_INTERVALS","maxMs","roundedStepMs","display","roundStepInterval","stepMs","getSuggestedStepMs","width","queryRangeMs","floor"],"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,SAAmBA,GAAG,QAAQ,WAAW;AAEzC,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB,UAAU,gCAAgC;AAChE,MAAMC,iBAAiB,WAAW,gCAAgC;AAClE,MAAMC,iBAAiB,aAAa,kCAAkC;AAmBtE;;CAEC,GACD,OAAO,SAASC,oBAAoBC,SAAyB;IAC3D,OAAO,AAACA,UAAgCC,YAAY,KAAKC;AAC3D;AAEA;;CAEC,GACD,OAAO,SAASC,oBAAoBH,SAAyB;IAC3D,OAAO,AAACA,UAAgCI,KAAK,KAAKF,aAAa,AAACF,UAAgCK,GAAG,KAAKH;AAC1G;AAEA;;CAEC,GACD,OAAO,SAASI,oBAAoBN,SAA4B;QAClDA;IAAZ,MAAMK,MAAML,CAAAA,iBAAAA,UAAUK,GAAG,cAAbL,4B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rE,UAAU;IACV;QAAEF,OAAO1C,iBAAiB;QAAG2C,eAAe3C;QAAgB4C,SAAS;IAAK;IAC1E,UAAU;IACV;QAAEF,OAAO1C,iBAAiB;QAAG2C,eAAe5C,gBAAgB;QAAI6C,SAAS;IAAM;IAC/E,UAAU;IACV;QAAEF,OAAOzC,iBAAiB;QAAG0C,eAAe1C;QAAgB2C,SAAS;IAAK;CAC3E;AAED;;CAEC,GACD,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,KAAK,MAAM,EAAEJ,KAAK,EAAEC,aAAa,EAAE,IAAIF,uBAAwB;QAC7D,IAAIK,SAASJ,OAAO;YAClB,OAAOC;QACT;IACF;IACA,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASO,mBAAmB5C,SAA4B,EAAE6C,KAAa;IAC5E,MAAMC,eAAe9C,UAAUK,GAAG,CAACsB,OAAO,KAAK3B,UAAUI,KAAK,CAACuB,OAAO;IACtE,MAAMgB,SAASd,KAAKkB,KAAK,CAACD,eAAeD;IACzC,OAAOH,kBAAkBC;AAC3B"}
1
+ {"version":3,"sources":["../../src/model/time.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 { Duration, sub } from 'date-fns';\n\nconst ONE_SECOND_IN_MS = 1000;\nconst ONE_MINUTE_IN_MS = 60000;\nconst ONE_HOUR_IN_MS = 3600000;\nconst ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h\nconst ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d\nconst ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d\n\nexport type UnixTimeMs = number;\n\nexport type DateTimeFormat = number | string;\n\nexport interface AbsoluteTimeRange {\n start: Date;\n end: Date;\n}\n\nexport interface RelativeTimeRange {\n // End date or undefined if relative to the current Date\n end?: Date;\n pastDuration: DurationString;\n}\n\nexport type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;\n\n/**\n * Determine whether a given time range is relative\n */\nexport function isRelativeTimeRange(timeRange: TimeRangeValue): timeRange is RelativeTimeRange {\n return (timeRange as RelativeTimeRange).pastDuration !== undefined;\n}\n\n/**\n * Determine whether a given time range is absolute\n */\nexport function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRange is AbsoluteTimeRange {\n return (timeRange as AbsoluteTimeRange).start !== undefined && (timeRange as AbsoluteTimeRange).end !== undefined;\n}\n\n/**\n * Returns an absolute time range from a RelativeTimeRange.\n */\nexport function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange {\n const end = timeRange.end ?? new Date();\n\n return {\n start: sub(end, parseDurationString(timeRange.pastDuration)),\n end,\n };\n}\n\ntype MillisecondsDurationString = `${number}ms`;\ntype SecondsDurationString = `${number}s`;\ntype MinutesDurationString = `${number}m`;\ntype HoursDurationString = `${number}h`;\ntype DaysDurationString = `${number}d`;\ntype WeeksDurationString = `${number}w`;\ntype YearsDurationString = `${number}y`;\n\nexport type DurationString = Exclude<\n `${YearsDurationString | ''}${WeeksDurationString | ''}${DaysDurationString | ''}${HoursDurationString | ''}${\n | MinutesDurationString\n | ''}${SecondsDurationString | ''}${MillisecondsDurationString | ''}`,\n ''\n>;\n\nexport const DURATION_REGEX = /^(?:(\\d+)y)?(?:(\\d+)w)?(?:(\\d+)d)?(?:(\\d+)h)?(?:(\\d+)m)?(?:(\\d+)s)?(?:(\\d+)ms)?$/;\n\n/**\n * Parses a DurationString into a Duration object with numeric values that can\n * be used to do Date math. Throws if not a valid duration string.\n */\nexport function parseDurationString(durationString: string): Duration {\n const matches = DURATION_REGEX.exec(durationString);\n if (matches === null) {\n throw new Error(`Invalid duration string '${durationString}'`);\n }\n\n return {\n years: parseInt(matches[1] ?? '0'),\n months: 0,\n weeks: parseInt(matches[2] ?? '0'),\n days: parseInt(matches[3] ?? '0'),\n hours: parseInt(matches[4] ?? '0'),\n minutes: parseInt(matches[5] ?? '0'),\n seconds: parseInt(matches[6] ?? '0') + parseInt(matches[7] ?? '0') / 1000,\n };\n}\n\n/**\n * Returns true if the given string is a valid DurationString.\n */\nexport function isDurationString(maybeDuration: string): maybeDuration is DurationString {\n if (maybeDuration === '') return false;\n return DURATION_REGEX.test(maybeDuration);\n}\n\nexport function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration {\n const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n return msToPrometheusDuration(durationInMs);\n}\n\nexport function msToPrometheusDuration(durationInMs: number): Duration {\n const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);\n if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;\n const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);\n if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;\n const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);\n if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;\n const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);\n if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;\n const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);\n if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;\n\n return {\n years: years,\n months: 0,\n weeks: weeks,\n days: days,\n hours: hours,\n minutes: minutes,\n seconds: durationInMs / 1000,\n };\n}\n\nexport function formatDuration(duration: Duration): DurationString {\n const result: string[] = [];\n if (duration.years) {\n result.push(`${duration.years}y`);\n }\n if (duration.weeks) {\n result.push(`${duration.weeks}w`);\n }\n if (duration.days) {\n result.push(`${duration.days}d`);\n }\n if (duration.hours) {\n result.push(`${duration.hours}h`);\n }\n if (duration.minutes) {\n result.push(`${duration.minutes}m`);\n }\n if (duration.seconds) {\n const seconds = Math.trunc(duration.seconds);\n if (seconds) {\n result.push(`${seconds}s`);\n }\n const ms = (duration.seconds - seconds) * 1000;\n if (ms) {\n result.push(`${ms}ms`);\n }\n }\n return result.join('') as DurationString;\n}\n\nconst DEFAULT_STEP_MS = 15000;\n\nconst ROUNDED_STEP_INTERVALS = [\n // max: 0.015s\n { maxMs: 15, roundedStepMs: 10, display: '0.01s' },\n // max: 0.035s\n { maxMs: 35, roundedStepMs: 20, display: '0.02s' },\n // max: 0.075s\n { maxMs: 75, roundedStepMs: 50, display: '0.05s' },\n // max: 0.15s\n { maxMs: 150, roundedStepMs: 100, display: '0.1s' },\n // max: 0.35s\n { maxMs: 350, roundedStepMs: 200, display: '0.2s' },\n // max: 0.75s\n { maxMs: 750, roundedStepMs: 500, display: '0.5s' },\n // max: 1.5s\n { maxMs: ONE_SECOND_IN_MS * 1.5, roundedStepMs: ONE_SECOND_IN_MS, display: '1s' },\n // max: 3.5s\n { maxMs: ONE_SECOND_IN_MS * 3.5, roundedStepMs: ONE_SECOND_IN_MS * 2, display: '2s' },\n // max: 7.5s\n { maxMs: ONE_SECOND_IN_MS * 7.5, roundedStepMs: ONE_SECOND_IN_MS * 5, display: '5s' },\n // max: 12.5s\n { maxMs: ONE_SECOND_IN_MS * 12.5, roundedStepMs: ONE_SECOND_IN_MS * 10, display: '10s' },\n // max: 17.5s\n { maxMs: ONE_SECOND_IN_MS * 17.5, roundedStepMs: ONE_SECOND_IN_MS * 15, display: '15s' },\n // max: 25s\n { maxMs: ONE_SECOND_IN_MS * 25, roundedStepMs: ONE_SECOND_IN_MS * 20, display: '20s' },\n // max: 45s\n { maxMs: ONE_SECOND_IN_MS * 45, roundedStepMs: ONE_SECOND_IN_MS * 30, display: '30s' },\n // max: 1.5m\n { maxMs: ONE_MINUTE_IN_MS * 1.5, roundedStepMs: ONE_MINUTE_IN_MS, display: '1m' },\n // max: 3.5m\n { maxMs: ONE_MINUTE_IN_MS * 3.5, roundedStepMs: ONE_MINUTE_IN_MS * 2, display: '2m' },\n // max: 7.5m\n { maxMs: ONE_MINUTE_IN_MS * 7.5, roundedStepMs: ONE_MINUTE_IN_MS * 5, display: '5m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 10, display: '10m' },\n // max: 12.5m\n { maxMs: ONE_MINUTE_IN_MS * 12.5, roundedStepMs: ONE_MINUTE_IN_MS * 15, display: '15m' },\n // max: 25m\n { maxMs: ONE_MINUTE_IN_MS * 25, roundedStepMs: ONE_MINUTE_IN_MS * 20, display: '20m' },\n // max: 45m\n { maxMs: ONE_MINUTE_IN_MS * 45, roundedStepMs: ONE_MINUTE_IN_MS * 30, display: '30m' },\n // max: 1.5h\n { maxMs: ONE_HOUR_IN_MS * 1.5, roundedStepMs: ONE_HOUR_IN_MS, display: '1h' },\n // max: 2.5h\n { maxMs: ONE_HOUR_IN_MS * 2.5, roundedStepMs: ONE_HOUR_IN_MS * 2, display: '2h' },\n // max: 4.5h\n { maxMs: ONE_HOUR_IN_MS * 4.5, roundedStepMs: ONE_HOUR_IN_MS * 3, display: '3h' },\n // max: 9h\n { maxMs: ONE_HOUR_IN_MS * 9, roundedStepMs: ONE_HOUR_IN_MS * 6, display: '6h' },\n // max: 1d\n { maxMs: ONE_DAY_IN_MS, roundedStepMs: ONE_HOUR_IN_MS * 12, display: '12h' },\n // max: 1w\n { maxMs: ONE_WEEK_IN_MS, roundedStepMs: ONE_DAY_IN_MS, display: '1d' },\n // max: 3w\n { maxMs: ONE_WEEK_IN_MS * 3, roundedStepMs: ONE_WEEK_IN_MS, display: '1w' },\n // max: 6w\n { maxMs: ONE_WEEK_IN_MS * 6, roundedStepMs: ONE_DAY_IN_MS * 30, display: '30d' },\n // max: 2y\n { maxMs: ONE_YEAR_IN_MS * 2, roundedStepMs: ONE_YEAR_IN_MS, display: '1y' },\n];\n\n/**\n * Round interval to clearer increments\n */\nexport function roundStepInterval(stepMs: number) {\n for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS) {\n if (stepMs < maxMs) {\n return roundedStepMs;\n }\n }\n return DEFAULT_STEP_MS;\n}\n\n/**\n * Gets a suggested step/interval size for a time range based on the width of a visual component.\n */\nexport function getSuggestedStepMs(timeRange: AbsoluteTimeRange, width: number) {\n const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n const stepMs = Math.floor(queryRangeMs / width);\n return roundStepInterval(stepMs);\n}\n"],"names":["sub","ONE_SECOND_IN_MS","ONE_MINUTE_IN_MS","ONE_HOUR_IN_MS","ONE_DAY_IN_MS","ONE_WEEK_IN_MS","ONE_YEAR_IN_MS","isRelativeTimeRange","timeRange","pastDuration","undefined","isAbsoluteTimeRange","start","end","toAbsoluteTimeRange","Date","parseDurationString","DURATION_REGEX","durationString","matches","exec","Error","years","parseInt","months","weeks","days","hours","minutes","seconds","isDurationString","maybeDuration","test","intervalToPrometheusDuration","durationInMs","valueOf","msToPrometheusDuration","Math","trunc","formatDuration","duration","result","push","ms","join","DEFAULT_STEP_MS","ROUNDED_STEP_INTERVALS","maxMs","roundedStepMs","display","roundStepInterval","stepMs","getSuggestedStepMs","width","queryRangeMs","floor"],"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,SAAmBA,GAAG,QAAQ,WAAW;AAEzC,MAAMC,mBAAmB;AACzB,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AACvB,MAAMC,gBAAgB,UAAU,gCAAgC;AAChE,MAAMC,iBAAiB,WAAW,gCAAgC;AAClE,MAAMC,iBAAiB,aAAa,kCAAkC;AAmBtE;;CAEC,GACD,OAAO,SAASC,oBAAoBC,SAAyB;IAC3D,OAAO,AAACA,UAAgCC,YAAY,K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iBAAiB;QAAG8C,SAAS;IAAK;IAChF,UAAU;IACV;QAAEF,OAAO5C,iBAAiB;QAAG6C,eAAe7C,iBAAiB;QAAG8C,SAAS;IAAK;IAC9E,UAAU;IACV;QAAEF,OAAO3C;QAAe4C,eAAe7C,iBAAiB;QAAI8C,SAAS;IAAM;IAC3E,UAAU;IACV;QAAEF,OAAO1C;QAAgB2C,eAAe5C;QAAe6C,SAAS;IAAK;IACrE,UAAU;IACV;QAAEF,OAAO1C,iBAAiB;QAAG2C,eAAe3C;QAAgB4C,SAAS;IAAK;IAC1E,UAAU;IACV;QAAEF,OAAO1C,iBAAiB;QAAG2C,eAAe5C,gBAAgB;QAAI6C,SAAS;IAAM;IAC/E,UAAU;IACV;QAAEF,OAAOzC,iBAAiB;QAAG0C,eAAe1C;QAAgB2C,SAAS;IAAK;CAC3E;AAED;;CAEC,GACD,OAAO,SAASC,kBAAkBC,MAAc;IAC9C,KAAK,MAAM,EAAEJ,KAAK,EAAEC,aAAa,EAAE,IAAIF,uBAAwB;QAC7D,IAAIK,SAASJ,OAAO;YAClB,OAAOC;QACT;IACF;IACA,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASO,mBAAmB5C,SAA4B,EAAE6C,KAAa;IAC5E,MAAMC,eAAe9C,UAAUK,GAAG,CAACsB,OAAO,KAAK3B,UAAUI,KAAK,CAACuB,OAAO;IACtE,MAAMgB,SAASd,KAAKkB,KAAK,CAACD,eAAeD;IACzC,OAAOH,kBAAkBC;AAC3B"}
@@ -1,10 +1,10 @@
1
- import { DashboardResource, Variable, Datasource } from '../model';
1
+ import { DashboardResource, Variable, Datasource, EphemeralDashboardResource } from '../model';
2
2
  /**
3
3
  * If the dashboard has a display name, return the dashboard display name
4
4
  * Else, only return the dashboard name
5
5
  * @param dashboard
6
6
  */
7
- export declare function getDashboardDisplayName(dashboard: DashboardResource): string;
7
+ export declare function getDashboardDisplayName(dashboard: DashboardResource | EphemeralDashboardResource): string;
8
8
  /**
9
9
  * If the variable has a display name, return the variable display name
10
10
  * Else, only return the variable name
@@ -22,7 +22,7 @@ export declare function getDatasourceDisplayName(datasource: Datasource): string
22
22
  * Else, only return the dashboard name
23
23
  * @param dashboard
24
24
  */
25
- export declare function getDashboardExtendedDisplayName(dashboard: DashboardResource): string;
25
+ export declare function getDashboardExtendedDisplayName(dashboard: DashboardResource | EphemeralDashboardResource): string;
26
26
  /**
27
27
  * If the variable has a display name, return the variable display name and the variable name
28
28
  * Else, only return the variable name
@@ -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,MAAM,UAAU,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,UAEnE;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,UAK3E;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,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 +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 } 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: 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) {\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,SAA4B;QAC3DA;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,SAA4B;QACtEA;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 { 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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.44.0-rc1",
3
+ "version": "0.44.0-rc2",
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",