@highstate/library 0.9.16 → 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.
Files changed (82) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +3548 -2985
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -5
  5. package/src/common/access-point.ts +105 -0
  6. package/src/common/files.ts +137 -0
  7. package/src/common/index.ts +3 -0
  8. package/src/common/server.ts +231 -0
  9. package/src/databases/index.ts +4 -0
  10. package/src/databases/mariadb.ts +37 -0
  11. package/src/databases/mongodb.ts +37 -0
  12. package/src/databases/postgresql.ts +37 -0
  13. package/src/databases/shared.ts +61 -0
  14. package/src/distributions/ubuntu.ts +13 -11
  15. package/src/dns.ts +116 -18
  16. package/src/git.ts +14 -10
  17. package/src/impl-ref.ts +26 -0
  18. package/src/index.ts +14 -15
  19. package/src/k3s.ts +14 -12
  20. package/src/k8s/apps/code-server.ts +48 -0
  21. package/src/k8s/apps/gitea.ts +25 -0
  22. package/src/k8s/apps/grocy.ts +39 -0
  23. package/src/k8s/apps/hubble.ts +30 -0
  24. package/src/{apps → k8s/apps}/index.ts +16 -13
  25. package/src/k8s/apps/kubernetes-dashboard.ts +28 -0
  26. package/src/k8s/apps/mariadb.ts +83 -0
  27. package/src/k8s/apps/maybe.ts +39 -0
  28. package/src/k8s/apps/mongodb.ts +84 -0
  29. package/src/k8s/apps/postgresql.ts +86 -0
  30. package/src/k8s/apps/shared.ts +149 -0
  31. package/src/k8s/apps/syncthing.ts +72 -0
  32. package/src/k8s/apps/traefik.ts +40 -0
  33. package/src/k8s/apps/vaultwarden.ts +31 -0
  34. package/src/k8s/apps/workload.ts +214 -0
  35. package/src/k8s/apps/zitadel.ts +26 -0
  36. package/src/k8s/cert-manager.ts +80 -0
  37. package/src/k8s/cilium.ts +64 -0
  38. package/src/k8s/gateway.ts +70 -0
  39. package/src/k8s/index.ts +9 -0
  40. package/src/{obfuscators → k8s/obfuscators}/phantun.ts +14 -10
  41. package/src/{obfuscators → k8s/obfuscators}/shared.ts +17 -11
  42. package/src/k8s/resources.ts +111 -0
  43. package/src/k8s/service.ts +65 -0
  44. package/src/k8s/shared.ts +343 -0
  45. package/src/k8s/workload.ts +77 -0
  46. package/src/network.ts +249 -63
  47. package/src/nixos.ts +38 -77
  48. package/src/proxmox.ts +203 -96
  49. package/src/restic.ts +28 -19
  50. package/src/sops.ts +19 -8
  51. package/src/ssh.ts +122 -24
  52. package/src/talos.ts +21 -19
  53. package/src/third-party/cloudflare.ts +59 -0
  54. package/src/third-party/index.ts +3 -0
  55. package/src/{mullvad.ts → third-party/mullvad.ts} +11 -9
  56. package/src/third-party/timeweb.ts +99 -0
  57. package/src/utils.ts +27 -6
  58. package/src/wireguard.ts +249 -115
  59. package/src/apps/code-server.ts +0 -34
  60. package/src/apps/deployment.ts +0 -60
  61. package/src/apps/dns.ts +0 -107
  62. package/src/apps/gitea.ts +0 -18
  63. package/src/apps/grocy.ts +0 -20
  64. package/src/apps/hubble.ts +0 -20
  65. package/src/apps/kubernetes-dashboard.ts +0 -19
  66. package/src/apps/mariadb.ts +0 -81
  67. package/src/apps/maybe.ts +0 -25
  68. package/src/apps/mongodb.ts +0 -81
  69. package/src/apps/network.ts +0 -55
  70. package/src/apps/postgresql.ts +0 -81
  71. package/src/apps/shared.ts +0 -290
  72. package/src/apps/syncthing.ts +0 -54
  73. package/src/apps/test.ts +0 -19
  74. package/src/apps/traefik.ts +0 -36
  75. package/src/apps/vaultwarden.ts +0 -23
  76. package/src/apps/zitadel.ts +0 -21
  77. package/src/cloudflare.ts +0 -26
  78. package/src/common.ts +0 -200
  79. package/src/files.ts +0 -146
  80. package/src/k8s.ts +0 -638
  81. package/src/timeweb.ts +0 -75
  82. package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
