@perses-dev/core 0.1.0 → 0.3.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.
Files changed (62) hide show
  1. package/LICENSE +201 -0
  2. package/dist/index.d.ts +2 -19
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -31
  5. package/dist/model/dashboard.d.ts +4 -4
  6. package/dist/model/dashboard.d.ts.map +1 -1
  7. package/dist/model/dashboard.js +1 -13
  8. package/dist/model/datasource.js +1 -13
  9. package/dist/model/definitions.js +1 -13
  10. package/dist/model/http.js +1 -15
  11. package/dist/model/index.d.ts +10 -0
  12. package/dist/model/index.d.ts.map +1 -0
  13. package/dist/model/index.js +1 -0
  14. package/dist/model/layout.d.ts +1 -1
  15. package/dist/model/layout.d.ts.map +1 -1
  16. package/dist/model/layout.js +1 -13
  17. package/dist/model/panels.d.ts +7 -12
  18. package/dist/model/panels.d.ts.map +1 -1
  19. package/dist/model/panels.js +1 -13
  20. package/dist/model/resource.js +1 -13
  21. package/dist/model/time.d.ts +4 -0
  22. package/dist/model/time.d.ts.map +1 -1
  23. package/dist/model/time.js +1 -53
  24. package/dist/model/variables.d.ts +4 -19
  25. package/dist/model/variables.d.ts.map +1 -1
  26. package/dist/model/variables.js +1 -13
  27. package/dist/utils/fetch.js +1 -42
  28. package/dist/utils/index.d.ts +4 -0
  29. package/dist/utils/index.d.ts.map +1 -0
  30. package/dist/utils/index.js +1 -0
  31. package/dist/{hooks → utils}/memo.d.ts +0 -0
  32. package/dist/{hooks → utils}/memo.d.ts.map +1 -1
  33. package/dist/utils/memo.js +1 -0
  34. package/dist/utils/panel-refs.d.ts +7 -0
  35. package/dist/utils/panel-refs.d.ts.map +1 -0
  36. package/dist/utils/panel-refs.js +1 -0
  37. package/package.json +11 -3
  38. package/dist/context/PluginRuntimeContext.d.ts +0 -26
  39. package/dist/context/PluginRuntimeContext.d.ts.map +0 -1
  40. package/dist/context/PluginRuntimeContext.js +0 -31
  41. package/dist/hooks/dashboard.d.ts +0 -22
  42. package/dist/hooks/dashboard.d.ts.map +0 -1
  43. package/dist/hooks/dashboard.js +0 -31
  44. package/dist/hooks/datasource.d.ts +0 -5
  45. package/dist/hooks/datasource.d.ts.map +0 -1
  46. package/dist/hooks/datasource.js +0 -26
  47. package/dist/hooks/graph-query.d.ts +0 -4
  48. package/dist/hooks/graph-query.d.ts.map +0 -1
  49. package/dist/hooks/graph-query.js +0 -16
  50. package/dist/hooks/memo.js +0 -45
  51. package/dist/hooks/panel.d.ts +0 -11
  52. package/dist/hooks/panel.d.ts.map +0 -1
  53. package/dist/hooks/panel.js +0 -19
  54. package/dist/model/graph-query.d.ts +0 -28
  55. package/dist/model/graph-query.d.ts.map +0 -1
  56. package/dist/model/graph-query.js +0 -13
  57. package/dist/model/json-references.d.ts +0 -12
  58. package/dist/model/json-references.d.ts.map +0 -1
  59. package/dist/model/json-references.js +0 -24
  60. package/dist/model/plugins.d.ts +0 -87
  61. package/dist/model/plugins.d.ts.map +0 -1
  62. package/dist/model/plugins.js +0 -16
