@highstate/library 0.9.3 → 0.9.5

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.9.3",
3
+ "version": "0.9.5",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -19,12 +19,12 @@
19
19
  "build": "highstate build --library"
20
20
  },
21
21
  "dependencies": {
22
- "@highstate/contract": "^0.9.3",
22
+ "@highstate/contract": "^0.9.5",
23
23
  "@sinclair/typebox": "^0.34.11",
24
24
  "remeda": "^2.21.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@highstate/cli": "^0.9.3"
27
+ "@highstate/cli": "^0.9.5"
28
28
  },
29
- "gitHead": "cdd2bb1d9001ba4a39f64087eb29af6f50d82bec"
29
+ "gitHead": "93fa1e8b1189a5232055c852fd79a684d8b80444"
30
30
  }
@@ -1,37 +1,18 @@
1
1
  import { defineUnit, Type } from "@highstate/contract"
2
- import {
3
- accessPointEntity,
4
- clusterEntity,
5
- persistentVolumeClaimEntity,
6
- statefulSetEntity,
7
- } from "../k8s"
8
- import { repoEntity } from "../restic"
2
+ import { persistentVolumeClaimEntity, statefulSetEntity } from "../k8s"
3
+ import { createArgs, createInputs } from "./shared"
9
4
 
10
5
  export const codeServer = defineUnit({
11
6
  type: "apps.code-server",
12
7
 
13
- args: {
14
- fqdn: Type.String(),
15
- appName: Type.Optional(Type.String()),
16
- },
8
+ args: createArgs("code-server", ["fqdn"]),
17
9
 
18
10
  secrets: {
19
11
  password: Type.Optional(Type.String()),
20
12
  sudoPassword: Type.Optional(Type.String()),
21
13
  },
22
14
 
23
- inputs: {
24
- accessPoint: accessPointEntity,
25
- k8sCluster: clusterEntity,
26
- resticRepo: {
27
- entity: repoEntity,
28
- required: false,
29
- },
30
- volume: {
31
- entity: persistentVolumeClaimEntity,
32
- required: false,
33
- },
34
- },
15
+ inputs: createInputs(["accessPoint", "resticRepo", "dnsProviders", "volume"]),
35
16
 
36
17
  outputs: {
37
18
  statefulSet: statefulSetEntity,
@@ -42,6 +23,7 @@ export const codeServer = defineUnit({
42
23
  displayName: "Code Server",
43
24
  description: "The Code Server instance deployed on Kubernetes.",
44
25
  primaryIcon: "material-icon-theme:vscode",
26
+ category: "Development",
45
27
  },
46
28
 
47
29
  source: {
@@ -1,10 +1,6 @@
1
1
  import { defineUnit, Type } from "@highstate/contract"
2
- import { clusterEntity, deploymentEntity, serviceEntity, serviceTypeSchema } from "../k8s"
3
- import { repoEntity } from "../restic"
4
- import { providerEntity } from "../dns"
5
- import { mariadbEntity } from "./mariadb"
6
- import { postgresqlEntity } from "./postgresql"
7
- import { mongodbEntity } from "./mongodb"
2
+ import { deploymentEntity, serviceEntity, serviceTypeSchema } from "../k8s"
3
+ import { createInputs, createSource } from "./shared"
8
4
 
9
5
  export const deployment = defineUnit({
10
6
  type: "apps.deployment",
@@ -32,51 +28,33 @@ export const deployment = defineUnit({
32
28
  httpRouteManifest: Type.Optional(Type.Record(Type.String(), Type.Any())),
33
29
  },
34
30
 
35
- inputs: {
36
- k8sCluster: clusterEntity,
37
-
38
- mariadb: {
39
- entity: mariadbEntity,
40
- required: false,
41
- },
42
- postgresql: {
43
- entity: postgresqlEntity,
44
- required: false,
45
- },
46
- mongodb: {
47
- entity: mongodbEntity,
48
- required: false,
49
- },
50
- resticRepo: {
51
- entity: repoEntity,
52
- required: false,
53
- },
54
- dnsProvider: {
55
- entity: providerEntity,
56
- required: false,
57
- },
31
+ secrets: {
32
+ mariadbPassword: Type.Optional(Type.String()),
33
+ postgresqlPassword: Type.Optional(Type.String()),
34
+ mongodbPassword: Type.Optional(Type.String()),
58
35
  },
59
36
 
37
+ inputs: createInputs([
38
+ "accessPoint",
39
+ "mariadb",
40
+ "postgresql",
41
+ "mongodb",
42
+ "resticRepo",
43
+ "dnsProviders",
44
+ ]),
45
+
60
46
  outputs: {
61
47
  deployment: deploymentEntity,
62
48
  service: serviceEntity,
63
49
  },
64
50
 
65
- secrets: {
66
- mariadbPassword: Type.Optional(Type.String()),
67
- postgresqlPassword: Type.Optional(Type.String()),
68
- mongodbPassword: Type.Optional(Type.String()),
69
- },
70
-
71
51
  meta: {
72
52
  displayName: "Kubernetes Deployment",
73
53
  description: "A generic Kubernetes deployment with optional service and gateway routes.",
74
- primaryIcon: "mdi:kubernetes",
54
+ primaryIcon: "devicon:kubernetes",
75
55
  secondaryIcon: "mdi:cube-outline",
56
+ category: "Kubernetes",
76
57
  },
77
58
 
78
- source: {
79
- package: "@highstate/apps",
80
- path: "deployment",
81
- },
59
+ source: createSource("deployment"),
82
60
  })
@@ -0,0 +1,109 @@
1
+ import { defineUnit, Type } from "@highstate/contract"
2
+ import { l3EndpointEntity, l4EndpointEntity } from "../network"
3
+ import { providerEntity } from "../dns"
4
+ import { createSource } from "./shared"
5
+
6
+ const endpointFilterSchema = Type.StringEnum(["all", "public", "external", "internal"])
7
+
8
+ export const recordSet = defineUnit({
9
+ type: "apps.dns-record-set",
10
+
11
+ args: {
12
+ /**
13
+ * The name of the DNS record.
14
+ *
15
+ * If not provided, will use the name of the unit.
16
+ */
17
+ recordName: Type.Optional(Type.String()),
18
+
19
+ /**
20
+ * The type of the DNS record.
21
+ *
22
+ * If not specified, will use the default type for the provider.
23
+ */
24
+ type: Type.Optional(Type.String()),
25
+
26
+ /**
27
+ * The values of the DNS record.
28
+ */
29
+ values: Type.Array(Type.String()),
30
+
31
+ /**
32
+ * The TTL of the DNS record.
33
+ */
34
+ ttl: Type.Optional(Type.Number()),
35
+
36
+ /**
37
+ * The priority of the DNS record.
38
+ */
39
+ priority: Type.Optional(Type.Number()),
40
+
41
+ /**
42
+ * Whether the DNS record is proxied.
43
+ *
44
+ * Available only for public IPs and some DNS providers like Cloudflare.
45
+ */
46
+ proxied: Type.Optional(Type.Boolean()),
47
+
48
+ /**
49
+ * The filter to apply to the endpoints.
50
+ *
51
+ * - `all`: All endpoints.
52
+ * - `public`: Only public endpoints accessible from the internet (default).
53
+ * - `external`: Only external endpoints (e.g. NodePort, LoadBalancer) accessible from outside the cluster, but not from the internet.
54
+ * - `internal`: Only internal endpoints (e.g. ClusterIP) accessible from within the cluster.
55
+ */
56
+ endpointFilter: Type.Default(endpointFilterSchema, "public"),
57
+ },
58
+
59
+ inputs: {
60
+ dnsProviders: {
61
+ entity: providerEntity,
62
+ multiple: true,
63
+ },
64
+ l3Endpoints: {
65
+ entity: l3EndpointEntity,
66
+ required: false,
67
+ multiple: true,
68
+ },
69
+ l4Endpoints: {
70
+ entity: l4EndpointEntity,
71
+ required: false,
72
+ multiple: true,
73
+ },
74
+ },
75
+
76
+ outputs: {
77
+ /**
78
+ * The single L3 endpoint representing created DNS records.
79
+ */
80
+ l3Endpoint: l3EndpointEntity,
81
+
82
+ /**
83
+ * Multiple L4 endpoints representing created DNS records for each unique port/protocol combination from the input L4 endpoints.
84
+ */
85
+ l4Endpoints: {
86
+ entity: l4EndpointEntity,
87
+ multiple: true,
88
+ },
89
+ },
90
+
91
+ meta: {
92
+ displayName: "DNS Record Set",
93
+ description: "A set of DNS records to be created.",
94
+ primaryIcon: "mdi:server",
95
+ defaultNamePrefix: "record",
96
+ category: "Network",
97
+ },
98
+
99
+ source: createSource("dns-record-set"),
100
+ })
101
+
102
+ export const sharedArgs = {
103
+ /**
104
+ * The FQDN to register the cluster nodes with.
105
+ *
106
+ * @schema
107
+ */
108
+ fqdn: Type.Optional(Type.String()),
109
+ }
package/src/apps/gitea.ts CHANGED
@@ -1,31 +1,18 @@
1
- import { defineUnit, Type } from "@highstate/contract"
2
- import { accessPointEntity, clusterEntity } from "../k8s"
3
- import { mariadbEntity } from "./mariadb"
1
+ import { defineUnit } from "@highstate/contract"
2
+ import { createArgs, createInputs, createSource } from "./shared"
4
3
 
5
4
  export const gitea = defineUnit({
6
5
  type: "apps.gitea",
7
6
 
8
- args: {
9
- domain: Type.String(),
10
- },
11
-
12
- inputs: {
13
- mariadb: {
14
- entity: mariadbEntity,
15
- displayName: "MariaDB",
16
- },
17
- accessPoint: accessPointEntity,
18
- k8sCluster: clusterEntity,
19
- },
7
+ args: createArgs("gitea"),
8
+ inputs: createInputs(["accessPoint", "mariadb"]),
20
9
 
21
10
  meta: {
22
11
  displayName: "Gitea",
23
12
  description: "The Gitea Git server deployed on Kubernetes.",
24
13
  primaryIcon: "simple-icons:gitea",
14
+ category: "Development",
25
15
  },
26
16
 
27
- source: {
28
- package: "@highstate/apps",
29
- path: "gitea",
30
- },
17
+ source: createSource("gitea"),
31
18
  })
package/src/apps/grocy.ts CHANGED
@@ -1,33 +1,19 @@
1
- import { defineUnit, Type } from "@highstate/contract"
2
- import { accessPointEntity, clusterEntity } from "../k8s"
3
- import { repoEntity } from "../restic"
1
+ import { defineUnit } from "@highstate/contract"
2
+ import { createArgs, createInputs, createSource } from "./shared"
4
3
 
5
4
  export const grocy = defineUnit({
6
5
  type: "apps.grocy",
7
6
 
8
- args: {
9
- fqdn: Type.String(),
10
- appName: Type.Optional(Type.String()),
11
- },
12
-
13
- inputs: {
14
- resticRepo: {
15
- entity: repoEntity,
16
- required: false,
17
- },
18
- accessPoint: accessPointEntity,
19
- k8sCluster: clusterEntity,
20
- },
7
+ args: createArgs("grocy", ["fqdn"]),
8
+ inputs: createInputs(["accessPoint", "resticRepo"]),
21
9
 
22
10
  meta: {
23
11
  displayName: "Grocy",
24
12
  description:
25
13
  "Grocy is a web-based self-hosted groceries & household management solution for your home.",
26
14
  primaryIcon: "simple-icons:grocy",
15
+ category: "Productivity",
27
16
  },
28
17
 
29
- source: {
30
- package: "@highstate/apps",
31
- path: "grocy",
32
- },
18
+ source: createSource("grocy"),
33
19
  })
package/src/apps/index.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  export * from "./mariadb"
2
2
  export * from "./postgresql"
3
3
  export * from "./vaultwarden"
4
+ export * from "./mongodb"
5
+ export * from "./network"
6
+ export * from "./dns"
4
7
  // export * from "./zitadel"
5
8
  // export * from "./gitea"
6
9
  export * from "./traefik"
7
10
  export * from "./kubernetes-dashboard"
8
11
  export * from "./grocy"
9
12
  export * from "./maybe"
10
- export * from "./mongodb"
11
13
  export * from "./deployment"
12
14
  export * from "./syncthing"
13
15
  export * from "./code-server"
16
+
17
+ export { createArgs, createInputs } from "./shared"
@@ -1,28 +1,19 @@
1
- import { defineUnit, Type } from "@highstate/contract"
2
- import { accessPointEntity, clusterEntity } from "../k8s"
1
+ import { defineUnit } from "@highstate/contract"
2
+ import { createArgs, createInputs, createSource } from "./shared"
3
3
 
4
4
  export const kubernetesDashboard = defineUnit({
5
5
  type: "apps.kubernetes-dashboard",
6
6
 
7
- args: {
8
- fqdn: Type.String(),
9
- appName: Type.Optional(Type.String()),
10
- },
11
-
12
- inputs: {
13
- k8sCluster: clusterEntity,
14
- accessPoint: accessPointEntity,
15
- },
7
+ args: createArgs("kubernetes-dashboard", ["fqdn"]),
8
+ inputs: createInputs(["accessPoint"]),
16
9
 
17
10
  meta: {
18
11
  displayName: "Kubernetes Dashboard",
19
12
  description: "The Kubernetes Dashboard deployed on Kubernetes.",
20
- primaryIcon: "simple-icons:kubernetes",
21
- secondaryIcon: "mdi:dashboard",
13
+ primaryIcon: "devicon:kubernetes",
14
+ secondaryIcon: "material-symbols:dashboard",
15
+ category: "Kubernetes",
22
16
  },
23
17
 
24
- source: {
25
- package: "@highstate/apps",
26
- path: "kubernetes-dashboard",
27
- },
18
+ source: createSource("kubernetes-dashboard"),
28
19
  })
@@ -1,18 +1,17 @@
1
1
  import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
2
- import { clusterEntity, serviceEntity } from "../k8s"
3
- import { repoEntity } from "../restic"
4
- import { providerEntity } from "../dns"
2
+ import { serviceEntity } from "../k8s"
3
+ import {
4
+ createArgs,
5
+ createInputs,
6
+ createSource,
7
+ databaseSchema,
8
+ extraInputDefinitions,
9
+ } from "./shared"
5
10
 
6
11
  export const mariadbEntity = defineEntity({
7
12
  type: "apps.mariadb",
8
13
 
9
- schema: Type.Object({
10
- service: Type.Optional(serviceEntity.schema),
11
-
12
- host: Type.String(),
13
- port: Type.Number(),
14
- rootPassword: Type.String(),
15
- }),
14
+ schema: databaseSchema,
16
15
 
17
16
  meta: {
18
17
  color: "#f06292",
@@ -22,26 +21,13 @@ export const mariadbEntity = defineEntity({
22
21
  export const mariadb = defineUnit({
23
22
  type: "apps.mariadb",
24
23
 
25
- args: {
26
- fqdn: Type.Optional(Type.String()),
27
- appName: Type.Optional(Type.String()),
28
- },
24
+ args: createArgs("mariadb", ["external"]),
29
25
 
30
26
  secrets: {
31
27
  rootPassword: Type.Optional(Type.String()),
32
28
  },
33
29
 
34
- inputs: {
35
- k8sCluster: clusterEntity,
36
- resticRepo: {
37
- entity: repoEntity,
38
- required: false,
39
- },
40
- dnsProvider: {
41
- entity: providerEntity,
42
- required: false,
43
- },
44
- },
30
+ inputs: createInputs(["resticRepo"]),
45
31
 
46
32
  outputs: {
47
33
  mariadb: mariadbEntity,
@@ -53,14 +39,17 @@ export const mariadb = defineUnit({
53
39
  description: "The MariaDB database deployed on Kubernetes.",
54
40
  primaryIcon: "simple-icons:mariadb",
55
41
  secondaryIcon: "mdi:database",
42
+ category: "Databases",
56
43
  },
57
44
 
58
- source: {
59
- package: "@highstate/apps",
60
- path: "mariadb/app",
61
- },
45
+ source: createSource("mariadb/app"),
62
46
  })
63
47
 
48
+ extraInputDefinitions.mariadb = {
49
+ entity: mariadbEntity,
50
+ displayName: "MariaDB",
51
+ }
52
+
64
53
  export const mariadbDatabase = defineUnit({
65
54
  type: "apps.mariadb.database",
66
55
 
@@ -69,27 +58,22 @@ export const mariadbDatabase = defineUnit({
69
58
  username: Type.Optional(Type.String()),
70
59
  },
71
60
 
61
+ inputs: createInputs(["mariadb"]),
62
+
72
63
  secrets: {
73
64
  password: Type.Optional(Type.String()),
74
65
  },
75
66
 
76
- inputs: {
77
- k8sCluster: clusterEntity,
78
- mariadb: mariadbEntity,
79
- },
80
-
81
67
  meta: {
82
68
  displayName: "MariaDB Database",
83
69
  description:
84
70
  "The virtual MariaDB database created on the MariaDB instance. Works only for MariaDB instances deployed on Kubernetes.",
85
71
  primaryIcon: "simple-icons:mariadb",
86
72
  secondaryIcon: "mdi:database-plus",
73
+ category: "Databases",
87
74
  },
88
75
 
89
- source: {
90
- package: "@highstate/apps",
91
- path: "mariadb/database",
92
- },
76
+ source: createSource("mariadb/database"),
93
77
  })
94
78
 
95
79
  export type MariaDB = Static<typeof mariadbEntity.schema>
package/src/apps/maybe.ts CHANGED
@@ -1,39 +1,24 @@
1
1
  import { defineUnit, Type } from "@highstate/contract"
2
- import { accessPointEntity, clusterEntity } from "../k8s"
3
- import { repoEntity } from "../restic"
4
- import { postgresqlEntity } from "./postgresql"
2
+ import { createArgs, createInputs, createSource } from "./shared"
5
3
 
6
4
  export const maybe = defineUnit({
7
5
  type: "apps.maybe",
8
6
 
9
- args: {
10
- fqdn: Type.String(),
11
- appName: Type.Optional(Type.String()),
12
- },
13
-
14
- inputs: {
15
- postgresql: postgresqlEntity,
16
- accessPoint: accessPointEntity,
17
- k8sCluster: clusterEntity,
18
- resticRepo: {
19
- entity: repoEntity,
20
- required: false,
21
- },
22
- },
7
+ args: createArgs("maybe", ["fqdn"]),
23
8
 
24
9
  secrets: {
25
10
  postgresqlPassword: Type.Optional(Type.String()),
26
11
  secretKey: Type.Optional(Type.String()),
27
12
  },
28
13
 
14
+ inputs: createInputs(["accessPoint", "resticRepo", "postgresql"]),
15
+
29
16
  meta: {
30
17
  displayName: "Maybe",
31
18
  description: "The OS for your personal finances.",
32
19
  primaryIcon: "arcticons:finance-manager",
20
+ category: "Finance",
33
21
  },
34
22
 
35
- source: {
36
- package: "@highstate/apps",
37
- path: "maybe",
38
- },
23
+ source: createSource("maybe"),
39
24
  })
@@ -1,18 +1,17 @@
1
1
  import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
2
- import { clusterEntity, serviceEntity, serviceTypeSchema } from "../k8s"
3
- import { repoEntity } from "../restic"
4
- import { providerEntity } from "../dns"
2
+ import { serviceEntity } from "../k8s"
3
+ import {
4
+ createArgs,
5
+ createInputs,
6
+ createSource,
7
+ databaseSchema,
8
+ extraInputDefinitions,
9
+ } from "./shared"
5
10
 
6
11
  export const mongodbEntity = defineEntity({
7
12
  type: "apps.mongodb",
8
13
 
9
- schema: Type.Object({
10
- service: Type.Optional(serviceEntity.schema),
11
-
12
- host: Type.String(),
13
- port: Type.Number(),
14
- rootPassword: Type.String(),
15
- }),
14
+ schema: databaseSchema,
16
15
 
17
16
  meta: {
18
17
  color: "#13aa52",
@@ -22,27 +21,13 @@ export const mongodbEntity = defineEntity({
22
21
  export const mongodb = defineUnit({
23
22
  type: "apps.mongodb",
24
23
 
25
- args: {
26
- fqdn: Type.Optional(Type.String()),
27
- appName: Type.Optional(Type.String()),
28
- serviceType: Type.Optional(serviceTypeSchema),
29
- },
24
+ args: createArgs("mongodb", ["external"]),
30
25
 
31
26
  secrets: {
32
27
  rootPassword: Type.Optional(Type.String()),
33
28
  },
34
29
 
35
- inputs: {
36
- k8sCluster: clusterEntity,
37
- resticRepo: {
38
- entity: repoEntity,
39
- required: false,
40
- },
41
- dnsProvider: {
42
- entity: providerEntity,
43
- required: false,
44
- },
45
- },
30
+ inputs: createInputs(["resticRepo"]),
46
31
 
47
32
  outputs: {
48
33
  mongodb: mongodbEntity,
@@ -54,14 +39,17 @@ export const mongodb = defineUnit({
54
39
  description: "The MongoDB instance deployed on Kubernetes.",
55
40
  primaryIcon: "simple-icons:mongodb",
56
41
  secondaryIcon: "mdi:database",
42
+ category: "Databases",
57
43
  },
58
44
 
59
- source: {
60
- package: "@highstate/apps",
61
- path: "mongodb/app",
62
- },
45
+ source: createSource("mongodb/app"),
63
46
  })
64
47
 
48
+ extraInputDefinitions.mongodb = {
49
+ entity: mongodbEntity,
50
+ displayName: "MongoDB",
51
+ }
52
+
65
53
  export const mongodbDatabase = defineUnit({
66
54
  type: "apps.mongodb.database",
67
55
 
@@ -74,10 +62,7 @@ export const mongodbDatabase = defineUnit({
74
62
  password: Type.Optional(Type.String()),
75
63
  },
76
64
 
77
- inputs: {
78
- k8sCluster: clusterEntity,
79
- mongodb: mongodbEntity,
80
- },
65
+ inputs: createInputs(["mongodb"]),
81
66
 
82
67
  meta: {
83
68
  displayName: "MongoDB Database",
@@ -85,12 +70,10 @@ export const mongodbDatabase = defineUnit({
85
70
  "The virtual MongoDB database created on the MongoDB instance. Works only for MongoDB instances deployed on Kubernetes.",
86
71
  primaryIcon: "simple-icons:mongodb",
87
72
  secondaryIcon: "mdi:database-plus",
73
+ category: "Databases",
88
74
  },
89
75
 
90
- source: {
91
- package: "@highstate/apps",
92
- path: "mongodb/database",
93
- },
76
+ source: createSource("mongodb/database"),
94
77
  })
95
78
 
96
79
  export type MongoDB = Static<typeof mongodbEntity.schema>