@highstate/library 0.21.1 → 0.26.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.
Files changed (58) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +3934 -1838
  3. package/package.json +3 -3
  4. package/src/abbreviations.ts +2 -0
  5. package/src/apps/index.ts +1 -0
  6. package/src/apps/vault.ts +374 -0
  7. package/src/common/access-point.ts +152 -9
  8. package/src/common/filter.ts +40 -0
  9. package/src/common/index.ts +1 -0
  10. package/src/common/server.ts +131 -1
  11. package/src/databases/etcd.ts +12 -4
  12. package/src/databases/index.ts +1 -0
  13. package/src/databases/minio.ts +19 -0
  14. package/src/databases/mongodb.ts +12 -4
  15. package/src/databases/mysql.ts +12 -4
  16. package/src/databases/postgresql.ts +12 -4
  17. package/src/databases/rustfs.ts +169 -0
  18. package/src/dns.ts +3 -3
  19. package/src/index.ts +3 -2
  20. package/src/k3s.ts +129 -3
  21. package/src/k8s/apps/envoy-gateway.ts +50 -0
  22. package/src/k8s/apps/etcd.ts +1 -1
  23. package/src/k8s/apps/grafana.ts +1 -1
  24. package/src/k8s/apps/index.ts +4 -0
  25. package/src/k8s/apps/mariadb.ts +1 -1
  26. package/src/k8s/apps/matrix-stack.ts +2 -1
  27. package/src/k8s/apps/minio.ts +2 -2
  28. package/src/k8s/apps/mongodb.ts +1 -1
  29. package/src/k8s/apps/postgresql.ts +1 -1
  30. package/src/k8s/apps/rustfs.ts +119 -0
  31. package/src/k8s/apps/shared.ts +16 -1
  32. package/src/k8s/apps/signoz.ts +32 -0
  33. package/src/k8s/apps/traefik.ts +5 -5
  34. package/src/k8s/apps/valkey.ts +1 -1
  35. package/src/k8s/apps/vault.ts +113 -0
  36. package/src/k8s/apps/vaultwarden.ts +31 -2
  37. package/src/k8s/apps/workload.ts +12 -14
  38. package/src/k8s/cert-manager.ts +44 -2
  39. package/src/k8s/cilium.ts +3 -16
  40. package/src/k8s/coredns.ts +62 -0
  41. package/src/k8s/gateway.ts +25 -0
  42. package/src/k8s/index.ts +1 -0
  43. package/src/k8s/scheduling.ts +87 -0
  44. package/src/k8s/service-args.ts +109 -0
  45. package/src/k8s/shared.ts +26 -0
  46. package/src/k8s/workload.ts +21 -0
  47. package/src/netaminity.ts +950 -0
  48. package/src/network/endpoint.ts +12 -1
  49. package/src/network/index.ts +1 -0
  50. package/src/network/network.ts +58 -0
  51. package/src/restic.ts +2 -1
  52. package/src/ssh.ts +27 -0
  53. package/src/third-party/gcp.ts +427 -0
  54. package/src/third-party/index.ts +1 -0
  55. package/src/third-party/yandex.ts +210 -1
  56. package/src/tls.ts +135 -6
  57. package/src/utils.ts +16 -1
  58. package/src/wireguard.ts +257 -4
@@ -7,7 +7,7 @@ import {
7
7
  type EntityValue,
8
8
  z,
9
9
  } from "@highstate/contract"
10
- import { l3EndpointContainer, l3EndpointEntity } from "../network"
10
+ import { l3EndpointContainer, l3EndpointEntity, networkEntity } from "../network"
11
11
  import * as ssh from "../ssh"
12
12
 
