@stacksjs/ts-cloud 0.7.39 → 0.7.41

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.
@@ -64,6 +64,45 @@ import {
64
64
  import {
65
65
  __require
66
66
  } from "./chunk-v0bahtg2.js";
67
+ // src/deploy/server-dns.ts
68
+ function collectServerDnsDomains(sites = {}) {
69
+ const domains = new Set;
70
+ for (const site of Object.values(sites)) {
71
+ if (!site.domain)
72
+ continue;
73
+ if (site.redirect || site.deploy === "server" || site.start)
74
+ domains.add(site.domain);
75
+ }
76
+ return domains;
77
+ }
78
+ function normalizeName(name) {
79
+ return name.replace(/\.$/, "").toLowerCase();
80
+ }
81
+ function matchesHostname(record, zone, hostname) {
82
+ const recordName = normalizeName(record.name);
83
+ const normalizedZone = normalizeName(zone);
84
+ const normalizedHostname = normalizeName(hostname);
85
+ const relativeName = normalizedHostname === normalizedZone ? "@" : normalizedHostname.endsWith(`.${normalizedZone}`) ? normalizedHostname.slice(0, -(normalizedZone.length + 1)) : normalizedHostname;
86
+ return recordName === normalizedHostname || recordName === relativeName || relativeName === "@" && (recordName === "" || recordName === normalizedZone);
87
+ }
88
+ async function removeStaleServerAddressRecords(provider, zone, hostname, desiredAddress) {
89
+ const listed = await provider.listRecords(zone);
90
+ if (!listed.success)
91
+ return [`could not list A records: ${listed.message || "unknown provider error"}`];
92
+ const matching = listed.records.filter((record) => record.type === "A" && matchesHostname(record, zone, hostname));
93
+ const desiredIndex = matching.findIndex((record) => record.content === desiredAddress);
94
+ if (matching.length <= 1 || desiredIndex === -1)
95
+ return [];
96
+ const warnings = [];
97
+ for (const [index, record] of matching.entries()) {
98
+ if (index === desiredIndex)
99
+ continue;
100
+ const result = await provider.deleteRecord(zone, record);
101
+ if (!result.success)
102
+ warnings.push(`could not remove stale ${record.name} A ${record.content}: ${result.message || "unknown provider error"}`);
103
+ }
104
+ return warnings;
105
+ }
67
106
  // src/deploy/static-site-helper.ts
68
107
  import process2 from "node:process";
69
108
  import { existsSync } from "node:fs";
@@ -13677,4 +13716,4 @@ async function startLocalDashboardServer(options = {}) {
13677
13716
  });
13678
13717
  return { server, url: `http://${host}:${server.port}/` };
13679
13718
  }
13680
- export { defaultConfig4 as defaultConfig, getConfig, loadCloudConfig, config5 as config, deploySite, infraEnvFromOutputs, buildFunctionEnv, deployServerlessApp, redeployServerlessApp, rollbackServerlessApp, setMaintenance, runRemoteCommand, resolveDashboardData, sanitizeCloudConfig, dashboardActions, resolveDashboardAction, startLocalDashboardServer };
13719
+ export { defaultConfig4 as defaultConfig, getConfig, loadCloudConfig, config5 as config, collectServerDnsDomains, removeStaleServerAddressRecords, deploySite, infraEnvFromOutputs, buildFunctionEnv, deployServerlessApp, redeployServerlessApp, rollbackServerlessApp, setMaintenance, runRemoteCommand, resolveDashboardData, sanitizeCloudConfig, dashboardActions, resolveDashboardAction, startLocalDashboardServer };
@@ -3,6 +3,7 @@
3
3
  * High-level deployment functions for common AWS architectures
4
4
  */
5
5
  export * from './site-target';
6
+ export * from './server-dns';
6
7
  export * from './static-site';
7
8
  export * from './static-site-external-dns';
8
9
  export * from './static-site-helper';
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  buildFunctionEnv,
3
+ collectServerDnsDomains,
3
4
  dashboardActions,
4
5
  deployServerlessApp,
5
6
  deploySite,
6
7
  infraEnvFromOutputs,
7
8
  redeployServerlessApp,
9
+ removeStaleServerAddressRecords,
8
10
  resolveDashboardAction,
9
11
  resolveDashboardData,
10
12
  rollbackServerlessApp,
@@ -12,7 +14,7 @@ import {
12
14
  sanitizeCloudConfig,
13
15
  setMaintenance,
14
16
  startLocalDashboardServer
15
- } from "../chunk-ndwv4y6c.js";
17
+ } from "../chunk-5pf5n3x1.js";
16
18
  import {
17
19
  buildAndPushServerlessImage
18
20
  } from "../chunk-tskj9fay.js";
