@highstate/library 0.9.18 → 0.9.20

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 (79) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +3684 -3126
  3. package/dist/index.js.map +1 -1
  4. package/package.json +5 -4
  5. package/src/common/access-point.ts +105 -0
  6. package/src/{files.ts → common/files.ts} +10 -8
  7. package/src/common/index.ts +3 -0
  8. package/src/{common.ts → common/server.ts} +69 -38
  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 +6 -4
  15. package/src/dns.ts +110 -12
  16. package/src/git.ts +7 -3
  17. package/src/impl-ref.ts +26 -0
  18. package/src/index.ts +14 -15
  19. package/src/k3s.ts +7 -5
  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/{apps → k8s/apps}/syncthing.ts +27 -9
  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 +10 -6
  41. package/src/{obfuscators → k8s/obfuscators}/shared.ts +11 -5
  42. package/src/k8s/resources.ts +111 -0
  43. package/src/k8s/service.ts +65 -0
  44. package/src/{k8s.ts → k8s/shared.ts} +35 -329
  45. package/src/k8s/workload.ts +77 -0
  46. package/src/network.ts +208 -22
  47. package/src/nixos.ts +23 -8
  48. package/src/proxmox.ts +62 -75
  49. package/src/restic.ts +15 -6
  50. package/src/sops.ts +16 -5
  51. package/src/ssh.ts +107 -9
  52. package/src/talos.ts +6 -4
  53. package/src/third-party/cloudflare.ts +59 -0
  54. package/src/third-party/index.ts +4 -0
  55. package/src/{mullvad.ts → third-party/mullvad.ts} +6 -4
  56. package/src/third-party/timeweb.ts +99 -0
  57. package/src/third-party/yandex.ts +211 -0
  58. package/src/utils.ts +24 -3
  59. package/src/wireguard.ts +171 -48
  60. package/src/apps/code-server.ts +0 -34
  61. package/src/apps/deployment.ts +0 -60
  62. package/src/apps/dns.ts +0 -107
  63. package/src/apps/gitea.ts +0 -18
  64. package/src/apps/grocy.ts +0 -20
  65. package/src/apps/hubble.ts +0 -20
  66. package/src/apps/kubernetes-dashboard.ts +0 -19
  67. package/src/apps/mariadb.ts +0 -81
  68. package/src/apps/maybe.ts +0 -25
  69. package/src/apps/mongodb.ts +0 -81
  70. package/src/apps/network.ts +0 -55
  71. package/src/apps/postgresql.ts +0 -81
  72. package/src/apps/shared.ts +0 -289
  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/timeweb.ts +0 -75
  79. package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
