@perses-dev/plugin-system 0.44.0 → 0.45.0-rc0

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 (122) hide show
  1. package/dist/cjs/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
  2. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +35 -37
  3. package/dist/cjs/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +22 -10
  4. package/dist/cjs/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
  5. package/dist/cjs/components/PanelSpecEditor/PanelSpecEditor.js +12 -46
  6. package/dist/cjs/components/PluginEditor/PluginEditor.js +6 -7
  7. package/dist/cjs/components/PluginEditor/plugin-editor-api.js +43 -31
  8. package/dist/cjs/components/PluginKindSelect/PluginKindSelect.js +25 -5
  9. package/dist/cjs/components/PluginRegistry/PluginRegistry.js +5 -3
  10. package/dist/cjs/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  11. package/dist/cjs/components/ProjectSelect.js +3 -2
  12. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +192 -0
  13. package/dist/cjs/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  14. package/dist/cjs/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
  15. package/dist/cjs/components/index.js +2 -1
  16. package/dist/cjs/constants/user-interface-text.js +4 -1
  17. package/dist/cjs/runtime/DataQueriesProvider/model.js +6 -2
  18. package/dist/cjs/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -0
  19. package/dist/cjs/runtime/plugin-registry.js +7 -5
  20. package/dist/cjs/validation/resource.js +1 -1
  21. package/dist/cjs/validation/user.js +46 -0
  22. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.d.ts.map +1 -1
  23. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js +12 -3
  24. package/dist/components/DatasourceEditorForm/DatasourceEditorForm.js.map +1 -1
  25. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts +16 -0
  26. package/dist/components/MultiQueryEditor/MultiQueryEditor.d.ts.map +1 -0
  27. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryEditor.js → MultiQueryEditor/MultiQueryEditor.js} +42 -37
  28. package/dist/components/MultiQueryEditor/MultiQueryEditor.js.map +1 -0
  29. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts +28 -0
  30. package/dist/components/MultiQueryEditor/QueryEditorContainer.d.ts.map +1 -0
  31. package/dist/components/{TimeSeriesQueryEditor/TimeSeriesQueryInput.js → MultiQueryEditor/QueryEditorContainer.js} +32 -9
  32. package/dist/components/MultiQueryEditor/QueryEditorContainer.js.map +1 -0
  33. package/dist/components/MultiQueryEditor/index.d.ts +2 -0
  34. package/dist/components/MultiQueryEditor/index.d.ts.map +1 -0
  35. package/dist/components/{TimeSeriesQueryEditor → MultiQueryEditor}/index.js +2 -2
  36. package/dist/components/{TraceQueryEditor → MultiQueryEditor}/index.js.map +1 -1
  37. package/dist/components/PanelSpecEditor/PanelSpecEditor.d.ts.map +1 -1
  38. package/dist/components/PanelSpecEditor/PanelSpecEditor.js +13 -47
  39. package/dist/components/PanelSpecEditor/PanelSpecEditor.js.map +1 -1
  40. package/dist/components/PluginEditor/PluginEditor.d.ts.map +1 -1
  41. package/dist/components/PluginEditor/PluginEditor.js +6 -7
  42. package/dist/components/PluginEditor/PluginEditor.js.map +1 -1
  43. package/dist/components/PluginEditor/plugin-editor-api.d.ts +15 -9
  44. package/dist/components/PluginEditor/plugin-editor-api.d.ts.map +1 -1
  45. package/dist/components/PluginEditor/plugin-editor-api.js +43 -31
  46. package/dist/components/PluginEditor/plugin-editor-api.js.map +1 -1
  47. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts +10 -4
  48. package/dist/components/PluginKindSelect/PluginKindSelect.d.ts.map +1 -1
  49. package/dist/components/PluginKindSelect/PluginKindSelect.js +31 -8
  50. package/dist/components/PluginKindSelect/PluginKindSelect.js.map +1 -1
  51. package/dist/components/PluginRegistry/PluginRegistry.js +5 -3
  52. package/dist/components/PluginRegistry/PluginRegistry.js.map +1 -1
  53. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts +3 -3
  54. package/dist/components/PluginSpecEditor/PluginSpecEditor.d.ts.map +1 -1
  55. package/dist/components/PluginSpecEditor/PluginSpecEditor.js +1 -1
  56. package/dist/components/PluginSpecEditor/PluginSpecEditor.js.map +1 -1
  57. package/dist/components/ProjectSelect.js +3 -2
  58. package/dist/components/ProjectSelect.js.map +1 -1
  59. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts +13 -0
  60. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -0
  61. package/dist/components/TimeRangeControls/TimeRangeControls.js +168 -0
  62. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  63. package/dist/components/TimeRangeControls/index.d.ts +2 -0
  64. package/dist/components/TimeRangeControls/index.d.ts.map +1 -0
  65. package/dist/components/{TraceQueryEditor → TimeRangeControls}/index.js +1 -1
  66. package/dist/components/TimeRangeControls/index.js.map +1 -0
  67. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.d.ts.map +1 -1
  68. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js +16 -4
  69. package/dist/components/Variables/VariableEditorForm/VariableEditorForm.js.map +1 -1
  70. package/dist/components/index.d.ts +2 -1
  71. package/dist/components/index.d.ts.map +1 -1
  72. package/dist/components/index.js +2 -1
  73. package/dist/components/index.js.map +1 -1
  74. package/dist/constants/user-interface-text.d.ts +2 -0
  75. package/dist/constants/user-interface-text.d.ts.map +1 -1
  76. package/dist/constants/user-interface-text.js +4 -1
  77. package/dist/constants/user-interface-text.js.map +1 -1
  78. package/dist/model/panels.d.ts +7 -2
  79. package/dist/model/panels.d.ts.map +1 -1
  80. package/dist/model/panels.js.map +1 -1
  81. package/dist/model/plugin-base.d.ts +0 -1
  82. package/dist/model/plugin-base.d.ts.map +1 -1
  83. package/dist/model/plugin-base.js.map +1 -1
  84. package/dist/runtime/DataQueriesProvider/model.d.ts.map +1 -1
  85. package/dist/runtime/DataQueriesProvider/model.js +6 -2
  86. package/dist/runtime/DataQueriesProvider/model.js.map +1 -1
  87. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts +4 -0
  88. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.d.ts.map +1 -1
  89. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js +8 -1
  90. package/dist/runtime/TimeRangeProvider/TimeRangeProvider.js.map +1 -1
  91. package/dist/runtime/plugin-registry.d.ts +5 -5
  92. package/dist/runtime/plugin-registry.d.ts.map +1 -1
  93. package/dist/runtime/plugin-registry.js +7 -5
  94. package/dist/runtime/plugin-registry.js.map +1 -1
  95. package/dist/validation/resource.js +1 -1
  96. package/dist/validation/resource.js.map +1 -1
  97. package/dist/validation/user.d.ts +93 -0
  98. package/dist/validation/user.d.ts.map +1 -0
  99. package/dist/validation/user.js +38 -0
  100. package/dist/validation/user.js.map +1 -0
  101. package/package.json +4 -4
  102. package/dist/cjs/components/TraceQueryEditor/TraceQueryEditor.js +0 -143
  103. package/dist/cjs/components/TraceQueryEditor/TraceQueryInput.js +0 -96
  104. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts +0 -7
  105. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.d.ts.map +0 -1
  106. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryEditor.js.map +0 -1
  107. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts +0 -12
  108. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.d.ts.map +0 -1
  109. package/dist/components/TimeSeriesQueryEditor/TimeSeriesQueryInput.js.map +0 -1
  110. package/dist/components/TimeSeriesQueryEditor/index.d.ts +0 -2
  111. package/dist/components/TimeSeriesQueryEditor/index.d.ts.map +0 -1
  112. package/dist/components/TimeSeriesQueryEditor/index.js.map +0 -1
  113. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts +0 -8
  114. package/dist/components/TraceQueryEditor/TraceQueryEditor.d.ts.map +0 -1
  115. package/dist/components/TraceQueryEditor/TraceQueryEditor.js +0 -130
  116. package/dist/components/TraceQueryEditor/TraceQueryEditor.js.map +0 -1
  117. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts +0 -12
  118. package/dist/components/TraceQueryEditor/TraceQueryInput.d.ts.map +0 -1
  119. package/dist/components/TraceQueryEditor/TraceQueryInput.js +0 -83
  120. package/dist/components/TraceQueryEditor/TraceQueryInput.js.map +0 -1
  121. package/dist/components/TraceQueryEditor/index.d.ts +0 -2
  122. package/dist/components/TraceQueryEditor/index.d.ts.map +0 -1
