@highstate/library 0.15.0 → 0.17.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.
- package/dist/highstate.library.msgpack +0 -0
- package/dist/index.js +1721 -953
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/abbreviations.ts +1 -0
- package/src/common/access-point.ts +2 -2
- package/src/common/files.ts +10 -0
- package/src/common/server.ts +15 -57
- package/src/databases/etcd.ts +97 -0
- package/src/databases/index.ts +1 -0
- package/src/databases/mariadb.ts +48 -2
- package/src/databases/mongodb.ts +48 -2
- package/src/databases/postgresql.ts +51 -2
- package/src/databases/redis.ts +48 -2
- package/src/databases/s3.ts +65 -6
- package/src/databases/shared.ts +12 -6
- package/src/dns.ts +59 -49
- package/src/k8s/apps/etcd.ts +46 -0
- package/src/k8s/apps/index.ts +2 -0
- package/src/k8s/apps/mariadb.ts +0 -5
- package/src/k8s/apps/minio.ts +0 -5
- package/src/k8s/apps/mongodb.ts +0 -5
- package/src/k8s/apps/postgresql.ts +0 -5
- package/src/k8s/apps/shared.ts +10 -1
- package/src/k8s/apps/traefik.ts +16 -1
- package/src/k8s/apps/valkey.ts +0 -5
- package/src/k8s/apps/wg-feed-server.ts +34 -0
- package/src/k8s/reduced-access.ts +23 -53
- package/src/k8s/resources.ts +78 -35
- package/src/k8s/service.ts +21 -10
- package/src/k8s/shared.ts +60 -90
- package/src/k8s/workload.ts +87 -26
- package/src/network/address-space.ts +94 -0
- package/src/network/address.ts +33 -0
- package/src/network/dynamic-endpoint.ts +39 -0
- package/src/network/endpoint-schema.ts +116 -0
- package/src/network/endpoint.ts +347 -0
- package/src/network/index.ts +6 -0
- package/src/network/subnet.ts +31 -0
- package/src/ssh.ts +66 -10
- package/src/third-party/cloudflare.ts +1 -0
- package/src/utils.ts +41 -11
- package/src/wireguard.ts +340 -150
- package/src/network.ts +0 -391
package/src/ssh.ts
CHANGED
|
@@ -4,11 +4,8 @@ import { l4EndpointEntity, portSchema } from "./network"
|
|
|
4
4
|
|
|
5
5
|
export const keyTypeSchema = z.enum(["ed25519"])
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export const keyPairEntity = defineEntity({
|
|
11
|
-
type: "ssh.key-pair.v1",
|
|
7
|
+
export const publicKeyEntity = defineEntity({
|
|
8
|
+
type: "ssh.public-key.v1",
|
|
12
9
|
|
|
13
10
|
schema: z.object({
|
|
14
11
|
/**
|
|
@@ -19,15 +16,30 @@ export const keyPairEntity = defineEntity({
|
|
|
19
16
|
type: keyTypeSchema,
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
|
-
* The
|
|
19
|
+
* The public key in OpenSSH format.
|
|
23
20
|
*/
|
|
24
|
-
|
|
21
|
+
publicKey: z.string(),
|
|
25
22
|
|
|
26
23
|
/**
|
|
27
|
-
* The
|
|
24
|
+
* The fingerprint of the SSH key.
|
|
28
25
|
*/
|
|
29
|
-
|
|
26
|
+
fingerprint: z.string(),
|
|
27
|
+
}),
|
|
30
28
|
|
|
29
|
+
meta: {
|
|
30
|
+
color: "#2b5797",
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The entity representing an SSH key pair.
|
|
36
|
+
*/
|
|
37
|
+
export const keyPairEntity = defineEntity({
|
|
38
|
+
type: "ssh.key-pair.v1",
|
|
39
|
+
|
|
40
|
+
extends: { publicKeyEntity },
|
|
41
|
+
|
|
42
|
+
schema: z.object({
|
|
31
43
|
/**
|
|
32
44
|
* The private key in PEM format.
|
|
33
45
|
*/
|
|
@@ -109,12 +121,55 @@ export const secrets = $secrets({
|
|
|
109
121
|
|
|
110
122
|
export const inputs = $inputs({
|
|
111
123
|
/**
|
|
112
|
-
* The SSH key pair to use for authentication.
|
|
124
|
+
* The SSH key pair to use for authentication by Highstate.
|
|
113
125
|
*/
|
|
114
126
|
sshKeyPair: {
|
|
115
127
|
entity: keyPairEntity,
|
|
116
128
|
required: false,
|
|
117
129
|
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* The extra SSH public keys to add to the server's `authorized_keys` file.
|
|
133
|
+
*
|
|
134
|
+
* Will not (and cannot) be used for authentication by Highstate.
|
|
135
|
+
*/
|
|
136
|
+
sshPublicKeys: {
|
|
137
|
+
entity: publicKeyEntity,
|
|
138
|
+
required: false,
|
|
139
|
+
multiple: true,
|
|
140
|
+
},
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Provides existing SSH public key.
|
|
145
|
+
*/
|
|
146
|
+
export const publicKey = defineUnit({
|
|
147
|
+
type: "ssh.public-key.v1",
|
|
148
|
+
|
|
149
|
+
args: {
|
|
150
|
+
/**
|
|
151
|
+
* The public key in OpenSSH format.
|
|
152
|
+
*/
|
|
153
|
+
publicKey: z.string().meta({ multiline: true }),
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
outputs: {
|
|
157
|
+
publicKey: publicKeyEntity,
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
meta: {
|
|
161
|
+
title: "SSH Public Key",
|
|
162
|
+
category: "ssh",
|
|
163
|
+
icon: "charm:key",
|
|
164
|
+
iconColor: "#ffffff",
|
|
165
|
+
secondaryIcon: "mdi:lock-open",
|
|
166
|
+
secondaryIconColor: "#ffffff",
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
source: {
|
|
170
|
+
package: "@highstate/common",
|
|
171
|
+
path: "units/ssh/public-key",
|
|
172
|
+
},
|
|
118
173
|
})
|
|
119
174
|
|
|
120
175
|
/**
|
|
@@ -154,5 +209,6 @@ export const keyPair = defineUnit({
|
|
|
154
209
|
|
|
155
210
|
export type Args = z.infer<typeof argsSchema>
|
|
156
211
|
export type KeyType = z.infer<typeof keyTypeSchema>
|
|
212
|
+
export type PublicKey = z.infer<typeof publicKeyEntity.schema>
|
|
157
213
|
export type KeyPair = z.infer<typeof keyPairEntity.schema>
|
|
158
214
|
export type Connection = z.infer<typeof connectionSchema>
|
package/src/utils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { z } from "@highstate/contract"
|
|
1
|
+
import { type FullComponentArgumentOptions, genericNameSchema, z } from "@highstate/contract"
|
|
2
|
+
import { mapValues } from "remeda"
|
|
2
3
|
|
|
3
4
|
type PrefixWith<TString extends string, TPrefix extends string> = TPrefix extends ""
|
|
4
5
|
? TString
|
|
@@ -37,16 +38,7 @@ export function prefixKeysWith<T extends Record<string, unknown>, Prefix extends
|
|
|
37
38
|
) as PrefixedKeys<T, Prefix>
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export const
|
|
41
|
-
export const booleanPatchSchema = z.enum(["keep", "true", "false"])
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The mode to use when patching some array:
|
|
45
|
-
*
|
|
46
|
-
* - `prepend`: prepend the values of the new array to the existing array;
|
|
47
|
-
* - `replace`: replace the existing array with the new array.
|
|
48
|
-
*/
|
|
49
|
-
export type ArrayPatchMode = z.infer<typeof arrayPatchModeSchema>
|
|
41
|
+
export const booleanPatchSchema = z.enum(["keep", "true", "false"]).default("keep")
|
|
50
42
|
|
|
51
43
|
/**
|
|
52
44
|
* The boolean patch:
|
|
@@ -56,3 +48,41 @@ export type ArrayPatchMode = z.infer<typeof arrayPatchModeSchema>
|
|
|
56
48
|
* - `false`: set the value to `false`.
|
|
57
49
|
*/
|
|
58
50
|
export type BooleanPatch = z.infer<typeof booleanPatchSchema>
|
|
51
|
+
|
|
52
|
+
export function toPatchArgs<T extends Record<string, FullComponentArgumentOptions>>(
|
|
53
|
+
args: T,
|
|
54
|
+
): {
|
|
55
|
+
[K in keyof T]: T[K]["schema"] extends z.ZodBoolean
|
|
56
|
+
? Omit<T[K], "schema"> & { schema: typeof booleanPatchSchema }
|
|
57
|
+
: T[K]
|
|
58
|
+
} {
|
|
59
|
+
return mapValues(args, arg => {
|
|
60
|
+
if (
|
|
61
|
+
arg.schema instanceof z.ZodBoolean ||
|
|
62
|
+
(arg.schema instanceof z.ZodDefault && arg.schema.unwrap() instanceof z.ZodBoolean) ||
|
|
63
|
+
(arg.schema instanceof z.ZodOptional && arg.schema.unwrap() instanceof z.ZodBoolean)
|
|
64
|
+
) {
|
|
65
|
+
return { ...arg, schema: booleanPatchSchema }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return arg
|
|
69
|
+
// biome-ignore lint/suspicious/noExplicitAny: already typed
|
|
70
|
+
}) as any
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The schema for a metadata key.
|
|
75
|
+
*
|
|
76
|
+
* Follows the same conventions as Highstate generic name, but requires at least two segments separated by a dot.
|
|
77
|
+
*/
|
|
78
|
+
export const metadataKeySchema = z.templateLiteral([
|
|
79
|
+
genericNameSchema,
|
|
80
|
+
z.literal("."),
|
|
81
|
+
genericNameSchema,
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
export const metadataSchema = z.record(metadataKeySchema, z.unknown())
|
|
85
|
+
|
|
86
|
+
export type Metadata = z.infer<typeof metadataSchema>
|
|
87
|
+
export type MetadataKey = z.infer<typeof metadataKeySchema>
|
|
88
|
+
export type MetadataContainer = { metadata?: Metadata }
|