@highstate/common 0.9.4 → 0.9.6

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 (48) hide show
  1. package/dist/chunk-USV6SHAU.js +530 -0
  2. package/dist/chunk-USV6SHAU.js.map +1 -0
  3. package/dist/highstate.manifest.json +9 -5
  4. package/dist/index.js +33 -7
  5. package/dist/units/dns/record-set/index.js +18 -0
  6. package/dist/units/dns/record-set/index.js.map +1 -0
  7. package/dist/units/existing-server/index.js +34 -0
  8. package/dist/units/existing-server/index.js.map +1 -0
  9. package/dist/units/network/l3-endpoint/index.js +15 -0
  10. package/dist/units/network/l3-endpoint/index.js.map +1 -0
  11. package/dist/units/network/l4-endpoint/index.js +15 -0
  12. package/dist/units/network/l4-endpoint/index.js.map +1 -0
  13. package/dist/{script → units/script}/index.js +5 -6
  14. package/dist/units/script/index.js.map +1 -0
  15. package/dist/units/server-dns/index.js +30 -0
  16. package/dist/units/server-dns/index.js.map +1 -0
  17. package/dist/units/server-patch/index.js +29 -0
  18. package/dist/units/server-patch/index.js.map +1 -0
  19. package/dist/units/ssh/key-pair/index.js +22 -0
  20. package/dist/units/ssh/key-pair/index.js.map +1 -0
  21. package/package.json +15 -10
  22. package/src/shared/command.ts +132 -0
  23. package/src/shared/dns.ts +209 -21
  24. package/src/shared/index.ts +2 -2
  25. package/src/shared/network.ts +311 -0
  26. package/src/shared/ssh.ts +111 -38
  27. package/src/units/dns/record-set/index.ts +16 -0
  28. package/src/units/existing-server/index.ts +34 -0
  29. package/src/units/network/l3-endpoint/index.ts +9 -0
  30. package/src/units/network/l4-endpoint/index.ts +9 -0
  31. package/src/{script → units/script}/index.ts +3 -5
  32. package/src/units/server-dns/index.ts +26 -0
  33. package/src/units/server-patch/index.ts +25 -0
  34. package/src/units/ssh/key-pair/index.ts +16 -0
  35. package/dist/chunk-ZA27FN5N.js +0 -214
  36. package/dist/chunk-ZA27FN5N.js.map +0 -1
  37. package/dist/dns/record/index.js +0 -1
  38. package/dist/dns/record/index.js.map +0 -1
  39. package/dist/existing-server/index.js +0 -48
  40. package/dist/existing-server/index.js.map +0 -1
  41. package/dist/script/index.js.map +0 -1
  42. package/dist/ssh/key-pair/index.js +0 -30
  43. package/dist/ssh/key-pair/index.js.map +0 -1
  44. package/src/dns/record/index.ts +0 -0
  45. package/src/existing-server/index.ts +0 -46
  46. package/src/shared/server.ts +0 -85
  47. package/src/shared/utils.ts +0 -18
  48. package/src/ssh/key-pair/index.ts +0 -24
