@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.
- package/dist/highstate.library.msgpack +0 -0
- package/dist/index.js +3548 -2985
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/common/access-point.ts +105 -0
- package/src/common/files.ts +137 -0
- package/src/common/index.ts +3 -0
- package/src/common/server.ts +231 -0
- package/src/databases/index.ts +4 -0
- package/src/databases/mariadb.ts +37 -0
- package/src/databases/mongodb.ts +37 -0
- package/src/databases/postgresql.ts +37 -0
- package/src/databases/shared.ts +61 -0
- package/src/distributions/ubuntu.ts +13 -11
- package/src/dns.ts +116 -18
- package/src/git.ts +14 -10
- package/src/impl-ref.ts +26 -0
- package/src/index.ts +14 -15
- package/src/k3s.ts +14 -12
- package/src/k8s/apps/code-server.ts +48 -0
- package/src/k8s/apps/gitea.ts +25 -0
- package/src/k8s/apps/grocy.ts +39 -0
- package/src/k8s/apps/hubble.ts +30 -0
- package/src/{apps → k8s/apps}/index.ts +16 -13
- package/src/k8s/apps/kubernetes-dashboard.ts +28 -0
- package/src/k8s/apps/mariadb.ts +83 -0
- package/src/k8s/apps/maybe.ts +39 -0
- package/src/k8s/apps/mongodb.ts +84 -0
- package/src/k8s/apps/postgresql.ts +86 -0
- package/src/k8s/apps/shared.ts +149 -0
- package/src/k8s/apps/syncthing.ts +72 -0
- package/src/k8s/apps/traefik.ts +40 -0
- package/src/k8s/apps/vaultwarden.ts +31 -0
- package/src/k8s/apps/workload.ts +214 -0
- package/src/k8s/apps/zitadel.ts +26 -0
- package/src/k8s/cert-manager.ts +80 -0
- package/src/k8s/cilium.ts +64 -0
- package/src/k8s/gateway.ts +70 -0
- package/src/k8s/index.ts +9 -0
- package/src/{obfuscators → k8s/obfuscators}/phantun.ts +14 -10
- package/src/{obfuscators → k8s/obfuscators}/shared.ts +17 -11
- package/src/k8s/resources.ts +111 -0
- package/src/k8s/service.ts +65 -0
- package/src/k8s/shared.ts +343 -0
- package/src/k8s/workload.ts +77 -0
- package/src/network.ts +249 -63
- package/src/nixos.ts +38 -77
- package/src/proxmox.ts +203 -96
- package/src/restic.ts +28 -19
- package/src/sops.ts +19 -8
- package/src/ssh.ts +122 -24
- package/src/talos.ts +21 -19
- package/src/third-party/cloudflare.ts +59 -0
- package/src/third-party/index.ts +3 -0
- package/src/{mullvad.ts → third-party/mullvad.ts} +11 -9
- package/src/third-party/timeweb.ts +99 -0
- package/src/utils.ts +27 -6
- package/src/wireguard.ts +249 -115
- package/src/apps/code-server.ts +0 -34
- package/src/apps/deployment.ts +0 -60
- package/src/apps/dns.ts +0 -107
- package/src/apps/gitea.ts +0 -18
- package/src/apps/grocy.ts +0 -20
- package/src/apps/hubble.ts +0 -20
- package/src/apps/kubernetes-dashboard.ts +0 -19
- package/src/apps/mariadb.ts +0 -81
- package/src/apps/maybe.ts +0 -25
- package/src/apps/mongodb.ts +0 -81
- package/src/apps/network.ts +0 -55
- package/src/apps/postgresql.ts +0 -81
- package/src/apps/shared.ts +0 -290
- package/src/apps/syncthing.ts +0 -54
- package/src/apps/test.ts +0 -19
- package/src/apps/traefik.ts +0 -36
- package/src/apps/vaultwarden.ts +0 -23
- package/src/apps/zitadel.ts +0 -21
- package/src/cloudflare.ts +0 -26
- package/src/common.ts +0 -200
- package/src/files.ts +0 -146
- package/src/k8s.ts +0 -638
- package/src/timeweb.ts +0 -75
- package/src/{obfuscators → k8s/obfuscators}/index.ts +1 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@highstate/library",
|
3
|
-
"version": "0.9.
|
3
|
+
"version": "0.9.19",
|
4
4
|
"type": "module",
|
5
5
|
"highstate": {
|
6
6
|
"type": "library"
|
@@ -22,12 +22,12 @@
|
|
22
22
|
"build": "highstate build"
|
23
23
|
},
|
24
24
|
"dependencies": {
|
25
|
-
"@highstate/contract": "^0.9.
|
26
|
-
"@sinclair/typebox": "^0.34.11",
|
25
|
+
"@highstate/contract": "^0.9.19",
|
27
26
|
"remeda": "^2.21.0"
|
28
27
|
},
|
29
28
|
"devDependencies": {
|
30
|
-
"@highstate/cli": "^0.9.
|
29
|
+
"@highstate/cli": "^0.9.19",
|
30
|
+
"type-fest": "^4.41.0"
|
31
31
|
},
|
32
|
-
"gitHead": "
|
32
|
+
"gitHead": "e77d292335556c6e5b6275acda1a3d1609d786a1"
|
33
33
|
}
|
@@ -0,0 +1,105 @@
|
|
1
|
+
import { defineEntity, defineUnit, z } from "@highstate/contract"
|
2
|
+
import * as dns from "../dns"
|
3
|
+
import { implementationReferenceSchema } from "../impl-ref"
|
4
|
+
|
5
|
+
export const gatewayEntity = defineEntity({
|
6
|
+
type: "common.gateway.v1",
|
7
|
+
|
8
|
+
schema: z.object({
|
9
|
+
/**
|
10
|
+
* The reference to the implementation of the gateway.
|
11
|
+
*/
|
12
|
+
implRef: implementationReferenceSchema,
|
13
|
+
}),
|
14
|
+
|
15
|
+
meta: {
|
16
|
+
color: "#F57F17",
|
17
|
+
},
|
18
|
+
})
|
19
|
+
|
20
|
+
export const tlsIssuerEntity = defineEntity({
|
21
|
+
type: "common.tls-issuer.v1",
|
22
|
+
|
23
|
+
schema: z.object({
|
24
|
+
/**
|
25
|
+
* The domain apex for which the TLS issuer will manage certificates.
|
26
|
+
*/
|
27
|
+
domain: z.string(),
|
28
|
+
|
29
|
+
/**
|
30
|
+
* The reference to the implementation of the TLS issuer.
|
31
|
+
*/
|
32
|
+
implRef: implementationReferenceSchema,
|
33
|
+
}),
|
34
|
+
|
35
|
+
meta: {
|
36
|
+
color: "#F57F17",
|
37
|
+
},
|
38
|
+
})
|
39
|
+
|
40
|
+
export const accessPointEntity = defineEntity({
|
41
|
+
type: "common.access-point.v1",
|
42
|
+
|
43
|
+
schema: z.object({
|
44
|
+
/**
|
45
|
+
* The gateway of the access point.
|
46
|
+
*/
|
47
|
+
gateway: gatewayEntity.schema,
|
48
|
+
|
49
|
+
/**
|
50
|
+
* The TLS issuers used to manage TLS certificates for the access point.
|
51
|
+
*/
|
52
|
+
tlsIssuers: tlsIssuerEntity.schema.array(),
|
53
|
+
|
54
|
+
/**
|
55
|
+
* The DNS providers used to manage the DNS records for the access point.
|
56
|
+
*/
|
57
|
+
dnsProviders: dns.providerEntity.schema.array(),
|
58
|
+
}),
|
59
|
+
|
60
|
+
meta: {
|
61
|
+
color: "#F57F17",
|
62
|
+
},
|
63
|
+
})
|
64
|
+
|
65
|
+
/**
|
66
|
+
* The access point unit which can be used to connect to services.
|
67
|
+
*
|
68
|
+
* It can be used to expose services and applications running in Kubernetes clusters or other environments.
|
69
|
+
*/
|
70
|
+
export const accessPoint = defineUnit({
|
71
|
+
type: "common.access-point.v1",
|
72
|
+
|
73
|
+
inputs: {
|
74
|
+
gateway: gatewayEntity,
|
75
|
+
tlsIssuers: {
|
76
|
+
entity: tlsIssuerEntity,
|
77
|
+
required: false,
|
78
|
+
multiple: true,
|
79
|
+
},
|
80
|
+
dnsProviders: {
|
81
|
+
entity: dns.providerEntity,
|
82
|
+
required: false,
|
83
|
+
multiple: true,
|
84
|
+
},
|
85
|
+
},
|
86
|
+
|
87
|
+
outputs: {
|
88
|
+
accessPoint: accessPointEntity,
|
89
|
+
},
|
90
|
+
|
91
|
+
meta: {
|
92
|
+
title: "Access Point",
|
93
|
+
icon: "mdi:access-point",
|
94
|
+
category: "Kubernetes",
|
95
|
+
},
|
96
|
+
|
97
|
+
source: {
|
98
|
+
package: "@highstate/common",
|
99
|
+
path: "units/access-point",
|
100
|
+
},
|
101
|
+
})
|
102
|
+
|
103
|
+
export type Gateway = z.infer<typeof gatewayEntity.schema>
|
104
|
+
export type AccessPoint = z.infer<typeof accessPointEntity.schema>
|
105
|
+
export type TlsIssuer = z.infer<typeof tlsIssuerEntity.schema>
|
@@ -0,0 +1,137 @@
|
|
1
|
+
import {
|
2
|
+
fileContentSchema as baseFileContentSchema,
|
3
|
+
fileMetaSchema as baseFileMetaSchema,
|
4
|
+
defineEntity,
|
5
|
+
defineUnit,
|
6
|
+
unitArtifactSchema,
|
7
|
+
z,
|
8
|
+
} from "@highstate/contract"
|
9
|
+
import { l7EndpointEntity } from "../network"
|
10
|
+
|
11
|
+
export const checksumAlgorithmSchema = z.enum(["md5", "sha1", "sha256", "sha384", "sha512"])
|
12
|
+
|
13
|
+
export const checksumSchema = z.object({
|
14
|
+
algorithm: checksumAlgorithmSchema,
|
15
|
+
value: z.string(),
|
16
|
+
})
|
17
|
+
|
18
|
+
export const fileContentSchema = z.union([
|
19
|
+
baseFileContentSchema,
|
20
|
+
z.object({
|
21
|
+
type: z.literal("local"),
|
22
|
+
path: z.string(),
|
23
|
+
}),
|
24
|
+
z.object({
|
25
|
+
type: z.literal("remote"),
|
26
|
+
endpoint: l7EndpointEntity.schema,
|
27
|
+
checksum: checksumSchema.optional(),
|
28
|
+
}),
|
29
|
+
])
|
30
|
+
|
31
|
+
export const fileEntity = defineEntity({
|
32
|
+
type: "common.file.v1",
|
33
|
+
|
34
|
+
schema: z.object({
|
35
|
+
meta: baseFileMetaSchema,
|
36
|
+
content: fileContentSchema,
|
37
|
+
}),
|
38
|
+
|
39
|
+
meta: {
|
40
|
+
color: "#FF5722",
|
41
|
+
},
|
42
|
+
})
|
43
|
+
|
44
|
+
export const folderMetaSchema = z.object({
|
45
|
+
name: z.string(),
|
46
|
+
mode: z.number().optional(),
|
47
|
+
})
|
48
|
+
|
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
|
+
])
|
75
|
+
|
76
|
+
export const folderEntity = defineEntity({
|
77
|
+
type: "common.folder.v1",
|
78
|
+
|
79
|
+
schema: z.object({
|
80
|
+
meta: folderMetaSchema,
|
81
|
+
content: folderContentSchema,
|
82
|
+
}),
|
83
|
+
|
84
|
+
meta: {
|
85
|
+
color: "#FF9800",
|
86
|
+
},
|
87
|
+
})
|
88
|
+
|
89
|
+
/**
|
90
|
+
* References a file from a remote URL.
|
91
|
+
*/
|
92
|
+
export const remoteFile = defineUnit({
|
93
|
+
type: "common.remote-file.v1",
|
94
|
+
|
95
|
+
args: {
|
96
|
+
/**
|
97
|
+
* The URL of the remote file.
|
98
|
+
*/
|
99
|
+
url: z.string().optional(),
|
100
|
+
},
|
101
|
+
|
102
|
+
inputs: {
|
103
|
+
/**
|
104
|
+
* The L7 endpoint of the remote file.
|
105
|
+
*/
|
106
|
+
endpoint: {
|
107
|
+
entity: l7EndpointEntity,
|
108
|
+
required: false,
|
109
|
+
},
|
110
|
+
},
|
111
|
+
|
112
|
+
outputs: {
|
113
|
+
file: fileEntity,
|
114
|
+
},
|
115
|
+
|
116
|
+
meta: {
|
117
|
+
title: "Remote File",
|
118
|
+
icon: "mdi:file-download",
|
119
|
+
category: "Files",
|
120
|
+
},
|
121
|
+
|
122
|
+
source: {
|
123
|
+
package: "@highstate/common",
|
124
|
+
path: "units/remote-file",
|
125
|
+
},
|
126
|
+
})
|
127
|
+
|
128
|
+
export type File = z.infer<typeof fileEntity.schema>
|
129
|
+
export type FileMeta = z.infer<typeof baseFileMetaSchema>
|
130
|
+
export type FileContent = z.infer<typeof fileContentSchema>
|
131
|
+
|
132
|
+
export type Folder = z.infer<typeof folderEntity.schema>
|
133
|
+
export type FolderMeta = z.infer<typeof folderMetaSchema>
|
134
|
+
export type FolderContent = z.infer<typeof folderContentSchema>
|
135
|
+
|
136
|
+
export type Checksum = z.infer<typeof checksumSchema>
|
137
|
+
export type ChecksumAlgorithm = z.infer<typeof checksumAlgorithmSchema>
|
@@ -0,0 +1,231 @@
|
|
1
|
+
import { $outputs, $secrets, defineEntity, defineUnit, z } from "@highstate/contract"
|
2
|
+
import * as dns from "../dns"
|
3
|
+
import { l3EndpointEntity } from "../network"
|
4
|
+
import * as ssh from "../ssh"
|
5
|
+
import { arrayPatchModeSchema } from "../utils"
|
6
|
+
|
7
|
+
/**
|
8
|
+
* The server entity represents a server with its hostname, endpoints, and optional SSH configuration.
|
9
|
+
*
|
10
|
+
* The OS of the server is not specified (but in most cases it will one of the Linux distributions).
|
11
|
+
*
|
12
|
+
* In fact, anything that have hostname (which can be any string) and L3 endpoints can be represented by this entity.
|
13
|
+
*/
|
14
|
+
export const serverEntity = defineEntity({
|
15
|
+
type: "common.server.v1",
|
16
|
+
|
17
|
+
schema: z.object({
|
18
|
+
hostname: z.string(),
|
19
|
+
endpoints: l3EndpointEntity.schema.array(),
|
20
|
+
ssh: ssh.connectionSchema.optional(),
|
21
|
+
}),
|
22
|
+
|
23
|
+
meta: {
|
24
|
+
color: "#009688",
|
25
|
+
},
|
26
|
+
})
|
27
|
+
|
28
|
+
/**
|
29
|
+
* The common outputs for units which create or modify a server.
|
30
|
+
*/
|
31
|
+
export const serverOutputs = $outputs({
|
32
|
+
/**
|
33
|
+
* The server entity representing the server.
|
34
|
+
*/
|
35
|
+
server: serverEntity,
|
36
|
+
|
37
|
+
/**
|
38
|
+
* The L3 endpoints of the server.
|
39
|
+
*/
|
40
|
+
endpoints: {
|
41
|
+
entity: l3EndpointEntity,
|
42
|
+
multiple: true,
|
43
|
+
},
|
44
|
+
})
|
45
|
+
|
46
|
+
export const vmSshArgs = ssh.argsSchema.omit({ user: true }).prefault({})
|
47
|
+
|
48
|
+
export const vmSecrets = $secrets({
|
49
|
+
/**
|
50
|
+
* The root password for the virtual machine.
|
51
|
+
*
|
52
|
+
* If not specified, will be generated automatically.
|
53
|
+
*/
|
54
|
+
rootPassword: z.string().optional(),
|
55
|
+
|
56
|
+
/**
|
57
|
+
* The SSH private for the `root` user of the virtual machine in PEM format.
|
58
|
+
*
|
59
|
+
* If not specified or provided via `keyPair`, will be generated automatically.
|
60
|
+
*/
|
61
|
+
sshPrivateKey: ssh.secrets.sshPrivateKey,
|
62
|
+
})
|
63
|
+
|
64
|
+
/**
|
65
|
+
* The existing server created outside of the Highstate.
|
66
|
+
*/
|
67
|
+
export const existingServer = defineUnit({
|
68
|
+
type: "common.existing-server.v1",
|
69
|
+
|
70
|
+
args: {
|
71
|
+
/**
|
72
|
+
* The endpoint of the server.
|
73
|
+
*
|
74
|
+
* Takes precedence over the `endpoint` input.
|
75
|
+
*/
|
76
|
+
endpoint: z.string().optional(),
|
77
|
+
|
78
|
+
/**
|
79
|
+
* The SSH confuguration for the server.
|
80
|
+
*/
|
81
|
+
ssh: ssh.argsSchema.prefault({}),
|
82
|
+
},
|
83
|
+
|
84
|
+
secrets: {
|
85
|
+
...ssh.secrets,
|
86
|
+
},
|
87
|
+
|
88
|
+
inputs: {
|
89
|
+
endpoint: {
|
90
|
+
entity: l3EndpointEntity,
|
91
|
+
required: false,
|
92
|
+
},
|
93
|
+
|
94
|
+
...ssh.inputs,
|
95
|
+
},
|
96
|
+
|
97
|
+
outputs: serverOutputs,
|
98
|
+
|
99
|
+
meta: {
|
100
|
+
title: "Existing Server",
|
101
|
+
icon: "mdi:server",
|
102
|
+
defaultNamePrefix: "server",
|
103
|
+
category: "Infrastructure",
|
104
|
+
},
|
105
|
+
|
106
|
+
source: {
|
107
|
+
package: "@highstate/common",
|
108
|
+
path: "units/existing-server",
|
109
|
+
},
|
110
|
+
})
|
111
|
+
|
112
|
+
/**
|
113
|
+
* Patches some properties of the server and outputs the updated server.
|
114
|
+
*/
|
115
|
+
export const serverPatch = defineUnit({
|
116
|
+
type: "common.server-patch.v1",
|
117
|
+
|
118
|
+
args: {
|
119
|
+
/**
|
120
|
+
* The endpoints of the server.
|
121
|
+
*
|
122
|
+
* The entry may represent real node endpoint or virtual endpoint (like a load balancer).
|
123
|
+
*
|
124
|
+
* The same server may also be represented by multiple entries (e.g. a node with private and public IP).
|
125
|
+
*/
|
126
|
+
endpoints: z.string().array().default([]),
|
127
|
+
|
128
|
+
/**
|
129
|
+
* The mode to use for patching the endpoints.
|
130
|
+
*
|
131
|
+
* - `prepend`: prepend the new endpoints to the existing ones (default);
|
132
|
+
* - `replace`: replace the existing endpoints with the new ones.
|
133
|
+
*/
|
134
|
+
endpointsPatchMode: arrayPatchModeSchema.default("prepend"),
|
135
|
+
},
|
136
|
+
|
137
|
+
inputs: {
|
138
|
+
server: serverEntity,
|
139
|
+
endpoints: {
|
140
|
+
entity: l3EndpointEntity,
|
141
|
+
required: false,
|
142
|
+
multiple: true,
|
143
|
+
},
|
144
|
+
},
|
145
|
+
|
146
|
+
outputs: {
|
147
|
+
...serverOutputs,
|
148
|
+
},
|
149
|
+
|
150
|
+
meta: {
|
151
|
+
title: "Server Patch",
|
152
|
+
icon: "mdi:server",
|
153
|
+
secondaryIcon: "fluent:patch-20-filled",
|
154
|
+
category: "Infrastructure",
|
155
|
+
},
|
156
|
+
|
157
|
+
source: {
|
158
|
+
package: "@highstate/common",
|
159
|
+
path: "units/server-patch",
|
160
|
+
},
|
161
|
+
})
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Creates a DNS record for the server and updates the endpoints.
|
165
|
+
*
|
166
|
+
* The DNS record will be created with the provided FQDN and the endpoints will be updated with the DNS record.
|
167
|
+
*/
|
168
|
+
export const serverDns = defineUnit({
|
169
|
+
type: "common.server-dns.v1",
|
170
|
+
|
171
|
+
args: dns.createArgs(),
|
172
|
+
|
173
|
+
inputs: {
|
174
|
+
server: serverEntity,
|
175
|
+
...dns.inputs,
|
176
|
+
},
|
177
|
+
|
178
|
+
outputs: {
|
179
|
+
server: serverEntity,
|
180
|
+
endpoints: {
|
181
|
+
entity: l3EndpointEntity,
|
182
|
+
multiple: true,
|
183
|
+
},
|
184
|
+
},
|
185
|
+
|
186
|
+
meta: {
|
187
|
+
title: "Server DNS",
|
188
|
+
icon: "mdi:server",
|
189
|
+
secondaryIcon: "mdi:dns",
|
190
|
+
category: "Infrastructure",
|
191
|
+
},
|
192
|
+
|
193
|
+
source: {
|
194
|
+
package: "@highstate/common",
|
195
|
+
path: "units/server-dns",
|
196
|
+
},
|
197
|
+
})
|
198
|
+
|
199
|
+
/**
|
200
|
+
* Runs a shell script on the server.
|
201
|
+
*/
|
202
|
+
export const script = defineUnit({
|
203
|
+
type: "common.script.v1",
|
204
|
+
|
205
|
+
args: {
|
206
|
+
script: z.string().meta({ language: "shell" }),
|
207
|
+
updateScript: z.string().optional().meta({ language: "shell" }),
|
208
|
+
deleteScript: z.string().optional().meta({ language: "shell" }),
|
209
|
+
},
|
210
|
+
|
211
|
+
inputs: {
|
212
|
+
server: serverEntity,
|
213
|
+
},
|
214
|
+
|
215
|
+
outputs: {
|
216
|
+
server: serverEntity,
|
217
|
+
},
|
218
|
+
|
219
|
+
meta: {
|
220
|
+
title: "Shell Script",
|
221
|
+
icon: "mdi:bash",
|
222
|
+
category: "Infrastructure",
|
223
|
+
},
|
224
|
+
|
225
|
+
source: {
|
226
|
+
package: "@highstate/common",
|
227
|
+
path: "units/script",
|
228
|
+
},
|
229
|
+
})
|
230
|
+
|
231
|
+
export type Server = z.infer<typeof serverEntity.schema>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { defineEntity, defineUnit, type z } from "@highstate/contract"
|
2
|
+
import { sharedArgs, sharedInputs, sharedSchema, sharedSecrets } from "./shared"
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Represents the MariaDB database or virtual database behind it.
|
6
|
+
*/
|
7
|
+
export const mariadbEntity = defineEntity({
|
8
|
+
type: "databases.mariadb.v1",
|
9
|
+
|
10
|
+
schema: sharedSchema,
|
11
|
+
|
12
|
+
meta: {
|
13
|
+
color: "#f06292",
|
14
|
+
},
|
15
|
+
})
|
16
|
+
|
17
|
+
/**
|
18
|
+
* The existing MariaDB database or virtual database behind it.
|
19
|
+
*/
|
20
|
+
export const existingMariadb = defineUnit({
|
21
|
+
type: "databases.mariadb.existing.v1",
|
22
|
+
|
23
|
+
args: sharedArgs,
|
24
|
+
secrets: sharedSecrets,
|
25
|
+
inputs: sharedInputs,
|
26
|
+
|
27
|
+
outputs: {
|
28
|
+
mariadb: mariadbEntity,
|
29
|
+
},
|
30
|
+
|
31
|
+
source: {
|
32
|
+
package: "@highstate/common",
|
33
|
+
path: "databases/existing-mariadb",
|
34
|
+
},
|
35
|
+
})
|
36
|
+
|
37
|
+
export type MariaDB = z.infer<typeof mariadbEntity.schema>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { defineEntity, defineUnit, type z } from "@highstate/contract"
|
2
|
+
import { sharedArgs, sharedInputs, sharedSchema, sharedSecrets } from "./shared"
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Represents the MongoDB database or virtual database behind it.
|
6
|
+
*/
|
7
|
+
export const mongodbEntity = defineEntity({
|
8
|
+
type: "databases.mongodb.v1",
|
9
|
+
|
10
|
+
schema: sharedSchema,
|
11
|
+
|
12
|
+
meta: {
|
13
|
+
color: "#13aa52",
|
14
|
+
},
|
15
|
+
})
|
16
|
+
|
17
|
+
/**
|
18
|
+
* The existing MongoDB database or virtual database behind it.
|
19
|
+
*/
|
20
|
+
export const existingMongodb = defineUnit({
|
21
|
+
type: "databases.mongodb.existing.v1",
|
22
|
+
|
23
|
+
args: sharedArgs,
|
24
|
+
secrets: sharedSecrets,
|
25
|
+
inputs: sharedInputs,
|
26
|
+
|
27
|
+
outputs: {
|
28
|
+
mongodb: mongodbEntity,
|
29
|
+
},
|
30
|
+
|
31
|
+
source: {
|
32
|
+
package: "@highstate/common",
|
33
|
+
path: "databases/existing-mongodb",
|
34
|
+
},
|
35
|
+
})
|
36
|
+
|
37
|
+
export type MongoDB = z.infer<typeof mongodbEntity.schema>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { defineEntity, defineUnit, type z } from "@highstate/contract"
|
2
|
+
import { sharedArgs, sharedInputs, sharedSchema, sharedSecrets } from "./shared"
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Represents the PostgreSQL database or virtual database behind it.
|
6
|
+
*/
|
7
|
+
export const postgresqlEntity = defineEntity({
|
8
|
+
type: "databases.postgresql.v1",
|
9
|
+
|
10
|
+
schema: sharedSchema,
|
11
|
+
|
12
|
+
meta: {
|
13
|
+
color: "#336791",
|
14
|
+
},
|
15
|
+
})
|
16
|
+
|
17
|
+
/**
|
18
|
+
* The existing PostgreSQL database or virtual database behind it.
|
19
|
+
*/
|
20
|
+
export const existingPostgresql = defineUnit({
|
21
|
+
type: "databases.postgresql.existing.v1",
|
22
|
+
|
23
|
+
args: sharedArgs,
|
24
|
+
secrets: sharedSecrets,
|
25
|
+
inputs: sharedInputs,
|
26
|
+
|
27
|
+
outputs: {
|
28
|
+
postgresql: postgresqlEntity,
|
29
|
+
},
|
30
|
+
|
31
|
+
source: {
|
32
|
+
package: "@highstate/common",
|
33
|
+
path: "databases/existing-postgresql",
|
34
|
+
},
|
35
|
+
})
|
36
|
+
|
37
|
+
export type PostgreSQL = z.infer<typeof postgresqlEntity.schema>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { $args, $inputs, $secrets, z } from "@highstate/contract"
|
2
|
+
import { l4EndpointEntity } from "../network"
|
3
|
+
|
4
|
+
export const sharedSchema = z.object({
|
5
|
+
/**
|
6
|
+
* The endpoints to connect to the database.
|
7
|
+
*/
|
8
|
+
endpoints: l4EndpointEntity.schema.array(),
|
9
|
+
|
10
|
+
/**
|
11
|
+
* The username to connect to the database with.
|
12
|
+
*/
|
13
|
+
username: z.string(),
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The password to connect to the database with.
|
17
|
+
*/
|
18
|
+
password: z.string().optional(),
|
19
|
+
|
20
|
+
/**
|
21
|
+
* The name of the database to connect to.
|
22
|
+
*/
|
23
|
+
database: z.string().optional(),
|
24
|
+
})
|
25
|
+
|
26
|
+
export const sharedArgs = $args({
|
27
|
+
/**
|
28
|
+
* The endpoints to connect to the database in form of `host:port`.
|
29
|
+
*/
|
30
|
+
endpoints: z.string().array().min(1),
|
31
|
+
|
32
|
+
/**
|
33
|
+
* The username to connect to the database with.
|
34
|
+
*
|
35
|
+
* If not provided, defaults to `root`.
|
36
|
+
*/
|
37
|
+
username: z.string().default("root"),
|
38
|
+
|
39
|
+
/**
|
40
|
+
* The name of the database to connect to.
|
41
|
+
*/
|
42
|
+
database: z.string().optional(),
|
43
|
+
})
|
44
|
+
|
45
|
+
export const sharedSecrets = $secrets({
|
46
|
+
/**
|
47
|
+
* The password to connect to the database with.
|
48
|
+
*/
|
49
|
+
password: z.string().optional(),
|
50
|
+
})
|
51
|
+
|
52
|
+
export const sharedInputs = $inputs({
|
53
|
+
/**
|
54
|
+
* The endpoints to connect to the database.
|
55
|
+
*/
|
56
|
+
endpoints: {
|
57
|
+
entity: l4EndpointEntity,
|
58
|
+
multiple: true,
|
59
|
+
required: false,
|
60
|
+
},
|
61
|
+
})
|