@@ -25,8 +25,12 @@ export function transformQueryResults(results, definitions) {
25
25
  });
26
26
  }
27
27
  export function useQueryType() {
28
- const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata('TimeSeriesQuery');
29
- const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata('TraceQuery');
28
+ const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([
29
+ 'TimeSeriesQuery'
30
+ ]);
31
+ const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata([
32
+ 'TraceQuery'
33
+ ]);
30
34
  // For example, `map: {"TimeSeriesQuery":["PrometheusTimeSeriesQuery"],"TraceQuery":["TempoTraceQuery"]}`
31
35
  const queryTypeMap = useMemo(()=>{
32
36
  const map = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\ntype QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: React.ReactNode;\n options?: QueryOptions;\n queryOptions?: QueryObserverOptions;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]) {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } =\n useListPluginMetadata('TimeSeriesQuery');\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata('TraceQuery');\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string) => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","pluginType","push","kind","getQueryType","pluginKind","Error","undefined","queryType","includes"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAIjC,SAASA,WAAW,EAAEC,OAAO,QAAQ,QAAQ;AAC7C,SAASC,qBAAqB,QAAQ,qBAAqB;AA+B3D,OAAO,SAASC,sBAAsBC,OAAyB,EAAEC,WAA8B;IAC7F,OAAOD,QAAQE,GAAG,CAAC,CAAC,EAA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,aAAa;gBACjD,OAAOG;YACT;QACF;QAEA,MAAM,IAAIF,MAAM,CAAC,oCAAoC,EAAED,WAAW,CAAC;IACrE,GACA;QAACT;QAAcH;QAA0BE;KAA0B;IAGrE,OAAOS;AACT"}
1
+ {"version":3,"sources":["../../../src/runtime/DataQueriesProvider/model.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Definition, QueryDefinition, UnknownSpec, QueryDataType } from '@perses-dev/core';\nimport { QueryObserverOptions, UseQueryResult } from '@tanstack/react-query';\nimport { useCallback, useMemo } from 'react';\nimport { useListPluginMetadata } from '../plugin-registry';\n\ntype QueryOptions = Record<string, unknown>;\nexport interface DataQueriesProviderProps<QueryPluginSpec = UnknownSpec> {\n definitions: Array<Definition<QueryPluginSpec>>;\n children?: React.ReactNode;\n options?: QueryOptions;\n queryOptions?: QueryObserverOptions;\n}\n\nexport interface DataQueriesContextType {\n queryResults: QueryData[];\n refetchAll: () => void;\n isFetching: boolean;\n isLoading: boolean;\n errors: unknown[];\n}\n\nexport interface UseDataQueryResults<T> extends Omit<DataQueriesContextType, 'queryResults'> {\n queryResults: Array<QueryData<T>>;\n}\n\nexport type QueryData<T = QueryDataType> = {\n data?: T;\n definition: QueryDefinition;\n error: unknown;\n isFetching: boolean;\n isLoading: boolean;\n refetch?: () => void;\n};\n\nexport function transformQueryResults(results: UseQueryResult[], definitions: QueryDefinition[]) {\n return results.map(({ data, isFetching, isLoading, refetch, error }, i) => {\n return {\n definition: definitions[i],\n data,\n isFetching,\n isLoading,\n refetch,\n error,\n } as QueryData;\n });\n}\n\nexport function useQueryType(): (pluginKind: string) => string | undefined {\n const { data: timeSeriesQueryPlugins, isLoading: isTimeSeriesQueryLoading } = useListPluginMetadata([\n 'TimeSeriesQuery',\n ]);\n const { data: traceQueryPlugins, isLoading: isTraceQueryPluginLoading } = useListPluginMetadata(['TraceQuery']);\n\n // For example, `map: {\"TimeSeriesQuery\":[\"PrometheusTimeSeriesQuery\"],\"TraceQuery\":[\"TempoTraceQuery\"]}`\n const queryTypeMap = useMemo(() => {\n const map: Record<string, string[]> = {\n TimeSeriesQuery: [],\n TraceQuery: [],\n };\n\n if (timeSeriesQueryPlugins) {\n timeSeriesQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n\n if (traceQueryPlugins) {\n traceQueryPlugins.forEach((plugin) => {\n map[plugin.pluginType]?.push(plugin.kind);\n });\n }\n return map;\n }, [timeSeriesQueryPlugins, traceQueryPlugins]);\n\n const getQueryType = useCallback(\n (pluginKind: string) => {\n const isLoading = (pluginKind: string) => {\n switch (pluginKind) {\n case 'PrometheusTimeSeriesQuery':\n return isTimeSeriesQueryLoading;\n case 'TempoTraceQuery':\n return isTraceQueryPluginLoading;\n }\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n };\n\n if (isLoading(pluginKind)) {\n return undefined;\n }\n\n for (const queryType in queryTypeMap) {\n if (queryTypeMap[queryType]?.includes(pluginKind)) {\n return queryType;\n }\n }\n\n throw new Error(`Unable to determine the query type: ${pluginKind}`);\n },\n [queryTypeMap, isTimeSeriesQueryLoading, isTraceQueryPluginLoading]\n );\n\n return getQueryType;\n}\n"],"names":["useCallback","useMemo","useListPluginMetadata","transformQueryResults","results","definitions","map","data","isFetching","isLoading","refetch","error","i","definition","useQueryType","timeSeriesQueryPlugins","isTimeSeriesQueryLoading","traceQueryPlugins","isTraceQueryPluginLoading","queryTypeMap","TimeSeriesQuery","TraceQuery","forEach","plugin","pluginType","push","kind","getQueryType","pluginKind","Error","undefined","queryType","includes"],"mappings":"AA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kB;IAE9C,MAAMU,eAAe3B,YACnB,CAAC4B;QACC,MAAMnB,YAAY,CAACmB;YACjB,OAAQA;gBACN,KAAK;oBACH,OAAOZ;gBACT,KAAK;oBACH,OAAOE;YACX;YACA,MAAM,IAAIW,MAAM,CAAC,oCAAoC,EAAED,WAAW,CAAC;QACrE;QAEA,IAAInB,UAAUmB,aAAa;YACzB,OAAOE;QACT;QAEA,IAAK,MAAMC,aAAaZ,aAAc;gBAChCA;YAAJ,KAAIA,0BAAAA,YAAY,CAACY,UAAU,cAAvBZ,8CAAAA,wBAAyBa,QAAQ,CAACJ,aAAa;gBACjD,OAAOG;YACT;QACF;QAEA,MAAM,IAAIF,MAAM,CAAC,oCAAoC,EAAED,WAAW,CAAC;IACrE,GACA;QAACT;QAAcH;QAA0BE;KAA0B;IAGrE,OAAOS;AACT"}
@@ -23,6 +23,10 @@ export declare function useTimeRangeContext(): TimeRange;
23
23
  * Get and set the current resolved time range at runtime.
