@stacksjs/ts-cloud 0.7.40 → 0.7.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/cli.js +268 -268
  3. package/dist/{chunk-d2p5n2aq.js → chunk-5snr8g8q.js} +2 -2
  4. package/dist/{chunk-tt4kxske.js → chunk-602g36gf.js} +49 -18
  5. package/dist/{chunk-ndwv4y6c.js → chunk-7z3tf1mj.js} +41 -2
  6. package/dist/{chunk-d7p84vz5.js → chunk-9n57qng8.js} +3 -3
  7. package/dist/deploy/index.d.ts +1 -0
  8. package/dist/deploy/index.js +7 -3
  9. package/dist/dns/index.js +1 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +7 -3
  12. package/dist/ui/index.html +3 -3
  13. package/dist/ui/server/actions.html +3 -3
  14. package/dist/ui/server/backups.html +3 -3
  15. package/dist/ui/server/database.html +3 -3
  16. package/dist/ui/server/deployments.html +3 -3
  17. package/dist/ui/server/firewall.html +3 -3
  18. package/dist/ui/server/logs.html +3 -3
  19. package/dist/ui/server/services.html +3 -3
  20. package/dist/ui/server/sites.html +3 -3
  21. package/dist/ui/server/ssh-keys.html +3 -3
  22. package/dist/ui/server/team.html +3 -3
  23. package/dist/ui/server/terminal.html +3 -3
  24. package/dist/ui/server/workers.html +3 -3
  25. package/dist/ui/serverless/alarms.html +3 -3
  26. package/dist/ui/serverless/assets.html +3 -3
  27. package/dist/ui/serverless/data.html +3 -3
  28. package/dist/ui/serverless/deployments.html +3 -3
  29. package/dist/ui/serverless/functions.html +3 -3
  30. package/dist/ui/serverless/logs.html +3 -3
  31. package/dist/ui/serverless/queues.html +3 -3
  32. package/dist/ui/serverless/scheduler.html +3 -3
  33. package/dist/ui/serverless/secrets.html +3 -3
  34. package/dist/ui/serverless/traces.html +3 -3
  35. package/dist/ui/serverless.html +3 -3
  36. package/package.json +3 -3
@@ -5,9 +5,9 @@ import {
5
5
  generateStaticSiteTemplate,
6
6
  invalidateCache,
7
7
  uploadStaticFiles
8
- } from "./chunk-d7p84vz5.js";
8
+ } from "./chunk-9n57qng8.js";
9
9
  import"./chunk-tjjgajbh.js";
10
- import"./chunk-tt4kxske.js";
10
+ import"./chunk-602g36gf.js";
11
11
  import"./chunk-tnztxpcb.js";
12
12
  import"./chunk-qpj3edwz.js";
13
13
  import"./chunk-vd87cpvn.js";
@@ -6,6 +6,16 @@ import {
6
6
  } from "./chunk-arsh1g5h.js";
7
7
  // src/dns/porkbun.ts
8
8
  var PORKBUN_API_URL = "https://api.porkbun.com/api/json/v3";
9
+ var PORKBUN_MAX_ATTEMPTS = 8;
10
+ function isRetryablePorkbunResponse(status, message = "") {
11
+ return status === 408 || status === 409 || status === 425 || status === 429 || status >= 500 || /rate limit|temporar|timed? ?out|try again/i.test(message);
12
+ }
13
+ async function waitForPorkbunRetry(attempt, response) {
14
+ const retryAfter = response?.headers.get("retry-after");
15
+ const retryAfterMs = retryAfter === null || retryAfter === undefined ? undefined : Number(retryAfter) * 1000;
16
+ const delay = Number.isFinite(retryAfterMs) ? Math.max(0, retryAfterMs) : Math.min(1000 * 2 ** (attempt - 1), 30000);
17
+ await new Promise((resolve) => setTimeout(resolve, delay));
18
+ }
9
19
 
