@highstate/library 0.9.18 → 0.9.19
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/highstate.library.msgpack +0 -0
- package/dist/index.js +3467 -3083
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/common/access-point.ts +105 -0
- package/src/{files.ts → common/files.ts} +10 -8
- package/src/common/index.ts +3 -0
- package/src/{common.ts → common/server.ts} +69 -38
- package/src/databases/index.ts +4 -0
- package/src/databases/mariadb.ts +37 -0
- package/src/databases/mongodb.ts +37 -0
- package/src/databases/postgresql.ts +37 -0
- package/src/databases/shared.ts +61 -0
- package/src/distributions/ubuntu.ts +6 -4
- package/src/dns.ts +110 -12
- package/src/git.ts +7 -3
- package/src/impl-ref.ts +26 -0
- package/src/index.ts +14 -15
- package/src/k3s.ts +7 -5
- package/src/k8s/apps/code-server.ts +48 -0
- package/src/k8s/apps/gitea.ts +25 -0
- package/src/k8s/apps/grocy.ts +39 -0
- package/src/k8s/apps/hubble.ts +30 -0
- package/src/{apps → k8s/apps}/index.ts +16 -13
- package/src/k8s/apps/kubernetes-dashboard.ts +28 -0
- package/src/k8s/apps/mariadb.ts +83 -0
- package/src/k8s/apps/maybe.ts +39 -0
- package/src/k8s/apps/mongodb.ts +84 -0
- package/src/k8s/apps/postgresql.ts +86 -0
- package/src/k8s/apps/shared.ts +149 -0
- package/src/{apps → k8s/apps}/syncthing.ts +27 -9
- package/src/k8s/apps/traefik.ts +40 -0
- package/src/k8s/apps/vaultwarden.ts +31 -0
- package/src/k8s/apps/workload.ts +214 -0
- package/src/k8s/apps/zitadel.ts +26 -0
- package/src/k8s/cert-manager.ts +80 -0
- package/src/k8s/cilium.ts +64 -0
- package/src/k8s/gateway.ts +70 -0
- package/src/k8s/index.ts +9 -0
- package/src/{obfuscators → k8s/obfuscators}/phantun.ts +10 -6
- package/src/{obfuscators → k8s/obfuscators}/shared.ts +11 -5
- package/src/k8s/resources.ts +111 -0
- package/src/k8s/service.ts +65 -0
- package/src/{k8s.ts → k8s/shared.ts} +35 -329
- package/src/k8s/workload.ts +77 -0
- package/src/network.ts +208 -22
- package/src/nixos.ts +23 -8
- package/src/proxmox.ts +62 -75
- package/src/restic.ts +15 -6
- package/src/sops.ts +16 -5
- package/src/ssh.ts +107 -9
- package/src/talos.ts +6 -4
- package/src/third-party/cloudflare.ts +59 -0
- package/src/third-party/index.ts +3 -0
- package/src/{mullvad.ts → third-party/mullvad.ts} +6 -4
- package/src/third-party/timeweb.ts +99 -0
- package/src/utils.ts +24 -3
- package/src/wireguard.ts +171 -48
- package/src/apps/code-server.ts +0 -34
- package/src/apps/deployment.ts +0 -60
- package/src/apps/dns.ts +0 -107
- package/src/apps/gitea.ts +0 -18
- package/src/apps/grocy.ts +0 -20
- package/src/apps/hubble.ts +0 -20
- package/src/apps/kubernetes-dashboard.ts +0 -19
- package/src/apps/mariadb.ts +0 -81
- package/src/apps/maybe.ts +0 -25
- package/src/apps/mongodb.ts +0 -81
- package/src/apps/network.ts +0 -55
- package/src/apps/postgresql.ts +0 -81
- package/src/apps/shared.ts +0 -289
- package/src/apps/test.ts +0 -19
- package/src/apps/traefik.ts +0 -36
- package/src/apps/vaultwarden.ts +0 -23
- package/src/apps/zitadel.ts +0 -21
- package/src/cloudflare.ts +0 -26
- package/src/timeweb.ts +0 -75
- package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
package/src/network.ts
CHANGED
@@ -1,19 +1,38 @@
|
|
1
|
+
import type { Simplify } from "type-fest"
|
1
2
|
import { defineEntity, defineUnit, z } from "@highstate/contract"
|
2
3
|
|
3
4
|
export const endpointVisibilitySchema = z.enum([
|
4
|
-
"public", //
|
5
|
-
"external", //
|
6
|
-
"internal", //
|
5
|
+
"public", // reachable from the public internet
|
6
|
+
"external", // reachable from outside the system boundary, but not public
|
7
|
+
"internal", // reachable only from within the system or cluster
|
7
8
|
])
|
8
9
|
|
9
10
|
export const endpointFilterSchema = endpointVisibilitySchema.array()
|
10
11
|
|
12
|
+
/**
|
13
|
+
* The L3 endpoint for some service.
|
14
|
+
*
|
15
|
+
* May be a domain name or an IP address.
|
16
|
+
*/
|
11
17
|
export const l3EndpointEntity = defineEntity({
|
12
|
-
type: "network.l3-endpoint",
|
18
|
+
type: "network.l3-endpoint.v1",
|
13
19
|
|
14
20
|
schema: z.intersection(
|
15
21
|
z.object({
|
22
|
+
/**
|
23
|
+
* The generic visibility of an endpoint.
|
24
|
+
*
|
25
|
+
* - `public`: reachable from the public internet;
|
26
|
+
* - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
|
27
|
+
* - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
28
|
+
*/
|
16
29
|
visibility: endpointVisibilitySchema,
|
30
|
+
|
31
|
+
/**
|
32
|
+
* The extra metadata for the endpoint.
|
33
|
+
*
|
34
|
+
* In most cases, this is provided by the endpoint origin (e.g., a Kubernetes service).
|
35
|
+
*/
|
17
36
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
18
37
|
}),
|
19
38
|
z.union([
|
@@ -46,25 +65,43 @@ export const l3EndpointEntity = defineEntity({
|
|
46
65
|
|
47
66
|
meta: {
|
48
67
|
color: "#4CAF50",
|
49
|
-
description: "The L3 endpoint for some service. May be a domain name or an IP address.",
|
50
68
|
},
|
51
69
|
})
|
52
70
|
|
53
71
|
export const l4ProtocolSchema = z.enum(["tcp", "udp"])
|
54
72
|
|
73
|
+
/**
|
74
|
+
* The schema for a TCP/UDP port.
|
75
|
+
*/
|
76
|
+
export const portSchema = z.number().int().min(1).max(65535)
|
77
|
+
|
78
|
+
/**
|
79
|
+
* The schema for an IPv4 prefix length.
|
80
|
+
*/
|
81
|
+
export const ipv4PrefixSchema = z.number().int().min(0).max(32)
|
82
|
+
|
83
|
+
/**
|
84
|
+
* The schema for address that can be either IPv4 or IPv6.
|
85
|
+
*/
|
86
|
+
export const ipv46Schema = z.union([z.ipv4(), z.ipv6()])
|
87
|
+
|
55
88
|
export const l4PortInfoSchema = z.object({
|
56
|
-
port:
|
89
|
+
port: portSchema,
|
57
90
|
protocol: l4ProtocolSchema,
|
58
91
|
})
|
59
92
|
|
93
|
+
/**
|
94
|
+
* The L4 endpoint for some service.
|
95
|
+
*
|
96
|
+
* Extends an L3 endpoint with a port and protocol.
|
97
|
+
*/
|
60
98
|
export const l4EndpointEntity = defineEntity({
|
61
|
-
type: "network.l4-endpoint",
|
99
|
+
type: "network.l4-endpoint.v1",
|
62
100
|
|
63
101
|
schema: z.intersection(l3EndpointEntity.schema, l4PortInfoSchema),
|
64
102
|
|
65
103
|
meta: {
|
66
104
|
color: "#2196F3",
|
67
|
-
description: "The L4 endpoint for some service. Extends an L3 endpoint with a port.",
|
68
105
|
},
|
69
106
|
})
|
70
107
|
|
@@ -83,20 +120,26 @@ export const l7AppInfoSchema = z.object({
|
|
83
120
|
resource: z.string().optional(),
|
84
121
|
})
|
85
122
|
|
123
|
+
/**
|
124
|
+
* The L7 endpoint for some service.
|
125
|
+
*
|
126
|
+
* Extends an L4 endpoint with application protocol information.
|
127
|
+
*/
|
86
128
|
export const l7EndpointEntity = defineEntity({
|
87
|
-
type: "network.l7-endpoint",
|
129
|
+
type: "network.l7-endpoint.v1",
|
88
130
|
|
89
131
|
schema: z.intersection(l4EndpointEntity.schema, l7AppInfoSchema),
|
90
132
|
|
91
133
|
meta: {
|
92
134
|
color: "#FF9800",
|
93
|
-
description:
|
94
|
-
"The L7 endpoint for some service. Extends an L4 endpoint with application protocol information.",
|
95
135
|
},
|
96
136
|
})
|
97
137
|
|
138
|
+
/**
|
139
|
+
* The component which creates an L3 endpoint.
|
140
|
+
*/
|
98
141
|
export const l3Endpoint = defineUnit({
|
99
|
-
type: "network.l3-endpoint",
|
142
|
+
type: "network.l3-endpoint.v1",
|
100
143
|
|
101
144
|
args: {
|
102
145
|
/**
|
@@ -108,6 +151,13 @@ export const l3Endpoint = defineUnit({
|
|
108
151
|
|
109
152
|
/**
|
110
153
|
* The visibility of the endpoint.
|
154
|
+
*
|
155
|
+
* The visibility levels are:
|
156
|
+
* - `public`: reachable from the public internet;
|
157
|
+
* - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
|
158
|
+
* - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
159
|
+
*
|
160
|
+
* If not specified, defaults to `public`.
|
111
161
|
*/
|
112
162
|
visibility: endpointVisibilitySchema.default("public"),
|
113
163
|
},
|
@@ -118,7 +168,6 @@ export const l3Endpoint = defineUnit({
|
|
118
168
|
|
119
169
|
meta: {
|
120
170
|
title: "L3 Endpoint",
|
121
|
-
description: "An L3 endpoint for some service. May be a domain name or an IP address.",
|
122
171
|
icon: "mdi:network-outline",
|
123
172
|
iconColor: "#4CAF50",
|
124
173
|
defaultNamePrefix: "endpoint",
|
@@ -131,8 +180,11 @@ export const l3Endpoint = defineUnit({
|
|
131
180
|
},
|
132
181
|
})
|
133
182
|
|
183
|
+
/**
|
184
|
+
* The component which creates an L4 endpoint.
|
185
|
+
*/
|
134
186
|
export const l4Endpoint = defineUnit({
|
135
|
-
type: "network.l4-endpoint",
|
187
|
+
type: "network.l4-endpoint.v1",
|
136
188
|
|
137
189
|
args: {
|
138
190
|
/**
|
@@ -150,6 +202,13 @@ export const l4Endpoint = defineUnit({
|
|
150
202
|
|
151
203
|
/**
|
152
204
|
* The visibility of the endpoint.
|
205
|
+
*
|
206
|
+
* The visibility levels are:
|
207
|
+
* - `public`: reachable from the public internet;
|
208
|
+
* - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
|
209
|
+
* - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
210
|
+
*
|
211
|
+
* If not specified, defaults to `public`.
|
153
212
|
*/
|
154
213
|
visibility: endpointVisibilitySchema.default("public"),
|
155
214
|
},
|
@@ -160,7 +219,6 @@ export const l4Endpoint = defineUnit({
|
|
160
219
|
|
161
220
|
meta: {
|
162
221
|
title: "L4 Endpoint",
|
163
|
-
description: "An L4 endpoint for some service. Extends an L3 endpoint with a port.",
|
164
222
|
icon: "mdi:network-outline",
|
165
223
|
iconColor: "#2196F3",
|
166
224
|
defaultNamePrefix: "endpoint",
|
@@ -173,12 +231,126 @@ export const l4Endpoint = defineUnit({
|
|
173
231
|
},
|
174
232
|
})
|
175
233
|
|
234
|
+
/**
|
235
|
+
* The component which creates an L7 endpoint.
|
236
|
+
*/
|
237
|
+
export const l7Endpoint = defineUnit({
|
238
|
+
type: "network.l7-endpoint.v1",
|
239
|
+
|
240
|
+
args: {
|
241
|
+
/**
|
242
|
+
* The string representation of the endpoint.
|
243
|
+
*
|
244
|
+
* The possible formats are:
|
245
|
+
*
|
246
|
+
* - `https://endpoint:port/resource`
|
247
|
+
* - `ftp://endpoint:port/resource`
|
248
|
+
* - `someotherprotocol://endpoint:port/resource`
|
249
|
+
*/
|
250
|
+
endpoint: z.string(),
|
251
|
+
|
252
|
+
/**
|
253
|
+
* The visibility of the endpoint.
|
254
|
+
*
|
255
|
+
* The visibility levels are:
|
256
|
+
* - `public`: reachable from the public internet;
|
257
|
+
* - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
|
258
|
+
* - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
259
|
+
*
|
260
|
+
* If not specified, defaults to `public`.
|
261
|
+
*/
|
262
|
+
visibility: endpointVisibilitySchema.default("public"),
|
263
|
+
},
|
264
|
+
|
265
|
+
outputs: {
|
266
|
+
endpoint: l7EndpointEntity,
|
267
|
+
},
|
268
|
+
|
269
|
+
meta: {
|
270
|
+
title: "L7 Endpoint",
|
271
|
+
icon: "mdi:network-outline",
|
272
|
+
iconColor: "#FF9800",
|
273
|
+
defaultNamePrefix: "endpoint",
|
274
|
+
category: "Network",
|
275
|
+
},
|
276
|
+
|
277
|
+
source: {
|
278
|
+
package: "@highstate/common",
|
279
|
+
path: "units/network/l7-endpoint",
|
280
|
+
},
|
281
|
+
})
|
282
|
+
|
283
|
+
/**
|
284
|
+
* Explicitly filter endpoints by their accessibility.
|
285
|
+
*/
|
286
|
+
export const endpointFilter = defineUnit({
|
287
|
+
type: "network.endpoint-filter.v1",
|
288
|
+
|
289
|
+
args: {
|
290
|
+
/**
|
291
|
+
* The endpoint filter to filter the endpoints before creating the DNS records.
|
292
|
+
*
|
293
|
+
* Possible values:
|
294
|
+
*
|
295
|
+
* - `public`: only endpoints exposed to the public internet;
|
296
|
+
* - `external`: reachable from outside the system but not public (e.g., LAN, VPC);
|
297
|
+
* - `internal`: reachable only from within the system boundary (e.g., inside a cluster).
|
298
|
+
*
|
299
|
+
* You can select one or more values.
|
300
|
+
*
|
301
|
+
* If no value is provided, the endpoints will be filtered by the most accessible type:
|
302
|
+
*
|
303
|
+
* - if any public endpoints exist, all public endpoints are selected;
|
304
|
+
* - otherwise, if any external endpoints exist, all external endpoints are selected;
|
305
|
+
* - if neither exist, all internal endpoints are selected.
|
306
|
+
*/
|
307
|
+
endpointFilter: endpointFilterSchema.default([]),
|
308
|
+
},
|
309
|
+
|
310
|
+
inputs: {
|
311
|
+
l3Endpoints: {
|
312
|
+
entity: l3EndpointEntity,
|
313
|
+
multiple: true,
|
314
|
+
required: false,
|
315
|
+
},
|
316
|
+
l4Endpoints: {
|
317
|
+
entity: l4EndpointEntity,
|
318
|
+
multiple: true,
|
319
|
+
required: false,
|
320
|
+
},
|
321
|
+
},
|
322
|
+
|
323
|
+
outputs: {
|
324
|
+
l3Endpoints: {
|
325
|
+
entity: l3EndpointEntity,
|
326
|
+
multiple: true,
|
327
|
+
},
|
328
|
+
l4Endpoints: {
|
329
|
+
entity: l4EndpointEntity,
|
330
|
+
multiple: true,
|
331
|
+
},
|
332
|
+
},
|
333
|
+
|
334
|
+
meta: {
|
335
|
+
title: "Endpoint Filter",
|
336
|
+
icon: "mdi:network-outline",
|
337
|
+
iconColor: "#FF9800",
|
338
|
+
secondaryIcon: "mdi:filter-outline",
|
339
|
+
category: "Network",
|
340
|
+
},
|
341
|
+
|
342
|
+
source: {
|
343
|
+
package: "@highstate/common",
|
344
|
+
path: "units/network/endpoint-filter",
|
345
|
+
},
|
346
|
+
})
|
347
|
+
|
176
348
|
/**
|
177
349
|
* The generic visibility of an endpoint.
|
178
350
|
*
|
179
|
-
* - `public`:
|
180
|
-
* - `external`:
|
181
|
-
* - `internal`:
|
351
|
+
* - `public`: reachable from the public internet;
|
352
|
+
* - `external`: reachable from outside the system boundary (e.g., LAN, VPC), but not public;
|
353
|
+
* - `internal`: reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
182
354
|
*/
|
183
355
|
export type EndpointVisibility = z.infer<typeof endpointVisibilitySchema>
|
184
356
|
|
@@ -192,14 +364,28 @@ export type EndpointVisibility = z.infer<typeof endpointVisibilitySchema>
|
|
192
364
|
*/
|
193
365
|
export type EndpointFilter = z.infer<typeof endpointFilterSchema>
|
194
366
|
|
195
|
-
export type L3Endpoint = z.infer<typeof l3EndpointEntity.schema
|
196
|
-
export type L4Endpoint = z.infer<typeof l4EndpointEntity.schema
|
367
|
+
export type L3Endpoint = Simplify<z.infer<typeof l3EndpointEntity.schema>>
|
368
|
+
export type L4Endpoint = Simplify<z.infer<typeof l4EndpointEntity.schema>>
|
197
369
|
export type L4Protocol = z.infer<typeof l4ProtocolSchema>
|
198
370
|
export type L4PortInfo = z.infer<typeof l4PortInfoSchema>
|
199
|
-
export type L7Endpoint = z.infer<typeof l7EndpointEntity.schema
|
371
|
+
export type L7Endpoint = Simplify<z.infer<typeof l7EndpointEntity.schema>>
|
200
372
|
export type L7AppInfo = z.infer<typeof l7AppInfoSchema>
|
201
373
|
|
374
|
+
export const l34EndpointSchema = z.union([
|
375
|
+
z.intersection(
|
376
|
+
l3EndpointEntity.schema,
|
377
|
+
z.object({
|
378
|
+
port: z.undefined().optional(),
|
379
|
+
protocol: z.undefined().optional(),
|
380
|
+
}),
|
381
|
+
),
|
382
|
+
l4EndpointEntity.schema,
|
383
|
+
])
|
384
|
+
|
202
385
|
/**
|
203
386
|
* The L3 or L4 endpoint for some service.
|
387
|
+
*
|
388
|
+
* For convenience, L3 case have `port` and `protocol` fields as `undefined`,
|
389
|
+
* so you can check any of them to determine if it's an L3 or L4 endpoint.
|
204
390
|
*/
|
205
|
-
export type L34Endpoint =
|
391
|
+
export type L34Endpoint = Simplify<z.infer<typeof l34EndpointSchema>>
|
package/src/nixos.ts
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
import { defineUnit, z } from "@highstate/contract"
|
2
|
-
import { fileEntity, folderEntity } from "./files"
|
3
|
-
import { serverEntity } from "./common"
|
2
|
+
import { fileEntity, folderEntity } from "./common/files"
|
3
|
+
import { serverEntity } from "./common/server"
|
4
4
|
|
5
|
+
/**
|
6
|
+
* Creates a NixOS module from inline code.
|
7
|
+
*/
|
5
8
|
export const inlineModule = defineUnit({
|
6
|
-
type: "nixos.inline-module",
|
9
|
+
type: "nixos.inline-module.v1",
|
7
10
|
|
8
11
|
args: {
|
9
12
|
/**
|
@@ -40,7 +43,6 @@ export const inlineModule = defineUnit({
|
|
40
43
|
|
41
44
|
meta: {
|
42
45
|
title: "NixOS Inline Module",
|
43
|
-
description: "Creates a NixOS module from inline code.",
|
44
46
|
icon: "simple-icons:nixos",
|
45
47
|
iconColor: "#7ebae4",
|
46
48
|
secondaryIcon: "mdi:file-code",
|
@@ -53,8 +55,14 @@ export const inlineModule = defineUnit({
|
|
53
55
|
},
|
54
56
|
})
|
55
57
|
|
58
|
+
/**
|
59
|
+
* Creates a NixOS flake from inline code.
|
60
|
+
*
|
61
|
+
* This unit allows you to define a NixOS flake directly in the unit code.
|
62
|
+
* It can reference other flakes, modules, files, and folders by their names.
|
63
|
+
*/
|
56
64
|
export const inlineFlake = defineUnit({
|
57
|
-
type: "nixos.inline-flake",
|
65
|
+
type: "nixos.inline-flake.v1",
|
58
66
|
|
59
67
|
args: {
|
60
68
|
/**
|
@@ -91,7 +99,6 @@ export const inlineFlake = defineUnit({
|
|
91
99
|
|
92
100
|
meta: {
|
93
101
|
title: "NixOS Inline Flake",
|
94
|
-
description: "Creates a NixOS flake from inline code.",
|
95
102
|
icon: "simple-icons:nixos",
|
96
103
|
iconColor: "#7ebae4",
|
97
104
|
secondaryIcon: "mdi:file-code",
|
@@ -104,8 +111,17 @@ export const inlineFlake = defineUnit({
|
|
104
111
|
},
|
105
112
|
})
|
106
113
|
|
114
|
+
/**
|
115
|
+
* Creates a NixOS system on top of any server.
|
116
|
+
*
|
117
|
+
* This unit allows you to define a NixOS system configuration that will be applied to the server.
|
118
|
+
* It can reference other modules, files, and folders by their names.
|
119
|
+
*
|
120
|
+
* To create a NixOS system, it will use `nixos-anywhere` which will use kexec
|
121
|
+
* to boot into the new kernel to install NixOS.
|
122
|
+
*/
|
107
123
|
export const system = defineUnit({
|
108
|
-
type: "nixos.system",
|
124
|
+
type: "nixos.system.v1",
|
109
125
|
|
110
126
|
args: {
|
111
127
|
system: z.string().optional(),
|
@@ -122,7 +138,6 @@ export const system = defineUnit({
|
|
122
138
|
|
123
139
|
meta: {
|
124
140
|
title: "NixOS System",
|
125
|
-
description: "Creates a NixOS system on top of any server.",
|
126
141
|
icon: "simple-icons:nixos",
|
127
142
|
iconColor: "#7ebae4",
|
128
143
|
secondaryIcon: "codicon:vm",
|