24
24
  */
25
25
  export declare function useTimeRange(): TimeRange;
26
+ /**
27
+ * Gets the suggested step for a graph query in ms for the currently selected time range.
28
+ */
29
+ export declare function useSuggestedStepMs(width?: number): number;
26
30
  /**
27
31
  * Provider implementation that supplies the time range state at runtime.
28
32
  */
@@ -1 +1 @@
1
- {"version":3,"file":"TimeRangeProvider.d.ts","sourceRoot":"","sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA+E,MAAM,OAAO,CAAC;AACpG,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EAGf,MAAM,kBAAkB,CAAC;AAG1B,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,cAAc,CAAC;IAC1B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC/C,kBAAkB,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IACrD,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,KAAK,IAAI,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CACrD;AAED,eAAO,MAAM,gBAAgB,sCAAkD,CAAC;AAEhF,wBAAgB,mBAAmB,cAMlC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,UAIhD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,2CAqC9D"}
@@ -12,7 +12,7 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';
15
- import { isRelativeTimeRange, toAbsoluteTimeRange } from '@perses-dev/core';
15
+ import { isRelativeTimeRange, toAbsoluteTimeRange, getSuggestedStepMs } from '@perses-dev/core';
16
16
  import { getRefreshIntervalInMs } from './refresh-interval';
17
17
  export const TimeRangeContext = /*#__PURE__*/ createContext(undefined);
18
18
  export function useTimeRangeContext() {
@@ -27,6 +27,13 @@ export function useTimeRangeContext() {
27
27
  */ export function useTimeRange() {
28
28
  return useTimeRangeContext();
29
29
  }
30
+ /**
31
+ * Gets the suggested step for a graph query in ms for the currently selected time range.
32
+ */ export function useSuggestedStepMs(width) {
33
+ const { absoluteTimeRange } = useTimeRange();
34
+ if (width === undefined) return 0;
35
+ return getSuggestedStepMs(absoluteTimeRange, width);
36
+ }
30
37
  /**
31
38
  * Provider implementation that supplies the time range state at runtime.
32
39
  */ export function TimeRangeProvider(props) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"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 React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: getRefreshIntervalInMs(localRefreshInterval),\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [localTimeRange, setTimeRange, refresh, refreshCounter, localRefreshInterval, setRefreshInterval]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","absoluteTimeRange","refreshKey","start","end","refreshIntervalInMs","Provider","value"],"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,OAAOA,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAA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AA,qBAAsBI;QAC5C;IACF,GAAG;QAACH;QAAgBF;QAAcQ;QAASF;QAAgBF;QAAsBH;KAAmB;IAEpG,qBAAO,KAACZ,iBAAiB0B,QAAQ;QAACC,OAAOxB;kBAAMO;;AACjD"}
