@perses-dev/core 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59
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/constants/dashboard-defaults.js +6 -2
- package/dist/cjs/constants/dialog.js +3 -1
- package/dist/cjs/constants/index.js +11 -9
- package/dist/cjs/index.js +12 -10
- package/dist/cjs/model/calculations.js +61 -51
- package/dist/cjs/model/ephemeraldashboard.js +16 -0
- package/dist/cjs/model/http-proxy.js +16 -0
- package/dist/cjs/model/index.js +35 -26
- package/dist/cjs/model/kind.js +39 -0
- package/dist/cjs/model/legend.js +39 -19
- package/dist/cjs/model/resource.js +9 -0
- package/dist/cjs/model/rolebindings.js +16 -0
- package/dist/cjs/model/roles.js +60 -0
- package/dist/cjs/model/secrets.js +16 -0
- package/dist/cjs/model/time-series-queries.js +3 -1
- package/dist/cjs/model/time.js +151 -65
- package/dist/cjs/model/trace-data.js +16 -0
- package/dist/cjs/model/units/bytes.js +37 -25
- package/dist/cjs/model/units/constants.js +3 -1
- package/dist/cjs/model/units/decimal.js +22 -16
- package/dist/cjs/model/units/index.js +13 -11
- package/dist/cjs/model/units/percent.js +26 -19
- package/dist/cjs/model/units/throughput.js +113 -0
- package/dist/cjs/model/units/time.js +99 -38
- package/dist/cjs/model/units/types.js +5 -2
- package/dist/cjs/model/units/units.js +81 -45
- package/dist/cjs/model/units/utils.js +13 -7
- package/dist/cjs/model/variables.js +16 -3
- package/dist/cjs/utils/event.js +3 -1
- package/dist/cjs/utils/fetch.js +32 -7
- package/dist/cjs/utils/index.js +17 -14
- package/dist/cjs/utils/is-empty-object.js +3 -1
- package/dist/cjs/utils/mathjs.js +4 -2
- package/dist/cjs/utils/memo.js +10 -6
- package/dist/cjs/utils/panel-refs.js +9 -3
- package/dist/cjs/utils/text.js +33 -21
- package/dist/cjs/utils/time-series-data.js +21 -11
- package/dist/cjs/utils/types.js +16 -0
- package/dist/constants/dashboard-defaults.js.map +1 -1
- package/dist/constants/dialog.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.d.ts +12 -12
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +46 -46
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/dashboard.js.map +1 -1
- package/dist/model/datasource.d.ts +17 -3
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +3 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/definitions.d.ts +1 -1
- package/dist/model/definitions.d.ts.map +1 -1
- package/dist/model/definitions.js +3 -0
- package/dist/model/definitions.js.map +1 -1
- package/dist/model/display.d.ts +1 -1
- package/dist/model/display.d.ts.map +1 -1
- package/dist/model/display.js.map +1 -1
- package/dist/model/ephemeraldashboard.d.ts +15 -0
- package/dist/model/ephemeraldashboard.d.ts.map +1 -0
- package/dist/model/ephemeraldashboard.js +15 -0
- package/dist/model/ephemeraldashboard.js.map +1 -0
- package/dist/model/http-proxy.d.ts +16 -0
- package/dist/model/http-proxy.d.ts.map +1 -0
- package/dist/model/http-proxy.js +15 -0
- package/dist/model/http-proxy.js.map +1 -0
- package/dist/model/http.d.ts +1 -1
- package/dist/model/http.d.ts.map +1 -1
- package/dist/model/index.d.ts +7 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +7 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +3 -0
- package/dist/model/kind.d.ts.map +1 -0
- package/dist/model/kind.js +31 -0
- package/dist/model/kind.js.map +1 -0
- package/dist/model/layout.d.ts +1 -1
- package/dist/model/layout.d.ts.map +1 -1
- package/dist/model/layout.js.map +1 -1
- package/dist/model/legend.d.ts +9 -9
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +9 -9
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.d.ts +5 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +3 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/project.js.map +1 -1
- package/dist/model/query.d.ts +15 -2
- package/dist/model/query.d.ts.map +1 -1
- package/dist/model/query.js +4 -1
- package/dist/model/query.js.map +1 -1
- package/dist/model/resource.d.ts +3 -2
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +3 -1
- package/dist/model/resource.js.map +1 -1
- package/dist/model/rolebindings.d.ts +27 -0
- package/dist/model/rolebindings.d.ts.map +1 -0
- package/dist/model/rolebindings.js +15 -0
- package/dist/model/rolebindings.js.map +1 -0
- package/dist/model/roles.d.ts +32 -0
- package/dist/model/roles.d.ts.map +1 -0
- package/dist/model/roles.js +41 -0
- package/dist/model/roles.js.map +1 -0
- package/dist/model/secrets.d.ts +44 -0
- package/dist/model/secrets.d.ts.map +1 -0
- package/dist/model/secrets.js +15 -0
- package/dist/model/secrets.js.map +1 -0
- package/dist/model/thresholds.d.ts +2 -2
- package/dist/model/thresholds.d.ts.map +1 -1
- package/dist/model/thresholds.js.map +1 -1
- package/dist/model/time-series-data.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +3 -3
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/time.d.ts +15 -11
- package/dist/model/time.d.ts.map +1 -1
- package/dist/model/time.js +117 -57
- package/dist/model/time.js.map +1 -1
- package/dist/model/trace-data.d.ts +20 -0
- package/dist/model/trace-data.d.ts.map +1 -0
- package/dist/model/trace-data.js +18 -0
- package/dist/model/trace-data.js.map +1 -0
- package/dist/model/units/bytes.d.ts +8 -8
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +27 -21
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/constants.js.map +1 -1
- package/dist/model/units/decimal.d.ts +8 -8
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +14 -14
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/index.js.map +1 -1
- package/dist/model/units/percent.d.ts +7 -7
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +17 -16
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/throughput.d.ts +13 -0
- package/dist/model/units/throughput.d.ts.map +1 -0
- package/dist/model/units/throughput.js +94 -0
- package/dist/model/units/throughput.js.map +1 -0
- package/dist/model/units/time.d.ts +15 -15
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +87 -34
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +18 -9
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js +2 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +50 -31
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +52 -37
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts +2 -2
- package/dist/model/units/utils.d.ts.map +1 -1
- package/dist/model/units/utils.js +4 -4
- package/dist/model/units/utils.js.map +1 -1
- package/dist/model/variables.d.ts +28 -9
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +3 -0
- package/dist/model/variables.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/utils/event.js.map +1 -1
- package/dist/utils/fetch.d.ts +3 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +21 -4
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-empty-object.js.map +1 -1
- package/dist/utils/mathjs.js +1 -1
- package/dist/utils/mathjs.js.map +1 -1
- package/dist/utils/memo.js +2 -2
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/panel-refs.js.map +1 -1
- package/dist/utils/text.d.ts +7 -7
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +17 -17
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time-series-data.d.ts +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +7 -7
- package/dist/utils/time-series-data.js.map +1 -1
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +15 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/rolebindings.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';\n\nexport interface Subject {\n kind: 'User';\n name: string;\n}\n\nexport interface RoleBindingSpec {\n // name of the role or global role (metadata.name)\n role: string;\n subjects: Subject[];\n}\n\n/**\n * A role binding that belongs to a project.\n */\nexport interface RoleBindingResource {\n kind: 'RoleBinding';\n metadata: ProjectMetadata;\n spec: RoleBindingSpec;\n}\n\n/**\n * A global role binding that doesn´t belong to a project.\n */\nexport interface GlobalRoleBindingResource {\n kind: 'GlobalRoleBinding';\n metadata: Metadata;\n spec: RoleBindingSpec;\n}\n\nexport type RoleBinding = RoleBindingResource | GlobalRoleBindingResource;\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;AAiCjC,WAA0E"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Metadata, ProjectMetadata } from './resource';
|
|
2
|
+
import { Kind } from './kind';
|
|
3
|
+
export type Action = 'create' | 'read' | 'update' | 'delete' | '*';
|
|
4
|
+
export declare const ACTIONS: string[];
|
|
5
|
+
export type Scope = Kind | '*';
|
|
6
|
+
export declare const PROJECT_SCOPES: string[];
|
|
7
|
+
export declare const GLOBAL_SCOPES: string[];
|
|
8
|
+
export interface Permission {
|
|
9
|
+
actions: Action[];
|
|
10
|
+
scopes: Scope[];
|
|
11
|
+
}
|
|
12
|
+
export interface RoleSpec {
|
|
13
|
+
permissions: Permission[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A role that belongs to a project.
|
|
17
|
+
*/
|
|
18
|
+
export interface RoleResource {
|
|
19
|
+
kind: 'Role';
|
|
20
|
+
metadata: ProjectMetadata;
|
|
21
|
+
spec: RoleSpec;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A global role that doesn´t belong to a project.
|
|
25
|
+
*/
|
|
26
|
+
export interface GlobalRoleResource {
|
|
27
|
+
kind: 'GlobalRole';
|
|
28
|
+
metadata: Metadata;
|
|
29
|
+
spec: RoleSpec;
|
|
30
|
+
}
|
|
31
|
+
export type Role = RoleResource | GlobalRoleResource;
|
|
32
|
+
//# sourceMappingURL=roles.d.ts.map
|
|
@@ -0,0 +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,UAW1B,CAAC;AAEF,eAAO,MAAM,aAAa,UAOzB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC;CAChB;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"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export const ACTIONS = [
|
|
14
|
+
'*',
|
|
15
|
+
'create',
|
|
16
|
+
'read',
|
|
17
|
+
'update',
|
|
18
|
+
'delete'
|
|
19
|
+
];
|
|
20
|
+
export const PROJECT_SCOPES = [
|
|
21
|
+
'*',
|
|
22
|
+
'Dashboard',
|
|
23
|
+
'Datasource',
|
|
24
|
+
'EphemeralDashboard',
|
|
25
|
+
'Folder',
|
|
26
|
+
'Project',
|
|
27
|
+
'Role',
|
|
28
|
+
'RoleBinding',
|
|
29
|
+
'Secret',
|
|
30
|
+
'Variable'
|
|
31
|
+
];
|
|
32
|
+
export const GLOBAL_SCOPES = [
|
|
33
|
+
'GlobalDatasource',
|
|
34
|
+
'GlobalRole',
|
|
35
|
+
'GlobalRoleBinding',
|
|
36
|
+
'GlobalSecret',
|
|
37
|
+
'GlobalVariable',
|
|
38
|
+
'User'
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +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 '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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Metadata, ProjectMetadata } from './resource';
|
|
2
|
+
export interface BasicAuth {
|
|
3
|
+
username: string;
|
|
4
|
+
password?: string;
|
|
5
|
+
passwordFile?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Authorization {
|
|
8
|
+
type?: string;
|
|
9
|
+
credentials?: string;
|
|
10
|
+
credentialsFile?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TLSConfig {
|
|
13
|
+
ca?: string;
|
|
14
|
+
cert?: string;
|
|
15
|
+
key?: string;
|
|
16
|
+
caFile?: string;
|
|
17
|
+
certFile?: string;
|
|
18
|
+
keyFile?: string;
|
|
19
|
+
serverName?: string;
|
|
20
|
+
insecureSkipVerify: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface SecretSpec {
|
|
23
|
+
basicAuth?: BasicAuth;
|
|
24
|
+
authorization?: Authorization;
|
|
25
|
+
tlsConfig?: TLSConfig;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A secret that belongs to a project.
|
|
29
|
+
*/
|
|
30
|
+
export interface SecretResource {
|
|
31
|
+
kind: 'Secret';
|
|
32
|
+
metadata: ProjectMetadata;
|
|
33
|
+
spec: SecretSpec;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A global secret that doesn´t belong to a project.
|
|
37
|
+
*/
|
|
38
|
+
export interface GlobalSecretResource {
|
|
39
|
+
kind: 'GlobalSecret';
|
|
40
|
+
metadata: Metadata;
|
|
41
|
+
spec: SecretSpec;
|
|
42
|
+
}
|
|
43
|
+
export type Secret = SecretResource | GlobalSecretResource;
|
|
44
|
+
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../src/model/secrets.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,SAAS;IACxB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,EAAE,eAAe,CAAC;IAC1B,IAAI,EAAE,UAAU,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,UAAU,CAAC;CAClB;AAED,MAAM,MAAM,MAAM,GAAG,cAAc,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2023 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
export { };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/model/secrets.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';\n\nexport interface BasicAuth {\n username: string;\n password?: string;\n passwordFile?: string;\n}\n\nexport interface Authorization {\n type?: string;\n credentials?: string;\n credentialsFile?: string;\n}\n\nexport interface TLSConfig {\n ca?: string;\n cert?: string;\n key?: string;\n caFile?: string;\n certFile?: string;\n keyFile?: string;\n serverName?: string;\n insecureSkipVerify: boolean;\n}\n\nexport interface SecretSpec {\n basicAuth?: BasicAuth;\n authorization?: Authorization;\n tlsConfig?: TLSConfig;\n}\n\n/**\n * A secret that belongs to a project.\n */\nexport interface SecretResource {\n kind: 'Secret';\n metadata: ProjectMetadata;\n spec: SecretSpec;\n}\n\n/**\n * A global secret that doesn´t belong to a project.\n */\nexport interface GlobalSecretResource {\n kind: 'GlobalSecret';\n metadata: Metadata;\n spec: SecretSpec;\n}\n\nexport type Secret = SecretResource | GlobalSecretResource;\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;AAmDjC,WAA2D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/model/thresholds.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,
|
|
1
|
+
{"version":3,"file":"thresholds.d.ts","sourceRoot":"","sources":["../../src/model/thresholds.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/thresholds.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface StepOptions {\n value: number;\n color?: string;\n name?: string;\n}\n\nexport interface ThresholdOptions {\n mode?: '
|
|
1
|
+
{"version":3,"sources":["../../src/model/thresholds.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport interface StepOptions {\n value: number;\n color?: string;\n name?: string;\n}\n\nexport interface ThresholdOptions {\n mode?: 'percent' | 'absolute';\n defaultColor?: string;\n max?: number; // is this same as the max in GaugeChartOptions? can we remove?\n steps?: StepOptions[];\n}\n\nexport interface ThresholdColorPalette {\n defaultColor: string;\n palette: 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,WAGC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Notice } from './notice';\nimport { AbsoluteTimeRange } from './time';\nimport { Labels, TimeSeriesValueTuple } from './time-series-queries';\n\nexport interface TimeScale {\n startMs: number;\n endMs: number;\n stepMs: number;\n rangeMs: number;\n}\n\nexport interface TimeSeriesData {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n metadata?: TimeSeriesMetadata;\n}\n\nexport interface TimeSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n formattedName?: string;\n labels?: Labels;\n}\n\nexport interface TimeSeriesMetadata {\n notices?: Notice[];\n\n /**\n * The raw query that is executed to generate this data.\n * Useful when needing to inspect the query that was executed\n * after variables and other context modifications have been applied.\n */\n executedQueryString?: 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;
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-data.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Notice } from './notice';\nimport { AbsoluteTimeRange } from './time';\nimport { Labels, TimeSeriesValueTuple } from './time-series-queries';\n\nexport interface TimeScale {\n startMs: number;\n endMs: number;\n stepMs: number;\n rangeMs: number;\n}\n\nexport interface TimeSeriesData {\n timeRange?: AbsoluteTimeRange;\n stepMs?: number;\n series: TimeSeries[];\n metadata?: TimeSeriesMetadata;\n}\n\nexport interface TimeSeries {\n name: string;\n values: TimeSeriesValueTuple[];\n formattedName?: string;\n labels?: Labels;\n}\n\nexport interface TimeSeriesMetadata {\n notices?: Notice[];\n\n /**\n * The raw query that is executed to generate this data.\n * Useful when needing to inspect the query that was executed\n * after variables and other context modifications have been applied.\n */\n executedQueryString?: 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;AA2BjC,WASC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnknownSpec } from './definitions';
|
|
2
2
|
import { QueryDefinition } from './query';
|
|
3
3
|
import { UnixTimeMs } from './time';
|
|
4
|
-
export
|
|
5
|
-
export
|
|
4
|
+
export type TimeSeriesQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TimeSeriesQuery', PluginSpec>;
|
|
5
|
+
export type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];
|
|
6
6
|
export declare function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple;
|
|
7
|
-
export
|
|
7
|
+
export type Labels = Record<string, string>;
|
|
8
8
|
//# sourceMappingURL=time-series-queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,
|
|
1
|
+
{"version":3,"file":"time-series-queries.d.ts","sourceRoot":"","sources":["../../src/model/time-series-queries.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,MAAM,yBAAyB,CAAC,UAAU,GAAG,WAAW,IAAI,eAAe,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAEjH,MAAM,MAAM,oBAAoB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AAEjF,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,IAAI,oBAAoB,CAG/F;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/model/time-series-queries.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 { UnknownSpec } from './definitions';\nimport { QueryDefinition } from './query';\nimport { UnixTimeMs } from './time';\n\nexport type TimeSeriesQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TimeSeriesQuery', PluginSpec>;\n\nexport type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];\n\nexport function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple {\n if (data.length !== 2) return false;\n return true;\n}\n\nexport type Labels = Record<string, string>;\n"],"names":["isTimeSeriesValueTuple","data","length"],"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;AAUjC,OAAO,SAASA,
|
|
1
|
+
{"version":3,"sources":["../../src/model/time-series-queries.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 { UnknownSpec } from './definitions';\nimport { QueryDefinition } from './query';\nimport { UnixTimeMs } from './time';\n\nexport type TimeSeriesQueryDefinition<PluginSpec = UnknownSpec> = QueryDefinition<'TimeSeriesQuery', PluginSpec>;\n\nexport type TimeSeriesValueTuple = [timestamp: UnixTimeMs, value: number | null];\n\nexport function isTimeSeriesValueTuple(data: TimeSeriesValueTuple): data is TimeSeriesValueTuple {\n if (data.length !== 2) return false;\n return true;\n}\n\nexport type Labels = Record<string, string>;\n"],"names":["isTimeSeriesValueTuple","data","length"],"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;AAUjC,OAAO,SAASA,uBAAuBC,IAA0B;IAC/D,IAAIA,KAAKC,MAAM,KAAK,GAAG,OAAO;IAC9B,OAAO;AACT"}
|
package/dist/model/time.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Duration } from 'date-fns';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type UnixTimeMs = number;
|
|
3
|
+
export type DateTimeFormat = number | string;
|
|
4
4
|
export interface AbsoluteTimeRange {
|
|
5
5
|
start: Date;
|
|
6
6
|
end: Date;
|
|
@@ -9,7 +9,7 @@ export interface RelativeTimeRange {
|
|
|
9
9
|
end?: Date;
|
|
10
10
|
pastDuration: DurationString;
|
|
11
11
|
}
|
|
12
|
-
export
|
|
12
|
+
export type TimeRangeValue = AbsoluteTimeRange | RelativeTimeRange;
|
|
13
13
|
/**
|
|
14
14
|
* Determine whether a given time range is relative
|
|
15
15
|
*/
|
|
@@ -22,14 +22,15 @@ export declare function isAbsoluteTimeRange(timeRange: TimeRangeValue): timeRang
|
|
|
22
22
|
* Returns an absolute time range from a RelativeTimeRange.
|
|
23
23
|
*/
|
|
24
24
|
export declare function toAbsoluteTimeRange(timeRange: RelativeTimeRange): AbsoluteTimeRange;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export
|
|
25
|
+
type MillisecondsDurationString = `${number}ms`;
|
|
26
|
+
type SecondsDurationString = `${number}s`;
|
|
27
|
+
type MinutesDurationString = `${number}m`;
|
|
28
|
+
type HoursDurationString = `${number}h`;
|
|
29
|
+
type DaysDurationString = `${number}d`;
|
|
30
|
+
type WeeksDurationString = `${number}w`;
|
|
31
|
+
type YearsDurationString = `${number}y`;
|
|
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.
|
|
@@ -39,6 +40,9 @@ export declare function parseDurationString(durationString: string): Duration;
|
|
|
39
40
|
* Returns true if the given string is a valid DurationString.
|
|
40
41
|
*/
|
|
41
42
|
export declare function isDurationString(maybeDuration: string): maybeDuration is DurationString;
|
|
43
|
+
export declare function intervalToPrometheusDuration(timeRange: AbsoluteTimeRange): Duration;
|
|
44
|
+
export declare function msToPrometheusDuration(durationInMs: number): Duration;
|
|
45
|
+
export declare function formatDuration(duration: Duration): DurationString;
|
|
42
46
|
/**
|
|
43
47
|
* Round interval to clearer increments
|
|
44
48
|
*/
|
package/dist/model/time.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAO,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"time.d.ts","sourceRoot":"","sources":["../../src/model/time.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,QAAQ,EAAO,MAAM,UAAU,CAAC;AASzC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,IAAI,CAAC;IACZ,GAAG,EAAE,IAAI,CAAC;CACX;AAED,MAAM,WAAW,iBAAiB;IAEhC,GAAG,CAAC,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,cAAc,CAAC;CAC9B;AAED,MAAM,MAAM,cAAc,GAAG,iBAAiB,GAAG,iBAAiB,CAAC;AAEnE;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,IAAI,iBAAiB,CAE7F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,cAAc,GAAG,SAAS,IAAI,iBAAiB,CAE7F;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,iBAAiB,GAAG,iBAAiB,CAOnF;AAED,KAAK,0BAA0B,GAAG,GAAG,MAAM,IAAI,CAAC;AAChD,KAAK,qBAAqB,GAAG,GAAG,MAAM,GAAG,CAAC;AAC1C,KAAK,qBAAqB,GAAG,GAAG,MAAM,GAAG,CAAC;AAC1C,KAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AACxC,KAAK,kBAAkB,GAAG,GAAG,MAAM,GAAG,CAAC;AACvC,KAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AACxC,KAAK,mBAAmB,GAAG,GAAG,MAAM,GAAG,CAAC;AAExC,MAAM,MAAM,cAAc,GAAG,OAAO,CAClC,GAAG,mBAAmB,GAAG,EAAE,GAAG,mBAAmB,GAAG,EAAE,GAAG,kBAAkB,GAAG,EAAE,GAAG,mBAAmB,GAAG,EAAE,GACvG,qBAAqB,GACrB,EAAE,GAAG,qBAAqB,GAAG,EAAE,GAAG,0BAA0B,GAAG,EAAE,EAAE,EACvE,EAAE,CACH,CAAC;AAEF,eAAO,MAAM,cAAc,QAAqF,CAAC;AAEjH;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAepE;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,IAAI,cAAc,CAGvF;AAED,wBAAgB,4BAA4B,CAAC,SAAS,EAAE,iBAAiB,GAAG,QAAQ,CAGnF;AAED,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAqBrE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,cAAc,CA4BjE;AAiED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,UAO/C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,UAI7E"}
|
package/dist/model/time.js
CHANGED
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { sub } from 'date-fns';
|
|
14
|
+
const ONE_SECOND_IN_MS = 1000;
|
|
15
|
+
const ONE_MINUTE_IN_MS = 60000;
|
|
16
|
+
const ONE_HOUR_IN_MS = 3600000;
|
|
17
|
+
const ONE_DAY_IN_MS = 86400000; // assuming a day has always 24h
|
|
18
|
+
const ONE_WEEK_IN_MS = 604800000; // assuming a week has always 7d
|
|
19
|
+
const ONE_YEAR_IN_MS = 31536000000; // assuming a year has always 365d
|
|
14
20
|
/**
|
|
15
21
|
* Determine whether a given time range is relative
|
|
16
22
|
*/ export function isRelativeTimeRange(timeRange) {
|
|
@@ -24,14 +30,14 @@ import { sub } from 'date-fns';
|
|
|
24
30
|
/**
|
|
25
31
|
* Returns an absolute time range from a RelativeTimeRange.
|
|
26
32
|
*/ export function toAbsoluteTimeRange(timeRange) {
|
|
27
|
-
var
|
|
28
|
-
const end = (
|
|
33
|
+
var _timeRange_end;
|
|
34
|
+
const end = (_timeRange_end = timeRange.end) !== null && _timeRange_end !== void 0 ? _timeRange_end : new Date();
|
|
29
35
|
return {
|
|
30
36
|
start: sub(end, parseDurationString(timeRange.pastDuration)),
|
|
31
37
|
end
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
|
-
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)?$/;
|
|
35
41
|
/**
|
|
36
42
|
* Parses a DurationString into a Duration object with numeric values that can
|
|
37
43
|
* be used to do Date math. Throws if not a valid duration string.
|
|
@@ -40,15 +46,15 @@ const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?
|
|
|
40
46
|
if (matches === null) {
|
|
41
47
|
throw new Error(`Invalid duration string '${durationString}'`);
|
|
42
48
|
}
|
|
43
|
-
var
|
|
49
|
+
var _matches_, _matches_1, _matches_2, _matches_3, _matches_4, _matches_5, _matches_6;
|
|
44
50
|
return {
|
|
45
|
-
years: parseInt((
|
|
51
|
+
years: parseInt((_matches_ = matches[1]) !== null && _matches_ !== void 0 ? _matches_ : '0'),
|
|
46
52
|
months: 0,
|
|
47
|
-
weeks: parseInt((
|
|
48
|
-
days: parseInt((
|
|
49
|
-
hours: parseInt((
|
|
50
|
-
minutes: parseInt((
|
|
51
|
-
seconds: parseInt((
|
|
53
|
+
weeks: parseInt((_matches_1 = matches[2]) !== null && _matches_1 !== void 0 ? _matches_1 : '0'),
|
|
54
|
+
days: parseInt((_matches_2 = matches[3]) !== null && _matches_2 !== void 0 ? _matches_2 : '0'),
|
|
55
|
+
hours: parseInt((_matches_3 = matches[4]) !== null && _matches_3 !== void 0 ? _matches_3 : '0'),
|
|
56
|
+
minutes: parseInt((_matches_4 = matches[5]) !== null && _matches_4 !== void 0 ? _matches_4 : '0'),
|
|
57
|
+
seconds: parseInt((_matches_5 = matches[6]) !== null && _matches_5 !== void 0 ? _matches_5 : '0') + parseInt((_matches_6 = matches[7]) !== null && _matches_6 !== void 0 ? _matches_6 : '0') / 1000
|
|
52
58
|
};
|
|
53
59
|
}
|
|
54
60
|
/**
|
|
@@ -57,6 +63,60 @@ const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?
|
|
|
57
63
|
if (maybeDuration === '') return false;
|
|
58
64
|
return DURATION_REGEX.test(maybeDuration);
|
|
59
65
|
}
|
|
66
|
+
export function intervalToPrometheusDuration(timeRange) {
|
|
67
|
+
const durationInMs = timeRange.end.valueOf() - timeRange.start.valueOf();
|
|
68
|
+
return msToPrometheusDuration(durationInMs);
|
|
69
|
+
}
|
|
70
|
+
export function msToPrometheusDuration(durationInMs) {
|
|
71
|
+
const years = Math.trunc(durationInMs / ONE_YEAR_IN_MS);
|
|
72
|
+
if (years > 0) durationInMs -= years * ONE_YEAR_IN_MS;
|
|
73
|
+
const weeks = Math.trunc(durationInMs / ONE_WEEK_IN_MS);
|
|
74
|
+
if (weeks > 0) durationInMs -= weeks * ONE_WEEK_IN_MS;
|
|
75
|
+
const days = Math.trunc(durationInMs / ONE_DAY_IN_MS);
|
|
76
|
+
if (days > 0) durationInMs -= days * ONE_DAY_IN_MS;
|
|
77
|
+
const hours = Math.trunc(durationInMs / ONE_HOUR_IN_MS);
|
|
78
|
+
if (hours > 0) durationInMs -= hours * ONE_HOUR_IN_MS;
|
|
79
|
+
const minutes = Math.trunc(durationInMs / ONE_MINUTE_IN_MS);
|
|
80
|
+
if (minutes > 0) durationInMs -= minutes * ONE_MINUTE_IN_MS;
|
|
81
|
+
return {
|
|
82
|
+
years: years,
|
|
83
|
+
months: 0,
|
|
84
|
+
weeks: weeks,
|
|
85
|
+
days: days,
|
|
86
|
+
hours: hours,
|
|
87
|
+
minutes: minutes,
|
|
88
|
+
seconds: durationInMs / 1000
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export function formatDuration(duration) {
|
|
92
|
+
const result = [];
|
|
93
|
+
if (duration.years) {
|
|
94
|
+
result.push(`${duration.years}y`);
|
|
95
|
+
}
|
|
96
|
+
if (duration.weeks) {
|
|
97
|
+
result.push(`${duration.weeks}w`);
|
|
98
|
+
}
|
|
99
|
+
if (duration.days) {
|
|
100
|
+
result.push(`${duration.days}d`);
|
|
101
|
+
}
|
|
102
|
+
if (duration.hours) {
|
|
103
|
+
result.push(`${duration.hours}h`);
|
|
104
|
+
}
|
|
105
|
+
if (duration.minutes) {
|
|
106
|
+
result.push(`${duration.minutes}m`);
|
|
107
|
+
}
|
|
108
|
+
if (duration.seconds) {
|
|
109
|
+
const seconds = Math.trunc(duration.seconds);
|
|
110
|
+
if (seconds) {
|
|
111
|
+
result.push(`${seconds}s`);
|
|
112
|
+
}
|
|
113
|
+
const ms = (duration.seconds - seconds) * 1000;
|
|
114
|
+
if (ms) {
|
|
115
|
+
result.push(`${ms}ms`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return result.join('');
|
|
119
|
+
}
|
|
60
120
|
const DEFAULT_STEP_MS = 15000;
|
|
61
121
|
const ROUNDED_STEP_INTERVALS = [
|
|
62
122
|
// max: 0.015s
|
|
@@ -97,147 +157,147 @@ const ROUNDED_STEP_INTERVALS = [
|
|
|
97
157
|
},
|
|
98
158
|
// max: 1.5s
|
|
99
159
|
{
|
|
100
|
-
maxMs:
|
|
101
|
-
roundedStepMs:
|
|
160
|
+
maxMs: ONE_SECOND_IN_MS * 1.5,
|
|
161
|
+
roundedStepMs: ONE_SECOND_IN_MS,
|
|
102
162
|
display: '1s'
|
|
103
163
|
},
|
|
104
164
|
// max: 3.5s
|
|
105
165
|
{
|
|
106
|
-
maxMs:
|
|
107
|
-
roundedStepMs:
|
|
166
|
+
maxMs: ONE_SECOND_IN_MS * 3.5,
|
|
167
|
+
roundedStepMs: ONE_SECOND_IN_MS * 2,
|
|
108
168
|
display: '2s'
|
|
109
169
|
},
|
|
110
170
|
// max: 7.5s
|
|
111
171
|
{
|
|
112
|
-
maxMs:
|
|
113
|
-
roundedStepMs:
|
|
172
|
+
maxMs: ONE_SECOND_IN_MS * 7.5,
|
|
173
|
+
roundedStepMs: ONE_SECOND_IN_MS * 5,
|
|
114
174
|
display: '5s'
|
|
115
175
|
},
|
|
116
176
|
// max: 12.5s
|
|
117
177
|
{
|
|
118
|
-
maxMs:
|
|
119
|
-
roundedStepMs:
|
|
178
|
+
maxMs: ONE_SECOND_IN_MS * 12.5,
|
|
179
|
+
roundedStepMs: ONE_SECOND_IN_MS * 10,
|
|
120
180
|
display: '10s'
|
|
121
181
|
},
|
|
122
182
|
// max: 17.5s
|
|
123
183
|
{
|
|
124
|
-
maxMs:
|
|
125
|
-
roundedStepMs:
|
|
184
|
+
maxMs: ONE_SECOND_IN_MS * 17.5,
|
|
185
|
+
roundedStepMs: ONE_SECOND_IN_MS * 15,
|
|
126
186
|
display: '15s'
|
|
127
187
|
},
|
|
128
188
|
// max: 25s
|
|
129
189
|
{
|
|
130
|
-
maxMs:
|
|
131
|
-
roundedStepMs:
|
|
190
|
+
maxMs: ONE_SECOND_IN_MS * 25,
|
|
191
|
+
roundedStepMs: ONE_SECOND_IN_MS * 20,
|
|
132
192
|
display: '20s'
|
|
133
193
|
},
|
|
134
194
|
// max: 45s
|
|
135
195
|
{
|
|
136
|
-
maxMs:
|
|
137
|
-
roundedStepMs:
|
|
196
|
+
maxMs: ONE_SECOND_IN_MS * 45,
|
|
197
|
+
roundedStepMs: ONE_SECOND_IN_MS * 30,
|
|
138
198
|
display: '30s'
|
|
139
199
|
},
|
|
140
200
|
// max: 1.5m
|
|
141
201
|
{
|
|
142
|
-
maxMs:
|
|
143
|
-
roundedStepMs:
|
|
202
|
+
maxMs: ONE_MINUTE_IN_MS * 1.5,
|
|
203
|
+
roundedStepMs: ONE_MINUTE_IN_MS,
|
|
144
204
|
display: '1m'
|
|
145
205
|
},
|
|
146
206
|
// max: 3.5m
|
|
147
207
|
{
|
|
148
|
-
maxMs:
|
|
149
|
-
roundedStepMs:
|
|
208
|
+
maxMs: ONE_MINUTE_IN_MS * 3.5,
|
|
209
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 2,
|
|
150
210
|
display: '2m'
|
|
151
211
|
},
|
|
152
212
|
// max: 7.5m
|
|
153
213
|
{
|
|
154
|
-
maxMs:
|
|
155
|
-
roundedStepMs:
|
|
214
|
+
maxMs: ONE_MINUTE_IN_MS * 7.5,
|
|
215
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 5,
|
|
156
216
|
display: '5m'
|
|
157
217
|
},
|
|
158
218
|
// max: 12.5m
|
|
159
219
|
{
|
|
160
|
-
maxMs:
|
|
161
|
-
roundedStepMs:
|
|
220
|
+
maxMs: ONE_MINUTE_IN_MS * 12.5,
|
|
221
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 10,
|
|
162
222
|
display: '10m'
|
|
163
223
|
},
|
|
164
224
|
// max: 12.5m
|
|
165
225
|
{
|
|
166
|
-
maxMs:
|
|
167
|
-
roundedStepMs:
|
|
226
|
+
maxMs: ONE_MINUTE_IN_MS * 12.5,
|
|
227
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 15,
|
|
168
228
|
display: '15m'
|
|
169
229
|
},
|
|
170
230
|
// max: 25m
|
|
171
231
|
{
|
|
172
|
-
maxMs:
|
|
173
|
-
roundedStepMs:
|
|
232
|
+
maxMs: ONE_MINUTE_IN_MS * 25,
|
|
233
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 20,
|
|
174
234
|
display: '20m'
|
|
175
235
|
},
|
|
176
236
|
// max: 45m
|
|
177
237
|
{
|
|
178
|
-
maxMs:
|
|
179
|
-
roundedStepMs:
|
|
238
|
+
maxMs: ONE_MINUTE_IN_MS * 45,
|
|
239
|
+
roundedStepMs: ONE_MINUTE_IN_MS * 30,
|
|
180
240
|
display: '30m'
|
|
181
241
|
},
|
|
182
242
|
// max: 1.5h
|
|
183
243
|
{
|
|
184
|
-
maxMs:
|
|
185
|
-
roundedStepMs:
|
|
244
|
+
maxMs: ONE_HOUR_IN_MS * 1.5,
|
|
245
|
+
roundedStepMs: ONE_HOUR_IN_MS,
|
|
186
246
|
display: '1h'
|
|
187
247
|
},
|
|
188
248
|
// max: 2.5h
|
|
189
249
|
{
|
|
190
|
-
maxMs:
|
|
191
|
-
roundedStepMs:
|
|
250
|
+
maxMs: ONE_HOUR_IN_MS * 2.5,
|
|
251
|
+
roundedStepMs: ONE_HOUR_IN_MS * 2,
|
|
192
252
|
display: '2h'
|
|
193
253
|
},
|
|
194
254
|
// max: 4.5h
|
|
195
255
|
{
|
|
196
|
-
maxMs:
|
|
197
|
-
roundedStepMs:
|
|
256
|
+
maxMs: ONE_HOUR_IN_MS * 4.5,
|
|
257
|
+
roundedStepMs: ONE_HOUR_IN_MS * 3,
|
|
198
258
|
display: '3h'
|
|
199
259
|
},
|
|
200
260
|
// max: 9h
|
|
201
261
|
{
|
|
202
|
-
maxMs:
|
|
203
|
-
roundedStepMs:
|
|
262
|
+
maxMs: ONE_HOUR_IN_MS * 9,
|
|
263
|
+
roundedStepMs: ONE_HOUR_IN_MS * 6,
|
|
204
264
|
display: '6h'
|
|
205
265
|
},
|
|
206
266
|
// max: 1d
|
|
207
267
|
{
|
|
208
|
-
maxMs:
|
|
209
|
-
roundedStepMs:
|
|
268
|
+
maxMs: ONE_DAY_IN_MS,
|
|
269
|
+
roundedStepMs: ONE_HOUR_IN_MS * 12,
|
|
210
270
|
display: '12h'
|
|
211
271
|
},
|
|
212
272
|
// max: 1w
|
|
213
273
|
{
|
|
214
|
-
maxMs:
|
|
215
|
-
roundedStepMs:
|
|
274
|
+
maxMs: ONE_WEEK_IN_MS,
|
|
275
|
+
roundedStepMs: ONE_DAY_IN_MS,
|
|
216
276
|
display: '1d'
|
|
217
277
|
},
|
|
218
278
|
// max: 3w
|
|
219
279
|
{
|
|
220
|
-
maxMs:
|
|
221
|
-
roundedStepMs:
|
|
280
|
+
maxMs: ONE_WEEK_IN_MS * 3,
|
|
281
|
+
roundedStepMs: ONE_WEEK_IN_MS,
|
|
222
282
|
display: '1w'
|
|
223
283
|
},
|
|
224
284
|
// max: 6w
|
|
225
285
|
{
|
|
226
|
-
maxMs:
|
|
227
|
-
roundedStepMs:
|
|
286
|
+
maxMs: ONE_WEEK_IN_MS * 6,
|
|
287
|
+
roundedStepMs: ONE_DAY_IN_MS * 30,
|
|
228
288
|
display: '30d'
|
|
229
289
|
},
|
|
230
290
|
// max: 2y
|
|
231
291
|
{
|
|
232
|
-
maxMs:
|
|
233
|
-
roundedStepMs:
|
|
292
|
+
maxMs: ONE_YEAR_IN_MS * 2,
|
|
293
|
+
roundedStepMs: ONE_YEAR_IN_MS,
|
|
234
294
|
display: '1y'
|
|
235
295
|
}
|
|
236
296
|
];
|
|
237
297
|
/**
|
|
238
298
|
* Round interval to clearer increments
|
|
239
299
|
*/ export function roundStepInterval(stepMs) {
|
|
240
|
-
for (const { maxMs
|
|
300
|
+
for (const { maxMs, roundedStepMs } of ROUNDED_STEP_INTERVALS){
|
|
241
301
|
if (stepMs < maxMs) {
|
|
242
302
|
return roundedStepMs;
|
|
243
303
|
}
|