@@ -1,289 +0,0 @@
1
- import type { mariadbEntity } from "./mariadb"
2
- import type { postgresqlEntity } from "./postgresql"
3
- import type { mongodbEntity } from "./mongodb"
4
- import { z } from "@highstate/contract"
5
- import {
6
- accessPointEntity,
7
- clusterEntity,
8
- persistentVolumeClaimEntity,
9
- serviceEntity,
10
- } from "../k8s"
11
- import { repositoryEntity } from "../restic"
12
- import { providerEntity } from "../dns"
13
- import { l4EndpointEntity } from "../network"
14
-
15
- const extraArgsDefinitions = {
16
- fqdn: {
17
- schema: z.string(),
18
- },
19
- endpoints: {
20
- schema: z.string().array(),
21
- required: false,
22
- },
23
- external: {
24
- schema: z.boolean(),
25
- required: false,
26
- },
27
- } as const
28
-
29
- const extraSecretsDefinitions = {
30
- rootPassword: {
31
- schema: z.string(),
32
- required: false,
33
- },
34
- backupPassword: {
35
- schema: z.string(),
36
- required: false,
37
- },
38
- }
39
-
40
- type LazyExtraInputDefinitions = {
41
- mariadb: {
42
- entity: typeof mariadbEntity
43
- title: "MariaDB"
44
- }
45
- postgresql: {
46
- entity: typeof postgresqlEntity
47
- title: "PostgreSQL"
48
- }
49
- mongodb: {
50
- entity: typeof mongodbEntity
51
- title: "MongoDB"
52
- }
53
- }
54
-
55
- const eagerExtraInputDefinitions = {
56
- accessPoint: {
57
- entity: accessPointEntity,
58
- },
59
- resticRepo: {
60
- entity: repositoryEntity,
61
- required: false,
62
- },
63
- dnsProviders: {
64
- entity: providerEntity,
65
- required: false,
66
- multiple: true,
67
- },
68
- volume: {
69
- entity: persistentVolumeClaimEntity,
70
- required: false,
71
- },
72
- } as const
73
-
74
- export const extraInputDefinitions = {
75
- ...eagerExtraInputDefinitions,
76
- } as typeof eagerExtraInputDefinitions & LazyExtraInputDefinitions
77
-
78
- type ExtraArgsDefinitions = typeof extraArgsDefinitions
79
- type ExtraSecretsDefinitions = typeof extraSecretsDefinitions
80
- type ExtraArgsName = keyof ExtraArgsDefinitions
81
- type ExtraSecretsName = keyof ExtraSecretsDefinitions
82
-
83
- type CreateArgsOptions<R extends readonly ExtraArgsName[], O extends readonly ExtraArgsName[]> = {
84
- required?: R
85
- optional?: O
86
- }
87
-
88
- type CreateSecretsOptions<
89
- R extends readonly ExtraSecretsName[],
90
- O extends readonly ExtraSecretsName[],
91
- > = {
92
- required?: R
93
- optional?: O
94
- }
95
-
96
- export function createArgs<T extends readonly ExtraArgsName[] = []>(
97
- defaultAppName: string,
98
- extraArgs?: T,
99
- ): {
100
- appName: z.ZodDefault<z.ZodString>
101
- } & {
102
- [K in T[number]]: ExtraArgsDefinitions[K]
103
- }
104
-
105
- export function createArgs<
106
- R extends readonly ExtraArgsName[] = [],
107
- O extends readonly ExtraArgsName[] = [],
108
- >(
109
- defaultAppName: string,
110
- extraArgs?: CreateArgsOptions<R, O>,
111
- ): {
112
- appName: z.ZodDefault<z.ZodString>
113
- } & {
114
- [K in R[number]]: ExtraArgsDefinitions[K] & { required: true }
115
- } & {
116
- [K in O[number]]: ExtraArgsDefinitions[K] & { required: false }
117
- }
118
-
119
- export function createArgs<
120
- R extends readonly ExtraArgsName[] = [],
121
- O extends readonly ExtraArgsName[] = [],
122
- >(defaultAppName: string, extraArgs?: readonly ExtraArgsName[] | CreateArgsOptions<R, O>) {
123
- const base = {
124
- appName: z.string().default(defaultAppName),
125
- }
126
-
127
- const dynamicArgs: Partial<Record<ExtraArgsName, object>> = {}
128
-
129
- if (Array.isArray(extraArgs)) {
130
- for (const name of extraArgs as readonly ExtraArgsName[]) {
131
- dynamicArgs[name] = extraArgsDefinitions[name]
132
- }
133
- } else {
134
- const { required, optional } = (extraArgs as CreateArgsOptions<R, O>) ?? {}
135
-
136
- for (const name of required ?? []) {
137
- dynamicArgs[name] = {
138
- ...extraArgsDefinitions[name],
139
- required: true,
140
- }
141
- }
142
-
143
- for (const name of optional ?? []) {
144
- dynamicArgs[name] = {
145
- ...extraArgsDefinitions[name],
146
- required: false,
147
- }
148
- }
149
- }
150
-
151
- return {
152
- ...base,
153
- ...dynamicArgs,
154
- }
155
- }
156
-
157
- export function createSecrets<T extends readonly ExtraSecretsName[] = []>(
158
- extraSecrets?: T,
159
- ): {
160
- [K in T[number]]: ExtraSecretsDefinitions[K]
161
- }
162
-
163
- export function createSecrets<
164
- R extends readonly ExtraSecretsName[] = [],
165
- O extends readonly ExtraSecretsName[] = [],
166
- >(
167
- extraSecrets?: CreateSecretsOptions<R, O>,
168
- ): {
169
- [K in R[number]]: ExtraSecretsDefinitions[K] & { required: true }
170
- } & {
171
- [K in O[number]]: ExtraSecretsDefinitions[K] & { required: false }
172
- }
173
-
174
- export function createSecrets<
175
- R extends readonly ExtraSecretsName[] = [],
176
- O extends readonly ExtraSecretsName[] = [],
177
- >(extraSecrets?: readonly ExtraSecretsName[] | CreateSecretsOptions<R, O>) {
178
- const dynamicSecrets: Partial<Record<ExtraSecretsName, object>> = {}
179
-
180
- if (Array.isArray(extraSecrets)) {
181
- for (const name of extraSecrets as readonly ExtraSecretsName[]) {
182
- dynamicSecrets[name] = extraSecretsDefinitions[name]
183
- }
184
- } else {
185
- const { required, optional } = (extraSecrets as CreateSecretsOptions<R, O>) ?? {}
186
-
187
- for (const name of required ?? []) {
188
- dynamicSecrets[name] = {
189
- ...extraSecretsDefinitions[name],
190
- required: true,
191
- }
192
- }
193
-
194
- for (const name of optional ?? []) {
195
- dynamicSecrets[name] = {
196
- ...extraSecretsDefinitions[name],
197
- required: false,
198
- }
199
- }
200
- }
201
-
202
- return dynamicSecrets as {
203
- [K in R[number]]: ExtraSecretsDefinitions[K] & { required: true }
204
- } & {
205
- [K in O[number]]: ExtraSecretsDefinitions[K] & { required: false }
206
- }
207
- }
208
-
209
- type ExtraInputDefinitions = typeof extraInputDefinitions
210
- type ExtraInputName = keyof ExtraInputDefinitions
211
-
212
- type CreateInputsOptions<
213
- R extends readonly ExtraInputName[],
214
- O extends readonly ExtraInputName[],
215
- > = {
216
- required?: R
217
- optional?: O
218
- }
219
-
220
- export function createInputs<T extends readonly ExtraInputName[] = []>(
221
- inputs?: T,
222
- ): {
223
- k8sCluster: typeof clusterEntity
224
- } & {
225
- [K in T[number]]: ExtraInputDefinitions[K]
226
- }
227
-
228
- export function createInputs<
229
- R extends readonly ExtraInputName[] = [],
230
- O extends readonly ExtraInputName[] = [],
231
- >(
232
- inputs?: CreateInputsOptions<R, O>,
233
- ): {
234
- k8sCluster: typeof clusterEntity
235
- } & {
236
- [K in R[number]]: ExtraInputDefinitions[K] & { required: true }
237
- } & {
238
- [K in O[number]]: ExtraInputDefinitions[K] & { required: false }
239
- }
240
-
241
- export function createInputs<
242
- R extends readonly ExtraInputName[] = [],
243
- O extends readonly ExtraInputName[] = [],
244
- >(inputs?: readonly ExtraInputName[] | CreateInputsOptions<R, O>) {
245
- const base = {
246
- k8sCluster: clusterEntity,
247
- }
248
-
249
- const dynamicInputs: Partial<Record<ExtraInputName, object>> = {}
250
-
251
- if (Array.isArray(inputs)) {
252
- for (const name of inputs as readonly ExtraInputName[]) {
253
- dynamicInputs[name] = extraInputDefinitions[name]
254
- }
255
- } else {
256
- const { required, optional } = (inputs as CreateInputsOptions<R, O>) ?? {}
257
-
258
- for (const name of required ?? []) {
259
- dynamicInputs[name] = {
260
- ...extraInputDefinitions[name],
261
- required: true,
262
- }
263
- }
264
- for (const name of optional ?? []) {
265
- dynamicInputs[name] = {
266
- ...extraInputDefinitions[name],
267
- required: false,
268
- }
269
- }
270
- }
271
-
272
- return {
273
- ...base,
274
- ...dynamicInputs,
275
- }
276
- }
277
-
278
- export function createSource(path: string) {
279
- return {
280
- package: "@highstate/apps",
281
- path,
282
- }
283
- }
284
-
285
- export const databaseSchema = z.object({
286
- endpoints: l4EndpointEntity.schema.array(),
287
- service: serviceEntity.schema.optional(),
288
- rootPassword: z.string(),
289
- })
package/src/apps/test.ts DELETED
@@ -1,19 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- import * as apps from "./mariadb"
3
-
4
- import type { InstanceInput } from "@highstate/contract"
5
-
6
- declare const cluster: InstanceInput<"k8s.cluster">
7
-
8
- const { mariadb, service } = apps.mariadb({
9
- name: "test",
10
- args: {
11
- external: true,
12
- },
13
- inputs: {
14
- k8sCluster: cluster,
15
- },
16
- })
17
-
18
- void mariadb
19
- void service
@@ -1,36 +0,0 @@
1
- import { defineUnit, z } from "@highstate/contract"
2
- import { gatewayEntity, serviceEntity } from "../k8s"
3
- import { l4EndpointEntity } from "../network"
4
- import { createArgs, createInputs } from "./shared"
5
-
6
- export const traefikGateway = defineUnit({
7
- type: "apps.traefik-gateway",
8
-
9
- args: {
10
- ...createArgs("traefik", ["external"]),
11
- className: z.string().optional(),
12
- },
13
-
14
- inputs: createInputs(),
15
-
16
- outputs: {
17
- gateway: gatewayEntity,
18
- service: serviceEntity,
19
- endpoints: {
20
- entity: l4EndpointEntity,
21
- multiple: true,
22
- },
23
- },
24
-
25
- meta: {
26
- title: "Traefik Gateway",
27
- description: "A Traefik gateway for routing traffic to services.",
28
- icon: "simple-icons:traefikproxy",
29
- category: "Network",
30
- },
31
-
32
- source: {
33
- package: "@highstate/apps",
34
- path: "traefik",
35
- },
36
- })
@@ -1,23 +0,0 @@
1
- import { defineUnit, z } from "@highstate/contract"
2
- import { createArgs, createInputs, createSource } from "./shared"
3
-
4
- export const vaultwarden = defineUnit({
5
- type: "apps.vaultwarden",
6
-
7
- args: createArgs("vaultwarden", ["fqdn"]),
8
-
9
- secrets: {
10
- mariadbPassword: z.string().optional(),
11
- },
12
-
13
- inputs: createInputs(["accessPoint", "mariadb"]),
14
-
15
- meta: {
16
- title: "Vaultwarden",
17
- description: "The Vaultwarden password manager deployed on Kubernetes.",
18
- icon: "simple-icons:vaultwarden",
19
- category: "Security",
20
- },
21
-
22
- source: createSource("vaultwarden"),
23
- })
@@ -1,21 +0,0 @@
1
- import { defineUnit } from "@highstate/contract"
2
- import { createArgs, createInputs } from "./shared"
3
-
4
- export const zitadel = defineUnit({
5
- type: "apps.zitadel",
6
-
7
- args: createArgs("zitadel", ["fqdn"]),
8
-
9
- inputs: createInputs(["accessPoint", "postgresql"]),
10
-
11
- meta: {
12
- title: "Zitadel",
13
- description: "The Zitadel IAM deployed on Kubernetes.",
14
- icon: "hugeicons:access",
15
- },
16
-
17
- source: {
18
- package: "@highstate/apps",
19
- path: "zitadel",
20
- },
21
- })
package/src/cloudflare.ts DELETED
@@ -1,26 +0,0 @@
1
- import { defineUnit, z } from "@highstate/contract"
2
- import { providerEntity } from "./dns"
3
-
4
- export const connection = defineUnit({
5
- type: "cloudflare.connection",
6
-
7
- secrets: {
8
- apiToken: z.string(),
9
- },
10
-
11
- outputs: {
12
- dnsProvider: providerEntity,
13
- },
14
-
15
- meta: {
16
- title: "Cloudflare Connection",
17
- description: "Creates a new Cloudflare connection for one zone.",
18
- icon: "simple-icons:cloudflare",
19
- category: "Cloudflare",
20
- },
21
-
22
- source: {
23
- package: "@highstate/cloudflare",
24
- path: "connection",
25
- },
26
- })
package/src/timeweb.ts DELETED
@@ -1,75 +0,0 @@
1
- import { defineEntity, defineUnit, z } 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: z.object({
9
- name: z.string(),
10
- apiToken: z.string(),
11
- }),
12
- })
13
-
14
- export const connection = defineUnit({
15
- type: "timeweb.connection",
16
-
17
- secrets: {
18
- apiToken: z.string(),
19
- },
20
-
21
- outputs: {
22
- connection: connectionEntity,
23
- },
24
-
25
- meta: {
26
- title: "Timeweb Connection",
27
- description: "Creates a new Timeweb connection.",
28
- icon: "material-symbols:cloud",
29
- category: "Timeweb",
30
- },
31
-
32
- source: {
33
- package: "@highstate/timeweb",
34
- path: "connection",
35
- },
36
- })
37
-
38
- export const virtualMachine = defineUnit({
39
- type: "timeweb.virtual-machine",
40
-
41
- args: {
42
- presetId: z.number().optional(),
43
- osId: z.number().optional(),
44
- availabilityZone: z.string(),
45
- },
46
-
47
- inputs: {
48
- connection: connectionEntity,
49
- sshKeyPair: {
50
- entity: keyPairEntity,
51
- required: false,
52
- },
53
- },
54
-
55
- secrets: {
56
- sshPrivateKey: z.string().optional(),
57
- },
58
-
59
- outputs: {
60
- server: serverEntity,
61
- },
62
-
63
- meta: {
64
- title: "Timeweb Virtual Machine",
65
- description: "Creates a new Timeweb virtual machine.",
66
- icon: "material-symbols:cloud",
67
- secondaryIcon: "codicon:vm",
68
- category: "Timeweb",
69
- },
70
-
71
- source: {
72
- package: "@highstate/timeweb",
73
- path: "virtual-machine",
74
- },
75
- })
@@ -1,2 +1,2 @@
1
- export * from "./shared"
2
1
  export * as phantun from "./phantun"
2
+ export * from "./shared"