@perses-dev/core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +18 -19
- package/dist/cjs/model/dashboard.js +5 -3
- package/dist/cjs/model/datasource.js +5 -3
- package/dist/cjs/model/definitions.js +7 -3
- package/dist/cjs/model/index.js +25 -26
- package/dist/cjs/model/layout.js +5 -3
- package/dist/cjs/model/panels.js +5 -3
- package/dist/cjs/model/resource.js +5 -3
- package/dist/cjs/model/{http.js → time-series-queries.js} +5 -8
- package/dist/cjs/model/time.js +41 -50
- package/dist/cjs/model/variables.js +5 -5
- package/dist/cjs/utils/event.js +12 -14
- package/dist/cjs/utils/fetch.js +17 -17
- package/dist/cjs/utils/index.js +19 -20
- package/dist/cjs/utils/memo.js +31 -25
- package/dist/cjs/utils/panel-refs.js +13 -10
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -0
- package/dist/model/dashboard.d.ts +2 -6
- package/dist/model/dashboard.d.ts.map +1 -1
- package/dist/model/dashboard.js +15 -1
- package/dist/model/dashboard.js.map +1 -0
- package/dist/model/datasource.d.ts +28 -10
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +15 -1
- package/dist/model/datasource.js.map +1 -0
- package/dist/model/definitions.d.ts +2 -12
- package/dist/model/definitions.d.ts.map +1 -1
- package/dist/model/definitions.js +17 -1
- package/dist/model/definitions.js.map +1 -0
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +23 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/layout.js +15 -1
- package/dist/model/layout.js.map +1 -0
- package/dist/model/panels.d.ts +6 -5
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +15 -1
- package/dist/model/panels.js.map +1 -0
- package/dist/model/resource.d.ts +4 -8
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +15 -1
- package/dist/model/resource.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +8 -0
- package/dist/model/time-series-queries.d.ts.map +1 -0
- package/dist/model/time-series-queries.js +15 -0
- package/dist/model/time-series-queries.js.map +1 -0
- package/dist/model/time.js +88 -1
- package/dist/model/time.js.map +1 -0
- package/dist/model/variables.d.ts +17 -29
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +15 -1
- package/dist/model/variables.js.map +1 -0
- package/dist/utils/event.js +27 -1
- package/dist/utils/event.js.map +1 -0
- package/dist/utils/fetch.js +41 -1
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/index.js +18 -1
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/memo.js +51 -1
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/panel-refs.d.ts +1 -1
- package/dist/utils/panel-refs.js +28 -1
- package/dist/utils/panel-refs.js.map +1 -0
- package/package.json +6 -3
- package/dist/model/http.d.ts +0 -19
- package/dist/model/http.d.ts.map +0 -1
- package/dist/model/http.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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 * from './model';
|
|
14
|
+
export * from './utils';
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2022 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 './model';\nexport * from './utils';\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,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
+
import { DatasourceSpec } from './datasource';
|
|
1
2
|
import { LayoutDefinition } from './layout';
|
|
2
3
|
import { PanelDefinition } from './panels';
|
|
3
4
|
import { ProjectMetadata } from './resource';
|
|
4
5
|
import { DurationString } from './time';
|
|
5
6
|
import { VariableDefinition } from './variables';
|
|
6
|
-
export interface DatasourceSelector {
|
|
7
|
-
name: string;
|
|
8
|
-
kind: string;
|
|
9
|
-
global: boolean;
|
|
10
|
-
}
|
|
11
7
|
export interface DashboardResource {
|
|
12
8
|
kind: 'Dashboard';
|
|
13
9
|
metadata: ProjectMetadata;
|
|
14
10
|
spec: DashboardSpec;
|
|
15
11
|
}
|
|
16
12
|
export interface DashboardSpec {
|
|
17
|
-
|
|
13
|
+
datasources?: Record<string, DatasourceSpec>;
|
|
18
14
|
duration: DurationString;
|
|
19
15
|
variables: VariableDefinition[];
|
|
20
16
|
layouts: LayoutDefinition[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/model/dashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/model/dashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,aAAa,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC7C,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,EAAE,kBAAkB,EAAE,CAAC;IAChC,OAAO,EAAE,gBAAgB,EAAE,CAAC;IAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;CACzC"}
|
package/dist/model/dashboard.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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=dashboard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/dashboard.ts"],"sourcesContent":["// Copyright 2022 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 { DatasourceSpec } from './datasource';\nimport { LayoutDefinition } from './layout';\nimport { PanelDefinition } from './panels';\nimport { ProjectMetadata } from './resource';\nimport { DurationString } from './time';\nimport { VariableDefinition } from './variables';\n\nexport interface DashboardResource {\n kind: 'Dashboard';\n metadata: ProjectMetadata;\n spec: DashboardSpec;\n}\n\nexport interface DashboardSpec {\n datasources?: Record<string, DatasourceSpec>;\n duration: DurationString;\n variables: VariableDefinition[];\n layouts: LayoutDefinition[];\n panels: Record<string, PanelDefinition>;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAmBC"}
|
|
@@ -1,17 +1,35 @@
|
|
|
1
|
+
import { Definition } from './definitions';
|
|
1
2
|
import { Metadata, ProjectMetadata } from './resource';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A Datasource that's available across all projects.
|
|
5
|
+
*/
|
|
6
|
+
export interface GlobalDatasource {
|
|
7
|
+
kind: 'GlobalDatasource';
|
|
8
|
+
metadata: Metadata;
|
|
9
|
+
spec: DatasourceSpec;
|
|
5
10
|
}
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
/**
|
|
12
|
+
* A Datasource that belongs to a project.
|
|
13
|
+
*/
|
|
14
|
+
export interface Datasource {
|
|
8
15
|
kind: 'Datasource';
|
|
9
16
|
metadata: ProjectMetadata;
|
|
10
|
-
spec:
|
|
17
|
+
spec: DatasourceSpec;
|
|
11
18
|
}
|
|
12
|
-
export interface
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
export interface DatasourceSpec<PluginSpec = unknown> {
|
|
20
|
+
display?: {
|
|
21
|
+
name: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
};
|
|
24
|
+
default: boolean;
|
|
25
|
+
plugin: Definition<PluginSpec>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A selector for pointing at a specific Datasource. If name is omitted, it's assumed that you want the default
|
|
29
|
+
* Datasource for the specified kind.
|
|
30
|
+
*/
|
|
31
|
+
export interface DatasourceSelector {
|
|
32
|
+
kind: string;
|
|
33
|
+
name?: string;
|
|
16
34
|
}
|
|
17
35
|
//# 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,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/model/datasource.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvD;;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,UAAU;IACzB,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,cAAc,CAAC,UAAU,GAAG,OAAO;IAClD,OAAO,CAAC,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
|
package/dist/model/datasource.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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=datasource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/datasource.ts"],"sourcesContent":["// Copyright 2022 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 } from './definitions';\nimport { Metadata, ProjectMetadata } from './resource';\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 that belongs to a project.\n */\nexport interface Datasource {\n kind: 'Datasource';\n metadata: ProjectMetadata;\n spec: DatasourceSpec;\n}\n\nexport interface DatasourceSpec<PluginSpec = unknown> {\n display?: {\n name: string;\n description?: string;\n };\n default: boolean;\n plugin: Definition<PluginSpec>;\n}\n\n/**\n * A selector for pointing at a specific Datasource. If name is omitted, it's assumed that you want the default\n * Datasource for the specified kind.\n */\nexport interface DatasourceSelector {\n kind: string;\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;AAEjC,WAqCC"}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Json config object.
|
|
3
|
-
*/
|
|
4
|
-
export interface JsonObject {
|
|
5
|
-
[key: string]: Json | undefined;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Json definition values.
|
|
9
|
-
*/
|
|
10
|
-
export declare type Json = string | number | boolean | null | JsonObject | Json[];
|
|
11
1
|
/**
|
|
12
2
|
* Base type for definitions in JSON config resources.
|
|
13
3
|
*/
|
|
14
|
-
export interface Definition<
|
|
4
|
+
export interface Definition<Spec> {
|
|
15
5
|
kind: string;
|
|
16
|
-
|
|
6
|
+
spec: Spec;
|
|
17
7
|
}
|
|
18
8
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/model/definitions.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,UAAU
|
|
1
|
+
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../src/model/definitions.ts"],"names":[],"mappings":"AAaA;;GAEG;AACH,MAAM,WAAW,UAAU,CAAC,IAAI;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,IAAI,CAAC;CACZ"}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
/**
|
|
14
|
+
* Base type for definitions in JSON config resources.
|
|
15
|
+
*/ export { };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/definitions.ts"],"sourcesContent":["// Copyright 2022 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * Base type for definitions in JSON config resources.\n */\nexport interface Definition<Spec> {\n kind: string;\n spec: Spec;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;;CAEC,GACD,WAGC"}
|
package/dist/model/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './dashboard';
|
|
2
2
|
export * from './datasource';
|
|
3
3
|
export * from './definitions';
|
|
4
|
-
export * from './http';
|
|
5
4
|
export * from './layout';
|
|
6
5
|
export * from './panels';
|
|
7
6
|
export * from './resource';
|
|
8
7
|
export * from './time';
|
|
8
|
+
export * from './time-series-queries';
|
|
9
9
|
export * from './variables';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AAaA,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
package/dist/model/index.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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 * from './dashboard';
|
|
14
|
+
export * from './datasource';
|
|
15
|
+
export * from './definitions';
|
|
16
|
+
export * from './layout';
|
|
17
|
+
export * from './panels';
|
|
18
|
+
export * from './resource';
|
|
19
|
+
export * from './time';
|
|
20
|
+
export * from './time-series-queries';
|
|
21
|
+
export * from './variables';
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/index.ts"],"sourcesContent":["// Copyright 2022 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 './dashboard';\nexport * from './datasource';\nexport * from './definitions';\nexport * from './layout';\nexport * from './panels';\nexport * from './resource';\nexport * from './time';\nexport * from './time-series-queries';\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,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC"}
|
package/dist/model/layout.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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=layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/layout.ts"],"sourcesContent":["// Copyright 2022 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 { PanelRef } from './panels';\n\nexport type LayoutDefinition = GridDefinition;\n\nexport interface GridDefinition {\n kind: 'Grid';\n spec: {\n display?: {\n title: string;\n collapse?: {\n open: boolean;\n };\n };\n items: GridItemDefinition[];\n };\n}\n\nexport interface GridItemDefinition {\n x: number;\n y: number;\n width: number;\n height: number;\n content: PanelRef;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAuBC"}
|
package/dist/model/panels.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Definition
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export interface
|
|
1
|
+
import { Definition } from './definitions';
|
|
2
|
+
export interface PanelDefinition<PluginSpec = unknown> extends Definition<PanelSpec<PluginSpec>> {
|
|
3
|
+
kind: 'Panel';
|
|
4
|
+
}
|
|
5
|
+
export interface PanelSpec<PluginSpec> {
|
|
6
6
|
display: {
|
|
7
7
|
name: string;
|
|
8
8
|
description?: string;
|
|
9
9
|
};
|
|
10
|
+
plugin: Definition<PluginSpec>;
|
|
10
11
|
}
|
|
11
12
|
/**
|
|
12
13
|
* 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,
|
|
1
|
+
{"version":3,"file":"panels.d.ts","sourceRoot":"","sources":["../../src/model/panels.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,eAAe,CAAC,UAAU,GAAG,OAAO,CAAE,SAAQ,UAAU,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC9F,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,SAAS,CAAC,UAAU;IACnC,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,iBAAiB,MAAM,EAAE,CAAC;CACjC"}
|
package/dist/model/panels.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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=panels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/panels.ts"],"sourcesContent":["// Copyright 2022 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 } from './definitions';\n\nexport interface PanelDefinition<PluginSpec = unknown> extends Definition<PanelSpec<PluginSpec>> {\n kind: 'Panel';\n}\n\nexport interface PanelSpec<PluginSpec> {\n display: {\n name: string;\n description?: string;\n };\n plugin: Definition<PluginSpec>;\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;AAEjC,WAmBC"}
|
package/dist/model/resource.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
export declare type ResourceMetadata = Record<string, string> & {
|
|
3
|
-
name: string;
|
|
4
|
-
};
|
|
5
|
-
export declare type Metadata = {
|
|
1
|
+
export interface Metadata {
|
|
6
2
|
name: string;
|
|
7
3
|
created_at: string;
|
|
8
4
|
updated_at: string;
|
|
9
5
|
version: number;
|
|
10
|
-
}
|
|
11
|
-
export
|
|
6
|
+
}
|
|
7
|
+
export interface ProjectMetadata extends Metadata {
|
|
12
8
|
project: string;
|
|
13
|
-
}
|
|
9
|
+
}
|
|
14
10
|
//# sourceMappingURL=resource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../../src/model/resource.ts"],"names":[],"mappings":"AAaA,
|
|
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,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/model/resource.js
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 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=resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/resource.ts"],"sourcesContent":["// Copyright 2022 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 created_at: string;\n updated_at: string;\n version: number;\n}\n\nexport interface ProjectMetadata extends Metadata {\n project: 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;AAEjC,WASC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Definition } from './definitions';
|
|
2
|
+
export interface TimeSeriesQueryDefinition<PluginSpec = unknown> extends Definition<TimeSeriesQuerySpec<PluginSpec>> {
|
|
3
|
+
kind: 'TimeSeriesQuery';
|
|
4
|
+
}
|
|
5
|
+
export interface TimeSeriesQuerySpec<PluginSpec> {
|
|
6
|
+
plugin: Definition<PluginSpec>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=time-series-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,yBAAyB,CAAC,UAAU,GAAG,OAAO,CAAE,SAAQ,UAAU,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAClH,IAAI,EAAE,iBAAiB,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB,CAAC,UAAU;IAC7C,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2022 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=time-series-queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-queries.ts"],"sourcesContent":["// Copyright 2022 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 } from './definitions';\n\nexport interface TimeSeriesQueryDefinition<PluginSpec = unknown> extends Definition<TimeSeriesQuerySpec<PluginSpec>> {\n kind: 'TimeSeriesQuery';\n}\n\nexport interface TimeSeriesQuerySpec<PluginSpec> {\n plugin: Definition<PluginSpec>;\n}\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,WAQC"}
|
package/dist/model/time.js
CHANGED
|
@@ -1 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
import { sub } from 'date-fns';
|
|
14
|
+
/**
|
|
15
|
+
* Determine whether a given time range is relative
|
|
16
|
+
*/ export function isRelativeTimeRange(timeRange) {
|
|
17
|
+
return timeRange.pastDuration !== undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Determine whether a given time range is absolute
|
|
21
|
+
*/ export function isAbsoluteTimeRange(timeRange) {
|
|
22
|
+
return timeRange.start !== undefined && timeRange.end !== undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns an absolute time range from a RelativeTimeRange.
|
|
26
|
+
*/ export function toAbsoluteTimeRange(timeRange) {
|
|
27
|
+
var _end;
|
|
28
|
+
const end = (_end = timeRange.end) !== null && _end !== void 0 ? _end : new Date();
|
|
29
|
+
return {
|
|
30
|
+
start: sub(end, parseDurationString(timeRange.pastDuration)),
|
|
31
|
+
end
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
|
|
35
|
+
/**
|
|
36
|
+
* Parses a DurationString into a Duration object with numeric values that can
|
|
37
|
+
* be used to do Date math. Throws if not a valid duration string.
|
|
38
|
+
*/ export function parseDurationString(durationString) {
|
|
39
|
+
const matches = DURATION_REGEX.exec(durationString);
|
|
40
|
+
if (matches === null) {
|
|
41
|
+
throw new Error(`Invalid duration string '${durationString}'`);
|
|
42
|
+
}
|
|
43
|
+
var ref, ref1, ref2, ref3, ref4, ref5, ref6;
|
|
44
|
+
return {
|
|
45
|
+
years: parseInt((ref = matches[1]) !== null && ref !== void 0 ? ref : '0'),
|
|
46
|
+
months: 0,
|
|
47
|
+
weeks: parseInt((ref1 = matches[2]) !== null && ref1 !== void 0 ? ref1 : '0'),
|
|
48
|
+
days: parseInt((ref2 = matches[3]) !== null && ref2 !== void 0 ? ref2 : '0'),
|
|
49
|
+
hours: parseInt((ref3 = matches[4]) !== null && ref3 !== void 0 ? ref3 : '0'),
|
|
50
|
+
minutes: parseInt((ref4 = matches[5]) !== null && ref4 !== void 0 ? ref4 : '0'),
|
|
51
|
+
seconds: parseInt((ref5 = matches[6]) !== null && ref5 !== void 0 ? ref5 : '0') + parseInt((ref6 = matches[7]) !== null && ref6 !== void 0 ? ref6 : '0') / 1000
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns true if the given string is a valid DurationString.
|
|
56
|
+
*/ export function isDurationString(maybeDuration) {
|
|
57
|
+
if (maybeDuration === '') return false;
|
|
58
|
+
return DURATION_REGEX.test(maybeDuration);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Gets a suggested step/interval size for a time range based on the width of a visual component.
|
|
62
|
+
*/ export function getSuggestedStepMs(timeRange, width) {
|
|
63
|
+
// TODO: Should we try to suggest more "rounded" step values based around
|
|
64
|
+
// time increments that make sense (e.g. 15s, 30s, 1m, 5m, etc.)
|
|
65
|
+
const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();
|
|
66
|
+
return Math.floor(queryRangeMs / width);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Gets the default time range taking into account URL params
|
|
70
|
+
*/ export function getDefaultTimeRange(dashboardDuration, queryString) {
|
|
71
|
+
const startParam = queryString.get('start');
|
|
72
|
+
const endParam = queryString.get('end');
|
|
73
|
+
if (startParam === null) {
|
|
74
|
+
// use relative time range from dashboard definition if start param is empty
|
|
75
|
+
return {
|
|
76
|
+
pastDuration: dashboardDuration
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// convert query param format to RelativeTimeRange or AbsoluteTimeRange
|
|
80
|
+
return isDurationString(startParam) ? {
|
|
81
|
+
pastDuration: startParam
|
|
82
|
+
} : {
|
|
83
|
+
start: new Date(Number(startParam)),
|
|
84
|
+
end: new Date(Number(endParam))
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/time.ts"],"sourcesContent":["// Copyright 2022 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\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\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 // TODO: Should we try to suggest more \"rounded\" step values based around\n // time increments that make sense (e.g. 15s, 30s, 1m, 5m, etc.)\n const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();\n return Math.floor(queryRangeMs / width);\n}\n\n/**\n * Gets the default time range taking into account URL params\n */\nexport function getDefaultTimeRange(dashboardDuration: DurationString, queryString: URLSearchParams): TimeRangeValue {\n const startParam = queryString.get('start');\n const endParam = queryString.get('end');\n\n if (startParam === null) {\n // use relative time range from dashboard definition if start param is empty\n return { pastDuration: dashboardDuration };\n }\n\n // convert query param format to RelativeTimeRange or AbsoluteTimeRange\n return isDurationString(startParam)\n ? { pastDuration: startParam }\n : { start: new Date(Number(startParam)), end: new Date(Number(endParam)) };\n}\n"],"names":["sub","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","getSuggestedStepMs","width","queryRangeMs","valueOf","Math","floor","getDefaultTimeRange","dashboardDuration","queryString","startParam","get","endParam","Number"],"mappings":"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"}
|
|
@@ -1,41 +1,29 @@
|
|
|
1
|
-
import { Definition
|
|
2
|
-
export declare const DEFAULT_ALL_VALUE: "$__all";
|
|
1
|
+
import { Definition } from './definitions';
|
|
3
2
|
export declare type VariableName = string;
|
|
4
|
-
export declare type VariableState = {
|
|
5
|
-
value: VariableValue;
|
|
6
|
-
options?: VariableOption[];
|
|
7
|
-
loading: boolean;
|
|
8
|
-
error?: Error;
|
|
9
|
-
};
|
|
10
|
-
export declare type VariableOption = {
|
|
11
|
-
label: string;
|
|
12
|
-
value: string;
|
|
13
|
-
};
|
|
14
|
-
export declare type VariableStateMap = Record<VariableName, VariableState>;
|
|
15
3
|
export declare type VariableValue = string | string[] | null;
|
|
16
|
-
|
|
17
|
-
kind: Kind;
|
|
4
|
+
interface VariableSpec {
|
|
18
5
|
name: VariableName;
|
|
19
6
|
display?: {
|
|
20
7
|
label?: string;
|
|
21
8
|
hidden?: boolean;
|
|
22
9
|
};
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
default_value?: VariableValue;
|
|
11
|
+
}
|
|
12
|
+
export interface TextVariableDefinition extends Definition<TextVariableSpec> {
|
|
13
|
+
kind: 'TextVariable';
|
|
25
14
|
}
|
|
26
|
-
export interface
|
|
15
|
+
export interface TextVariableSpec extends VariableSpec {
|
|
27
16
|
value: string;
|
|
28
17
|
}
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
};
|
|
39
|
-
export declare type ListVariableDefinition<Options extends JsonObject = JsonObject> = Variable<'ListVariable', ListVariableOptions<Options>>;
|
|
18
|
+
export interface ListVariableDefinition<PluginSpec = unknown> extends Definition<ListVariableSpec<PluginSpec>> {
|
|
19
|
+
kind: 'ListVariable';
|
|
20
|
+
}
|
|
21
|
+
export interface ListVariableSpec<PluginSpec> extends VariableSpec {
|
|
22
|
+
allow_multiple?: boolean;
|
|
23
|
+
allow_all_value?: boolean;
|
|
24
|
+
custom_all_value?: string;
|
|
25
|
+
plugin: Definition<PluginSpec>;
|
|
26
|
+
}
|
|
40
27
|
export declare type VariableDefinition = TextVariableDefinition | ListVariableDefinition;
|
|
28
|
+
export {};
|
|
41
29
|
//# sourceMappingURL=variables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../src/model/variables.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,oBAAY,YAAY,GAAG,MAAM,CAAC;AAElC,oBAAY,aAAa,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;AAErD,UAAU,YAAY;IACpB,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAuB,SAAQ,UAAU,CAAC,gBAAgB,CAAC;IAC1E,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,gBAAiB,SAAQ,YAAY;IACpD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,sBAAsB,CAAC,UAAU,GAAG,OAAO,CAAE,SAAQ,UAAU,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5G,IAAI,EAAE,cAAc,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB,CAAC,UAAU,CAAE,SAAQ,YAAY;IAChE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC;CAChC;AAED,oBAAY,kBAAkB,GAAG,sBAAsB,GAAG,sBAAsB,CAAC"}
|