@omniviewdev/runtime 0.0.0-nightly.20260225

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 (111) hide show
  1. package/LICENSE +661 -0
  2. package/dist/Client-DGdSmmVk.js +585 -0
  3. package/dist/Client-ES-O5dCV.cjs +1 -0
  4. package/dist/api.cjs +1 -0
  5. package/dist/api.d.ts +13 -0
  6. package/dist/api.js +120 -0
  7. package/dist/context/drawer/BottomDrawerContext.d.ts +20 -0
  8. package/dist/context/drawer/RightDrawerContext.d.ts +15 -0
  9. package/dist/context/drawer/index.d.ts +3 -0
  10. package/dist/context/drawer/types.d.ts +222 -0
  11. package/dist/context/index.d.ts +5 -0
  12. package/dist/context/modal/ConfirmationModalContext.d.ts +12 -0
  13. package/dist/context/modal/index.d.ts +1 -0
  14. package/dist/context/operations/OperationsContext.d.ts +27 -0
  15. package/dist/context/plugins/PluginContext.d.ts +9 -0
  16. package/dist/context/plugins/PluginContextProvider.d.ts +5 -0
  17. package/dist/context/plugins/index.d.ts +3 -0
  18. package/dist/context/plugins/usePluginContext.d.ts +3 -0
  19. package/dist/context/settings/SettingsContext.d.ts +9 -0
  20. package/dist/context/settings/index.d.ts +1 -0
  21. package/dist/errors/index.d.ts +3 -0
  22. package/dist/errors/parseAppError.d.ts +51 -0
  23. package/dist/errors/parseAppError.test.d.ts +1 -0
  24. package/dist/errors/types.d.ts +40 -0
  25. package/dist/extensions/index.d.ts +2 -0
  26. package/dist/extensions/points/resource/helpers.d.ts +19 -0
  27. package/dist/extensions/points/resource/types.d.ts +6 -0
  28. package/dist/extensions/provider.d.ts +18 -0
  29. package/dist/extensions/registry.d.ts +30 -0
  30. package/dist/extensions/utils.d.ts +4 -0
  31. package/dist/hooks/connection/index.d.ts +4 -0
  32. package/dist/hooks/connection/useConnection.d.ts +37 -0
  33. package/dist/hooks/connection/useConnectionNamespaces.d.ts +20 -0
  34. package/dist/hooks/connection/useConnectionStatus.d.ts +29 -0
  35. package/dist/hooks/connection/useConnections.d.ts +18 -0
  36. package/dist/hooks/data/index.d.ts +1 -0
  37. package/dist/hooks/data/usePluginData.d.ts +11 -0
  38. package/dist/hooks/drawer/index.d.ts +2 -0
  39. package/dist/hooks/drawer/useBottomDrawer.d.ts +1 -0
  40. package/dist/hooks/drawer/useRightDrawer.d.ts +5 -0
  41. package/dist/hooks/exec/index.d.ts +1 -0
  42. package/dist/hooks/exec/useExecSession.d.ts +21 -0
  43. package/dist/hooks/index.d.ts +13 -0
  44. package/dist/hooks/logs/index.d.ts +1 -0
  45. package/dist/hooks/logs/useLogSession.d.ts +21 -0
  46. package/dist/hooks/metric/index.d.ts +3 -0
  47. package/dist/hooks/metric/useMetricProviders.d.ts +9 -0
  48. package/dist/hooks/metric/useMetricStream.d.ts +40 -0
  49. package/dist/hooks/metric/useResourceMetrics.d.ts +46 -0
  50. package/dist/hooks/modal/index.d.ts +1 -0
  51. package/dist/hooks/modal/useConfirmationModal.d.ts +5 -0
  52. package/dist/hooks/networker/index.d.ts +3 -0
  53. package/dist/hooks/networker/types.d.ts +50 -0
  54. package/dist/hooks/networker/usePortForwardSessions.d.ts +13 -0
  55. package/dist/hooks/networker/useResourcePortForwarder.d.ts +21 -0
  56. package/dist/hooks/operations/useOperations.d.ts +1 -0
  57. package/dist/hooks/resource/index.d.ts +13 -0
  58. package/dist/hooks/resource/useActiveSyncs.d.ts +16 -0
  59. package/dist/hooks/resource/useEditorSchemas.d.ts +22 -0
  60. package/dist/hooks/resource/useInformerState.d.ts +24 -0
  61. package/dist/hooks/resource/useResource.d.ts +74 -0
  62. package/dist/hooks/resource/useResourceActions.d.ts +69 -0
  63. package/dist/hooks/resource/useResourceAreaComponent.d.ts +9 -0
  64. package/dist/hooks/resource/useResourceGroups.d.ts +22 -0
  65. package/dist/hooks/resource/useResourceMutations.d.ts +58 -0
  66. package/dist/hooks/resource/useResourceSearch.d.ts +36 -0
  67. package/dist/hooks/resource/useResourceType.d.ts +22 -0
  68. package/dist/hooks/resource/useResourceTypes.d.ts +22 -0
  69. package/dist/hooks/resource/useResources.d.ts +73 -0
  70. package/dist/hooks/resource/useStreamAction.d.ts +21 -0
  71. package/dist/hooks/settings/index.d.ts +1 -0
  72. package/dist/hooks/settings/useSettings.d.ts +2 -0
  73. package/dist/hooks/snackbar/index.d.ts +1 -0
  74. package/dist/hooks/snackbar/useSnackbar.d.ts +24 -0
  75. package/dist/hooks/useResolvedPluginId.d.ts +8 -0
  76. package/dist/index.cjs +2 -0
  77. package/dist/index.d.ts +6 -0
  78. package/dist/index.js +2593 -0
  79. package/dist/models.cjs +1 -0
  80. package/dist/models.d.ts +1 -0
  81. package/dist/models.js +1915 -0
  82. package/dist/router/Link.d.ts +24 -0
  83. package/dist/router/index.d.ts +11 -0
  84. package/dist/router/usePluginRouter.d.ts +40 -0
  85. package/dist/runtime.cjs +1 -0
  86. package/dist/runtime.d.ts +1 -0
  87. package/dist/runtime.js +215 -0
  88. package/dist/types/app.d.ts +73 -0
  89. package/dist/types/extensions.d.ts +186 -0
  90. package/dist/types/index.d.ts +4 -0
  91. package/dist/types/informer.d.ts +49 -0
  92. package/dist/types/plugin.d.ts +5 -0
  93. package/dist/utils/activeSyncAggregator.d.ts +29 -0
  94. package/dist/utils/activeSyncAggregator.test.d.ts +1 -0
  95. package/dist/wailsjs/go/data/Client.d.ts +10 -0
  96. package/dist/wailsjs/go/devserver/DevServerManager.d.ts +22 -0
  97. package/dist/wailsjs/go/diagnostics/DiagnosticsClient.d.ts +18 -0
  98. package/dist/wailsjs/go/exec/Client.d.ts +26 -0
  99. package/dist/wailsjs/go/logs/Client.d.ts +16 -0
  100. package/dist/wailsjs/go/main/App.d.ts +8 -0
  101. package/dist/wailsjs/go/metric/Client.d.ts +12 -0
  102. package/dist/wailsjs/go/models.d.ts +894 -0
  103. package/dist/wailsjs/go/networker/Client.d.ts +14 -0
  104. package/dist/wailsjs/go/plugin/pluginManager.d.ts +52 -0
  105. package/dist/wailsjs/go/resource/Client.d.ts +68 -0
  106. package/dist/wailsjs/go/settings/Client.d.ts +14 -0
  107. package/dist/wailsjs/go/settings/provider.d.ts +46 -0
  108. package/dist/wailsjs/go/ui/Client.d.ts +6 -0
  109. package/dist/wailsjs/go/utils/Client.d.ts +2 -0
  110. package/dist/wailsjs/runtime/runtime.d.ts +249 -0
  111. package/package.json +68 -0