1
+ {"version":3,"sources":["../../../src/runtime/TimeRangeProvider/TimeRangeProvider.tsx"],"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 React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AbsoluteTimeRange,\n DurationString,\n TimeRangeValue,\n isRelativeTimeRange,\n toAbsoluteTimeRange,\n getSuggestedStepMs,\n} from '@perses-dev/core';\nimport { getRefreshIntervalInMs } from './refresh-interval';\n\nexport interface TimeRangeProviderProps {\n timeRange: TimeRangeValue;\n refreshInterval?: DurationString;\n setTimeRange?: (value: TimeRangeValue) => void;\n setRefreshInterval?: (value: DurationString) => void;\n children?: React.ReactNode;\n}\n\nexport interface TimeRange {\n timeRange: TimeRangeValue;\n absoluteTimeRange: AbsoluteTimeRange; // resolved absolute time for plugins to use\n setTimeRange: (value: TimeRangeValue) => void;\n refresh: () => void;\n refreshKey: string;\n refreshInterval?: DurationString;\n refreshIntervalInMs: number;\n setRefreshInterval: (value: DurationString) => void;\n}\n\nexport const TimeRangeContext = createContext<TimeRange | undefined>(undefined);\n\nexport function useTimeRangeContext() {\n const ctx = useContext(TimeRangeContext);\n if (ctx === undefined) {\n throw new Error('No TimeRangeContext found. Did you forget a Provider?');\n }\n return ctx;\n}\n\n/**\n * Get and set the current resolved time range at runtime.\n */\nexport function useTimeRange(): TimeRange {\n return useTimeRangeContext();\n}\n\n/**\n * Gets the suggested step for a graph query in ms for the currently selected time range.\n */\nexport function useSuggestedStepMs(width?: number) {\n const { absoluteTimeRange } = useTimeRange();\n if (width === undefined) return 0;\n return getSuggestedStepMs(absoluteTimeRange, width);\n}\n\n/**\n * Provider implementation that supplies the time range state at runtime.\n */\nexport function TimeRangeProvider(props: TimeRangeProviderProps) {\n const { timeRange, refreshInterval, children, setTimeRange, setRefreshInterval } = props;\n\n const [localTimeRange, setLocalTimeRange] = useState<TimeRangeValue>(timeRange);\n const [localRefreshInterval, setLocalRefreshInterval] = useState<DurationString | undefined>(refreshInterval);\n\n const [refreshCounter, setRefreshCounter] = useState(0);\n\n useEffect(() => {\n setLocalTimeRange(timeRange);\n }, [timeRange, refreshCounter]);\n\n useEffect(() => {\n setLocalRefreshInterval(refreshInterval);\n }, [refreshInterval]);\n\n const refresh = useCallback(() => {\n setRefreshCounter((counter) => counter + 1);\n }, [setRefreshCounter]);\n\n const ctx = useMemo(() => {\n const absoluteTimeRange = isRelativeTimeRange(localTimeRange)\n ? toAbsoluteTimeRange(localTimeRange)\n : localTimeRange;\n return {\n timeRange: localTimeRange,\n setTimeRange: setTimeRange ?? setLocalTimeRange,\n absoluteTimeRange,\n refresh,\n refreshKey: `${absoluteTimeRange.start}:${absoluteTimeRange.end}:${localRefreshInterval}:${refreshCounter}`,\n refreshInterval: localRefreshInterval,\n refreshIntervalInMs: getRefreshIntervalInMs(localRefreshInterval),\n setRefreshInterval: setRefreshInterval ?? setLocalRefreshInterval,\n };\n }, [localTimeRange, setTimeRange, refresh, refreshCounter, localRefreshInterval, setRefreshInterval]);\n\n return <TimeRangeContext.Provider value={ctx}>{children}</TimeRangeContext.Provider>;\n}\n"],"names":["React","createContext","useCallback","useContext","useEffect","useMemo","useState","isRelativeTimeRange","toAbsoluteTimeRange","getSuggestedStepMs","getRefreshIntervalInMs","TimeRangeContext","undefined","useTimeRangeContext","ctx","Error","useTimeRange","useSuggestedStepMs","width","absoluteTimeRange","TimeRangeProvider","props","timeRange","refreshInterval","children","setTimeRange","setRefreshInterval","localTimeRange","setLocalTimeRange","localRefreshInterval","setLocalRefreshInterval","refreshCounter","setRefreshCounter","refresh","counter","refreshKey","start","end","refreshIntervalInMs","Provider","value"],"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,OAAOA,SAASC,aAAa,EAAEC,WAAW,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAQ;AACpG,SAIEC,mBAAmB,EACnBC,mBAAmB,EACnBC,kBAAkB,QACb,mBAAmB;AAC1B,SAASC,sBAAsB,QAAQ,qBAAqB;AAqB5D,OAAO,MAAMC,iCAAmBV,cAAqCW,WAAW;AAEhF,OAAO,SAASC;IACd,MAAMC,MAAMX,WAAWQ;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAEA;;CAEC,GACD,OAAO,SAASE;IACd,OAAOH;AACT;AAEA;;CAEC,GACD,OAAO,SAASI,mBAAmBC,KAAc;IAC/C,MAAM,EAAEC,iBAAiB,EAAE,GAAGH;IAC9B,IAAIE,UAAUN,WAAW,OAAO;IAChC,OAAOH,mBAAmBU,mBAAmBD;AAC/C;AAEA;;CAEC,GACD,OAAO,SAASE,kBAAkBC,KAA6B;IAC7D,MAAM,EAAEC,SAAS,EAAEC,eAAe,EAAEC,QAAQ,EAAEC,YAAY,EAAEC,kBAAkB,EAAE,GAAGL;IAEnF,MAAM,CAACM,gBAAgBC,kBAAkB,GAAGtB,SAAyBgB;IACrE,MAAM,CAACO,sBAAsBC,wBAAwB,GAAGxB,SAAqCiB;IAE7F,MAAM,CAACQ,gBAAgBC,kBAAkB,GAAG1B,SAAS;IAErDF,UAAU;QACRwB,kBAAkBN;IACpB,GAAG;QAACA;QAAWS;KAAe;IAE9B3B,UAAU;QACR0B,wBAAwBP;IAC1B,GAAG;QAACA;KAAgB;IAEpB,MAAMU,UAAU/B,YAAY;QAC1B8B,kBAAkB,CAACE,UAAYA,UAAU;IAC3C,GAAG;QAACF;KAAkB;IAEtB,MAAMlB,MAAMT,QAAQ;QAClB,MAAMc,oBAAoBZ,oBAAoBoB,kBAC1CnB,oBAAoBmB,kBACpBA;QACJ,OAAO;YACLL,WAAWK;YACXF,cAAcA,yBAAAA,0BAAAA,eAAgBG;YAC9BT;YACAc;YACAE,YAAY,CAAC,EAAEhB,kBAAkBiB,KAAK,CAAC,CAAC,EAAEjB,kBAAkBkB,GAAG,CAAC,CAAC,EAAER,qBAAqB,CAAC,EAAEE,eAAe,CAAC;YAC3GR,iBAAiBM;YACjBS,qBAAqB5B,uBAAuBmB;YAC5CH,oBAAoBA,+BAAAA,gCAAAA,qBAAsBI;QAC5C;IACF,GAAG;QAACH;QAAgBF;QAAcQ;QAASF;QAAgBF;QAAsBH;KAAmB;IAEpG,qBAAO,KAACf,iBAAiB4B,QAAQ;QAACC,OAAO1B;kBAAMU;;AACjD"}
@@ -4,7 +4,7 @@ import { BuiltinVariableDefinition } from '@perses-dev/core';
4
4
  import { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';
5
5
  export interface PluginRegistryContextType {
6
6
  getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;
7
- listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;
7
+ listPluginMetadata(pluginTypes: PluginType[]): Promise<PluginMetadata[]>;
8
8
  defaultPluginKinds?: DefaultPluginKinds;
9
9
  }
10
10
  export declare const PluginRegistryContext: import("react").Context<PluginRegistryContextType | undefined>;
@@ -13,22 +13,22 @@ export declare const PluginRegistryContext: import("react").Context<PluginRegist
13
13
  * be using `usePlugin` or `useListPluginMetadata` instead.
14
14
  */
15
15
  export declare function usePluginRegistry(): PluginRegistryContextType;
16
- type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType, string]>, 'queryKey' | 'queryFn'>;
16
+ type UsePluginOptions<T extends PluginType> = Omit<UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType | undefined, string]>, 'queryKey' | 'queryFn'>;
17
17
  /**
18
18
  * Loads a plugin and returns the plugin implementation, along with loading/error state.
19
19
  */