package/src/proxmox.ts CHANGED
@@ -1,23 +1,30 @@
1
- import { defineEntity, defineUnit, Type } from "@highstate/contract"
2
- import { checksumSchema, fileEntity, serverOutputs } from "./common"
3
- import { credentialsSchema, keyPairEntity } from "./ssh"
4
- import { l7EndpointEntity } from "./network"
1
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
+ import {
3
+ checksumSchema,
4
+ fileEntity,
5
+ serverEntity,
6
+ serverOutputs,
7
+ vmSecrets,
8
+ vmSshArgs,
9
+ } from "./common"
10
+ import { ipv4PrefixSchema, ipv46Schema, l7EndpointEntity } from "./network"
11
+ import * as ssh from "./ssh"
5
12
 
6
13
  export const clusterEntity = defineEntity({
7
- type: "proxmox.cluster",
14
+ type: "proxmox.cluster.v1",
8
15
 
9
- schema: Type.Object({
16
+ schema: z.object({
10
17
  endpoint: l7EndpointEntity.schema,
11
- insecure: Type.Optional(Type.Boolean()),
12
- username: Type.Optional(Type.String()),
18
+ insecure: z.boolean().optional(),
19
+ username: z.string().optional(),
13
20
 
14
- defaultNodeName: Type.String(),
15
- defaultDatastoreId: Type.String(),
21
+ defaultNodeName: z.string(),
22
+ defaultDatastoreId: z.string(),
16
23
 
17
- password: Type.Optional(Type.String()),
18
- apiToken: Type.Optional(Type.String()),
24
+ password: z.string().optional(),
25
+ apiToken: z.string().optional(),
19
26
 
20
- ssh: Type.Optional(credentialsSchema),
27
+ ssh: ssh.connectionSchema.optional(),
21
28
  }),
22
29
 
23
30
  meta: {
@@ -26,10 +33,10 @@ export const clusterEntity = defineEntity({
26
33
  })
27
34
 
28
35
  export const imageEntity = defineEntity({
29
- type: "proxmox.image",
36
+ type: "proxmox.image.v1",
30
37
 
31
- schema: Type.Object({
32
- id: Type.String(),
38
+ schema: z.object({
39
+ id: z.string(),
33
40
  }),
34
41
 
35
42
  meta: {
@@ -37,54 +44,48 @@ export const imageEntity = defineEntity({
37
44
  },
38
45
  })
39
46
 
47
+ /**
48
+ * The connection to an existing Proxmox cluster.
49
+ */
40
50
  export const connection = defineUnit({
41
- type: "proxmox.connection",
51
+ type: "proxmox.connection.v1",
42
52
 
43
53
  args: {
44
54
  /**
45
55
  * The endpoint of the Proxmox API.
46
56
  */
47
- endpoint: Type.String(),
57
+ endpoint: z.string(),
48
58
 
49
59
  /**
50
60
  * Whether to allow insecure connections to the Proxmox API.
51
61
  */
52
- insecure: Type.Optional(Type.Boolean()),
62
+ insecure: z.boolean().optional(),
53
63
 
54
64
  /**
55
65
  * The username to use for the Proxmox API.
56
66
  *
57
67
  * Only required for password token authentication.
58
68
  */
59
- username: Type.Optional(Type.String()),
69
+ username: z.string().optional(),
60
70
 
61
71
  /**
62
72
  * The name of the default Proxmox node to use for operations.
63
73
  *
64
74
  * If not specified, the first node in the cluster will be used.
65
75
  */
66
- defaultNodeName: Type.Optional(Type.String()),
76
+ defaultNodeName: z.string().optional(),
67
77
 
68
78
  /**
69
79
  * The ID of the default Proxmox datastore to use for operations.
70
80
  *
71
81
  * If not specified, the first datastore in the cluster will be used.
72
82
  */
73
- defaultDatastoreId: Type.Optional(Type.String()),
83
+ defaultDatastoreId: z.string().optional(),
74
84
 
75
85
  /**
76
- * The username to use for SSH connections to the Proxmox nodes.
77
- *
78
- * By default, this is set to "root".
79
- */
80
- sshUser: Type.Default(Type.String(), "root"),
81
-
82
- /**
83
- * The port to use for SSH connections to the Proxmox nodes.
84
- *
85
- * By default, this is set to 22.
86
+ * The SSH configuration to use for connecting to the Proxmox nodes.
86
87
  */
87
- sshPort: Type.Default(Type.Number(), 22),
88
+ ssh: ssh.argsSchema.prefault({}),
88
89
  },
89
90
 
90
91
  secrets: {
@@ -94,9 +95,9 @@ export const connection = defineUnit({
94
95
  * Requires `username` to be set.
95
96
  */
96
97
  password: {
97
- schema: Type.Optional(Type.String()),
98
+ schema: z.string().optional(),
98
99
  meta: {
99
- displayName: "Proxmox Password",
100
+ title: "Proxmox Password",
100
101
  },
101
102
  },
102
103
 
@@ -104,38 +105,39 @@ export const connection = defineUnit({
104
105
  * The Proxmox API token to use for authentication.
105
106
  */
106
107
  apiToken: {
107
- schema: Type.Optional(Type.String()),
108
+ schema: z.string().optional(),
108
109
  meta: {
109
- displayName: "Proxmox API Token",
110
+ title: "Proxmox API Token",
110
111
  },
111
112
  },
112
113
 
113
- /**
114
- * The SSH password to use for connecting to the Proxmox nodes.
115
- */
116
- sshPassword: Type.Optional(Type.String()),
114
+ ...ssh.secrets,
117
115
  },
118
116
 
119
117
  inputs: {
120
- /**
121
- * The key pair to use for SSH connections to the Proxmox nodes.
122
- */
123
- sshKeyPair: {
124
- entity: keyPairEntity,
125
- required: false,
126
- },
118
+ ...ssh.inputs,
127
119
  },
128
120
 
129
121
  outputs: {
122
+ /**
123
+ * The Proxmox cluster.
124
+ */
130
125
  proxmoxCluster: clusterEntity,
126
+
127
+ /**
128
+ * The server representing the Proxmox API endpoint.
129
+ */
130
+ server: {
131
+ entity: serverEntity,
132
+ required: false,
133
+ },
131
134
  },
132
135
 
133
136
  meta: {
134
- displayName: "Proxmox Connection",
135
- description: "The connection to an existing Proxmox cluster.",
137
+ title: "Proxmox Connection",
136
138
  category: "Proxmox",
137
- primaryIcon: "simple-icons:proxmox",
138
- primaryIconColor: "#e56901",
139
+ icon: "simple-icons:proxmox",
140
+ iconColor: "#e56901",
139
141
  },
140
142
 
141
143
  source: {
@@ -144,8 +146,11 @@ export const connection = defineUnit({
144
146
  },
145
147
  })
146
148
 
149
+ /**
150
+ * The image to upload to a Proxmox cluster.
151
+ */
147
152
  export const image = defineUnit({
148
- type: "proxmox.image",
153
+ type: "proxmox.image.v1",
149
154
 
150
155
  args: {
151
156
  /**
@@ -154,31 +159,31 @@ export const image = defineUnit({
154
159
  * If not specified, the default name is `<unitName>-<sha256>.<extension>`
155
160
  * or `<unitName>.<extension>` if `sha256` is not provided.
156
161
  */
157
- fileName: Type.Optional(Type.String()),
162
+ fileName: z.string().optional(),
158
163
 
159
164
  /**
160
165
  * The URL of the image to upload.
161
166
  */
162
- url: Type.Optional(Type.String()),
167
+ url: z.string().optional(),
163
168
 
164
169
  /**
165
170
  * The checksum of the image file to verify.
166
171
  */
167
- checksum: Type.Optional(checksumSchema),
172
+ checksum: checksumSchema.optional(),
168
173
 
169
174
  /**
170
175
  * The name of the Proxmox node to upload the image to.
171
176
  *
172
177
  * If not specified, the default node name from the cluster will be used.
173
178
  */
174
- nodeName: Type.Optional(Type.String()),
179
+ nodeName: z.string().optional(),
175
180
 
176
181
  /**
177
182
  * The ID of the Proxmox datastore to upload the image to.
178
183
  *
179
184
  * If not specified, the default datastore ID from the cluster will be used.
180
185
  */
181
- datastoreId: Type.Optional(Type.String()),
186
+ datastoreId: z.string().optional(),
182
187
  },
183
188
 
184
189
  inputs: {
@@ -203,11 +208,10 @@ export const image = defineUnit({
203
208
  },
204
209
 
205
210
  meta: {
206
- displayName: "Proxmox Image",
207
- description: "The image to upload to a Proxmox cluster.",
211
+ title: "Proxmox Image",
208
212
  category: "Proxmox",
209
- primaryIcon: "simple-icons:proxmox",
210
- primaryIconColor: "#e56901",
213
+ icon: "simple-icons:proxmox",
214
+ iconColor: "#e56901",
211
215
  secondaryIcon: "mage:compact-disk-fill",
212
216
  },
213
217
 
@@ -217,11 +221,14 @@ export const image = defineUnit({
217
221
  },
218
222
  })
219
223
 
224
+ /**
225
+ * The existing image on a Proxmox cluster.
226
+ */
220
227
  export const existingImage = defineUnit({
221
- type: "proxmox.existing-image",
228
+ type: "proxmox.existing-image.v1",
222
229
 
223
230
  args: {
224
- id: Type.String(),
231
+ id: z.string(),
225
232
  },
226
233
 
227
234
  inputs: {
@@ -233,11 +240,10 @@ export const existingImage = defineUnit({
233
240
  },
234
241
 
235
242
  meta: {
236
- displayName: "Proxmox Existing Image",
237
- description: "The existing image on a Proxmox cluster.",
243
+ title: "Proxmox Existing Image",
238
244
  category: "Proxmox",
239
- primaryIcon: "simple-icons:proxmox",
240
- primaryIconColor: "#e56901",
245
+ icon: "simple-icons:proxmox",
246
+ iconColor: "#e56901",
241
247
  secondaryIcon: "mage:compact-disk-fill",
242
248
  },
243
249
 
@@ -247,50 +253,147 @@ export const existingImage = defineUnit({
247
253
  },
248
254
  })
249
255
 
256
+ /**
257
+ * The virtual machine on a Proxmox cluster.
258
+ */
250
259
  export const virtualMachine = defineUnit({
251
- type: "proxmox.virtual-machine",
260
+ type: "proxmox.virtual-machine.v1",
252
261
 
253
262
  args: {
254
- nodeName: Type.Optional(Type.String()),
263
+ /**
264
+ * The name of the node to create the virtual machine on.
265
+ *
266
+ * If not specified, the default node name from the cluster will be used.
267
+ */
268
+ nodeName: z.string().optional(),
255
269
 
256
- cpuType: Type.Default(Type.String(), "host"),
257
- cores: Type.Default(Type.Number(), 1),
258
- sockets: Type.Default(Type.Number(), 1),
259
- memory: Type.Default(Type.Number(), 512),
270
+ /**
271
+ * The ID of the Proxmox datastore to create the virtual machine on.
272
+ *
273
+ * If not specified, the default datastore ID from the cluster will be used.
274
+ */
275
+ datastoreId: z.string().optional(),
260
276
 
261
277
  /**
262
- * The IPv4 address to assign to the virtual machine.
278
+ * The type of CPU to use for the virtual machine.
263
279
  *
264
- * If not specified, the virtual machine will not have an IPv4 address.
280
+ * By default, this is set to "host" which offers the best performance.
281
+ */
282
+ cpuType: z.string().default("host"),
283
+
284
+ /**
285
+ * The resources to allocate to the virtual machine.
286
+ */
287
+ resources: z
288
+ .object({
289
+ /**
290
+ * The number of CPU cores to allocate to the virtual machine.
291
+ *
292
+ * By default, this is set to 1.
293
+ */
294
+ cores: z.number().default(1),
295
+
296
+ /**
297
+ * The number of CPU sockets to allocate to the virtual machine.
298
+ *
299
+ * By default, this is set to 1.
300
+ */
301
+ sockets: z.number().default(1),
302
+
303
+ /**
304
+ * The amount of dedicated memory to allocate to the virtual machine, in MB.
305
+ *
306
+ * By default, this is set to 512 MB.
307
+ */
308
+ memory: z.number().default(512),
309
+
310
+ /**
311
+ * The size of the disk to create for the virtual machine, in GB.
312
+ *
313
+ * By default, this is set to 8 GB.
314
+ */
315
+ diskSize: z.number().default(8),
316
+ })
317
+ .prefault({}),
318
+
319
+ /**
320
+ * The IPv4 address configuration for the virtual machine.
321
+ */
322
+ ipv4: z
323
+ .discriminatedUnion("type", [
324
+ z.object({
325
+ type: z.literal("dhcp"),
326
+ }),
327
+ z.object({
328
+ type: z.literal("static"),
329
+
330
+ /**
331
+ * The IPv4 address to assign to the virtual machine.
332
+ */
333
+ address: z.ipv4(),
334
+
335
+ /**
336
+ * The CIDR prefix for the IPv4 address.
337
+ *
338
+ * By default, this is set to 24.
339
+ */
340
+ prefix: ipv4PrefixSchema.default(24),
341
+
342
+ /**
343
+ * The IPv4 gateway for the virtual machine.
344
+ *
345
+ * If not specified, will be set to the first address in the subnet.
346
+ */
347
+ gateway: z.ipv4().optional(),
348
+ }),
349
+ ])
350
+ .default({ type: "dhcp" }),
351
+
352
+ /**
353
+ * The network configuration for the virtual machine.
265
354
  */
266
- ipv4: Type.Optional(Type.String()),
267
- ipv4Gateway: Type.Optional(Type.String()),
268
- dns: Type.Optional(Type.Array(Type.String())),
355
+ network: z
356
+ .object({
357
+ /**
358
+ * The list of DNS servers to use for the virtual machine.
359
+ */
360
+ dns: ipv46Schema.array().default([]),
361
+
362
+ /**
363
+ * The name of the network bridge to connect the virtual machine to.
364
+ *
365
+ * By default, this is set to "vmbr0".
366
+ */
367
+ bridge: z.string().default("vmbr0"),
368
+ })
369
+ .prefault({}),
269
370
 
270
- datastoreId: Type.Optional(Type.String()),
271
- diskSize: Type.Default(Type.Number(), 8),
272
- bridge: Type.Default(Type.String(), "vmbr0"),
371
+ /**
372
+ * The SSH configuration for the virtual machine.
373
+ */
374
+ ssh: vmSshArgs,
273
375
 
274
- sshPort: Type.Default(Type.Number(), 22),
275
- sshUser: Type.Default(Type.String(), "root"),
376
+ /**
377
+ * Whether to wait for the Proxmox agent to be ready before returning.
378
+ */
379
+ waitForAgent: z.boolean().default(true),
276
380
 
277
- waitForAgent: Type.Default(Type.Boolean(), true),
278
- vendorData: Type.Optional(Type.String({ language: "yaml" })),
381
+ /**
382
+ * The cloud-init vendor data to use for the virtual machine.
383
+ *
384
+ * Will take precedence over the `vendorData` input.
385
+ */
386
+ vendorData: z.string().optional().meta({ multiline: true }),
279
387
  },
280
388
 
281
389
  secrets: {
282
- sshPassword: Type.Optional(Type.String()),
390
+ ...vmSecrets,
283
391
  },
284
392
 
285
393
  inputs: {
286
394
  proxmoxCluster: clusterEntity,
287
395
  image: imageEntity,
288
396
 
289
- sshKeyPair: {
290
- entity: keyPairEntity,
291
- required: false,
292
- },
293
-
294
397
  /**
295
398
  * The cloud-init vendor data to use for the virtual machine.
296
399
  *
@@ -300,16 +403,17 @@ export const virtualMachine = defineUnit({
300
403
  entity: fileEntity,
301
404
  required: false,
302
405
  },
406
+
407
+ ...ssh.inputs,
303
408
  },
304
409
 
305
410
  outputs: serverOutputs,
306
411
 
307
412
  meta: {
308
- displayName: "Proxmox Virtual Machine",
309
- description: "The virtual machine on a Proxmox cluster.",
413
+ title: "Proxmox Virtual Machine",
310
414
  category: "Proxmox",
311
- primaryIcon: "simple-icons:proxmox",
312
- primaryIconColor: "#e56901",
415
+ icon: "simple-icons:proxmox",
416
+ iconColor: "#e56901",
313
417
  secondaryIcon: "codicon:vm",
314
418
  },
315
419
 
@@ -318,3 +422,6 @@ export const virtualMachine = defineUnit({
318
422
  path: "virtual-machine",
319
423
  },
320
424
  })
425
+
426
+ export type Cluster = z.infer<typeof clusterEntity.schema>
427
+ export type Image = z.infer<typeof imageEntity.schema>
package/src/restic.ts CHANGED
@@ -1,16 +1,16 @@
1
- import { defineEntity, defineUnit, Type, type Static } from "@highstate/contract"
1
+ import { defineEntity, defineUnit, z } from "@highstate/contract"
2
2
  import { l3EndpointEntity, l4EndpointEntity } from "./network"
3
3
 
4
4
  export const repositoryEntity = defineEntity({
5
- type: "restic.repository",
5
+ type: "restic.repository.v1",
6
6
 
7
- schema: Type.Object({
8
- remoteEndpoints: Type.Array(Type.Union([l3EndpointEntity.schema, l4EndpointEntity.schema])),
7
+ schema: z.object({
8
+ remoteEndpoints: z.union([l3EndpointEntity.schema, l4EndpointEntity.schema]).array(),
9
9
 
10
- type: Type.Literal("rclone"),
11
- rcloneConfig: Type.String(),
12
- remoteName: Type.String(),
13
- pathPattern: Type.String(),
10
+ type: z.literal("rclone"),
11
+ rcloneConfig: z.string(),
12
+ remoteName: z.string(),
13
+ pathPattern: z.string(),
14
14
  }),
15
15
 
16
16
  meta: {
@@ -18,11 +18,21 @@ export const repositoryEntity = defineEntity({
18
18
  },
19
19
  })
20
20
 
21
- export const repo = defineUnit({
22
- type: "restic.repo",
21
+ /**
22
+ * Holds the configuration for a Restic repository and its remote storage.
23
+ */
24
+ export const repository = defineUnit({
25
+ type: "restic.repository.v1",
23
26
 
24
27
  args: {
25
- remoteEndpoints: Type.Default(Type.Array(Type.String()), []),
28
+ /**
29
+ * The remote endpoints of the cloud storage where the Restic repository will be stored.
30
+ *
31
+ * They will be used to create network policies to allow access to the storage.
32
+ *
33
+ * For some cloud providers, these endpoints can be automatically discovered.
34
+ */
35
+ remoteEndpoints: z.string().array().default([]),
26
36
 
27
37
  /**
28
38
  * The pattern for the path where backups will be stored for the specific application.
@@ -35,11 +45,11 @@ export const repo = defineUnit({
35
45
  *
36
46
  * By default, the path pattern is `backups/$clusterName/$appName`.
37
47
  */
38
- pathPattern: Type.Default(Type.String(), "backups/$clusterName/$appName"),
48
+ pathPattern: z.string().default("backups/$clusterName/$appName"),
39
49
  },
40
50
 
41
51
  secrets: {
42
- rcloneConfig: Type.String({ language: "ini" }),
52
+ rcloneConfig: z.string().meta({ language: "ini" }),
43
53
  },
44
54
 
45
55
  inputs: {
@@ -60,17 +70,16 @@ export const repo = defineUnit({
60
70
  },
61
71
 
62
72
  meta: {
63
- displayName: "Restic Repo",
64
- description: "Holds the configuration for a Restic repository and its remote storage.",
65
- primaryIconColor: "#e56901",
66
- primaryIcon: "material-symbols:backup",
73
+ title: "Restic Repo",
74
+ iconColor: "#e56901",
75
+ icon: "material-symbols:backup",
67
76
  category: "Infrastructure",
68
77
  },
69
78
 
70
79
  source: {
71
80
  package: "@highstate/restic",
72
- path: "repo",
81
+ path: "repository",
73
82
  },
74
83
  })
75
84
 
76
- export type Repository = Static<typeof repositoryEntity.schema>
85
+ export type Repository = z.infer<typeof repositoryEntity.schema>
package/src/sops.ts CHANGED
@@ -1,12 +1,20 @@
1
- import { defineUnit, Type } from "@highstate/contract"
2
- import { fileEntity } from "./files"
3
- import { serverEntity } from "./common"
1
+ import { defineUnit, z } from "@highstate/contract"
2
+ import { fileEntity } from "./common/files"
3
+ import { serverEntity } from "./common/server"
4
4
 
5
+ /**
6
+ * Encrypts secrets using SOPS for the specified servers.
7
+ */
5
8
  export const secrets = defineUnit({
6
- type: "sops.secrets",
9
+ type: "sops.secrets.v1",
7
10
 
8
11
  secrets: {
9
- data: Type.Record(Type.String(), Type.Any()),
12
+ /**
13
+ * The content of the SOPS secrets file.
14
+ *
15
+ * Will take precedence over the `data` input.
16
+ */
17
+ data: z.record(z.string(), z.unknown()),
10
18
  },
11
19
 
12
20
  inputs: {
@@ -15,6 +23,10 @@ export const secrets = defineUnit({
15
23
  required: false,
16
24
  multiple: true,
17
25
  },
26
+ data: {
27
+ entity: fileEntity,
28
+ required: false,
29
+ },
18
30
  },
19
31
 
20
32
  outputs: {
@@ -22,9 +34,8 @@ export const secrets = defineUnit({
22
34
  },
23
35
 
24
36
  meta: {
25
- displayName: "SOPS Secrets",
26
- description: "Encrypts secrets using SOPS for the specified servers.",
27
- primaryIcon: "mdi:file-lock",
37
+ title: "SOPS Secrets",
38
+ icon: "mdi:file-lock",
28
39
  category: "Secrets",
29
40
  },
30
41