@@ -1,30 +0,0 @@
1
- import {
2
- generatePrivateKey,
3
- getKeysFromString
4
- } from "../../chunk-ZA27FN5N.js";
5
-
6
- // src/ssh/key-pair/index.ts
7
- import { ssh } from "@highstate/library";
8
- import { forUnit, getOrCreateSecret, unsecret } from "@highstate/pulumi";
9
- var { secrets, outputs } = forUnit(ssh.keyPair);
10
- var privateKey = getOrCreateSecret(secrets, "privateKey", generatePrivateKey);
11
- var keys = privateKey.apply(getKeysFromString);
12
- var key_pair_default = outputs({
13
- keyPair: {
14
- type: "ed25519",
15
- privateKey: keys.privateKey,
16
- publicKey: unsecret(keys.publicKey)
17
- },
18
- $status: {
19
- fingerprint: {
20
- value: unsecret(keys.fingerprint)
21
- },
22
- publicKey: {
23
- value: unsecret(keys.publicKey)
24
- }
25
- }
26
- });
27
- export {
28
- key_pair_default as default
29
- };
30
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/ssh/key-pair/index.ts"],"sourcesContent":["import { ssh } from \"@highstate/library\"\nimport { forUnit, getOrCreateSecret, unsecret } from \"@highstate/pulumi\"\nimport { generatePrivateKey, getKeysFromString } from \"../../shared\"\n\nconst { secrets, outputs } = forUnit(ssh.keyPair)\n\nconst privateKey = getOrCreateSecret(secrets, \"privateKey\", generatePrivateKey)\nconst keys = privateKey.apply(getKeysFromString)\n\nexport default outputs({\n keyPair: {\n type: \"ed25519\",\n privateKey: keys.privateKey,\n publicKey: unsecret(keys.publicKey),\n },\n $status: {\n fingerprint: {\n value: unsecret(keys.fingerprint),\n },\n publicKey: {\n value: unsecret(keys.publicKey),\n },\n },\n})\n"],"mappings":";;;;;;AAAA,SAAS,WAAW;AACpB,SAAS,SAAS,mBAAmB,gBAAgB;AAGrD,IAAM,EAAE,SAAS,QAAQ,IAAI,QAAQ,IAAI,OAAO;AAEhD,IAAM,aAAa,kBAAkB,SAAS,cAAc,kBAAkB;AAC9E,IAAM,OAAO,WAAW,MAAM,iBAAiB;AAE/C,IAAO,mBAAQ,QAAQ;AAAA,EACrB,SAAS;AAAA,IACP,MAAM;AAAA,IACN,YAAY,KAAK;AAAA,IACjB,WAAW,SAAS,KAAK,SAAS;AAAA,EACpC;AAAA,EACA,SAAS;AAAA,IACP,aAAa;AAAA,MACX,OAAO,SAAS,KAAK,WAAW;AAAA,IAClC;AAAA,IACA,WAAW;AAAA,MACT,OAAO,SAAS,KAAK,SAAS;AAAA,IAChC;AAAA,EACF;AACF,CAAC;","names":[]}
File without changes
@@ -1,46 +0,0 @@
1
- import { common } from "@highstate/library"
2
- import { forUnit, Output, output } from "@highstate/pulumi"
3
- import { remote } from "@pulumi/command"
4
- import { createSshTerminal } from "../shared"
5
-
6
- const { args, inputs, secrets, outputs } = forUnit(common.existingServer)
7
-
8
- const privateKey = inputs.sshKeyPair?.privateKey ?? secrets.sshPrivateKey
9
-
10
- const hostnameResult = new remote.Command("hostname", {
11
- connection: output({
12
- host: args.endpoint,
13
- port: args.sshPort,
14
- user: args.sshUser,
15
- password: secrets.sshPassword,
16
- privateKey,
17
- dialErrorLimit: 3,
18
- }),
19
- create: "hostname",
20
- triggers: [Date.now()],
21
- })
22
-
23
- const hostname = hostnameResult.stdout.apply(x => x.trim())
24
-
25
- const server: Output<common.Server> = output({
26
- endpoint: args.endpoint,
27
- hostname,
28
- sshCredentials: {
29
- user: args.sshUser,
30
- port: args.sshPort,
31
- password: secrets.sshPassword,
32
- privateKey,
33
- },
34
- })
35
-
36
- export default outputs({
37
- server,
38
- $status: {
39
- hostname: {
40
- value: hostname,
41
- },
42
- },
43
- $terminals: {
44
- ssh: server.apply(createSshTerminal),
45
- },
46
- })
@@ -1,85 +0,0 @@
1
- import { remote, type types } from "@pulumi/command"
2
- import {
3
- interpolate,
4
- output,
5
- Resource,
6
- type Input,
7
- type InputOrArray,
8
- type Output,
9
- } from "@highstate/pulumi"
10
- import { common } from "@highstate/library"
11
-
12
- export function getServerConnection(
13
- server: Input<common.Server>,
14
- ): Output<types.input.remote.ConnectionArgs> {
15
- return output(server).apply(server => ({
16
- host: server.endpoint,
17
- port: server.sshCredentials?.port ?? 22,
18
- user: server.sshCredentials?.user ?? "root",
19
- password: server.sshCredentials?.password,
20
- privateKey: server.sshCredentials?.privateKey,
21
- dialErrorLimit: 3,
22
- }))
23
- }
24
-
25
- export interface CommandOptions {
26
- id: string
27
- create: Input<string>
28
- update?: Input<string>
29
- delete?: Input<string>
30
- logging?: Input<remote.Logging>
31
- dependsOn?: InputOrArray<Resource>
32
- }
33
-
34
- export interface FileOptions {
35
- id: string
36
- path: Input<string>
37
- content: Input<string>
38
- dependsOn?: InputOrArray<Resource>
39
- }
40
-
41
- export class Server {
42
- public readonly server: Output<common.Server>
43
- public readonly connection: Output<types.input.remote.ConnectionArgs>
44
-
45
- public get endpoint(): Output<string> {
46
- return this.server.endpoint
47
- }
48
-
49
- public get hostname(): Output<string> {
50
- return this.server.hostname
51
- }
52
-
53
- constructor(server: Input<common.Server>) {
54
- this.server = output(server)
55
- this.connection = getServerConnection(this.server)
56
- }
57
-
58
- public command(options: CommandOptions): remote.Command {
59
- return new remote.Command(
60
- options.id,
61
- {
62
- connection: this.connection,
63
- create: options.create,
64
- update: options.update,
65
- delete: options.delete,
66
- logging: options.logging,
67
- },
68
- { dependsOn: options.dependsOn },
69
- )
70
- }
71
-
72
- public file(options: FileOptions): remote.Command {
73
- const escapedContent = output(options.content).apply(content => content.replace(/"/g, '\\"'))
74
-
75
- return new remote.Command(
76
- options.id,
77
- {
78
- connection: this.connection,
79
- create: interpolate`mkdir -p $(dirname ${options.path}) && echo "${escapedContent}" > ${options.path}`,
80
- delete: interpolate`rm -rf ${options.path}`,
81
- },
82
- { dependsOn: options.dependsOn },
83
- )
84
- }
85
- }
@@ -1,18 +0,0 @@
1
- import type { common } from "@highstate/library"
2
-
3
- export function l4EndpointToString(l4Endpoint: common.L4Endpoint): string {
4
- return `${l4Endpoint.endpoint}:${l4Endpoint.port}`
5
- }
6
-
7
- export function parseL4Endpoint(l4Endpoint: string): common.L4Endpoint {
8
- const [endpoint, port] = l4Endpoint.split(":")
9
-
10
- if (!port) {
11
- throw new Error(`Invalid L4 endpoint: ${l4Endpoint}`)
12
- }
13
-
14
- return {
15
- endpoint,
16
- port: parseInt(port, 10),
17
- }
18
- }
@@ -1,24 +0,0 @@
1
- import { ssh } from "@highstate/library"
2
- import { forUnit, getOrCreateSecret, unsecret } from "@highstate/pulumi"
3
- import { generatePrivateKey, getKeysFromString } from "../../shared"
4
-
5
- const { secrets, outputs } = forUnit(ssh.keyPair)
6
-
7
- const privateKey = getOrCreateSecret(secrets, "privateKey", generatePrivateKey)
8
- const keys = privateKey.apply(getKeysFromString)
9
-
10
- export default outputs({
11
- keyPair: {
12
- type: "ed25519",
13
- privateKey: keys.privateKey,
14
- publicKey: unsecret(keys.publicKey),
15
- },
16
- $status: {
17
- fingerprint: {
18
- value: unsecret(keys.fingerprint),
19
- },
20
- publicKey: {
21
- value: unsecret(keys.publicKey),
22
- },
23
- },
24
- })