13
13
  /**
@@ -108,6 +108,12 @@ export const existingServer = defineUnit({
108
108
  multiple: true,
109
109
  },
110
110
 
111
+ networks: {
112
+ entity: networkEntity,
113
+ required: false,
114
+ multiple: true,
115
+ },
116
+
111
117
  ...ssh.inputs,
112
118
  },
113
119
 
@@ -206,5 +212,129 @@ export const script = defineUnit({
206
212
  },
207
213
  })
208
214
 
215
+ /**
216
+ * Runs a shell script on multiple servers.
217
+ */
218
+ export const scriptV2 = defineUnit({
219
+ type: "common.script.v2",
220
+
221
+ args: {
222
+ /**
223
+ * The script to run when the unit is created.
224
+ */
225
+ script: z.string().meta({ language: "shell" }),
226
+
227
+ /**
228
+ * The script to run when the unit is updated.
229
+ */
230
+ updateScript: z.string().optional().meta({ language: "shell" }),
231
+
232
+ /**
233
+ * The script to run when the unit is deleted.
234
+ */
235
+ deleteScript: z.string().optional().meta({ language: "shell" }),
236
+ },
237
+
238
+ inputs: {
239
+ servers: {
240
+ entity: serverEntity,
241
+ multiple: true,
242
+ },
243
+ },
244
+
245
+ outputs: {
246
+ servers: {
247
+ entity: serverEntity,
248
+ multiple: true,
249
+ },
250
+ },
251
+
252
+ meta: {
253
+ title: "Shell Script",
254
+ icon: "mdi:bash",
255
+ category: "Infrastructure",
256
+ },
257
+
258
+ source: {
259
+ package: "@highstate/common",
260
+ path: "units/script-v2",
261
+ },
262
+ })
263
+
264
+ /**
265
+ * Runs a shell script as a systemd service on multiple servers.
266
+ */
267
+ export const systemdUnit = defineUnit({
268
+ type: "common.systemd.unit.v1",
269
+
270
+ args: {
271
+ /**
272
+ * The script to run as the systemd service.
273
+ */
274
+ script: z.string().meta({ language: "shell" }),
275
+
276
+ /**
277
+ * The name of the systemd service.
278
+ *
279
+ * By default, the Highstate unit name is used with dots replaced by hyphens.
280
+ */
281
+ serviceName: z.string().optional(),
282
+
283
+ /**
284
+ * The systemd service type.
285
+ *
286
+ * Oneshot services remain active after the script exits and run again after each boot.
287
+ */
288
+ type: z.enum(["simple", "oneshot"]).default("simple"),
289
+
290
+ /**
291
+ * The systemd units that must be started before this service.
292
+ */
293
+ after: z.string().array().default(["network-online.target"]),
294
+
295
+ /**
296
+ * The systemd units that should be started with this service.
297
+ */
298
+ wants: z.string().array().default(["network-online.target"]),
299
+
300
+ /**
301
+ * The systemd units that are required by this service.
302
+ */
303
+ requires: z.string().array().default([]),
304
+
305
+ /**
306
+ * Additional systemd INI configuration appended to the generated service file.
307
+ *
308
+ * It can add sections or override generated directives using systemd's normal INI semantics.
309
+ */
310
+ extraConfig: z.string().default("").meta({ language: "ini" }),
311
+ },
312
+
313
+ inputs: {
314
+ servers: {
315
+ entity: serverEntity,
316
+ multiple: true,
317
+ },
318
+ },
319
+
320
+ outputs: {
321
+ servers: {
322
+ entity: serverEntity,
323
+ multiple: true,
324
+ },
325
+ },
326
+
327
+ meta: {
328
+ title: "Systemd Unit",
329
+ icon: "material-icon-theme:systemd",
330
+ category: "Infrastructure",
331
+ },
332
+
333
+ source: {
334
+ package: "@highstate/common",
335
+ path: "units/systemd/unit",
336
+ },
337
+ })
338
+
209
339
  export type Server = EntityValue<typeof serverEntity>
210
340
  export type ServerInput = EntityInput<typeof serverEntity>
@@ -6,8 +6,8 @@ import {
6
6
  secretSchema,
7
7
  z,
8
8
  } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
9
10
  import { l4EndpointContainer, l4EndpointEntity } from "../network"
10
- import { certificateEntity } from "../tls"
11
11
 
12
12
  /**
13
13
  * The credentials for authenticating to the etcd cluster.
@@ -38,10 +38,10 @@ export const connectionEntity = defineEntity({
38
38
 
39
39
  includes: {
40
40
  /**
41
- * The TLS certificate of the server if any.
41
+ * The CA certificate file used to verify the server if any.
42
42
  */
