@ankhorage/infra-hetzner 0.0.0-stage → 0.3.2
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/LICENSE +21 -0
- package/README.md +39 -2
- package/dist/constants/infra.d.ts +11 -0
- package/dist/constants/infra.d.ts.map +1 -0
- package/dist/constants/infra.js +4 -0
- package/dist/constants/infra.js.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.d.ts +4 -0
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.d.ts.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js +193 -0
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.d.ts +4 -0
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.d.ts.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js +63 -0
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.d.ts +14 -0
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.d.ts.map +1 -0
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.js +162 -0
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.js.map +1 -0
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.js +38 -0
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.js +46 -0
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.js +28 -0
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.js +19 -0
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/hetznerResults.d.ts +6 -0
- package/dist/features/cloud-compute/application/hetznerResults.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/hetznerResults.js +31 -0
- package/dist/features/cloud-compute/application/hetznerResults.js.map +1 -0
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.js +15 -0
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.d.ts +5 -0
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.js +35 -0
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/projectHetznerCompute.d.ts +5 -0
- package/dist/features/cloud-compute/application/projectHetznerCompute.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/projectHetznerCompute.js +36 -0
- package/dist/features/cloud-compute/application/projectHetznerCompute.js.map +1 -0
- package/dist/features/cloud-compute/application/resolveHetznerCredentialsAsync.d.ts +10 -0
- package/dist/features/cloud-compute/application/resolveHetznerCredentialsAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/resolveHetznerCredentialsAsync.js +39 -0
- package/dist/features/cloud-compute/application/resolveHetznerCredentialsAsync.js.map +1 -0
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.d.ts +6 -0
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.d.ts.map +1 -0
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.js +23 -0
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.js.map +1 -0
- package/dist/features/cloud-compute/composition/createInfraAdapter.d.ts +12 -0
- package/dist/features/cloud-compute/composition/createInfraAdapter.d.ts.map +1 -0
- package/dist/features/cloud-compute/composition/createInfraAdapter.js +31 -0
- package/dist/features/cloud-compute/composition/createInfraAdapter.js.map +1 -0
- package/dist/features/cloud-compute/utils/hetznerOwnership.d.ts +13 -0
- package/dist/features/cloud-compute/utils/hetznerOwnership.d.ts.map +1 -0
- package/dist/features/cloud-compute/utils/hetznerOwnership.js +41 -0
- package/dist/features/cloud-compute/utils/hetznerOwnership.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types/hetznerCompute.d.ts +55 -0
- package/dist/types/hetznerCompute.d.ts.map +1 -0
- package/dist/types/hetznerCompute.js +2 -0
- package/dist/types/hetznerCompute.js.map +1 -0
- package/package.json +66 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hetznerApiValues.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/hetznerApiValues.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,MAAM,UAAU,yBAAyB,CACvC,UAA6B,EAC7B,OAA8B,EAC9B,MAAwC,EACxC,YAA8F;IAE9F,QAAQ,UAAU,EAAE,CAA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AAC,YAAY,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;AAClF,CAAC;AAED,SAAS,QAAQ,CAAC,MAAc;IAC9B,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC;IACvC,IAAI,MAAM,KAAK,cAAc,IAAI,MAAM,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IACzE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,SAAS,CAAC;IACzC,IAAI,QAAQ,KAAK,KAAK;QAAE,OAAO,cAAc,CAAC;IAC9C,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["import type { InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n HetznerCloudObservation,\n HetznerDesiredCompute,\n HetznerResourceId,\n HetznerResourceObservation,\n} from '../../../../types/hetznerCompute';\nimport { HETZNER_LABELS } from '../../utils/hetznerOwnership';\n\nexport type HetznerListKey = 'networks' | 'firewalls' | 'ssh_keys' | 'servers';\n\nexport function createHetznerResourceBody(\n resourceId: HetznerResourceId,\n desired: HetznerDesiredCompute,\n labels: Readonly<Record<string, string>>,\n dependencies?: Readonly<Record<'network' | 'firewall' | 'sshKey', HetznerResourceObservation>>,\n): Readonly<Record<string, unknown>> | undefined {\n switch (resourceId) {\n case 'network':\n return {\n name: desired.network.name,\n ip_range: '10.42.0.0/16',\n subnets: [\n {\n type: 'cloud',\n network_zone: getNetworkZone(desired.location),\n ip_range: '10.42.0.0/24',\n },\n ],\n labels,\n };\n case 'firewall':\n return {\n name: desired.firewall.name,\n labels,\n rules: [desired.sshPort, 80, 443, 6443].map((port) => ({\n direction: 'in',\n protocol: 'tcp',\n port: String(port),\n source_ips: ['0.0.0.0/0', '::/0'],\n })),\n };\n case 'ssh-key':\n return { name: desired.sshKey.name, public_key: desired.sshPublicKey, labels };\n case 'server':\n return dependencies === undefined\n ? undefined\n : {\n name: desired.server.name,\n location: desired.location,\n server_type: desired.serverType,\n image: desired.image,\n networks: [Number(dependencies.network.externalId)],\n firewalls: [{ firewall: Number(dependencies.firewall.externalId) }],\n ssh_keys: [Number(dependencies.sshKey.externalId)],\n public_net: { enable_ipv4: true, enable_ipv6: false },\n labels,\n };\n }\n}\n\nexport function parseHetznerResource(\n value: unknown,\n resourceId: HetznerResourceId,\n): HetznerResourceObservation | undefined {\n if (!isRecord(value) || (typeof value.id !== 'number' && typeof value.id !== 'string'))\n return undefined;\n const labels = isRecord(value.labels) ? value.labels : {};\n const labeledResourceId = labels[HETZNER_LABELS.resourceId];\n if (labeledResourceId !== undefined && labeledResourceId !== resourceId) return undefined;\n const hash = labels[HETZNER_LABELS.configurationHash];\n const publicIpv4 = readServerIpv4(value);\n const architecture = readServerArchitecture(value);\n return {\n resourceId,\n externalId: String(value.id),\n ...(typeof hash === 'string' ? { configurationHash: hash } : {}),\n state: mapState(typeof value.status === 'string' ? value.status : 'running'),\n ...(publicIpv4 === undefined ? {} : { publicIpv4 }),\n ...(architecture === undefined ? {} : { architecture }),\n };\n}\n\nexport function hasHetznerDrift(\n observed: HetznerCloudObservation,\n desired: HetznerDesiredCompute,\n): boolean {\n const hashes: Readonly<Record<HetznerResourceId, string>> = {\n network: desired.network.configurationHash,\n firewall: desired.firewall.configurationHash,\n 'ssh-key': desired.sshKey.configurationHash,\n server: desired.server.configurationHash,\n };\n return observed.resources.some(\n (resource) => resource.configurationHash !== hashes[resource.resourceId],\n );\n}\n\nexport function readHetznerList(\n value: unknown,\n key: HetznerListKey,\n): readonly unknown[] | undefined {\n if (!isRecord(value)) return undefined;\n const candidate =\n key === 'networks'\n ? value.networks\n : key === 'firewalls'\n ? value.firewalls\n : key === 'ssh_keys'\n ? value.ssh_keys\n : value.servers;\n return Array.isArray(candidate) ? candidate : undefined;\n}\n\nexport function readCreatedHetznerResource(\n value: unknown,\n resourceId: HetznerResourceId,\n): Readonly<Record<string, unknown>> | undefined {\n if (!isRecord(value)) return undefined;\n const candidate =\n resourceId === 'network'\n ? value.network\n : resourceId === 'firewall'\n ? value.firewall\n : resourceId === 'ssh-key'\n ? value.ssh_key\n : value.server;\n return isRecord(candidate) ? candidate : undefined;\n}\n\nexport function readActionId(value: unknown): number | undefined {\n return isRecord(value) && isRecord(value.action) && typeof value.action.id === 'number'\n ? value.action.id\n : undefined;\n}\n\nexport function readActionStatus(value: unknown): string | undefined {\n return isRecord(value) && isRecord(value.action) && typeof value.action.status === 'string'\n ? value.action.status\n : undefined;\n}\n\nexport function hasNamedHetznerResource(\n value: unknown,\n key: 'locations' | 'server_types' | 'images',\n): boolean {\n if (!isRecord(value)) return false;\n const list =\n key === 'locations'\n ? value.locations\n : key === 'server_types'\n ? value.server_types\n : value.images;\n return Array.isArray(list) && list.length > 0;\n}\n\nexport function apiSuccess<T>(value: T): InfraResult<T> {\n return { ok: true, value, diagnostics: [] };\n}\n\nexport function apiFailure(code: string): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [{ severity: 'error', code, message: 'The Hetzner Cloud operation failed.' }],\n };\n}\n\nfunction readServerIpv4(value: Readonly<Record<string, unknown>>): string | undefined {\n const publicNetwork = value.public_net;\n if (!isRecord(publicNetwork) || !isRecord(publicNetwork.ipv4)) return undefined;\n return typeof publicNetwork.ipv4.ip === 'string' ? publicNetwork.ipv4.ip : undefined;\n}\n\nfunction readServerArchitecture(\n value: Readonly<Record<string, unknown>>,\n): 'amd64' | 'arm64' | undefined {\n const serverType = value.server_type;\n if (!isRecord(serverType) || typeof serverType.architecture !== 'string') return undefined;\n if (['x86', 'x64', 'amd64'].includes(serverType.architecture)) return 'amd64';\n return ['arm', 'arm64'].includes(serverType.architecture) ? 'arm64' : undefined;\n}\n\nfunction mapState(status: string): HetznerResourceObservation['state'] {\n if (status === 'running') return 'ready';\n if (status === 'off') return 'stopped';\n if (status === 'initializing' || status === 'starting') return 'pending';\n return 'degraded';\n}\n\nfunction getNetworkZone(location: string): string {\n if (location === 'ash') return 'us-east';\n if (location === 'hil') return 'us-west';\n if (location === 'sin') return 'ap-southeast';\n return 'eu-central';\n}\n\nfunction isRecord(value: unknown): value is Readonly<Record<string, unknown>> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraComputeSnapshot, InfraControlPlaneCredentialRef, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudObservation, HetznerDesiredCompute, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
3
|
+
/*** Convert observed owned Cloud resources into a portable read-only compute snapshot. */
|
|
4
|
+
export declare function createHetznerComputeSnapshotAsync(hostKeyProbe: HetznerHostKeyProbe, desired: HetznerDesiredCompute, sshReference: InfraControlPlaneCredentialRef, observation: HetznerCloudObservation, signal?: AbortSignal): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
|
+
//# sourceMappingURL=createHetznerComputeSnapshotAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHetznerComputeSnapshotAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/createHetznerComputeSnapshotAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,+BAA+B,CAAC;AAGvC,0FAA0F;AAC1F,wBAAsB,iCAAiC,CACrD,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,qBAAqB,EAC9B,YAAY,EAAE,8BAA8B,EAC5C,WAAW,EAAE,uBAAuB,EACpC,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAuC5C"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { toOwnedResources, toPublicOutputs } from './hetznerResults';
|
|
2
|
+
/*** Convert observed owned Cloud resources into a portable read-only compute snapshot. */
|
|
3
|
+
export async function createHetznerComputeSnapshotAsync(hostKeyProbe, desired, sshReference, observation, signal) {
|
|
4
|
+
const server = observation.resources.find(({ resourceId }) => resourceId === 'server');
|
|
5
|
+
const base = {
|
|
6
|
+
resources: toOwnedResources(desired.identity, observation),
|
|
7
|
+
outputs: toPublicOutputs(desired.identity, observation),
|
|
8
|
+
};
|
|
9
|
+
if (server?.state !== 'ready' ||
|
|
10
|
+
server.publicIpv4 === undefined ||
|
|
11
|
+
server.architecture === undefined) {
|
|
12
|
+
return { ok: true, value: { ...base, targets: [] }, diagnostics: [] };
|
|
13
|
+
}
|
|
14
|
+
const fingerprint = await hostKeyProbe.fingerprintAsync(server.publicIpv4, desired.sshPort, signal);
|
|
15
|
+
if (!fingerprint.ok)
|
|
16
|
+
return fingerprint;
|
|
17
|
+
return {
|
|
18
|
+
ok: true,
|
|
19
|
+
value: {
|
|
20
|
+
...base,
|
|
21
|
+
targets: [
|
|
22
|
+
{
|
|
23
|
+
id: 'server',
|
|
24
|
+
kind: 'ssh-host',
|
|
25
|
+
os: 'linux',
|
|
26
|
+
architecture: server.architecture,
|
|
27
|
+
host: server.publicIpv4,
|
|
28
|
+
port: desired.sshPort,
|
|
29
|
+
user: desired.sshUser,
|
|
30
|
+
credential: sshReference,
|
|
31
|
+
hostKeyFingerprint: fingerprint.value,
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
diagnostics: [],
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=createHetznerComputeSnapshotAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHetznerComputeSnapshotAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/createHetznerComputeSnapshotAsync.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAErE,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,iCAAiC,CACrD,YAAiC,EACjC,OAA8B,EAC9B,YAA4C,EAC5C,WAAoC,EACpC,MAAoB;IAEpB,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC;IACvF,MAAM,IAAI,GAAG;QACX,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC;QAC1D,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC;KACxD,CAAC;IACF,IACE,MAAM,EAAE,KAAK,KAAK,OAAO;QACzB,MAAM,CAAC,UAAU,KAAK,SAAS;QAC/B,MAAM,CAAC,YAAY,KAAK,SAAS,EACjC,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACxE,CAAC;IACD,MAAM,WAAW,GAAG,MAAM,YAAY,CAAC,gBAAgB,CACrD,MAAM,CAAC,UAAU,EACjB,OAAO,CAAC,OAAO,EACf,MAAM,CACP,CAAC;IACF,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,WAAW,CAAC;IACxC,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE;YACL,GAAG,IAAI;YACP,OAAO,EAAE;gBACP;oBACE,EAAE,EAAE,QAAQ;oBACZ,IAAI,EAAE,UAAU;oBAChB,EAAE,EAAE,OAAO;oBACX,YAAY,EAAE,MAAM,CAAC,YAAY;oBACjC,IAAI,EAAE,MAAM,CAAC,UAAU;oBACvB,IAAI,EAAE,OAAO,CAAC,OAAO;oBACrB,IAAI,EAAE,OAAO,CAAC,OAAO;oBACrB,UAAU,EAAE,YAAY;oBACxB,kBAAkB,EAAE,WAAW,CAAC,KAAK;iBACtC;aACF;SACF;QACD,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraComputeSnapshot,\n InfraControlPlaneCredentialRef,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type {\n HetznerCloudObservation,\n HetznerDesiredCompute,\n HetznerHostKeyProbe,\n} from '../../../types/hetznerCompute';\nimport { toOwnedResources, toPublicOutputs } from './hetznerResults';\n\n/*** Convert observed owned Cloud resources into a portable read-only compute snapshot. */\nexport async function createHetznerComputeSnapshotAsync(\n hostKeyProbe: HetznerHostKeyProbe,\n desired: HetznerDesiredCompute,\n sshReference: InfraControlPlaneCredentialRef,\n observation: HetznerCloudObservation,\n signal?: AbortSignal,\n): Promise<InfraResult<InfraComputeSnapshot>> {\n const server = observation.resources.find(({ resourceId }) => resourceId === 'server');\n const base = {\n resources: toOwnedResources(desired.identity, observation),\n outputs: toPublicOutputs(desired.identity, observation),\n };\n if (\n server?.state !== 'ready' ||\n server.publicIpv4 === undefined ||\n server.architecture === undefined\n ) {\n return { ok: true, value: { ...base, targets: [] }, diagnostics: [] };\n }\n const fingerprint = await hostKeyProbe.fingerprintAsync(\n server.publicIpv4,\n desired.sshPort,\n signal,\n );\n if (!fingerprint.ok) return fingerprint;\n return {\n ok: true,\n value: {\n ...base,\n targets: [\n {\n id: 'server',\n kind: 'ssh-host',\n os: 'linux',\n architecture: server.architecture,\n host: server.publicIpv4,\n port: desired.sshPort,\n user: desired.sshUser,\n credential: sshReference,\n hostKeyFingerprint: fingerprint.value,\n },\n ],\n },\n diagnostics: [],\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraDestroyRequest, InfraExecutionContext, InfraReconcileResult, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Delete exact owned compute resources only after project/environment confirmation. */
|
|
4
|
+
export declare function destroyHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, request: InfraDestroyRequest): Promise<InfraResult<InfraReconcileResult>>;
|
|
5
|
+
//# sourceMappingURL=destroyHetznerComputeAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroyHetznerComputeAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/destroyHetznerComputeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,+BAA+B,CAAC;AAMxF,wFAAwF;AACxF,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,qBAAqB,EAC9B,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAuB5C"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
2
|
+
import { toOwnedResources, toPublicOutputs } from './hetznerResults';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
+
import { invalidSelection } from './validateHetznerComputeAsync';
|
|
5
|
+
/** Delete exact owned compute resources only after project/environment confirmation. */
|
|
6
|
+
export async function destroyHetznerComputeAsync(api, context, request) {
|
|
7
|
+
if (!isConfirmed(context, request))
|
|
8
|
+
return unconfirmed();
|
|
9
|
+
const selection = context.desired.deployment.compute;
|
|
10
|
+
if (selection.provider !== 'hetzner')
|
|
11
|
+
return invalidSelection();
|
|
12
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
13
|
+
if (!credentials.ok)
|
|
14
|
+
return credentials;
|
|
15
|
+
const identity = getHetznerIdentity(context);
|
|
16
|
+
const removed = await api.destroyAsync(credentials.value.token, identity, ['server', 'firewall', 'network', 'ssh-key'], context.signal);
|
|
17
|
+
return removed.ok
|
|
18
|
+
? {
|
|
19
|
+
ok: true,
|
|
20
|
+
value: {
|
|
21
|
+
resources: toOwnedResources(identity, removed.value),
|
|
22
|
+
outputs: toPublicOutputs(identity, removed.value),
|
|
23
|
+
},
|
|
24
|
+
diagnostics: [],
|
|
25
|
+
}
|
|
26
|
+
: removed;
|
|
27
|
+
}
|
|
28
|
+
function isConfirmed(context, request) {
|
|
29
|
+
return (request.projectId === context.projectId &&
|
|
30
|
+
request.environment === context.environment &&
|
|
31
|
+
request.confirmation.projectId === context.projectId &&
|
|
32
|
+
request.confirmation.environment === context.environment);
|
|
33
|
+
}
|
|
34
|
+
function unconfirmed() {
|
|
35
|
+
return {
|
|
36
|
+
ok: false,
|
|
37
|
+
diagnostics: [
|
|
38
|
+
{
|
|
39
|
+
severity: 'error',
|
|
40
|
+
code: 'hetzner-destroy-unconfirmed',
|
|
41
|
+
message: 'Hetzner destroy requires exact project and environment confirmation.',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=destroyHetznerComputeAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destroyHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/destroyHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO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,CACL,OAAO,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS;QACvC,OAAO,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW;QAC3C,OAAO,CAAC,YAAY,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS;QACpD,OAAO,CAAC,YAAY,CAAC,WAAW,KAAK,OAAO,CAAC,WAAW,CACzD,CAAC;AACJ,CAAC;AAED,SAAS,WAAW;IAClB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,6BAA6B;gBACnC,OAAO,EAAE,sEAAsE;aAChF;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraDestroyRequest,\n InfraExecutionContext,\n InfraReconcileResult,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi, HetznerResourceId } from '../../../types/hetznerCompute';\nimport { getHetznerIdentity } from '../utils/hetznerOwnership';\nimport { toOwnedResources, toPublicOutputs } from './hetznerResults';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\nimport { invalidSelection } from './validateHetznerComputeAsync';\n\n/** Delete exact owned compute resources only after project/environment confirmation. */\nexport async function destroyHetznerComputeAsync(\n api: HetznerCloudApi,\n context: InfraExecutionContext,\n request: InfraDestroyRequest,\n): Promise<InfraResult<InfraReconcileResult>> {\n if (!isConfirmed(context, request)) return unconfirmed();\n const selection = context.desired.deployment.compute;\n if (selection.provider !== 'hetzner') return invalidSelection();\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n const identity = getHetznerIdentity(context);\n const removed = await api.destroyAsync(\n credentials.value.token,\n identity,\n ['server', 'firewall', 'network', 'ssh-key'] satisfies readonly HetznerResourceId[],\n context.signal,\n );\n return removed.ok\n ? {\n ok: true,\n value: {\n resources: toOwnedResources(identity, removed.value),\n outputs: toPublicOutputs(identity, removed.value),\n },\n diagnostics: [],\n }\n : removed;\n}\n\nfunction isConfirmed(context: InfraExecutionContext, request: InfraDestroyRequest): boolean {\n return (\n request.projectId === context.projectId &&\n request.environment === context.environment &&\n request.confirmation.projectId === context.projectId &&\n request.confirmation.environment === context.environment\n );\n}\n\nfunction unconfirmed(): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'hetzner-destroy-unconfirmed',\n message: 'Hetzner destroy requires exact project and environment confirmation.',\n },\n ],\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraComputeSnapshot, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Reconcile owned Cloud resources and return one verified portable SSH target. */
|
|
4
|
+
export declare function ensureHetznerComputeAsync(api: HetznerCloudApi, hostKeyProbe: HetznerHostKeyProbe, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
|
+
//# sourceMappingURL=ensureHetznerComputeAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureHetznerComputeAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/ensureHetznerComputeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAK1F,mFAAmF;AACnF,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,eAAe,EACpB,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAc5C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';
|
|
2
|
+
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
+
/** Reconcile owned Cloud resources and return one verified portable SSH target. */
|
|
5
|
+
export async function ensureHetznerComputeAsync(api, hostKeyProbe, context, selection) {
|
|
6
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
7
|
+
if (!credentials.ok)
|
|
8
|
+
return credentials;
|
|
9
|
+
const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);
|
|
10
|
+
const reconciled = await api.reconcileAsync(credentials.value.token, desired, context.signal);
|
|
11
|
+
if (!reconciled.ok)
|
|
12
|
+
return reconciled;
|
|
13
|
+
const snapshot = await createHetznerComputeSnapshotAsync(hostKeyProbe, desired, credentials.value.sshReference, reconciled.value, context.signal);
|
|
14
|
+
return snapshot.ok && snapshot.value.targets.length === 0 ? unavailableServer() : snapshot;
|
|
15
|
+
}
|
|
16
|
+
function unavailableServer() {
|
|
17
|
+
return {
|
|
18
|
+
ok: false,
|
|
19
|
+
diagnostics: [
|
|
20
|
+
{
|
|
21
|
+
severity: 'error',
|
|
22
|
+
code: 'hetzner-server-unavailable',
|
|
23
|
+
message: 'The Hetzner server is not ready with a public IPv4 address.',
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ensureHetznerComputeAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/ensureHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,GAAoB,EACpB,YAAiC,EACjC,OAA8B,EAC9B,SAA2C;IAE3C,MAAM,WAAW,GAAG,MAAM,8BAA8B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7E,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,WAAW,CAAC;IACxC,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1F,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9F,IAAI,CAAC,UAAU,CAAC,EAAE;QAAE,OAAO,UAAU,CAAC;IACtC,MAAM,QAAQ,GAAG,MAAM,iCAAiC,CACtD,YAAY,EACZ,OAAO,EACP,WAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,UAAU,CAAC,KAAK,EAChB,OAAO,CAAC,MAAM,CACf,CAAC;IACF,OAAO,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC7F,CAAC;AAED,SAAS,iBAAiB;IACxB,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,4BAA4B;gBAClC,OAAO,EAAE,6DAA6D;aACvE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraComputeSelection,\n InfraComputeSnapshot,\n InfraExecutionContext,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';\nimport { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';\nimport { projectHetznerCompute } from './projectHetznerCompute';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\n\n/** Reconcile owned Cloud resources and return one verified portable SSH target. */\nexport async function ensureHetznerComputeAsync(\n api: HetznerCloudApi,\n hostKeyProbe: HetznerHostKeyProbe,\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n): Promise<InfraResult<InfraComputeSnapshot>> {\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);\n const reconciled = await api.reconcileAsync(credentials.value.token, desired, context.signal);\n if (!reconciled.ok) return reconciled;\n const snapshot = await createHetznerComputeSnapshotAsync(\n hostKeyProbe,\n desired,\n credentials.value.sshReference,\n reconciled.value,\n context.signal,\n );\n return snapshot.ok && snapshot.value.targets.length === 0 ? unavailableServer() : snapshot;\n}\n\nfunction unavailableServer(): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'hetzner-server-unavailable',\n message: 'The Hetzner server is not ready with a public IPv4 address.',\n },\n ],\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraExecutionContext, InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Read exact owned Hetzner resource status from a fresh execution context. */
|
|
4
|
+
export declare function getHetznerComputeStatusAsync(api: HetznerCloudApi, context: InfraExecutionContext): Promise<InfraResult<readonly InfraResourceStatus[]>>;
|
|
5
|
+
//# sourceMappingURL=getHetznerComputeStatusAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHetznerComputeStatusAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/getHetznerComputeStatusAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAMrE,+EAA+E;AAC/E,wBAAsB,4BAA4B,CAChD,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,WAAW,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC,CAUtD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
2
|
+
import { toStatuses } from './hetznerResults';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
+
import { invalidSelection } from './validateHetznerComputeAsync';
|
|
5
|
+
/** Read exact owned Hetzner resource status from a fresh execution context. */
|
|
6
|
+
export async function getHetznerComputeStatusAsync(api, context) {
|
|
7
|
+
const selection = context.desired.deployment.compute;
|
|
8
|
+
if (selection.provider !== 'hetzner')
|
|
9
|
+
return invalidSelection();
|
|
10
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
11
|
+
if (!credentials.ok)
|
|
12
|
+
return credentials;
|
|
13
|
+
const identity = getHetznerIdentity(context);
|
|
14
|
+
const observed = await api.inspectAsync(credentials.value.token, identity, context.signal);
|
|
15
|
+
return observed.ok
|
|
16
|
+
? { ok: true, value: toStatuses(identity, observed.value), diagnostics: [] }
|
|
17
|
+
: observed;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=getHetznerComputeStatusAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getHetznerComputeStatusAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/getHetznerComputeStatusAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,GAAoB,EACpB,OAA8B;IAE9B,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;IACrD,IAAI,SAAS,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,gBAAgB,EAAE,CAAC;IAChE,MAAM,WAAW,GAAG,MAAM,8BAA8B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7E,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,WAAW,CAAC;IACxC,MAAM,QAAQ,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3F,OAAO,QAAQ,CAAC,EAAE;QAChB,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;QAC5E,CAAC,CAAC,QAAQ,CAAC;AACf,CAAC","sourcesContent":["import type {\n InfraExecutionContext,\n InfraResourceStatus,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi } from '../../../types/hetznerCompute';\nimport { getHetznerIdentity } from '../utils/hetznerOwnership';\nimport { toStatuses } from './hetznerResults';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\nimport { invalidSelection } from './validateHetznerComputeAsync';\n\n/** Read exact owned Hetzner resource status from a fresh execution context. */\nexport async function getHetznerComputeStatusAsync(\n api: HetznerCloudApi,\n context: InfraExecutionContext,\n): Promise<InfraResult<readonly InfraResourceStatus[]>> {\n const selection = context.desired.deployment.compute;\n if (selection.provider !== 'hetzner') return invalidSelection();\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n const identity = getHetznerIdentity(context);\n const observed = await api.inspectAsync(credentials.value.token, identity, context.signal);\n return observed.ok\n ? { ok: true, value: toStatuses(identity, observed.value), diagnostics: [] }\n : observed;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InfraOutput, InfraOwnedResource, InfraResourceStatus } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudObservation, HetznerProjectIdentity } from '../../../types/hetznerCompute';
|
|
3
|
+
export declare function toOwnedResources(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraOwnedResource[];
|
|
4
|
+
export declare function toStatuses(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraResourceStatus[];
|
|
5
|
+
export declare function toPublicOutputs(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraOutput[];
|
|
6
|
+
//# sourceMappingURL=hetznerResults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hetznerResults.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/hetznerResults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EAEvB,MAAM,+BAA+B,CAAC;AAGvC,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,sBAAsB,EAChC,WAAW,EAAE,uBAAuB,GACnC,SAAS,kBAAkB,EAAE,CAK/B;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,sBAAsB,EAChC,WAAW,EAAE,uBAAuB,GACnC,SAAS,mBAAmB,EAAE,CAKhC;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,sBAAsB,EAChC,WAAW,EAAE,uBAAuB,GACnC,SAAS,WAAW,EAAE,CAaxB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { createHetznerOwner } from '../utils/hetznerOwnership';
|
|
2
|
+
export function toOwnedResources(identity, observation) {
|
|
3
|
+
return observation.resources.map((resource) => ({
|
|
4
|
+
...createHetznerOwner(identity, resource.resourceId),
|
|
5
|
+
externalId: resource.externalId,
|
|
6
|
+
}));
|
|
7
|
+
}
|
|
8
|
+
export function toStatuses(identity, observation) {
|
|
9
|
+
return observation.resources.map((resource) => ({
|
|
10
|
+
owner: createHetznerOwner(identity, resource.resourceId).identity,
|
|
11
|
+
state: resource.state,
|
|
12
|
+
}));
|
|
13
|
+
}
|
|
14
|
+
export function toPublicOutputs(identity, observation) {
|
|
15
|
+
const server = observation.resources.find(hasPublicAddress);
|
|
16
|
+
return server === undefined
|
|
17
|
+
? []
|
|
18
|
+
: [
|
|
19
|
+
{
|
|
20
|
+
owner: createHetznerOwner(identity, 'server').identity,
|
|
21
|
+
name: 'publicIpv4',
|
|
22
|
+
visibility: 'public',
|
|
23
|
+
value: server.publicIpv4,
|
|
24
|
+
environmentVariable: 'ANKHORAGE_SERVER_IPV4',
|
|
25
|
+
},
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
function hasPublicAddress(resource) {
|
|
29
|
+
return resource.resourceId === 'server' && resource.publicIpv4 !== undefined;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=hetznerResults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hetznerResults.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/hetznerResults.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,UAAU,gBAAgB,CAC9B,QAAgC,EAChC,WAAoC;IAEpC,OAAO,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC;QACpD,UAAU,EAAE,QAAQ,CAAC,UAAU;KAChC,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,QAAgC,EAChC,WAAoC;IAEpC,OAAO,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC9C,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ;QACjE,KAAK,EAAE,QAAQ,CAAC,KAAK;KACtB,CAAC,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,QAAgC,EAChC,WAAoC;IAEpC,MAAM,MAAM,GAAG,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAC5D,OAAO,MAAM,KAAK,SAAS;QACzB,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC;YACE;gBACE,KAAK,EAAE,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,QAAQ;gBACtD,IAAI,EAAE,YAAY;gBAClB,UAAU,EAAE,QAAQ;gBACpB,KAAK,EAAE,MAAM,CAAC,UAAU;gBACxB,mBAAmB,EAAE,uBAAuB;aAC7C;SACF,CAAC;AACR,CAAC;AAED,SAAS,gBAAgB,CACvB,QAAoC;IAEpC,OAAO,QAAQ,CAAC,UAAU,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,CAAC;AAC/E,CAAC","sourcesContent":["import type {\n InfraOutput,\n InfraOwnedResource,\n InfraResourceStatus,\n} from '@ankhorage/contracts/infra';\n\nimport type {\n HetznerCloudObservation,\n HetznerProjectIdentity,\n HetznerResourceObservation,\n} from '../../../types/hetznerCompute';\nimport { createHetznerOwner } from '../utils/hetznerOwnership';\n\nexport function toOwnedResources(\n identity: HetznerProjectIdentity,\n observation: HetznerCloudObservation,\n): readonly InfraOwnedResource[] {\n return observation.resources.map((resource) => ({\n ...createHetznerOwner(identity, resource.resourceId),\n externalId: resource.externalId,\n }));\n}\n\nexport function toStatuses(\n identity: HetznerProjectIdentity,\n observation: HetznerCloudObservation,\n): readonly InfraResourceStatus[] {\n return observation.resources.map((resource) => ({\n owner: createHetznerOwner(identity, resource.resourceId).identity,\n state: resource.state,\n }));\n}\n\nexport function toPublicOutputs(\n identity: HetznerProjectIdentity,\n observation: HetznerCloudObservation,\n): readonly InfraOutput[] {\n const server = observation.resources.find(hasPublicAddress);\n return server === undefined\n ? []\n : [\n {\n owner: createHetznerOwner(identity, 'server').identity,\n name: 'publicIpv4',\n visibility: 'public',\n value: server.publicIpv4,\n environmentVariable: 'ANKHORAGE_SERVER_IPV4',\n },\n ];\n}\n\nfunction hasPublicAddress(\n resource: HetznerResourceObservation,\n): resource is HetznerResourceObservation & { readonly publicIpv4: string } {\n return resource.resourceId === 'server' && resource.publicIpv4 !== undefined;\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraComputeSnapshot, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
3
|
+
/*** Inspect exact owned Hetzner resources without creating, updating or deleting them. */
|
|
4
|
+
export declare function inspectHetznerComputeAsync(api: HetznerCloudApi, hostKeyProbe: HetznerHostKeyProbe, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
|
+
//# sourceMappingURL=inspectHetznerComputeAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectHetznerComputeAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/inspectHetznerComputeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAK1F,0FAA0F;AAC1F,wBAAsB,0BAA0B,CAC9C,GAAG,EAAE,eAAe,EACpB,YAAY,EAAE,mBAAmB,EACjC,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC,CAiB5C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';
|
|
2
|
+
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
+
/*** Inspect exact owned Hetzner resources without creating, updating or deleting them. */
|
|
5
|
+
export async function inspectHetznerComputeAsync(api, hostKeyProbe, context, selection) {
|
|
6
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
7
|
+
if (!credentials.ok)
|
|
8
|
+
return credentials;
|
|
9
|
+
const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);
|
|
10
|
+
const observed = await api.inspectAsync(credentials.value.token, desired.identity, context.signal);
|
|
11
|
+
if (!observed.ok)
|
|
12
|
+
return observed;
|
|
13
|
+
return createHetznerComputeSnapshotAsync(hostKeyProbe, desired, credentials.value.sshReference, observed.value, context.signal);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=inspectHetznerComputeAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspectHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/inspectHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,0FAA0F;AAC1F,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,GAAoB,EACpB,YAAiC,EACjC,OAA8B,EAC9B,SAA2C;IAE3C,MAAM,WAAW,GAAG,MAAM,8BAA8B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7E,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,WAAW,CAAC;IACxC,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,EAAE,SAAS,EAAE,WAAW,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1F,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,YAAY,CACrC,WAAW,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,CAAC,QAAQ,EAChB,OAAO,CAAC,MAAM,CACf,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC;IAClC,OAAO,iCAAiC,CACtC,YAAY,EACZ,OAAO,EACP,WAAW,CAAC,KAAK,CAAC,YAAY,EAC9B,QAAQ,CAAC,KAAK,EACd,OAAO,CAAC,MAAM,CACf,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraComputeSelection,\n InfraComputeSnapshot,\n InfraExecutionContext,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';\nimport { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';\nimport { projectHetznerCompute } from './projectHetznerCompute';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\n\n/*** Inspect exact owned Hetzner resources without creating, updating or deleting them. */\nexport async function inspectHetznerComputeAsync(\n api: HetznerCloudApi,\n hostKeyProbe: HetznerHostKeyProbe,\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n): Promise<InfraResult<InfraComputeSnapshot>> {\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);\n const observed = await api.inspectAsync(\n credentials.value.token,\n desired.identity,\n context.signal,\n );\n if (!observed.ok) return observed;\n return createHetznerComputeSnapshotAsync(\n hostKeyProbe,\n desired,\n credentials.value.sshReference,\n observed.value,\n context.signal,\n );\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraExecutionContext, InfraPlanAction, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Compare exact owned Cloud state with the deterministic single-node projection. */
|
|
4
|
+
export declare function planHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<readonly InfraPlanAction[]>>;
|
|
5
|
+
//# sourceMappingURL=planHetznerComputeAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planHetznerComputeAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/planHetznerComputeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,eAAe,EACf,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,+BAA+B,CAAC;AAIxF,qFAAqF;AACrF,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC,CAkClD"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
2
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
3
|
+
/** Compare exact owned Cloud state with the deterministic single-node projection. */
|
|
4
|
+
export async function planHetznerComputeAsync(api, context, selection) {
|
|
5
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
6
|
+
if (!credentials.ok)
|
|
7
|
+
return credentials;
|
|
8
|
+
const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);
|
|
9
|
+
const observed = await api.inspectAsync(credentials.value.token, desired.identity, context.signal);
|
|
10
|
+
if (!observed.ok)
|
|
11
|
+
return observed;
|
|
12
|
+
const byId = new Map(observed.value.resources.map((resource) => [resource.resourceId, resource]));
|
|
13
|
+
return {
|
|
14
|
+
ok: true,
|
|
15
|
+
value: [desired.network, desired.firewall, desired.sshKey, desired.server].map((resource) => {
|
|
16
|
+
const current = byId.get(resource.owner.identity.resourceId);
|
|
17
|
+
const operation = current === undefined
|
|
18
|
+
? 'create'
|
|
19
|
+
: current.configurationHash === resource.configurationHash
|
|
20
|
+
? 'noop'
|
|
21
|
+
: 'update';
|
|
22
|
+
return {
|
|
23
|
+
owner: resource.owner.identity,
|
|
24
|
+
operation,
|
|
25
|
+
impact: operation === 'update' && resource.owner.identity.resourceId === 'server'
|
|
26
|
+
? 'interrupts-service'
|
|
27
|
+
: 'none',
|
|
28
|
+
detail: `${operation} Hetzner ${resource.owner.identity.resourceId}.`,
|
|
29
|
+
dependsOn: resource.owner.dependsOn,
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
diagnostics: [],
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=planHetznerComputeAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"planHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/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nB,CAAC,CAAC,QAAQ;gBACV,CAAC,CAAC,OAAO,CAAC,iBAAiB,KAAK,QAAQ,CAAC,iBAAiB;oBACxD,CAAC,CAAC,MAAM;oBACR,CAAC,CAAC,QAAQ,CAAC;YACjB,OAAO;gBACL,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ;gBAC9B,SAAS;gBACT,MAAM,EACJ,SAAS,KAAK,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ;oBACvE,CAAC,CAAC,oBAAoB;oBACtB,CAAC,CAAC,MAAM;gBACZ,MAAM,EAAE,GAAG,SAAS,YAAY,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG;gBACrE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,SAAS;aACpC,CAAC;QACJ,CAAC,CAAC;QACF,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraComputeSelection,\n InfraExecutionContext,\n InfraPlanAction,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi, HetznerResourceId } from '../../../types/hetznerCompute';\nimport { projectHetznerCompute } from './projectHetznerCompute';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\n\n/** Compare exact owned Cloud state with the deterministic single-node projection. */\nexport async function planHetznerComputeAsync(\n api: HetznerCloudApi,\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n): Promise<InfraResult<readonly InfraPlanAction[]>> {\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n const desired = projectHetznerCompute(context, selection, credentials.value.sshPublicKey);\n const observed = await api.inspectAsync(\n credentials.value.token,\n desired.identity,\n context.signal,\n );\n if (!observed.ok) return observed;\n const byId = new Map(observed.value.resources.map((resource) => [resource.resourceId, resource]));\n return {\n ok: true,\n value: [desired.network, desired.firewall, desired.sshKey, desired.server].map((resource) => {\n const current = byId.get(resource.owner.identity.resourceId as HetznerResourceId);\n const operation =\n current === undefined\n ? 'create'\n : current.configurationHash === resource.configurationHash\n ? 'noop'\n : 'update';\n return {\n owner: resource.owner.identity,\n operation,\n impact:\n operation === 'update' && resource.owner.identity.resourceId === 'server'\n ? 'interrupts-service'\n : 'none',\n detail: `${operation} Hetzner ${resource.owner.identity.resourceId}.`,\n dependsOn: resource.owner.dependsOn,\n };\n }),\n diagnostics: [],\n };\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraExecutionContext } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerDesiredCompute } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Project one low-cost, single-node Hetzner compute target without runtime-specific behavior. */
|
|
4
|
+
export declare function projectHetznerCompute(context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>, sshPublicKey: string): HetznerDesiredCompute;
|
|
5
|
+
//# sourceMappingURL=projectHetznerCompute.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectHetznerCompute.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/projectHetznerCompute.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAE/F,OAAO,KAAK,EAAE,qBAAqB,EAAqB,MAAM,+BAA+B,CAAC;AAG9F,kGAAkG;AAClG,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,EAC3C,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA+BvB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createHetznerOwner, getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
3
|
+
/** Project one low-cost, single-node Hetzner compute target without runtime-specific behavior. */
|
|
4
|
+
export function projectHetznerCompute(context, selection, sshPublicKey) {
|
|
5
|
+
const identity = getHetznerIdentity(context);
|
|
6
|
+
const suffix = createHash('sha256')
|
|
7
|
+
.update(`${context.projectId}:${context.environment}`)
|
|
8
|
+
.digest('hex')
|
|
9
|
+
.slice(0, 10);
|
|
10
|
+
const prefix = `ankh-${context.environment}-${suffix}`;
|
|
11
|
+
const base = {
|
|
12
|
+
location: selection.location,
|
|
13
|
+
serverType: selection.serverType ?? 'cx23',
|
|
14
|
+
image: selection.image ?? 'ubuntu-24.04',
|
|
15
|
+
sshUser: selection.ssh?.user ?? 'root',
|
|
16
|
+
sshPort: selection.ssh?.port ?? 22,
|
|
17
|
+
sshPublicKey,
|
|
18
|
+
};
|
|
19
|
+
const resource = (resourceId) => ({
|
|
20
|
+
owner: createHetznerOwner(identity, resourceId),
|
|
21
|
+
name: `${prefix}-${resourceId}`,
|
|
22
|
+
configurationHash: createHash('sha256')
|
|
23
|
+
.update(JSON.stringify({ ...base, resourceId }))
|
|
24
|
+
.digest('hex')
|
|
25
|
+
.slice(0, 32),
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
identity,
|
|
29
|
+
...base,
|
|
30
|
+
network: resource('network'),
|
|
31
|
+
firewall: resource('firewall'),
|
|
32
|
+
sshKey: resource('ssh-key'),
|
|
33
|
+
server: resource('server'),
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=projectHetznerCompute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projectHetznerCompute.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/projectHetznerCompute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEnF,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CACnC,OAA8B,EAC9B,SAA2C,EAC3C,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AE,QAAQ,CAAC,QAAQ,CAAC;KAC3B,CAAC;AACJ,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\n\nimport type { InfraComputeSelection, InfraExecutionContext } from '@ankhorage/contracts/infra';\n\nimport type { HetznerDesiredCompute, HetznerResourceId } from '../../../types/hetznerCompute';\nimport { createHetznerOwner, getHetznerIdentity } from '../utils/hetznerOwnership';\n\n/** Project one low-cost, single-node Hetzner compute target without runtime-specific behavior. */\nexport function projectHetznerCompute(\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n sshPublicKey: string,\n): HetznerDesiredCompute {\n const identity = getHetznerIdentity(context);\n const suffix = createHash('sha256')\n .update(`${context.projectId}:${context.environment}`)\n .digest('hex')\n .slice(0, 10);\n const prefix = `ankh-${context.environment}-${suffix}`;\n const base = {\n location: selection.location,\n serverType: selection.serverType ?? 'cx23',\n image: selection.image ?? 'ubuntu-24.04',\n sshUser: selection.ssh?.user ?? 'root',\n sshPort: selection.ssh?.port ?? 22,\n sshPublicKey,\n };\n const resource = (resourceId: HetznerResourceId) => ({\n owner: createHetznerOwner(identity, resourceId),\n name: `${prefix}-${resourceId}`,\n configurationHash: createHash('sha256')\n .update(JSON.stringify({ ...base, resourceId }))\n .digest('hex')\n .slice(0, 32),\n });\n return {\n identity,\n ...base,\n network: resource('network'),\n firewall: resource('firewall'),\n sshKey: resource('ssh-key'),\n server: resource('server'),\n };\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraControlPlaneCredentialRef, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
interface HetznerCredentials {
|
|
3
|
+
readonly token: string;
|
|
4
|
+
readonly sshPublicKey: string;
|
|
5
|
+
readonly sshReference: InfraControlPlaneCredentialRef;
|
|
6
|
+
}
|
|
7
|
+
/** Resolve bootstrap credentials transiently and expose only fields needed by the compute boundary. */
|
|
8
|
+
export declare function resolveHetznerCredentialsAsync(context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<HetznerCredentials>>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=resolveHetznerCredentialsAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveHetznerCredentialsAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/resolveHetznerCredentialsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,8BAA8B,EAC9B,qBAAqB,EACrB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,YAAY,EAAE,8BAA8B,CAAC;CACvD;AAKD,uGAAuG;AACvG,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CA8B1C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const DEFAULT_API_CREDENTIAL = { source: 'control-plane', name: 'HCLOUD_TOKEN' };
|
|
2
|
+
const DEFAULT_SSH_CREDENTIAL = { source: 'control-plane', name: 'HETZNER_SSH' };
|
|
3
|
+
/** Resolve bootstrap credentials transiently and expose only fields needed by the compute boundary. */
|
|
4
|
+
export async function resolveHetznerCredentialsAsync(context, selection) {
|
|
5
|
+
const apiReference = selection.credentials ?? DEFAULT_API_CREDENTIAL;
|
|
6
|
+
const sshReference = selection.ssh?.credentials ?? DEFAULT_SSH_CREDENTIAL;
|
|
7
|
+
const [api, ssh] = await Promise.all([
|
|
8
|
+
context.credentials.resolveAsync(apiReference),
|
|
9
|
+
context.credentials.resolveAsync(sshReference),
|
|
10
|
+
]);
|
|
11
|
+
if (!api.ok)
|
|
12
|
+
return api;
|
|
13
|
+
if (!ssh.ok)
|
|
14
|
+
return ssh;
|
|
15
|
+
const { token } = api.value;
|
|
16
|
+
const { publicKey } = ssh.value;
|
|
17
|
+
const { privateKey } = ssh.value;
|
|
18
|
+
if (!isNonEmpty(token) || !isNonEmpty(publicKey) || !isNonEmpty(privateKey)) {
|
|
19
|
+
return {
|
|
20
|
+
ok: false,
|
|
21
|
+
diagnostics: [
|
|
22
|
+
{
|
|
23
|
+
severity: 'error',
|
|
24
|
+
code: 'hetzner-credentials-invalid',
|
|
25
|
+
message: 'Hetzner requires a token plus matching publicKey/privateKey SSH credential fields.',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
ok: true,
|
|
32
|
+
value: { token, sshPublicKey: publicKey, sshReference },
|
|
33
|
+
diagnostics: [],
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function isNonEmpty(value) {
|
|
37
|
+
return value !== undefined && value.trim().length > 0;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=resolveHetznerCredentialsAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveHetznerCredentialsAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/resolveHetznerCredentialsAsync.ts"],"names":[],"mappings":"AAaA,MAAM,sBAAsB,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,cAAc,EAAW,CAAC;AAC1F,MAAM,sBAAsB,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,aAAa,EAAW,CAAC;AAEzF,uGAAuG;AACvG,MAAM,CAAC,KAAK,UAAU,8BAA8B,CAClD,OAA8B,EAC9B,SAA2C;IAE3C,MAAM,YAAY,GAAG,SAAS,CAAC,WAAW,IAAI,sBAAsB,CAAC;IACrE,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,EAAE,WAAW,IAAI,sBAAsB,CAAC;IAC1E,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACnC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC;QAC9C,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,YAAY,CAAC;KAC/C,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,GAAG,CAAC;IACxB,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,GAAG,CAAC;IACxB,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAC5B,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAChC,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IACjC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5E,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW,EAAE;gBACX;oBACE,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,6BAA6B;oBACnC,OAAO,EACL,oFAAoF;iBACvF;aACF;SACF,CAAC;IACJ,CAAC;IACD,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE;QACvD,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC;AAED,SAAS,UAAU,CAAC,KAAyB;IAC3C,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import type {\n InfraComputeSelection,\n InfraControlPlaneCredentialRef,\n InfraExecutionContext,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\ninterface HetznerCredentials {\n readonly token: string;\n readonly sshPublicKey: string;\n readonly sshReference: InfraControlPlaneCredentialRef;\n}\n\nconst DEFAULT_API_CREDENTIAL = { source: 'control-plane', name: 'HCLOUD_TOKEN' } as const;\nconst DEFAULT_SSH_CREDENTIAL = { source: 'control-plane', name: 'HETZNER_SSH' } as const;\n\n/** Resolve bootstrap credentials transiently and expose only fields needed by the compute boundary. */\nexport async function resolveHetznerCredentialsAsync(\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n): Promise<InfraResult<HetznerCredentials>> {\n const apiReference = selection.credentials ?? DEFAULT_API_CREDENTIAL;\n const sshReference = selection.ssh?.credentials ?? DEFAULT_SSH_CREDENTIAL;\n const [api, ssh] = await Promise.all([\n context.credentials.resolveAsync(apiReference),\n context.credentials.resolveAsync(sshReference),\n ]);\n if (!api.ok) return api;\n if (!ssh.ok) return ssh;\n const { token } = api.value;\n const { publicKey } = ssh.value;\n const { privateKey } = ssh.value;\n if (!isNonEmpty(token) || !isNonEmpty(publicKey) || !isNonEmpty(privateKey)) {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'hetzner-credentials-invalid',\n message:\n 'Hetzner requires a token plus matching publicKey/privateKey SSH credential fields.',\n },\n ],\n };\n }\n return {\n ok: true,\n value: { token, sshPublicKey: publicKey, sshReference },\n diagnostics: [],\n };\n}\n\nfunction isNonEmpty(value: string | undefined): value is string {\n return value !== undefined && value.trim().length > 0;\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InfraComputeSelection, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
3
|
+
/** Validate selection and control-plane access without creating cloud resources. */
|
|
4
|
+
export declare function validateHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<null>>;
|
|
5
|
+
export declare function invalidSelection(): InfraResult<never>;
|
|
6
|
+
//# sourceMappingURL=validateHetznerComputeAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateHetznerComputeAsync.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/validateHetznerComputeAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,WAAW,EACZ,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGrE,oFAAoF;AACpF,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,GAC1C,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAK5B;AAED,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,KAAK,CAAC,CAWrD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
2
|
+
/** Validate selection and control-plane access without creating cloud resources. */
|
|
3
|
+
export async function validateHetznerComputeAsync(api, context, selection) {
|
|
4
|
+
if (context.desired.deployment.compute.provider !== 'hetzner')
|
|
5
|
+
return invalidSelection();
|
|
6
|
+
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
7
|
+
if (!credentials.ok)
|
|
8
|
+
return credentials;
|
|
9
|
+
return api.validateAsync(credentials.value.token, selection, context.signal);
|
|
10
|
+
}
|
|
11
|
+
export function invalidSelection() {
|
|
12
|
+
return {
|
|
13
|
+
ok: false,
|
|
14
|
+
diagnostics: [
|
|
15
|
+
{
|
|
16
|
+
severity: 'error',
|
|
17
|
+
code: 'hetzner-selection-invalid',
|
|
18
|
+
message: 'Hetzner compute requires the canonical Hetzner selection.',
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=validateHetznerComputeAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/validateHetznerComputeAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAElF,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,GAAoB,EACpB,OAA8B,EAC9B,SAA2C;IAE3C,IAAI,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,gBAAgB,EAAE,CAAC;IACzF,MAAM,WAAW,GAAG,MAAM,8BAA8B,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC7E,IAAI,CAAC,WAAW,CAAC,EAAE;QAAE,OAAO,WAAW,CAAC;IACxC,OAAO,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI,EAAE,2BAA2B;gBACjC,OAAO,EAAE,2DAA2D;aACrE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type {\n InfraComputeSelection,\n InfraExecutionContext,\n InfraResult,\n} from '@ankhorage/contracts/infra';\n\nimport type { HetznerCloudApi } from '../../../types/hetznerCompute';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';\n\n/** Validate selection and control-plane access without creating cloud resources. */\nexport async function validateHetznerComputeAsync(\n api: HetznerCloudApi,\n context: InfraExecutionContext,\n selection: InfraComputeSelection<'hetzner'>,\n): Promise<InfraResult<null>> {\n if (context.desired.deployment.compute.provider !== 'hetzner') return invalidSelection();\n const credentials = await resolveHetznerCredentialsAsync(context, selection);\n if (!credentials.ok) return credentials;\n return api.validateAsync(credentials.value.token, selection, context.signal);\n}\n\nexport function invalidSelection(): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'hetzner-selection-invalid',\n message: 'Hetzner compute requires the canonical Hetzner selection.',\n },\n ],\n };\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InfraComputeAdapter } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { HetznerAdapterOptions } from '../../../types/hetznerCompute';
|
|
3
|
+
/***
|
|
4
|
+
* Create the canonical Hetzner Cloud compute adapter.
|
|
5
|
+
*
|
|
6
|
+
* The default composition uses the authenticated Cloud REST API and a shell-free SSH host-key
|
|
7
|
+
* probe. Provider API and SSH credentials remain transient execution inputs.
|
|
8
|
+
*
|
|
9
|
+
* @readme
|
|
10
|
+
*/
|
|
11
|
+
export declare function createInfraAdapter(options?: HetznerAdapterOptions): InfraComputeAdapter<'hetzner'>;
|
|
12
|
+
//# sourceMappingURL=createInfraAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInfraAdapter.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/composition/createInfraAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAU3E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,qBAA0B,GAClC,mBAAmB,CAAC,SAAS,CAAC,CAchC"}
|