@highstate/library 0.11.7 → 0.12.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@highstate/library",
3
- "version": "0.11.7",
3
+ "version": "0.12.1",
4
4
  "type": "module",
5
5
  "highstate": {
6
6
  "type": "library"
@@ -1,4 +1,6 @@
1
1
  export * from "./mariadb"
2
2
  export * from "./mongodb"
3
3
  export * from "./postgresql"
4
+ export * from "./redis"
5
+ export * from "./s3"
4
6
  export * from "./shared"
@@ -0,0 +1,48 @@
1
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
+ import { sharedArgs, sharedInputs, sharedSchema } from "./shared"
3
+
4
+ /**
5
+ * Represents the Redis database or virtual database behind it.
6
+ */
7
+ export const redisEntity = defineEntity({
8
+ type: "databases.redis.v1",
9
+
10
+ schema: sharedSchema.pick({ endpoints: true }).extend({
11
+ /**
12
+ * The number of the database to use.
13
+ */
14
+ database: z.number().default(0),
15
+ }),
16
+
17
+ meta: {
18
+ color: "#dc382d",
19
+ },
20
+ })
21
+
22
+ /**
23
+ * The existing Redis database or virtual database behind it.
24
+ */
25
+ export const existingRedis = defineUnit({
26
+ type: "databases.redis.existing.v1",
27
+
28
+ args: sharedArgs,
29
+ inputs: sharedInputs,
30
+
31
+ outputs: {
32
+ redis: redisEntity,
33
+ },
34
+
35
+ source: {
36
+ package: "@highstate/common",
37
+ path: "units/databases/existing-redis",
38
+ },
39
+
40
+ meta: {
41
+ title: "Existing Redis Database",
42
+ icon: "simple-icons:redis",
43
+ secondaryIcon: "mdi:database",
44
+ category: "Databases",
45
+ },
46
+ })
47
+
48
+ export type Redis = z.infer<typeof redisEntity.schema>
@@ -0,0 +1,123 @@
1
+ import { $args, $inputs, $secrets, defineEntity, defineUnit, z } from "@highstate/contract"
2
+ import { l4EndpointEntity } from "../network"
3
+
4
+ export const s3BucketPolicySchema = z.enum(["none", "download", "upload", "public"])
5
+
6
+ export const s3BucketSchema = z.object({
7
+ /**
8
+ * The name of the bucket.
9
+ */
10
+ name: z.string(),
11
+
12
+ /**
13
+ * The optional policy applied to the bucket.
14
+ */
15
+ policy: s3BucketPolicySchema.optional(),
16
+ })
17
+
18
+ const s3Args = $args({
19
+ /**
20
+ * The endpoints to connect to the S3-compatible API in form of `host:port`.
21
+ */
22
+ endpoints: z.string().array().min(1),
23
+
24
+ /**
25
+ * The access key used to authenticate against the S3-compatible API.
26
+ */
27
+ accessKey: z.string(),
28
+
29
+ /**
30
+ * The region associated with the S3-compatible deployment.
31
+ */
32
+ region: z.string().optional(),
33
+
34
+ /**
35
+ * The buckets that must exist on the instance.
36
+ */
37
+ buckets: s3BucketSchema.array().default([]),
38
+ })
39
+
40
+ const s3Secrets = $secrets({
41
+ /**
42
+ * The secret key used to authenticate against the S3-compatible API.
43
+ */
44
+ secretKey: z.string(),
45
+ })
46
+
47
+ const s3Inputs = $inputs({
48
+ /**
49
+ * The endpoints to connect to the S3-compatible API.
50
+ */
51
+ endpoints: {
52
+ entity: l4EndpointEntity,
53
+ multiple: true,
54
+ required: false,
55
+ },
56
+ })
57
+
58
+ /**
59
+ * Represents an S3-compatible object storage endpoint.
60
+ */
61
+ export const s3Entity = defineEntity({
62
+ type: "databases.s3.v1",
63
+
64
+ schema: z.object({
65
+ /**
66
+ * The endpoints that expose the S3-compatible API.
67
+ */
68
+ endpoints: l4EndpointEntity.schema.array(),
69
+
70
+ /**
71
+ * The region associated with the object storage instance.
72
+ */
73
+ region: z.string().optional(),
74
+
75
+ /**
76
+ * The access key used to authenticate against the API.
77
+ */
78
+ accessKey: z.string(),
79
+
80
+ /**
81
+ * The secret key used to authenticate against the API.
82
+ */
83
+ secretKey: z.string(),
84
+
85
+ /**
86
+ * The buckets that must exist on the instance.
87
+ */
88
+ buckets: s3BucketSchema.array(),
89
+ }),
90
+
91
+ meta: {
92
+ color: "#ff9900",
93
+ },
94
+ })
95
+
96
+ /**
97
+ * The existing S3-compatible object storage instance.
98
+ */
99
+ export const existingS3 = defineUnit({
100
+ type: "databases.s3.existing.v1",
101
+
102
+ args: s3Args,
103
+ secrets: s3Secrets,
104
+ inputs: s3Inputs,
105
+
106
+ outputs: {
107
+ s3: s3Entity,
108
+ },
109
+
110
+ source: {
111
+ package: "@highstate/common",
112
+ path: "units/databases/existing-s3",
113
+ },
114
+
115
+ meta: {
116
+ title: "Existing S3-Compatible Storage",
117
+ icon: "simple-icons:amazons3",
118
+ secondaryIcon: "mdi:bucket",
119
+ category: "Databases",
120
+ },
121
+ })
122
+
123
+ export type S3 = z.infer<typeof s3Entity.schema>
package/src/k3s.ts CHANGED
@@ -49,6 +49,20 @@ export const cluster = defineUnit({
49
49
  */
50
50
  config: z.record(z.string(), z.unknown()).optional(),
51
51
 
52
+ /**
53
+ * The K3S configuration to pass to each server in the cluster.
54
+ *
55
+ * See: https://docs.k3s.io/installation/configuration
56
+ */
57
+ serverConfig: z.record(z.string(), z.unknown()).optional(),
58
+
59
+ /**
60
+ * The K3S configuration to pass to each agent in the cluster.
61
+ *
62
+ * See: https://docs.k3s.io/installation/configuration
63
+ */
64
+ agentConfig: z.record(z.string(), z.unknown()).optional(),
65
+
52
66
  /**
53
67
  * The configuration of the registries to use for the K3S cluster.
54
68
  *
@@ -4,6 +4,7 @@ export * from "./hubble"
4
4
  export * from "./kubernetes-dashboard"
5
5
  export * from "./mariadb"
6
6
  export * from "./maybe"
7
+ export * from "./minio"
7
8
  export * from "./mongodb"
8
9
  export * from "./postgresql"
9
10
  export {
@@ -18,5 +19,6 @@ export * from "./syncthing"
18
19
  // export * from "./zitadel"
19
20
  // export * from "./gitea"
20
21
  export * from "./traefik"
22
+ export * from "./valkey"
21
23
  export * from "./vaultwarden"
22
24
  export * from "./workload"
@@ -24,7 +24,7 @@ export const maybe = defineUnit({
24
24
  },
25
25
 
26
26
  inputs: {
27
- ...pick(sharedInputs, ["k8sCluster", "accessPoint", "postgresql"]),
27
+ ...pick(sharedInputs, ["k8sCluster", "accessPoint", "postgresql", "redis"]),
28
28
  ...pick(optionalSharedInputs, ["resticRepo"]),
29
29
  },
30
30
 
@@ -0,0 +1,81 @@
1
+ import { $secrets, defineUnit, text, z } from "@highstate/contract"
2
+ import { pick } from "remeda"
3
+ import * as databases from "../../databases"
4
+ import { l4EndpointEntity } from "../../network"
5
+ import { serviceEntity } from "../service"
6
+ import { appName, optionalSharedInputs, sharedArgs, sharedInputs, source } from "./shared"
7
+
8
+ const minioSecrets = $secrets({
9
+ /**
10
+ * The secret key used to authenticate with MinIO.
11
+ */
12
+ secretKey: z.string().optional(),
13
+
14
+ /**
15
+ * The key that protects Restic backups.
16
+ */
17
+ backupKey: z.string().optional(),
18
+ })
19
+
20
+ /**
21
+ * The MinIO object storage deployed on Kubernetes.
22
+ */
23
+ export const minio = defineUnit({
24
+ type: "k8s.apps.minio.v1",
25
+ args: {
26
+ ...appName("minio"),
27
+ ...pick(sharedArgs, ["external"]),
28
+
29
+ accessKey: {
30
+ schema: z.string().default("admin"),
31
+ meta: {
32
+ description: text`
33
+ The access key used to authenticate with MinIO.
34
+ If not provided, defaults to "admin".
35
+ `,
36
+ },
37
+ },
38
+
39
+ region: {
40
+ schema: z.string().optional(),
41
+ meta: {
42
+ description: text`The region associated with the MinIO deployment.`,
43
+ },
44
+ },
45
+
46
+ buckets: {
47
+ schema: databases.s3BucketSchema.array().default([]),
48
+ meta: {
49
+ description: text`
50
+ The buckets that must exist on the MinIO instance.
51
+ Each entry can optionally include a bucket policy: none, download, upload, or public.
52
+ `,
53
+ },
54
+ },
55
+ },
56
+
57
+ secrets: minioSecrets,
58
+
59
+ inputs: {
60
+ ...pick(sharedInputs, ["k8sCluster"]),
61
+ ...pick(optionalSharedInputs, ["resticRepo"]),
62
+ },
63
+
64
+ outputs: {
65
+ s3: databases.s3Entity,
66
+ service: serviceEntity,
67
+ endpoints: {
68
+ entity: l4EndpointEntity,
69
+ multiple: true,
70
+ },
71
+ },
72
+
73
+ meta: {
74
+ title: "MinIO",
75
+ icon: "simple-icons:minio",
76
+ secondaryIcon: "mdi:bucket",
77
+ category: "Databases",
78
+ },
79
+
80
+ source: source("minio/app"),
81
+ })
@@ -12,7 +12,7 @@ import {
12
12
  } from "@highstate/contract"
13
13
  import { mapValues } from "remeda"
14
14
  import { accessPointEntity } from "../../common"
15
- import { mariadbEntity, mongodbEntity, postgresqlEntity } from "../../databases"
15
+ import { mariadbEntity, mongodbEntity, postgresqlEntity, redisEntity } from "../../databases"
16
16
  import { providerEntity } from "../../dns"
17
17
  import { repositoryEntity } from "../../restic"
18
18
  import { namespaceEntity, persistentVolumeClaimEntity } from "../resources"
@@ -138,6 +138,9 @@ export const sharedInputs = $inputs({
138
138
  mongodb: {
139
139
  entity: mongodbEntity,
140
140
  },
141
+ redis: {
142
+ entity: redisEntity,
143
+ },
141
144
  })
142
145
 
143
146
  type ToOptionalInputs<T extends Record<string, FullComponentInputOptions>> = Simplify<{
@@ -14,7 +14,13 @@ export const traefik = defineUnit({
14
14
  args: {
15
15
  ...appName("traefik"),
16
16
  ...pick(sharedArgs, ["external", "replicas", "endpoints"]),
17
- className: z.string().optional(),
17
+
18
+ /**
19
+ * The name of the class to configure for ingress and gateway resources.
20
+ *
21
+ * Defaults to "traefik".
22
+ */
23
+ className: z.string().default("traefik"),
18
24
  },
19
25
 
20
26
  inputs: {
@@ -0,0 +1,52 @@
1
+ import { defineUnit } from "@highstate/contract"
2
+ import { pick } from "remeda"
3
+ import { databases } from "../.."
4
+ import { l4EndpointEntity } from "../../network"
5
+ import { serviceEntity } from "../service"
6
+ import {
7
+ appName,
8
+ optionalSharedInputs,
9
+ sharedArgs,
10
+ sharedInputs,
11
+ sharedSecrets,
12
+ source,
13
+ } from "./shared"
14
+
15
+ /**
16
+ * The Valkey instance deployed on Kubernetes.
17
+ */
18
+ export const valkey = defineUnit({
19
+ type: "k8s.apps.valkey.v1",
20
+
21
+ args: {
22
+ ...appName("valkey"),
23
+ ...pick(sharedArgs, ["external"]),
24
+ },
25
+
26
+ secrets: {
27
+ ...pick(sharedSecrets, ["backupKey"]),
28
+ },
29
+
30
+ inputs: {
31
+ ...pick(sharedInputs, ["k8sCluster"]),
32
+ ...pick(optionalSharedInputs, ["resticRepo"]),
33
+ },
34
+
35
+ outputs: {
36
+ redis: databases.redisEntity,
37
+ service: serviceEntity,
38
+ endpoints: {
39
+ entity: l4EndpointEntity,
40
+ multiple: true,
41
+ },
42
+ },
43
+
44
+ meta: {
45
+ title: "Valkey (Redis)",
46
+ icon: "simple-icons:redis",
47
+ secondaryIcon: "mdi:database",
48
+ category: "Databases",
49
+ },
50
+
51
+ source: source("valkey/app"),
52
+ })
package/src/proxmox.ts CHANGED
@@ -260,6 +260,13 @@ export const virtualMachine = defineUnit({
260
260
  type: "proxmox.virtual-machine.v1",
261
261
 
262
262
  args: {
263
+ /**
264
+ * The name of the virtual machine.
265
+ *
266
+ * If not specified, the unit name will be used.
267
+ */
268
+ vmName: z.string().optional(),
269
+
263
270
  /**
264
271
  * The name of the node to create the virtual machine on.
265
272
  *
@@ -46,6 +46,13 @@ export const virtualMachine = defineUnit({
46
46
  type: "timeweb.virtual-machine.v1",
47
47
 
48
48
  args: {
49
+ /**
50
+ * The name of the virtual machine.
51
+ *
52
+ * If not provided, the name of the unit will be used.
53
+ */
54
+ vmName: z.string().optional(),
55
+
49
56
  /**
50
57
  * The ID of the preset to use for the virtual machine.
51
58
  *
@@ -97,3 +104,5 @@ export const virtualMachine = defineUnit({
97
104
  path: "virtual-machine",
98
105
  },
99
106
  })
107
+
108
+ export type Connection = z.infer<typeof connectionEntity.schema>