@@ -1,42 +1 @@
1
- // Copyright 2021 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
- * Calls `global.fetch`, but throws a `FetchError` for non-200 responses.
15
- */
16
- export async function fetch(...args) {
17
- const response = await global.fetch(...args);
18
- if (response.ok === false) {
19
- throw new FetchError(response);
20
- }
21
- return response;
22
- }
23
- /**
24
- * Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also
25
- * decodes the response body as JSON, casting it to type `T`. Returns the
26
- * decoded body.
27
- */
28
- export async function fetchJson(...args) {
29
- const response = await fetch(...args);
30
- const json = await response.json();
31
- return json;
32
- }
33
- /**
34
- * Error thrown when fetch returns a non-200 response.
35
- */
36
- export class FetchError extends Error {
37
- constructor(response) {
38
- super(`${response.status} ${response.statusText}`);
39
- this.response = response;
40
- Object.setPrototypeOf(this, FetchError.prototype);
41
- }
42
- }
1
+ export async function fetch(...t){const r=await global.fetch(...t);if(!1===r.ok)throw new FetchError(r);return r}export async function fetchJson(...t){const r=await fetch(...t);return await r.json()}export class FetchError extends Error{constructor(t){super(`${t.status} ${t.statusText}`),this.response=t,Object.setPrototypeOf(this,FetchError.prototype)}}
@@ -0,0 +1,4 @@
1
+ export * from './fetch';
2
+ export * from './memo';
3
+ export * from './panel-refs';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
@@ -0,0 +1 @@
1
+ export*from"./fetch";export*from"./memo";export*from"./panel-refs";
File without changes
@@ -1 +1 @@
1
- {"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/hooks/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,KAgBpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAMxE"}
1
+ {"version":3,"file":"memo.d.ts","sourceRoot":"","sources":["../../src/utils/memo.ts"],"names":[],"mappings":"AAaA,OAAO,EAAU,cAAc,EAAE,MAAM,OAAO,CAAC;AAQ/C;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,KAgBpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,cAAc,GAAG,CAAC,CAMxE"}
@@ -0,0 +1 @@
1
+ import{useRef}from"react";import{isEqual}from"lodash-es";export function useMemoized(e,r){var u;const t=useRef();let n=!0;for(let e=0;e<r.length;e++)if((null===(u=t.current)||void 0===u?void 0:u.deps[e])!==r[e]){n=!1;break}return void 0!==t.current&&!1!==n||(t.current={value:e(),deps:r}),t.current.value}export function useDeepMemo(e,r){const u=useRef();return void 0!==u.current&&!1!==isEqual(r,u.current.deps)||(u.current={value:e(),deps:r}),u.current.value}
@@ -0,0 +1,7 @@
1
+ import { DashboardSpec, PanelRef } from '../model';
2
+ /**
3
+ * Resolve a PanelRef (JSON reference) against the provided DashboardSpec to
4
+ * a PanelDefinition.
5
+ */
6
+ export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef): import("../model").PanelDefinition<import("../model").JsonObject>;
7
+ //# sourceMappingURL=panel-refs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panel-refs.d.ts","sourceRoot":"","sources":["../../src/utils/panel-refs.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,qEAOtE"}
@@ -0,0 +1 @@
1
+ export function resolvePanelRef(e,r){const n=r.$ref.substring(9),o=e.panels[n];if(void 0===o)throw new Error(`Could not resolve panels reference ${r.$ref}`);return o}
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@perses-dev/core",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Core functionality consumed by both the Perses UI and plugins",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/perses/perses/blob/main/README.md",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/perses/perses.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/perses/perses/issues"
13
+ },
5
14
  "module": "dist/index.js",
6
15
  "types": "dist/index.d.ts",
7
16
  "scripts": {
@@ -19,9 +28,8 @@
19
28
  "react": "^17.0.2"
20
29
  },
21
30
  "devDependencies": {
22
- "@types/lodash-es": "^4.17.5"
31
+ "@types/lodash-es": "^4.17.6"
23
32
  },
24
- "license": "Apache-2.0",
25
33
  "files": [
26
34
  "dist"
27
35
  ]
