kubetsx 0.1.1 → 0.1.3
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/README.md +9 -1
- package/dist/cli.js +1 -1
- package/package.json +6 -1
- package/examples/basic.tsx +0 -71
- package/examples/full-stack.tsx +0 -339
- package/examples/tsconfig.json +0 -21
- package/src/cli.ts +0 -111
- package/src/components/index.ts +0 -241
- package/src/index.ts +0 -123
- package/src/jsx-runtime.ts +0 -71
- package/src/render.ts +0 -863
- package/src/types.ts +0 -362
- package/tsconfig.examples.json +0 -18
- package/tsconfig.json +0 -22
package/src/components/index.ts
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🎯 Kubetsx - Component Definitions
|
|
3
|
-
*
|
|
4
|
-
* All Kubernetes resource components as JSX elements
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { h } from '../jsx-runtime.js';
|
|
8
|
-
import type {
|
|
9
|
-
KubexElement,
|
|
10
|
-
KubexNode,
|
|
11
|
-
ManifestProps,
|
|
12
|
-
ClusterProps,
|
|
13
|
-
NamespaceProps,
|
|
14
|
-
DeploymentProps,
|
|
15
|
-
ContainerProps,
|
|
16
|
-
PortProps,
|
|
17
|
-
EnvProps,
|
|
18
|
-
SecretRefProps,
|
|
19
|
-
ConfigMapRefProps,
|
|
20
|
-
ResourcesProps,
|
|
21
|
-
ProbeProps,
|
|
22
|
-
HttpProbeProps,
|
|
23
|
-
TcpProbeProps,
|
|
24
|
-
ExecProbeProps,
|
|
25
|
-
ServiceProps,
|
|
26
|
-
IngressProps,
|
|
27
|
-
IngressHostProps,
|
|
28
|
-
RouteProps,
|
|
29
|
-
ConfigMapProps,
|
|
30
|
-
SecretProps,
|
|
31
|
-
VolumeProps,
|
|
32
|
-
VolumeMountProps,
|
|
33
|
-
EmptyDirProps,
|
|
34
|
-
PvcVolumeProps,
|
|
35
|
-
ConfigMapVolumeProps,
|
|
36
|
-
SecretVolumeProps,
|
|
37
|
-
PvcProps,
|
|
38
|
-
HpaProps,
|
|
39
|
-
JobProps,
|
|
40
|
-
CronJobProps,
|
|
41
|
-
ServiceAccountProps,
|
|
42
|
-
RoleProps,
|
|
43
|
-
ClusterRoleProps,
|
|
44
|
-
RoleBindingProps,
|
|
45
|
-
ClusterRoleBindingProps,
|
|
46
|
-
} from '../types.js';
|
|
47
|
-
|
|
48
|
-
// Helper to get children array
|
|
49
|
-
function getChildren(children: KubexNode | undefined): KubexNode[] {
|
|
50
|
-
if (!children) return [];
|
|
51
|
-
return Array.isArray(children) ? children : [children];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Cast helper
|
|
55
|
-
function toProps(props: object): Record<string, unknown> {
|
|
56
|
-
return props as Record<string, unknown>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// ============================================================================
|
|
60
|
-
// Manifest (Fragment alternative - groups multiple resources)
|
|
61
|
-
// ============================================================================
|
|
62
|
-
|
|
63
|
-
export function Manifest(props: ManifestProps): KubexElement {
|
|
64
|
-
return h('Manifest', toProps(props), ...getChildren(props.children));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// ============================================================================
|
|
68
|
-
// Cluster & Namespace
|
|
69
|
-
// ============================================================================
|
|
70
|
-
|
|
71
|
-
export function Cluster(props: ClusterProps): KubexElement {
|
|
72
|
-
return h('Cluster', toProps(props), ...getChildren(props.children));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function Namespace(props: NamespaceProps): KubexElement {
|
|
76
|
-
return h('Namespace', toProps(props), ...getChildren(props.children));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// ============================================================================
|
|
80
|
-
// Workloads
|
|
81
|
-
// ============================================================================
|
|
82
|
-
|
|
83
|
-
export function Deployment(props: DeploymentProps): KubexElement {
|
|
84
|
-
return h('Deployment', toProps(props), ...getChildren(props.children));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export function Container(props: ContainerProps & { children?: KubexNode }): KubexElement {
|
|
88
|
-
return h('Container', toProps(props), ...getChildren(props.children));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function Job(props: JobProps): KubexElement {
|
|
92
|
-
return h('Job', toProps(props), ...getChildren(props.children));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function CronJob(props: CronJobProps): KubexElement {
|
|
96
|
-
return h('CronJob', toProps(props), ...getChildren(props.children));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// ============================================================================
|
|
100
|
-
// Container Configuration
|
|
101
|
-
// ============================================================================
|
|
102
|
-
|
|
103
|
-
export function Port(props: PortProps): KubexElement {
|
|
104
|
-
return h('Port', toProps(props));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function Env(props: EnvProps): KubexElement {
|
|
108
|
-
return h('Env', toProps(props), ...getChildren(props.children));
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export function SecretRef(props: SecretRefProps): KubexElement {
|
|
112
|
-
return h('SecretRef', toProps(props));
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function ConfigMapRef(props: ConfigMapRefProps): KubexElement {
|
|
116
|
-
return h('ConfigMapRef', toProps(props));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export function Resources(props: ResourcesProps): KubexElement {
|
|
120
|
-
return h('Resources', toProps(props));
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// ============================================================================
|
|
124
|
-
// Probes
|
|
125
|
-
// ============================================================================
|
|
126
|
-
|
|
127
|
-
export function Probe(props: ProbeProps): KubexElement {
|
|
128
|
-
return h('Probe', toProps(props), ...getChildren(props.children));
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function HttpProbe(props: HttpProbeProps): KubexElement {
|
|
132
|
-
return h('HttpProbe', toProps(props));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
export function TcpProbe(props: TcpProbeProps): KubexElement {
|
|
136
|
-
return h('TcpProbe', toProps(props));
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function ExecProbe(props: ExecProbeProps): KubexElement {
|
|
140
|
-
return h('ExecProbe', toProps(props));
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ============================================================================
|
|
144
|
-
// Networking
|
|
145
|
-
// ============================================================================
|
|
146
|
-
|
|
147
|
-
export function Service(props: ServiceProps): KubexElement {
|
|
148
|
-
return h('Service', toProps(props));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function Ingress(props: IngressProps & { host?: string }): KubexElement {
|
|
152
|
-
return h('Ingress', toProps(props), ...getChildren(props.children));
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function IngressHost(props: IngressHostProps): KubexElement {
|
|
156
|
-
return h('IngressHost', toProps(props), ...getChildren(props.children));
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function Route(props: RouteProps): KubexElement {
|
|
160
|
-
return h('Route', toProps(props));
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
// ============================================================================
|
|
164
|
-
// Configuration
|
|
165
|
-
// ============================================================================
|
|
166
|
-
|
|
167
|
-
export function ConfigMap(props: ConfigMapProps): KubexElement {
|
|
168
|
-
return h('ConfigMap', toProps(props));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
export function Secret(props: SecretProps): KubexElement {
|
|
172
|
-
return h('Secret', toProps(props));
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// ============================================================================
|
|
176
|
-
// Volumes
|
|
177
|
-
// ============================================================================
|
|
178
|
-
|
|
179
|
-
export function Volume(props: VolumeProps): KubexElement {
|
|
180
|
-
return h('Volume', toProps(props), ...getChildren(props.children));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export function VolumeMount(props: VolumeMountProps): KubexElement {
|
|
184
|
-
return h('VolumeMount', toProps(props));
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export function EmptyDir(props: EmptyDirProps = {}): KubexElement {
|
|
188
|
-
return h('EmptyDir', toProps(props));
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export function PvcVolume(props: PvcVolumeProps): KubexElement {
|
|
192
|
-
return h('PvcVolume', toProps(props));
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export function ConfigMapVolume(props: ConfigMapVolumeProps): KubexElement {
|
|
196
|
-
return h('ConfigMapVolume', toProps(props));
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
export function SecretVolume(props: SecretVolumeProps): KubexElement {
|
|
200
|
-
return h('SecretVolume', toProps(props));
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ============================================================================
|
|
204
|
-
// Storage
|
|
205
|
-
// ============================================================================
|
|
206
|
-
|
|
207
|
-
export function Pvc(props: PvcProps): KubexElement {
|
|
208
|
-
return h('Pvc', toProps(props));
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
// ============================================================================
|
|
212
|
-
// Autoscaling
|
|
213
|
-
// ============================================================================
|
|
214
|
-
|
|
215
|
-
export function Hpa(props: HpaProps): KubexElement {
|
|
216
|
-
return h('Hpa', toProps(props));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// ============================================================================
|
|
220
|
-
// RBAC & Service Accounts
|
|
221
|
-
// ============================================================================
|
|
222
|
-
|
|
223
|
-
export function ServiceAccount(props: ServiceAccountProps): KubexElement {
|
|
224
|
-
return h('ServiceAccount', toProps(props));
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export function Role(props: RoleProps): KubexElement {
|
|
228
|
-
return h('Role', toProps(props));
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
export function ClusterRole(props: ClusterRoleProps): KubexElement {
|
|
232
|
-
return h('ClusterRole', toProps(props));
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export function RoleBinding(props: RoleBindingProps): KubexElement {
|
|
236
|
-
return h('RoleBinding', toProps(props));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
export function ClusterRoleBinding(props: ClusterRoleBindingProps): KubexElement {
|
|
240
|
-
return h('ClusterRoleBinding', toProps(props));
|
|
241
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🎯 Kubetsx - The Declarative Kubernetes Framework
|
|
3
|
-
*
|
|
4
|
-
* Write K8s configs with JSX. Yes, really.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// JSX Runtime
|
|
8
|
-
export { h, Fragment, jsx, jsxs, jsxDEV } from './jsx-runtime.js';
|
|
9
|
-
|
|
10
|
-
// Render Engine
|
|
11
|
-
export { render } from './render.js';
|
|
12
|
-
|
|
13
|
-
// Components
|
|
14
|
-
export {
|
|
15
|
-
// Manifest (groups multiple resources)
|
|
16
|
-
Manifest,
|
|
17
|
-
|
|
18
|
-
// Cluster & Namespace
|
|
19
|
-
Cluster,
|
|
20
|
-
Namespace,
|
|
21
|
-
|
|
22
|
-
// Workloads
|
|
23
|
-
Deployment,
|
|
24
|
-
Container,
|
|
25
|
-
Job,
|
|
26
|
-
CronJob,
|
|
27
|
-
|
|
28
|
-
// Container Configuration
|
|
29
|
-
Port,
|
|
30
|
-
Env,
|
|
31
|
-
SecretRef,
|
|
32
|
-
ConfigMapRef,
|
|
33
|
-
Resources,
|
|
34
|
-
|
|
35
|
-
// Probes
|
|
36
|
-
Probe,
|
|
37
|
-
HttpProbe,
|
|
38
|
-
TcpProbe,
|
|
39
|
-
ExecProbe,
|
|
40
|
-
|
|
41
|
-
// Networking
|
|
42
|
-
Service,
|
|
43
|
-
Ingress,
|
|
44
|
-
IngressHost,
|
|
45
|
-
Route,
|
|
46
|
-
|
|
47
|
-
// Configuration
|
|
48
|
-
ConfigMap,
|
|
49
|
-
Secret,
|
|
50
|
-
|
|
51
|
-
// Volumes
|
|
52
|
-
Volume,
|
|
53
|
-
VolumeMount,
|
|
54
|
-
EmptyDir,
|
|
55
|
-
PvcVolume,
|
|
56
|
-
ConfigMapVolume,
|
|
57
|
-
SecretVolume,
|
|
58
|
-
|
|
59
|
-
// Storage
|
|
60
|
-
Pvc,
|
|
61
|
-
|
|
62
|
-
// Autoscaling
|
|
63
|
-
Hpa,
|
|
64
|
-
|
|
65
|
-
// RBAC
|
|
66
|
-
ServiceAccount,
|
|
67
|
-
Role,
|
|
68
|
-
ClusterRole,
|
|
69
|
-
RoleBinding,
|
|
70
|
-
ClusterRoleBinding,
|
|
71
|
-
} from './components/index.js';
|
|
72
|
-
|
|
73
|
-
// Types
|
|
74
|
-
export type {
|
|
75
|
-
// Core
|
|
76
|
-
KubexElement,
|
|
77
|
-
KubexNode,
|
|
78
|
-
KubexComponent,
|
|
79
|
-
RenderOptions,
|
|
80
|
-
|
|
81
|
-
// K8s Types
|
|
82
|
-
K8sMetadata,
|
|
83
|
-
K8sResource,
|
|
84
|
-
|
|
85
|
-
// Component Props
|
|
86
|
-
ManifestProps,
|
|
87
|
-
ClusterProps,
|
|
88
|
-
NamespaceProps,
|
|
89
|
-
DeploymentProps,
|
|
90
|
-
ContainerProps,
|
|
91
|
-
PortProps,
|
|
92
|
-
EnvProps,
|
|
93
|
-
SecretRefProps,
|
|
94
|
-
ConfigMapRefProps,
|
|
95
|
-
ResourcesProps,
|
|
96
|
-
ProbeProps,
|
|
97
|
-
HttpProbeProps,
|
|
98
|
-
TcpProbeProps,
|
|
99
|
-
ExecProbeProps,
|
|
100
|
-
ServiceProps,
|
|
101
|
-
IngressProps,
|
|
102
|
-
IngressHostProps,
|
|
103
|
-
RouteProps,
|
|
104
|
-
ConfigMapProps,
|
|
105
|
-
SecretProps,
|
|
106
|
-
VolumeProps,
|
|
107
|
-
VolumeMountProps,
|
|
108
|
-
EmptyDirProps,
|
|
109
|
-
PvcVolumeProps,
|
|
110
|
-
ConfigMapVolumeProps,
|
|
111
|
-
SecretVolumeProps,
|
|
112
|
-
PvcProps,
|
|
113
|
-
HpaProps,
|
|
114
|
-
JobProps,
|
|
115
|
-
CronJobProps,
|
|
116
|
-
ServiceAccountProps,
|
|
117
|
-
RoleProps,
|
|
118
|
-
ClusterRoleProps,
|
|
119
|
-
RoleBindingProps,
|
|
120
|
-
ClusterRoleBindingProps,
|
|
121
|
-
RoleRule,
|
|
122
|
-
} from './types.js';
|
|
123
|
-
|
package/src/jsx-runtime.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 🎯 Kubetsx - JSX Runtime
|
|
3
|
-
*
|
|
4
|
-
* Custom JSX factory for Kubernetes components
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { KubexElement, KubexNode, KubexComponent } from './types.js';
|
|
8
|
-
|
|
9
|
-
// Helper to flatten children
|
|
10
|
-
function flattenChildren(children: KubexNode[]): KubexNode[] {
|
|
11
|
-
const result: KubexNode[] = [];
|
|
12
|
-
for (const child of children) {
|
|
13
|
-
if (Array.isArray(child)) {
|
|
14
|
-
result.push(...flattenChildren(child));
|
|
15
|
-
} else {
|
|
16
|
-
result.push(child);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return result;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* JSX Element Factory
|
|
24
|
-
*/
|
|
25
|
-
export function h(
|
|
26
|
-
type: string | KubexComponent,
|
|
27
|
-
props: Record<string, unknown> | null,
|
|
28
|
-
...children: KubexNode[]
|
|
29
|
-
): KubexElement {
|
|
30
|
-
return {
|
|
31
|
-
type,
|
|
32
|
-
props: props || {},
|
|
33
|
-
children: flattenChildren(children),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Fragment support
|
|
39
|
-
*/
|
|
40
|
-
export function Fragment(props: { children?: KubexNode }): KubexElement {
|
|
41
|
-
const children = props.children;
|
|
42
|
-
return {
|
|
43
|
-
type: 'Fragment',
|
|
44
|
-
props: {},
|
|
45
|
-
children: Array.isArray(children) ? children : children ? [children] : [],
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* JSX automatic runtime exports
|
|
51
|
-
*/
|
|
52
|
-
export function jsx(
|
|
53
|
-
type: string | KubexComponent,
|
|
54
|
-
props: Record<string, unknown> & { children?: KubexNode }
|
|
55
|
-
): KubexElement {
|
|
56
|
-
const { children, ...restProps } = props;
|
|
57
|
-
const childArray = children !== undefined
|
|
58
|
-
? (Array.isArray(children) ? children : [children])
|
|
59
|
-
: [];
|
|
60
|
-
return {
|
|
61
|
-
type,
|
|
62
|
-
props: restProps,
|
|
63
|
-
children: flattenChildren(childArray),
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export const jsxs = jsx;
|
|
68
|
-
export const jsxDEV = jsx;
|
|
69
|
-
|
|
70
|
-
// Default export for compatibility
|
|
71
|
-
export default { h, Fragment, jsx, jsxs, jsxDEV };
|