20
- export declare function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, Error>;
20
+ export declare function usePlugin<T extends PluginType>(pluginType: T | undefined, kind: string, options?: UsePluginOptions<T>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, Error>;
21
21
  /**
22
22
  * Loads a list of plugins and returns the plugin implementation, along with loading/error state.
23
23
  */
24
24
  export declare function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{
25
25
  kind: string;
26
26
  }>): import("@tanstack/react-query").UseQueryResult<PluginImplementation<T>, unknown>[];
27
- type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>, 'queryKey' | 'queryFn'>;
27
+ type UseListPluginMetadataOptions = Omit<UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType[]]>, 'queryKey' | 'queryFn'>;
28
28
  /**
29
29
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
30
30
  */
31
- export declare function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions): import("@tanstack/react-query").UseQueryResult<PluginMetadata[], Error>;
31
+ export declare function useListPluginMetadata(pluginTypes: PluginType[], options?: UseListPluginMetadataOptions): import("@tanstack/react-query").UseQueryResult<PluginMetadata[], Error>;
32
32
  export declare function usePluginBuiltinVariableDefinitions(): import("@tanstack/react-query").UseQueryResult<BuiltinVariableDefinition[], unknown>;
33
33
  export {};
34
34
  //# sourceMappingURL=plugin-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-registry.d.ts","sourceRoot":"","sources":["../../src/runtime/plugin-registry.ts"],"names":[],"mappings":";AAcA,OAAO,EAAwB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEhG,MAAM,WAAW,yBAAyB;IACxC,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/F,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IACtE,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC;AAED,eAAO,MAAM,qBAAqB,gEAAkE,CAAC;AAErG;;;GAGG;AACH,wBAAgB,iBAAiB,8BAMhC;AAGD,KAAK,gBAAgB,CAAC,CAAC,SAAS,UAAU,IAAI,IAAI,CAChD,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,EACtG,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,kFAQzG;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,OAA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,MAAM,CAAC,CAAC,EAClH,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,UAAU,EAC5C,UAAU,EAAE,CAAC,GAAG,SAAS,EACzB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,kFAS9B;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,sFAU/F;AAGD,KAAK,4BAA4B,GAAG,IAAI,CACtC,eAAe,CAAC,cAAc,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,EAClF,UAAU,GAAG,SAAS,CACvB,CAAC;AAEF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,EAAE,4BAA4B,2EAGtG;AAED,wBAAgB,mCAAmC,yFAelD"}
@@ -30,7 +30,7 @@ export const PluginRegistryContext = createContext(undefined);
30
30
  // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically
31
31
  options = {
32
32
  ...options,
33
- enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && kind !== ''
33
+ enabled: ((_options_enabled = options === null || options === void 0 ? void 0 : options.enabled) !== null && _options_enabled !== void 0 ? _options_enabled : true) && pluginType !== undefined && kind !== ''
34
34
  };
35
35
  const { getPlugin } = usePluginRegistry();
36
36
  return useQuery([
@@ -58,19 +58,21 @@ export const PluginRegistryContext = createContext(undefined);
58
58
  }
59
59
  /**
60
60
  * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.
61
- */ export function useListPluginMetadata(pluginType, options) {
61
+ */ export function useListPluginMetadata(pluginTypes, options) {
62
62
  const { listPluginMetadata } = usePluginRegistry();
63
63
  return useQuery([
64
64
  'listPluginMetadata',
65
- pluginType
66
- ], ()=>listPluginMetadata(pluginType), options);
65
+ pluginTypes
66
+ ], ()=>listPluginMetadata(pluginTypes), options);
67
67
  }
