@ankhorage/infra-hetzner 0.3.2 → 0.3.4
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/README.md +18 -11
- package/dist/constants/infra.d.ts +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.d.ts +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.d.ts.map +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js +2 -2
- package/dist/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js.map +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.d.ts +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.d.ts.map +1 -1
- package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js.map +1 -1
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.d.ts +1 -1
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.d.ts.map +1 -1
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.js +1 -1
- package/dist/features/cloud-compute/adapters/outbound/hetznerApiValues.js.map +1 -1
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.js +1 -1
- package/dist/features/cloud-compute/application/createHetznerComputeSnapshotAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.js +4 -4
- package/dist/features/cloud-compute/application/destroyHetznerComputeAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.js +3 -3
- package/dist/features/cloud-compute/application/ensureHetznerComputeAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.js +4 -4
- package/dist/features/cloud-compute/application/getHetznerComputeStatusAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/hetznerResults.d.ts +1 -1
- package/dist/features/cloud-compute/application/hetznerResults.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/hetznerResults.js +1 -1
- package/dist/features/cloud-compute/application/hetznerResults.js.map +1 -1
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.js +3 -3
- package/dist/features/cloud-compute/application/inspectHetznerComputeAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.js +2 -2
- package/dist/features/cloud-compute/application/planHetznerComputeAsync.js.map +1 -1
- package/dist/features/cloud-compute/application/projectHetznerCompute.d.ts +1 -1
- package/dist/features/cloud-compute/application/projectHetznerCompute.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/projectHetznerCompute.js +1 -1
- package/dist/features/cloud-compute/application/projectHetznerCompute.js.map +1 -1
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.d.ts +1 -1
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.d.ts.map +1 -1
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.js +1 -1
- package/dist/features/cloud-compute/application/validateHetznerComputeAsync.js.map +1 -1
- package/dist/features/cloud-compute/composition/createInfraAdapter.d.ts +1 -1
- package/dist/features/cloud-compute/composition/createInfraAdapter.d.ts.map +1 -1
- package/dist/features/cloud-compute/composition/createInfraAdapter.js +9 -9
- package/dist/features/cloud-compute/composition/createInfraAdapter.js.map +1 -1
- package/dist/features/cloud-compute/utils/hetznerOwnership.d.ts +1 -1
- package/dist/features/cloud-compute/utils/hetznerOwnership.d.ts.map +1 -1
- package/dist/features/cloud-compute/utils/hetznerOwnership.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
<!-- markdownlint-disable MD013 MD033 -->
|
|
2
2
|
<!-- This file is generated by Paradox. Do not edit manually. -->
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
# Ankhorage Hetzner Infrastructure
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
|
-
Hetzner Cloud compute adapter
|
|
8
|
+
Provides a Hetzner Cloud compute adapter with REST-backed lifecycle operations and shell-free SSH host verification.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Translate provider-neutral compute intent into Hetzner Cloud server lifecycle behavior without leaking provider credentials into portable state.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
- [Architecture overview](././paradox/diagrams/architecture-overview.mmd)
|
|
16
|
-
- [Module relationships](././paradox/diagrams/module-relationships.mmd)
|
|
17
|
-
- [Export graph](././paradox/diagrams/export-graph.mmd)
|
|
18
|
-
- [createInfraAdapter sequence](././paradox/diagrams/sequences/create-infra-adapter.mmd)
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
Open `./paradox/index.html` locally in your browser to browse the complete documentation.
|
|
19
15
|
|
|
20
16
|
## Public API
|
|
21
17
|
|
|
@@ -38,3 +34,14 @@ Source: `src/features/cloud-compute/composition/createInfraAdapter.ts:22:1`
|
|
|
38
34
|
Related symbols: `HetznerAdapterOptions`
|
|
39
35
|
|
|
40
36
|
</details>
|
|
37
|
+
|
|
38
|
+
## Contributors
|
|
39
|
+
|
|
40
|
+
<!-- readme: contributors -start -->
|
|
41
|
+
<!-- readme: contributors -end -->
|
|
42
|
+
|
|
43
|
+
## Donation
|
|
44
|
+
|
|
45
|
+
If this project is useful to you, you can support its continued development.
|
|
46
|
+
|
|
47
|
+
[Support @ankhorage](https://github.com/sponsors/ankhorage)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Canonical Contracts-backed identity used for adapter discovery and conformance. */
|
|
2
2
|
export declare const infraAdapterDescriptor: {
|
|
3
3
|
readonly id: "hetzner";
|
|
4
|
-
readonly package: "@ankhorage/hetzner";
|
|
4
|
+
readonly package: "@ankhorage/infra-hetzner";
|
|
5
5
|
readonly kind: "compute";
|
|
6
6
|
readonly configVersion: 1;
|
|
7
7
|
readonly capabilities: readonly ["compute"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HetznerCloudApi, HetznerFetchApiOptions } from '../../../../types/hetznerCompute';
|
|
1
|
+
import type { HetznerCloudApi, HetznerFetchApiOptions } from '../../../../types/hetznerCompute.js';
|
|
2
2
|
/** Create the concrete authenticated Hetzner Cloud REST adapter. */
|
|
3
3
|
export declare function createFetchHetznerCloudApi(options?: HetznerFetchApiOptions): HetznerCloudApi;
|
|
4
4
|
//# sourceMappingURL=createFetchHetznerCloudApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFetchHetznerCloudApi.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAGf,sBAAsB,EAIvB,MAAM,
|
|
1
|
+
{"version":3,"file":"createFetchHetznerCloudApi.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAGf,sBAAsB,EAIvB,MAAM,qCAAqC,CAAC;AAsB7C,oEAAoE;AACpE,wBAAgB,0BAA0B,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAahG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getHetznerLabels } from '../../utils/hetznerOwnership';
|
|
2
|
-
import { apiFailure, apiSuccess, createHetznerResourceBody, hasHetznerDrift, hasNamedHetznerResource, parseHetznerResource, readActionId, readActionStatus, readCreatedHetznerResource, readHetznerList, } from './hetznerApiValues';
|
|
1
|
+
import { getHetznerLabels } from '../../utils/hetznerOwnership.js';
|
|
2
|
+
import { apiFailure, apiSuccess, createHetznerResourceBody, hasHetznerDrift, hasNamedHetznerResource, parseHetznerResource, readActionId, readActionStatus, readCreatedHetznerResource, readHetznerList, } from './hetznerApiValues.js';
|
|
3
3
|
const HETZNER_RESOURCE_LISTS = [
|
|
4
4
|
['networks', 'network'],
|
|
5
5
|
['firewalls', 'firewall'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createFetchHetznerCloudApi.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EACL,UAAU,EACV,UAAU,EACV,yBAAyB,EACzB,eAAe,EACf,uBAAuB,EACvB,oBAAoB,EACpB,YAAY,EACZ,gBAAgB,EAChB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,sBAAsB,GAAG;IAC7B,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,WAAW,EAAE,UAAU,CAAC;IACzB,CAAC,UAAU,EAAE,SAAS,CAAC;IACvB,CAAC,SAAS,EAAE,QAAQ,CAAC;CACb,CA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M,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,EAAE,EAAE;gBAC7D,MAAM;gBACN,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;iBACtE;gBACD,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7D,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;aAC5C,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,CAAC,EAAE;gBAAE,OAAO,UAAU,CAAC,4BAA4B,CAAC,CAAC;YAClE,OAAO,UAAU,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5E,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,UAAU,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { InfraComputeSelection, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n HetznerCloudApi,\n HetznerCloudObservation,\n HetznerDesiredCompute,\n HetznerFetchApiOptions,\n HetznerProjectIdentity,\n HetznerResourceId,\n HetznerResourceObservation,\n} from '../../../../types/hetznerCompute';\nimport { getHetznerLabels } from '../../utils/hetznerOwnership';\nimport {\n apiFailure,\n apiSuccess,\n createHetznerResourceBody,\n hasHetznerDrift,\n hasNamedHetznerResource,\n parseHetznerResource,\n readActionId,\n readActionStatus,\n readCreatedHetznerResource,\n readHetznerList,\n} from './hetznerApiValues';\n\nconst HETZNER_RESOURCE_LISTS = [\n ['networks', 'network'],\n ['firewalls', 'firewall'],\n ['ssh_keys', 'ssh-key'],\n ['servers', 'server'],\n] as const;\n\n/** Create the concrete authenticated Hetzner Cloud REST adapter. */\nexport function createFetchHetznerCloudApi(options: HetznerFetchApiOptions = {}): HetznerCloudApi {\n const client = new Client(\n options.endpoint ?? 'https://api.hetzner.cloud/v1',\n options.fetch ?? fetch,\n options.pollIntervalMs ?? 500,\n );\n return {\n validateAsync: (token, selection, signal) => client.validateAsync(token, selection, signal),\n inspectAsync: (token, identity, signal) => client.inspectAsync(token, identity, signal),\n reconcileAsync: (token, desired, signal) => client.reconcileAsync(token, desired, signal),\n destroyAsync: (token, identity, resourceIds, signal) =>\n client.destroyAsync(token, identity, resourceIds, signal),\n };\n}\n\nclass Client implements HetznerCloudApi {\n constructor(\n private readonly endpoint: string,\n private readonly fetcher: typeof fetch,\n private readonly pollIntervalMs: number,\n ) {}\n\n async validateAsync(\n token: string,\n selection: InfraComputeSelection<'hetzner'>,\n signal?: AbortSignal,\n ): Promise<InfraResult<null>> {\n const location = await this.requestAsync(\n token,\n 'GET',\n `/locations?name=${encodeURIComponent(selection.location)}`,\n undefined,\n signal,\n );\n if (!location.ok || !hasNamedHetznerResource(location.value, 'locations')) {\n return apiFailure('hetzner-location-invalid');\n }\n const serverType = await this.requestAsync(\n token,\n 'GET',\n `/server_types?name=${encodeURIComponent(selection.serverType ?? 'cx23')}`,\n undefined,\n signal,\n );\n if (!serverType.ok || !hasNamedHetznerResource(serverType.value, 'server_types')) {\n return apiFailure('hetzner-server-type-invalid');\n }\n const image = await this.requestAsync(\n token,\n 'GET',\n `/images?name=${encodeURIComponent(selection.image ?? 'ubuntu-24.04')}&type=system`,\n undefined,\n signal,\n );\n return image.ok && hasNamedHetznerResource(image.value, 'images')\n ? apiSuccess(null)\n : apiFailure('hetzner-image-invalid');\n }\n\n async inspectAsync(\n token: string,\n identity: HetznerProjectIdentity,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const selector = encodeURIComponent(\n Object.entries(getHetznerLabels(identity))\n .map(([key, value]) => `${key}=${value}`)\n .join(','),\n );\n const requests = await this.listOwnedAsync(token, selector, signal);\n const failed = requests.find(({ result }) => !result.ok);\n if (failed !== undefined) return apiFailure('hetzner-api-request-failed');\n const resources: HetznerResourceObservation[] = [];\n const kinds = HETZNER_RESOURCE_LISTS.map(([, kind]) => kind);\n for (const { key, kind, result } of requests) {\n if (!result.ok) return result;\n const list = readHetznerList(result.value, key);\n if (list === undefined) return apiFailure('hetzner-api-response-invalid');\n for (const value of list) {\n const parsed = parseHetznerResource(value, kind);\n if (parsed === undefined) return apiFailure('hetzner-api-response-invalid');\n resources.push(parsed);\n }\n }\n for (const kind of kinds) {\n if (resources.filter(({ resourceId }) => resourceId === kind).length > 1) {\n return apiFailure('hetzner-ownership-collision');\n }\n }\n return apiSuccess({ resources });\n }\n\n private listOwnedAsync(token: string, selector: string, signal?: AbortSignal) {\n return Promise.all(\n HETZNER_RESOURCE_LISTS.map(async ([key, kind]) => ({\n key,\n kind,\n result: await this.requestAsync(\n token,\n 'GET',\n `/${key}?label_selector=${selector}&per_page=50`,\n undefined,\n signal,\n ),\n })),\n );\n }\n\n async reconcileAsync(\n token: string,\n desired: HetznerDesiredCompute,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const observed = await this.inspectAsync(token, desired.identity, signal);\n if (!observed.ok) return observed;\n if (hasHetznerDrift(observed.value, desired)) {\n return apiFailure('hetzner-replacement-requires-destroy');\n }\n const byId = new Map(\n observed.value.resources.map((resource) => [resource.resourceId, resource]),\n );\n let network = byId.get('network');\n if (network === undefined) {\n const created = await this.createAsync(token, 'network', desired, undefined, signal);\n if (!created.ok) return created;\n network = created.value;\n }\n let firewall = byId.get('firewall');\n if (firewall === undefined) {\n const created = await this.createAsync(token, 'firewall', desired, undefined, signal);\n if (!created.ok) return created;\n firewall = created.value;\n }\n let sshKey = byId.get('ssh-key');\n if (sshKey === undefined) {\n const created = await this.createAsync(token, 'ssh-key', desired, undefined, signal);\n if (!created.ok) return created;\n sshKey = created.value;\n }\n if (byId.get('server') === undefined) {\n const created = await this.createAsync(\n token,\n 'server',\n desired,\n { network, firewall, sshKey },\n signal,\n );\n if (!created.ok) return created;\n }\n return this.inspectAsync(token, desired.identity, signal);\n }\n\n async destroyAsync(\n token: string,\n identity: HetznerProjectIdentity,\n resourceIds: readonly HetznerResourceId[],\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const observed = await this.inspectAsync(token, identity, signal);\n if (!observed.ok) return observed;\n const byId = new Map(\n observed.value.resources.map((resource) => [resource.resourceId, resource]),\n );\n for (const resourceId of resourceIds) {\n const resource = byId.get(resourceId);\n if (resource === undefined) continue;\n const endpoint = resourceId === 'ssh-key' ? 'ssh_keys' : `${resourceId}s`;\n const removed = await this.requestAsync(\n token,\n 'DELETE',\n `/${endpoint}/${encodeURIComponent(resource.externalId)}`,\n undefined,\n signal,\n );\n if (!removed.ok) return removed;\n const actionId = readActionId(removed.value);\n if (actionId !== undefined) {\n const waited = await this.waitForActionAsync(token, actionId, signal);\n if (!waited.ok) return waited;\n }\n }\n return this.inspectAsync(token, identity, signal);\n }\n\n private async createAsync(\n token: string,\n resourceId: HetznerResourceId,\n desired: HetznerDesiredCompute,\n dependencies?: Readonly<Record<'network' | 'firewall' | 'sshKey', HetznerResourceObservation>>,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerResourceObservation>> {\n const resource = desired[resourceId === 'ssh-key' ? 'sshKey' : resourceId];\n const labels = getHetznerLabels(desired.identity, resourceId, resource.configurationHash);\n const body = createHetznerResourceBody(resourceId, desired, labels, dependencies);\n if (body === undefined) return apiFailure('hetzner-dependency-missing');\n const endpoint = resourceId === 'ssh-key' ? 'ssh_keys' : `${resourceId}s`;\n const response = await this.requestAsync(token, 'POST', `/${endpoint}`, body, signal);\n if (!response.ok) return response;\n const actionId = readActionId(response.value);\n if (actionId !== undefined) {\n const waited = await this.waitForActionAsync(token, actionId, signal);\n if (!waited.ok) return waited;\n }\n const value = readCreatedHetznerResource(response.value, resourceId);\n const parsed = value === undefined ? undefined : parseHetznerResource(value, resourceId);\n return parsed === undefined ? apiFailure('hetzner-api-response-invalid') : apiSuccess(parsed);\n }\n\n private async waitForActionAsync(\n token: string,\n actionId: number,\n signal?: AbortSignal,\n ): Promise<InfraResult<null>> {\n for (let attempt = 0; attempt < 240; attempt += 1) {\n if (signal?.aborted === true) return apiFailure('hetzner-action-aborted');\n const response = await this.requestAsync(\n token,\n 'GET',\n `/actions/${actionId}`,\n undefined,\n signal,\n );\n if (!response.ok) return response;\n const status = readActionStatus(response.value);\n if (status === 'success') return apiSuccess(null);\n if (status === 'error') return apiFailure('hetzner-action-failed');\n await new Promise((resolve) => setTimeout(resolve, this.pollIntervalMs));\n }\n return apiFailure('hetzner-action-timeout');\n }\n\n private async requestAsync(\n token: string,\n method: 'GET' | 'POST' | 'DELETE',\n path: string,\n body?: Readonly<Record<string, unknown>>,\n signal?: AbortSignal,\n ): Promise<InfraResult<unknown>> {\n try {\n const response = await this.fetcher(`${this.endpoint}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${token}`,\n ...(body === undefined ? {} : { 'Content-Type': 'application/json' }),\n },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n ...(signal === undefined ? {} : { signal }),\n });\n if (!response.ok) return apiFailure('hetzner-api-request-failed');\n return apiSuccess(response.status === 204 ? null : await response.json());\n } catch {\n return apiFailure('hetzner-api-request-failed');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createFetchHetznerCloudApi.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EACL,UAAU,EACV,UAAU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'@ankhorage/contracts/infra';\n\nimport type {\n HetznerCloudApi,\n HetznerCloudObservation,\n HetznerDesiredCompute,\n HetznerFetchApiOptions,\n HetznerProjectIdentity,\n HetznerResourceId,\n HetznerResourceObservation,\n} from '../../../../types/hetznerCompute.js';\nimport { getHetznerLabels } from '../../utils/hetznerOwnership.js';\nimport {\n apiFailure,\n apiSuccess,\n createHetznerResourceBody,\n hasHetznerDrift,\n hasNamedHetznerResource,\n parseHetznerResource,\n readActionId,\n readActionStatus,\n readCreatedHetznerResource,\n readHetznerList,\n} from './hetznerApiValues.js';\n\nconst HETZNER_RESOURCE_LISTS = [\n ['networks', 'network'],\n ['firewalls', 'firewall'],\n ['ssh_keys', 'ssh-key'],\n ['servers', 'server'],\n] as const;\n\n/** Create the concrete authenticated Hetzner Cloud REST adapter. */\nexport function createFetchHetznerCloudApi(options: HetznerFetchApiOptions = {}): HetznerCloudApi {\n const client = new Client(\n options.endpoint ?? 'https://api.hetzner.cloud/v1',\n options.fetch ?? fetch,\n options.pollIntervalMs ?? 500,\n );\n return {\n validateAsync: (token, selection, signal) => client.validateAsync(token, selection, signal),\n inspectAsync: (token, identity, signal) => client.inspectAsync(token, identity, signal),\n reconcileAsync: (token, desired, signal) => client.reconcileAsync(token, desired, signal),\n destroyAsync: (token, identity, resourceIds, signal) =>\n client.destroyAsync(token, identity, resourceIds, signal),\n };\n}\n\nclass Client implements HetznerCloudApi {\n constructor(\n private readonly endpoint: string,\n private readonly fetcher: typeof fetch,\n private readonly pollIntervalMs: number,\n ) {}\n\n async validateAsync(\n token: string,\n selection: InfraComputeSelection<'hetzner'>,\n signal?: AbortSignal,\n ): Promise<InfraResult<null>> {\n const location = await this.requestAsync(\n token,\n 'GET',\n `/locations?name=${encodeURIComponent(selection.location)}`,\n undefined,\n signal,\n );\n if (!location.ok || !hasNamedHetznerResource(location.value, 'locations')) {\n return apiFailure('hetzner-location-invalid');\n }\n const serverType = await this.requestAsync(\n token,\n 'GET',\n `/server_types?name=${encodeURIComponent(selection.serverType ?? 'cx23')}`,\n undefined,\n signal,\n );\n if (!serverType.ok || !hasNamedHetznerResource(serverType.value, 'server_types')) {\n return apiFailure('hetzner-server-type-invalid');\n }\n const image = await this.requestAsync(\n token,\n 'GET',\n `/images?name=${encodeURIComponent(selection.image ?? 'ubuntu-24.04')}&type=system`,\n undefined,\n signal,\n );\n return image.ok && hasNamedHetznerResource(image.value, 'images')\n ? apiSuccess(null)\n : apiFailure('hetzner-image-invalid');\n }\n\n async inspectAsync(\n token: string,\n identity: HetznerProjectIdentity,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const selector = encodeURIComponent(\n Object.entries(getHetznerLabels(identity))\n .map(([key, value]) => `${key}=${value}`)\n .join(','),\n );\n const requests = await this.listOwnedAsync(token, selector, signal);\n const failed = requests.find(({ result }) => !result.ok);\n if (failed !== undefined) return apiFailure('hetzner-api-request-failed');\n const resources: HetznerResourceObservation[] = [];\n const kinds = HETZNER_RESOURCE_LISTS.map(([, kind]) => kind);\n for (const { key, kind, result } of requests) {\n if (!result.ok) return result;\n const list = readHetznerList(result.value, key);\n if (list === undefined) return apiFailure('hetzner-api-response-invalid');\n for (const value of list) {\n const parsed = parseHetznerResource(value, kind);\n if (parsed === undefined) return apiFailure('hetzner-api-response-invalid');\n resources.push(parsed);\n }\n }\n for (const kind of kinds) {\n if (resources.filter(({ resourceId }) => resourceId === kind).length > 1) {\n return apiFailure('hetzner-ownership-collision');\n }\n }\n return apiSuccess({ resources });\n }\n\n private listOwnedAsync(token: string, selector: string, signal?: AbortSignal) {\n return Promise.all(\n HETZNER_RESOURCE_LISTS.map(async ([key, kind]) => ({\n key,\n kind,\n result: await this.requestAsync(\n token,\n 'GET',\n `/${key}?label_selector=${selector}&per_page=50`,\n undefined,\n signal,\n ),\n })),\n );\n }\n\n async reconcileAsync(\n token: string,\n desired: HetznerDesiredCompute,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const observed = await this.inspectAsync(token, desired.identity, signal);\n if (!observed.ok) return observed;\n if (hasHetznerDrift(observed.value, desired)) {\n return apiFailure('hetzner-replacement-requires-destroy');\n }\n const byId = new Map(\n observed.value.resources.map((resource) => [resource.resourceId, resource]),\n );\n let network = byId.get('network');\n if (network === undefined) {\n const created = await this.createAsync(token, 'network', desired, undefined, signal);\n if (!created.ok) return created;\n network = created.value;\n }\n let firewall = byId.get('firewall');\n if (firewall === undefined) {\n const created = await this.createAsync(token, 'firewall', desired, undefined, signal);\n if (!created.ok) return created;\n firewall = created.value;\n }\n let sshKey = byId.get('ssh-key');\n if (sshKey === undefined) {\n const created = await this.createAsync(token, 'ssh-key', desired, undefined, signal);\n if (!created.ok) return created;\n sshKey = created.value;\n }\n if (byId.get('server') === undefined) {\n const created = await this.createAsync(\n token,\n 'server',\n desired,\n { network, firewall, sshKey },\n signal,\n );\n if (!created.ok) return created;\n }\n return this.inspectAsync(token, desired.identity, signal);\n }\n\n async destroyAsync(\n token: string,\n identity: HetznerProjectIdentity,\n resourceIds: readonly HetznerResourceId[],\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerCloudObservation>> {\n const observed = await this.inspectAsync(token, identity, signal);\n if (!observed.ok) return observed;\n const byId = new Map(\n observed.value.resources.map((resource) => [resource.resourceId, resource]),\n );\n for (const resourceId of resourceIds) {\n const resource = byId.get(resourceId);\n if (resource === undefined) continue;\n const endpoint = resourceId === 'ssh-key' ? 'ssh_keys' : `${resourceId}s`;\n const removed = await this.requestAsync(\n token,\n 'DELETE',\n `/${endpoint}/${encodeURIComponent(resource.externalId)}`,\n undefined,\n signal,\n );\n if (!removed.ok) return removed;\n const actionId = readActionId(removed.value);\n if (actionId !== undefined) {\n const waited = await this.waitForActionAsync(token, actionId, signal);\n if (!waited.ok) return waited;\n }\n }\n return this.inspectAsync(token, identity, signal);\n }\n\n private async createAsync(\n token: string,\n resourceId: HetznerResourceId,\n desired: HetznerDesiredCompute,\n dependencies?: Readonly<Record<'network' | 'firewall' | 'sshKey', HetznerResourceObservation>>,\n signal?: AbortSignal,\n ): Promise<InfraResult<HetznerResourceObservation>> {\n const resource = desired[resourceId === 'ssh-key' ? 'sshKey' : resourceId];\n const labels = getHetznerLabels(desired.identity, resourceId, resource.configurationHash);\n const body = createHetznerResourceBody(resourceId, desired, labels, dependencies);\n if (body === undefined) return apiFailure('hetzner-dependency-missing');\n const endpoint = resourceId === 'ssh-key' ? 'ssh_keys' : `${resourceId}s`;\n const response = await this.requestAsync(token, 'POST', `/${endpoint}`, body, signal);\n if (!response.ok) return response;\n const actionId = readActionId(response.value);\n if (actionId !== undefined) {\n const waited = await this.waitForActionAsync(token, actionId, signal);\n if (!waited.ok) return waited;\n }\n const value = readCreatedHetznerResource(response.value, resourceId);\n const parsed = value === undefined ? undefined : parseHetznerResource(value, resourceId);\n return parsed === undefined ? apiFailure('hetzner-api-response-invalid') : apiSuccess(parsed);\n }\n\n private async waitForActionAsync(\n token: string,\n actionId: number,\n signal?: AbortSignal,\n ): Promise<InfraResult<null>> {\n for (let attempt = 0; attempt < 240; attempt += 1) {\n if (signal?.aborted === true) return apiFailure('hetzner-action-aborted');\n const response = await this.requestAsync(\n token,\n 'GET',\n `/actions/${actionId}`,\n undefined,\n signal,\n );\n if (!response.ok) return response;\n const status = readActionStatus(response.value);\n if (status === 'success') return apiSuccess(null);\n if (status === 'error') return apiFailure('hetzner-action-failed');\n await new Promise((resolve) => setTimeout(resolve, this.pollIntervalMs));\n }\n return apiFailure('hetzner-action-timeout');\n }\n\n private async requestAsync(\n token: string,\n method: 'GET' | 'POST' | 'DELETE',\n path: string,\n body?: Readonly<Record<string, unknown>>,\n signal?: AbortSignal,\n ): Promise<InfraResult<unknown>> {\n try {\n const response = await this.fetcher(`${this.endpoint}${path}`, {\n method,\n headers: {\n Authorization: `Bearer ${token}`,\n ...(body === undefined ? {} : { 'Content-Type': 'application/json' }),\n },\n ...(body === undefined ? {} : { body: JSON.stringify(body) }),\n ...(signal === undefined ? {} : { signal }),\n });\n if (!response.ok) return apiFailure('hetzner-api-request-failed');\n return apiSuccess(response.status === 204 ? null : await response.json());\n } catch {\n return apiFailure('hetzner-api-request-failed');\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HetznerHostKeyProbe } from '../../../../types/hetznerCompute';
|
|
1
|
+
import type { HetznerHostKeyProbe } from '../../../../types/hetznerCompute.js';
|
|
2
2
|
/** Create a shell-free SSH host-key probe for freshly provisioned public addresses. */
|
|
3
3
|
export declare function createNodeHetznerHostKeyProbe(): HetznerHostKeyProbe;
|
|
4
4
|
//# sourceMappingURL=createNodeHetznerHostKeyProbe.d.ts.map
|
package/dist/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNodeHetznerHostKeyProbe.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createNodeHetznerHostKeyProbe.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,uFAAuF;AACvF,wBAAgB,6BAA6B,IAAI,mBAAmB,CAEnE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createNodeHetznerHostKeyProbe.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,uFAAuF;AACvF,MAAM,UAAU,6BAA6B;IAC3C,OAAO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AAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI;gBACJ,OAAO,EAAE,6DAA6D;aACvE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { spawn } from 'node:child_process';\nimport { createHash } from 'node:crypto';\n\nimport type { InfraResult } from '@ankhorage/contracts/infra';\n\nimport type { HetznerHostKeyProbe } from '../../../../types/hetznerCompute';\n\n/** Create a shell-free SSH host-key probe for freshly provisioned public addresses. */\nexport function createNodeHetznerHostKeyProbe(): HetznerHostKeyProbe {\n return { fingerprintAsync };\n}\n\nasync function fingerprintAsync(\n host: string,\n port: number,\n signal?: AbortSignal,\n): Promise<InfraResult<string>> {\n const deadline = Date.now() + 120_000;\n while (Date.now() <= deadline) {\n if (signal?.aborted === true) return failure('hetzner-host-key-aborted');\n const scanned = await scanAsync(host, port, signal).catch(() => undefined);\n const fingerprint = scanned === undefined ? undefined : parseFingerprint(scanned);\n if (fingerprint !== undefined) {\n return { ok: true, value: fingerprint, diagnostics: [] };\n }\n await new Promise((resolve) => setTimeout(resolve, 1_000));\n }\n return failure('hetzner-host-key-timeout');\n}\n\nfunction scanAsync(host: string, port: number, signal?: AbortSignal): Promise<string> {\n return new Promise((resolve, reject) => {\n const child = spawn(\n 'ssh-keyscan',\n ['-T', '5', '-p', String(port), '-t', 'ed25519', '--', host],\n {\n shell: false,\n stdio: ['ignore', 'pipe', 'ignore'],\n ...(signal === undefined ? {} : { signal }),\n },\n );\n const output: Buffer[] = [];\n child.stdout.on('data', (chunk: Buffer) => output.push(chunk));\n child.once('error', reject);\n child.once('close', (code) =>\n code === 0\n ? resolve(Buffer.concat(output).toString('utf8'))\n : reject(new Error('scan failed')),\n );\n });\n}\n\nfunction parseFingerprint(output: string): string | undefined {\n for (const line of output.split('\\n')) {\n const fields = line.trim().split(/\\s+/u);\n if (fields[1] !== 'ssh-ed25519' || fields[2] === undefined) continue;\n try {\n const digest = createHash('sha256').update(Buffer.from(fields[2], 'base64')).digest('base64');\n return `SHA256:${digest.replace(/=+$/u, '')}`;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction failure(code: string): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code,\n message: 'The provisioned Hetzner SSH host key could not be verified.',\n },\n ],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"createNodeHetznerHostKeyProbe.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,uFAAuF;AACvF,MAAM,UAAU,6BAA6B;IAC3C,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,IAAY,EACZ,IAAY,EACZ,MAAoB;IAEpB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACtC,OAAO,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,MAAM,EAAE,OAAO,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC,0BAA0B,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC3E,MAAM,WAAW,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,C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AAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACjD,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CACrC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACtC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,aAAa,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS;YAAE,SAAS;QACrE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9F,OAAO,UAAU,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,OAAO,CAAC,IAAY;IAC3B,OAAO;QACL,EAAE,EAAE,KAAK;QACT,WAAW,EAAE;YACX;gBACE,QAAQ,EAAE,OAAO;gBACjB,IAAI;gBACJ,OAAO,EAAE,6DAA6D;aACvE;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { spawn } from 'node:child_process';\nimport { createHash } from 'node:crypto';\n\nimport type { InfraResult } from '@ankhorage/contracts/infra';\n\nimport type { HetznerHostKeyProbe } from '../../../../types/hetznerCompute.js';\n\n/** Create a shell-free SSH host-key probe for freshly provisioned public addresses. */\nexport function createNodeHetznerHostKeyProbe(): HetznerHostKeyProbe {\n return { fingerprintAsync };\n}\n\nasync function fingerprintAsync(\n host: string,\n port: number,\n signal?: AbortSignal,\n): Promise<InfraResult<string>> {\n const deadline = Date.now() + 120_000;\n while (Date.now() <= deadline) {\n if (signal?.aborted === true) return failure('hetzner-host-key-aborted');\n const scanned = await scanAsync(host, port, signal).catch(() => undefined);\n const fingerprint = scanned === undefined ? undefined : parseFingerprint(scanned);\n if (fingerprint !== undefined) {\n return { ok: true, value: fingerprint, diagnostics: [] };\n }\n await new Promise((resolve) => setTimeout(resolve, 1_000));\n }\n return failure('hetzner-host-key-timeout');\n}\n\nfunction scanAsync(host: string, port: number, signal?: AbortSignal): Promise<string> {\n return new Promise((resolve, reject) => {\n const child = spawn(\n 'ssh-keyscan',\n ['-T', '5', '-p', String(port), '-t', 'ed25519', '--', host],\n {\n shell: false,\n stdio: ['ignore', 'pipe', 'ignore'],\n ...(signal === undefined ? {} : { signal }),\n },\n );\n const output: Buffer[] = [];\n child.stdout.on('data', (chunk: Buffer) => output.push(chunk));\n child.once('error', reject);\n child.once('close', (code) =>\n code === 0\n ? resolve(Buffer.concat(output).toString('utf8'))\n : reject(new Error('scan failed')),\n );\n });\n}\n\nfunction parseFingerprint(output: string): string | undefined {\n for (const line of output.split('\\n')) {\n const fields = line.trim().split(/\\s+/u);\n if (fields[1] !== 'ssh-ed25519' || fields[2] === undefined) continue;\n try {\n const digest = createHash('sha256').update(Buffer.from(fields[2], 'base64')).digest('base64');\n return `SHA256:${digest.replace(/=+$/u, '')}`;\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nfunction failure(code: string): InfraResult<never> {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code,\n message: 'The provisioned Hetzner SSH host key could not be verified.',\n },\n ],\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudObservation, HetznerDesiredCompute, HetznerResourceId, HetznerResourceObservation } from '../../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudObservation, HetznerDesiredCompute, HetznerResourceId, HetznerResourceObservation } from '../../../../types/hetznerCompute.js';
|
|
3
3
|
export type HetznerListKey = 'networks' | 'firewalls' | 'ssh_keys' | 'servers';
|
|
4
4
|
export declare function createHetznerResourceBody(resourceId: HetznerResourceId, desired: HetznerDesiredCompute, labels: Readonly<Record<string, string>>, dependencies?: Readonly<Record<'network' | 'firewall' | 'sshKey', HetznerResourceObservation>>): Readonly<Record<string, unknown>> | undefined;
|
|
5
5
|
export declare function parseHetznerResource(value: unknown, resourceId: HetznerResourceId): HetznerResourceObservation | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hetznerApiValues.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/hetznerApiValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,
|
|
1
|
+
{"version":3,"file":"hetznerApiValues.d.ts","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/hetznerApiValues.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,KAAK,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,EACjB,0BAA0B,EAC3B,MAAM,qCAAqC,CAAC;AAG7C,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAE/E,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,iBAAiB,EAC7B,OAAO,EAAE,qBAAqB,EAC9B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EACxC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,GAAG,UAAU,GAAG,QAAQ,EAAE,0BAA0B,CAAC,CAAC,GAC7F,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CA2C/C;AAED,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,iBAAiB,GAC5B,0BAA0B,GAAG,SAAS,CAiBxC;AAED,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,uBAAuB,EACjC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAUT;AAED,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,cAAc,GAClB,SAAS,OAAO,EAAE,GAAG,SAAS,CAWhC;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,iBAAiB,GAC5B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAW/C;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAI/D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAInE;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,WAAW,GAAG,cAAc,GAAG,QAAQ,GAC3C,OAAO,CAST;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAEtD;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,CAK3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hetznerApiValues.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/hetznerApiValues.ts"],"names":[],"mappings":"AAQA,OAAO,EA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OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,OAAO,CAAC;IAC9E,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,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"]}
|
|
1
|
+
{"version":3,"file":"hetznerApiValues.js","sourceRoot":"","sources":["../../../../../src/features/cloud-compute/adapters/outbound/hetznerApiValues.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAIjE,MAAM,UAAU,yBAAyB,CACvC,UAA6B,EAC7B,OAA8B,EAC9B,MAAwC,EACxC,YAA8F;IAE9F,QAAQ,UAAU,EAAE,CAAC;QACnB,KAAK,SAAS;YACZ,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,IAAI;gBAC1B,QAAQ,EAAE,cAAc;gBACxB,OAAO,EAAE;oBACP;wBACE,IAAI,EAAE,OAAO;wBACb,YAAY,EAAE,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC;wBAC9C,QAAQ,EAAE,cAAc;qBACzB;iBACF;gBACD,MAAM;aACP,CAAC;QACJ,KAAK,UAAU;YACb,OAAO;gBACL,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAC3B,MAAM;gBACN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AAI,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.js';\nimport { HETZNER_LABELS } from '../../utils/hetznerOwnership.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSnapshot, InfraControlPlaneCredentialRef, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudObservation, HetznerDesiredCompute, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudObservation, HetznerDesiredCompute, HetznerHostKeyProbe } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/*** Convert observed owned Cloud resources into a portable read-only compute snapshot. */
|
|
4
4
|
export declare function createHetznerComputeSnapshotAsync(hostKeyProbe: HetznerHostKeyProbe, desired: HetznerDesiredCompute, sshReference: InfraControlPlaneCredentialRef, observation: HetznerCloudObservation, signal?: AbortSignal): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
5
|
//# sourceMappingURL=createHetznerComputeSnapshotAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAG1C,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { toOwnedResources, toPublicOutputs } from './hetznerResults';
|
|
1
|
+
import { toOwnedResources, toPublicOutputs } from './hetznerResults.js';
|
|
2
2
|
/*** Convert observed owned Cloud resources into a portable read-only compute snapshot. */
|
|
3
3
|
export async function createHetznerComputeSnapshotAsync(hostKeyProbe, desired, sshReference, observation, signal) {
|
|
4
4
|
const server = observation.resources.find(({ resourceId }) => resourceId === 'server');
|
|
@@ -1 +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,
|
|
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,qBAAqB,CAAC;AAExE,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.js';\nimport { toOwnedResources, toPublicOutputs } from './hetznerResults.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraDestroyRequest, InfraExecutionContext, InfraReconcileResult, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Delete exact owned compute resources only after project/environment confirmation. */
|
|
4
4
|
export declare function destroyHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, request: InfraDestroyRequest): Promise<InfraResult<InfraReconcileResult>>;
|
|
5
5
|
//# sourceMappingURL=destroyHetznerComputeAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAM3F,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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
2
|
-
import { toOwnedResources, toPublicOutputs } from './hetznerResults';
|
|
3
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
-
import { invalidSelection } from './validateHetznerComputeAsync';
|
|
1
|
+
import { getHetznerIdentity } from '../utils/hetznerOwnership.js';
|
|
2
|
+
import { toOwnedResources, toPublicOutputs } from './hetznerResults.js';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
4
|
+
import { invalidSelection } from './validateHetznerComputeAsync.js';
|
|
5
5
|
/** Delete exact owned compute resources only after project/environment confirmation. */
|
|
6
6
|
export async function destroyHetznerComputeAsync(api, context, request) {
|
|
7
7
|
if (!isConfirmed(context, request))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"destroyHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/destroyHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"destroyHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/destroyHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,GAAoB,EACpB,OAA8B,EAC9B,OAA4B;IAE5B,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC;QAAE,OAAO,WAAW,EAAE,CAAC;IACzD,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,OAAO,GAAG,MAAM,GAAG,CAAC,YAAY,CACpC,WAAW,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EACR,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,CAAwC,EACnF,OAAO,CAAC,MAAM,CACf,CAAC;IACF,OAAO,OAAO,CAAC,EAAE;QACf,CAAC,CAAC;YACE,EAAE,EAAE,IAAI;YACR,KAAK,EAAE;gBACL,SAAS,EAAE,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;gBACpD,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,OAAO,CAAC,KAAK,CAAC;aAClD;YACD,WAAW,EAAE,EAAE;SAChB;QACH,CAAC,CAAC,OAAO,CAAC;AACd,CAAC;AAED,SAAS,WAAW,CAAC,OAA8B,EAAE,OAA4B;IAC/E,OAAO,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.js';\nimport { getHetznerIdentity } from '../utils/hetznerOwnership.js';\nimport { toOwnedResources, toPublicOutputs } from './hetznerResults.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\nimport { invalidSelection } from './validateHetznerComputeAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSelection, InfraComputeSnapshot, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Reconcile owned Cloud resources and return one verified portable SSH target. */
|
|
4
4
|
export declare function ensureHetznerComputeAsync(api: HetznerCloudApi, hostKeyProbe: HetznerHostKeyProbe, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
5
|
//# sourceMappingURL=ensureHetznerComputeAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAK7F,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';
|
|
2
|
-
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
3
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
1
|
+
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync.js';
|
|
2
|
+
import { projectHetznerCompute } from './projectHetznerCompute.js';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
4
4
|
/** Reconcile owned Cloud resources and return one verified portable SSH target. */
|
|
5
5
|
export async function ensureHetznerComputeAsync(api, hostKeyProbe, context, selection) {
|
|
6
6
|
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensureHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/ensureHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ensureHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/ensureHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,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.js';\nimport { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync.js';\nimport { projectHetznerCompute } from './projectHetznerCompute.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraExecutionContext, InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Read exact owned Hetzner resource status from a fresh execution context. */
|
|
4
4
|
export declare function getHetznerComputeStatusAsync(api: HetznerCloudApi, context: InfraExecutionContext): Promise<InfraResult<readonly InfraResourceStatus[]>>;
|
|
5
5
|
//# sourceMappingURL=getHetznerComputeStatusAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAMxE,+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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
2
|
-
import { toStatuses } from './hetznerResults';
|
|
3
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
4
|
-
import { invalidSelection } from './validateHetznerComputeAsync';
|
|
1
|
+
import { getHetznerIdentity } from '../utils/hetznerOwnership.js';
|
|
2
|
+
import { toStatuses } from './hetznerResults.js';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
4
|
+
import { invalidSelection } from './validateHetznerComputeAsync.js';
|
|
5
5
|
/** Read exact owned Hetzner resource status from a fresh execution context. */
|
|
6
6
|
export async function getHetznerComputeStatusAsync(api, context) {
|
|
7
7
|
const selection = context.desired.deployment.compute;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHetznerComputeStatusAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/getHetznerComputeStatusAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"getHetznerComputeStatusAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/getHetznerComputeStatusAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AACrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,+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.js';\nimport { getHetznerIdentity } from '../utils/hetznerOwnership.js';\nimport { toStatuses } from './hetznerResults.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\nimport { invalidSelection } from './validateHetznerComputeAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraOutput, InfraOwnedResource, InfraResourceStatus } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudObservation, HetznerProjectIdentity } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudObservation, HetznerProjectIdentity } from '../../../types/hetznerCompute.js';
|
|
3
3
|
export declare function toOwnedResources(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraOwnedResource[];
|
|
4
4
|
export declare function toStatuses(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraResourceStatus[];
|
|
5
5
|
export declare function toPublicOutputs(identity: HetznerProjectIdentity, observation: HetznerCloudObservation): readonly InfraOutput[];
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAG1C,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHetznerOwner } from '../utils/hetznerOwnership';
|
|
1
|
+
import { createHetznerOwner } from '../utils/hetznerOwnership.js';
|
|
2
2
|
export function toOwnedResources(identity, observation) {
|
|
3
3
|
return observation.resources.map((resource) => ({
|
|
4
4
|
...createHetznerOwner(identity, resource.resourceId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hetznerResults.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/hetznerResults.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"hetznerResults.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/hetznerResults.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAElE,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.js';\nimport { createHetznerOwner } from '../utils/hetznerOwnership.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSelection, InfraComputeSnapshot, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi, HetznerHostKeyProbe } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/*** Inspect exact owned Hetzner resources without creating, updating or deleting them. */
|
|
4
4
|
export declare function inspectHetznerComputeAsync(api: HetznerCloudApi, hostKeyProbe: HetznerHostKeyProbe, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<InfraComputeSnapshot>>;
|
|
5
5
|
//# sourceMappingURL=inspectHetznerComputeAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAK7F,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync';
|
|
2
|
-
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
3
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
1
|
+
import { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync.js';
|
|
2
|
+
import { projectHetznerCompute } from './projectHetznerCompute.js';
|
|
3
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
4
4
|
/*** Inspect exact owned Hetzner resources without creating, updating or deleting them. */
|
|
5
5
|
export async function inspectHetznerComputeAsync(api, hostKeyProbe, context, selection) {
|
|
6
6
|
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspectHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/inspectHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"inspectHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/inspectHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,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.js';\nimport { createHetznerComputeSnapshotAsync } from './createHetznerComputeSnapshotAsync.js';\nimport { projectHetznerCompute } from './projectHetznerCompute.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSelection, InfraExecutionContext, InfraPlanAction, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Compare exact owned Cloud state with the deterministic single-node projection. */
|
|
4
4
|
export declare function planHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<readonly InfraPlanAction[]>>;
|
|
5
5
|
//# sourceMappingURL=planHetznerComputeAsync.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAI3F,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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { projectHetznerCompute } from './projectHetznerCompute';
|
|
2
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
1
|
+
import { projectHetznerCompute } from './projectHetznerCompute.js';
|
|
2
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
3
3
|
/** Compare exact owned Cloud state with the deterministic single-node projection. */
|
|
4
4
|
export async function planHetznerComputeAsync(api, context, selection) {
|
|
5
5
|
const credentials = await resolveHetznerCredentialsAsync(context, selection);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/planHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"planHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/planHetznerComputeAsync.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,qFAAqF;AACrF,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,GAAoB,EACpB,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,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAClG,OAAO;QACL,EAAE,EAAE,IAAI;QACR,KAAK,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC1F,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,UAA+B,CAAC,CAAC;YAClF,MAAM,SAAS,GACb,OAAO,KAAK,SAAS;gBACnB,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.js';\nimport { projectHetznerCompute } from './projectHetznerCompute.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSelection, InfraExecutionContext } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerDesiredCompute } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerDesiredCompute } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Project one low-cost, single-node Hetzner compute target without runtime-specific behavior. */
|
|
4
4
|
export declare function projectHetznerCompute(context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>, sshPublicKey: string): HetznerDesiredCompute;
|
|
5
5
|
//# sourceMappingURL=projectHetznerCompute.d.ts.map
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAGjG,kGAAkG;AAClG,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,qBAAqB,CAAC,SAAS,CAAC,EAC3C,YAAY,EAAE,MAAM,GACnB,qBAAqB,CA+BvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import { createHetznerOwner, getHetznerIdentity } from '../utils/hetznerOwnership';
|
|
2
|
+
import { createHetznerOwner, getHetznerIdentity } from '../utils/hetznerOwnership.js';
|
|
3
3
|
/** Project one low-cost, single-node Hetzner compute target without runtime-specific behavior. */
|
|
4
4
|
export function projectHetznerCompute(context, selection, sshPublicKey) {
|
|
5
5
|
const identity = getHetznerIdentity(context);
|
|
@@ -1 +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,
|
|
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,8BAA8B,CAAC;AAEtF,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CACnC,OAA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AS,CAAC;QAC3B,MAAM,EAAE,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.js';\nimport { createHetznerOwner, getHetznerIdentity } from '../utils/hetznerOwnership.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeSelection, InfraExecutionContext, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerCloudApi } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerCloudApi } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/** Validate selection and control-plane access without creating cloud resources. */
|
|
4
4
|
export declare function validateHetznerComputeAsync(api: HetznerCloudApi, context: InfraExecutionContext, selection: InfraComputeSelection<'hetzner'>): Promise<InfraResult<null>>;
|
|
5
5
|
export declare function invalidSelection(): InfraResult<never>;
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAGxE,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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync';
|
|
1
|
+
import { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';
|
|
2
2
|
/** Validate selection and control-plane access without creating cloud resources. */
|
|
3
3
|
export async function validateHetznerComputeAsync(api, context, selection) {
|
|
4
4
|
if (context.desired.deployment.compute.provider !== 'hetzner')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/validateHetznerComputeAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"validateHetznerComputeAsync.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/application/validateHetznerComputeAsync.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,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.js';\nimport { resolveHetznerCredentialsAsync } from './resolveHetznerCredentialsAsync.js';\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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraComputeAdapter } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerAdapterOptions } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerAdapterOptions } from '../../../types/hetznerCompute.js';
|
|
3
3
|
/***
|
|
4
4
|
* Create the canonical Hetzner Cloud compute adapter.
|
|
5
5
|
*
|
|
@@ -1 +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
|
|
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,kCAAkC,CAAC;AAU9E;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,qBAA0B,GAClC,mBAAmB,CAAC,SAAS,CAAC,CAchC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { infraAdapterDescriptor } from '../../../constants/infra';
|
|
2
|
-
import { createFetchHetznerCloudApi } from '../adapters/outbound/createFetchHetznerCloudApi';
|
|
3
|
-
import { createNodeHetznerHostKeyProbe } from '../adapters/outbound/createNodeHetznerHostKeyProbe';
|
|
4
|
-
import { destroyHetznerComputeAsync } from '../application/destroyHetznerComputeAsync';
|
|
5
|
-
import { ensureHetznerComputeAsync } from '../application/ensureHetznerComputeAsync';
|
|
6
|
-
import { getHetznerComputeStatusAsync } from '../application/getHetznerComputeStatusAsync';
|
|
7
|
-
import { inspectHetznerComputeAsync } from '../application/inspectHetznerComputeAsync';
|
|
8
|
-
import { planHetznerComputeAsync } from '../application/planHetznerComputeAsync';
|
|
9
|
-
import { validateHetznerComputeAsync } from '../application/validateHetznerComputeAsync';
|
|
1
|
+
import { infraAdapterDescriptor } from '../../../constants/infra.js';
|
|
2
|
+
import { createFetchHetznerCloudApi } from '../adapters/outbound/createFetchHetznerCloudApi.js';
|
|
3
|
+
import { createNodeHetznerHostKeyProbe } from '../adapters/outbound/createNodeHetznerHostKeyProbe.js';
|
|
4
|
+
import { destroyHetznerComputeAsync } from '../application/destroyHetznerComputeAsync.js';
|
|
5
|
+
import { ensureHetznerComputeAsync } from '../application/ensureHetznerComputeAsync.js';
|
|
6
|
+
import { getHetznerComputeStatusAsync } from '../application/getHetznerComputeStatusAsync.js';
|
|
7
|
+
import { inspectHetznerComputeAsync } from '../application/inspectHetznerComputeAsync.js';
|
|
8
|
+
import { planHetznerComputeAsync } from '../application/planHetznerComputeAsync.js';
|
|
9
|
+
import { validateHetznerComputeAsync } from '../application/validateHetznerComputeAsync.js';
|
|
10
10
|
/***
|
|
11
11
|
* Create the canonical Hetzner Cloud compute adapter.
|
|
12
12
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInfraAdapter.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/composition/createInfraAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createInfraAdapter.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/composition/createInfraAdapter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EA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AE,OAAO,CAAC;QACpE,YAAY,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC,0BAA0B,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC;KACtF,CAAC;AACJ,CAAC","sourcesContent":["import type { InfraComputeAdapter } from '@ankhorage/contracts/infra';\n\nimport { infraAdapterDescriptor } from '../../../constants/infra.js';\nimport type { HetznerAdapterOptions } from '../../../types/hetznerCompute.js';\nimport { createFetchHetznerCloudApi } from '../adapters/outbound/createFetchHetznerCloudApi.js';\nimport { createNodeHetznerHostKeyProbe } from '../adapters/outbound/createNodeHetznerHostKeyProbe.js';\nimport { destroyHetznerComputeAsync } from '../application/destroyHetznerComputeAsync.js';\nimport { ensureHetznerComputeAsync } from '../application/ensureHetznerComputeAsync.js';\nimport { getHetznerComputeStatusAsync } from '../application/getHetznerComputeStatusAsync.js';\nimport { inspectHetznerComputeAsync } from '../application/inspectHetznerComputeAsync.js';\nimport { planHetznerComputeAsync } from '../application/planHetznerComputeAsync.js';\nimport { validateHetznerComputeAsync } from '../application/validateHetznerComputeAsync.js';\n\n/***\n * Create the canonical Hetzner Cloud compute adapter.\n *\n * The default composition uses the authenticated Cloud REST API and a shell-free SSH host-key\n * probe. Provider API and SSH credentials remain transient execution inputs.\n *\n * @readme\n */\nexport function createInfraAdapter(\n options: HetznerAdapterOptions = {},\n): InfraComputeAdapter<'hetzner'> {\n const api = options.api ?? createFetchHetznerCloudApi();\n const hostKeyProbe = options.hostKeyProbe ?? createNodeHetznerHostKeyProbe();\n return {\n descriptor: infraAdapterDescriptor,\n validateAsync: (context, selection) => validateHetznerComputeAsync(api, context, selection),\n inspectAsync: (context, selection) =>\n inspectHetznerComputeAsync(api, hostKeyProbe, context, selection),\n planAsync: (context, selection) => planHetznerComputeAsync(api, context, selection),\n ensureAsync: (context, selection) =>\n ensureHetznerComputeAsync(api, hostKeyProbe, context, selection),\n statusAsync: (context) => getHetznerComputeStatusAsync(api, context),\n destroyAsync: (context, request) => destroyHetznerComputeAsync(api, context, request),\n };\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { InfraExecutionContext, InfraOwnedResource } from '@ankhorage/contracts/infra';
|
|
2
|
-
import type { HetznerProjectIdentity, HetznerResourceId } from '../../../types/hetznerCompute';
|
|
2
|
+
import type { HetznerProjectIdentity, HetznerResourceId } from '../../../types/hetznerCompute.js';
|
|
3
3
|
export declare const HETZNER_LABELS: {
|
|
4
4
|
readonly project: "ankhorage.com/project";
|
|
5
5
|
readonly environment: "ankhorage.com/environment";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hetznerOwnership.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/utils/hetznerOwnership.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"hetznerOwnership.d.ts","sourceRoot":"","sources":["../../../../src/features/cloud-compute/utils/hetznerOwnership.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAE5F,OAAO,KAAK,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAElG,eAAO,MAAM,cAAc;;;;;;CAMjB,CAAC;AAEX,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,sBAAsB,EAChC,UAAU,EAAE,iBAAiB,GAC5B,kBAAkB,CAepB;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,sBAAsB,EAChC,UAAU,CAAC,EAAE,iBAAiB,EAC9B,iBAAiB,CAAC,EAAE,MAAM,GACzB,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAalC;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,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,WAAW;QAClD,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS;QACnC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;QAChF,GAAG,CAAC,iBAAiB,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAA8B;IAC/D,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\n\nimport type { InfraExecutionContext, InfraOwnedResource } from '@ankhorage/contracts/infra';\n\nimport type { HetznerProjectIdentity, HetznerResourceId } from '../../../types/hetznerCompute';\n\nexport const HETZNER_LABELS = {\n project: 'ankhorage.com/project',\n environment: 'ankhorage.com/environment',\n adapter: 'ankhorage.com/adapter',\n resourceId: 'ankhorage.com/resource-id',\n configurationHash: 'ankhorage.com/configuration-hash',\n} as const;\n\nexport function createHetznerOwner(\n identity: HetznerProjectIdentity,\n resourceId: HetznerResourceId,\n): InfraOwnedResource {\n const ownIdentity = { ...identity, adapter: 'hetzner' as const, resourceId };\n return {\n identity: ownIdentity,\n persistent: false,\n retention: 'delete-on-destroy',\n dependsOn:\n resourceId === 'server'\n ? (['network', 'firewall', 'ssh-key'] as const).map((dependency) => ({\n ...identity,\n adapter: 'hetzner' as const,\n resourceId: dependency,\n }))\n : [],\n };\n}\n\nexport function getHetznerLabels(\n identity: HetznerProjectIdentity,\n resourceId?: HetznerResourceId,\n configurationHash?: string,\n): Readonly<Record<string, string>> {\n return {\n [HETZNER_LABELS.project]: createHash('sha256')\n .update(identity.projectId)\n .digest('hex')\n .slice(0, 32),\n [HETZNER_LABELS.environment]: identity.environment,\n [HETZNER_LABELS.adapter]: 'hetzner',\n ...(resourceId === undefined ? {} : { [HETZNER_LABELS.resourceId]: resourceId }),\n ...(configurationHash === undefined\n ? {}\n : { [HETZNER_LABELS.configurationHash]: configurationHash }),\n };\n}\n\nexport function getHetznerIdentity(context: InfraExecutionContext): HetznerProjectIdentity {\n return { projectId: context.projectId, environment: context.environment };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hetznerOwnership.js","sourceRoot":"","sources":["../../../../src/features/cloud-compute/utils/hetznerOwnership.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMzC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,OAAO,EAAE,uBAAuB;IAChC,WAAW,EAAE,2BAA2B;IACxC,OAAO,EAAE,uBAAuB;IAChC,UAAU,EAAE,2BAA2B;IACvC,iBAAiB,EAAE,kCAAkC;CAC7C,CAAC;AAEX,MAAM,UAAU,kBAAkB,CAChC,QAAgC,EAChC,UAA6B;IAE7B,MAAM,WAAW,GAAG,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,SAAkB,EAAE,UAAU,EAAE,CAAC;IAC7E,OAAO;QACL,QAAQ,EAAE,WAAW;QACrB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,mBAAmB;QAC9B,SAAS,EACP,UAAU,KAAK,QAAQ;YACrB,CAAC,CAAE,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;gBACjE,GAAG,QAAQ;gBACX,OAAO,EAAE,SAAkB;gBAC3B,UAAU,EAAE,UAAU;aACvB,CAAC,CAAC;YACL,CAAC,CAAC,EAAE;KACT,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,QAAgC,EAChC,UAA8B,EAC9B,iBAA0B;IAE1B,OAAO;QACL,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,QAAQ,CAAC;aAC3C,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;aAC1B,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QACf,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,QAAQ,CAAC,WAAW;QAClD,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE,SAAS;QACnC,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;QAChF,GAAG,CAAC,iBAAiB,KAAK,SAAS;YACjC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,iBAAiB,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAA8B;IAC/D,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;AAC5E,CAAC","sourcesContent":["import { createHash } from 'node:crypto';\n\nimport type { InfraExecutionContext, InfraOwnedResource } from '@ankhorage/contracts/infra';\n\nimport type { HetznerProjectIdentity, HetznerResourceId } from '../../../types/hetznerCompute.js';\n\nexport const HETZNER_LABELS = {\n project: 'ankhorage.com/project',\n environment: 'ankhorage.com/environment',\n adapter: 'ankhorage.com/adapter',\n resourceId: 'ankhorage.com/resource-id',\n configurationHash: 'ankhorage.com/configuration-hash',\n} as const;\n\nexport function createHetznerOwner(\n identity: HetznerProjectIdentity,\n resourceId: HetznerResourceId,\n): InfraOwnedResource {\n const ownIdentity = { ...identity, adapter: 'hetzner' as const, resourceId };\n return {\n identity: ownIdentity,\n persistent: false,\n retention: 'delete-on-destroy',\n dependsOn:\n resourceId === 'server'\n ? (['network', 'firewall', 'ssh-key'] as const).map((dependency) => ({\n ...identity,\n adapter: 'hetzner' as const,\n resourceId: dependency,\n }))\n : [],\n };\n}\n\nexport function getHetznerLabels(\n identity: HetznerProjectIdentity,\n resourceId?: HetznerResourceId,\n configurationHash?: string,\n): Readonly<Record<string, string>> {\n return {\n [HETZNER_LABELS.project]: createHash('sha256')\n .update(identity.projectId)\n .digest('hex')\n .slice(0, 32),\n [HETZNER_LABELS.environment]: identity.environment,\n [HETZNER_LABELS.adapter]: 'hetzner',\n ...(resourceId === undefined ? {} : { [HETZNER_LABELS.resourceId]: resourceId }),\n ...(configurationHash === undefined\n ? {}\n : { [HETZNER_LABELS.configurationHash]: configurationHash }),\n };\n}\n\nexport function getHetznerIdentity(context: InfraExecutionContext): HetznerProjectIdentity {\n return { projectId: context.projectId, environment: context.environment };\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Public Hetzner Cloud compute adapter package boundary. */
|
|
2
|
-
export { infraAdapterDescriptor } from './constants/infra';
|
|
3
|
-
export { createFetchHetznerCloudApi } from './features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi';
|
|
4
|
-
export { createNodeHetznerHostKeyProbe } from './features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe';
|
|
5
|
-
export { createInfraAdapter } from './features/cloud-compute/composition/createInfraAdapter';
|
|
6
|
-
export type { HetznerAdapterOptions, HetznerCloudApi, HetznerCloudObservation, HetznerDesiredCompute, HetznerFetchApiOptions, HetznerHostKeyProbe, HetznerProjectIdentity, HetznerResourceId, HetznerResourceObservation, } from './types/hetznerCompute';
|
|
2
|
+
export { infraAdapterDescriptor } from './constants/infra.js';
|
|
3
|
+
export { createFetchHetznerCloudApi } from './features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js';
|
|
4
|
+
export { createNodeHetznerHostKeyProbe } from './features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js';
|
|
5
|
+
export { createInfraAdapter } from './features/cloud-compute/composition/createInfraAdapter.js';
|
|
6
|
+
export type { HetznerAdapterOptions, HetznerCloudApi, HetznerCloudObservation, HetznerDesiredCompute, HetznerFetchApiOptions, HetznerHostKeyProbe, HetznerProjectIdentity, HetznerResourceId, HetznerResourceObservation, } from './types/hetznerCompute.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,6BAA6B,EAAE,MAAM,6EAA6E,CAAC;AAC5H,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC;AAChG,YAAY,EACV,qBAAqB,EACrB,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Public Hetzner Cloud compute adapter package boundary. */
|
|
2
|
-
export { infraAdapterDescriptor } from './constants/infra';
|
|
3
|
-
export { createFetchHetznerCloudApi } from './features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi';
|
|
4
|
-
export { createNodeHetznerHostKeyProbe } from './features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe';
|
|
5
|
-
export { createInfraAdapter } from './features/cloud-compute/composition/createInfraAdapter';
|
|
2
|
+
export { infraAdapterDescriptor } from './constants/infra.js';
|
|
3
|
+
export { createFetchHetznerCloudApi } from './features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js';
|
|
4
|
+
export { createNodeHetznerHostKeyProbe } from './features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js';
|
|
5
|
+
export { createInfraAdapter } from './features/cloud-compute/composition/createInfraAdapter.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,0EAA0E,CAAC;AACtH,OAAO,EAAE,6BAA6B,EAAE,MAAM,6EAA6E,CAAC;AAC5H,OAAO,EAAE,kBAAkB,EAAE,MAAM,4DAA4D,CAAC","sourcesContent":["/** Public Hetzner Cloud compute adapter package boundary. */\nexport { infraAdapterDescriptor } from './constants/infra.js';\nexport { createFetchHetznerCloudApi } from './features/cloud-compute/adapters/outbound/createFetchHetznerCloudApi.js';\nexport { createNodeHetznerHostKeyProbe } from './features/cloud-compute/adapters/outbound/createNodeHetznerHostKeyProbe.js';\nexport { createInfraAdapter } from './features/cloud-compute/composition/createInfraAdapter.js';\nexport type {\n HetznerAdapterOptions,\n HetznerCloudApi,\n HetznerCloudObservation,\n HetznerDesiredCompute,\n HetznerFetchApiOptions,\n HetznerHostKeyProbe,\n HetznerProjectIdentity,\n HetznerResourceId,\n HetznerResourceObservation,\n} from './types/hetznerCompute.js';\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ankhorage/infra-hetzner",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"description": "Hetzner Cloud compute adapter for provider-neutral Ankhorage infrastructure.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"typecheck": "bun x tsc --noEmit -p tsconfig.json",
|
|
44
44
|
"check-types": "bun run typecheck",
|
|
45
45
|
"test": "bun test src",
|
|
46
|
+
"test:packed-consumer": "bun consumer-tests/packedConsumer.ts",
|
|
46
47
|
"docs": "paradox && ankhorage-prettier --write README.md paradox",
|
|
47
48
|
"prepack": "bun run build",
|
|
48
49
|
"lint": "ankhorage-eslint . --max-warnings=0",
|
|
@@ -55,13 +56,13 @@
|
|
|
55
56
|
"version-packages": "ankhorage-changeset version"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@ankhorage/contracts": "^
|
|
59
|
+
"@ankhorage/contracts": "^26.13.0"
|
|
59
60
|
},
|
|
60
61
|
"devDependencies": {
|
|
61
|
-
"@ankhorage/devtools": "^2.
|
|
62
|
-
"@ankhorage/paradox": "
|
|
62
|
+
"@ankhorage/devtools": "^2.10.0",
|
|
63
|
+
"@ankhorage/paradox": "0.6.0",
|
|
63
64
|
"@types/bun": "^1.4.2",
|
|
64
|
-
"@types/node": "^26.6.
|
|
65
|
+
"@types/node": "^26.6.6",
|
|
65
66
|
"typescript": "~6.0.3"
|
|
66
67
|
},
|
|
67
68
|
"packageManager": "bun@1.4.2"
|