@highstate/library 0.7.9 → 0.7.11
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.manifest.json +1 -1
- package/dist/index.js +371 -49
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/common.ts +82 -0
- package/src/index.ts +3 -0
- package/src/k3s.ts +5 -1
- package/src/k8s.ts +42 -37
- package/src/nixos.ts +167 -0
- package/src/sops.ts +33 -0
- package/src/timeweb.ts +73 -0
package/src/common.ts
CHANGED
@@ -66,5 +66,87 @@ export const existingServer = defineUnit({
|
|
66
66
|
},
|
67
67
|
})
|
68
68
|
|
69
|
+
export const script = defineUnit({
|
70
|
+
type: "common.script",
|
71
|
+
|
72
|
+
args: {
|
73
|
+
script: Type.String({ language: "shell" }),
|
74
|
+
updateScript: Type.Optional(Type.String({ language: "shell" })),
|
75
|
+
deleteScript: Type.Optional(Type.String({ language: "shell" })),
|
76
|
+
},
|
77
|
+
|
78
|
+
inputs: {
|
79
|
+
server: serverEntity,
|
80
|
+
},
|
81
|
+
|
82
|
+
outputs: {
|
83
|
+
server: serverEntity,
|
84
|
+
},
|
85
|
+
|
86
|
+
meta: {
|
87
|
+
displayName: "Shell Script",
|
88
|
+
description: "Run a shell script on the server.",
|
89
|
+
primaryIcon: "mdi:bash",
|
90
|
+
},
|
91
|
+
|
92
|
+
source: {
|
93
|
+
package: "@highstate/common",
|
94
|
+
path: "script",
|
95
|
+
},
|
96
|
+
})
|
97
|
+
|
98
|
+
export const fileMetaEntity = defineEntity({
|
99
|
+
type: "common.file-meta",
|
100
|
+
|
101
|
+
schema: Type.Object({
|
102
|
+
name: Type.String(),
|
103
|
+
size: Type.Number(),
|
104
|
+
isBinary: Type.Optional(Type.Boolean()),
|
105
|
+
isExecutable: Type.Optional(Type.Boolean()),
|
106
|
+
}),
|
107
|
+
|
108
|
+
meta: {
|
109
|
+
color: "#FF5722",
|
110
|
+
description: "Metadata for a file.",
|
111
|
+
},
|
112
|
+
})
|
113
|
+
|
114
|
+
export const fileContentEntity = defineEntity({
|
115
|
+
type: "common.file-content",
|
116
|
+
|
117
|
+
schema: Type.Union([
|
118
|
+
Type.Object({
|
119
|
+
type: Type.Literal("inline"),
|
120
|
+
content: Type.String(),
|
121
|
+
}),
|
122
|
+
Type.Object({
|
123
|
+
type: Type.Literal("remote"),
|
124
|
+
url: Type.String(),
|
125
|
+
}),
|
126
|
+
]),
|
127
|
+
|
128
|
+
meta: {
|
129
|
+
color: "#FF5722",
|
130
|
+
description: "The content of a file.",
|
131
|
+
},
|
132
|
+
})
|
133
|
+
|
134
|
+
export const fileEntity = defineEntity({
|
135
|
+
type: "common.file",
|
136
|
+
|
137
|
+
schema: Type.Object({
|
138
|
+
meta: fileMetaEntity.schema,
|
139
|
+
content: fileContentEntity.schema,
|
140
|
+
}),
|
141
|
+
|
142
|
+
meta: {
|
143
|
+
color: "#FF5722",
|
144
|
+
},
|
145
|
+
})
|
146
|
+
|
69
147
|
export type Server = Static<typeof serverEntity.schema>
|
70
148
|
export type Endpoint = Static<typeof endpointEntity.schema>
|
149
|
+
|
150
|
+
export type File = Static<typeof fileEntity.schema>
|
151
|
+
export type FileMeta = Static<typeof fileMetaEntity.schema>
|
152
|
+
export type FileContent = Static<typeof fileContentEntity.schema>
|
package/src/index.ts
CHANGED
package/src/k3s.ts
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
import { defineUnit } from "@highstate/contract"
|
2
2
|
import { serverEntity } from "./common"
|
3
|
-
import { clusterEntity } from "./k8s"
|
3
|
+
import { clusterEntity, sharedClusterArgs } from "./k8s"
|
4
4
|
|
5
5
|
export const cluster = defineUnit({
|
6
6
|
type: "k3s.cluster",
|
7
7
|
|
8
|
+
args: {
|
9
|
+
...sharedClusterArgs,
|
10
|
+
},
|
11
|
+
|
8
12
|
inputs: {
|
9
13
|
server: serverEntity,
|
10
14
|
},
|
package/src/k8s.ts
CHANGED
@@ -63,47 +63,51 @@ export const clusterEntity = defineEntity({
|
|
63
63
|
|
64
64
|
export const internalIpsPolicySchema = Type.StringEnum(["always", "public", "never"])
|
65
65
|
|
66
|
+
export const sharedClusterArgs = {
|
67
|
+
/**
|
68
|
+
* The list of external IPs of the cluster nodes allowed to be used for external access.
|
69
|
+
*
|
70
|
+
* If not provided, will be automatically detected by querying the cluster nodes.
|
71
|
+
*
|
72
|
+
* @schema
|
73
|
+
*/
|
74
|
+
externalIps: Type.Optional(Type.Array(Type.String())),
|
75
|
+
|
76
|
+
/**
|
77
|
+
* The policy for using internal IPs of the nodes as external IPs.
|
78
|
+
*
|
79
|
+
* - `always`: always use internal IPs as external IPs;
|
80
|
+
* - `public`: use internal IPs as external IPs only if they are (theoretically) routable from the public internet **(default)**;
|
81
|
+
* - `never`: never use internal IPs as external IPs.
|
82
|
+
*
|
83
|
+
* @schema
|
84
|
+
*/
|
85
|
+
internalIpsPolicy: { ...internalIpsPolicySchema, default: "public" },
|
86
|
+
|
87
|
+
/**
|
88
|
+
* The FQDN to register the cluster nodes with.
|
89
|
+
*
|
90
|
+
* If provided and `registerFqdn` is set to `true`, the corresponding DNS provider must be provided to set up the DNS records.
|
91
|
+
*
|
92
|
+
* @schema
|
93
|
+
*/
|
94
|
+
fqdn: Type.Optional(Type.String()),
|
95
|
+
|
96
|
+
/**
|
97
|
+
* Whether to register the cluster nodes with the provided FQDN.
|
98
|
+
*
|
99
|
+
* By default, `true`.
|
100
|
+
*
|
101
|
+
* @schema
|
102
|
+
*/
|
103
|
+
registerFqdn: Type.Boolean({ default: true }),
|
104
|
+
}
|
105
|
+
|
66
106
|
export const existingCluster = defineUnit({
|
67
107
|
type: "k8s.existing-cluster",
|
68
108
|
|
69
109
|
args: {
|
70
|
-
|
71
|
-
* The list of external IPs of the cluster nodes allowed to be used for external access.
|
72
|
-
*
|
73
|
-
* If not provided, will be automatically detected by querying the cluster nodes.
|
74
|
-
*
|
75
|
-
* @schema
|
76
|
-
*/
|
77
|
-
externalIps: Type.Optional(Type.Array(Type.String())),
|
78
|
-
|
79
|
-
/**
|
80
|
-
* The policy for using internal IPs of the nodes as external IPs.
|
81
|
-
*
|
82
|
-
* - `always`: always use internal IPs as external IPs;
|
83
|
-
* - `public`: use internal IPs as external IPs only if they are (theoretically) routable from the public internet **(default)**;
|
84
|
-
* - `never`: never use internal IPs as external IPs.
|
85
|
-
*
|
86
|
-
* @schema
|
87
|
-
*/
|
88
|
-
internalIpsPolicy: { ...internalIpsPolicySchema, default: "public" },
|
89
|
-
|
90
|
-
/**
|
91
|
-
* The FQDN to register the cluster nodes with.
|
92
|
-
*
|
93
|
-
* If provided and `registerFqdn` is set to `true`, the corresponding DNS provider must be provided to set up the DNS records.
|
94
|
-
*
|
95
|
-
* @schema
|
96
|
-
*/
|
97
|
-
fqdn: Type.Optional(Type.String()),
|
98
|
-
|
99
|
-
/**
|
100
|
-
* Whether to register the cluster nodes with the provided FQDN.
|
101
|
-
*
|
102
|
-
* By default, `true`.
|
103
|
-
*
|
104
|
-
* @schema
|
105
|
-
*/
|
106
|
-
registerFqdn: Type.Boolean({ default: true }),
|
110
|
+
...sharedClusterArgs,
|
107
111
|
},
|
108
112
|
|
109
113
|
secrets: {
|
@@ -351,3 +355,4 @@ export type PersistentVolumeClaim = Static<typeof persistentVolumeClaimEntity.sc
|
|
351
355
|
export type StatefulSet = Static<typeof statefulSetEntity.schema>
|
352
356
|
|
353
357
|
export type Interface = Static<typeof interfaceEntity.schema>
|
358
|
+
export type InternalIpsPolicy = Static<typeof internalIpsPolicySchema>
|
package/src/nixos.ts
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
import { defineEntity, defineUnit, Type } from "@highstate/contract"
|
2
|
+
import { fileEntity, serverEntity } from "./common"
|
3
|
+
|
4
|
+
export const inlineModuleEntity = defineEntity({
|
5
|
+
type: "nixos.inline-module",
|
6
|
+
|
7
|
+
schema: Type.Object({
|
8
|
+
code: Type.String(),
|
9
|
+
}),
|
10
|
+
|
11
|
+
meta: {
|
12
|
+
displayName: "NixOS Inline Module",
|
13
|
+
description: "The NixOS module reference.",
|
14
|
+
color: "#5277c3",
|
15
|
+
},
|
16
|
+
})
|
17
|
+
|
18
|
+
export const inlineModule = defineUnit({
|
19
|
+
type: "nixos.inline-module",
|
20
|
+
|
21
|
+
args: {
|
22
|
+
code: Type.String({ language: "nix" }),
|
23
|
+
},
|
24
|
+
|
25
|
+
inputs: {
|
26
|
+
files: {
|
27
|
+
entity: fileEntity,
|
28
|
+
required: false,
|
29
|
+
multiple: true,
|
30
|
+
},
|
31
|
+
},
|
32
|
+
|
33
|
+
outputs: {
|
34
|
+
module: inlineModuleEntity,
|
35
|
+
},
|
36
|
+
|
37
|
+
meta: {
|
38
|
+
displayName: "NixOS Inline Module",
|
39
|
+
description: "Creates a NixOS module from inline code.",
|
40
|
+
primaryIcon: "simple-icons:nixos",
|
41
|
+
primaryIconColor: "#7ebae4",
|
42
|
+
secondaryIcon: "mdi:file-code",
|
43
|
+
},
|
44
|
+
|
45
|
+
source: {
|
46
|
+
package: "@highstate/nixos",
|
47
|
+
path: "inline-module",
|
48
|
+
},
|
49
|
+
})
|
50
|
+
|
51
|
+
export const flakeEntity = defineEntity({
|
52
|
+
type: "nixos.flake",
|
53
|
+
|
54
|
+
schema: Type.Object({
|
55
|
+
url: Type.String(),
|
56
|
+
}),
|
57
|
+
|
58
|
+
meta: {
|
59
|
+
displayName: "NixOS Flake",
|
60
|
+
description: "The NixOS flake reference.",
|
61
|
+
color: "#5277c3",
|
62
|
+
},
|
63
|
+
})
|
64
|
+
|
65
|
+
export const remoteFlake = defineUnit({
|
66
|
+
type: "nixos.remote-flake",
|
67
|
+
|
68
|
+
args: {
|
69
|
+
url: Type.String(),
|
70
|
+
},
|
71
|
+
|
72
|
+
outputs: {
|
73
|
+
flake: flakeEntity,
|
74
|
+
},
|
75
|
+
|
76
|
+
meta: {
|
77
|
+
displayName: "NixOS Remote Flake",
|
78
|
+
description: "References a remote NixOS flake.",
|
79
|
+
primaryIcon: "simple-icons:nixos",
|
80
|
+
primaryIconColor: "#7ebae4",
|
81
|
+
secondaryIcon: "simple-icons:git",
|
82
|
+
secondaryIconColor: "#f1502f",
|
83
|
+
},
|
84
|
+
|
85
|
+
source: {
|
86
|
+
package: "@highstate/nixos",
|
87
|
+
path: "flake",
|
88
|
+
},
|
89
|
+
})
|
90
|
+
|
91
|
+
export const inlineFlake = defineUnit({
|
92
|
+
type: "nixos.inline-flake",
|
93
|
+
|
94
|
+
args: {
|
95
|
+
code: Type.String({ language: "nix" }),
|
96
|
+
},
|
97
|
+
|
98
|
+
inputs: {
|
99
|
+
flakes: {
|
100
|
+
entity: flakeEntity,
|
101
|
+
required: false,
|
102
|
+
multiple: true,
|
103
|
+
},
|
104
|
+
modules: {
|
105
|
+
entity: inlineModuleEntity,
|
106
|
+
required: false,
|
107
|
+
multiple: true,
|
108
|
+
},
|
109
|
+
files: {
|
110
|
+
entity: fileEntity,
|
111
|
+
required: false,
|
112
|
+
multiple: true,
|
113
|
+
},
|
114
|
+
},
|
115
|
+
|
116
|
+
outputs: {
|
117
|
+
flake: flakeEntity,
|
118
|
+
},
|
119
|
+
|
120
|
+
meta: {
|
121
|
+
displayName: "NixOS Inline Flake",
|
122
|
+
description: "Creates a NixOS flake from inline code.",
|
123
|
+
primaryIcon: "simple-icons:nixos",
|
124
|
+
primaryIconColor: "#7ebae4",
|
125
|
+
secondaryIcon: "mdi:file-code",
|
126
|
+
},
|
127
|
+
|
128
|
+
source: {
|
129
|
+
package: "@highstate/nixos",
|
130
|
+
path: "inline-flake",
|
131
|
+
},
|
132
|
+
})
|
133
|
+
|
134
|
+
export const system = defineUnit({
|
135
|
+
type: "nixos.system",
|
136
|
+
|
137
|
+
args: {
|
138
|
+
system: Type.Optional(Type.String()),
|
139
|
+
},
|
140
|
+
|
141
|
+
inputs: {
|
142
|
+
flake: flakeEntity,
|
143
|
+
server: serverEntity,
|
144
|
+
modules: {
|
145
|
+
entity: inlineModuleEntity,
|
146
|
+
required: false,
|
147
|
+
multiple: true,
|
148
|
+
},
|
149
|
+
},
|
150
|
+
|
151
|
+
outputs: {
|
152
|
+
server: serverEntity,
|
153
|
+
},
|
154
|
+
|
155
|
+
meta: {
|
156
|
+
displayName: "NixOS System",
|
157
|
+
description: "Creates a NixOS system on top of any server.",
|
158
|
+
primaryIcon: "simple-icons:nixos",
|
159
|
+
primaryIconColor: "#7ebae4",
|
160
|
+
secondaryIcon: "codicon:vm",
|
161
|
+
},
|
162
|
+
|
163
|
+
source: {
|
164
|
+
package: "@highstate/nixos",
|
165
|
+
path: "system",
|
166
|
+
},
|
167
|
+
})
|
package/src/sops.ts
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
import { defineUnit, Type } from "@highstate/contract"
|
2
|
+
import { fileEntity, serverEntity } from "./common"
|
3
|
+
|
4
|
+
export const secrets = defineUnit({
|
5
|
+
type: "sops.secrets",
|
6
|
+
|
7
|
+
args: {
|
8
|
+
secrets: Type.Record(Type.String(), Type.Any()),
|
9
|
+
},
|
10
|
+
|
11
|
+
inputs: {
|
12
|
+
servers: {
|
13
|
+
entity: serverEntity,
|
14
|
+
required: false,
|
15
|
+
multiple: true,
|
16
|
+
},
|
17
|
+
},
|
18
|
+
|
19
|
+
outputs: {
|
20
|
+
file: fileEntity,
|
21
|
+
},
|
22
|
+
|
23
|
+
meta: {
|
24
|
+
displayName: "SOPS Secrets",
|
25
|
+
description: "Encrypts secrets using SOPS for the specified servers.",
|
26
|
+
primaryIcon: "mdi:file-lock",
|
27
|
+
},
|
28
|
+
|
29
|
+
source: {
|
30
|
+
package: "@highstate/sops",
|
31
|
+
path: "secrets",
|
32
|
+
},
|
33
|
+
})
|
package/src/timeweb.ts
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
import { defineEntity, defineUnit, Type } from "@highstate/contract"
|
2
|
+
import { serverEntity } from "./common"
|
3
|
+
import { keyPairEntity } from "./ssh"
|
4
|
+
|
5
|
+
export const connectionEntity = defineEntity({
|
6
|
+
type: "timeweb.connection",
|
7
|
+
|
8
|
+
schema: Type.Object({
|
9
|
+
name: Type.String(),
|
10
|
+
apiToken: Type.String(),
|
11
|
+
}),
|
12
|
+
})
|
13
|
+
|
14
|
+
export const connection = defineUnit({
|
15
|
+
type: "timeweb.connection",
|
16
|
+
|
17
|
+
secrets: {
|
18
|
+
apiToken: Type.String(),
|
19
|
+
},
|
20
|
+
|
21
|
+
outputs: {
|
22
|
+
connection: connectionEntity,
|
23
|
+
},
|
24
|
+
|
25
|
+
meta: {
|
26
|
+
displayName: "Timeweb Connection",
|
27
|
+
description: "Creates a new Timeweb connection.",
|
28
|
+
primaryIcon: "material-symbols:cloud",
|
29
|
+
},
|
30
|
+
|
31
|
+
source: {
|
32
|
+
package: "@highstate/timeweb",
|
33
|
+
path: "connection",
|
34
|
+
},
|
35
|
+
})
|
36
|
+
|
37
|
+
export const virtualMachine = defineUnit({
|
38
|
+
type: "timeweb.virtual-machine",
|
39
|
+
|
40
|
+
args: {
|
41
|
+
presetId: Type.Optional(Type.Number()),
|
42
|
+
osId: Type.Optional(Type.Number()),
|
43
|
+
availabilityZone: Type.String(),
|
44
|
+
},
|
45
|
+
|
46
|
+
inputs: {
|
47
|
+
connection: connectionEntity,
|
48
|
+
sshKeyPair: {
|
49
|
+
entity: keyPairEntity,
|
50
|
+
required: false,
|
51
|
+
},
|
52
|
+
},
|
53
|
+
|
54
|
+
secrets: {
|
55
|
+
sshPrivateKey: Type.Optional(Type.String()),
|
56
|
+
},
|
57
|
+
|
58
|
+
outputs: {
|
59
|
+
server: serverEntity,
|
60
|
+
},
|
61
|
+
|
62
|
+
meta: {
|
63
|
+
displayName: "Timeweb Virtual Machine",
|
64
|
+
description: "Creates a new Timeweb virtual machine.",
|
65
|
+
primaryIcon: "material-symbols:cloud",
|
66
|
+
secondaryIcon: "codicon:vm",
|
67
|
+
},
|
68
|
+
|
69
|
+
source: {
|
70
|
+
package: "@highstate/timeweb",
|
71
|
+
path: "virtual-machine",
|
72
|
+
},
|
73
|
+
})
|