@kite-dev/plugin-sdk 0.0.1
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/host-runtime.d.ts +26 -0
- package/dist/host-runtime.js +46 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +227 -0
- package/dist/types.js +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ButtonProps, KubeResourceTableProps, KitePluginHostRuntime, LogsViewerProps, PageProps, PanelProps, PluginOperationParams, PluginResourceDefinition, ResourceTableProps, SectionProps, SimpleResourceDetailProps, SimpleTableProps, TerminalProps } from './types';
|
|
3
|
+
declare global {
|
|
4
|
+
interface Window {
|
|
5
|
+
__KITE_PLUGIN_HOST__?: KitePluginHostRuntime;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function defineKitePlugin<T>(setup: T): T;
|
|
9
|
+
export declare function ResourceTable<T>(props: ResourceTableProps<T>): React.ReactElement | null;
|
|
10
|
+
export declare function SimpleTable<T>(props: SimpleTableProps<T>): React.ReactElement | null;
|
|
11
|
+
export declare function KubeResourceTable<T>(props: KubeResourceTableProps<T>): React.ReactElement | null;
|
|
12
|
+
export declare const SimpleResourceDetail: (props: SimpleResourceDetailProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
13
|
+
export declare const LogsViewer: (props: LogsViewerProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
14
|
+
export declare const Terminal: (props: TerminalProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
15
|
+
export declare const Page: (props: PageProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
16
|
+
export declare const Section: (props: SectionProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
17
|
+
export declare const Button: (props: ButtonProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
18
|
+
export declare const Panel: (props: PanelProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
19
|
+
export declare function getResource<T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams): Promise<T>;
|
|
20
|
+
export declare function updateResource<T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams, body: T): Promise<void>;
|
|
21
|
+
export declare function patchResource<T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams, body: T): Promise<void>;
|
|
22
|
+
export declare function deleteResource(resource: PluginResourceDefinition, params: PluginOperationParams, options?: {
|
|
23
|
+
force?: boolean;
|
|
24
|
+
wait?: boolean;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export type * from './types';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
const getHost = () => {
|
|
3
|
+
const host = window.__KITE_PLUGIN_HOST__;
|
|
4
|
+
if (!host) {
|
|
5
|
+
throw new Error('Kite plugin host runtime is not ready');
|
|
6
|
+
}
|
|
7
|
+
return host;
|
|
8
|
+
};
|
|
9
|
+
const createComponentProxy = (key) => (props) => {
|
|
10
|
+
const Component = getHost().components[key];
|
|
11
|
+
return React.createElement(Component, props);
|
|
12
|
+
};
|
|
13
|
+
export function defineKitePlugin(setup) {
|
|
14
|
+
return setup;
|
|
15
|
+
}
|
|
16
|
+
export function ResourceTable(props) {
|
|
17
|
+
const Component = getHost().components.ResourceTable;
|
|
18
|
+
return React.createElement(Component, props);
|
|
19
|
+
}
|
|
20
|
+
export function SimpleTable(props) {
|
|
21
|
+
const Component = getHost().components.SimpleTable;
|
|
22
|
+
return React.createElement(Component, props);
|
|
23
|
+
}
|
|
24
|
+
export function KubeResourceTable(props) {
|
|
25
|
+
const Component = getHost().components.KubeResourceTable;
|
|
26
|
+
return React.createElement(Component, props);
|
|
27
|
+
}
|
|
28
|
+
export const SimpleResourceDetail = createComponentProxy('SimpleResourceDetail');
|
|
29
|
+
export const LogsViewer = createComponentProxy('LogsViewer');
|
|
30
|
+
export const Terminal = createComponentProxy('Terminal');
|
|
31
|
+
export const Page = createComponentProxy('Page');
|
|
32
|
+
export const Section = createComponentProxy('Section');
|
|
33
|
+
export const Button = createComponentProxy('Button');
|
|
34
|
+
export const Panel = createComponentProxy('Panel');
|
|
35
|
+
export function getResource(resource, params) {
|
|
36
|
+
return getHost().api.getResource(resource, params);
|
|
37
|
+
}
|
|
38
|
+
export function updateResource(resource, params, body) {
|
|
39
|
+
return getHost().api.updateResource(resource, params, body);
|
|
40
|
+
}
|
|
41
|
+
export function patchResource(resource, params, body) {
|
|
42
|
+
return getHost().api.patchResource(resource, params, body);
|
|
43
|
+
}
|
|
44
|
+
export function deleteResource(resource, params, options) {
|
|
45
|
+
return getHost().api.deleteResource(resource, params, options);
|
|
46
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './host-runtime';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './host-runtime';
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ComponentType, HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type PluginMenuGroupId = 'plugin';
|
|
3
|
+
export type PluginResourceScope = 'namespaced' | 'cluster';
|
|
4
|
+
export interface BuiltinPluginResource {
|
|
5
|
+
source: 'builtin';
|
|
6
|
+
resourceType: string;
|
|
7
|
+
scope: PluginResourceScope;
|
|
8
|
+
}
|
|
9
|
+
export interface CRDPluginResource {
|
|
10
|
+
source: 'crd';
|
|
11
|
+
crdName: string;
|
|
12
|
+
kind: string;
|
|
13
|
+
scope: PluginResourceScope;
|
|
14
|
+
}
|
|
15
|
+
export type PluginResourceDefinition = BuiltinPluginResource | CRDPluginResource;
|
|
16
|
+
export interface PluginMenuDefinition {
|
|
17
|
+
groupId: PluginMenuGroupId;
|
|
18
|
+
title: string;
|
|
19
|
+
icon?: string;
|
|
20
|
+
after?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PluginRegistryListEntry {
|
|
23
|
+
routerName: string;
|
|
24
|
+
title: string;
|
|
25
|
+
resource: PluginResourceDefinition;
|
|
26
|
+
menu: PluginMenuDefinition;
|
|
27
|
+
}
|
|
28
|
+
export interface PluginRegistryDetailEntry {
|
|
29
|
+
routerName: string;
|
|
30
|
+
resource: PluginResourceDefinition;
|
|
31
|
+
}
|
|
32
|
+
export interface PluginRegistryEntry {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
version: string;
|
|
36
|
+
enabled: boolean;
|
|
37
|
+
entry: string;
|
|
38
|
+
lists?: PluginRegistryListEntry[];
|
|
39
|
+
details?: PluginRegistryDetailEntry[];
|
|
40
|
+
}
|
|
41
|
+
export interface PluginManifest {
|
|
42
|
+
schemaVersion: string;
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
sdkVersionRange: string;
|
|
47
|
+
hostVersionRange: string;
|
|
48
|
+
entry: string;
|
|
49
|
+
lists?: PluginRegistryListEntry[];
|
|
50
|
+
details?: PluginRegistryDetailEntry[];
|
|
51
|
+
}
|
|
52
|
+
export type InstalledPluginStatus = 'enabled' | 'disabled' | 'failed';
|
|
53
|
+
export interface InstalledPlugin {
|
|
54
|
+
id: number;
|
|
55
|
+
pluginId: string;
|
|
56
|
+
name: string;
|
|
57
|
+
version: string;
|
|
58
|
+
enabled: boolean;
|
|
59
|
+
status: InstalledPluginStatus;
|
|
60
|
+
manifestUrl: string;
|
|
61
|
+
assetUrl: string;
|
|
62
|
+
sdkVersionRange: string;
|
|
63
|
+
hostVersionRange: string;
|
|
64
|
+
errorMessage?: string;
|
|
65
|
+
installSource: string;
|
|
66
|
+
manifest?: PluginManifest;
|
|
67
|
+
createdAt: string;
|
|
68
|
+
updatedAt: string;
|
|
69
|
+
}
|
|
70
|
+
export interface PluginOperationParams {
|
|
71
|
+
name: string;
|
|
72
|
+
namespace?: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ResourceTableColumn<T> {
|
|
75
|
+
header: string;
|
|
76
|
+
render: (item: T, index: number) => ReactNode;
|
|
77
|
+
align?: 'left' | 'center' | 'right';
|
|
78
|
+
}
|
|
79
|
+
export interface ResourceTableProps<T> {
|
|
80
|
+
title?: ReactNode;
|
|
81
|
+
items: T[];
|
|
82
|
+
columns: ResourceTableColumn<T>[];
|
|
83
|
+
isLoading?: boolean;
|
|
84
|
+
error?: unknown;
|
|
85
|
+
emptyMessage?: string;
|
|
86
|
+
searchPlaceholder?: string;
|
|
87
|
+
searchText?: (item: T) => string;
|
|
88
|
+
getRowKey?: (item: T, index: number) => string;
|
|
89
|
+
onRefresh?: () => void | Promise<void>;
|
|
90
|
+
toolbar?: ReactNode;
|
|
91
|
+
namespace?: string;
|
|
92
|
+
setNamespace?: (namespace: string) => void;
|
|
93
|
+
clusterScope?: boolean;
|
|
94
|
+
}
|
|
95
|
+
export interface SimpleTableColumn<T> {
|
|
96
|
+
header: string;
|
|
97
|
+
accessor: (item: T) => unknown;
|
|
98
|
+
cell: (value: unknown, item: T) => ReactNode;
|
|
99
|
+
align?: 'left' | 'center' | 'right';
|
|
100
|
+
}
|
|
101
|
+
export interface SimpleTableProps<T> {
|
|
102
|
+
data: T[];
|
|
103
|
+
columns: SimpleTableColumn<T>[];
|
|
104
|
+
emptyMessage?: string;
|
|
105
|
+
}
|
|
106
|
+
export interface PageProps {
|
|
107
|
+
title?: ReactNode;
|
|
108
|
+
description?: ReactNode;
|
|
109
|
+
actions?: ReactNode;
|
|
110
|
+
children?: ReactNode;
|
|
111
|
+
}
|
|
112
|
+
export interface SectionProps {
|
|
113
|
+
title?: ReactNode;
|
|
114
|
+
description?: ReactNode;
|
|
115
|
+
children?: ReactNode;
|
|
116
|
+
}
|
|
117
|
+
export type ButtonProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
118
|
+
variant?: 'default' | 'destructive' | 'outline' | 'secondary' | 'ghost' | 'link';
|
|
119
|
+
size?: 'default' | 'sm' | 'lg' | 'icon';
|
|
120
|
+
};
|
|
121
|
+
export type PanelProps = HTMLAttributes<HTMLDivElement>;
|
|
122
|
+
export interface SimpleResourceDetailProps {
|
|
123
|
+
resourceType: string;
|
|
124
|
+
name: string;
|
|
125
|
+
namespace?: string;
|
|
126
|
+
}
|
|
127
|
+
export interface KubeResourceTableProps<T> {
|
|
128
|
+
resourceName: string;
|
|
129
|
+
resourceType?: string;
|
|
130
|
+
columns: unknown[];
|
|
131
|
+
clusterScope?: boolean;
|
|
132
|
+
searchQueryFilter?: (item: T, query: string) => boolean;
|
|
133
|
+
showCreateButton?: boolean;
|
|
134
|
+
onCreateClick?: () => void;
|
|
135
|
+
extraToolbars?: ReactNode[];
|
|
136
|
+
defaultHiddenColumns?: string[];
|
|
137
|
+
}
|
|
138
|
+
export interface PluginListPageProps<T = unknown> {
|
|
139
|
+
items: T[];
|
|
140
|
+
isLoading: boolean;
|
|
141
|
+
error?: unknown;
|
|
142
|
+
namespace?: string;
|
|
143
|
+
setNamespace?: (namespace: string) => void;
|
|
144
|
+
refetch: () => Promise<unknown> | unknown;
|
|
145
|
+
routeBase: string;
|
|
146
|
+
resource: PluginResourceDefinition;
|
|
147
|
+
}
|
|
148
|
+
export interface PluginDetailPageProps<T = unknown> {
|
|
149
|
+
item: T | null;
|
|
150
|
+
isLoading: boolean;
|
|
151
|
+
error?: unknown;
|
|
152
|
+
refetch: () => Promise<unknown> | unknown;
|
|
153
|
+
routeBase: string;
|
|
154
|
+
resource: PluginResourceDefinition;
|
|
155
|
+
}
|
|
156
|
+
export interface ResourceListRegistration<T = unknown> {
|
|
157
|
+
routerName: string;
|
|
158
|
+
component: ComponentType<PluginListPageProps<T>>;
|
|
159
|
+
}
|
|
160
|
+
export interface ResourceDetailRegistration<T = unknown> {
|
|
161
|
+
routerName: string;
|
|
162
|
+
component: ComponentType<PluginDetailPageProps<T>>;
|
|
163
|
+
}
|
|
164
|
+
export interface KitePluginSetupApi {
|
|
165
|
+
registerResourceList: <T = unknown>(def: ResourceListRegistration<T>) => void;
|
|
166
|
+
registerResourceDetail: <T = unknown>(def: ResourceDetailRegistration<T>) => void;
|
|
167
|
+
}
|
|
168
|
+
export interface LogsViewerProps {
|
|
169
|
+
namespace: string;
|
|
170
|
+
podName?: string;
|
|
171
|
+
pods?: Array<{
|
|
172
|
+
metadata?: {
|
|
173
|
+
name?: string;
|
|
174
|
+
};
|
|
175
|
+
}>;
|
|
176
|
+
labelSelector?: string;
|
|
177
|
+
containers?: Array<{
|
|
178
|
+
name: string;
|
|
179
|
+
}>;
|
|
180
|
+
initContainers?: Array<{
|
|
181
|
+
name: string;
|
|
182
|
+
}>;
|
|
183
|
+
onClose?: () => void;
|
|
184
|
+
}
|
|
185
|
+
export interface TerminalProps {
|
|
186
|
+
type?: 'node' | 'pod' | 'kubectl';
|
|
187
|
+
namespace?: string;
|
|
188
|
+
podName?: string;
|
|
189
|
+
nodeName?: string;
|
|
190
|
+
pods?: Array<{
|
|
191
|
+
metadata?: {
|
|
192
|
+
name?: string;
|
|
193
|
+
};
|
|
194
|
+
}>;
|
|
195
|
+
containers?: Array<{
|
|
196
|
+
name: string;
|
|
197
|
+
}>;
|
|
198
|
+
initContainers?: Array<{
|
|
199
|
+
name: string;
|
|
200
|
+
}>;
|
|
201
|
+
embedded?: boolean;
|
|
202
|
+
}
|
|
203
|
+
export interface KitePluginHostAPI {
|
|
204
|
+
getResource: <T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams) => Promise<T>;
|
|
205
|
+
updateResource: <T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams, body: T) => Promise<void>;
|
|
206
|
+
patchResource: <T = unknown>(resource: PluginResourceDefinition, params: PluginOperationParams, body: T) => Promise<void>;
|
|
207
|
+
deleteResource: (resource: PluginResourceDefinition, params: PluginOperationParams, options?: {
|
|
208
|
+
force?: boolean;
|
|
209
|
+
wait?: boolean;
|
|
210
|
+
}) => Promise<void>;
|
|
211
|
+
}
|
|
212
|
+
export interface KitePluginHostComponents {
|
|
213
|
+
ResourceTable: ComponentType<ResourceTableProps<unknown>>;
|
|
214
|
+
SimpleTable: ComponentType<SimpleTableProps<unknown>>;
|
|
215
|
+
SimpleResourceDetail: ComponentType<SimpleResourceDetailProps>;
|
|
216
|
+
KubeResourceTable: ComponentType<KubeResourceTableProps<unknown>>;
|
|
217
|
+
LogsViewer: ComponentType<LogsViewerProps>;
|
|
218
|
+
Terminal: ComponentType<TerminalProps>;
|
|
219
|
+
Page: ComponentType<PageProps>;
|
|
220
|
+
Section: ComponentType<SectionProps>;
|
|
221
|
+
Button: ComponentType<ButtonProps>;
|
|
222
|
+
Panel: ComponentType<PanelProps>;
|
|
223
|
+
}
|
|
224
|
+
export interface KitePluginHostRuntime {
|
|
225
|
+
api: KitePluginHostAPI;
|
|
226
|
+
components: KitePluginHostComponents;
|
|
227
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kite-dev/plugin-sdk",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/host-runtime.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/host-runtime.js"
|
|
11
|
+
},
|
|
12
|
+
"./host-runtime": "./dist/host-runtime.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"prepublishOnly": "pnpm run build"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@tanstack/react-query": "^5.90.21",
|
|
23
|
+
"react": "^19.2.4",
|
|
24
|
+
"react-dom": "^19.2.4",
|
|
25
|
+
"react-router-dom": "^7.13.1"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/react": "^19.2.14",
|
|
29
|
+
"@types/react-dom": "^19.2.3",
|
|
30
|
+
"typescript": "~5.9.3"
|
|
31
|
+
}
|
|
32
|
+
}
|