@highstate/library 0.9.16 → 0.9.18

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.
@@ -1,4 +1,4 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { createArgs, createInputs, createSource } from "./shared"
3
3
 
4
4
  export const vaultwarden = defineUnit({
@@ -7,15 +7,15 @@ export const vaultwarden = defineUnit({
7
7
  args: createArgs("vaultwarden", ["fqdn"]),
8
8
 
9
9
  secrets: {
10
- mariadbPassword: Type.Optional(Type.String()),
10
+ mariadbPassword: z.string().optional(),
11
11
  },
12
12
 
13
13
  inputs: createInputs(["accessPoint", "mariadb"]),
14
14
 
15
15
  meta: {
16
- displayName: "Vaultwarden",
16
+ title: "Vaultwarden",
17
17
  description: "The Vaultwarden password manager deployed on Kubernetes.",
18
- primaryIcon: "simple-icons:vaultwarden",
18
+ icon: "simple-icons:vaultwarden",
19
19
  category: "Security",
20
20
  },
21
21
 
@@ -9,9 +9,9 @@ export const zitadel = defineUnit({
9
9
  inputs: createInputs(["accessPoint", "postgresql"]),
10
10
 
11
11
  meta: {
12
- displayName: "Zitadel",
12
+ title: "Zitadel",
13
13
  description: "The Zitadel IAM deployed on Kubernetes.",
14
- primaryIcon: "hugeicons:access",
14
+ icon: "hugeicons:access",
15
15
  },
16
16
 
17
17
  source: {
package/src/cloudflare.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { providerEntity } from "./dns"
3
3
 
4
4
  export const connection = defineUnit({
5
5
  type: "cloudflare.connection",
6
6
 
7
7
  secrets: {
8
- apiToken: Type.String(),
8
+ apiToken: z.string(),
9
9
  },
10
10
 
11
11
  outputs: {
@@ -13,9 +13,9 @@ export const connection = defineUnit({
13
13
  },
14
14
 
15
15
  meta: {
16
- displayName: "Cloudflare Connection",
16
+ title: "Cloudflare Connection",
17
17
  description: "Creates a new Cloudflare connection for one zone.",
18
- primaryIcon: "simple-icons:cloudflare",
18
+ icon: "simple-icons:cloudflare",
19
19
  category: "Cloudflare",
20
20
  },
21
21
 
package/src/common.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
1
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
2
  import { credentialsSchema, keyPairEntity } from "./ssh"
3
3
  import { l3EndpointEntity } from "./network"
4
4
  import * as dns from "./dns"
@@ -7,10 +7,10 @@ import { arrayPatchModeSchema } from "./utils"
7
7
  export const serverEntity = defineEntity({
8
8
  type: "common.server",
9
9
 
10
- schema: Type.Object({
11
- hostname: Type.String(),
12
- endpoints: Type.Array(l3EndpointEntity.schema),
13
- ssh: Type.Optional(credentialsSchema),
10
+ schema: z.object({
11
+ hostname: z.string(),
12
+ endpoints: l3EndpointEntity.schema.array(),
13
+ ssh: credentialsSchema.optional(),
14
14
  }),
15
15
 
16
16
  meta: {
@@ -35,22 +35,22 @@ export const existingServer = defineUnit({
35
35
  *
36
36
  * Takes precedence over the `endpoint` input.
37
37
  */
38
- endpoint: Type.Optional(Type.String()),
38
+ endpoint: z.string().optional(),
39
39
 
40
40
  /**
41
41
  * The SSH user to use for connecting to the server.
42
42
  */
43
- sshUser: Type.Default(Type.String(), "root"),
43
+ sshUser: z.string().default("root"),
44
44
 
45
45
  /**
46
46
  * The SSH port to use for connecting to the server.
47
47
  */
48
- sshPort: Type.Default(Type.Number(), 22),
48
+ sshPort: z.number().default(22),
49
49
  },
50
50
 
51
51
  secrets: {
52
- sshPassword: Type.Optional(Type.String()),
53
- sshPrivateKey: Type.Optional(Type.String()),
52
+ sshPassword: z.string().optional(),
53
+ sshPrivateKey: z.string().optional(),
54
54
  },
55
55
 
56
56
  inputs: {
@@ -67,9 +67,9 @@ export const existingServer = defineUnit({
67
67
  outputs: serverOutputs,
68
68
 
69
69
  meta: {
70
- displayName: "Existing Server",
70
+ title: "Existing Server",
71
71
  description: "An existing server that can be used in the configuration.",
72
- primaryIcon: "mdi:server",
72
+ icon: "mdi:server",
73
73
  defaultNamePrefix: "server",
74
74
  category: "Infrastructure",
75
75
  },
@@ -91,7 +91,7 @@ export const serverPatch = defineUnit({
91
91
  *
92
92
  * The same server may also be represented by multiple entries (e.g. a node with private and public IP).
93
93
  */
94
- endpoints: Type.Default(Type.Array(Type.String()), []),
94
+ endpoints: z.string().array().default([]),
95
95
 
96
96
  /**
97
97
  * The mode to use for patching the endpoints.
@@ -99,7 +99,7 @@ export const serverPatch = defineUnit({
99
99
  * - `prepend`: prepend the new endpoints to the existing ones (default);
100
100
  * - `replace`: replace the existing endpoints with the new ones.
101
101
  */
102
- endpointsPatchMode: Type.Default(arrayPatchModeSchema, "prepend"),
102
+ endpointsPatchMode: arrayPatchModeSchema.default("prepend"),
103
103
  },
104
104
 
105
105
  inputs: {
@@ -120,9 +120,9 @@ export const serverPatch = defineUnit({
120
120
  },
121
121
 
122
122
  meta: {
123
- displayName: "Server Patch",
123
+ title: "Server Patch",
124
124
  description: "Patches some properties of the server.",
125
- primaryIcon: "mdi:server",
125
+ icon: "mdi:server",
126
126
  secondaryIcon: "fluent:patch-20-filled",
127
127
  category: "Infrastructure",
128
128
  },
@@ -152,9 +152,9 @@ export const serverDns = defineUnit({
152
152
  },
153
153
 
154
154
  meta: {
155
- displayName: "Server DNS",
155
+ title: "Server DNS",
156
156
  description: "Creates DNS records for the server and updates endpoints.",
157
- primaryIcon: "mdi:server",
157
+ icon: "mdi:server",
158
158
  secondaryIcon: "mdi:dns",
159
159
  category: "Infrastructure",
160
160
  },
@@ -169,9 +169,9 @@ export const script = defineUnit({
169
169
  type: "common.script",
170
170
 
171
171
  args: {
172
- script: Type.String({ language: "shell" }),
173
- updateScript: Type.Optional(Type.String({ language: "shell" })),
174
- deleteScript: Type.Optional(Type.String({ language: "shell" })),
172
+ script: z.string().meta({ language: "shell" }),
173
+ updateScript: z.string().optional().meta({ language: "shell" }),
174
+ deleteScript: z.string().optional().meta({ language: "shell" }),
175
175
  },
176
176
 
177
177
  inputs: {
@@ -183,9 +183,9 @@ export const script = defineUnit({
183
183
  },
184
184
 
185
185
  meta: {
186
- displayName: "Shell Script",
186
+ title: "Shell Script",
187
187
  description: "Run a shell script on the server.",
188
- primaryIcon: "mdi:bash",
188
+ icon: "mdi:bash",
189
189
  category: "Infrastructure",
190
190
  },
191
191
 
@@ -195,6 +195,6 @@ export const script = defineUnit({
195
195
  },
196
196
  })
197
197
 
198
- export type Server = Static<typeof serverEntity.schema>
198
+ export type Server = z.infer<typeof serverEntity.schema>
199
199
 
200
200
  export * from "./files"
@@ -1,15 +1,15 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { fileEntity } from "../files"
3
3
 
4
- export const ubuntuVersionSchema = Type.StringEnum(["22.04", "24.04", "24.10", "25.04", "25.10"])
5
- export const ubuntuArchitectureSchema = Type.StringEnum(["amd64", "arm64"])
4
+ export const ubuntuVersionSchema = z.enum(["22.04", "24.04", "24.10", "25.04", "25.10"])
5
+ export const ubuntuArchitectureSchema = z.enum(["amd64", "arm64"])
6
6
 
7
7
  export const ubuntu = defineUnit({
8
8
  type: "distributions.ubuntu",
9
9
 
10
10
  args: {
11
- version: Type.Default(ubuntuVersionSchema, "24.04"),
12
- architecture: Type.Default(ubuntuArchitectureSchema, "amd64"),
11
+ version: ubuntuVersionSchema.default("24.04"),
12
+ architecture: ubuntuArchitectureSchema.default("amd64"),
13
13
  },
14
14
 
15
15
  outputs: {
@@ -18,10 +18,10 @@ export const ubuntu = defineUnit({
18
18
  },
19
19
 
20
20
  meta: {
21
- displayName: "Ubuntu",
21
+ title: "Ubuntu",
22
22
  description: "Ubuntu distribution with image and cloud-config.",
23
- primaryIcon: "mdi:ubuntu",
24
- primaryIconColor: "#E95420",
23
+ icon: "mdi:ubuntu",
24
+ iconColor: "#E95420",
25
25
  category: "Distributions",
26
26
  },
27
27
 
package/src/dns.ts CHANGED
@@ -1,15 +1,15 @@
1
- import { defineEntity, Type, type Static } from "@highstate/contract"
1
+ import { defineEntity, z } from "@highstate/contract"
2
2
  import { endpointFilterSchema } from "./network"
3
3
  import { arrayPatchModeSchema, prefixKeysWith } from "./utils"
4
4
 
5
5
  export const providerEntity = defineEntity({
6
6
  type: "dns.provider",
7
7
 
8
- schema: Type.Object({
9
- name: Type.String(),
10
- type: Type.String(),
11
- data: Type.Record(Type.String(), Type.Unknown()),
12
- domain: Type.String(),
8
+ schema: z.object({
9
+ name: z.string(),
10
+ type: z.string(),
11
+ data: z.record(z.string(), z.unknown()),
12
+ domain: z.string(),
13
13
  }),
14
14
 
15
15
  meta: {
@@ -26,7 +26,7 @@ export function createArgs<TPrefix extends string = "">(prefix?: TPrefix) {
26
26
  *
27
27
  * Will throw an error if no matching provider is found.
28
28
  */
29
- fqdn: Type.Optional(Type.String()),
29
+ fqdn: z.string().optional(),
30
30
 
31
31
  /**
32
32
  * The endpoint filter to filter the endpoints before creating the DNS records.
@@ -45,7 +45,7 @@ export function createArgs<TPrefix extends string = "">(prefix?: TPrefix) {
45
45
  * - Otherwise, if any external endpoints exist, all external endpoints are selected;
46
46
  * - If neither exist, all internal endpoints are selected.
47
47
  */
48
- endpointFilter: Type.Default(endpointFilterSchema, []),
48
+ endpointFilter: endpointFilterSchema.default([]),
49
49
 
50
50
  /**
51
51
  * The mode to use for patching the existing endpoints.
@@ -55,7 +55,7 @@ export function createArgs<TPrefix extends string = "">(prefix?: TPrefix) {
55
55
  *
56
56
  * The default is `prepend`.
57
57
  */
58
- patchMode: Type.Default(arrayPatchModeSchema, "prepend"),
58
+ patchMode: arrayPatchModeSchema.default("prepend"),
59
59
  })
60
60
  }
61
61
 
@@ -71,4 +71,4 @@ export const inputs = {
71
71
  },
72
72
  } as const
73
73
 
74
- export type Provider = Static<typeof providerEntity.schema>
74
+ export type Provider = z.infer<typeof providerEntity.schema>
package/src/files.ts CHANGED
@@ -1,45 +1,37 @@
1
- import type { Static } from "@sinclair/typebox"
2
1
  import {
3
2
  defineEntity,
4
3
  defineUnit,
5
- HighstateSignature,
6
- Type,
4
+ z,
7
5
  fileContentSchema as baseFileContentSchema,
8
6
  fileMetaSchema as baseFileMetaSchema,
9
7
  unitArtifactSchema,
10
8
  } from "@highstate/contract"
11
9
  import { l7EndpointEntity } from "./network"
12
10
 
13
- export const checksumAlgorithmSchema = Type.StringEnum([
14
- "md5",
15
- "sha1",
16
- "sha256",
17
- "sha384",
18
- "sha512",
19
- ])
11
+ export const checksumAlgorithmSchema = z.enum(["md5", "sha1", "sha256", "sha384", "sha512"])
20
12
 
21
- export const checksumSchema = Type.Object({
13
+ export const checksumSchema = z.object({
22
14
  algorithm: checksumAlgorithmSchema,
23
- value: Type.String(),
15
+ value: z.string(),
24
16
  })
25
17
 
26
- export const fileContentSchema = Type.Union([
18
+ export const fileContentSchema = z.union([
27
19
  baseFileContentSchema,
28
- Type.Object({
29
- type: Type.Literal("local"),
30
- path: Type.String(),
20
+ z.object({
21
+ type: z.literal("local"),
22
+ path: z.string(),
31
23
  }),
32
- Type.Object({
33
- type: Type.Literal("remote"),
24
+ z.object({
25
+ type: z.literal("remote"),
34
26
  endpoint: l7EndpointEntity.schema,
35
- checksum: Type.Optional(checksumSchema),
27
+ checksum: checksumSchema.optional(),
36
28
  }),
37
29
  ])
38
30
 
39
31
  export const fileEntity = defineEntity({
40
32
  type: "common.file",
41
33
 
42
- schema: Type.Object({
34
+ schema: z.object({
43
35
  meta: baseFileMetaSchema,
44
36
  content: fileContentSchema,
45
37
  }),
@@ -49,45 +41,42 @@ export const fileEntity = defineEntity({
49
41
  },
50
42
  })
51
43
 
52
- export const folderMetaSchema = Type.Object({
53
- name: Type.String(),
54
- mode: Type.Optional(Type.Number()),
44
+ export const folderMetaSchema = z.object({
45
+ name: z.string(),
46
+ mode: z.number().optional(),
55
47
  })
56
48
 
57
- export const folderContentSchema = Type.Recursive(
58
- TSelf => {
59
- return Type.Union([
60
- Type.Object({
61
- type: Type.Literal("embedded"),
62
- files: Type.Array(fileEntity.schema),
63
- folders: Type.Array(
64
- Type.Object({
65
- meta: folderMetaSchema,
66
- content: TSelf,
67
- }),
68
- ),
69
- }),
70
- Type.Object({
71
- type: Type.Literal("artifact"),
72
- [HighstateSignature.Artifact]: unitArtifactSchema,
73
- }),
74
- Type.Object({
75
- type: Type.Literal("local"),
76
- path: Type.String(),
77
- }),
78
- Type.Object({
79
- type: Type.Literal("remote"),
80
- endpoint: l7EndpointEntity.schema,
81
- }),
82
- ])
83
- },
84
- { $id: "common.folder.content" },
85
- )
49
+ export const folderContentSchema = z.union([
50
+ z.object({
51
+ type: z.literal("embedded"),
52
+ files: fileEntity.schema.array(),
53
+ folders: z
54
+ .object({
55
+ meta: folderMetaSchema,
56
+ get content() {
57
+ return folderContentSchema
58
+ },
59
+ })
60
+ .array(),
61
+ }),
62
+ z.object({
63
+ type: z.literal("artifact"),
64
+ ...unitArtifactSchema.shape,
65
+ }),
66
+ z.object({
67
+ type: z.literal("local"),
68
+ path: z.string(),
69
+ }),
70
+ z.object({
71
+ type: z.literal("remote"),
72
+ endpoint: l7EndpointEntity.schema,
73
+ }),
74
+ ])
86
75
 
87
76
  export const folderEntity = defineEntity({
88
77
  type: "common.folder",
89
78
 
90
- schema: Type.Object({
79
+ schema: z.object({
91
80
  meta: folderMetaSchema,
92
81
  content: folderContentSchema,
93
82
  }),
@@ -104,7 +93,7 @@ export const remoteFile = defineUnit({
104
93
  /**
105
94
  * The URL of the remote file.
106
95
  */
107
- url: Type.Optional(Type.String()),
96
+ url: z.string().optional(),
108
97
  },
109
98
 
110
99
  inputs: {
@@ -122,9 +111,9 @@ export const remoteFile = defineUnit({
122
111
  },
123
112
 
124
113
  meta: {
125
- displayName: "Remote File",
114
+ title: "Remote File",
126
115
  description: "References a file from a remote URL.",
127
- primaryIcon: "mdi:file-download",
116
+ icon: "mdi:file-download",
128
117
  category: "Files",
129
118
  },
130
119
 
@@ -134,13 +123,13 @@ export const remoteFile = defineUnit({
134
123
  },
135
124
  })
136
125
 
137
- export type File = Static<typeof fileEntity.schema>
138
- export type FileMeta = Static<typeof baseFileMetaSchema>
139
- export type FileContent = Static<typeof fileContentSchema>
126
+ export type File = z.infer<typeof fileEntity.schema>
127
+ export type FileMeta = z.infer<typeof baseFileMetaSchema>
128
+ export type FileContent = z.infer<typeof fileContentSchema>
140
129
 
141
- export type Folder = Static<typeof folderEntity.schema>
142
- export type FolderMeta = Static<typeof folderMetaSchema>
143
- export type FolderContent = Static<typeof folderContentSchema>
130
+ export type Folder = z.infer<typeof folderEntity.schema>
131
+ export type FolderMeta = z.infer<typeof folderMetaSchema>
132
+ export type FolderContent = z.infer<typeof folderContentSchema>
144
133
 
145
- export type Checksum = Static<typeof checksumSchema>
146
- export type ChecksumAlgorithm = Static<typeof checksumAlgorithmSchema>
134
+ export type Checksum = z.infer<typeof checksumSchema>
135
+ export type ChecksumAlgorithm = z.infer<typeof checksumAlgorithmSchema>
package/src/git.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { l7EndpointEntity } from "./network"
3
3
  import { folderEntity } from "./files"
4
4
 
@@ -9,21 +9,21 @@ export const remoteRepository = defineUnit({
9
9
  /**
10
10
  * The URL of the remote repository.
11
11
  */
12
- url: Type.Optional(Type.String()),
12
+ url: z.string().optional(),
13
13
 
14
14
  /**
15
15
  * The ref of the remote repository to checkout.
16
16
  *
17
17
  * If not specified, the default branch will be used.
18
18
  */
19
- ref: Type.Optional(Type.String()),
19
+ ref: z.string().optional(),
20
20
 
21
21
  /**
22
22
  * Whether to include the .git directory in the packed artifact.
23
23
  *
24
24
  * Do not enable this unless you need the full git history.
25
25
  */
26
- includeGit: Type.Default(Type.Boolean(), false),
26
+ includeGit: z.boolean().default(false),
27
27
  },
28
28
 
29
29
  inputs: {
@@ -44,10 +44,10 @@ export const remoteRepository = defineUnit({
44
44
  },
45
45
 
46
46
  meta: {
47
- displayName: "Git Remote Repository",
47
+ title: "Git Remote Repository",
48
48
  description: "References a remote Git repository.",
49
- primaryIcon: "simple-icons:git",
50
- primaryIconColor: "#f1502f",
49
+ icon: "simple-icons:git",
50
+ iconColor: "#f1502f",
51
51
  category: "Git",
52
52
  },
53
53
 
package/src/k3s.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineUnit, Type } from "@highstate/contract"
1
+ import { defineUnit, z } from "@highstate/contract"
2
2
  import { clusterInputs, clusterOutputs } from "./k8s"
3
3
 
4
4
  export const packagedComponents = [
@@ -18,9 +18,9 @@ export const internalComponents = [
18
18
  "helm-controller",
19
19
  ] as const
20
20
 
21
- export const componentSchema = Type.StringEnum([...packagedComponents, ...internalComponents])
21
+ export const componentSchema = z.enum([...packagedComponents, ...internalComponents])
22
22
 
23
- export const cniSchema = Type.StringEnum(["none", "flannel"])
23
+ export const cniSchema = z.enum(["none", "flannel"])
24
24
 
25
25
  export const cluster = defineUnit({
26
26
  type: "k3s.cluster",
@@ -29,7 +29,7 @@ export const cluster = defineUnit({
29
29
  /**
30
30
  * The components to disable in the K3S cluster.
31
31
  */
32
- disabledComponents: Type.Default(Type.Array(componentSchema), []),
32
+ disabledComponents: componentSchema.array().default([]),
33
33
 
34
34
  /**
35
35
  * The CNI to use in the K3S cluster.
@@ -37,31 +37,31 @@ export const cluster = defineUnit({
37
37
  * Setting this to "none" will disable default Flannel CNI, but will not disable network policy controller and kube-proxy.
38
38
  * If needed, you can disable them using `disabledComponents` argument.
39
39
  */
40
- cni: Type.Default(cniSchema, "flannel"),
40
+ cni: cniSchema.default("flannel"),
41
41
 
42
42
  /**
43
43
  * The K3S configuration to pass to each server or agent in the cluster.
44
44
  *
45
45
  * See: https://docs.k3s.io/installation/configuration
46
46
  */
47
- config: Type.Optional(Type.Record(Type.String(), Type.Any())),
47
+ config: z.record(z.string(), z.any()).optional(),
48
48
 
49
49
  /**
50
50
  * The configuration of the registries to use for the K3S cluster.
51
51
  *
52
52
  * See: https://docs.k3s.io/installation/private-registry
53
53
  */
54
- registries: Type.Optional(Type.Record(Type.String(), Type.Any())),
54
+ registries: z.record(z.string(), z.any()).optional(),
55
55
  },
56
56
 
57
57
  inputs: clusterInputs,
58
58
  outputs: clusterOutputs,
59
59
 
60
60
  meta: {
61
- displayName: "K3s Cluster",
61
+ title: "K3s Cluster",
62
62
  description: "The K3s cluster created on top of the server.",
63
63
  category: "k3s",
64
- primaryIcon: "devicon:k3s",
64
+ icon: "devicon:k3s",
65
65
  secondaryIcon: "devicon:kubernetes",
66
66
  },
67
67