@@ -1,26 +0,0 @@
1
- /// <reference types="react" />
2
- import { useGraphQuery } from '../hooks/graph-query';
3
- import { useDashboardSpec, useDashboardTimeRange, useDashboardVariables } from '../hooks/dashboard';
4
- import { useDataSources } from '../hooks/datasource';
5
- import { usePanelState } from '../hooks/panel';
6
- /**
7
- * Hooks exposed to plugins at runtime. This is so we don't have to put
8
- * implementation details here in core (i.e. a plugin doesn't need to worry
9
- * about whether these are using Context, Redux, etc).
10
- */
11
- export interface PluginRuntime {
12
- useDashboardSpec: typeof useDashboardSpec;
13
- useDashboardVariables: typeof useDashboardVariables;
14
- useDashboardTimeRange: typeof useDashboardTimeRange;
15
- useDataSources: typeof useDataSources;
16
- useGraphQuery: typeof useGraphQuery;
17
- usePanelState: typeof usePanelState;
18
- }
19
- export declare const PluginRuntimeContext: import("react").Context<PluginRuntime | undefined>;
20
- export interface PluginRuntimeProviderProps {
21
- value: PluginRuntime;
22
- children: React.ReactNode;
23
- }
24
- export declare function PluginRuntimeProvider(props: PluginRuntimeProviderProps): JSX.Element;
25
- export declare function usePluginRuntime<T extends keyof PluginRuntime>(hook: T): PluginRuntime[T];
26
- //# sourceMappingURL=PluginRuntimeContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PluginRuntimeContext.d.ts","sourceRoot":"","sources":["../../src/context/PluginRuntimeContext.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,gBAAgB,EAAE,OAAO,gBAAgB,CAAC;IAC1C,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;IACpD,qBAAqB,EAAE,OAAO,qBAAqB,CAAC;IACpD,cAAc,EAAE,OAAO,cAAc,CAAC;IACtC,aAAa,EAAE,OAAO,aAAa,CAAC;IACpC,aAAa,EAAE,OAAO,aAAa,CAAC;CACrC;AAED,eAAO,MAAM,oBAAoB,oDAAsD,CAAC;AAExF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,eAStE;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,aAAa,EAAE,IAAI,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAMzF"}
@@ -1,31 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- // Copyright 2021 The Perses Authors
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { createContext, useContext, useRef } from 'react';
15
- export const PluginRuntimeContext = createContext(undefined);
16
- export function PluginRuntimeProvider(props) {
17
- // Initialize once, then always pass the same value down so we don't have
18
- // the possibility of hook implementations changing (i.e. conditional hooks)
19
- const context = useRef();
20
- if (context.current === undefined) {
21
- context.current = props.value;
22
- }
23
- return _jsx(PluginRuntimeContext.Provider, { value: context.current, children: props.children }, void 0);
24
- }
25
- export function usePluginRuntime(hook) {
26
- const context = useContext(PluginRuntimeContext);
27
- if (context === undefined) {
28
- throw new Error('Could not find ExposeToPlugin context. Did you forget a provider?');
29
- }
30
- return context[hook];
31
- }
@@ -1,22 +0,0 @@
1
- import { DashboardSpec } from '../model/dashboard';
2
- import { AbsoluteTimeRange } from '../model/time';
3
- /**
4
- * Gets the spec for the current Dashboard.
5
- */
6
- export declare function useDashboardSpec(): DashboardSpec;
7
- /**
8
- * The value and options for a Dashboard variable.
9
- */
10
- export interface VariableState {
11
- value: string | string[];
12
- options?: string[];
13
- }
14
- /**
15
- * Gets the variable values and options for the current Dashboard.
16
- */
17
- export declare function useDashboardVariables(): Record<string, VariableState>;
18
- /**
19
- * Gets the selected time range for the current Dashboard.
20
- */
21
- export declare function useDashboardTimeRange(): AbsoluteTimeRange;
22
- //# sourceMappingURL=dashboard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../src/hooks/dashboard.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAErE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,iBAAiB,CAEzD"}
@@ -1,31 +0,0 @@
1
- // Copyright 2021 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 { usePluginRuntime } from '../context/PluginRuntimeContext';
14
- /**
15
- * Gets the spec for the current Dashboard.
16
- */
17
- export function useDashboardSpec() {
18
- return usePluginRuntime('useDashboardSpec')();
19
- }
20
- /**
21
- * Gets the variable values and options for the current Dashboard.
22
- */
23
- export function useDashboardVariables() {
24
- return usePluginRuntime('useDashboardVariables')();
25
- }
26
- /**
27
- * Gets the selected time range for the current Dashboard.
28
- */
29
- export function useDashboardTimeRange() {
30
- return usePluginRuntime('useDashboardTimeRange')();
31
- }
@@ -1,5 +0,0 @@
1
- import { AnyDatasourceSpecDefinition, DatasourceSpecDefinition, GlobalDatasourceModel } from '../model/datasource';
2
- import { DatasourceSelector } from '../model/dashboard';
3
- export declare function useDataSources(selector: DatasourceSelector): GlobalDatasourceModel[];
4
- export declare function useDataSourceConfig<T extends DatasourceSpecDefinition>(selector: DatasourceSelector, validate: (value: AnyDatasourceSpecDefinition) => value is T): T;
5
- //# sourceMappingURL=datasource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datasource.d.ts","sourceRoot":"","sources":["../../src/hooks/datasource.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnH,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,wBAAgB,cAAc,CAAC,QAAQ,EAAE,kBAAkB,GAAG,qBAAqB,EAAE,CAEpF;AAED,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,wBAAwB,EACpE,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,CAAC,KAAK,EAAE,2BAA2B,KAAK,KAAK,IAAI,CAAC,GAC3D,CAAC,CAYH"}
@@ -1,26 +0,0 @@
1
- // Copyright 2021 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 { usePluginRuntime } from '../context/PluginRuntimeContext';
14
- export function useDataSources(selector) {
15
- return usePluginRuntime('useDataSources')(selector);
16
- }
17
- export function useDataSourceConfig(selector, validate) {
18
- const datasources = useDataSources(selector);
19
- if (datasources.length !== 1 || datasources[0] === undefined) {
20
- throw new Error(`Could not find Datasource for selector ${selector}`);
21
- }
22
- if (validate(datasources[0].spec)) {
23
- return datasources[0].spec;
24
- }
25
- throw new Error(`Datasource spec for selector ${selector} is not valid`);
26
- }
@@ -1,4 +0,0 @@
1
- import { UseGraphQueryHook } from '../model/graph-query';
2
- import { JsonObject } from '../model/definitions';
3
- export declare const useGraphQuery: UseGraphQueryHook<JsonObject>;
4
- //# sourceMappingURL=graph-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graph-query.d.ts","sourceRoot":"","sources":["../../src/hooks/graph-query.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,UAAU,CAEvD,CAAC"}
@@ -1,16 +0,0 @@
1
- // Copyright 2021 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 { usePluginRuntime } from '../context/PluginRuntimeContext';
14
- export const useGraphQuery = (definition) => {
15
- return usePluginRuntime('useGraphQuery')(definition);
16
- };
@@ -1,45 +0,0 @@
1
- // Copyright 2021 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 { useRef } from 'react';
14
- import { isEqual } from 'lodash-es';
15
- /**
16
- * Like React's useMemo, but guarantees the value will only be recalulated if
17
- * a dependency changes. Uses strict equality (===) for comparison. (React's
18
- * useMemo does not offer this guarantee, it's only a performance optimization).
19
- */
20
- export function useMemoized(factory, deps) {
21
- var _a;
22
- const ref = useRef();
23
- let areEqual = true;
24
- for (let i = 0; i < deps.length; i++) {
25
- if (((_a = ref.current) === null || _a === void 0 ? void 0 : _a.deps[i]) !== deps[i]) {
26
- areEqual = false;
27
- break;
28
- }
29
- }
30
- if (ref.current === undefined || areEqual === false) {
31
- ref.current = { value: factory(), deps: deps };
32
- }
33
- return ref.current.value;
34
- }
35
- /**
36
- * Like React's useMemo, except it does a deep equality comparison with lodash's
37
- * isEqual on the dependency list.
38
- */
39
- export function useDeepMemo(factory, deps) {
40
- const ref = useRef();
41
- if (ref.current === undefined || isEqual(deps, ref.current.deps) === false) {
42
- ref.current = { value: factory(), deps };
43
- }
44
- return ref.current.value;
45
- }
@@ -1,11 +0,0 @@
1
- export interface PanelState {
2
- contentDimensions?: {
3
- width: number;
4
- height: number;
5
- };
6
- }
7
- /**
8
- * Gets the state of the current panel being rendered.
9
- */
10
- export declare function usePanelState(): PanelState;
11
- //# sourceMappingURL=panel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/hooks/panel.ts"],"names":[],"mappings":"AAeA,MAAM,WAAW,UAAU;IACzB,iBAAiB,CAAC,EAAE;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAE1C"}
@@ -1,19 +0,0 @@
1
- // Copyright 2021 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 { usePluginRuntime } from '../context/PluginRuntimeContext';
14
- /**
15
- * Gets the state of the current panel being rendered.
16
- */
17
- export function usePanelState() {
18
- return usePluginRuntime('usePanelState')();
19
- }
@@ -1,28 +0,0 @@
1
- import { AbsoluteTimeRange, UnixTimeMs } from './time';
2
- import { Definition, JsonObject } from './definitions';
3
- import { AnyPluginDefinition, AnyPluginImplementation } from './plugins';
4
- import { ResourceSelector } from './resource';
5
- export interface GraphQueryDefinition<Options extends JsonObject> extends Definition<Options> {
6
- datasource?: ResourceSelector;
7
- }
8
- export interface GraphQueryPlugin<Options extends JsonObject> {
9
- useGraphQuery: UseGraphQueryHook<Options>;
10
- }
11
- export declare type UseGraphQueryHook<Options extends JsonObject> = (definition: GraphQueryDefinition<Options>) => {
12
- data?: GraphData;
13
- loading: boolean;
14
- error?: Error;
15
- };
16
- export interface GraphData {
17
- timeRange: AbsoluteTimeRange;
18
- stepMs: number;
19
- series: Iterable<GraphSeries>;
20
- }
21
- export interface GraphSeries {
22
- name: string;
23
- values: Iterable<GraphSeriesValueTuple>;
24
- }
25
- export declare type GraphSeriesValueTuple = [timestamp: UnixTimeMs, value: number];
26
- export declare type AnyGraphQueryDefinition = AnyPluginDefinition<'GraphQuery'>;
27
- export declare type AnyGraphQueryPlugin = AnyPluginImplementation<'GraphQuery'>;
28
- //# sourceMappingURL=graph-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"graph-query.d.ts","sourceRoot":"","sources":["../../src/model/graph-query.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,UAAU,CAAE,SAAQ,UAAU,CAAC,OAAO,CAAC;IAC3F,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,UAAU;IAC1D,aAAa,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED,oBAAY,iBAAiB,CAAC,OAAO,SAAS,UAAU,IAAI,CAAC,UAAU,EAAE,oBAAoB,CAAC,OAAO,CAAC,KAAK;IACzG,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,CAAC;AAEF,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;CACzC;AAED,oBAAY,qBAAqB,GAAG,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAE3E,oBAAY,uBAAuB,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAExE,oBAAY,mBAAmB,GAAG,uBAAuB,CAAC,YAAY,CAAC,CAAC"}
@@ -1,13 +0,0 @@
1
- // Copyright 2021 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 {};
@@ -1,12 +0,0 @@
1
- import { DashboardSpec } from './dashboard';
2
- import { JsonObject } from './definitions';
3
- export interface PanelRef extends JsonObject {
4
- $ref: PanelPointer;
5
- }
6
- export declare type PanelPointer = `#/panels/${string}`;
7
- /**
8
- * Resolve a PanelRef (JSON reference) against the provided DashboardSpec to
9
- * a PanelDefinition.
10
- */
11
- export declare function resolvePanelRef(spec: DashboardSpec, panelRef: PanelRef): import("./panels").PanelDefinition<JsonObject>;
12
- //# sourceMappingURL=json-references.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"json-references.d.ts","sourceRoot":"","sources":["../../src/model/json-references.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,WAAW,QAAS,SAAQ,UAAU;IAC1C,IAAI,EAAE,YAAY,CAAC;CACpB;AAED,oBAAY,YAAY,GAAG,YAAY,MAAM,EAAE,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,kDAOtE"}
@@ -1,24 +0,0 @@
1
- // Copyright 2021 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
- * Resolve a PanelRef (JSON reference) against the provided DashboardSpec to
15
- * a PanelDefinition.
16
- */
17
- export function resolvePanelRef(spec, panelRef) {
18
- const panelsKey = panelRef.$ref.substring(9);
19
- const panelDefinition = spec.panels[panelsKey];
20
- if (panelDefinition === undefined) {
21
- throw new Error(`Could not resolve panels reference ${panelRef.$ref}`);
22
- }
23
- return panelDefinition;
24
- }
@@ -1,87 +0,0 @@
1
- import { GraphQueryDefinition, GraphQueryPlugin } from './graph-query';
2
- import { JsonObject } from './definitions';
3
- import { PanelDefinition, PanelPlugin } from './panels';
4
- import { ResourceMetadata } from './resource';
5
- import { VariableDefinition, VariablePlugin } from './variables';
6
- export interface PluginResource {
7
- kind: 'Plugin';
8
- metadata: ResourceMetadata;
9
- spec: PluginSpec;
10
- }
11
- export interface PluginSpec {
12
- supported_kinds: Record<string, PluginType>;
13
- plugin_module_path: string;
14
- }
15
- /**
16
- * A JavaScript module with Perses plugins.
17
- */
18
- export interface PluginModule {
19
- setup: PluginSetupFunction;
20
- }
21
- /**
22
- * When a PluginModule is loaded, this function is called to allow the module
23
- * to register plugins with Perses.
24
- */
25
- export declare type PluginSetupFunction = (registerPlugin: RegisterPlugin) => void;
26
- /**
27
- * Callback function that registers a plugin with Perses.
28
- */
29
- export declare type RegisterPlugin = <Options extends JsonObject>(config: PluginRegistrationConfig<Options>) => void;
30
- /**
31
- * All supported plugin type values as an array for use at runtime.
32
- */
33
- export declare const ALL_PLUGIN_TYPES: readonly ["Variable", "Panel", "GraphQuery"];
34
- /**
35
- * All supported plugin types.
36
- */
37
- export declare type PluginType = typeof ALL_PLUGIN_TYPES[number];
38
- declare type SupportedPlugins<Options extends JsonObject> = {
39
- Variable: {
40
- Def: VariableDefinition<Options>;
41
- Impl: VariablePlugin<Options>;
42
- };
43
- Panel: {
44
- Def: PanelDefinition<Options>;
45
- Impl: PanelPlugin<Options>;
46
- };
47
- GraphQuery: {
48
- Def: GraphQueryDefinition<Options>;
49
- Impl: GraphQueryPlugin<Options>;
50
- };
51
- };
52
- /**
53
- * The definition handled for a given plugin type.
54
- */
55
- export declare type PluginDefinition<Type extends PluginType, Options extends JsonObject> = SupportedPlugins<Options>[Type]['Def'];
56
- /**
57
- * The implementation for a given plugin type.
58
- */
59
- export declare type PluginImplementation<Type extends PluginType, Options extends JsonObject> = SupportedPlugins<Options>[Type]['Impl'];
60
- /**
61
- * Configuration (including the plugin implementation) that's expected when
62
- * registering a plugin with Perses.
63
- */
64
- export declare type PluginRegistrationConfig<Options extends JsonObject> = {
65
- [Type in PluginType]: PluginConfig<Type, Options>;
66
- }[PluginType];
67
- /**
68
- * Configuration expected for a particular plugin type.
69
- */
70
- export declare type PluginConfig<Type extends PluginType, Options extends JsonObject> = {
71
- pluginType: Type;
72
- kind: string;
73
- validate?: (config: AnyPluginDefinition<Type>) => string[];
74
- plugin: PluginImplementation<Type, Options>;
75
- };
76
- /**
77
- * A PluginDefinition at runtime where we know the plugin type, but not the
78
- * specific Kind/Options that it handles.
79
- */
80
- export declare type AnyPluginDefinition<Type extends PluginType> = PluginDefinition<Type, JsonObject>;
81
- /**
82
- * A PluginImplementation at runtime where we know the plugin type, but not the
83
- * specific Kind/Options that it handles.
84
- */
85
- export declare type AnyPluginImplementation<Type extends PluginType> = PluginImplementation<Type, JsonObject>;
86
- export {};
87
- //# sourceMappingURL=plugins.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/model/plugins.ts"],"names":[],"mappings":"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"}
@@ -1,16 +0,0 @@
1
- // Copyright 2021 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
- * All supported plugin type values as an array for use at runtime.
15
- */
16
- export const ALL_PLUGIN_TYPES = ['Variable', 'Panel', 'GraphQuery'];