@@ -66,6 +68,7 @@ export {
66
68
  resolveDashboardData,
67
69
  resolveDashboardAuth,
68
70
  resolveDashboardAction,
71
+ removeStaleServerAddressRecords,
69
72
  redeployServerlessApp,
70
73
  isPhpSite,
71
74
  invalidateCache,
@@ -81,6 +84,7 @@ export {
81
84
  deployServerlessApp,
82
85
  deleteStaticSite,
83
86
  dashboardActions,
87
+ collectServerDnsDomains,
84
88
  buildManagementDashboardArtifact,
85
89
  buildFunctionEnv,
86
90
  buildAndPushServerlessImage,
@@ -0,0 +1,16 @@
1
+ import type { DnsProvider } from '../dns/types';
2
+ interface ServerSite {
3
+ domain?: string;
4
+ deploy?: string;
5
+ redirect?: string;
6
+ start?: string;
7
+ }
8
+ /** Domains served by a compute box, including redirect-only virtual hosts. */
9
+ export declare function collectServerDnsDomains(sites?: Record<string, ServerSite>): Set<string>;
10
+ /**
11
+ * A compute deployment owns one address per managed hostname. After an upsert,
12
+ * remove only duplicate A records for that exact hostname, preserving one copy
13
+ * of the desired address and leaving every unrelated record untouched.
14
+ */
15
+ export declare function removeStaleServerAddressRecords(provider: DnsProvider, zone: string, hostname: string, desiredAddress: string): Promise<string[]>;
16
+ export {};
package/dist/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { keyMatchesFilters, migrateObjectStorage, remapKey, } from './object-sto
10
10
  export type { MigrateEndpoint, MigrateError, MigrateOptions, MigratePlanItem, MigrateProgress, MigrateResult, MigrateVerification, } from './object-storage/migrate';
11
11
  export * from './ssl';
12
12
  export { deployStaticSite, deployStaticSiteFull, uploadStaticFiles, invalidateCache, deleteStaticSite, generateStaticSiteTemplate, deployStaticSiteWithExternalDns, deployStaticSiteWithExternalDnsFull, generateExternalDnsStaticSiteTemplate, deploySite, resolveSiteDeployTarget, resolveSiteKind, validateDeploymentConfig, buildAndPushServerlessImage, buildFunctionEnv, deployServerlessApp, infraEnvFromOutputs, redeployServerlessApp, rollbackServerlessApp, runRemoteCommand, setMaintenance, buildManagementDashboardArtifact, DASHBOARD_CREDENTIALS_FILE, ensureManagementDashboard, MANAGEMENT_DASHBOARD_SITE, resolveDashboardAuth, resolveUiSource, } from './deploy';
13
+ export { collectServerDnsDomains, removeStaleServerAddressRecords, } from './deploy/server-dns';
13
14
  export type { EnsureDashboardLogger, ResolvedDashboardAuth, StaticSiteConfig, DeployResult, UploadOptions, ExternalDnsStaticSiteConfig, ExternalDnsDeployResult, DeploySiteConfig, DeploySiteResult, StaticSiteDnsProvider, SiteDeployKind, DeploymentValidationResult, BuildImageOptions, BuiltImage, CodeSource, DeployServerlessOptions, ResolvedContext, } from './deploy';
14
15
  export { createCloudDriver, CloudDriverFactory, cloudDrivers, AwsDriver, HetznerDriver, HetznerClient, resolveHetznerApiToken, normalizeSshPublicKey, ensureFirewall, ensureServer, ensureSshKey, serverPublicIpv4, sshExec, sshExecOrThrow, scpUpload, waitForSsh, waitForCloudInit, buildSshArgs, generateUbuntuAppCloudInit, wrapCloudInitUserData, buildHostCleanupScript, buildSiteDeployScript, buildStaticSiteDeployScript, resolveExecStart, deployAllComputeSites, deploySiteRelease, } from './drivers';
15
16
  export type { CreateCloudDriverOptions } from './drivers/factory';
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ import {
40
40
  } from "./chunk-zn0nxxa8.js";
41
41
  import {
42
42
  buildFunctionEnv,
43
+ collectServerDnsDomains,
43
44
  config,
44
45
  dashboardActions,
45
46
  defaultConfig,
@@ -49,13 +50,14 @@ import {
49
50
  infraEnvFromOutputs,
50
51
  loadCloudConfig,
51
52
  redeployServerlessApp,
53
+ removeStaleServerAddressRecords,
52
54
  resolveDashboardAction,
53
55
  rollbackServerlessApp,
54
56
  runRemoteCommand,
55
57
  sanitizeCloudConfig,
56
58
  setMaintenance,
57
59
  startLocalDashboardServer
58
- } from "./chunk-ndwv4y6c.js";
60
+ } from "./chunk-5pf5n3x1.js";
59
61
  import {
60
62
  buildAndPushServerlessImage
61
63
  } from "./chunk-tskj9fay.js";
@@ -4735,6 +4737,7 @@ export {
4735
4737
  resolveApp,
4736
4738
  requiresReplacement,
4737
4739
  replicaManager,
4740
+ removeStaleServerAddressRecords,
4738
4741
  remapKey,
4739
4742
  regionPairManager,
4740
4743
  redeployServerlessApp,
@@ -4946,6 +4949,7 @@ export {
4946
4949
  config,
4947
4950
  composeServerlessAppTemplate,
4948
4951
  composePresets,
4952
+ collectServerDnsDomains,
4949
4953
  collectPhpAppEntries,
4950
4954
  cloudTrailManager,
4951
4955
  cloudDrivers,