43
- certificate: {
44
- entity: certificateEntity,
43
+ ca: {
44
+ entity: fileEntity,
45
45
  required: false,
46
46
  },
47
47
  },
@@ -92,6 +92,14 @@ export const connection = defineUnit({
92
92
  multiple: true,
93
93
  required: false,
94
94
  },
95
+
96
+ /**
97
+ * The CA certificate file used to verify the server if any.
98
+ */
99
+ ca: {
100
+ entity: fileEntity,
101
+ required: false,
102
+ },
95
103
  },
96
104
 
97
105
  outputs: {
@@ -5,4 +5,5 @@ export * as mongodb from "./mongodb"
5
5
  export * as mysql from "./mysql"
6
6
  export * as postgresql from "./postgresql"
7
7
  export * as redis from "./redis"
8
+ export * as rustfs from "./rustfs"
8
9
  export * as s3 from "./s3"
@@ -6,6 +6,7 @@ import {
6
6
  secretSchema,
7
7
  z,
8
8
  } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
9
10
  import { l7EndpointContainer, l7EndpointEntity } from "../network"
10
11
  import { bucketEntity } from "./s3"
11
12
 
@@ -29,6 +30,16 @@ export const connectionEntity = defineEntity({
29
30
 
30
31
  extends: { l7EndpointContainer },
31
32
 
33
+ includes: {
34
+ /**
35
+ * The CA certificate file used to verify the server if any.
36
+ */
37
+ ca: {
38
+ entity: fileEntity,
39
+ required: false,
40
+ },
41
+ },
42
+
32
43
  schema: z.object({
33
44
  /**
34
45
  * The region of the MinIO instance.
@@ -80,6 +91,14 @@ export const connection = defineUnit({
80
91
  multiple: true,
81
92
  required: false,
82
93
  },
94
+
95
+ /**
96
+ * The CA certificate file used to verify the server if any.
97
+ */
98
+ ca: {
99
+ entity: fileEntity,
100
+ required: false,
101
+ },
83
102
  },
84
103
 
85
104
  secrets: {
@@ -6,8 +6,8 @@ import {
6
6
  secretSchema,
7
7
  z,
8
8
  } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
9
10
  import { l4EndpointContainer, l4EndpointEntity } from "../network"
10
- import { certificateEntity } from "../tls"
11
11
 
12
12
  export const credentialsSchema = z.discriminatedUnion("type", [
13
13
  z.object({
@@ -35,10 +35,10 @@ export const connectionEntity = defineEntity({
35
35
 
36
36
  includes: {
37
37
  /**
38
- * The TLS certificate of the server if any.
38
+ * The CA certificate file used to verify the server if any.
39
39
  */
40
- certificate: {
41
- entity: certificateEntity,
40
+ ca: {
41
+ entity: fileEntity,
42
42
  required: false,
43
43
  },
44
44
  },
@@ -87,6 +87,14 @@ export const connection = defineUnit({
87
87
  multiple: true,
88
88
  required: false,
89
89
  },
90
+
91
+ /**
92
+ * The CA certificate file used to verify the server if any.
93
+ */
94
+ ca: {
95
+ entity: fileEntity,
96
+ required: false,
97
+ },
90
98
  },
91
99
 
92
100
  secrets: {
@@ -6,8 +6,8 @@ import {
6
6
  secretSchema,
7
7
  z,
8
8
  } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
9
10
  import { l4EndpointContainer, l4EndpointEntity } from "../network"
10
- import { certificateEntity } from "../tls"
11
11
 
12
12
  export const credentialsSchema = z.discriminatedUnion("type", [
13
13
  z.object({
@@ -35,10 +35,10 @@ export const connectionEntity = defineEntity({
35
35
 
36
36
  includes: {
37
37
  /**
38
- * The TLS certificate of the server if any.
38
+ * The CA certificate file used to verify the server if any.
39
39
  */
40
- certificate: {
41
- entity: certificateEntity,
40
+ ca: {
41
+ entity: fileEntity,
42
42
  required: false,
43
43
  },
44
44
  },
@@ -87,6 +87,14 @@ export const connection = defineUnit({
87
87
  multiple: true,
88
88
  required: false,
89
89
  },
90
+
91
+ /**
92
+ * The CA certificate file used to verify the server if any.
93
+ */
94
+ ca: {
95
+ entity: fileEntity,
96
+ required: false,
97
+ },
90
98
  },
91
99
 
92
100
  secrets: {
@@ -6,8 +6,8 @@ import {
6
6
  secretSchema,
7
7
  z,
8
8
  } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
9
10
  import { l4EndpointContainer, l4EndpointEntity } from "../network"
10
- import { certificateEntity } from "../tls"
11
11
 
12
12
  export const credentialsSchema = z.discriminatedUnion("type", [
13
13
  z.object({
@@ -35,10 +35,10 @@ export const connectionEntity = defineEntity({
35
35
 
36
36
  includes: {
37
37
  /**
38
- * The TLS certificate of the server if any.
38
+ * The CA certificate file used to verify the server if any.
39
39
  */
40
- certificate: {
41
- entity: certificateEntity,
40
+ ca: {
41
+ entity: fileEntity,
42
42
  required: false,
43
43
  },
44
44
  },
@@ -92,6 +92,14 @@ export const connection = defineUnit({
92
92
  multiple: true,
93
93
  required: false,
94
94
  },
95
+
96
+ /**
97
+ * The CA certificate file used to verify the server if any.
98
+ */
99
+ ca: {
100
+ entity: fileEntity,
101
+ required: false,
102
+ },
95
103
  },
96
104
 
97
105
  secrets: {
@@ -0,0 +1,169 @@
1
+ import {
2
+ defineEntity,
3
+ defineUnit,
4
+ type EntityInput,
5
+ type EntityValue,
6
+ secretSchema,
7
+ z,
8
+ } from "@highstate/contract"
9
+ import { fileEntity } from "../common"
10
+ import { l7EndpointContainer, l7EndpointEntity } from "../network"
11
+ import { bucketEntity } from "./s3"
12
+
13
+ export const credentialsSchema = z.object({
14
+ /**
15
+ * The access key used to authenticate against RustFS.
16
+ */
17
+ accessKey: z.string(),
18
+
19
+ /**
20
+ * The secret key used to authenticate against RustFS.
21
+ */
22
+ secretKey: secretSchema(z.string()),
23
+ })
24
+
25
+ /**
26
+ * Represents a connection to a RustFS instance.
27
+ */
28
+ export const connectionEntity = defineEntity({
29
+ type: "rustfs.connection.v1",
30
+
31
+ extends: { l7EndpointContainer },
32
+
33
+ includes: {
34
+ /**
35
+ * The CA certificate file used to verify the server if any.
36
+ */
37
+ ca: {
38
+ entity: fileEntity,
39
+ required: false,
40
+ },
41
+ },
42
+
43
+ schema: z.object({
44
+ /**
45
+ * The S3 region of the RustFS instance.
46
+ */
47
+ region: z.string(),
48
+
49
+ /**
50
+ * The credentials for authenticating to RustFS.
51
+ */
52
+ credentials: credentialsSchema,
53
+ }),
54
+
55
+ meta: {
56
+ color: "#D34516",
57
+ },
58
+ })
59
+
60
+ /**
61
+ * An existing RustFS connection hosted on a server or Kubernetes cluster.
62
+ */
63
+ export const connection = defineUnit({
64
+ type: "rustfs.connection.v1",
65
+
66
+ args: {
67
+ /**
68
+ * The access key to authenticate with.
69
+ */
70
+ accessKey: z.string(),
71
+
72
+ /**
73
+ * The S3 region of the RustFS instance.
74
+ */
75
+ region: z.string().default("us-east-1"),
76
+
77
+ /**
78
+ * The endpoints to connect to the RustFS instance.
79
+ */
80
+ endpoints: z.string().array().default([]),
81
+ },
82
+
83
+ inputs: {
84
+ /**
85
+ * The endpoints to connect to the RustFS instance.
86
+ */
87
+ endpoints: {
88
+ entity: l7EndpointEntity,
89
+ multiple: true,
90
+ required: false,
91
+ },
92
+
93
+ /**
94
+ * The CA certificate file used to verify the server if any.
95
+ */
96
+ ca: {
97
+ entity: fileEntity,
98
+ required: false,
99
+ },
100
+ },
101
+
102
+ secrets: {
103
+ /**
104
+ * The secret key to authenticate with.
105
+ */
106
+ secretKey: z.string(),
107
+ },
108
+
109
+ outputs: {
110
+ connection: connectionEntity,
111
+ },
112
+
113
+ source: {
114
+ package: "@highstate/rustfs",
115
+ path: "connection",
116
+ },
117
+
118
+ meta: {
119
+ title: "RustFS Connection",
120
+ icon: "simple-icons:rust",
121
+ secondaryIcon: "mdi:database",
122
+ category: "Databases",
123
+ },
124
+ })
125
+
126
+ /**
127
+ * Creates a bucket and bucket-scoped service account on a RustFS instance.
128
+ */
129
+ export const bucket = defineUnit({
130
+ type: "rustfs.bucket.v1",
131
+
132
+ args: {
133
+ /**
134
+ * The name of the bucket to create.
135
+ *
136
+ * Defaults to the name of the unit if not provided.
137
+ */
138
+ bucketName: z.string().optional(),
139
+ },
140
+
141
+ inputs: {
142
+ /**
143
+ * The RustFS instance where the bucket should be created.
144
+ */
145
+ connection: connectionEntity,
146
+ },
147
+
148
+ outputs: {
149
+ /**
150
+ * The created S3-compatible bucket with scoped credentials.
151
+ */
152
+ bucket: bucketEntity,
153
+ },
154
+
155
+ source: {
156
+ package: "@highstate/rustfs",
157
+ path: "bucket",
158
+ },
159
+
160
+ meta: {
161
+ title: "RustFS Bucket",
162
+ icon: "simple-icons:rust",
163
+ secondaryIcon: "mdi:bucket",
164
+ category: "Databases",
165
+ },
166
+ })
167
+
168
+ export type Connection = EntityValue<typeof connectionEntity>
169
+ export type ConnectionInput = EntityInput<typeof connectionEntity>
package/src/dns.ts CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  import { mapValues, pick } from "remeda"
9
9
  import { serverEntity } from "./common/server"
10
10
  import { implementationReferenceSchema } from "./impl-ref"
11
- import { l3EndpointEntity, l4EndpointEntity, networkArgs } from "./network"
11
+ import { l3EndpointEntity, l4EndpointEntity, l7EndpointEntity, networkArgs } from "./network"
12
12
 
13
13
  export const providerEntity = defineEntity({
14
14
  type: "dns.provider.v1",
@@ -122,7 +122,7 @@ export const recordSet = defineUnit({
122
122
  * The L7 endpoints to use as values of the DNS records.
123
123
  */
124
124
  l7Endpoints: {
125
- entity: l4EndpointEntity,
125
+ entity: l7EndpointEntity,
126
126
  required: false,
127
127
  multiple: true,
128
128
  },
@@ -152,7 +152,7 @@ export const recordSet = defineUnit({
152
152
  * The duplicates are removed and metadata is merged.
153
153
  */
154
154
  l7Endpoints: {
155
- entity: l4EndpointEntity,
155
+ entity: l7EndpointEntity,
156
156
  multiple: true,
157
157
  },
158
158
  },
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import { noop } from "./abbreviations"
2
2
 
3
3
  noop()
4
4
 
5
+ export * from "./apps"
5
6
  export * as common from "./common"
6
7
  export * from "./databases"
7
8
  export * as distributions from "./distributions"
@@ -10,6 +11,7 @@ export * as git from "./git"
10
11
  export * from "./impl-ref"
11
12
  export * as k3s from "./k3s"
12
13
  export * as k8s from "./k8s"
14
+ export * as netaminity from "./netaminity"
13
15
  export * as network from "./network"
14
16
  export * as nixos from "./nixos"
15
17
  export * as proxmox from "./proxmox"
@@ -18,7 +20,6 @@ export * as sops from "./sops"
18
20
  export * as ssh from "./ssh"
19
21
  export * as talos from "./talos"
20
22
  export * from "./third-party"
23
+ export * as tls from "./tls"
21
24
  export * from "./utils"
22
25
  export * as wireguard from "./wireguard"
23
-
24
- // hi234