68
68
  export function usePluginBuiltinVariableDefinitions() {
69
69
  const { getPlugin, listPluginMetadata } = usePluginRegistry();
70
70
  return useQuery([
71
71
  'usePluginBuiltinVariableDefinitions'
72
72
  ], async ()=>{
73
- const datasources = await listPluginMetadata('Datasource');
73
+ const datasources = await listPluginMetadata([
74
+ 'Datasource'
75
+ ]);
74
76
  const datasourceKinds = new Set(datasources.map((datasource)=>datasource.kind));
75
77
  const result = [];
76
78
  for (const kind of datasourceKinds){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtime/plugin-registry.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 { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginType: PluginType): Promise<PluginMetadata[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry() {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(pluginType: T, kind: string, options?: UsePluginOptions<T>) {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery(['getPlugin', pluginType, kind], () => getPlugin(pluginType, kind), options);\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{ kind: string }>) {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(pluginType: PluginType, options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery(['listPluginMetadata', pluginType], () => listPluginMetadata(pluginType), options);\n}\n\nexport function usePluginBuiltinVariableDefinitions() {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery(['usePluginBuiltinVariableDefinitions'], async () => {\n const datasources = await listPluginMetadata('Datasource');\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","usePlugins","plugins","queries","map","p","queryKey","queryFn","useListPluginMetadata","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"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,SAASA,aAAa,EAAEC,UAAU,QAAQ,QAAQ;AAClD,SAASC,QAAQ,EAAEC,UAAU,QAAyB,wBAAwB;AAU9E,OAAO,MAAMC,wBAAwBJ,cAAqDK,WAAW;AAErG;;;CAGC,GACD,OAAO,SAASC;IACd,MAAMC,MAAMN,WAAWG;IACvB,IAAIG,QAAQF,WAAW;QACrB,MAAM,IAAIG,MAAM;IAClB;IACA,OAAOD;AACT;AAQA;;CAEC,GACD,OAAO,SAASE,UAAgCC,UAAa,EAAEC,IAAY,EAAEC,OAA6B;QAI5FA;IAHZ,wGAAwG;IACxGA,UAAU;QACR,GAAGA,OAAO;QACVC,SAAS,AAACD,CAAAA,CAAAA,mBAAAA,oBAAAA,8BAAAA,QAASC,OAAO,cAAhBD,8BAAAA,mBAAoB,IAAG,KAAMD,SAAS;IAClD;IACA,MAAM,EAAEG,SAAS,EAAE,GAAGR;IACtB,OAAOJ,SAAS;QAAC;QAAaQ;QAAYC;KAAK,EAAE,IAAMG,UAAUJ,YAAYC,OAAOC;AACtF;AAEA;;CAEC,GACD,OAAO,SAASG,WAAiCL,UAAa,EAAEM,OAAgC;IAC9F,MAAM,EAAEF,SAAS,EAAE,GAAGR;IACtB,OAAOH,WAAW;QAChBc,SAASD,QAAQE,GAAG,CAAC,CAACC;YACpB,OAAO;gBACLC,UAAU;oBAAC;oBAAaV;oBAAYS,EAAER,IAAI;iBAAC;gBAC3CU,SAAS,IAAMP,UAAUJ,YAAYS,EAAER,IAAI;YAC7C;QACF;IACF;AACF;AAQA;;CAEC,GACD,OAAO,SAASW,sBAAsBZ,UAAsB,EAAEE,OAAsC;IAClG,MAAM,EAAEW,kBAAkB,EAAE,GAAGjB;IAC/B,OAAOJ,SAAS;QAAC;QAAsBQ;KAAW,EAAE,IAAMa,mBAAmBb,aAAaE;AAC5F;AAEA,OAAO,SAASY;IACd,MAAM,EAAEV,SAAS,EAAES,kBAAkB,EAAE,GAAGjB;IAE1C,OAAOJ,SAAS;QAAC;KAAsC,EAAE;QACvD,MAAMuB,cAAc,MAAMF,mBAAmB;QAC7C,MAAMG,kBAAkB,IAAIC,IAAIF,YAAYP,GAAG,CAAC,CAACU,aAAeA,WAAWjB,IAAI;QAC/E,MAAMkB,SAAsC,EAAE;QAC9C,KAAK,MAAMlB,QAAQe,gBAAiB;YAClC,MAAMI,SAAS,MAAMhB,UAAU,cAAcH;YAC7C,IAAImB,OAAOC,6BAA6B,EAAE;gBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeJ,OAAOK,IAAI,CAACD;YAC7E;QACF;QACA,OAAOJ;IACT;AACF"}
1
+ {"version":3,"sources":["../../src/runtime/plugin-registry.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 { createContext, useContext } from 'react';\nimport { useQuery, useQueries, UseQueryOptions } from '@tanstack/react-query';\nimport { BuiltinVariableDefinition } from '@perses-dev/core';\nimport { DefaultPluginKinds, PluginImplementation, PluginMetadata, PluginType } from '../model';\n\nexport interface PluginRegistryContextType {\n getPlugin<T extends PluginType>(pluginType: T, kind: string): Promise<PluginImplementation<T>>;\n listPluginMetadata(pluginTypes: PluginType[]): Promise<PluginMetadata[]>;\n defaultPluginKinds?: DefaultPluginKinds;\n}\n\nexport const PluginRegistryContext = createContext<PluginRegistryContextType | undefined>(undefined);\n\n/**\n * Use the PluginRegistry context directly. This is meant as an escape hatch for custom async flows. You should probably\n * be using `usePlugin` or `useListPluginMetadata` instead.\n */\nexport function usePluginRegistry() {\n const ctx = useContext(PluginRegistryContext);\n if (ctx === undefined) {\n throw new Error('PluginRegistryContext not found. Did you forget a provider?');\n }\n return ctx;\n}\n\n// Allows consumers to pass useQuery options from react-query when loading a plugin\ntype UsePluginOptions<T extends PluginType> = Omit<\n UseQueryOptions<PluginImplementation<T>, Error, PluginImplementation<T>, [string, PluginType | undefined, string]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Loads a plugin and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugin<T extends PluginType>(\n pluginType: T | undefined,\n kind: string,\n options?: UsePluginOptions<T>\n) {\n // We never want to ask for a plugin when the kind isn't set yet, so disable those queries automatically\n options = {\n ...options,\n enabled: (options?.enabled ?? true) && pluginType !== undefined && kind !== '',\n };\n const { getPlugin } = usePluginRegistry();\n return useQuery(['getPlugin', pluginType, kind], () => getPlugin(pluginType!, kind), options);\n}\n\n/**\n * Loads a list of plugins and returns the plugin implementation, along with loading/error state.\n */\nexport function usePlugins<T extends PluginType>(pluginType: T, plugins: Array<{ kind: string }>) {\n const { getPlugin } = usePluginRegistry();\n return useQueries({\n queries: plugins.map((p) => {\n return {\n queryKey: ['getPlugin', pluginType, p.kind],\n queryFn: () => getPlugin(pluginType, p.kind),\n };\n }),\n });\n}\n\n// Allow consumers to pass useQuery options from react-query when listing metadata\ntype UseListPluginMetadataOptions = Omit<\n UseQueryOptions<PluginMetadata[], Error, PluginMetadata[], [string, PluginType[]]>,\n 'queryKey' | 'queryFn'\n>;\n\n/**\n * Gets a list of plugin metadata for the specified plugin type and returns it, along with loading/error state.\n */\nexport function useListPluginMetadata(pluginTypes: PluginType[], options?: UseListPluginMetadataOptions) {\n const { listPluginMetadata } = usePluginRegistry();\n return useQuery(['listPluginMetadata', pluginTypes], () => listPluginMetadata(pluginTypes), options);\n}\n\nexport function usePluginBuiltinVariableDefinitions() {\n const { getPlugin, listPluginMetadata } = usePluginRegistry();\n\n return useQuery(['usePluginBuiltinVariableDefinitions'], async () => {\n const datasources = await listPluginMetadata(['Datasource']);\n const datasourceKinds = new Set(datasources.map((datasource) => datasource.kind));\n const result: BuiltinVariableDefinition[] = [];\n for (const kind of datasourceKinds) {\n const plugin = await getPlugin('Datasource', kind);\n if (plugin.getBuiltinVariableDefinitions) {\n plugin.getBuiltinVariableDefinitions().forEach((definition) => result.push(definition));\n }\n }\n return result;\n });\n}\n"],"names":["createContext","useContext","useQuery","useQueries","PluginRegistryContext","undefined","usePluginRegistry","ctx","Error","usePlugin","pluginType","kind","options","enabled","getPlugin","usePlugins","plugins","queries","map","p","queryKey","queryFn","useListPluginMetadata","pluginTypes","listPluginMetadata","usePluginBuiltinVariableDefinitions","datasources","datasourceKinds","Set","datasource","result","plugin","getBuiltinVariableDefinitions","forEach","definition","push"],"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,SAASA,aAAa,EAA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;QACvD,MAAMwB,cAAc,MAAMF,mBAAmB;YAAC;SAAa;QAC3D,MAAMG,kBAAkB,IAAIC,IAAIF,YAAYR,GAAG,CAAC,CAACW,aAAeA,WAAWlB,IAAI;QAC/E,MAAMmB,SAAsC,EAAE;QAC9C,KAAK,MAAMnB,QAAQgB,gBAAiB;YAClC,MAAMI,SAAS,MAAMjB,UAAU,cAAcH;YAC7C,IAAIoB,OAAOC,6BAA6B,EAAE;gBACxCD,OAAOC,6BAA6B,GAAGC,OAAO,CAAC,CAACC,aAAeJ,OAAOK,IAAI,CAACD;YAC7E;QACF;QACA,OAAOJ;IACT;AACF"}
@@ -11,6 +11,6 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
  import { z } from 'zod';
14
- export const resourceIdValidationSchema = z.string().nonempty('Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
14
+ export const resourceIdValidationSchema = z.string().min(1, 'Required').max(75, 'Must be 75 or fewer characters long').regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');
15
15
 
16
16
  //# sourceMappingURL=resource.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/validation/resource.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\n\nexport const resourceIdValidationSchema = z\n .string()\n .nonempty('Required')\n .max(75, 'Must be 75 or fewer characters long')\n .regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');\n"],"names":["z","resourceIdValidationSchema","string","nonempty","max","regex"],"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,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,6BAA6BD,EACvCE,MAAM,GACNC,QAAQ,CAAC,YACTC,GAAG,CAAC,IAAI,uCACRC,KAAK,CAAC,qBAAqB,6EAA6E"}
1
+ {"version":3,"sources":["../../src/validation/resource.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { z } from 'zod';\n\nexport const resourceIdValidationSchema = z\n .string()\n .min(1, 'Required')\n .max(75, 'Must be 75 or fewer characters long')\n .regex(/^[a-zA-Z0-9_.-]+$/, 'Must only contains alphanumerical characters and special characters _ . -');\n"],"names":["z","resourceIdValidationSchema","string","min","max","regex"],"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,SAASA,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,6BAA6BD,EACvCE,MAAM,GACNC,GAAG,CAAC,GAAG,YACPC,GAAG,CAAC,IAAI,uCACRC,KAAK,CAAC,qBAAqB,6EAA6E"}
@@ -0,0 +1,93 @@
1
+ import { z } from 'zod';
2
+ export declare const userEditorValidationSchema: z.ZodObject<{
3
+ kind: z.ZodLiteral<"User">;
4
+ metadata: z.ZodObject<{
5
+ name: z.ZodString;
6
+ }, "strip", z.ZodTypeAny, {
7
+ name: string;
8
+ }, {
9
+ name: string;
10
+ }>;
11
+ spec: z.ZodObject<{
12
+ firstName: z.ZodOptional<z.ZodString>;
13
+ lastName: z.ZodOptional<z.ZodString>;
14
+ nativeProvider: z.ZodOptional<z.ZodObject<{
15
+ password: z.ZodOptional<z.ZodString>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ password?: string | undefined;
18
+ }, {
19
+ password?: string | undefined;
20
+ }>>;
21
+ oauthProviders: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
+ issuer: z.ZodOptional<z.ZodString>;
23
+ email: z.ZodOptional<z.ZodString>;
24
+ subject: z.ZodOptional<z.ZodString>;
25
+ }, "strip", z.ZodTypeAny, {
26
+ issuer?: string | undefined;
27
+ email?: string | undefined;
28
+ subject?: string | undefined;
29
+ }, {
30
+ issuer?: string | undefined;
31
+ email?: string | undefined;
32
+ subject?: string | undefined;
33
+ }>, "many">>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ firstName?: string | undefined;
36
+ lastName?: string | undefined;
37
+ nativeProvider?: {
38
+ password?: string | undefined;
39
+ } | undefined;
40
+ oauthProviders?: {
41
+ issuer?: string | undefined;
42
+ email?: string | undefined;
43
+ subject?: string | undefined;
44
+ }[] | undefined;
45
+ }, {
46
+ firstName?: string | undefined;
47
+ lastName?: string | undefined;
48
+ nativeProvider?: {
49
+ password?: string | undefined;
50
+ } | undefined;
51
+ oauthProviders?: {
52
+ issuer?: string | undefined;
53
+ email?: string | undefined;
54
+ subject?: string | undefined;
55
+ }[] | undefined;
56
+ }>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ kind: "User";
59
+ spec: {
60
+ firstName?: string | undefined;
61
+ lastName?: string | undefined;
62
+ nativeProvider?: {
63
+ password?: string | undefined;
64
+ } | undefined;
65
+ oauthProviders?: {
66
+ issuer?: string | undefined;
67
+ email?: string | undefined;
68
+ subject?: string | undefined;
69
+ }[] | undefined;
70
+ };
71
+ metadata: {
72
+ name: string;
73
+ };
74
+ }, {
75
+ kind: "User";
76
+ spec: {
77
+ firstName?: string | undefined;
78
+ lastName?: string | undefined;
79
+ nativeProvider?: {
80
+ password?: string | undefined;
81
+ } | undefined;
82
+ oauthProviders?: {
83
+ issuer?: string | undefined;
84
+ email?: string | undefined;
85
+ subject?: string | undefined;
86
+ }[] | undefined;
87
+ };
88
+ metadata: {
89
+ name: string;
90
+ };
91
+ }>;
92
+ export type UserEditorValidationType = z.infer<typeof userEditorValidationSchema>;
93
+ //# sourceMappingURL=user.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/validation/user.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAqBxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMrC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
@@ -0,0 +1,38 @@
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
+ import { z } from 'zod';
14
+ import { resourceIdValidationSchema } from './resource';
15
+ const nativeProviderSchema = z.object({
16
+ password: z.string().optional()
17
+ });
18
+ const oauthProvidersSchema = z.object({
19
+ issuer: z.string().optional(),
20
+ email: z.string().optional(),
21
+ subject: z.string().optional()
22
+ });
23
+ // TODO: handle exclusion native / oauth?
24
+ const userSpecSchema = z.object({
25
+ firstName: z.string().optional(),
26
+ lastName: z.string().optional(),
27
+ nativeProvider: nativeProviderSchema.optional(),
28
+ oauthProviders: z.array(oauthProvidersSchema).optional()
29
+ });
30
+ export const userEditorValidationSchema = z.object({
31
+ kind: z.literal('User'),
32
+ metadata: z.object({
33
+ name: resourceIdValidationSchema
34
+ }),
35
+ spec: userSpecSchema
36
+ });
37
+
38
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/validation/user.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 { z } from 'zod';\nimport { resourceIdValidationSchema } from './resource';\n\nconst nativeProviderSchema = z.object({\n password: z.string().optional(),\n});\n\nconst oauthProvidersSchema = z.object({\n issuer: z.string().optional(),\n email: z.string().optional(),\n subject: z.string().optional(),\n});\n\n// TODO: handle exclusion native / oauth?\nconst userSpecSchema = z.object({\n firstName: z.string().optional(),\n lastName: z.string().optional(),\n nativeProvider: nativeProviderSchema.optional(),\n oauthProviders: z.array(oauthProvidersSchema).optional(),\n});\n\nexport const userEditorValidationSchema = z.object({\n kind: z.literal('User'),\n metadata: z.object({\n name: resourceIdValidationSchema,\n }),\n spec: userSpecSchema,\n});\n\nexport type UserEditorValidationType = z.infer<typeof userEditorValidationSchema>;\n"],"names":["z","resourceIdValidationSchema","nativeProviderSchema","object","password","string","optional","oauthProvidersSchema","issuer","email","subject","userSpecSchema","firstName","lastName","nativeProvider","oauthProviders","array","userEditorValidationSchema","kind","literal","metadata","name","spec"],"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,SAASA,CAAC,QAAQ,MAAM;AACxB,SAASC,0BAA0B,QAAQ,aAAa;AAExD,MAAMC,uBAAuBF,EAAEG,MAAM,CAAC;IACpCC,UAAUJ,EAAEK,MAAM,GAAGC,QAAQ;AAC/B;AAEA,MAAMC,uBAAuBP,EAAEG,MAAM,CAAC;IACpCK,QAAQR,EAAEK,MAAM,GAAGC,QAAQ;IAC3BG,OAAOT,EAAEK,MAAM,GAAGC,QAAQ;IAC1BI,SAASV,EAAEK,MAAM,GAAGC,QAAQ;AAC9B;AAEA,yCAAyC;AACzC,MAAMK,iBAAiBX,EAAEG,MAAM,CAAC;IAC9BS,WAAWZ,EAAEK,MAAM,GAAGC,QAAQ;IAC9BO,UAAUb,EAAEK,MAAM,GAAGC,QAAQ;IAC7BQ,gBAAgBZ,qBAAqBI,QAAQ;IAC7CS,gBAAgBf,EAAEgB,KAAK,CAACT,sBAAsBD,QAAQ;AACxD;AAEA,OAAO,MAAMW,6BAA6BjB,EAAEG,MAAM,CAAC;IACjDe,MAAMlB,EAAEmB,OAAO,CAAC;IAChBC,UAAUpB,EAAEG,MAAM,CAAC;QACjBkB,MAAMpB;IACR;IACAqB,MAAMX;AACR,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/plugin-system",
3
- "version": "0.44.0",
3
+ "version": "0.45.0-rc0",
4
4
  "description": "The plugin feature in Pereses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -28,8 +28,8 @@
28
28
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
29
29
  },
30
30
  "dependencies": {
31
- "@perses-dev/components": "0.44.0",
32
- "@perses-dev/core": "0.44.0",
31
+ "@perses-dev/components": "0.45.0-rc0",
32
+ "@perses-dev/core": "0.45.0-rc0",
33
33
  "date-fns": "^2.30.0",
34
34
  "immer": "^9.0.15",
35
35
  "react-hook-form": "^7.46.1",
@@ -38,7 +38,7 @@
38
38
  "zod": "^3.22.2"
39
39
  },
40
40
  "devDependencies": {
41
- "@perses-dev/storybook": "0.44.0"
41
+ "@perses-dev/storybook": "0.45.0-rc0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@mui/material": "^5.10.0",
@@ -1,143 +0,0 @@
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
- "use strict";
14
- Object.defineProperty(exports, "__esModule", {
15
- value: true
16
- });
17
- Object.defineProperty(exports, "TraceQueryEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return TraceQueryEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _material = require("@mui/material");
25
- const _Plus = /*#__PURE__*/ _interop_require_default(require("mdi-material-ui/Plus"));
26
- const _react = require("react");
27
- const _immer = require("immer");
28
- const _runtime = require("../../runtime");
29
- const _TraceQueryInput = require("./TraceQueryInput");
30
- function _interop_require_default(obj) {
31
- return obj && obj.__esModule ? obj : {
32
- default: obj
33
- };
34
- }
35
- const DEFAULT_QUERY_PLUGIN_TYPE = 'TraceQuery';
36
- function TraceQueryEditor({ queries = [], onChange }) {
37
- const hasMoreThanOneQuery = queries.length > 1;
38
- const defaultTraceQueryKind = 'TempoTraceQuery';
39
- // State for which queries are collapsed
40
- // TODO: Would be easier if we had IDs for queries.
41
- const [queriesCollapsed, setQueriesCollapsed] = (0, _react.useState)(queries.map(()=>false));
42
- const { data: defaultQueryPlugin } = (0, _runtime.usePlugin)(DEFAULT_QUERY_PLUGIN_TYPE, defaultTraceQueryKind, {
43
- useErrorBoundary: true,
44
- enabled: true
45
- });
46
- // Query handlers
47
- const handleQueryChange = (index, queryDef)=>{
48
- onChange((0, _immer.produce)(queries, (draft)=>{
49
- if (draft) {
50
- draft[index] = queryDef;
51
- } else {
52
- draft = [
53
- queryDef
54
- ];
55
- }
56
- }));
57
- };
58
- const handleQueryAdd = ()=>{
59
- if (!defaultQueryPlugin) return;
60
- onChange((0, _immer.produce)(queries, (draft)=>{
61
- const queryDef = {
62
- kind: DEFAULT_QUERY_PLUGIN_TYPE,
63
- spec: {
64
- plugin: {
65
- kind: defaultTraceQueryKind,
66
- spec: defaultQueryPlugin.createInitialOptions()
67
- }
68
- }
69
- };
70
- if (draft) {
71
- draft.push(queryDef);
72
- } else {
73
- draft = [
74
- ...queries,
75
- queryDef
76
- ];
77
- }
78
- }));
79
- setQueriesCollapsed((queriesCollapsed)=>{
80
- queriesCollapsed.push(false);
81
- return [
82
- ...queriesCollapsed
83
- ];
84
- });
85
- };
86
- const handleQueryDelete = (index)=>{
87
- onChange((0, _immer.produce)(queries, (draft)=>{
88
- draft.splice(index, 1);
89
- }));
90
- setQueriesCollapsed((queriesCollapsed)=>{
91
- queriesCollapsed.splice(index, 1);
92
- return [
93
- ...queriesCollapsed
94
- ];
95
- });
96
- };
97
- const handleQueryCollapseExpand = (index)=>{
98
- setQueriesCollapsed((queriesCollapsed)=>{
99
- queriesCollapsed[index] = !queriesCollapsed[index];
100
- return [
101
- ...queriesCollapsed
102
- ];
103
- });
104
- };
105
- // show one query input if queries is empty
106
- const queryDefinitions = queries.length ? queries : [
107
- {
108
- kind: 'TraceQuery',
109
- spec: {
110
- plugin: {
111
- kind: 'TempoTraceQuery',
112
- spec: {
113
- query: ''
114
- }
115
- }
116
- }
117
- }
118
- ];
119
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
120
- children: [
121
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Stack, {
122
- spacing: 1,
123
- children: queryDefinitions.map((query, i)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_TraceQueryInput.TraceQueryInput, {
124
- index: i,
125
- query: query,
126
- isCollapsed: !!queriesCollapsed[i],
127
- onChange: handleQueryChange,
128
- onDelete: hasMoreThanOneQuery ? handleQueryDelete : undefined,
129
- onCollapseExpand: handleQueryCollapseExpand
130
- }, i))
131
- }),
132
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
133
- variant: "contained",
134
- startIcon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Plus.default, {}),
135
- sx: {
136
- marginTop: 1
137
- },
138
- onClick: handleQueryAdd,
139
- children: "Add Query"
140
- })
141
- ]
142
- });
143
- }