10
20
  class PorkbunProvider {
11
21
  name = "porkbun";
@@ -16,25 +26,46 @@ class PorkbunProvider {
16
26
  this.secretKey = secretKey;
17
27
  }
18
28
  async request(endpoint, additionalBody = {}) {
19
- const response = await fetch(`${PORKBUN_API_URL}${endpoint}`, {
20
- method: "POST",
21
- headers: {
22
- "Content-Type": "application/json"
23
- },
24
- body: JSON.stringify({
25
- apikey: this.apiKey,
26
- secretapikey: this.secretKey,
27
- ...additionalBody
28
- })
29
- });
30
- if (!response.ok) {
31
- throw new Error(`Porkbun API error: ${response.status} ${response.statusText}`);
32
- }
33
- const data = await response.json();
34
- if (data.status === "ERROR") {
35
- throw new Error(`Porkbun API error: ${data.message || "Unknown error"}`);
29
+ let lastError;
30
+ for (let attempt = 1;attempt <= PORKBUN_MAX_ATTEMPTS; attempt += 1) {
31
+ let response;
32
+ try {
33
+ response = await fetch(`${PORKBUN_API_URL}${endpoint}`, {
34
+ method: "POST",
35
+ headers: {
36
+ "Content-Type": "application/json"
37
+ },
38
+ body: JSON.stringify({
39
+ apikey: this.apiKey,
40
+ secretapikey: this.secretKey,
41
+ ...additionalBody
42
+ })
43
+ });
44
+ } catch (error) {
45
+ lastError = error;
46
+ if (attempt === PORKBUN_MAX_ATTEMPTS)
47
+ throw error;
48
+ await waitForPorkbunRetry(attempt);
49
+ continue;
50
+ }
51
+ if (!response.ok) {
52
+ lastError = new Error(`Porkbun API error: ${response.status} ${response.statusText}`);
53
+ if (!isRetryablePorkbunResponse(response.status) || attempt === PORKBUN_MAX_ATTEMPTS)
54
+ throw lastError;
55
+ await waitForPorkbunRetry(attempt, response);
56
+ continue;
57
+ }
58
+ const data = await response.json();
59
+ if (data.status === "ERROR") {
60
+ lastError = new Error(`Porkbun API error: ${data.message || "Unknown error"}`);
61
+ if (!isRetryablePorkbunResponse(0, data.message) || attempt === PORKBUN_MAX_ATTEMPTS)
62
+ throw lastError;
63
+ await waitForPorkbunRetry(attempt, response);
64
+ continue;
65
+ }
66
+ return data;
36
67
  }
37
- return data;
68
+ throw lastError;
38
69
  }
39
70
  getSubdomain(recordName, domain) {
40
71
  const cleanName = recordName.replace(/\.$/, "");
@@ -47,7 +47,7 @@ import {
47
47
  } from "./chunk-stt1z5cx.js";
48
48
  import {
49
49
  deployStaticSiteWithExternalDnsFull
50
- } from "./chunk-d7p84vz5.js";
50
+ } from "./chunk-9n57qng8.js";
51
51
  import {
52
52
  CloudFrontClient
53
53
  } from "./chunk-tjjgajbh.js";
@@ -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 };
@@ -7,7 +7,7 @@ import {
7
7
  Route53Provider,
8
8
  UnifiedDnsValidator,
9
9
  createDnsProvider
10
- } from "./chunk-tt4kxske.js";
10
+ } from "./chunk-602g36gf.js";
11
11
  import {
12
12
  Route53Client
13
13
  } from "./chunk-tnztxpcb.js";
@@ -813,7 +813,7 @@ async function deployStaticSiteWithExternalDnsFull(config) {
813
813
  }
814
814
  }
815
815
  onProgress?.("upload", "Uploading files to S3...");
816
- const { uploadStaticFiles } = await import("./chunk-d2p5n2aq.js");
816
+ const { uploadStaticFiles } = await import("./chunk-5snr8g8q.js");
817
817
  const uploadResult = await uploadStaticFiles({
818
818
  sourceDir,
819
819
  bucket: infraResult.bucket,
@@ -833,7 +833,7 @@ async function deployStaticSiteWithExternalDnsFull(config) {
833
833
  }
834
834
  if (infraResult.distributionId && uploadResult.uploaded > 0) {
835
835
  onProgress?.("invalidate", "Invalidating CloudFront cache...");
836
- const { invalidateCache } = await import("./chunk-d2p5n2aq.js");
836
+ const { invalidateCache } = await import("./chunk-5snr8g8q.js");
837
837
  await invalidateCache(infraResult.distributionId);
838
838
  }
839
839
  onProgress?.("complete", "Deployment complete!");
@@ -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-7z3tf1mj.js";
16
18
  import {
17
19
  buildAndPushServerlessImage
18
20
  } from "../chunk-tskj9fay.js";
@@ -43,9 +45,9 @@ import {
43
45
  generateStaticSiteTemplate,
44
46
  invalidateCache,
45
47
  uploadStaticFiles
46
- } from "../chunk-d7p84vz5.js";
48
+ } from "../chunk-9n57qng8.js";
47
49
  import"../chunk-tjjgajbh.js";
48
- import"../chunk-tt4kxske.js";
50
+ import"../chunk-602g36gf.js";
49
51
  import"../chunk-tnztxpcb.js";
50
52
  import"../chunk-qpj3edwz.js";
51
53
  import"../chunk-vd87cpvn.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,
package/dist/dns/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  createRoute53Validator,
12
12
  detectDnsProvider,
13
13
  dnsProviders
14
- } from "../chunk-tt4kxske.js";
14
+ } from "../chunk-602g36gf.js";
15
15
  import"../chunk-tnztxpcb.js";
16
16
  import"../chunk-arsh1g5h.js";
17
17
  import"../chunk-v0bahtg2.js";
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-7z3tf1mj.js";
59
61
  import {
60
62
  buildAndPushServerlessImage
61
63
  } from "./chunk-tskj9fay.js";
@@ -526,7 +528,7 @@ import {
526
528
  generateStaticSiteTemplate,
527
529
  invalidateCache,
528
530
  uploadStaticFiles
529
- } from "./chunk-d7p84vz5.js";
531
+ } from "./chunk-9n57qng8.js";
530
532
  import {
531
533
  CloudFrontClient
532
534
  } from "./chunk-tjjgajbh.js";
@@ -544,7 +546,7 @@ import {
544
546
  createRoute53Validator,
545
547
  detectDnsProvider,
546
548
  dnsProviders
547
- } from "./chunk-tt4kxske.js";
549
+ } from "./chunk-602g36gf.js";
548
550
  import {
549
551
  Route53Client
550
552
  } from "./chunk-tnztxpcb.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,