kubetsx 0.1.0
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/LICENSE +22 -0
- package/README.md +371 -0
- package/dist/components/index.d.ts +46 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +155 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-runtime.d.ts +33 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +58 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/render.d.ts +12 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +746 -0
- package/dist/render.js.map +1 -0
- package/dist/types.d.ts +339 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/examples/basic.tsx +71 -0
- package/examples/full-stack.tsx +339 -0
- package/examples/tsconfig.json +21 -0
- package/package.json +57 -0
- package/src/components/index.ts +241 -0
- package/src/index.ts +123 -0
- package/src/jsx-runtime.ts +71 -0
- package/src/render.ts +862 -0
- package/src/types.ts +362 -0
- package/tsconfig.examples.json +18 -0
- package/tsconfig.json +22 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
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 };
|