@stacksjs/ts-cloud 0.7.41 → 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.
@@ -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";
@@ -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!");
@@ -14,7 +14,7 @@ import {
14
14
  sanitizeCloudConfig,
15
15
  setMaintenance,
16
16
  startLocalDashboardServer
17
- } from "../chunk-5pf5n3x1.js";
17
+ } from "../chunk-7z3tf1mj.js";
18
18
  import {
19
19
  buildAndPushServerlessImage
20
20
  } from "../chunk-tskj9fay.js";
@@ -45,9 +45,9 @@ import {
45
45
  generateStaticSiteTemplate,
46
46
  invalidateCache,
47
47
  uploadStaticFiles
48
- } from "../chunk-d7p84vz5.js";
48
+ } from "../chunk-9n57qng8.js";
49
49
  import"../chunk-tjjgajbh.js";
50
- import"../chunk-tt4kxske.js";
50
+ import"../chunk-602g36gf.js";
51
51
  import"../chunk-tnztxpcb.js";
52
52
  import"../chunk-qpj3edwz.js";
53
53
  import"../chunk-vd87cpvn.js";
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.js CHANGED
@@ -57,7 +57,7 @@ import {
57
57
  sanitizeCloudConfig,
58
58
  setMaintenance,
59
59
  startLocalDashboardServer
60
- } from "./chunk-5pf5n3x1.js";
60
+ } from "./chunk-7z3tf1mj.js";
61
61
  import {
62
62
  buildAndPushServerlessImage
63
63
  } from "./chunk-tskj9fay.js";
@@ -528,7 +528,7 @@ import {
528
528
  generateStaticSiteTemplate,
529
529
  invalidateCache,
530
530
  uploadStaticFiles
531
- } from "./chunk-d7p84vz5.js";
531
+ } from "./chunk-9n57qng8.js";
532
532
  import {
533
533
  CloudFrontClient
534
534
  } from "./chunk-tjjgajbh.js";
@@ -546,7 +546,7 @@ import {
546
546
  createRoute53Validator,
547
547
  detectDnsProvider,
548
548
  dnsProviders
549
- } from "./chunk-tt4kxske.js";
549
+ } from "./chunk-602g36gf.js";
550
550
  import {
551
551
  Route53Client
552
552
  } from "./chunk-tnztxpcb.js";