@prorobotech/openapi-k8s-toolkit 1.0.3 → 1.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/openapi-k8s-toolkit.es.js +704 -59
- package/dist/openapi-k8s-toolkit.es.js.map +1 -1
- package/dist/openapi-k8s-toolkit.umd.js +706 -57
- package/dist/openapi-k8s-toolkit.umd.js.map +1 -1
- package/dist/types/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.d.ts +4 -2
- package/dist/types/components/molecules/ManageableBreadcrumbs/utils.d.ts +2 -2
- package/dist/types/components/molecules/ManageableSidebar/ManageableSidebar.d.ts +4 -2
- package/dist/types/hooks/useK8sSmartResource.d.ts +29 -0
- package/dist/types/hooks/useK8sVerbs.d.ts +13 -0
- package/dist/types/hooks/useListThenWatch/index.d.ts +3 -0
- package/dist/types/hooks/useListThenWatch/reducer.d.ts +20 -0
- package/dist/types/hooks/useListThenWatch/types.d.ts +30 -0
- package/dist/types/hooks/useListThenWatch/useInfiniteSentinel.d.ts +2 -0
- package/dist/types/hooks/useListThenWatch/useListWatch.d.ts +71 -0
- package/dist/types/hooks/useListThenWatch/utils.d.ts +11 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -7,8 +7,10 @@ export type TManageableBreadcrumbsProps = {
|
|
|
7
7
|
};
|
|
8
8
|
export declare const ManageableBreadcrumbs: FC<TManageableBreadcrumbsProps>;
|
|
9
9
|
export type TManageableBreadcrumbsWithDataProviderProps = {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
cluster: string;
|
|
11
|
+
apiGroup: string;
|
|
12
|
+
apiVersion: string;
|
|
13
|
+
plural: string;
|
|
12
14
|
isEnabled?: boolean;
|
|
13
15
|
replaceValues: Record<string, string | undefined>;
|
|
14
16
|
pathname: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { BreadcrumbItemType } from 'antd/es/breadcrumb/Breadcrumb';
|
|
2
2
|
import { TLink } from './types';
|
|
3
3
|
export declare const prepareDataForManageableBreadcrumbs: ({ data, replaceValues, idToCompare, }: {
|
|
4
|
-
data: {
|
|
4
|
+
data: ({
|
|
5
5
|
id: string;
|
|
6
6
|
breadcrumbItems: TLink[];
|
|
7
|
-
}[];
|
|
7
|
+
} | undefined)[];
|
|
8
8
|
replaceValues: Record<string, string | undefined>;
|
|
9
9
|
pathname: string;
|
|
10
10
|
idToCompare: string;
|
|
@@ -9,8 +9,10 @@ export type TManageableSidebarProps = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const ManageableSidebar: FC<TManageableSidebarProps>;
|
|
11
11
|
export type TManageableSidebarWithDataProviderProps = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
cluster: string;
|
|
13
|
+
apiGroup: string;
|
|
14
|
+
apiVersion: string;
|
|
15
|
+
plural: string;
|
|
14
16
|
isEnabled?: boolean;
|
|
15
17
|
replaceValues: Record<string, string | undefined>;
|
|
16
18
|
pathname: string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { TSingleResource } from '../localTypes/k8s';
|
|
3
|
+
type UseK8sSmartResourceParams<T> = {
|
|
4
|
+
cluster: string;
|
|
5
|
+
group?: string;
|
|
6
|
+
version: string;
|
|
7
|
+
plural: string;
|
|
8
|
+
namespace?: string;
|
|
9
|
+
fieldSelector?: string;
|
|
10
|
+
labelSelector?: string;
|
|
11
|
+
limit?: number;
|
|
12
|
+
isEnabled?: boolean;
|
|
13
|
+
listRefetchInterval?: number | false;
|
|
14
|
+
mapListWatchState?: (state: {
|
|
15
|
+
order: string[];
|
|
16
|
+
byKey: Record<string, TSingleResource>;
|
|
17
|
+
}) => T;
|
|
18
|
+
};
|
|
19
|
+
type SmartResult<T> = {
|
|
20
|
+
data: T | undefined;
|
|
21
|
+
isLoading: boolean;
|
|
22
|
+
isError: boolean;
|
|
23
|
+
error: AxiosError | Error | string | undefined;
|
|
24
|
+
_meta?: {
|
|
25
|
+
used: 'list' | 'watch' | 'disabled' | 'verbs-loading' | 'verbs-error';
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const useK8sSmartResource: <T>({ cluster, group, version, plural, namespace, fieldSelector, labelSelector, isEnabled, listRefetchInterval, limit, mapListWatchState, }: UseK8sSmartResourceParams<T>) => SmartResult<T>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const useK8sVerbs: ({ cluster, group, version, plural, isEnabled, }: {
|
|
2
|
+
cluster: string;
|
|
3
|
+
group?: string | undefined;
|
|
4
|
+
version: string;
|
|
5
|
+
plural: string;
|
|
6
|
+
isEnabled?: boolean | undefined;
|
|
7
|
+
}) => {
|
|
8
|
+
canList: boolean;
|
|
9
|
+
canWatch: boolean;
|
|
10
|
+
isError: boolean;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TSingleResource } from '../../localTypes/k8s';
|
|
2
|
+
type TState = {
|
|
3
|
+
order: string[];
|
|
4
|
+
byKey: Record<string, TSingleResource>;
|
|
5
|
+
};
|
|
6
|
+
type TAction = {
|
|
7
|
+
type: 'RESET';
|
|
8
|
+
items: TSingleResource[];
|
|
9
|
+
} | {
|
|
10
|
+
type: 'APPEND_PAGE';
|
|
11
|
+
items: TSingleResource[];
|
|
12
|
+
} | {
|
|
13
|
+
type: 'UPSERT';
|
|
14
|
+
item: TSingleResource;
|
|
15
|
+
} | {
|
|
16
|
+
type: 'REMOVE';
|
|
17
|
+
key: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const reducer: (state: TState, action: TAction) => TState;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { TSingleResource } from '../../localTypes/k8s';
|
|
2
|
+
type TWatchPhase = 'ADDED' | 'MODIFIED' | 'DELETED' | 'BOOKMARK';
|
|
3
|
+
type TInitialFrame = {
|
|
4
|
+
type: 'INITIAL';
|
|
5
|
+
items: TSingleResource[];
|
|
6
|
+
continue?: string;
|
|
7
|
+
remainingItemCount?: number;
|
|
8
|
+
resourceVersion?: string;
|
|
9
|
+
};
|
|
10
|
+
type TPageFrame = {
|
|
11
|
+
type: 'PAGE';
|
|
12
|
+
items: TSingleResource[];
|
|
13
|
+
continue?: string;
|
|
14
|
+
remainingItemCount?: number;
|
|
15
|
+
};
|
|
16
|
+
type TPageErrorFrame = {
|
|
17
|
+
type: 'PAGE_ERROR';
|
|
18
|
+
error: string;
|
|
19
|
+
};
|
|
20
|
+
type TDeltaFrame = {
|
|
21
|
+
type: TWatchPhase;
|
|
22
|
+
item: TSingleResource;
|
|
23
|
+
};
|
|
24
|
+
export type TServerFrame = TInitialFrame | TPageFrame | TPageErrorFrame | TDeltaFrame;
|
|
25
|
+
export type TScrollMsg = {
|
|
26
|
+
type: 'SCROLL';
|
|
27
|
+
continue: string;
|
|
28
|
+
limit?: number;
|
|
29
|
+
};
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { TSingleResource } from '../../localTypes/k8s';
|
|
2
|
+
export type TConnStatus = 'connecting' | 'open' | 'closed';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters that define which resource collection we are listing/watching.
|
|
5
|
+
* These map to common Kubernetes list params and discovery fields.
|
|
6
|
+
*/
|
|
7
|
+
export type TUseListWatchQuery = {
|
|
8
|
+
namespace?: string;
|
|
9
|
+
apiGroup?: string;
|
|
10
|
+
apiVersion: string;
|
|
11
|
+
plural: string;
|
|
12
|
+
fieldSelector?: string;
|
|
13
|
+
labelSelector?: string;
|
|
14
|
+
initialLimit?: number;
|
|
15
|
+
initialContinue?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Hook configuration flags and callbacks.
|
|
19
|
+
*/
|
|
20
|
+
export type TUseListWatchOptions = {
|
|
21
|
+
/** Base WebSocket URL or path (http[s] will be auto-upgraded to ws[s]) */
|
|
22
|
+
wsUrl: string;
|
|
23
|
+
/** Page size for subsequent SCROLL requests */
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
/** Temporarily pause applying ADDED/MODIFIED/DELETED updates */
|
|
26
|
+
paused?: boolean;
|
|
27
|
+
/** Skip applying DELETED events when true */
|
|
28
|
+
ignoreRemove?: boolean;
|
|
29
|
+
/** Optional connection status observer */
|
|
30
|
+
onStatus?: (s: TConnStatus) => void;
|
|
31
|
+
/** Optional error observer */
|
|
32
|
+
onError?: (msg: string) => void;
|
|
33
|
+
/** If true, auto-fetch all remaining pages after snapshot */
|
|
34
|
+
autoDrain?: boolean;
|
|
35
|
+
/** If false, reset state when URL or query changes */
|
|
36
|
+
preserveStateOnUrlChange?: boolean;
|
|
37
|
+
/** Gate the hook on/off. When false, no WebSocket is opened. */
|
|
38
|
+
isEnabled?: boolean;
|
|
39
|
+
/** What to list/watch */
|
|
40
|
+
query: TUseListWatchQuery;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Values returned from the hook for rendering and control.
|
|
44
|
+
*/
|
|
45
|
+
export type TUseListWatchReturn = {
|
|
46
|
+
state: {
|
|
47
|
+
order: string[];
|
|
48
|
+
byKey: Record<string, TSingleResource>;
|
|
49
|
+
};
|
|
50
|
+
total: number;
|
|
51
|
+
hasMore: boolean;
|
|
52
|
+
continueToken?: string;
|
|
53
|
+
status: TConnStatus;
|
|
54
|
+
lastError?: string;
|
|
55
|
+
setPaused: (v: boolean) => void;
|
|
56
|
+
setIgnoreRemove: (v: boolean) => void;
|
|
57
|
+
/** Ask the server for the next page (if any) */
|
|
58
|
+
sendScroll: () => void;
|
|
59
|
+
/** Drain multiple pages sequentially (client-side pagination helper) */
|
|
60
|
+
drainAll: (opts?: {
|
|
61
|
+
maxPages?: number;
|
|
62
|
+
maxItems?: number;
|
|
63
|
+
}) => Promise<number>;
|
|
64
|
+
/** Manually reconnect the socket (cancels any pending auto-reconnect) */
|
|
65
|
+
reconnect: () => void;
|
|
66
|
+
/** Change the base WebSocket URL (will reconnect if enabled) */
|
|
67
|
+
setUrl: (next: string) => void;
|
|
68
|
+
/** Update the list/watch query (will reconnect if enabled) */
|
|
69
|
+
setQuery: (q: TUseListWatchQuery) => void;
|
|
70
|
+
};
|
|
71
|
+
export declare const useListWatch: ({ wsUrl, pageSize, paused, ignoreRemove, onStatus, onError, autoDrain, preserveStateOnUrlChange, isEnabled, query, }: TUseListWatchOptions) => TUseListWatchReturn;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TSingleResource } from '../../localTypes/k8s';
|
|
2
|
+
export declare const eventKey: (e: TSingleResource) => string;
|
|
3
|
+
export declare const compareRV: (a: string, b: string) => number;
|
|
4
|
+
type WithRV = {
|
|
5
|
+
metadata?: {
|
|
6
|
+
resourceVersion?: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare const getRV: (item: WithRV) => string | undefined;
|
|
10
|
+
export declare const getMaxRV: <T extends WithRV>(items: readonly T[]) => string | undefined;
|
|
11
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -23,6 +23,10 @@ export { useBuiltinResourceTypes } from './hooks/useBuiltinResourceTypes';
|
|
|
23
23
|
export { useCrdData } from './hooks/useCrdData';
|
|
24
24
|
export { useDirectUnknownResource } from './hooks/useDirectUnknownResource';
|
|
25
25
|
export { usePermissions } from './hooks/usePermissions';
|
|
26
|
+
export { useListWatch, useInfiniteSentinel } from './hooks/useListThenWatch';
|
|
27
|
+
export type { TConnStatus, TUseListWatchQuery, TUseListWatchOptions, TUseListWatchReturn, } from './hooks/useListThenWatch';
|
|
28
|
+
export { useK8sVerbs } from './hooks/useK8sVerbs';
|
|
29
|
+
export { useK8sSmartResource } from './hooks/useK8sSmartResource';
|
|
26
30
|
export type { TRequestError } from './localTypes/api';
|
|
27
31
|
export type { TClusterList } from './localTypes/clusterList';
|
|
28
32
|
export type { TItemTypeMap, TRenderableItem, TRendererComponents, TFactoryDataK8s, TFactoryResponse, TFactoryResource, } from './localTypes/dynamicRender';
|
package/package.json
CHANGED