@@ -0,0 +1,22 @@
1
+ type UseResourceGroupsOptions = {
2
+ /**
3
+ * The ID of the category responsible for this resource
4
+ * @example "appearance"
5
+ */
6
+ pluginID?: string;
7
+ /**
8
+ * The ID of the connection
9
+ */
10
+ connectionID: string;
11
+ };
12
+ /**
13
+ * Interact with a category of settings from the global settings provider. Intended for use in the settings UI - if
14
+ * you need to read or write settings from a specific plugin, use the `@hooks/settings/useSettings` hook instead.
15
+ */
16
+ export declare const useResourceGroups: ({ pluginID: explicitPluginID, connectionID }: UseResourceGroupsOptions) => {
17
+ /**
18
+ * The current settings from the provider.
19
+ */
20
+ groups: import('@tanstack/react-query').UseQueryResult<Record<string, import("../../models").types.ResourceGroup>, Error>;
21
+ };
22
+ export default useResourceGroups;
@@ -0,0 +1,58 @@
1
+ import { types } from '../../wailsjs/go/models';
2
+ type ResourceMutationOptions = {
3
+ /**
4
+ * The connection ID to scope the resource to
5
+ * @example "integration"
6
+ */
7
+ connectionID: string;
8
+ /**
9
+ * The GVR (Group, Version, Resource) identifier to fetch
10
+ * @example "core::v1::pods"
11
+ */
12
+ resourceKey: string;
13
+ /**
14
+ * The ID of the resource to fetch
15
+ * @example "nginx-1452"
16
+ */
17
+ resourceID: string;
18
+ /**
19
+ * Optional namespace to scope the resource to, if the backend
20
+ * supports the concept of namespaces of resources.
21
+ * @example "default"
22
+ */
23
+ namespace?: string;
24
+ /**
25
+ * Optional parameters to pass to the call
26
+ * @example { labelSelector: "app=nginx" }
27
+ */
28
+ params?: Record<string, unknown>;
29
+ };
30
+ type UseResourceMutationsOptions = {
31
+ /**
32
+ * The ID of the plugin responsible for this resource
33
+ * @example "kubernetes"
34
+ */
35
+ pluginID?: string;
36
+ };
37
+ /**
38
+ * The useResource hook returns a hook, scoped to the desired resource and connection, that allows for interacting
39
+ * with, and fetching, the resource data.
40
+ *
41
+ * It should be noted that this hook does not perform any logic to ensure that either the resource exists,
42
+ * @throws If the resourceID is invalid
43
+ */
44
+ export declare const useResourceMutations: ({ pluginID: explicitPluginID }: UseResourceMutationsOptions) => {
45
+ create: import('@tanstack/react-query').UseMutateAsyncFunction<types.CreateResult, unknown, {
46
+ opts: ResourceMutationOptions;
47
+ input: Partial<types.CreateInput>;
48
+ }, unknown>;
49
+ update: import('@tanstack/react-query').UseMutateAsyncFunction<types.UpdateResult, unknown, {
50
+ opts: ResourceMutationOptions;
51
+ input: Partial<types.UpdateInput>;
52
+ }, unknown>;
53
+ remove: import('@tanstack/react-query').UseMutateAsyncFunction<types.DeleteResult, unknown, {
54
+ opts: ResourceMutationOptions;
55
+ input: Partial<types.DeleteInput>;
56
+ }, unknown>;
57
+ };
58
+ export default useResourceMutations;
@@ -0,0 +1,36 @@
1
+ type UseResourceSearchOptions = {
2
+ /**
3
+ * The ID of the plugin responsible for this resource
4
+ * @example "kubernetes"
5
+ */
6
+ pluginID?: string;
7
+ /**
8
+ * The connection ID to scope the resource to
9
+ * @example "integration"
10
+ */
11
+ connectionID: string;
12
+ /**
13
+ * Entry for the resource search
14
+ */
15
+ searches: ResourceSearchEntry[];
16
+ };
17
+ type ResourceSearchEntry = {
18
+ /**
19
+ * The key of the resource
20
+ */
21
+ key: string;
22
+ /**
23
+ * The namespaces to search for the resource
24
+ */
25
+ namespaces: string[];
26
+ /**
27
+ * Post-retrieve function filter to apply after the resources are found
28
+ */
29
+ postFilter?: (resource: unknown) => boolean;
30
+ };
31
+ /**
32
+ * The useResourceSearch is a utility hook to search across multiple resources and/or namespaces. This hook is currently
33
+ * limited searching within a single plugin, and a single connection.
34
+ */
35
+ export declare const useResourceSearch: ({ pluginID: explicitPluginID, connectionID, searches, }: UseResourceSearchOptions) => import('@tanstack/react-query').UseQueryResult<any[], Error>[];
36
+ export default useResourceSearch;
@@ -0,0 +1,22 @@
1
+ type UseResourceTypesOptions = {
2
+ /**
3
+ * The ID of the category responsible for this resource
4
+ * @example "appearance"
5
+ */
6
+ pluginID?: string;
7
+ /**
8
+ * The key of the resource to fetch
9
+ */
10
+ resourceKey: string;
11
+ };
12
+ /**
13
+ * Interact with a category of settings from the global settings provider. Intended for use in the settings UI - if
14
+ * you need to read or write settings from a specific plugin, use the `@hooks/settings/useSettings` hook instead.
15
+ */
16
+ export declare const useResourceType: ({ pluginID: explicitPluginID, resourceKey }: UseResourceTypesOptions) => {
17
+ /**
18
+ * The current settings from the provider.
19
+ */
20
+ resourceType: import('@tanstack/react-query').UseQueryResult<import("../../models").types.ResourceMeta, Error>;
21
+ };
22
+ export default useResourceType;
@@ -0,0 +1,22 @@
1
+ type UseResourceTypesOptions = {
2
+ /**
3
+ * The ID of the category responsible for this resource
4
+ * @example "appearance"
5
+ */
6
+ pluginID?: string;
7
+ /**
8
+ * The ID of the connection
9
+ */
10
+ connectionID: string;
11
+ };
12
+ /**
13
+ * Interact with a category of settings from the global settings provider. Intended for use in the settings UI - if
14
+ * you need to read or write settings from a specific plugin, use the `@hooks/settings/useSettings` hook instead.
15
+ */
16
+ export declare const useResourceTypes: ({ pluginID: explicitPluginID, connectionID }: UseResourceTypesOptions) => {
17
+ /**
18
+ * The current settings from the provider.
19
+ */
20
+ types: import('@tanstack/react-query').UseQueryResult<Record<string, import("../../models").types.ResourceMeta>, Error>;
21
+ };
22
+ export {};
@@ -0,0 +1,73 @@
1
+ import { types } from '../../wailsjs/go/models';
2
+ import { InformerResourceState } from '../../types/informer';
3
+ type UseResourcesOptions = {
4
+ /**
5
+ * The ID of the plugin responsible for this resource
6
+ * @example "kubernetes"
7
+ */
8
+ pluginID?: string;
9
+ /**
10
+ * The connection ID to scope the resource to
11
+ * @example "integration"
12
+ */
13
+ connectionID: string;
14
+ /**
15
+ * The GVR (Group, Version, Resource) identifier to fetch
16
+ * @example "core::v1::pods"
17
+ */
18
+ resourceKey: string;
19
+ /**
20
+ * Optional namespace to scope the resource to, if the backend
21
+ * supports the concept of namespaces of resources. If the backend
22
+ * supports the concept of namespaces, and this is not provided,
23
+ * it will default to selecting from all namespaces.
24
+ * @example "default"
25
+ */
26
+ namespaces?: string[];
27
+ /**
28
+ * The dot-delimited path on which id's can be used for updates. In order for the informer
29
+ * live functionality to work, this must be set to the path on which the ID is located.
30
+ */
31
+ idAccessor?: string;
32
+ /**
33
+ * Optional parameters to pass to the resource fetch
34
+ * @example { labelSelector: "app=nginx" }
35
+ */
36
+ listParams?: Record<string, unknown>;
37
+ /**
38
+ * Optional parameters to pass to the resource create
39
+ * @example { dryRun: true }
40
+ */
41
+ createParams?: Record<string, unknown>;
42
+ };
43
+ /**
44
+ * The useResource hook returns a hook, scoped to the desired resource and connection, that allows for interacting
45
+ * with, and fetching, the resource data.
46
+ *
47
+ * It should be noted that this hook does not perform any logic to ensure that either the resource exists,
48
+ * @throws If the resourceID is invalid
49
+ */
50
+ export declare const useResources: ({ pluginID: explicitPluginID, connectionID, resourceKey, idAccessor, namespaces, listParams, createParams, }: UseResourcesOptions) => {
51
+ /**
52
+ * Fetch result for the resource. The client will automatically cache the result, and update the cache
53
+ * when the resources are updated or deleted via the returned create and remove mutation functions, or
54
+ * the per-resource hook mutation functions.
55
+ */
56
+ resources: import('@tanstack/react-query').UseQueryResult<types.ListResult, Error>;
57
+ /**
58
+ * Create a new resource. A set of optional parameters can be passed to customize the create behavior,
59
+ * which if specified, will add additional default behavior set via the hook options.
60
+ *
61
+ * @params opts Optional parameters to pass to the resource create operation
62
+ */
63
+ create: import('@tanstack/react-query').UseMutateAsyncFunction<types.CreateResult, unknown, Partial<types.CreateInput>, unknown>;
64
+ /** Current informer state for this resource type */
65
+ informerState: InformerResourceState;
66
+ /** Whether the informer is currently syncing */
67
+ isSyncing: boolean;
68
+ /** Whether the informer has fully synced */
69
+ isSynced: boolean;
70
+ /** Whether the informer encountered an error */
71
+ informerError: boolean;
72
+ };
73
+ export {};
@@ -0,0 +1,21 @@
1
+ type UseStreamActionOptions = {
2
+ pluginID?: string;
3
+ connectionID: string;
4
+ resourceKey: string;
5
+ };
6
+ type StartStreamActionParams = {
7
+ actionID: string;
8
+ id: string;
9
+ namespace: string;
10
+ label: string;
11
+ params?: Record<string, unknown>;
12
+ };
13
+ /**
14
+ * useStreamAction provides a function to start a streaming action,
15
+ * automatically subscribing to Wails events and tracking the operation
16
+ * in the OperationsContext.
17
+ */
18
+ export declare const useStreamAction: ({ pluginID: explicitPluginID, connectionID, resourceKey, }: UseStreamActionOptions) => {
19
+ startStreamAction: ({ actionID, id, namespace, label, params }: StartStreamActionParams) => Promise<string>;
20
+ };
21
+ export {};
@@ -0,0 +1 @@
1
+ export * from './useSettings';
@@ -0,0 +1,2 @@
1
+ import { SettingsContextType } from '../../context/settings/SettingsContext';
2
+ export declare const useSettings: () => SettingsContextType;
@@ -0,0 +1 @@
1
+ export * from './useSnackbar';
@@ -0,0 +1,24 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ type VariantType = 'default' | 'success' | 'error' | 'warning' | 'info';
3
+ type SnackbarContextType = {
4
+ showSnackbar(message: string, status: VariantType, icon?: string, details?: string): void;
5
+ showSnackbar(options: ShowSnackbarOptions): void;
6
+ };
7
+ type SnackbarProviderProps = {
8
+ children: ReactNode;
9
+ };
10
+ type ShowSnackbarOptions = {
11
+ message: string;
12
+ status: VariantType;
13
+ icon?: string;
14
+ details?: string;
15
+ showOnce?: boolean;
16
+ autoHideDuration?: number;
17
+ actions?: Array<{
18
+ label: string;
19
+ onClick: () => void;
20
+ }>;
21
+ };
22
+ export declare const SnackbarProvider: React.FC<SnackbarProviderProps>;
23
+ export declare const useSnackbar: () => SnackbarContextType;
24
+ export default useSnackbar;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Resolves the pluginID to use for API calls and event subscriptions.
3
+ *
4
+ * Prefers the pluginID from PluginContext (set by the framework when a
5
+ * plugin is mounted). Falls back to an explicit value when no context is
6
+ * available (e.g. host-app code calling a hook directly).
7
+ */
8
+ export declare function useResolvedPluginId(explicit?: string): string;
package/dist/index.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";var Nt=Object.defineProperty;var kt=(e,t,n)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var $=(e,t,n)=>kt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),d=require("react"),X=require("react-router-dom"),m=require("./Client-ES-O5dCV.cjs"),F=require("./models.cjs"),g=require("@tanstack/react-query"),$t=require("@omniviewdev/ui/feedback"),I=require("./runtime.cjs"),de=d.createContext(void 0),ie={PLUGIN_NOT_FOUND:"omniview:plugin/not-found",PLUGIN_NOT_LOADED:"omniview:plugin/not-loaded",PLUGIN_ALREADY_LOADED:"omniview:plugin/already-loaded",PLUGIN_INSTALL_FAILED:"omniview:plugin/install-failed",PLUGIN_LOAD_FAILED:"omniview:plugin/load-failed",PLUGIN_BUILD_FAILED:"omniview:plugin/build-failed",SETTINGS_MISSING_CONFIG:"omniview:settings/missing-config",SETTINGS_INVALID_CONFIG:"omniview:settings/invalid-config",RESOURCE_NOT_FOUND:"omniview:resource/not-found",RESOURCE_FORBIDDEN:"omniview:resource/forbidden",RESOURCE_UNAUTHORIZED:"omniview:resource/unauthorized",RESOURCE_CONFLICT:"omniview:resource/conflict",RESOURCE_TIMEOUT:"omniview:resource/timeout",CONNECTION_NOT_FOUND:"omniview:connection/not-found",CONNECTION_FAILED:"omniview:connection/failed",SESSION_NOT_FOUND:"omniview:session/not-found",SESSION_FAILED:"omniview:session/failed",CANCELLED:"omniview:cancelled",INTERNAL:"omniview:internal",VALIDATION:"omniview:validation",NOT_IMPLEMENTED:"omniview:not-implemented"};function q(e){if(e==null)return{type:ie.INTERNAL,title:"Unknown error",status:500,detail:"An unknown error occurred."};let t;if(typeof e=="string"?t=e:e instanceof Error?t=e.message:t=String(e),t.startsWith("{"))try{const n=JSON.parse(t);if(typeof n.type=="string"&&typeof n.title=="string"&&typeof n.status=="number"&&typeof n.detail=="string")return n}catch{}return{type:ie.INTERNAL,title:"Error",status:500,detail:t}}function Ae(e){return e==null?!1:(typeof e=="string"?e:e instanceof Error?e.message:String(e))==="cancelled"?!0:q(e).type===ie.CANCELLED}function rt(e){switch(e.type){case"navigate":return{label:e.label,onClick:()=>{window.location.hash=e.target??""}};case"open-url":return{label:e.label,onClick:()=>{window.open(e.target,"_blank")}};case"copy":return{label:e.label,onClick:()=>{navigator.clipboard.writeText(e.target??"")}};case"retry":return{label:e.label,onClick:()=>{}};default:return{label:e.label,onClick:()=>{}}}}function st(e,t){var s,i;const n=[e.detail,...((s=e.suggestions)==null?void 0:s.map(o=>`• ${o}`))??[]].join(`
2
+ `);return{message:t||(e.title!=="Error"?e.title:"Operation failed"),status:"error",details:n,actions:(i=e.actions)==null?void 0:i.map(rt)}}function G(e,t,n){if(Ae(t))return;const r=q(t);e(st(r,n))}function A(e,t){return n=>{if(Ae(n))return;const r=q(n);e(st(r,r.title!=="Error"?r.title:t))}}function Lt(e){const{children:t,pluginId:n}=e,[r,s]=d.useState({}),[i,o]=d.useState(new F.config.PluginMeta),[a,c]=d.useState(!1),[l,u]=d.useState(null);console.debug("[PluginContextProvider] render",{pluginId:n,metaLoaded:a,metaError:!!l});const h=()=>{n===void 0||n===""||(console.debug(`[PluginContextProvider] fetching settings for "${n}"`),m.PluginValues(n).then(p=>{console.debug(`[PluginContextProvider] settings loaded for "${n}"`,Object.keys(p)),s(p)}).catch(p=>{const C=q(p);console.error(`[PluginContextProvider] error fetching settings for "${n}":`,C.detail)}))},_=()=>{if(n===void 0||n===""){console.debug("[PluginContextProvider] skipping meta fetch — empty pluginId");return}console.debug(`[PluginContextProvider] fetching meta for "${n}"`),u(null),m.GetPluginMeta(n).then(p=>{console.debug(`[PluginContextProvider] meta loaded for "${n}"`,{name:p==null?void 0:p.name,version:p==null?void 0:p.version}),o(p),c(!0)}).catch(p=>{const C=q(p);console.error(`[PluginContextProvider] error fetching meta for "${n}":`,C.detail),u(C.detail),c(!1)})};return d.useEffect(()=>{console.debug(`[PluginContextProvider] useEffect — pluginId changed to "${n}"`),h(),_()},[n]),l?x.jsx("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center",padding:24},children:x.jsxs("div",{style:{maxWidth:480,width:"100%",border:"1px solid #7F1D1D",borderRadius:8,backgroundColor:"#1C1917",padding:20,fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},children:[x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[x.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#EF4444",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[x.jsx("circle",{cx:"12",cy:"12",r:"10"}),x.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),x.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),x.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#FECACA"},children:"Plugin failed to load"})]}),x.jsx("p",{style:{fontSize:13,color:"#A1A1AA",margin:"0 0 16px"},children:l}),x.jsx("button",{onClick:()=>_(),style:{background:"transparent",color:"#F87171",border:"1px solid #7F1D1D",borderRadius:6,padding:"6px 14px",fontSize:13,fontWeight:500,cursor:"pointer"},children:"Retry"})]})}):a?x.jsx(de.Provider,{value:{pluginId:n,settings:r,meta:i},children:t}):x.jsxs("div",{style:{display:"flex",flex:1,alignItems:"center",justifyContent:"center"},children:[x.jsx("div",{style:{width:24,height:24,border:"2px solid #3F3F46",borderTopColor:"#A1A1AA",borderRadius:"50%",animation:"plugin-spin 0.8s linear infinite"}}),x.jsx("style",{children:"@keyframes plugin-spin { to { transform: rotate(360deg); } }"})]})}function fe(){const e=d.useContext(de);if(!e)throw new Error("usePluginContext must be used within a PluginContextProvider");return e}function qt(){return fe().settings}const Re=d.createContext(void 0),Qt=({children:e})=>{const[t,n]=d.useState({}),r=()=>{m.Values().then(i=>{console.log("Fetched settings:",i),n(i)}).catch(i=>{console.error("Error fetching settings:",i)})};d.useEffect(()=>{r()},[]);const s=()=>{r()};return x.jsx(Re.Provider,{value:{settings:t,reload:s},children:e})},ot={height:32,focused:0,tabs:[],createTab:()=>{},createTabs:()=>{},updateTab:()=>{},focusTab:()=>{},reorderTab:()=>{},closeTab:()=>{},closeTabs:()=>{},resizeDrawer:()=>{},closeDrawer:()=>{},fullscreenDrawer:()=>{}},it=d.createContext(ot),at=d.createContext(void 0),ct=d.createContext(void 0),Te=d.createContext(void 0),jt=3e4,Gt=({children:e})=>{const[t,n]=d.useState([]),r=d.useCallback(a=>{n(c=>[a,...c])},[]),s=d.useCallback((a,c)=>{n(l=>l.map(u=>u.id===a?{...u,...c}:u))},[]),i=d.useCallback(a=>{n(c=>c.filter(l=>l.id!==a))},[]);d.useEffect(()=>{const a=[];for(const c of t)if(c.status==="completed"||c.status==="error"){const l=Date.now()-(c.completedAt??c.startedAt),u=Math.max(0,jt-l);a.push(setTimeout(()=>i(c.id),u))}return()=>a.forEach(clearTimeout)},[t,i]);const o=d.useMemo(()=>({operations:t,addOperation:r,updateOperation:s,removeOperation:i}),[t,r,s,i]);return x.jsx(Te.Provider,{value:o,children:e})};var ve=function(e,t){return ve=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},ve(e,t)};function Ut(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");ve(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ce="Invariant Violation",We=Object.setPrototypeOf,Kt=We===void 0?function(e,t){return e.__proto__=t,e}:We,zt=function(e){Ut(t,e);function t(n){n===void 0&&(n=Ce);var r=e.call(this,typeof n=="number"?Ce+": "+n+" (see https://github.com/apollographql/invariant-packages)":n)||this;return r.framesToPop=1,r.name=Ce,Kt(r,t.prototype),r}return t}(Error);function be(e,t){if(!e)throw new zt(t)}var ut=["debug","log","warn","error","silent"],Wt=ut.indexOf("log");function re(e){return function(){if(ut.indexOf(e)>=Wt){var t=console[e]||console.log;return t.apply(console,arguments)}}}(function(e){e.debug=re("debug"),e.log=re("log"),e.warn=re("warn"),e.error=re("error")})(be||(be={}));const lt=d.createContext(void 0),Me=()=>d.useContext(lt),Bt=e=>{const t=Me();return t==null?void 0:t.getExtensionPoint(e)},Ht=e=>{const t=Me(),n=t==null?void 0:t.getExtensionPoint(e);return n?n.provide({getCacheKey:()=>e}):[]},Yt=({registry:e,children:t})=>{const n=d.useRef(e);return d.useEffect(()=>{be(n.current===e,"You can't change the extension registry after it has been rendered")},[e]),x.jsx(lt.Provider,{value:n.current,children:d.Children.only(t)})},Be=e=>{if(!e||typeof e!="string")throw new TypeError(`extensionName is required to be a string and can't be: "${e}" (${typeof e})`);return e.trim()};class dt{constructor(t){$(this,"_settings");$(this,"_extensions",new Map);$(this,"_lookupCache",new Map);$(this,"_matchCache",new Map);$(this,"_matcher");const{matcher:n,...r}=t;this._settings=r,this._matcher=t.matcher}settings(){return this._settings}register(t){if(this._extensions.get(t.id))throw new Error(`Resource sidebar view with id ${t.id} already exists`);const n={...t,registeredAt:new Date,updatedAt:new Date,enabled:!0};this._extensions.set(t.id,n);const r=Array.from(this._matchCache.keys());for(const s of r)s.startsWith(t.plugin)&&this._matchCache.delete(s)}unregister(t){this._extensions.delete(t)}get(t){var n;return(n=this._extensions.get(t))==null?void 0:n.component}list(){return Array.from(this._extensions.values())}generateMatchCacheKey(t){return`${t.plugin}/${t.id}`}calculateMatches(t){if(!this._matcher)return Array.from(this._extensions.values());const n=[];for(const r of this._extensions.values()){const s=this.generateMatchCacheKey(r),i=this._matchCache.has(s);if(i&&this._matchCache.get(s)){n.push(r);continue}this._matcher(t,r)?(this._matchCache.set(s,!0),n.push(r)):i||this._matchCache.set(s,!1)}return n}preload(t){const n=this.calculateMatches(t),r=t.getCacheKey();this._lookupCache.set(r,n.map(s=>s.id))}provide(t){if(this._settings.disabled)return[];if(this._settings.mode==="single"){const i=this._extensions.get(this._settings.selected);return i?[i.component]:[]}const n=t.getCacheKey();let r=this._lookupCache.get(n);if(r){let i=r.map(o=>this._extensions.get(o)).filter(o=>!!o).map(o=>o.component);return this._settings.order&&(i=this.reorderComponents(i,r,this._settings.order)),i}r=this.calculateMatches(t).map(i=>i.id),this._lookupCache.set(n,r);let s=r.map(i=>this._extensions.get(i)).filter(i=>!!i).map(i=>i.component);return this._settings.order&&(s=this.reorderComponents(s,r,this._settings.order)),s}reorderComponents(t,n,r){const s=new Map(n.map((i,o)=>[i,t[o]]));return r.map(i=>s.get(i)).filter(i=>!!i)}reorder(t){const n=t.map(o=>this._extensions.get(o)).filter(o=>!!o),r=Array.from(this._extensions.values()).filter(o=>!t.includes(o.id)),s=[...n,...r];this._extensions.clear(),s.forEach(o=>this._extensions.set(o.id,o));const i=Array.from(this._lookupCache.keys());for(const o of i){const a=this._lookupCache.get(o);if(!a)continue;const c=a.filter(l=>t.includes(l));this._lookupCache.set(o,c)}}clearLookupCache(){this._lookupCache.clear()}clearMatchCache(){this._matchCache.clear()}clearAllCaches(){this.clearLookupCache(),this.clearMatchCache()}}class Jt{constructor({initialStores:t}){$(this,"store",{});t.forEach(n=>{this.addExtensionPoint(n)})}addExtensionPoint(t){let n=Be(t.id);if(console.log("validated",n),console.log("store",this.store),this.store[n]){console.warn(`Extension point ${n} already exists. Not adding again.`);return}this.store[n]=new dt(t)}getExtensionPoint(t){return t=Be(t),this.store[t]}listExtensionPointIds(){return Object.keys(this.store)}listExtensionPoints(){return Object.values(this.store).map(t=>t.settings())}}const ft=d.createContext(void 0),Vt={default:"info",info:"info",success:"success",warning:"warning",error:"error"},Xt=({children:e})=>{const{push:t}=$t.useNotificationStack(),[n,r]=d.useState([]),s=o=>{r(a=>[...a,o])},i=(o,a,c)=>{const l=typeof o=="object";let u="",h="info",_,p=5e3,C;if(l){if(u=o.message,o.showOnce){if(n.includes(u))return;s(u)}h=o.status,_=o.details,p=o.autoHideDuration??5e3,C=o.actions}else u=o,h=a,_=c;t({severity:Vt[h]??"info",title:u,message:_,timeout:p,actions:C})};return x.jsx(ft.Provider,{value:{showSnackbar:i},children:e})},k=()=>{const e=d.useContext(ft);if(e===void 0)throw new Error("useCustomSnackbar must be used within a CustomSnackbarProvider");return e};function D(e){const t=d.useContext(de),n=(t==null?void 0:t.pluginId)??e;if(!n)throw new Error("pluginID must be provided either via PluginContext or as an explicit parameter");return n}const Zt=({pluginID:e,connectionID:t})=>{const n=D(e),r=g.useQueryClient(),{showSnackbar:s}=k(),i=[n,"connection","detail",t],{mutateAsync:o}=g.useMutation({mutationFn:async()=>m.StartConnection(n,t),onSuccess(h){r.setQueryData(i,h),r.invalidateQueries({queryKey:["EDITOR_SCHEMAS",n,t]})},onError:A(s,"Failed to start connection")}),{mutateAsync:a}=g.useMutation({mutationFn:async()=>m.StopConnection(n,t),onSuccess(h){r.setQueryData(i,h)},onError:A(s,"Failed to stop connection")}),{mutateAsync:c}=g.useMutation({mutationFn:async h=>m.UpdateConnection(n,h),onSuccess(h,{name:_}){s({message:`Connection ${_} successfully updated`,status:"success"}),r.setQueryData(i,u),r.setQueriesData({queryKey:[n,"connection","list"]},p=>p==null?void 0:p.map(C=>C.id===t?h:C))},onError:A(s,"Failed to update connection")}),{mutateAsync:l}=g.useMutation({mutationFn:async()=>m.RemoveConnection(n,t),onSuccess(){s({message:"Connection successfully removed",status:"success"}),r.setQueryData(i,void 0),r.setQueriesData({queryKey:[n,"connection","list"]},h=>h==null?void 0:h.filter(_=>_.id!==t))},onError:A(s,"Failed to remove connection")}),u=g.useQuery({queryKey:i,queryFn:async()=>m.GetConnection(n,t)});return{connection:u,startConnection:o,stopConnection:a,updateConnection:c,deleteConnection:l}},pt=e=>[e,"connection","list"],en=({plugin:e})=>{const t=D(e),n=g.useQueryClient(),{showSnackbar:r}=k(),s=pt(t),{mutateAsync:i}=g.useMutation({mutationFn:async l=>m.StartConnectionInformer(t,l.id),onError:A(r,"Failed to start connection informer")}),{mutateAsync:o}=g.useMutation({mutationFn:async l=>m.StopConnectionInformer(t,l.id),onError:A(r,"Failed to stop connection informer")}),a=d.useCallback(l=>{console.log("got update to connections",l),n.setQueryData(s,l)},[]);return d.useEffect(()=>{const l=I.EventsOn(`${t}/connection/sync`,a);return()=>{l()}},[]),{connections:g.useQuery({queryKey:s,queryFn:async()=>{try{return await m.ListConnections(t)}catch(l){console.log(l),A(r,"Failed to load connections")(l)}return[]},staleTime:3e4,placeholderData:g.keepPreviousData}),startInformer:i,stopInformer:o}},tn=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"connection","namespaces",t];return{namespaces:g.useQuery({queryKey:r,queryFn:async()=>m.GetConnectionNamespaces(n,t)})}};var yt=(e=>(e[e.OnConnect=0]="OnConnect",e[e.OnFirstQuery=1]="OnFirstQuery",e[e.Never=2]="Never",e))(yt||{}),O=(e=>(e[e.Pending=0]="Pending",e[e.Syncing=1]="Syncing",e[e.Synced=2]="Synced",e[e.Error=3]="Error",e[e.Cancelled=4]="Cancelled",e))(O||{});function ht(e){const t=Object.values(e.states),n=t.length;let r=0,s=0;for(const a of t)a===O.Synced&&r++,a===O.Error&&s++;const i=t.filter(a=>a===O.Synced||a===O.Error||a===O.Cancelled).length,o=n>0?i/n:0;return{pluginID:e.pluginID,connectionID:e.connectionID,totalResources:n,syncedCount:r,errorCount:s,doneCount:i,progress:o}}function ae(e){return e.totalResources>0&&e.doneCount>=e.totalResources}function gt(e){return e.some(t=>!ae(t))}function mt(e){const t=e.reduce((r,s)=>r+s.totalResources,0);return t===0?0:e.reduce((r,s)=>r+s.doneCount,0)/t}function Ne(e){return`${e.pluginId}/${e.connection}`}function _t(e,t){const n=Ne(t);e.has(n)||e.set(n,{states:{},pluginID:t.pluginId,connectionID:t.connection});const r=e.get(n);return r.states[t.resourceKey]=t.state,r}function nn(){const[e,t]=d.useState(new Set),[n,r]=d.useState({}),[s,i]=d.useState(new Map),o=d.useRef(new Map);d.useEffect(()=>{m.ListAllConnections().then(y=>{y&&r(y)}).catch(()=>{})},[]),d.useEffect(()=>I.EventsOn("connection/status",E=>{const w=`${E.pluginID}/${E.connectionID}`;E.status==="DISCONNECTED"?(t(P=>{const f=new Set(P);return f.delete(w),f}),i(P=>{const f=new Map(P);return f.delete(w),f}),o.current.delete(w)):t(P=>{const f=new Set(P);return f.add(w),f}),m.ListAllConnections().then(P=>{P&&r(P)}).catch(()=>{})}),[]);const a=d.useCallback(y=>{const E=Ne(y);t(f=>{if(f.has(E))return f;const S=new Set(f);return S.add(E),S});const w=_t(o.current,y),P=ht(w);i(f=>{const S=new Map(f);return S.set(E,P),S})},[]);d.useEffect(()=>I.EventsOn("informer/STATE",a),[a]);const c=d.useCallback(async(y,E)=>{await m.StopConnection(y,E)},[]),l=d.useCallback(async(y,E)=>{await m.StartConnectionInformer(y,E)},[]),u=[];for(const y of e){const[E,w]=y.split("/",2),f=(n[E]??[]).find(N=>N.id===w),S=s.get(y),b=S!=null&&!ae(S),v=S!=null&&S.errorCount>0;u.push({pluginID:E,connectionID:w,name:(f==null?void 0:f.name)??w,avatar:(f==null?void 0:f.avatar)??"",isStarted:!0,sync:S,isSyncing:b,hasErrors:v})}const h=new Map;for(const y of u){const E=h.get(y.pluginID)??[];E.push(y),h.set(y.pluginID,E)}const _=Array.from(s.values()),p=u.filter(y=>y.isSyncing),C=u.filter(y=>y.hasErrors);return{entries:u,grouped:h,connectedCount:u.length,syncingCount:p.length,errorCount:C.length,hasSyncing:gt(_),aggregateProgress:mt(_),disconnect:c,retryInformer:l}}function rn(e,t){return window.go.data.Client.Get(e,t)}function sn(e,t,n){return window.go.data.Client.Set(e,t,n)}function on(e,t,n){const r=D(e),s=g.useQueryClient(),i=[r,"data",t],o=g.useQuery({queryKey:i,queryFn:async()=>{const c=await rn(r,t);return c??n}}),a=g.useMutation({mutationFn:async c=>{await sn(r,t,c)},onMutate:async c=>{await s.cancelQueries({queryKey:i});const l=s.getQueryData(i);return s.setQueryData(i,c),{previous:l}},onError:(c,l,u)=>{(u==null?void 0:u.previous)!==void 0&&s.setQueryData(i,u.previous)},onSettled:()=>{s.invalidateQueries({queryKey:i})}});return{data:o.data??n,update:async c=>{await a.mutateAsync(c)},isLoading:o.isLoading}}const an=()=>{const e=d.useContext(at);if(!e)throw new Error("useRightDrawer must be used within a RightDrawerProvider");return e},ke=()=>{const e=d.useContext(it);if(e===void 0)throw new Error("useBottomDrawer must be used within a BottomDrawerProvider");return e},cn=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=k(),{createTab:r,updateTab:s}=ke();return{createSession:g.useMutation({mutationFn:async({connectionID:o,icon:a,label:c,opts:l})=>{const u=`pending-${crypto.randomUUID()}`;r({id:u,title:c??"Connecting...",variant:"terminal",icon:a??"LuSquareTerminal",properties:{status:"connecting",pluginID:t,connectionID:o,opts:{...l}}});const h=F.exec.SessionOptions.createFrom({command:["/bin/bash"],tty:!0,...l});try{const _=await m.CreateSession(t,o,h);s({id:u},{id:_.id,title:c??`Session ${_.id.substring(0,8)}`,properties:{status:"connected",pluginID:t,connectionID:o,opts:{...l}}})}catch(_){const p=q(_);s({id:u},{properties:{status:"error",error:p.detail,pluginID:t,connectionID:o,opts:{...l}}}),G(n,_,"Failed to start session")}}}).mutateAsync}},un=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=k(),{createTab:r}=ke(),s=g.useMutation({mutationFn:async({connectionID:o,resourceKey:a,resourceID:c,resourceData:l,icon:u,label:h,target:_,follow:p=!0,tailLines:C=1e3,params:y})=>{const E=F.logs.CreateSessionOptions.createFrom({resource_key:a,resource_id:c,resource_data:l,options:F.logs.LogSessionOptions.createFrom({target:_??"",follow:p,include_previous:!1,include_timestamps:!0,tail_lines:C,since_seconds:0,limit_bytes:0,include_source_events:!0,params:y??{}})}),w=await m.CreateSession$1(t,o,E);return r({id:w.id,title:h??`Logs ${w.id.substring(0,8)}`,variant:"logs",icon:u??"LuLogs"}),w},onError:A(n,"Failed to start log session")}),i=g.useMutation({mutationFn:async o=>{await m.CloseSession(o)},onError:A(n,"Failed to close log session")});return{createLogSession:s.mutateAsync,closeLogSession:i.mutateAsync}},ln=()=>g.useQuery({queryKey:["metric","providers"],queryFn:m.GetProviders,staleTime:3e4}),Ct=e=>g.useQuery({queryKey:["metric","providers",e],queryFn:()=>m.GetProvidersForResource(e),enabled:!!e,staleTime:3e4}),dn=e=>{var E,w;const{connectionID:t,resourceKey:n,resourceID:r,resourceNamespace:s="",resourceData:i={},metricIDs:o=[],shape:a=0,timeRange:c,refreshInterval:l=0,enabled:u=!0}=e,{data:h,isLoading:_}=Ct(n),p=h??[],C=c?Math.max(Math.floor((c.end.getTime()-c.start.getTime())/250),15e3)*1e6:0,y=g.useQuery({queryKey:["metric","query",t,n,r,s,o,a,(E=c==null?void 0:c.start)==null?void 0:E.getTime(),(w=c==null?void 0:c.end)==null?void 0:w.getTime()],queryFn:()=>m.QueryAll(t,n,r,s,i,o,a,(c==null?void 0:c.start)??new Date(0),(c==null?void 0:c.end)??new Date(0),C),enabled:u&&!!t&&!!n&&(n.startsWith("cluster::")||!!r)&&p.length>0,refetchInterval:l>0?l:void 0,staleTime:5e3,placeholderData:g.keepPreviousData});return{data:y.data??void 0,providers:p,isLoading:_||y.isLoading,error:y.error,refetch:y.refetch}},fn=e=>{const{pluginID:t,connectionID:n,resourceKey:r,resourceID:s,resourceNamespace:i="",resourceData:o={},metricIDs:a=[],interval:c=1e4,enabled:l=!0}=e,u=D(t),[h,_]=d.useState(null),[p,C]=d.useState(null),[y,E]=d.useState(!1),[w,P]=d.useState(null),f=d.useRef(null),S=d.useCallback(async()=>{if(!(!l||!u||!n||!r||!s))try{const v=await m.Subscribe(u,n,{resource_key:r,resource_id:s,resource_namespace:i,resource_data:o,metric_ids:a,interval:c*1e6});C(v),E(!0),P(null);const N=I.EventsOn(`core/metrics/data/${v}`,B=>{try{const L=JSON.parse(B);L.results&&_(L.results)}catch(L){console.error("Failed to parse metric stream data:",L)}}),ne=I.EventsOn(`core/metrics/error/${v}`,B=>{try{const L=JSON.parse(B);P(L.error||"Unknown error")}catch{P("Failed to parse metric stream error")}});f.current=()=>{N(),ne()}}catch(v){P(v instanceof Error?v.message:String(v))}},[u,n,r,s,i,a,c,l]),b=d.useCallback(async()=>{if(p)try{await m.Unsubscribe(p)}catch(v){console.error("Failed to unsubscribe:",v)}f.current&&(f.current(),f.current=null),C(null),E(!1)},[p]);return d.useEffect(()=>()=>{p&&m.Unsubscribe(p).catch(console.error),f.current&&f.current()},[p]),{data:h,subscriptionID:p,isStreaming:y,error:w,start:S,stop:b}},j=["networker","portforward","all-sessions"];function pn(){const{showSnackbar:e}=k(),t=g.useQueryClient(),n=g.useQuery({queryKey:[...j],queryFn:async()=>m.ListAllPortForwardSessions().catch(i=>{if(q(i).detail.includes("not found"))return[];throw i}),retry:!1});d.useEffect(()=>{const i=I.EventsOn("core/networker/portforward/created",()=>{t.invalidateQueries({queryKey:[...j]})}),o=I.EventsOn("core/networker/portforward/closed",()=>{t.invalidateQueries({queryKey:[...j]})});return()=>{i(),o()}},[t]);const r=n.data??[],s=g.useMutation({mutationFn:async i=>m.ClosePortForwardSession(i),onError:A(e,"Failed to close port forwarding session"),onSuccess:async()=>{await t.invalidateQueries({queryKey:[...j]})}});return{sessions:n,activeSessions:r,closeSession:s.mutateAsync,openInBrowser:i=>I.BrowserOpenURL(`http://localhost:${i}`)}}function yn({pluginID:e,connectionID:t,resourceID:n}){const r=D(e),s=["networker","portforward","sessions",r,t,n],{showSnackbar:i}=k(),o=g.useQueryClient(),a=g.useQuery({queryKey:s,queryFn:async()=>m.FindPortForwardSessions(r,t,F.networker.FindPortForwardSessionRequest.createFrom({resource_id:n,connection_id:t})).catch(u=>{const h=q(u);return h.detail.includes("not found")?[]:(i({message:"Failed to fetch port forward sessions",status:"error",details:h.detail}),[])}),retry:!1}),c=g.useMutation({mutationFn:async({opts:u})=>{const h=F.networker.PortForwardSessionOptions.createFrom({local_port:u.localPort||0,remote_port:u.remotePort,protocol:u.protocol||"TCP",connection_type:"RESOURCE",connection:{resource_data:u.resource,connection_id:t,plugin_id:r,resource_id:u.resourceId,resource_key:u.resourceKey},labels:u.labels??{},params:u.parameters??{}}),_=await m.StartResourcePortForwardingSession(r,t,h);return u.openInBrowser&&I.BrowserOpenURL(`http://localhost:${_.local_port}`),_},onError:A(i,"Failed to start port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...j]})])}}),l=g.useMutation({mutationFn:async({opts:u})=>m.ClosePortForwardSession(u.sessionID),onError:A(i,"Failed to close port forwarding session"),onSuccess:async()=>{await Promise.all([o.invalidateQueries({queryKey:s}),o.invalidateQueries({queryKey:[...j]})])}});return{sessions:a,forward:c.mutateAsync,close:l.mutateAsync}}const hn=()=>{const e=d.useContext(ct);if(!e)throw new Error("useConfirmationModal must be used within a ConfirmationModalProvider");return e},gn=({pluginID:e,connectionID:t,resourceKey:n,resourceID:r,namespace:s="",getParams:i={},updateParams:o={},deleteParams:a={}})=>{const c=D(e),l=g.useQueryClient(),{showSnackbar:u}=k(),h=["RESOURCE",c,t,n,r,s],{mutateAsync:_}=g.useMutation({mutationFn:async y=>m.Update(c,t,n,F.types.UpdateInput.createFrom({params:{...o,...y.params},input:{...o,...y.input},id:r,namespace:s})),onSuccess:async()=>{u(`Resource ${r} updated`,"success"),await l.invalidateQueries({queryKey:h})},onError:A(u,`Failed to update resource ${r}`)}),{mutateAsync:p}=g.useMutation({mutationFn:async y=>m.Delete(c,t,n,F.types.DeleteInput.createFrom({params:{...a,...y.params},input:{...a,...y.input},id:r,...y,namespace:s})),onSuccess:async()=>{u(`Resource ${r} deleted`,"success"),await l.invalidateQueries({queryKey:h})},onError:A(u,`Failed to delete resource ${r}`)});return{resource:g.useQuery({queryKey:h,queryFn:async()=>m.Get(c,t,n,F.types.GetInput.createFrom({params:i,id:r,namespace:s})),retry:!1}),update:_,remove:p}},mn=e=>{const t=["component",e.plugin,e.resource,e.area];return{component:g.useQuery({queryKey:t,queryFn:async()=>m.GetResourceAreaComponent(e)})}},_n=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"resource_groups","list"];return{groups:g.useQuery({queryKey:r,queryFn:async()=>m.GetResourceGroups(n,t),retry:!1})}},Cn=({pluginID:e,connectionID:t,searches:n})=>{const r=D(e),s=o=>[r,t,o.key,o.namespaces,"list"];return g.useQueries({queries:n.map(o=>({queryKey:s(o),queryFn:async()=>m.List(r,t,o.key,F.types.ListInput.createFrom({params:{},order:{by:"name",direction:!0},pagination:{page:1,pageSize:200},namespaces:o.namespaces})).then(a=>(console.log(a.result),a.result&&o.postFilter?Object.values(a.result).filter(o.postFilter):Object.values(a.result||{}))),retry:!1}))})},Sn=({pluginID:e,resourceKey:t})=>{const n=D(e),r=[n,"resources",t];return{resourceType:g.useQuery({queryKey:r,queryFn:async()=>m.GetResourceType(n,t),retry:!1})}},wn=({pluginID:e,connectionID:t})=>{const n=D(e),r=[n,"resources","list"];return{types:g.useQuery({queryKey:r,queryFn:async()=>m.GetResourceTypes(n,t),retry:!1})}};var St=Symbol.for("immer-nothing"),He=Symbol.for("immer-draftable"),T=Symbol.for("immer-state"),En=process.env.NODE_ENV!=="production"?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function R(e,...t){if(process.env.NODE_ENV!=="production"){const n=En[e],r=typeof n=="function"?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Y=Object.getPrototypeOf;function J(e){return!!e&&!!e[T]}function U(e){var t;return e?wt(e)||Array.isArray(e)||!!e[He]||!!((t=e.constructor)!=null&&t[He])||ye(e)||he(e):!1}var vn=Object.prototype.constructor.toString();function wt(e){if(!e||typeof e!="object")return!1;const t=Y(e);if(t===null)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===vn}function ce(e,t){pe(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function pe(e){const t=e[T];return t?t.type_:Array.isArray(e)?1:ye(e)?2:he(e)?3:0}function Pe(e,t){return pe(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Et(e,t,n){const r=pe(e);r===2?e.set(t,n):r===3?e.add(n):e[t]=n}function bn(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function ye(e){return e instanceof Map}function he(e){return e instanceof Set}function Q(e){return e.copy_||e.base_}function xe(e,t){if(ye(e))return new Map(e);if(he(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=wt(e);if(t===!0||t==="class_only"&&!n){const r=Object.getOwnPropertyDescriptors(e);delete r[T];let s=Reflect.ownKeys(r);for(let i=0;i<s.length;i++){const o=s[i],a=r[o];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(r[o]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[o]})}return Object.create(Y(e),r)}else{const r=Y(e);if(r!==null&&n)return{...e};const s=Object.create(r);return Object.assign(s,e)}}function $e(e,t=!1){return ge(e)||J(e)||!U(e)||(pe(e)>1&&(e.set=e.add=e.clear=e.delete=Pn),Object.freeze(e),t&&Object.entries(e).forEach(([n,r])=>$e(r,!0))),e}function Pn(){R(2)}function ge(e){return Object.isFrozen(e)}var xn={};function K(e){const t=xn[e];return t||R(0,e),t}var Z;function vt(){return Z}function Dn(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ye(e,t){t&&(K("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function De(e){Fe(e),e.drafts_.forEach(Fn),e.drafts_=null}function Fe(e){e===Z&&(Z=e.parent_)}function Je(e){return Z=Dn(Z,e)}function Fn(e){const t=e[T];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Ve(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return e!==void 0&&e!==n?(n[T].modified_&&(De(t),R(4)),U(e)&&(e=ue(t,e),t.parent_||le(t,e)),t.patches_&&K("Patches").generateReplacementPatches_(n[T].base_,e,t.patches_,t.inversePatches_)):e=ue(t,n,[]),De(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==St?e:void 0}function ue(e,t,n){if(ge(t))return t;const r=t[T];if(!r)return ce(t,(s,i)=>Xe(e,r,t,s,i,n)),t;if(r.scope_!==e)return t;if(!r.modified_)return le(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const s=r.copy_;let i=s,o=!1;r.type_===3&&(i=new Set(s),s.clear(),o=!0),ce(i,(a,c)=>Xe(e,r,s,a,c,n,o)),le(e,s,!1),n&&e.patches_&&K("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function Xe(e,t,n,r,s,i,o){if(process.env.NODE_ENV!=="production"&&s===n&&R(5),J(s)){const a=i&&t&&t.type_!==3&&!Pe(t.assigned_,r)?i.concat(r):void 0,c=ue(e,s,a);if(Et(n,r,c),J(c))e.canAutoFreeze_=!1;else return}else o&&n.add(s);if(U(s)&&!ge(s)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ue(e,s),(!t||!t.scope_.parent_)&&typeof r!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,r)&&le(e,s)}}function le(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&$e(t,n)}function In(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:vt(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,i=Le;n&&(s=[r],i=ee);const{revoke:o,proxy:a}=Proxy.revocable(s,i);return r.draft_=a,r.revoke_=o,a}var Le={get(e,t){if(t===T)return e;const n=Q(e);if(!Pe(n,t))return On(e,n,t);const r=n[t];return e.finalized_||!U(r)?r:r===Se(e.base_,t)?(we(e),e.copy_[t]=Oe(r,e)):r},has(e,t){return t in Q(e)},ownKeys(e){return Reflect.ownKeys(Q(e))},set(e,t,n){const r=bt(Q(e),t);if(r!=null&&r.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const s=Se(Q(e),t),i=s==null?void 0:s[T];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(bn(n,s)&&(n!==void 0||Pe(e.base_,t)))return!0;we(e),Ie(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Se(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,we(e),Ie(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){const n=Q(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:r.enumerable,value:n[t]}},defineProperty(){R(11)},getPrototypeOf(e){return Y(e.base_)},setPrototypeOf(){R(12)}},ee={};ce(Le,(e,t)=>{ee[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});ee.deleteProperty=function(e,t){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(t))&&R(13),ee.set.call(this,e,t,void 0)};ee.set=function(e,t,n){return process.env.NODE_ENV!=="production"&&t!=="length"&&isNaN(parseInt(t))&&R(14),Le.set.call(this,e[0],t,n,e[0])};function Se(e,t){const n=e[T];return(n?Q(n):e)[t]}function On(e,t,n){var s;const r=bt(t,n);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(e.draft_):void 0}function bt(e,t){if(!(t in e))return;let n=Y(e);for(;n;){const r=Object.getOwnPropertyDescriptor(n,t);if(r)return r;n=Y(n)}}function Ie(e){e.modified_||(e.modified_=!0,e.parent_&&Ie(e.parent_))}function we(e){e.copy_||(e.copy_=xe(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var An=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,r)=>{if(typeof t=="function"&&typeof n!="function"){const i=n;n=t;const o=this;return function(c=i,...l){return o.produce(c,u=>n.call(this,u,...l))}}typeof n!="function"&&R(6),r!==void 0&&typeof r!="function"&&R(7);let s;if(U(t)){const i=Je(this),o=Oe(t,void 0);let a=!0;try{s=n(o),a=!1}finally{a?De(i):Fe(i)}return Ye(i,r),Ve(s,i)}else if(!t||typeof t!="object"){if(s=n(t),s===void 0&&(s=t),s===St&&(s=void 0),this.autoFreeze_&&$e(s,!0),r){const i=[],o=[];K("Patches").generateReplacementPatches_(t,s,i,o),r(i,o)}return s}else R(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(o,...a)=>this.produceWithPatches(o,c=>t(c,...a));let r,s;return[this.produce(t,n,(o,a)=>{r=o,s=a}),r,s]},typeof(e==null?void 0:e.autoFreeze)=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof(e==null?void 0:e.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){U(e)||R(8),J(e)&&(e=Rn(e));const t=Je(this),n=Oe(e,void 0);return n[T].isManual_=!0,Fe(t),n}finishDraft(e,t){const n=e&&e[T];(!n||!n.isManual_)&&R(9);const{scope_:r}=n;return Ye(r,t),Ve(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const s=t[n];if(s.path.length===0&&s.op==="replace"){e=s.value;break}}n>-1&&(t=t.slice(n+1));const r=K("Patches").applyPatches_;return J(e)?r(e,t):this.produce(e,s=>r(s,t))}};function Oe(e,t){const n=ye(e)?K("MapSet").proxyMap_(e,t):he(e)?K("MapSet").proxySet_(e,t):In(e,t);return(t?t.scope_:vt()).drafts_.push(n),n}function Rn(e){return J(e)||R(10,e),Pt(e)}function Pt(e){if(!U(e)||ge(e))return e;const t=e[T];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=xe(e,t.scope_.immer_.useStrictShallowCopy_)}else n=xe(e,!0);return ce(n,(r,s)=>{Et(n,r,Pt(s))}),t&&(t.finalized_=!1),n}var M=new An,oe=M.produce;M.produceWithPatches.bind(M);M.setAutoFreeze.bind(M);M.setUseStrictShallowCopy.bind(M);M.applyPatches.bind(M);M.createDraft.bind(M);M.finishDraft.bind(M);var se=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Tn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Mn="Expected a function",xt="__lodash_hash_undefined__",Nn="[object Function]",kn="[object GeneratorFunction]",$n="[object Symbol]",Ln=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,qn=/^\w*$/,Qn=/^\./,jn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Gn=/[\\^$.*+?()[\]{}|]/g,Un=/\\(\\)?/g,Kn=/^\[object .+?Constructor\]$/,zn=typeof se=="object"&&se&&se.Object===Object&&se,Wn=typeof self=="object"&&self&&self.Object===Object&&self,qe=zn||Wn||Function("return this")();function Bn(e,t){return e==null?void 0:e[t]}function Hn(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch{}return t}var Yn=Array.prototype,Jn=Function.prototype,Dt=Object.prototype,Ee=qe["__core-js_shared__"],Ze=function(){var e=/[^.]+$/.exec(Ee&&Ee.keys&&Ee.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ft=Jn.toString,Qe=Dt.hasOwnProperty,It=Dt.toString,Vn=RegExp("^"+Ft.call(Qe).replace(Gn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),et=qe.Symbol,Xn=Yn.splice,Zn=Ot(qe,"Map"),te=Ot(Object,"create"),tt=et?et.prototype:void 0,nt=tt?tt.toString:void 0;function z(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function er(){this.__data__=te?te(null):{}}function tr(e){return this.has(e)&&delete this.__data__[e]}function nr(e){var t=this.__data__;if(te){var n=t[e];return n===xt?void 0:n}return Qe.call(t,e)?t[e]:void 0}function rr(e){var t=this.__data__;return te?t[e]!==void 0:Qe.call(t,e)}function sr(e,t){var n=this.__data__;return n[e]=te&&t===void 0?xt:t,this}z.prototype.clear=er;z.prototype.delete=tr;z.prototype.get=nr;z.prototype.has=rr;z.prototype.set=sr;function V(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function or(){this.__data__=[]}function ir(e){var t=this.__data__,n=me(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():Xn.call(t,n,1),!0}function ar(e){var t=this.__data__,n=me(t,e);return n<0?void 0:t[n][1]}function cr(e){return me(this.__data__,e)>-1}function ur(e,t){var n=this.__data__,r=me(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}V.prototype.clear=or;V.prototype.delete=ir;V.prototype.get=ar;V.prototype.has=cr;V.prototype.set=ur;function W(e){var t=-1,n=e?e.length:0;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}function lr(){this.__data__={hash:new z,map:new(Zn||V),string:new z}}function dr(e){return _e(this,e).delete(e)}function fr(e){return _e(this,e).get(e)}function pr(e){return _e(this,e).has(e)}function yr(e,t){return _e(this,e).set(e,t),this}W.prototype.clear=lr;W.prototype.delete=dr;W.prototype.get=fr;W.prototype.has=pr;W.prototype.set=yr;function me(e,t){for(var n=e.length;n--;)if(Pr(e[n][0],t))return n;return-1}function hr(e,t){t=Cr(t,e)?[t]:_r(t);for(var n=0,r=t.length;e!=null&&n<r;)e=e[vr(t[n++])];return n&&n==r?e:void 0}function gr(e){if(!Rt(e)||wr(e))return!1;var t=xr(e)||Hn(e)?Vn:Kn;return t.test(br(e))}function mr(e){if(typeof e=="string")return e;if(Ge(e))return nt?nt.call(e):"";var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function _r(e){return At(e)?e:Er(e)}function _e(e,t){var n=e.__data__;return Sr(t)?n[typeof t=="string"?"string":"hash"]:n.map}function Ot(e,t){var n=Bn(e,t);return gr(n)?n:void 0}function Cr(e,t){if(At(e))return!1;var n=typeof e;return n=="number"||n=="symbol"||n=="boolean"||e==null||Ge(e)?!0:qn.test(e)||!Ln.test(e)||t!=null&&e in Object(t)}function Sr(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function wr(e){return!!Ze&&Ze in e}var Er=je(function(e){e=Fr(e);var t=[];return Qn.test(e)&&t.push(""),e.replace(jn,function(n,r,s,i){t.push(s?i.replace(Un,"$1"):r||n)}),t});function vr(e){if(typeof e=="string"||Ge(e))return e;var t=e+"";return t=="0"&&1/e==-1/0?"-0":t}function br(e){if(e!=null){try{return Ft.call(e)}catch{}try{return e+""}catch{}}return""}function je(e,t){if(typeof e!="function"||t&&typeof t!="function")throw new TypeError(Mn);var n=function(){var r=arguments,s=t?t.apply(this,r):r[0],i=n.cache;if(i.has(s))return i.get(s);var o=e.apply(this,r);return n.cache=i.set(s,o),o};return n.cache=new(je.Cache||W),n}je.Cache=W;function Pr(e,t){return e===t||e!==e&&t!==t}var At=Array.isArray;function xr(e){var t=Rt(e)?It.call(e):"";return t==Nn||t==kn}function Rt(e){var t=typeof e;return!!e&&(t=="object"||t=="function")}function Dr(e){return!!e&&typeof e=="object"}function Ge(e){return typeof e=="symbol"||Dr(e)&&It.call(e)==$n}function Fr(e){return e==null?"":mr(e)}function Ir(e,t,n){var r=e==null?void 0:hr(e,t);return r===void 0?n:r}var Or=Ir;const H=Tn(Or),Ar=({pluginID:e,connectionID:t,resourceKey:n,idAccessor:r,namespaces:s=[],listParams:i={},createParams:o={}})=>{const a=D(e),c=g.useQueryClient(),{showSnackbar:l}=k(),u=[a,t,n,s,"list"],h=(f,S)=>[a,t,n,S,f];console.log("getting from key: ",`${a}/${t}/${n}`);const{mutateAsync:_}=g.useMutation({mutationFn:async f=>m.Create(a,t,n,F.types.CreateInput.createFrom({params:f.params||o,input:f.input,namespaces:s})),onSuccess:async f=>{var v,N,ne,B,L,Ue,Ke,ze;let S="";(v=f.result.metadata)!=null&&v.name?S=f.result.metadata.name:(N=f.result)!=null&&N.id?S=(ne=f.result)==null?void 0:ne.id:(B=f.result)!=null&&B.name?S=(L=f.result)==null?void 0:L.name:(Ue=f.result)!=null&&Ue.ID?S=(Ke=f.result)==null?void 0:Ke.ID:(ze=f.result)!=null&&ze.Name&&(S=f.result.Name);const b=S?`Resource ${S} created`:"Resource created";l(b,"success"),await c.invalidateQueries({queryKey:u})},onError:A(l,"Failed to create resource")}),p=g.useQuery({queryKey:u,queryFn:async()=>m.List(a,t,n,F.types.ListInput.createFrom({params:i,order:{by:"name",direction:!0},pagination:{page:1,pageSize:200},namespaces:s})),placeholderData:(f,S)=>f,retry:!1}),C=d.useCallback(f=>{console.log("got a new resource",f),r&&(c.setQueryData(u,S=>oe(S,b=>{if(b||(b=F.types.ListResult.createFrom({result:[],success:!0,pagination:{}})),b.result.findIndex(N=>H(f.data,r)===H(N,r))===-1){b.result.push(f.data);return}})),c.setQueryData(h(f.id,f.namespace),{result:f.data}))},[]),y=d.useCallback(f=>{console.log("got an updated resource",f),r&&(c.setQueryData(u,S=>oe(S,b=>{b||(b=F.types.ListResult.createFrom({result:[],success:!0,pagination:{}}));const v=b.result.findIndex(N=>H(f.newData,r)===H(N,r));if(v!==-1){b.result[v]=f.newData;return}})),c.setQueryData(h(f.id,f.namespace),{result:f.newData}))},[]),E=d.useCallback(f=>{console.log("got a deleted resource",f),r&&c.setQueryData(u,S=>oe(S,b=>{if(!b)return;const v=b.result.findIndex(N=>H(f.data,r)===H(N,r));if(v!==-1){b.result.splice(v,1);return}}))},[]);d.useEffect(()=>{if(!r)return;const f=I.EventsOn(`${a}/${t}/${n}/ADD`,C),S=I.EventsOn(`${a}/${t}/${n}/UPDATE`,y),b=I.EventsOn(`${a}/${t}/${n}/DELETE`,E);return()=>{f(),S(),b()}},[]);const[w,P]=d.useState(O.Pending);return d.useEffect(()=>I.EventsOn(`${a}/${t}/informer/STATE`,S=>{S.resourceKey===n&&P(S.state)}),[a,t,n]),{resources:p,create:_,informerState:w,isSyncing:w===O.Syncing,isSynced:w===O.Synced,informerError:w===O.Error}},Rr=({pluginID:e})=>{const t=D(e),{showSnackbar:n}=k(),r=g.useMutation({mutationFn:async({opts:o,input:a})=>m.Create(t,o.connectionID,o.resourceKey,F.types.CreateInput.createFrom({params:{...o.params,...a.params},input:{...o.params,...a.input},id:o.resourceID,namespace:o.namespace})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} created`,"success")},onError(o,{opts:a}){G(n,o,`Failed to create resource ${a.resourceID}`)}}),s=g.useMutation({mutationFn:async({opts:o,input:a})=>m.Update(t,o.connectionID,o.resourceKey,F.types.UpdateInput.createFrom({params:{...o.params,...a.params},input:{...o.params,...a.input},id:o.resourceID,namespace:o.namespace})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} updated`,"success")},onError(o,{opts:a}){G(n,o,`Failed to update resource ${a.resourceID}`)}}),i=g.useMutation({mutationFn:async({opts:o,input:a})=>m.Delete(t,o.connectionID,o.resourceKey,F.types.DeleteInput.createFrom({...a,params:{...o.params,...a.params},input:{...o.params,...a.input},id:o.resourceID,namespace:o.namespace})),onSuccess:(o,{opts:a})=>{n(`Resource ${a.resourceID} deleted`,"success")},onError(o,{opts:a}){G(n,o,`Failed to delete resource ${a.resourceID}`)}});return{create:r.mutateAsync,update:s.mutateAsync,remove:i.mutateAsync}},Tr=({pluginID:e,connectionID:t,resourceKey:n,enabled:r=!0})=>{const s=D(e),i=g.useQuery({queryKey:["RESOURCE_ACTIONS",s,t,n],queryFn:()=>m.GetActions(s,t,n),enabled:r&&!!s&&!!t&&!!n,staleTime:5*60*1e3});return{actions:i.data??[],isLoading:i.isLoading,error:i.error}},Mr=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),s=g.useQueryClient(),{showSnackbar:i}=k(),o=g.useMutation({mutationFn:async({actionID:a,id:c="",namespace:l="",params:u={}})=>m.ExecuteAction(r,t,n,a,F.types.ActionInput.createFrom({id:c,namespace:l,params:u})),onSuccess:a=>{a.message&&i(a.message,"success"),s.invalidateQueries({queryKey:["RESOURCES",r,t,n]})},onError:(a,c)=>{G(i,a,`Failed to execute action "${c.actionID}"`)}});return{executeAction:o.mutateAsync,isExecuting:o.isPending,error:o.error}},Nr=({pluginID:e,connectionID:t,enabled:n=!0})=>{const r=D(e),s=g.useQuery({queryKey:["EDITOR_SCHEMAS",r,t],queryFn:()=>m.GetEditorSchemas(r,t),enabled:n&&!!r&&!!t,staleTime:10*60*1e3,retry:1});return{schemas:s.data??[],isLoading:s.isLoading,error:s.error,refetch:s.refetch}},kr=({pluginID:e,connectionID:t,enabled:n=!0})=>{const r=D(e),s=g.useQueryClient(),i=[r,t,"informer-state"],o=g.useQuery({queryKey:i,queryFn:()=>m.GetInformerState(r,t),enabled:n&&!!r&&!!t});d.useEffect(()=>!n||!r||!t?void 0:I.EventsOn(`${r}/${t}/informer/STATE`,u=>{s.setQueryData(i,h=>h&&oe(h,_=>{_.resources[u.resourceKey]=u.state,_.resourceCounts[u.resourceKey]=u.resourceCount;let p=0,C=0;for(const y of Object.values(_.resources))y===O.Synced&&p++,y===O.Error&&C++;_.syncedCount=p,_.errorCount=C}))}),[r,t,n]);const a=o.data;let c=0;if(a!=null&&a.resources)for(const l of Object.values(a.resources))(l===O.Synced||l===O.Error||l===O.Cancelled)&&c++;return{summary:o,getResourceState:l=>a==null?void 0:a.resources[l],isFullySynced:a?a.totalResources>0&&c===a.totalResources:!1,syncProgress:a&&a.totalResources>0?c/a.totalResources:0,errorCount:(a==null?void 0:a.errorCount)??0}},$r=()=>{const[e,t]=d.useState(new Map),n=d.useRef(new Map),r=d.useRef(new Map),s=d.useCallback(l=>{const u=Ne(l),h=_t(n.current,l),_=ht(h);if(t(p=>{const C=new Map(p);return C.set(u,_),C}),r.current.has(u)&&(clearTimeout(r.current.get(u)),r.current.delete(u)),ae(_)){const p=setTimeout(()=>{t(C=>{const y=new Map(C);return y.delete(u),y}),n.current.delete(u),r.current.delete(u)},5e3);r.current.set(u,p)}},[]);d.useEffect(()=>{const l=I.EventsOn("informer/STATE",s);return()=>{l();for(const u of r.current.values())clearTimeout(u)}},[s]);const i=Array.from(e.values()),o=gt(i),a=i.find(l=>!ae(l))??i[0]??null,c=mt(i);return{syncs:i,hasSyncing:o,primarySync:a,aggregateProgress:c}},Tt=()=>{const e=d.useContext(Te);if(!e)throw new Error("useOperations must be used within an OperationsProvider");return e},Lr=({pluginID:e,connectionID:t,resourceKey:n})=>{const r=D(e),{showSnackbar:s}=k(),{addOperation:i,updateOperation:o}=Tt(),a=d.useRef([]);return d.useEffect(()=>()=>{a.current.forEach(l=>l())},[]),{startStreamAction:d.useCallback(async({actionID:l,id:u,namespace:h,label:_,params:p={}})=>{try{const C=await m.StreamAction(r,t,n,l,F.types.ActionInput.createFrom({id:u,namespace:h,params:p}));i({id:C,label:_,resourceKey:n,resourceName:u,namespace:h,connectionID:t,status:"running",startedAt:Date.now()});const y=`action/stream/${C}`,E=I.EventsOn(y,w=>{var P,f,S,b;switch(w.type){case"progress":{const v=w.data??{};o(C,{message:v.message,progress:v.ready!==void 0&&v.desired!==void 0?{ready:v.ready,desired:v.desired}:void 0});break}case"complete":o(C,{status:"completed",message:((P=w.data)==null?void 0:P.message)??"Completed",completedAt:Date.now()}),s(((f=w.data)==null?void 0:f.message)??_+" completed","success"),I.EventsOff(y);break;case"error":o(C,{status:"error",message:((S=w.data)==null?void 0:S.message)??"Failed",completedAt:Date.now()}),s(((b=w.data)==null?void 0:b.message)??_+" failed","error"),I.EventsOff(y);break}});return a.current.push(()=>{E(),I.EventsOff(y)}),C}catch(C){throw G(s,C,`Failed to start "${l}"`),C}},[r,t,n,i,o,s])}},qr=()=>{const e=d.useContext(Re);if(!e)throw new Error("useSettings must be used within a SettingsProvider");return e},Qr=({to:e,withinContext:t,...n})=>{const{meta:r}=fe();r.id||console.error("Link used outside of a plugin context");const s=`/_plugin/${r.id}${e.startsWith("/")?"":"/"}${e}`;return d.useMemo(()=>x.jsx(X.Link,{style:{textDecoration:"none",color:"inherit"},...n,to:s}),[n,s])};function jr(){const e=X.useNavigate(),t=X.useLocation(),{meta:n}=fe();n.id||console.error("usePluginRouter used outside of a plugin context");const r=`/_plugin/${n.id}`,s=t.pathname.startsWith(r)?t.pathname.slice(r.length)||"/":t.pathname,i=(o,a)=>{const{...c}=a??{};o.startsWith("/")?e(`${r}${o}`,c):e(o,c)};return d.useMemo(()=>({location:t,navigate:i,pluginPath:s}),[t.pathname])}class Gr{}class Ur{constructor(){$(this,"_extensions");$(this,"root");$(this,"pages");$(this,"_routes")}get extensions(){return this._extensions||[]}get Routes(){var t;if(!this._routes&&this.root)return[{path:"",index:!0,Component:this.root}];if(!((t=this._routes)!=null&&t.length))throw new Error("cannot use plugin without a root page or router");return this._routes}get Window(){if(!this._routes&&this.root)return x.jsx(this.root,{});const t=X.createMemoryRouter(this._routes||[]);return x.jsx(X.RouterProvider,{router:t})}registerExtensionPoints(t){return this._extensions=t||[],this}setRootPage(t){return this.root=t,this}withPage(t,n){return this.pages||(this.pages={}),this.pages[t]?(console.warn("Cannot register page with the same name. Please use a different name."),this):(this.pages[t]=n,this)}withRoutes(t){return this._routes=t,this}}var Mt=(e=>(e.MISSING_MANIFEST="MISSING_MANIFEST",e.MISSING_PLUGIN="MISSING_PLUGIN",e.MISSING_ENTRYPOINT="MISSING_ENTRYPOINT",e))(Mt||{});exports.ALL_SESSIONS_KEY=j;exports.BottomDrawerContext=it;exports.ConfirmationModalContext=ct;exports.ErrorTypes=ie;exports.ExtensionPointRegistry=Jt;exports.ExtensionPointStore=dt;exports.ExtensionProvider=Yt;exports.InformerResourceState=O;exports.InformerSyncPolicy=yt;exports.Link=Qr;exports.OperationsContext=Te;exports.OperationsProvider=Gt;exports.PluginContext=de;exports.PluginContextProvider=Lt;exports.PluginErrorCode=Mt;exports.PluginWindow=Ur;exports.PluginWindowRootProps=Gr;exports.RightDrawerContext=at;exports.SettingsContext=Re;exports.SettingsProvider=Qt;exports.SnackbarProvider=Xt;exports.actionToSnackbar=rt;exports.connectionListQueryKey=pt;exports.createErrorHandler=A;exports.defaultState=ot;exports.isCancelledError=Ae;exports.parseAppError=q;exports.showAppError=G;exports.useActiveSyncs=$r;exports.useBottomDrawer=ke;exports.useConfirmationModal=hn;exports.useConnection=Zt;exports.useConnectionNamespaces=tn;exports.useConnectionStatus=nn;exports.useConnections=en;exports.useEditorSchemas=Nr;exports.useExec=cn;exports.useExecuteAction=Mr;exports.useExtensionPoint=Bt;exports.useExtensionPointComponents=Ht;exports.useExtensionRegistry=Me;exports.useInformerState=kr;exports.useLogs=un;exports.useMetricProviders=ln;exports.useMetricProvidersForResource=Ct;exports.useMetricStream=fn;exports.useOperations=Tt;exports.usePluginContext=fe;exports.usePluginData=on;exports.usePluginRouter=jr;exports.usePluginSettings=qt;exports.usePortForwardSessions=pn;exports.useResolvedPluginId=D;exports.useResource=gn;exports.useResourceActions=Tr;exports.useResourceAreaComponent=mn;exports.useResourceGroups=_n;exports.useResourceMetrics=dn;exports.useResourceMutations=Rr;exports.useResourcePortForwarder=yn;exports.useResourceSearch=Cn;exports.useResourceType=Sn;exports.useResourceTypes=wn;exports.useResources=Ar;exports.useRightDrawer=an;exports.useSettings=qr;exports.useSnackbar=k;exports.useStreamAction=Lr;
@@ -0,0 +1,6 @@
1
+ export * from './context';
2
+ export * from './errors';
3
+ export * from './extensions';
4
+ export * from './hooks';
5
+ export * from './router';
6
+ export * from './types';